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