0
|
1 ;;; x-menubar.el --- Menubar and popup-menu support for X.
|
|
2
|
|
3 ;; Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
|
|
4 ;; Copyright (C) 1995 Tinker Systems and INS Engineering Corp.
|
|
5 ;; Copyright (C) 1995 Sun Microsystems.
|
|
6 ;; Copyright (C) 1995, 1996 Ben Wing.
|
|
7
|
|
8 ;; This file is part of XEmacs.
|
|
9
|
|
10 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
11 ;; under the terms of the GNU General Public License as published by
|
|
12 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
13 ;; any later version.
|
|
14
|
|
15 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
18 ;; General Public License for more details.
|
|
19
|
|
20 ;; You should have received a copy of the GNU General Public License
|
70
|
21 ;; along with Xmacs; see the file COPYING. If not, write to the
|
|
22 ;; Free Software Foundation, 59 Temple Place - Suite 330,
|
|
23 ;; Boston, MA 02111-1307, USA.
|
0
|
24
|
|
25 ;;; Commentary:
|
|
26
|
|
27 ;;; Code:
|
|
28
|
70
|
29 ;;; Warning-free compile
|
|
30 (eval-when-compile
|
|
31 (defvar language-environment-list))
|
|
32
|
0
|
33 (defconst default-menubar
|
|
34 (purecopy-menubar
|
|
35 ;; note backquote.
|
|
36 `(
|
|
37 ("File"
|
|
38 :filter file-menu-filter
|
|
39 ["Open..." find-file t]
|
|
40 ["Open in Other Window..." find-file-other-window t]
|
|
41 ["Open in New Frame..." find-file-other-frame t]
|
|
42 ["Insert File..." insert-file t]
|
|
43 ["View File..." view-file t]
|
|
44 "------"
|
|
45 ["Save" save-buffer t nil]
|
|
46 ["Save As..." write-file t]
|
|
47 ["Save Some Buffers" save-some-buffers t]
|
|
48 "-----"
|
|
49 ["Print Buffer" lpr-buffer t nil]
|
|
50 ["Pretty-Print Buffer" ps-print-buffer-with-faces t nil]
|
|
51 "-----"
|
|
52 ["New Frame" make-frame t]
|
|
53 ["Frame on Other Display..."
|
|
54 make-frame-on-display t]
|
|
55 ["Delete Frame" delete-frame t]
|
|
56 "-----"
|
|
57 ["Split Window" split-window-vertically t]
|
|
58 ["Un-Split (Keep This)" delete-other-windows (not (one-window-p t))]
|
|
59 ["Un-Split (Keep Others)" delete-window (not (one-window-p t))]
|
|
60 "-----"
|
|
61 ["Revert Buffer" revert-buffer t nil]
|
|
62 ["Delete Buffer" kill-this-buffer t nil]
|
|
63 "-----"
|
|
64 ["Exit XEmacs" save-buffers-kill-emacs t]
|
|
65 )
|
|
66
|
|
67 ("Edit"
|
|
68 :filter edit-menu-filter
|
|
69 ["Undo" advertised-undo t]
|
|
70 ["Cut" x-kill-primary-selection t]
|
|
71 ["Copy" x-copy-primary-selection t]
|
|
72 ["Paste" x-yank-clipboard-selection t]
|
|
73 ["Clear" x-delete-primary-selection t]
|
|
74 "----"
|
|
75 ["Search..." isearch-forward t]
|
|
76 ["Search Backward..." isearch-backward t]
|
|
77 ["Replace..." query-replace t]
|
|
78 "----"
|
|
79 ["Search (Regexp)..." isearch-forward-regexp t]
|
|
80 ["Search Backward (Regexp)..." isearch-backward-regexp t]
|
|
81 ["Replace (Regexp)..." query-replace-regexp t]
|
|
82 "----"
|
|
83 ("Bookmarks"
|
70
|
84 ["Jump to bookmark" bookmark-menu-jump t]
|
|
85 ["Set bookmark" bookmark-set t]
|
0
|
86 "---"
|
70
|
87 ["Insert contents" bookmark-menu-insert t]
|
|
88 ["Insert location" bookmark-menu-locate t]
|
0
|
89 "---"
|
70
|
90 ["Rename bookmark" bookmark-menu-rename t]
|
|
91 ["Delete bookmark" bookmark-menu-delete t]
|
|
92 ["Edit Bookmark List" bookmark-bmenu-list t]
|
0
|
93 "---"
|
70
|
94 ["Save bookmarks" bookmark-save t]
|
|
95 ["Save bookmarks as..." bookmark-write t]
|
|
96 ["Load a bookmark file" bookmark-load t])
|
0
|
97 "----"
|
|
98 ["Goto Line..." goto-line t]
|
|
99 ["What Line" what-line t]
|
|
100 "----"
|
|
101 ["Start Macro Recording" start-kbd-macro (not defining-kbd-macro)]
|
|
102 ["End Macro Recording" end-kbd-macro defining-kbd-macro]
|
|
103 ["Execute Last Macro" call-last-kbd-macro last-kbd-macro]
|
|
104 )
|
|
105
|
|
106 ("Apps"
|
|
107 ["Read Mail (VM)..." vm t]
|
|
108 ["Read Mail (MH)..." (mh-rmail t) t]
|
|
109 ["Send mail..." mail t]
|
|
110 ["Usenet News" gnus t]
|
|
111 ["Browse the Web" w3 t]
|
|
112 ["Gopher" gopher t]
|
|
113 ["Hyperbole..." hyperbole t]
|
|
114 "----"
|
|
115 ["Spell-Check Buffer" ispell-buffer t]
|
|
116 ["Emulate VI" viper-mode t]
|
|
117 "----"
|
|
118 ("Calendar"
|
|
119 ["3-Month Calendar" calendar t]
|
|
120 ["Diary" diary t]
|
|
121 ["Holidays" holidays t]
|
|
122 ;; we're all pagans at heart ...
|
|
123 ["Phases of the Moon" phases-of-moon t]
|
|
124 ["Sunrise/Sunset" sunrise-sunset t]
|
|
125 )
|
|
126 ("Games"
|
|
127 ["Quote from Zippy" yow t]
|
|
128 ["Psychoanalyst" doctor t]
|
|
129 ["Psychoanalyze Zippy!" psychoanalyze-pinhead t]
|
|
130 ["Random Flames" flame t]
|
|
131 ["Dunnet (Adventure)" dunnet t]
|
|
132 ["Towers of Hanoi" hanoi t]
|
|
133 ["Game of Life" life t]
|
|
134 ["Multiplication Puzzle" mpuz t]
|
|
135 )
|
|
136 )
|
|
137
|
|
138 ("Options"
|
|
139 ["Read Only" (toggle-read-only)
|
|
140 :style toggle :selected buffer-read-only]
|
|
141 ("Editing Options"
|
|
142 ["Overstrike" (progn
|
|
143 (overwrite-mode current-prefix-arg)
|
|
144 (setq-default overwrite-mode overwrite-mode))
|
|
145 :style toggle :selected overwrite-mode]
|
|
146 ["Case Sensitive Search" (progn
|
|
147 (setq case-fold-search (not case-fold-search))
|
|
148 (setq-default case-fold-search
|
|
149 case-fold-search))
|
|
150 :style toggle :selected (not case-fold-search)]
|
|
151 ["Case Matching Replace" (setq case-replace (not case-replace))
|
|
152 :style toggle :selected case-replace]
|
|
153 ["Auto Delete Selection" (if (memq 'pending-delete-pre-hook
|
|
154 pre-command-hook)
|
|
155 (pending-delete-off nil)
|
|
156 (pending-delete-on nil))
|
|
157 :style toggle
|
|
158 :selected (memq 'pending-delete-pre-hook pre-command-hook)]
|
|
159 ["Active Regions" (setq zmacs-regions (not zmacs-regions))
|
|
160 :style toggle :selected zmacs-regions]
|
|
161 ["Mouse Paste At Text Cursor" (setq mouse-yank-at-point
|
|
162 (not mouse-yank-at-point))
|
|
163 :style toggle :selected mouse-yank-at-point]
|
|
164 )
|
|
165 ("General Options"
|
|
166 ["Teach Extended Commands" (setq teach-extended-commands-p
|
|
167 (not teach-extended-commands-p))
|
|
168 :style toggle :selected teach-extended-commands-p]
|
|
169 ["Debug On Error" (setq debug-on-error (not debug-on-error))
|
|
170 :style toggle :selected debug-on-error]
|
|
171 ["Debug On Quit" (setq debug-on-quit (not debug-on-quit))
|
|
172 :style toggle :selected debug-on-quit]
|
|
173 )
|
|
174 ("Printing Options"
|
|
175 ["Command-Line Switches for `lpr'/`lp'..."
|
2
|
176 (setq lpr-switches
|
|
177 (read-expression "Switches for `lpr'/`lp': "
|
|
178 (format "%S" lpr-switches)))
|
0
|
179 t]
|
70
|
180 ["Pretty-Print With Color"
|
|
181 (setq ps-print-color-p (not ps-print-color-p))
|
|
182 :style toggle :selected ps-print-color-p]
|
0
|
183 ("Pretty-Print Paper Size"
|
|
184 ["Letter"
|
70
|
185 (setq ps-paper-type 'ps-letter)
|
0
|
186 :style radio
|
70
|
187 :selected (eq ps-paper-type 'ps-letter)]
|
|
188 ["Legal"
|
|
189 (setq ps-paper-type 'ps-legal)
|
16
|
190 :style radio
|
70
|
191 :selected (eq ps-paper-type 'ps-legal)]
|
0
|
192 ["A4"
|
70
|
193 (setq ps-paper-type 'ps-a4)
|
0
|
194 :style radio
|
70
|
195 :selected (eq ps-paper-type 'ps-a4)]
|
0
|
196 )
|
|
197 )
|
|
198 ("\"Other Window\" Location"
|
|
199 ["Always in Same Frame"
|
|
200 (setq get-frame-for-buffer-default-instance-limit nil)
|
|
201 :style radio
|
|
202 :selected (null get-frame-for-buffer-default-instance-limit)]
|
|
203 ["Other Frame (2 Frames Max)"
|
|
204 (setq get-frame-for-buffer-default-instance-limit 2)
|
|
205 :style radio
|
|
206 :selected (eq 2 get-frame-for-buffer-default-instance-limit)]
|
|
207 ["Other Frame (3 Frames Max)"
|
|
208 (setq get-frame-for-buffer-default-instance-limit 3)
|
|
209 :style radio
|
|
210 :selected (eq 3 get-frame-for-buffer-default-instance-limit)]
|
|
211 ["Other Frame (4 Frames Max)"
|
|
212 (setq get-frame-for-buffer-default-instance-limit 4)
|
|
213 :style radio
|
|
214 :selected (eq 4 get-frame-for-buffer-default-instance-limit)]
|
|
215 ["Other Frame (5 Frames Max)"
|
|
216 (setq get-frame-for-buffer-default-instance-limit 5)
|
|
217 :style radio
|
|
218 :selected (eq 5 get-frame-for-buffer-default-instance-limit)]
|
|
219 ["Always Create New Frame"
|
|
220 (setq get-frame-for-buffer-default-instance-limit 0)
|
|
221 :style radio
|
|
222 :selected (eq 0 get-frame-for-buffer-default-instance-limit)]
|
|
223 "-----"
|
|
224 ["Temp Buffers Always in Same Frame"
|
|
225 (setq temp-buffer-show-function 'show-temp-buffer-in-current-frame)
|
|
226 :style radio
|
|
227 :selected (eq temp-buffer-show-function
|
|
228 'show-temp-buffer-in-current-frame)]
|
|
229 ["Temp Buffers Like Other Buffers"
|
|
230 (setq temp-buffer-show-function nil)
|
|
231 :style radio
|
|
232 :selected (null temp-buffer-show-function)]
|
|
233 )
|
|
234
|
|
235 "-----"
|
|
236 ("Syntax Highlighting"
|
|
237 ["In This Buffer" (font-lock-mode)
|
|
238 :style toggle :selected font-lock-mode]
|
|
239 ["Automatic" (if (not (featurep 'font-lock))
|
|
240 (progn
|
|
241 (setq font-lock-auto-fontify t)
|
|
242 (require 'font-lock))
|
|
243 (setq font-lock-auto-fontify
|
|
244 (not font-lock-auto-fontify)))
|
|
245 :style toggle
|
|
246 :selected (and (featurep 'font-lock) font-lock-auto-fontify)]
|
|
247 "-----"
|
|
248 ["Fonts" (progn (require 'font-lock)
|
|
249 (font-lock-use-default-fonts)
|
|
250 (setq font-lock-use-fonts t
|
|
251 font-lock-use-colors nil)
|
|
252 (font-lock-mode 1))
|
|
253 :style radio
|
|
254 :selected (and font-lock-mode
|
|
255 font-lock-use-fonts)]
|
|
256 ["Colors" (progn (require 'font-lock)
|
|
257 (font-lock-use-default-colors)
|
|
258 (setq font-lock-use-colors t
|
|
259 font-lock-use-fonts nil)
|
|
260 (font-lock-mode 1))
|
|
261 :style radio
|
|
262 :selected (and font-lock-mode
|
|
263 font-lock-use-colors)]
|
|
264 "-----"
|
|
265 ["Least" (if (or (and (not (integerp font-lock-maximum-decoration))
|
|
266 (not (eq t font-lock-maximum-decoration)))
|
|
267 (and (integerp font-lock-maximum-decoration)
|
|
268 (<= font-lock-maximum-decoration 0)))
|
|
269 nil
|
|
270 (setq font-lock-maximum-decoration nil)
|
|
271 (font-lock-recompute-variables))
|
|
272 :style radio
|
|
273 :active font-lock-mode
|
|
274 :selected (and font-lock-mode
|
|
275 (or (and (not (integerp font-lock-maximum-decoration))
|
|
276 (not (eq t font-lock-maximum-decoration)))
|
|
277 (and (integerp font-lock-maximum-decoration)
|
|
278 (<= font-lock-maximum-decoration 0))))]
|
|
279 ["More" (if (and (integerp font-lock-maximum-decoration)
|
|
280 (= 1 font-lock-maximum-decoration))
|
|
281 nil
|
|
282 (setq font-lock-maximum-decoration 1)
|
|
283 (font-lock-recompute-variables))
|
|
284 :style radio
|
|
285 :active font-lock-mode
|
|
286 :selected (and font-lock-mode
|
|
287 (integerp font-lock-maximum-decoration)
|
|
288 (= 1 font-lock-maximum-decoration))]
|
|
289 ["Even More" (if (and (integerp font-lock-maximum-decoration)
|
|
290 (= 2 font-lock-maximum-decoration))
|
|
291 nil
|
|
292 (setq font-lock-maximum-decoration 2)
|
|
293 (font-lock-recompute-variables))
|
|
294 :style radio
|
|
295 :active font-lock-mode
|
|
296 :selected (and font-lock-mode
|
|
297 (integerp font-lock-maximum-decoration)
|
|
298 (= 2 font-lock-maximum-decoration))]
|
|
299 ["Most" (if (or (eq font-lock-maximum-decoration t)
|
|
300 (and (integerp font-lock-maximum-decoration)
|
|
301 (>= font-lock-maximum-decoration 3)))
|
|
302 nil
|
|
303 (setq font-lock-maximum-decoration t)
|
|
304 (font-lock-recompute-variables))
|
|
305 :style radio
|
|
306 :active font-lock-mode
|
|
307 :selected (and font-lock-mode
|
|
308 (or (eq font-lock-maximum-decoration t)
|
|
309 (and (integerp font-lock-maximum-decoration)
|
|
310 (>= font-lock-maximum-decoration 3))))]
|
|
311 "-----"
|
|
312 ["Lazy" (progn (require 'lazy-lock)
|
|
313 (if (and (boundp 'lazy-lock-mode) lazy-lock-mode)
|
|
314 (progn
|
|
315 (lazy-lock-mode 0)
|
|
316 ;; this shouldn't be necessary so there has to
|
|
317 ;; be a redisplay bug lurking somewhere (or
|
|
318 ;; possibly another event handler bug)
|
70
|
319 (redraw-modeline))
|
0
|
320 (if font-lock-mode
|
|
321 (progn
|
|
322 (lazy-lock-mode 1)
|
70
|
323 (redraw-modeline)))))
|
0
|
324 :active font-lock-mode
|
|
325 :style toggle
|
|
326 :selected (and (boundp 'lazy-lock-mode) lazy-lock-mode)]
|
|
327 ["Caching" (progn (require 'fast-lock)
|
|
328 (if fast-lock-mode
|
|
329 (progn
|
|
330 (fast-lock-mode 0)
|
|
331 ;; this shouldn't be necessary so there has to
|
|
332 ;; be a redisplay bug lurking somewhere (or
|
|
333 ;; possibly another event handler bug)
|
|
334 (redraw-modeline))
|
|
335 (if font-lock-mode
|
|
336 (progn
|
|
337 (fast-lock-mode 1)
|
|
338 (redraw-modeline)))))
|
|
339 :active font-lock-mode
|
|
340 :style toggle
|
70
|
341 :selected fast-lock-mode]
|
0
|
342 )
|
|
343 ("Paren Highlighting"
|
|
344 ["None" (paren-set-mode -1)
|
|
345 :style radio :selected (not paren-mode)]
|
|
346 ["Blinking Paren" (paren-set-mode 'blink-paren)
|
|
347 :style radio :selected (eq paren-mode 'blink-paren)]
|
|
348 ["Steady Paren" (paren-set-mode 'paren)
|
|
349 :style radio :selected (eq paren-mode 'paren)]
|
|
350 ["Expression" (paren-set-mode 'sexp)
|
|
351 :style radio :selected (eq paren-mode 'sexp)]
|
|
352 ;;; ["Nested Shading" (paren-set-mode 'nested)
|
|
353 ;;; :style radio :selected (eq paren-mode 'nested)]
|
|
354 )
|
|
355 "-----"
|
|
356 ("Frame Appearance"
|
|
357 ,@(if (featurep 'scrollbar)
|
|
358 '(["Scrollbars" (if (= (specifier-instance scrollbar-width) 0)
|
|
359 (progn
|
|
360 (set-specifier scrollbar-width 15)
|
|
361 (set-specifier scrollbar-height 15))
|
|
362 (set-specifier scrollbar-width 0)
|
|
363 (set-specifier scrollbar-height 0))
|
|
364 :style toggle :selected (> (specifier-instance scrollbar-width) 0)]))
|
|
365 ["3D Modeline"
|
|
366 (progn
|
|
367 (if (zerop (specifier-instance modeline-shadow-thickness))
|
|
368 (set-specifier modeline-shadow-thickness 2)
|
|
369 (set-specifier modeline-shadow-thickness 0))
|
|
370 (redraw-modeline t))
|
|
371 :style toggle :selected
|
|
372 (let ((thickness
|
|
373 (specifier-instance modeline-shadow-thickness)))
|
|
374 (and (integerp thickness)
|
|
375 (> thickness 0)))]
|
|
376 ["Truncate Lines" (progn
|
|
377 (setq truncate-lines (not truncate-lines))
|
|
378 (setq-default truncate-lines truncate-lines))
|
|
379 :style toggle :selected truncate-lines]
|
|
380 ["Bar Cursor" (progn
|
|
381 (setq bar-cursor
|
|
382 (if (not bar-cursor) 2 nil))
|
|
383 (force-cursor-redisplay))
|
|
384 :style toggle :selected bar-cursor]
|
|
385 ["Blinking Cursor" (blink-cursor-mode)
|
|
386 :style toggle
|
|
387 :selected (and (boundp 'blink-cursor-mode) blink-cursor-mode)]
|
|
388 ; ["Line Numbers" (line-number-mode nil)
|
|
389 ; :style toggle :selected line-number-mode]
|
|
390 )
|
|
391 ("Menubar Appearance"
|
|
392 ["Buffers Menu Length..."
|
|
393 (progn
|
|
394 (setq buffers-menu-max-size
|
|
395 (read-number
|
|
396 "Enter number of buffers to display (or 0 for unlimited): "))
|
|
397 (if (eq buffers-menu-max-size 0) (setq buffers-menu-max-size nil)))
|
|
398 t]
|
|
399 ["Multi-Operation Buffers Sub-Menus"
|
|
400 (setq complex-buffers-menu-p
|
|
401 (not complex-buffers-menu-p))
|
|
402 :style toggle :selected complex-buffers-menu-p]
|
|
403 ("Buffers Menu Sorting"
|
|
404 ["Most Recently Used"
|
|
405 (progn
|
|
406 (setq buffers-menu-sort-function nil)
|
|
407 (setq buffers-menu-grouping-function nil))
|
|
408 :style radio
|
|
409 :selected (null buffers-menu-sort-function)]
|
|
410 ["Alphabetically"
|
|
411 (progn
|
|
412 (setq buffers-menu-sort-function
|
|
413 'sort-buffers-menu-alphabetically)
|
|
414 (setq buffers-menu-grouping-function nil))
|
|
415 :style radio
|
|
416 :selected (eq 'sort-buffers-menu-alphabetically
|
|
417 buffers-menu-sort-function)]
|
|
418 ["By Major Mode, Then Alphabetically"
|
|
419 (progn
|
|
420 (setq buffers-menu-sort-function
|
|
421 'sort-buffers-menu-by-mode-then-alphabetically)
|
|
422 (setq buffers-menu-grouping-function
|
|
423 'group-buffers-menu-by-mode-then-alphabetically))
|
|
424 :style radio
|
|
425 :selected (eq 'sort-buffers-menu-by-mode-then-alphabetically
|
|
426 buffers-menu-sort-function)])
|
|
427 ["Submenus for Buffer Groups"
|
|
428 (setq buffers-menu-submenus-for-groups-p
|
|
429 (not buffers-menu-submenus-for-groups-p))
|
|
430 :style toggle
|
|
431 :selected buffers-menu-submenus-for-groups-p
|
|
432 :active (not (null buffers-menu-grouping-function))]
|
|
433 "---"
|
70
|
434 ["Frame-Local Font Menu" (setq font-menu-this-frame-only-p
|
|
435 (not font-menu-this-frame-only-p))
|
|
436 :style toggle :selected font-menu-this-frame-only-p]
|
0
|
437 ["Ignore Scaled Fonts" (setq font-menu-ignore-scaled-fonts
|
|
438 (not font-menu-ignore-scaled-fonts))
|
|
439 :style toggle :selected font-menu-ignore-scaled-fonts]
|
|
440 )
|
|
441 ,@(if (featurep 'toolbar)
|
|
442 '(("Toolbar Appearance"
|
|
443 ["Visible" (set-specifier default-toolbar-visible-p
|
|
444 (not (specifier-instance
|
|
445 default-toolbar-visible-p)))
|
|
446 :style toggle
|
|
447 :selected (specifier-instance default-toolbar-visible-p)]
|
|
448 ["Captioned" (set-specifier toolbar-buttons-captioned-p
|
|
449 (not (specifier-instance
|
|
450 toolbar-buttons-captioned-p)))
|
|
451 :style toggle
|
|
452 :selected
|
|
453 (specifier-instance toolbar-buttons-captioned-p)]
|
|
454 ("Default Location"
|
|
455 ["Top" (set-default-toolbar-position 'top)
|
|
456 :style radio :selected (eq (default-toolbar-position) 'top)]
|
|
457 ["Bottom" (set-default-toolbar-position 'bottom)
|
|
458 :style radio :selected (eq (default-toolbar-position) 'bottom)]
|
|
459 ["Left" (set-default-toolbar-position 'left)
|
|
460 :style radio :selected (eq (default-toolbar-position) 'left)]
|
|
461 ["Right" (set-default-toolbar-position 'right)
|
|
462 :style radio :selected (eq (default-toolbar-position) 'right)]
|
|
463 )
|
|
464 )))
|
|
465 ("Open URLs With"
|
|
466 ["Emacs-W3" (setq browse-url-browser-function 'browse-url-w3)
|
|
467 :style radio
|
|
468 :selected (eq browse-url-browser-function 'browse-url-w3)]
|
|
469 ["Netscape" (setq browse-url-browser-function 'browse-url-netscape)
|
|
470 :style radio
|
|
471 :selected (eq browse-url-browser-function 'browse-url-netscape)]
|
|
472 ["Mosaic" (setq browse-url-browser-function 'browse-url-mosaic)
|
|
473 :style radio
|
|
474 :selected (eq browse-url-browser-function 'browse-url-mosaic)]
|
|
475 ["Mosaic (CCI)" (setq browse-url-browser-function 'browse-url-cci)
|
|
476 :style radio
|
|
477 :selected (eq browse-url-browser-function 'browse-url-iximosaic)]
|
|
478 ["IXI Mosaic" (setq browse-url-browser-function 'browse-url-iximosaic)
|
|
479 :style radio
|
|
480 :selected (eq browse-url-browser-function 'browse-url-iximosaic)]
|
|
481 ["Lynx (xterm)" (setq browse-url-browser-function 'browse-url-lynx-xterm)
|
|
482 :style radio
|
|
483 :selected (eq browse-url-browser-function 'browse-url-lynx-xterm)]
|
|
484 ["Lynx (xemacs)" (setq browse-url-browser-function 'browse-url-lynx-emacs)
|
|
485 :style radio
|
|
486 :selected (eq browse-url-browser-function 'browse-url-lynx-emacs)]
|
|
487 ["Grail" (setq browse-url-browser-function 'browse-url-grail)
|
|
488 :style radio
|
|
489 :selected (eq browse-url-browser-function 'browse-url-grail)]
|
|
490 )
|
|
491 "-----"
|
70
|
492 ["Edit Faces..." edit-faces t]
|
0
|
493 ("Font" :filter font-menu-family-constructor)
|
|
494 ("Size" :filter font-menu-size-constructor)
|
|
495 ("Weight" :filter font-menu-weight-constructor)
|
70
|
496 ,@(if (featurep 'mule)
|
|
497 '("-----"
|
|
498 ("Language Environment"
|
|
499 :filter language-environment-menu-filter)))
|
0
|
500 "-----"
|
|
501 ["Save Options" save-options-menu-settings t]
|
|
502 )
|
|
503
|
|
504 ("Buffers"
|
|
505 :filter buffers-menu-filter
|
|
506 ["List All Buffers" list-buffers t]
|
|
507 "--"
|
|
508 )
|
|
509
|
|
510 ("Tools"
|
|
511 ["Grep..." grep t]
|
|
512 ["Compile..." compile t]
|
6
|
513 ["Shell" shell t]
|
0
|
514 ["Shell Command..." shell-command t]
|
70
|
515 ["Shell Command on Region..." shell-command-on-region (region-exists-p)]
|
0
|
516 ["Debug (GDB)..." gdb t]
|
|
517 ["Debug (DBX)..." dbx t]
|
|
518 "-----"
|
|
519 ["OO-Browser..." oobr t]
|
|
520 ("Tags"
|
70
|
521 ["Find Tag..." find-tag t]
|
0
|
522 ["Find Other Window..." find-tag-other-window t]
|
70
|
523 ["Next Tag..." (find-tag nil) t]
|
|
524 ["Next Other Window..." (find-tag-other-window nil) t]
|
|
525 ["Next File" next-file t]
|
|
526 "-----"
|
0
|
527 ["Tags Search..." tags-search t]
|
|
528 ["Tags Replace..." tags-query-replace t]
|
70
|
529 ["Continue Search/Replace" tags-loop-continue t]
|
0
|
530 "-----"
|
|
531 ["Pop stack" pop-tag-mark t]
|
70
|
532 ["Apropos..." tags-apropos t]
|
|
533 "-----"
|
|
534 ["Set Tags Table File..." visit-tags-table t]
|
|
535 ))
|
0
|
536
|
|
537 nil ; the partition: menus after this are flushright
|
|
538
|
|
539 ("Help"
|
|
540 ["About XEmacs..." about-xemacs t]
|
|
541 "-----"
|
70
|
542 ["XEmacs WWW Page" xemacs-www-page t]
|
|
543 ["Newest XEmacs FAQ via WWW" xemacs-www-faq t]
|
|
544 ["XEmacs FAQ (local)" xemacs-local-faq t]
|
|
545 ["XEmacs Tutorial" help-with-tutorial t]
|
|
546 ["XEmacs News" view-emacs-news t]
|
74
|
547 ["Sample" (find-file
|
|
548 (expand-file-name "sample.emacs"
|
|
549 data-directory))
|
70
|
550 t ".emacs"]
|
74
|
551 ["Sample" (find-file
|
|
552 (expand-file-name "sample.Xdefaults"
|
|
553 data-directory))
|
70
|
554 t ".Xdefaults"]
|
0
|
555 "-----"
|
70
|
556 ["Info (Detailed Docs)" info t]
|
0
|
557 ("Lookup in Info"
|
70
|
558 ["Key/Mouse Binding..." Info-goto-emacs-key-command-node t]
|
0
|
559 ["Command..." Info-goto-emacs-command-node t]
|
70
|
560 ["Elisp Function..." Info-elisp-ref t]
|
0
|
561 ["Topic..." Info-query t])
|
70
|
562 ["Package Browser" finder-by-keyword t]
|
|
563 ["Describe Mode" describe-mode t]
|
|
564 ["Apropos..." hyper-apropos t]
|
|
565 ["Apropos Documentation..." apropos-documentation t]
|
|
566 "-----"
|
|
567 ["Recent Keystrokes/Messages" view-lossage t]
|
|
568 ["Describe Key/Mouse..." describe-key t]
|
|
569 ["List Key Bindings" describe-bindings t]
|
|
570 ["List Mouse Bindings" describe-pointer t]
|
0
|
571 "-----"
|
70
|
572 ["Describe Function..." describe-function t]
|
|
573 ["Describe Variable..." describe-variable t]
|
|
574 ["Where Is Command..." where-is t]
|
|
575 "-----"
|
|
576 ["Unix Manual..." manual-entry t]
|
0
|
577 ("Misc"
|
70
|
578 ["Describe No Warranty" describe-no-warranty t]
|
|
579 ["Describe XEmacs License" describe-copying t]
|
|
580 ["Getting the Latest Version" describe-distribution t])
|
0
|
581 )
|
|
582 )))
|
|
583
|
|
584
|
|
585 (defun maybe-add-init-button ()
|
2
|
586 "Don't call this.
|
|
587 Adds `Load .emacs' button to menubar when starting up with -q."
|
0
|
588 ;; by Stig@hackvan.com
|
|
589 (cond
|
|
590 (init-file-user nil)
|
|
591 ((file-exists-p (cond
|
|
592 ((eq system-type 'ms-dos)
|
|
593 (concat "~" (user-login-name) "/_emacs"))
|
|
594 ((eq system-type 'vax-vms)
|
|
595 "sys$login:.emacs")
|
|
596 (t
|
|
597 (concat "~" (user-login-name) "/.emacs"))))
|
|
598 (add-menu-button nil
|
|
599 ["Load .emacs"
|
|
600 (progn (delete-menu-item '("Load .emacs"))
|
|
601 (load-user-init-file (user-login-name)))
|
|
602 t]
|
|
603 "Help"))
|
|
604 (t nil)))
|
|
605
|
|
606 (add-hook 'before-init-hook 'maybe-add-init-button)
|
|
607
|
|
608
|
|
609 ;;; The File and Edit menus
|
|
610
|
|
611 (defvar put-buffer-names-in-file-menu t)
|
|
612
|
|
613 ;; The sensitivity part of this function could be done by just adding forms
|
|
614 ;; to evaluate to the menu items themselves; that would be marginally less
|
|
615 ;; efficient but not perceptibly so (I think). But in order to change the
|
|
616 ;; names of the Undo menu item and the various things on the File menu item,
|
|
617 ;; we need to use a hook.
|
|
618
|
|
619 (defun file-menu-filter (menu-items)
|
|
620 "Incrementally update the file menu.
|
|
621 This function changes the arguments and sensitivity of these File menu items:
|
|
622
|
|
623 Delete Buffer has the name of the current buffer appended to it.
|
|
624 Print Buffer has the name of the current buffer appended to it.
|
|
625 Pretty-Print Buffer
|
|
626 has the name of the current buffer appended to it.
|
|
627 Save has the name of the current buffer appended to it, and is
|
|
628 sensitive only when the current buffer is modified.
|
|
629 Revert Buffer has the name of the current buffer appended to it, and is
|
|
630 sensitive only when the current buffer has a file.
|
|
631 Delete Frame sensitive only when there is more than one frame.
|
|
632
|
|
633 The name of the current buffer is only appended to the menu items if
|
|
634 `put-buffer-names-in-file-menu' is non-nil. This behavior is the default."
|
|
635 (let* ((bufname (buffer-name))
|
|
636 (result menu-items) ; save pointer to start of menu.
|
|
637 name
|
|
638 item)
|
|
639 ;; the contents of the menu items in the file menu are destructively
|
|
640 ;; modified so that there is as little consing as possible. This is okay.
|
|
641 ;; As soon as the result is returned, it is converted to widget_values
|
|
642 ;; inside lwlib and the lisp menu-items can be safely modified again.
|
|
643 (while (setq item (pop menu-items))
|
|
644 (if (vectorp item)
|
|
645 (progn
|
|
646 (setq name (aref item 0))
|
|
647 (and put-buffer-names-in-file-menu
|
|
648 (member name '("Save" "Revert Buffer" "Print Buffer"
|
|
649 "Pretty-Print Buffer" "Delete Buffer"))
|
|
650 (>= 4 (length item))
|
|
651 (aset item 3 bufname))
|
|
652 (and (string= "Save" name)
|
|
653 (aset item 2 (buffer-modified-p)))
|
|
654 (and (string= "Revert Buffer" name)
|
|
655 (aset item 2 (not (not (or buffer-file-name
|
|
656 revert-buffer-function)))))
|
|
657 (and (string= "Delete Frame" name)
|
|
658 (aset item 2 (not (eq (next-frame) (selected-frame)))))
|
|
659 )))
|
|
660 result))
|
|
661
|
|
662 (defun edit-menu-filter (menu-items)
|
|
663 "For use as an incremental menu construction filter.
|
|
664 This function changes the sensitivity of these Edit menu items:
|
|
665
|
|
666 Cut sensitive only when emacs owns the primary X Selection.
|
|
667 Copy sensitive only when emacs owns the primary X Selection.
|
|
668 Clear sensitive only when emacs owns the primary X Selection.
|
|
669 Paste sensitive only when there is an owner for the X Clipboard Selection.
|
|
670 Undo sensitive only when there is undo information.
|
|
671 While in the midst of an undo, this is changed to \"Undo More\"."
|
|
672 (let* (item
|
|
673 name
|
|
674 (result menu-items) ; save pointer to head of list
|
|
675 (x-dev (eq 'x (device-type (selected-device))))
|
|
676 (emacs-owns-selection-p (and x-dev (x-selection-owner-p)))
|
|
677 (clipboard-exists-p (and x-dev (x-selection-exists-p 'CLIPBOARD)))
|
|
678 ;;; undo-available undoing-more
|
|
679 ;;; (undo-info-available (not (null (and (not (eq t buffer-undo-list))
|
|
680 ;;; (if (eq last-command 'undo)
|
|
681 ;;; (setq undoing-more
|
|
682 ;;; (and (boundp 'pending-undo-list)
|
|
683 ;;; pending-undo-list)
|
|
684 ;;; buffer-undo-list))))))
|
|
685 undo-name undo-state
|
|
686 )
|
|
687 ;; As with file-menu-filter, menu-items are destructively modified.
|
|
688 ;; This is OK.
|
|
689 (while (setq item (pop menu-items))
|
|
690 (if (vectorp item)
|
|
691 (progn
|
|
692 (setq name (aref item 0))
|
|
693 (and (member name '("Cut" "Copy" "Clear"))
|
|
694 (aset item 2 emacs-owns-selection-p))
|
|
695 (and (string= name "Paste")
|
|
696 (aset item 2 clipboard-exists-p))
|
|
697 (and (member name '("Undo" "Undo More"))
|
|
698 (progn
|
|
699 ;; we could also do this with the third field of the item.
|
|
700 (if (eq last-command 'undo)
|
|
701 (setq undo-name "Undo More"
|
|
702 undo-state (not (null (and (boundp 'pending-undo-list)
|
|
703 pending-undo-list))))
|
|
704 (setq undo-name "Undo"
|
|
705 undo-state (and (not (eq buffer-undo-list t))
|
|
706 (not (null
|
|
707 (or buffer-undo-list
|
|
708 (and (boundp 'pending-undo-list)
|
|
709 pending-undo-list)))))))
|
|
710 (if buffer-read-only (setq undo-state nil))
|
|
711 (aset item 0 undo-name)
|
|
712 (aset item 2 undo-state)
|
|
713 ))
|
|
714 )))
|
|
715 result))
|
|
716
|
|
717
|
|
718 ;;; The Buffers menu
|
|
719
|
|
720 (defvar buffers-menu-max-size 25
|
|
721 "*Maximum number of entries which may appear on the \"Buffers\" menu.
|
|
722 If this is 10, then only the ten most-recently-selected buffers will be
|
|
723 shown. If this is nil, then all buffers will be shown. Setting this to
|
|
724 a large number or nil will slow down menu responsiveness.")
|
|
725
|
|
726 (defvar complex-buffers-menu-p nil
|
|
727 "*If true, the buffers menu will contain several commands, as submenus
|
|
728 of each buffer line. If this is false, then there will be only one command:
|
|
729 select that buffer.")
|
|
730
|
|
731 (defvar buffers-menu-submenus-for-groups-p nil
|
|
732 "*If true, the buffers menu will contain one submenu per group of buffers,
|
74
|
733 if a grouping function is specified in `buffers-menu-grouping-function'.
|
|
734 If this is an integer, do not build submenus if the number of buffers
|
|
735 is not larger than this value.")
|
0
|
736
|
|
737 (defvar buffers-menu-switch-to-buffer-function 'switch-to-buffer
|
|
738 "*The function to call to select a buffer from the buffers menu.
|
|
739 `switch-to-buffer' is a good choice, as is `pop-to-buffer'.")
|
|
740
|
|
741 (defvar buffers-menu-omit-function 'buffers-menu-omit-invisible-buffers
|
|
742 "*If non-nil, a function specifying the buffers to omit from the buffers menu.
|
|
743 This is passed a buffer and should return non-nil if the buffer should be
|
|
744 omitted. The default value `buffers-menu-omit-invisible-buffers' omits
|
|
745 buffers that are normally considered \"invisible\" (those whose name
|
|
746 begins with a space).")
|
|
747
|
|
748 (defvar buffers-menu-format-buffer-line-function 'format-buffers-menu-line
|
|
749 "*The function to call to return a string to represent a buffer in the
|
|
750 buffers menu. The function is passed a buffer and should return a string.
|
|
751 The default value `format-buffers-menu-line' just returns the name of
|
|
752 the buffer. Also check out `slow-format-buffers-menu-line' which
|
|
753 returns a whole bunch of info about a buffer.")
|
|
754
|
|
755 (defvar buffers-menu-sort-function
|
|
756 'sort-buffers-menu-by-mode-then-alphabetically
|
|
757 "*If non-nil, a function to sort the list of buffers in the buffers menu.
|
|
758 It will be passed two arguments (two buffers to compare) and should return
|
|
759 T if the first is \"less\" than the second. One possible value is
|
|
760 `sort-buffers-menu-alphabetically'; another is
|
|
761 `sort-buffers-menu-by-mode-then-alphabetically'.")
|
|
762
|
|
763 (defvar buffers-menu-grouping-function
|
|
764 'group-buffers-menu-by-mode-then-alphabetically
|
|
765 "*If non-nil, a function to group buffers in the buffers menu together.
|
|
766 It will be passed two arguments, successive members of the sorted buffers
|
|
767 list after being passed through `buffers-menu-sort-function'. It should
|
|
768 return non-nil if the second buffer begins a new group. The return value
|
|
769 should be the name of the old group, which may be used in hierarchical
|
|
770 buffers menus. The last invocation of the function contains nil as the
|
|
771 second argument, so that the name of the last group can be determined.
|
|
772
|
|
773 The sensible values of this function are dependent on the value specified
|
|
774 for `buffers-menu-sort-function'.")
|
|
775
|
|
776 (defun buffers-menu-omit-invisible-buffers (buf)
|
|
777 "For use as a value of `buffers-menu-omit-function'.
|
|
778 Omits normally invisible buffers (those whose name begins with a space)."
|
|
779 (not (null (string-match "\\` " (buffer-name buf)))))
|
|
780
|
|
781 (defun sort-buffers-menu-alphabetically (buf1 buf2)
|
|
782 "For use as a value of `buffers-menu-sort-function'.
|
|
783 Sorts the buffers in alphabetical order by name, but puts buffers beginning
|
|
784 with a star at the end of the list."
|
|
785 (let* ((nam1 (buffer-name buf1))
|
|
786 (nam2 (buffer-name buf2))
|
|
787 (star1p (not (null (string-match "\\`*" nam1))))
|
|
788 (star2p (not (null (string-match "\\`*" nam2)))))
|
|
789 (if (not (eq star1p star2p))
|
|
790 (not star1p)
|
|
791 (string-lessp nam1 nam2))))
|
|
792
|
|
793 (defun sort-buffers-menu-by-mode-then-alphabetically (buf1 buf2)
|
|
794 "For use as a value of `buffers-menu-sort-function'.
|
|
795 Sorts first by major mode and then alphabetically by name, but puts buffers
|
|
796 beginning with a star at the end of the list."
|
|
797 (let* ((nam1 (buffer-name buf1))
|
|
798 (nam2 (buffer-name buf2))
|
|
799 (star1p (not (null (string-match "\\`*" nam1))))
|
|
800 (star2p (not (null (string-match "\\`*" nam2))))
|
|
801 (mode1 (symbol-value-in-buffer 'major-mode buf1))
|
|
802 (mode2 (symbol-value-in-buffer 'major-mode buf2)))
|
|
803 (cond ((not (eq star1p star2p)) (not star1p))
|
|
804 ((and star1p star2p (string-lessp nam1 nam2)))
|
|
805 ((string-lessp mode1 mode2) t)
|
|
806 ((string-lessp mode2 mode1) nil)
|
|
807 (t (string-lessp nam1 nam2)))))
|
|
808
|
|
809 ;; this version is too slow on some machines.
|
|
810 (defun slow-format-buffers-menu-line (buffer)
|
|
811 "For use as a value of `buffers-menu-format-buffer-line-function'.
|
|
812 This returns a string containing a bunch of info about the buffer."
|
|
813 (format "%s%s %-19s %6s %-15s %s"
|
|
814 (if (buffer-modified-p buffer) "*" " ")
|
|
815 (if (symbol-value-in-buffer 'buffer-read-only buffer) "%" " ")
|
|
816 (buffer-name buffer)
|
|
817 (buffer-size buffer)
|
|
818 (symbol-value-in-buffer 'mode-name buffer)
|
|
819 (or (buffer-file-name buffer) "")))
|
|
820
|
|
821 (defun format-buffers-menu-line (buffer)
|
|
822 "For use as a value of `buffers-menu-format-buffer-line-function'.
|
|
823 This just returns the buffer's name."
|
|
824 (buffer-name buffer))
|
|
825
|
|
826 (defun group-buffers-menu-by-mode-then-alphabetically (buf1 buf2)
|
|
827 "For use as a value of `buffers-menu-grouping-function'.
|
|
828 This groups buffers by major mode. It only really makes sense if
|
|
829 `buffers-menu-sorting-function' is
|
|
830 `sort-buffers-menu-by-mode-then-alphabetically'."
|
|
831 (cond ((string-match "\\`*" (buffer-name buf1))
|
|
832 (and (null buf2) "*Misc*"))
|
|
833 ((or (null buf2)
|
|
834 (string-match "\\`*" (buffer-name buf2))
|
|
835 (not (eq (symbol-value-in-buffer 'major-mode buf1)
|
|
836 (symbol-value-in-buffer 'major-mode buf2))))
|
|
837 (symbol-value-in-buffer 'mode-name buf1))
|
|
838 (t nil)))
|
|
839
|
|
840 (defun buffer-menu-save-buffer (buffer)
|
|
841 (save-excursion
|
|
842 (set-buffer buffer)
|
|
843 (save-buffer)))
|
|
844
|
|
845 (defun buffer-menu-write-file (buffer)
|
|
846 (save-excursion
|
|
847 (set-buffer buffer)
|
|
848 (write-file (read-file-name
|
|
849 (format "Write %s to file: "
|
|
850 (buffer-name (current-buffer)))))))
|
|
851
|
|
852 (defsubst build-buffers-menu-internal (buffers)
|
|
853 (let (name line)
|
|
854 (mapcar
|
74
|
855 #'(lambda (buffer)
|
|
856 (if (eq buffer t)
|
|
857 "---"
|
|
858 (setq line (funcall buffers-menu-format-buffer-line-function
|
|
859 buffer))
|
|
860 (if complex-buffers-menu-p
|
|
861 (delq nil
|
|
862 (list line
|
|
863 (vector "Switch to Buffer"
|
|
864 (list buffers-menu-switch-to-buffer-function
|
|
865 (setq name (buffer-name buffer)))
|
|
866 t)
|
|
867 (if (eq buffers-menu-switch-to-buffer-function
|
|
868 'switch-to-buffer)
|
|
869 (vector "Switch to Buffer, Other Frame"
|
|
870 (list 'switch-to-buffer-other-frame
|
|
871 (setq name (buffer-name buffer)))
|
|
872 t)
|
|
873 nil)
|
|
874 (if (and (buffer-modified-p buffer)
|
|
875 (buffer-file-name buffer))
|
|
876 (vector "Save Buffer"
|
|
877 (list 'buffer-menu-save-buffer name) t)
|
|
878 ["Save Buffer" nil nil]
|
|
879 )
|
|
880 (vector "Save As..."
|
|
881 (list 'buffer-menu-write-file name) t)
|
|
882 (vector "Delete Buffer" (list 'kill-buffer name)
|
|
883 t)))
|
|
884 ;; ### We don't want buffer names to be translated,
|
|
885 ;; ### so we put the buffer name in the suffix.
|
|
886 ;; ### Also, avoid losing with non-ASCII buffer names.
|
|
887 ;; ### We still lose, however, if complex-buffers-menu-p. --mrb
|
|
888 (vector ""
|
|
889 (list buffers-menu-switch-to-buffer-function
|
|
890 (buffer-name buffer))
|
|
891 t line))))
|
0
|
892 buffers)))
|
|
893
|
|
894 (defun buffers-menu-filter (menu)
|
|
895 "This is the menu filter for the top-level buffers \"Buffers\" menu.
|
|
896 It dynamically creates a list of buffers to use as the contents of the menu.
|
|
897 Only the most-recently-used few buffers will be listed on the menu, for
|
|
898 efficiency reasons. You can control how many buffers will be shown by
|
|
899 setting `buffers-menu-max-size'. You can control the text of the menu
|
|
900 items by redefining the function `format-buffers-menu-line'."
|
|
901 (let ((buffers (delete-if buffers-menu-omit-function (buffer-list))))
|
|
902 (and (integerp buffers-menu-max-size)
|
|
903 (> buffers-menu-max-size 1)
|
|
904 (> (length buffers) buffers-menu-max-size)
|
74
|
905 ;; shorten list of buffers (not with submenus!)
|
|
906 (not (and buffers-menu-grouping-function
|
|
907 buffers-menu-submenus-for-groups-p))
|
0
|
908 (setcdr (nthcdr buffers-menu-max-size buffers) nil))
|
|
909 (if buffers-menu-sort-function
|
|
910 (setq buffers (sort buffers buffers-menu-sort-function)))
|
|
911 (if (and buffers-menu-grouping-function
|
74
|
912 buffers-menu-submenus-for-groups-p
|
|
913 (or (not (integerp buffers-menu-submenus-for-groups-p))
|
|
914 (> (length buffers) buffers-menu-submenus-for-groups-p)))
|
0
|
915 (let (groups groupnames current-group)
|
|
916 (mapl
|
|
917 #'(lambda (sublist)
|
|
918 (let ((groupname (funcall buffers-menu-grouping-function
|
|
919 (car sublist) (cadr sublist))))
|
|
920 (setq current-group (cons (car sublist) current-group))
|
|
921 (if groupname
|
|
922 (progn
|
|
923 (setq groups (cons (nreverse current-group)
|
|
924 groups))
|
|
925 (setq groupnames (cons groupname groupnames))
|
|
926 (setq current-group nil)))))
|
|
927 buffers)
|
|
928 (setq buffers
|
|
929 (mapcar*
|
|
930 #'(lambda (groupname group)
|
|
931 (cons groupname (build-buffers-menu-internal group)))
|
|
932 (nreverse groupnames)
|
|
933 (nreverse groups))))
|
|
934 (if buffers-menu-grouping-function
|
|
935 (progn
|
|
936 (setq buffers
|
|
937 (mapcon
|
|
938 #'(lambda (sublist)
|
|
939 (cond ((funcall buffers-menu-grouping-function
|
|
940 (car sublist) (cadr sublist))
|
|
941 (list (car sublist) t))
|
|
942 (t (list (car sublist)))))
|
|
943 buffers))
|
|
944 ;; remove a trailing separator.
|
|
945 (and (>= (length buffers) 2)
|
|
946 (let ((lastcdr (nthcdr (- (length buffers) 2) buffers)))
|
|
947 (if (eq t (cadr lastcdr))
|
|
948 (setcdr lastcdr nil))))))
|
|
949 (setq buffers (build-buffers-menu-internal buffers)))
|
|
950 (append menu buffers)
|
|
951 ))
|
|
952
|
70
|
953 (defun language-environment-menu-filter (menu)
|
|
954 "This is the menu filter for the \"Language Environment\" submenu."
|
|
955 (mapcar (lambda (env-sym)
|
|
956 `[ ,(capitalize (symbol-name env-sym))
|
|
957 (set-language-environment ',env-sym) t])
|
|
958 language-environment-list))
|
0
|
959
|
|
960
|
|
961 ;;; The Options menu
|
|
962
|
|
963 (defconst options-menu-saved-forms
|
|
964 ;; This is really quite a kludge, but it gets the job done.
|
|
965 ;;
|
|
966 ;; remember that we have to conditionalize on default features
|
|
967 ;; both in the forms to evaluate and in the forms output to
|
|
968 ;; .emacs, in case the .emacs is loaded into an XEmacs with
|
|
969 ;; different features.
|
|
970 (purecopy
|
|
971 '(
|
|
972 ;; Editing Options menu.
|
|
973 ;; put case-fold-search first to defeat a bug in the backquote
|
|
974 ;; processing mechanism. Feh!
|
|
975 case-fold-search
|
|
976 `(setq-default overwrite-mode ,(default-value 'overwrite-mode))
|
|
977 (if (default-value 'overwrite-mode)
|
|
978 '(overwrite-mode 1))
|
|
979 `(setq-default case-fold-search ,(default-value 'case-fold-search))
|
|
980 case-replace
|
|
981 (if (memq 'pending-delete-pre-hook pre-command-hook)
|
|
982 '(progn
|
|
983 (require 'pending-del)
|
|
984 (pending-delete-on nil)))
|
|
985 zmacs-regions
|
|
986 mouse-yank-at-point
|
|
987
|
|
988 ;; General Options menu.
|
|
989 teach-extended-commands-p
|
|
990 ;; (#### not actually on Options menu)
|
|
991 teach-extended-commands-timeout
|
|
992 debug-on-error
|
|
993 debug-on-quit
|
|
994
|
|
995 ;; Printing Options menu.
|
|
996 lpr-switches
|
|
997 ps-print-color-p
|
|
998 ps-paper-type
|
|
999
|
|
1000 ;; Other Window Location
|
|
1001 get-frame-for-buffer-default-instance-limit
|
|
1002 temp-buffer-show-function
|
|
1003
|
|
1004 ;; Syntax Highlighting
|
|
1005 font-lock-auto-fontify
|
|
1006 font-lock-use-fonts
|
|
1007 font-lock-use-colors
|
|
1008 font-lock-maximum-decoration
|
|
1009 font-lock-maximum-size
|
|
1010 ;; (#### the next two not on Options menu)
|
|
1011 font-lock-mode-enable-list
|
|
1012 font-lock-mode-disable-list
|
|
1013 ;; #### - this structure is clearly broken. There's no way to ever
|
|
1014 ;; un-require font-lock via the menus. --Stig
|
|
1015 (if (featurep 'font-lock)
|
|
1016 '(require 'font-lock))
|
|
1017 (if (and (boundp 'font-lock-mode-hook)
|
|
1018 (memq 'turn-on-fast-lock font-lock-mode-hook))
|
|
1019 '(add-hook 'font-lock-mode-hook 'turn-on-fast-lock)
|
|
1020 '(remove-hook 'font-lock-mode-hook 'turn-on-fast-lock))
|
|
1021 (if (and (boundp 'font-lock-mode-hook)
|
|
1022 (memq 'turn-on-lazy-lock font-lock-mode-hook))
|
|
1023 '(add-hook 'font-lock-mode-hook 'turn-on-lazy-lock)
|
|
1024 '(remove-hook 'font-lock-mode-hook 'turn-on-lazy-lock))
|
|
1025
|
|
1026 ;; Paren Highlighting
|
|
1027 (if paren-mode
|
|
1028 `(progn (require 'paren) (paren-set-mode ',paren-mode)))
|
|
1029
|
|
1030 ;; For specifiers, we only save global settings since the others
|
|
1031 ;; will belong to objects which only exist during this session.
|
|
1032
|
|
1033 ;; Frame Appearance
|
|
1034 (if (featurep 'scrollbar)
|
|
1035 `(if (featurep 'scrollbar)
|
|
1036 (progn
|
|
1037 (add-spec-list-to-specifier
|
|
1038 scrollbar-width
|
|
1039 ',(specifier-spec-list scrollbar-width 'global))
|
|
1040 (add-spec-list-to-specifier
|
|
1041 scrollbar-height
|
|
1042 ',(specifier-spec-list scrollbar-height 'global)))))
|
|
1043 `(add-spec-list-to-specifier
|
|
1044 modeline-shadow-thickness
|
|
1045 ',(specifier-spec-list modeline-shadow-thickness 'global))
|
|
1046 `(setq-default truncate-lines ,(default-value 'truncate-lines))
|
|
1047 bar-cursor
|
|
1048 (if (and (boundp 'blink-cursor-mode) blink-cursor-mode)
|
|
1049 '(blink-cursor-mode t))
|
|
1050
|
|
1051 ;; Menubar Appearance
|
|
1052 buffers-menu-max-size
|
|
1053 complex-buffers-menu-p
|
|
1054 buffers-menu-sort-function
|
|
1055 buffers-menu-grouping-function
|
|
1056 buffers-menu-submenus-for-groups-p
|
|
1057 font-menu-ignore-scaled-fonts
|
|
1058 font-menu-this-frame-only-p
|
|
1059
|
|
1060 ;; Toolbar Appearance
|
|
1061 (if (featurep 'toolbar)
|
|
1062 `(if (featurep 'toolbar)
|
|
1063 (progn
|
|
1064 (set-default-toolbar-position
|
|
1065 ',(default-toolbar-position))
|
|
1066 (add-spec-list-to-specifier
|
|
1067 default-toolbar-visible-p
|
|
1068 ',(specifier-spec-list default-toolbar-visible-p 'global))
|
|
1069 (add-spec-list-to-specifier
|
|
1070 toolbar-buttons-captioned-p
|
|
1071 ',(specifier-spec-list toolbar-buttons-captioned-p
|
|
1072 'global)))))
|
|
1073
|
|
1074 ;; Open URLs With
|
|
1075 browse-url-browser-function
|
|
1076
|
|
1077 ;; Now save all faces.
|
|
1078
|
|
1079 ;; Setting this in lisp conflicts with X resources. Bad move. --Stig
|
|
1080 ;; (list 'set-face-font ''default (face-font-name 'default))
|
|
1081 ;; (list 'set-face-font ''modeline (face-font-name 'modeline))
|
70
|
1082
|
|
1083 (cons 'progn
|
|
1084 (mapcar #'(lambda (face)
|
|
1085 `(make-face ',face))
|
|
1086 (face-list)))
|
|
1087
|
|
1088 (cons 'progn
|
|
1089 (apply 'nconc
|
|
1090 (mapcar
|
|
1091 #'(lambda (face)
|
|
1092 (delq nil
|
|
1093 (mapcar
|
|
1094 #'(lambda (property)
|
|
1095 (if (specifier-spec-list
|
|
1096 (face-property face property))
|
|
1097 `(add-spec-list-to-specifier
|
|
1098 (face-property ',face ',property)
|
|
1099 ',(save-options-specifier-spec-list
|
|
1100 face property))))
|
74
|
1101 (delq 'display-table
|
|
1102 (copy-sequence
|
|
1103 built-in-face-specifiers)))))
|
70
|
1104 (face-list))))
|
|
1105
|
|
1106 ;; Mule-specific:
|
|
1107 (if (featurep 'mule)
|
|
1108 `(if (featurep 'mule)
|
|
1109 (set-language-environment ',(current-language-environment))))
|
0
|
1110 ))
|
|
1111 "The variables to save; or forms to evaluate to get forms to write out.
|
|
1112 This is used by `save-options-menu-settings' and should mirror the
|
|
1113 options listed in the Options menu.")
|
|
1114
|
|
1115 (defun save-options-specifier-spec-list (face property)
|
|
1116 (if (not (or (eq property 'font) (eq property 'color)))
|
|
1117 (specifier-spec-list (face-property face property) 'global)
|
|
1118 (let* ((retlist (specifier-spec-list (face-property face property)
|
|
1119 'global))
|
|
1120 (entry (cdr (car retlist)))
|
|
1121 item)
|
|
1122 (while entry
|
|
1123 (setq item (car entry))
|
|
1124 (if (eq property 'font)
|
|
1125 (if (font-instance-p (cdr item))
|
|
1126 (setcdr item (font-instance-name (cdr item))))
|
|
1127 (if (color-instance-p (cdr item))
|
|
1128 (setcdr item (color-instance-name (cdr item)))))
|
|
1129 (setq entry (cdr entry)))
|
|
1130 retlist)))
|
|
1131
|
|
1132 (defvar save-options-init-file nil
|
|
1133 "File into which to save forms to load the options file (nil for .emacs).
|
|
1134 Normally this is nil, which means save into your .emacs file (the value
|
|
1135 of `user-init-file'.")
|
|
1136
|
|
1137 (defvar save-options-file ".xemacs-options"
|
|
1138 "File to save options into.
|
|
1139 This file is loaded from your .emacs file.
|
|
1140 If this is a relative filename, it is put into the same directory as your
|
|
1141 .emacs file.")
|
|
1142
|
|
1143 (defun save-options-menu-settings ()
|
|
1144 "Saves the current settings of the `Options' menu to your `.emacs' file."
|
|
1145 (interactive)
|
|
1146 ;; we compute the actual filenames now because x-menubar is loaded
|
|
1147 ;; at dump time, when the identity of the user running XEmacs is not known.
|
|
1148 (let* ((actual-save-options-init-file
|
|
1149 (or save-options-init-file
|
|
1150 (and (not (equal user-init-file ""))
|
|
1151 user-init-file)
|
|
1152 (and (eq system-type 'ms-dos)
|
|
1153 (concat "~" (user-login-name) "/_emacs"))
|
|
1154 (concat "~" (user-login-name) "/.emacs")))
|
|
1155 (actual-save-options-file
|
|
1156 (abbreviate-file-name
|
|
1157 (expand-file-name
|
|
1158 save-options-file
|
|
1159 (file-name-directory actual-save-options-init-file))
|
2
|
1160 ;; Don't hack-homedir in abbreviate-file-name. This will
|
|
1161 ;; cause an incorrect expansion if the save-options variables
|
|
1162 ;; have ~ in them.
|
|
1163 ))
|
0
|
1164 (init-output-buffer (find-file-noselect
|
|
1165 actual-save-options-init-file))
|
|
1166 init-output-marker
|
|
1167 (options-output-buffer
|
|
1168 (find-file-noselect actual-save-options-file))
|
|
1169 options-output-marker)
|
|
1170
|
|
1171 (save-excursion
|
|
1172 (set-buffer options-output-buffer)
|
|
1173 (erase-buffer)
|
|
1174 (setq options-output-marker (point-marker)))
|
|
1175
|
|
1176 ;; run with current-buffer unchanged so that variables are evaluated in
|
|
1177 ;; the current context, instead of in the context of the ".emacs" buffer
|
|
1178 ;; or the ".xemacs-options" buffer.
|
|
1179
|
|
1180 ;; first write out .xemacs-options.
|
|
1181
|
|
1182 (let ((standard-output options-output-marker))
|
|
1183 (princ ";; -*- Mode: Emacs-Lisp -*-\n\n")
|
|
1184 (princ "(setq options-file-xemacs-version '(")
|
|
1185 (princ emacs-major-version)
|
|
1186 (princ " ")
|
|
1187 (princ emacs-minor-version)
|
|
1188 (princ "))\n")
|
|
1189 (let ((print-readably t)
|
|
1190 (print-escape-newlines t))
|
|
1191 (mapcar #'(lambda (var)
|
|
1192 (princ " ")
|
|
1193 (if (symbolp var)
|
|
1194 (prin1 (list 'setq-default var
|
|
1195 (let ((val (symbol-value var)))
|
|
1196 (if (or (memq val '(t nil))
|
|
1197 (and (not (symbolp val))
|
|
1198 (not (consp val))))
|
|
1199 val
|
|
1200 (list 'quote val)))))
|
|
1201 (setq var (eval var))
|
|
1202 (cond ((eq (car-safe var) 'progn)
|
|
1203 (while (setq var (cdr var))
|
|
1204 (prin1 (car var))
|
|
1205 (princ "\n")
|
|
1206 (if (cdr var) (princ " "))
|
|
1207 ))
|
|
1208 (var
|
|
1209 (prin1 var))))
|
|
1210 (if var (princ "\n")))
|
|
1211 options-menu-saved-forms)
|
|
1212 ))
|
|
1213 (set-marker options-output-marker nil)
|
|
1214 (save-excursion
|
|
1215 (set-buffer options-output-buffer)
|
|
1216 (save-buffer))
|
|
1217
|
|
1218 ;; then fix .emacs.
|
|
1219
|
|
1220 (save-excursion
|
|
1221 (set-buffer init-output-buffer)
|
|
1222 ;;
|
|
1223 ;; Find and delete the previously saved data, and position to write.
|
|
1224 ;;
|
|
1225 (goto-char (point-min))
|
|
1226 (if (re-search-forward "^;; Options Menu Settings *\n" nil 'move)
|
|
1227 (let ((p (match-beginning 0)))
|
|
1228 (goto-char p)
|
|
1229 (or (re-search-forward
|
|
1230 "^;; End of Options Menu Settings *\\(\n\\|\\'\\)"
|
|
1231 nil t)
|
|
1232 (error "can't find END of saved state in .emacs"))
|
|
1233 (delete-region p (match-end 0)))
|
|
1234 (goto-char (point-max))
|
|
1235 (insert "\n"))
|
|
1236 (setq init-output-marker (point-marker)))
|
|
1237
|
|
1238 (let ((standard-output init-output-marker))
|
|
1239 (princ ";; Options Menu Settings\n")
|
|
1240 (princ ";; =====================\n")
|
|
1241 (princ "(cond\n")
|
|
1242 (princ " ((and (string-match \"XEmacs\" emacs-version)\n")
|
|
1243 (princ " (boundp 'emacs-major-version)\n")
|
|
1244 (princ " (or (and\n")
|
|
1245 (princ " (= emacs-major-version 19)\n")
|
|
1246 (princ " (>= emacs-minor-version 14))\n")
|
|
1247 (princ " (= emacs-major-version 20))\n")
|
|
1248 (princ " (fboundp 'load-options-file))\n")
|
|
1249 (princ " (load-options-file \"")
|
|
1250 (princ actual-save-options-file)
|
|
1251 (princ "\")))\n")
|
|
1252 (princ ";; ============================\n")
|
|
1253 (princ ";; End of Options Menu Settings\n"))
|
|
1254
|
|
1255 (set-marker init-output-marker nil)
|
|
1256 (save-excursion
|
|
1257 (set-buffer init-output-buffer)
|
|
1258 (save-buffer))
|
|
1259 ))
|
|
1260
|
|
1261
|
|
1262 (set-menubar default-menubar)
|
|
1263
|
|
1264
|
|
1265 ;;; Popup menus.
|
|
1266
|
|
1267 (defconst default-popup-menu
|
|
1268 '("XEmacs Commands"
|
|
1269 :filter edit-menu-filter
|
|
1270 ["Undo" advertised-undo t]
|
|
1271 ["Cut" x-kill-primary-selection t]
|
|
1272 ["Copy" x-copy-primary-selection t]
|
|
1273 ["Paste" x-yank-clipboard-selection t]
|
|
1274 ["Clear" x-delete-primary-selection t]
|
|
1275 "-----"
|
|
1276 ["Select Block" mark-paragraph t]
|
|
1277 ["Split Window" (split-window) t]
|
|
1278 ["Unsplit Window" delete-other-windows t]
|
|
1279 ))
|
|
1280
|
|
1281 (defvar global-popup-menu nil
|
|
1282 "The global popup menu. This is present in all modes.
|
|
1283 See the function `popup-menu' for a description of menu syntax.")
|
|
1284
|
|
1285 (defvar mode-popup-menu nil
|
|
1286 "The mode-specific popup menu. Automatically buffer local.
|
|
1287 This is appended to the default items in `global-popup-menu'.
|
|
1288 See the function `popup-menu' for a description of menu syntax.")
|
|
1289 (make-variable-buffer-local 'mode-popup-menu)
|
|
1290
|
|
1291 ;; In an effort to avoid massive menu clutter, this mostly worthless menu is
|
|
1292 ;; superceded by any local popup menu...
|
|
1293 (setq-default mode-popup-menu default-popup-menu)
|
|
1294
|
|
1295 (defvar activate-popup-menu-hook nil
|
|
1296 "Function or functions run before a mode-specific popup menu is made visible.
|
|
1297 These functions are called with no arguments, and should interrogate and
|
|
1298 modify the value of `global-popup-menu' or `mode-popup-menu' as desired.
|
|
1299 Note: this hook is only run if you use `popup-mode-menu' for activating the
|
|
1300 global and mode-specific commands; if you have your own binding for button3,
|
|
1301 this hook won't be run.")
|
|
1302
|
|
1303 (defun popup-mode-menu ()
|
|
1304 "Pop up a menu of global and mode-specific commands.
|
|
1305 The menu is computed by combining `global-popup-menu' and `mode-popup-menu'."
|
|
1306 (interactive "@_")
|
|
1307 (run-hooks 'activate-popup-menu-hook)
|
|
1308 (popup-menu
|
|
1309 (cond ((and global-popup-menu mode-popup-menu)
|
|
1310 (check-menu-syntax mode-popup-menu)
|
70
|
1311 (let ((title (car mode-popup-menu))
|
|
1312 (items (cdr mode-popup-menu)))
|
|
1313 (append global-popup-menu
|
0
|
1314 '("---" "---")
|
|
1315 (if popup-menu-titles (list title))
|
|
1316 (if popup-menu-titles '("---" "---"))
|
|
1317 items)))
|
|
1318 (t
|
|
1319 (or mode-popup-menu
|
|
1320 global-popup-menu
|
|
1321 (error "No menu here."))))))
|
|
1322
|
|
1323 (defun popup-buffer-menu (event)
|
|
1324 "Pop up a copy of the Buffers menu (from the menubar) where the mouse is clicked."
|
|
1325 (interactive "e")
|
|
1326 (let ((window (and (event-over-text-area-p event) (event-window event)))
|
|
1327 (bmenu nil))
|
|
1328 (or window
|
|
1329 (error "Pointer must be in a normal window"))
|
|
1330 (select-window window)
|
|
1331 (if current-menubar
|
|
1332 (setq bmenu (assoc "Buffers" current-menubar)))
|
|
1333 (if (null bmenu)
|
|
1334 (setq bmenu (assoc "Buffers" default-menubar)))
|
|
1335 (if (null bmenu)
|
|
1336 (error "Can't find the Buffers menu"))
|
|
1337 (popup-menu bmenu)))
|
|
1338
|
|
1339 (defun popup-menubar-menu (event)
|
|
1340 "Pop up a copy of menu that also appears in the menubar"
|
|
1341 ;; by Stig@hackvan.com
|
|
1342 (interactive "e")
|
|
1343 (let ((window (and (event-over-text-area-p event) (event-window event)))
|
|
1344 popup-menubar)
|
|
1345 (or window
|
|
1346 (error "Pointer must be in a normal window"))
|
|
1347 (select-window window)
|
|
1348 (and current-menubar (run-hooks 'activate-menubar-hook))
|
|
1349 ;; ##### Instead of having to copy this just to safely get rid of
|
|
1350 ;; any nil what we should really do is fix up the internal menubar
|
|
1351 ;; code to just ignore nil if generating a popup menu
|
|
1352 (setq popup-menubar (delete nil (copy-sequence (or current-menubar
|
|
1353 default-menubar))))
|
|
1354 (popup-menu (cons "Menubar Menu" popup-menubar))
|
|
1355 ))
|
|
1356
|
|
1357 (global-set-key 'button3 'popup-mode-menu)
|
|
1358 ;; shift button3 and shift button2 are reserved for Hyperbole
|
|
1359 (global-set-key '(meta control button3) 'popup-buffer-menu)
|
|
1360 (global-set-key '(meta shift button3) 'popup-menubar-menu)
|
|
1361
|
|
1362 ;; Here's a test of the cool new menu features (from Stig).
|
|
1363
|
|
1364 ;(setq mode-popup-menu
|
|
1365 ; '("Test Popup Menu"
|
|
1366 ; :filter cdr
|
|
1367 ; ["this item won't appear because of the menu filter" ding t]
|
|
1368 ; "--:singleLine"
|
|
1369 ; "singleLine"
|
|
1370 ; "--:doubleLine"
|
|
1371 ; "doubleLine"
|
|
1372 ; "--:singleDashedLine"
|
|
1373 ; "singleDashedLine"
|
|
1374 ; "--:doubleDashedLine"
|
|
1375 ; "doubleDashedLine"
|
|
1376 ; "--:noLine"
|
|
1377 ; "noLine"
|
|
1378 ; "--:shadowEtchedIn"
|
|
1379 ; "shadowEtchedIn"
|
|
1380 ; "--:shadowEtchedOut"
|
|
1381 ; "shadowEtchedOut"
|
|
1382 ; "--:shadowDoubleEtchedIn"
|
|
1383 ; "shadowDoubleEtchedIn"
|
|
1384 ; "--:shadowDoubleEtchedOut"
|
|
1385 ; "shadowDoubleEtchedOut"
|
|
1386 ; "--:shadowEtchedInDash"
|
|
1387 ; "shadowEtchedInDash"
|
|
1388 ; "--:shadowEtchedOutDash"
|
|
1389 ; "shadowEtchedOutDash"
|
|
1390 ; "--:shadowDoubleEtchedInDash"
|
|
1391 ; "shadowDoubleEtchedInDash"
|
|
1392 ; "--:shadowDoubleEtchedOutDash"
|
|
1393 ; "shadowDoubleEtchedOutDash"
|
|
1394 ; ))
|
|
1395
|
|
1396
|
|
1397 (provide 'x-menubar)
|
|
1398
|
|
1399 ;;; x-menubar.el ends here.
|