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