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