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