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