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