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