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