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