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