annotate lisp/menu-bar.el @ 10359:5087094fb4d7

(VALBITS, XTYPE): Adjust for new bit layout.
author Karl Heuer <kwzh@gnu.org>
date Sat, 07 Jan 1995 00:18:38 +0000
parents 49eee3cb0ffa
children 9f68d8d6357b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2488
278580be9b4a Added and corrected library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2485
diff changeset
1 ;;; menu-bar.el --- define a default menu bar.
278580be9b4a Added and corrected library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2485
diff changeset
2
278580be9b4a Added and corrected library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2485
diff changeset
3 ;; Author: RMS
5140
9cde7d7fea1f Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 4941
diff changeset
4 ;; Keywords: internal
2488
278580be9b4a Added and corrected library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2485
diff changeset
5
5473
e080a27c1dd6 (mouse-menu-choose-yank): Don't use rotate-yank-pointer; set
Roland McGrath <roland@gnu.org>
parents: 5270
diff changeset
6 ;; Copyright (C) 1993, 1994 Free Software Foundation, Inc.
2485
c34bbe650160 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 2181
diff changeset
7
c34bbe650160 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 2181
diff changeset
8 ;; This file is part of GNU Emacs.
c34bbe650160 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 2181
diff changeset
9
c34bbe650160 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 2181
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
c34bbe650160 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 2181
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
c34bbe650160 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 2181
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
c34bbe650160 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 2181
diff changeset
13 ;; any later version.
c34bbe650160 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 2181
diff changeset
14
c34bbe650160 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 2181
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
c34bbe650160 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 2181
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
c34bbe650160 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 2181
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c34bbe650160 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 2181
diff changeset
18 ;; GNU General Public License for more details.
c34bbe650160 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 2181
diff changeset
19
c34bbe650160 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 2181
diff changeset
20 ;; You should have received a copy of the GNU General Public License
c34bbe650160 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 2181
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
c34bbe650160 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 2181
diff changeset
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
c34bbe650160 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 2181
diff changeset
23
2488
278580be9b4a Added and corrected library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2485
diff changeset
24 ;;; Code:
2485
c34bbe650160 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 2181
diff changeset
25
4668
12289fa93455 Don't clobber existing binding for menu-bar in global-map.
Roland McGrath <roland@gnu.org>
parents: 4628
diff changeset
26 ;; Don't clobber an existing menu-bar keymap, to preserve any menu-bar key
12289fa93455 Don't clobber existing binding for menu-bar in global-map.
Roland McGrath <roland@gnu.org>
parents: 4628
diff changeset
27 ;; definitions made in loaddefs.el.
12289fa93455 Don't clobber existing binding for menu-bar in global-map.
Roland McGrath <roland@gnu.org>
parents: 4628
diff changeset
28 (or (lookup-key global-map [menu-bar])
12289fa93455 Don't clobber existing binding for menu-bar in global-map.
Roland McGrath <roland@gnu.org>
parents: 4628
diff changeset
29 (define-key global-map [menu-bar] (make-sparse-keymap "menu-bar")))
3504
5fb4eefbd7ac (menu-bar-help-menu): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents: 3500
diff changeset
30 (defvar menu-bar-help-menu (make-sparse-keymap "Help"))
4114
5746e25610f8 (revert-buffer): Make menu-enable form more accurate
Richard M. Stallman <rms@gnu.org>
parents: 4101
diff changeset
31 ;; Put Help item last.
5746e25610f8 (revert-buffer): Make menu-enable form more accurate
Richard M. Stallman <rms@gnu.org>
parents: 4101
diff changeset
32 (setq menu-bar-final-items '(help))
5746e25610f8 (revert-buffer): Make menu-enable form more accurate
Richard M. Stallman <rms@gnu.org>
parents: 4101
diff changeset
33 (define-key global-map [menu-bar help] (cons "Help" menu-bar-help-menu))
3504
5fb4eefbd7ac (menu-bar-help-menu): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents: 3500
diff changeset
34 (defvar menu-bar-edit-menu (make-sparse-keymap "Edit"))
2178
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
35 (define-key global-map [menu-bar edit] (cons "Edit" menu-bar-edit-menu))
3504
5fb4eefbd7ac (menu-bar-help-menu): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents: 3500
diff changeset
36 (defvar menu-bar-file-menu (make-sparse-keymap "File"))
2181
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
37 (define-key global-map [menu-bar file] (cons "File" menu-bar-file-menu))
8010
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
38
8977
c8e2c62cf851 (vc-menu-map): New menu.
Richard M. Stallman <rms@gnu.org>
parents: 8809
diff changeset
39 (defvar vc-menu-map (make-sparse-keymap "Version Control"))
c8e2c62cf851 (vc-menu-map): New menu.
Richard M. Stallman <rms@gnu.org>
parents: 8809
diff changeset
40
2177
942a63709e37 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2175
diff changeset
41 (define-key menu-bar-file-menu [exit-emacs]
2175
61d3483521d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 '("Exit Emacs" . save-buffers-kill-emacs))
8010
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
43
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
44 (define-key menu-bar-file-menu [separator-compare]
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
45 '("--"))
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
46
7420
6207bb464d7b (menu-bar-file-menu): Add Apply Patch and Compare Files
Richard M. Stallman <rms@gnu.org>
parents: 7367
diff changeset
47 (define-key menu-bar-file-menu [epatch]
6207bb464d7b (menu-bar-file-menu): Add Apply Patch and Compare Files
Richard M. Stallman <rms@gnu.org>
parents: 7367
diff changeset
48 '("Apply Patch" . menu-bar-epatch-menu))
6207bb464d7b (menu-bar-file-menu): Add Apply Patch and Compare Files
Richard M. Stallman <rms@gnu.org>
parents: 7367
diff changeset
49 (define-key menu-bar-file-menu [ediff]
8525
fcc070bca96d (menu-bar-file-menu): Compare Files renamed to Compare.
Richard M. Stallman <rms@gnu.org>
parents: 8391
diff changeset
50 '("Compare" . menu-bar-ediff-menu))
6279
8ee9dcd3771e Delete the `>' from various menu item strings.
Richard M. Stallman <rms@gnu.org>
parents: 6100
diff changeset
51 (define-key menu-bar-file-menu [emerge] '("Emerge" . menu-bar-emerge-menu))
8010
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
52
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
53 (define-key menu-bar-file-menu [separator-misc]
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
54 '("--"))
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
55
5612
bf68550ececf (menu-bar-file-menu): Add rmail, gnus, calendar items.
Richard M. Stallman <rms@gnu.org>
parents: 5473
diff changeset
56 (define-key menu-bar-file-menu [calendar] '("Calendar" . calendar))
bf68550ececf (menu-bar-file-menu): Add rmail, gnus, calendar items.
Richard M. Stallman <rms@gnu.org>
parents: 5473
diff changeset
57 (define-key menu-bar-file-menu [rmail] '("Read Mail" . rmail))
bf68550ececf (menu-bar-file-menu): Add rmail, gnus, calendar items.
Richard M. Stallman <rms@gnu.org>
parents: 5473
diff changeset
58 (define-key menu-bar-file-menu [gnus] '("Read Net News" . gnus))
8010
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
59
9422
669208821120 (menu-bar-file-menu): Don't include the frame
Richard M. Stallman <rms@gnu.org>
parents: 9356
diff changeset
60 (if (fboundp 'delete-frame)
669208821120 (menu-bar-file-menu): Don't include the frame
Richard M. Stallman <rms@gnu.org>
parents: 9356
diff changeset
61 (progn
669208821120 (menu-bar-file-menu): Don't include the frame
Richard M. Stallman <rms@gnu.org>
parents: 9356
diff changeset
62 (define-key menu-bar-file-menu [separator-frames]
669208821120 (menu-bar-file-menu): Don't include the frame
Richard M. Stallman <rms@gnu.org>
parents: 9356
diff changeset
63 '("--"))
8010
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
64
9422
669208821120 (menu-bar-file-menu): Don't include the frame
Richard M. Stallman <rms@gnu.org>
parents: 9356
diff changeset
65 (define-key menu-bar-file-menu [delete-frame]
669208821120 (menu-bar-file-menu): Don't include the frame
Richard M. Stallman <rms@gnu.org>
parents: 9356
diff changeset
66 '("Delete Frame" . delete-frame))
9667
49eee3cb0ffa (menu-bar-file-menu): Add item `Make Frame On Display'.
Richard M. Stallman <rms@gnu.org>
parents: 9518
diff changeset
67 (define-key menu-bar-file-menu [make-frame-on-display]
49eee3cb0ffa (menu-bar-file-menu): Add item `Make Frame On Display'.
Richard M. Stallman <rms@gnu.org>
parents: 9518
diff changeset
68 '("Make Frame on Display" . make-frame-on-display))
9422
669208821120 (menu-bar-file-menu): Don't include the frame
Richard M. Stallman <rms@gnu.org>
parents: 9356
diff changeset
69 (define-key menu-bar-file-menu [make-frame]
669208821120 (menu-bar-file-menu): Don't include the frame
Richard M. Stallman <rms@gnu.org>
parents: 9356
diff changeset
70 '("Make New Frame" . make-frame))))
8010
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
71
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
72 (define-key menu-bar-file-menu [separator-buffers]
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
73 '("--"))
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
74
4892
884b7620b60b Added a define-key for menu-bar-bookmark-map, so that the File menu on
Karl Fogel <kfogel@red-bean.com>
parents: 4742
diff changeset
75 (define-key menu-bar-file-menu [bookmark]
6279
8ee9dcd3771e Delete the `>' from various menu item strings.
Richard M. Stallman <rms@gnu.org>
parents: 6100
diff changeset
76 '("Bookmarks" . menu-bar-bookmark-map))
8010
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
77 (define-key menu-bar-file-menu [print-buffer]
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
78 '("Print Buffer" . print-buffer))
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
79 (define-key menu-bar-file-menu [kill-buffer]
8773
573c8013896b (menu-bar-file-menu): Rename "Kill Buffer" menu item.
Richard M. Stallman <rms@gnu.org>
parents: 8767
diff changeset
80 '("Kill (Current) Buffer" . kill-this-buffer))
8229
e772982a087b (menu-bar-file-menu): Add insert-file menu item.
Richard M. Stallman <rms@gnu.org>
parents: 8055
diff changeset
81 (define-key menu-bar-file-menu [insert-file]
e772982a087b (menu-bar-file-menu): Add insert-file menu item.
Richard M. Stallman <rms@gnu.org>
parents: 8055
diff changeset
82 '("Insert File" . insert-file))
8977
c8e2c62cf851 (vc-menu-map): New menu.
Richard M. Stallman <rms@gnu.org>
parents: 8809
diff changeset
83 (define-key menu-bar-file-menu [vc-menu]
c8e2c62cf851 (vc-menu-map): New menu.
Richard M. Stallman <rms@gnu.org>
parents: 8809
diff changeset
84 (cons "Version Control" vc-menu-map))
2178
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
85 (define-key menu-bar-file-menu [revert-buffer]
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
86 '("Revert Buffer" . revert-buffer))
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
87 (define-key menu-bar-file-menu [write-file]
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
88 '("Save Buffer As..." . write-file))
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
89 (define-key menu-bar-file-menu [save-buffer] '("Save Buffer" . save-buffer))
4069
643048c8e307 (menu-bar-file-menu): Add menu item for dired.
Richard M. Stallman <rms@gnu.org>
parents: 4061
diff changeset
90 (define-key menu-bar-file-menu [dired] '("Open Directory..." . dired))
2178
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
91 (define-key menu-bar-file-menu [open-file] '("Open File..." . find-file))
8525
fcc070bca96d (menu-bar-file-menu): Compare Files renamed to Compare.
Richard M. Stallman <rms@gnu.org>
parents: 8391
diff changeset
92
fcc070bca96d (menu-bar-file-menu): Compare Files renamed to Compare.
Richard M. Stallman <rms@gnu.org>
parents: 8391
diff changeset
93 ;; This is just one element of the ediff menu--the first.
fcc070bca96d (menu-bar-file-menu): Compare Files renamed to Compare.
Richard M. Stallman <rms@gnu.org>
parents: 8391
diff changeset
94 (define-key menu-bar-ediff-menu [window]
fcc070bca96d (menu-bar-file-menu): Compare Files renamed to Compare.
Richard M. Stallman <rms@gnu.org>
parents: 8391
diff changeset
95 '("This Window And Next Window" . compare-windows))
8010
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
96
5270
1136488153c0 (menu-bar-edit-menu): Add query-replace menu item.
Richard M. Stallman <rms@gnu.org>
parents: 5140
diff changeset
97 (define-key menu-bar-edit-menu [query-replace]
1136488153c0 (menu-bar-edit-menu): Add query-replace menu item.
Richard M. Stallman <rms@gnu.org>
parents: 5140
diff changeset
98 '("Query Replace" . query-replace))
4941
74c118ef608c (menu-bar-edit-menu): Add menu items for searching.
Richard M. Stallman <rms@gnu.org>
parents: 4892
diff changeset
99 (define-key menu-bar-edit-menu [re-search-back]
74c118ef608c (menu-bar-edit-menu): Add menu items for searching.
Richard M. Stallman <rms@gnu.org>
parents: 4892
diff changeset
100 '("Regexp Search Backwards" . re-search-backward))
74c118ef608c (menu-bar-edit-menu): Add menu items for searching.
Richard M. Stallman <rms@gnu.org>
parents: 4892
diff changeset
101 (define-key menu-bar-edit-menu [search-back]
74c118ef608c (menu-bar-edit-menu): Add menu items for searching.
Richard M. Stallman <rms@gnu.org>
parents: 4892
diff changeset
102 '("Search Backwards" . search-backward))
74c118ef608c (menu-bar-edit-menu): Add menu items for searching.
Richard M. Stallman <rms@gnu.org>
parents: 4892
diff changeset
103 (define-key menu-bar-edit-menu [re-search-fwd]
74c118ef608c (menu-bar-edit-menu): Add menu items for searching.
Richard M. Stallman <rms@gnu.org>
parents: 4892
diff changeset
104 '("Regexp Search" . re-search-forward))
74c118ef608c (menu-bar-edit-menu): Add menu items for searching.
Richard M. Stallman <rms@gnu.org>
parents: 4892
diff changeset
105 (define-key menu-bar-edit-menu [search-fwd]
74c118ef608c (menu-bar-edit-menu): Add menu items for searching.
Richard M. Stallman <rms@gnu.org>
parents: 4892
diff changeset
106 '("Search" . search-forward))
8010
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
107
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
108 (define-key menu-bar-edit-menu [separator-misc]
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
109 '("--"))
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
110
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
111 (define-key menu-bar-edit-menu [spell] '("Spell" . ispell-menu-map))
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
112 (define-key menu-bar-edit-menu [fill] '("Fill" . fill-region))
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
113
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
114 (define-key menu-bar-edit-menu [separator-edit]
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
115 '("--"))
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
116
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
117 (define-key menu-bar-edit-menu [clear] '("Clear" . delete-region))
8767
441af4b664ac (yank-menu): New variable; kill-ring in menu format.
Karl Heuer <kwzh@gnu.org>
parents: 8525
diff changeset
118
441af4b664ac (yank-menu): New variable; kill-ring in menu format.
Karl Heuer <kwzh@gnu.org>
parents: 8525
diff changeset
119 (define-key menu-bar-edit-menu [paste] '("Paste most recent" . yank))
441af4b664ac (yank-menu): New variable; kill-ring in menu format.
Karl Heuer <kwzh@gnu.org>
parents: 8525
diff changeset
120
441af4b664ac (yank-menu): New variable; kill-ring in menu format.
Karl Heuer <kwzh@gnu.org>
parents: 8525
diff changeset
121 (defvar yank-menu (cons "Select Yank" nil))
441af4b664ac (yank-menu): New variable; kill-ring in menu format.
Karl Heuer <kwzh@gnu.org>
parents: 8525
diff changeset
122 (fset 'yank-menu (cons 'keymap yank-menu))
441af4b664ac (yank-menu): New variable; kill-ring in menu format.
Karl Heuer <kwzh@gnu.org>
parents: 8525
diff changeset
123 (define-key menu-bar-edit-menu [select-paste] '("Select and Paste" . yank-menu))
2847
01a46a8f1e1b (fill-region, kill-region, delete-region)
Richard M. Stallman <rms@gnu.org>
parents: 2765
diff changeset
124 (define-key menu-bar-edit-menu [copy] '("Copy" . kill-ring-save))
01a46a8f1e1b (fill-region, kill-region, delete-region)
Richard M. Stallman <rms@gnu.org>
parents: 2765
diff changeset
125 (define-key menu-bar-edit-menu [cut] '("Cut" . kill-region))
01a46a8f1e1b (fill-region, kill-region, delete-region)
Richard M. Stallman <rms@gnu.org>
parents: 2765
diff changeset
126 (define-key menu-bar-edit-menu [undo] '("Undo" . undo))
01a46a8f1e1b (fill-region, kill-region, delete-region)
Richard M. Stallman <rms@gnu.org>
parents: 2765
diff changeset
127
01a46a8f1e1b (fill-region, kill-region, delete-region)
Richard M. Stallman <rms@gnu.org>
parents: 2765
diff changeset
128 (put 'fill-region 'menu-enable 'mark-active)
01a46a8f1e1b (fill-region, kill-region, delete-region)
Richard M. Stallman <rms@gnu.org>
parents: 2765
diff changeset
129 (put 'kill-region 'menu-enable 'mark-active)
01a46a8f1e1b (fill-region, kill-region, delete-region)
Richard M. Stallman <rms@gnu.org>
parents: 2765
diff changeset
130 (put 'kill-ring-save 'menu-enable 'mark-active)
01a46a8f1e1b (fill-region, kill-region, delete-region)
Richard M. Stallman <rms@gnu.org>
parents: 2765
diff changeset
131 (put 'yank 'menu-enable '(x-selection-exists-p))
8767
441af4b664ac (yank-menu): New variable; kill-ring in menu format.
Karl Heuer <kwzh@gnu.org>
parents: 8525
diff changeset
132 (put 'yank-menu 'menu-enable '(cdr yank-menu))
2847
01a46a8f1e1b (fill-region, kill-region, delete-region)
Richard M. Stallman <rms@gnu.org>
parents: 2765
diff changeset
133 (put 'delete-region 'menu-enable 'mark-active)
01a46a8f1e1b (fill-region, kill-region, delete-region)
Richard M. Stallman <rms@gnu.org>
parents: 2765
diff changeset
134 (put 'undo 'menu-enable '(if (eq last-command 'undo)
01a46a8f1e1b (fill-region, kill-region, delete-region)
Richard M. Stallman <rms@gnu.org>
parents: 2765
diff changeset
135 pending-undo-list
01a46a8f1e1b (fill-region, kill-region, delete-region)
Richard M. Stallman <rms@gnu.org>
parents: 2765
diff changeset
136 (consp buffer-undo-list)))
9356
28c6c3d7efb4 (query-replace): Add missing quote.
Richard M. Stallman <rms@gnu.org>
parents: 8977
diff changeset
137 (put 'query-replace 'menu-enable '(not buffer-read-only))
2175
61d3483521d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138
4061
7279958409fe (ispell-menu-map): New autoload definition.
Richard M. Stallman <rms@gnu.org>
parents: 4048
diff changeset
139 (autoload 'ispell-menu-map "ispell" nil t 'keymap)
7279958409fe (ispell-menu-map): New autoload definition.
Richard M. Stallman <rms@gnu.org>
parents: 4048
diff changeset
140
6699
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
141 ;; These are alternative definitions for the cut, paste and copy
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
142 ;; menu items. Use them if your system expects these to use the clipboard
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
143
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
144 (put 'clipboard-kill-region 'menu-enable 'mark-active)
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
145 (put 'clipboard-kill-ring-save 'menu-enable 'mark-active)
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
146 (put 'clipboard-yank 'menu-enable
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
147 '(or (x-selection-exists-p) (x-selection-exists-p 'CLIPBOARD)))
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
148
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
149 (defun clipboard-yank ()
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
150 "Reinsert the last stretch of killed text, or the clipboard contents."
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
151 (interactive)
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
152 (let ((x-select-enable-clipboard t))
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
153 (yank)))
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
154
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
155 (defun clipboard-kill-ring-save (beg end)
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
156 "Copy region to kill ring, and save in the X clipboard."
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
157 (interactive "r")
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
158 (let ((x-select-enable-clipboard t))
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
159 (kill-ring-save beg end)))
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
160
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
161 (defun clipboard-kill-region (beg end)
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
162 "Kill the region, and save it in the X clipboard."
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
163 (interactive "r")
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
164 (let ((x-select-enable-clipboard t))
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
165 (kill-region beg end)))
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
166
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
167 (defun menu-bar-enable-clipboard ()
8391
bb9718e6e844 (menu-bar-enable-clipboard): Moved here the
Richard M. Stallman <rms@gnu.org>
parents: 8347
diff changeset
168 "Make CUT, PASTE and COPY (keys and menu bar items) use the clipboard.
bb9718e6e844 (menu-bar-enable-clipboard): Moved here the
Richard M. Stallman <rms@gnu.org>
parents: 8347
diff changeset
169 Do the same for the keys of the same name."
6699
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
170 (interactive)
6948
54b252f540ea (menu-bar-enable-clipboard): Construct new cons cells.
Richard M. Stallman <rms@gnu.org>
parents: 6843
diff changeset
171 ;; We can't use constant list structure here because it becomes pure,
54b252f540ea (menu-bar-enable-clipboard): Construct new cons cells.
Richard M. Stallman <rms@gnu.org>
parents: 6843
diff changeset
172 ;; and because it gets modified with cache data.
54b252f540ea (menu-bar-enable-clipboard): Construct new cons cells.
Richard M. Stallman <rms@gnu.org>
parents: 6843
diff changeset
173 (define-key menu-bar-edit-menu [paste]
54b252f540ea (menu-bar-enable-clipboard): Construct new cons cells.
Richard M. Stallman <rms@gnu.org>
parents: 6843
diff changeset
174 (cons "Paste" 'clipboard-yank))
54b252f540ea (menu-bar-enable-clipboard): Construct new cons cells.
Richard M. Stallman <rms@gnu.org>
parents: 6843
diff changeset
175 (define-key menu-bar-edit-menu [copy]
54b252f540ea (menu-bar-enable-clipboard): Construct new cons cells.
Richard M. Stallman <rms@gnu.org>
parents: 6843
diff changeset
176 (cons "Copy" 'clipboard-kill-ring-save))
54b252f540ea (menu-bar-enable-clipboard): Construct new cons cells.
Richard M. Stallman <rms@gnu.org>
parents: 6843
diff changeset
177 (define-key menu-bar-edit-menu [cut]
8391
bb9718e6e844 (menu-bar-enable-clipboard): Moved here the
Richard M. Stallman <rms@gnu.org>
parents: 8347
diff changeset
178 (cons "Cut" 'clipboard-kill-region))
6745
469d679ca338 (global-map): Bind function keys f16, f18 and f20,
Richard M. Stallman <rms@gnu.org>
parents: 6699
diff changeset
179
8391
bb9718e6e844 (menu-bar-enable-clipboard): Moved here the
Richard M. Stallman <rms@gnu.org>
parents: 8347
diff changeset
180 (define-key global-map [f20] 'clipboard-kill-region)
bb9718e6e844 (menu-bar-enable-clipboard): Moved here the
Richard M. Stallman <rms@gnu.org>
parents: 8347
diff changeset
181 (define-key global-map [f16] 'clipboard-kill-ring-save)
bb9718e6e844 (menu-bar-enable-clipboard): Moved here the
Richard M. Stallman <rms@gnu.org>
parents: 8347
diff changeset
182 (define-key global-map [f18] 'clipboard-yank)
bb9718e6e844 (menu-bar-enable-clipboard): Moved here the
Richard M. Stallman <rms@gnu.org>
parents: 8347
diff changeset
183 ;; X11R6 versions
bb9718e6e844 (menu-bar-enable-clipboard): Moved here the
Richard M. Stallman <rms@gnu.org>
parents: 8347
diff changeset
184 (define-key global-map [cut] 'clipboard-kill-region)
bb9718e6e844 (menu-bar-enable-clipboard): Moved here the
Richard M. Stallman <rms@gnu.org>
parents: 8347
diff changeset
185 (define-key global-map [copy] 'clipboard-kill-ring-save)
bb9718e6e844 (menu-bar-enable-clipboard): Moved here the
Richard M. Stallman <rms@gnu.org>
parents: 8347
diff changeset
186 (define-key global-map [paste] 'clipboard-yank))
6699
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
187
7153
4e0683b070f8 (menu-bar-help-menu): Add item for emacs-version.
Richard M. Stallman <rms@gnu.org>
parents: 7150
diff changeset
188 (define-key menu-bar-help-menu [emacs-version]
4e0683b070f8 (menu-bar-help-menu): Add item for emacs-version.
Richard M. Stallman <rms@gnu.org>
parents: 7150
diff changeset
189 '("Show Version" . emacs-version))
7154
47987d8aba3d (menu-bar-help-menu): Add item for report-emacs-bug.
Richard M. Stallman <rms@gnu.org>
parents: 7153
diff changeset
190 (define-key menu-bar-help-menu [report-emacs-bug]
47987d8aba3d (menu-bar-help-menu): Add item for report-emacs-bug.
Richard M. Stallman <rms@gnu.org>
parents: 7153
diff changeset
191 '("Send Bug Report" . report-emacs-bug))
2178
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
192 (define-key menu-bar-help-menu [emacs-tutorial]
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
193 '("Emacs Tutorial" . help-with-tutorial))
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
194 (define-key menu-bar-help-menu [man] '("Man..." . manual-entry))
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
195 (define-key menu-bar-help-menu [describe-variable]
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
196 '("Describe Variable..." . describe-variable))
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
197 (define-key menu-bar-help-menu [describe-function]
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
198 '("Describe Function..." . describe-function))
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
199 (define-key menu-bar-help-menu [describe-key]
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
200 '("Describe Key..." . describe-key))
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
201 (define-key menu-bar-help-menu [list-keybindings]
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
202 '("List Keybindings" . describe-bindings))
2177
942a63709e37 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2175
diff changeset
203 (define-key menu-bar-help-menu [command-apropos]
2175
61d3483521d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 '("Command Apropos..." . command-apropos))
2178
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
205 (define-key menu-bar-help-menu [describe-mode]
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
206 '("Describe Mode" . describe-mode))
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
207 (define-key menu-bar-help-menu [info] '("Info" . info))
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
208
2177
942a63709e37 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2175
diff changeset
209 (define-key menu-bar-help-menu [emacs-news] '("Emacs News" . view-emacs-news))
2175
61d3483521d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 (defun kill-this-buffer () ; for the menubar
61d3483521d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 "Kills the current buffer."
61d3483521d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 (interactive)
61d3483521d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 (kill-buffer (current-buffer)))
61d3483521d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214
2178
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
215 (defun kill-this-buffer-enabled-p ()
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
216 (let ((count 0)
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
217 (buffers (buffer-list)))
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
218 (while buffers
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
219 (or (string-match "^ " (buffer-name (car buffers)))
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
220 (setq count (1+ count)))
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
221 (setq buffers (cdr buffers)))
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
222 (> count 1)))
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
223
2175
61d3483521d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 (put 'save-buffer 'menu-enable '(buffer-modified-p))
4114
5746e25610f8 (revert-buffer): Make menu-enable form more accurate
Richard M. Stallman <rms@gnu.org>
parents: 4101
diff changeset
225 (put 'revert-buffer 'menu-enable
5746e25610f8 (revert-buffer): Make menu-enable form more accurate
Richard M. Stallman <rms@gnu.org>
parents: 4101
diff changeset
226 '(or revert-buffer-function revert-buffer-insert-file-contents-function
5746e25610f8 (revert-buffer): Make menu-enable form more accurate
Richard M. Stallman <rms@gnu.org>
parents: 4101
diff changeset
227 (and (buffer-file-name)
4742
cafb372921c3 (revert-buffer): Enable menu item when the buffer is modified.
Roland McGrath <roland@gnu.org>
parents: 4668
diff changeset
228 (or (buffer-modified-p)
cafb372921c3 (revert-buffer): Enable menu item when the buffer is modified.
Roland McGrath <roland@gnu.org>
parents: 4668
diff changeset
229 (not (verify-visited-file-modtime (current-buffer)))))))
4337
cda282328afd (delete-frame): Permit it, if > 1 frame is vis or iconic.
Richard M. Stallman <rms@gnu.org>
parents: 4160
diff changeset
230 ;; Permit deleting frame if it would leave a visible or iconified frame.
cda282328afd (delete-frame): Permit it, if > 1 frame is vis or iconic.
Richard M. Stallman <rms@gnu.org>
parents: 4160
diff changeset
231 (put 'delete-frame 'menu-enable
cda282328afd (delete-frame): Permit it, if > 1 frame is vis or iconic.
Richard M. Stallman <rms@gnu.org>
parents: 4160
diff changeset
232 '(let ((frames (frame-list))
cda282328afd (delete-frame): Permit it, if > 1 frame is vis or iconic.
Richard M. Stallman <rms@gnu.org>
parents: 4160
diff changeset
233 (count 0))
cda282328afd (delete-frame): Permit it, if > 1 frame is vis or iconic.
Richard M. Stallman <rms@gnu.org>
parents: 4160
diff changeset
234 (while frames
cda282328afd (delete-frame): Permit it, if > 1 frame is vis or iconic.
Richard M. Stallman <rms@gnu.org>
parents: 4160
diff changeset
235 (if (cdr (assq 'visibility (frame-parameters (car frames))))
cda282328afd (delete-frame): Permit it, if > 1 frame is vis or iconic.
Richard M. Stallman <rms@gnu.org>
parents: 4160
diff changeset
236 (setq count (1+ count)))
cda282328afd (delete-frame): Permit it, if > 1 frame is vis or iconic.
Richard M. Stallman <rms@gnu.org>
parents: 4160
diff changeset
237 (setq frames (cdr frames)))
cda282328afd (delete-frame): Permit it, if > 1 frame is vis or iconic.
Richard M. Stallman <rms@gnu.org>
parents: 4160
diff changeset
238 (> count 1)))
2178
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
239 (put 'kill-this-buffer 'menu-enable '(kill-this-buffer-enabled-p))
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
240
2175
61d3483521d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 (put 'advertised-undo 'menu-enable
61d3483521d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 '(and (not (eq t buffer-undo-list))
61d3483521d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 (if (eq last-command 'undo)
2178
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
244 (and (boundp 'pending-undo-list)
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
245 pending-undo-list)
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
246 buffer-undo-list)))
3795
d59af8c9bc65 (mouse-menu-choose-yank): New function. Put it in the edit menu.
Richard M. Stallman <rms@gnu.org>
parents: 3504
diff changeset
247
d59af8c9bc65 (mouse-menu-choose-yank): New function. Put it in the edit menu.
Richard M. Stallman <rms@gnu.org>
parents: 3504
diff changeset
248 (defvar yank-menu-length 100
8767
441af4b664ac (yank-menu): New variable; kill-ring in menu format.
Karl Heuer <kwzh@gnu.org>
parents: 8525
diff changeset
249 "*Maximum length to display in the yank-menu.")
3795
d59af8c9bc65 (mouse-menu-choose-yank): New function. Put it in the edit menu.
Richard M. Stallman <rms@gnu.org>
parents: 3504
diff changeset
250
8767
441af4b664ac (yank-menu): New variable; kill-ring in menu format.
Karl Heuer <kwzh@gnu.org>
parents: 8525
diff changeset
251 (defun menu-bar-update-yank-menu (string old)
441af4b664ac (yank-menu): New variable; kill-ring in menu format.
Karl Heuer <kwzh@gnu.org>
parents: 8525
diff changeset
252 (let ((front (car (cdr yank-menu)))
441af4b664ac (yank-menu): New variable; kill-ring in menu format.
Karl Heuer <kwzh@gnu.org>
parents: 8525
diff changeset
253 (menu-string (if (<= (length string) yank-menu-length)
441af4b664ac (yank-menu): New variable; kill-ring in menu format.
Karl Heuer <kwzh@gnu.org>
parents: 8525
diff changeset
254 string
441af4b664ac (yank-menu): New variable; kill-ring in menu format.
Karl Heuer <kwzh@gnu.org>
parents: 8525
diff changeset
255 (substring string 0 yank-menu-length))))
441af4b664ac (yank-menu): New variable; kill-ring in menu format.
Karl Heuer <kwzh@gnu.org>
parents: 8525
diff changeset
256 ;; If we're supposed to be extending an existing string, and that
441af4b664ac (yank-menu): New variable; kill-ring in menu format.
Karl Heuer <kwzh@gnu.org>
parents: 8525
diff changeset
257 ;; string really is at the front of the menu, then update it in place.
441af4b664ac (yank-menu): New variable; kill-ring in menu format.
Karl Heuer <kwzh@gnu.org>
parents: 8525
diff changeset
258 (if (and old (or (eq old (car front))
441af4b664ac (yank-menu): New variable; kill-ring in menu format.
Karl Heuer <kwzh@gnu.org>
parents: 8525
diff changeset
259 (string= old (car front))))
3942
877f540d9717 (mouse-menu-choose-yank): Just return when x-popup-menu returns nil.
Roland McGrath <roland@gnu.org>
parents: 3898
diff changeset
260 (progn
8767
441af4b664ac (yank-menu): New variable; kill-ring in menu format.
Karl Heuer <kwzh@gnu.org>
parents: 8525
diff changeset
261 (setcar front string)
441af4b664ac (yank-menu): New variable; kill-ring in menu format.
Karl Heuer <kwzh@gnu.org>
parents: 8525
diff changeset
262 (setcar (cdr front) menu-string))
441af4b664ac (yank-menu): New variable; kill-ring in menu format.
Karl Heuer <kwzh@gnu.org>
parents: 8525
diff changeset
263 (setcdr yank-menu
441af4b664ac (yank-menu): New variable; kill-ring in menu format.
Karl Heuer <kwzh@gnu.org>
parents: 8525
diff changeset
264 (cons
441af4b664ac (yank-menu): New variable; kill-ring in menu format.
Karl Heuer <kwzh@gnu.org>
parents: 8525
diff changeset
265 (cons string (cons menu-string 'menu-bar-select-yank))
441af4b664ac (yank-menu): New variable; kill-ring in menu format.
Karl Heuer <kwzh@gnu.org>
parents: 8525
diff changeset
266 (cdr yank-menu)))))
441af4b664ac (yank-menu): New variable; kill-ring in menu format.
Karl Heuer <kwzh@gnu.org>
parents: 8525
diff changeset
267 (if (> (length (cdr yank-menu)) kill-ring-max)
441af4b664ac (yank-menu): New variable; kill-ring in menu format.
Karl Heuer <kwzh@gnu.org>
parents: 8525
diff changeset
268 (setcdr (nthcdr kill-ring-max yank-menu) nil)))
441af4b664ac (yank-menu): New variable; kill-ring in menu format.
Karl Heuer <kwzh@gnu.org>
parents: 8525
diff changeset
269
441af4b664ac (yank-menu): New variable; kill-ring in menu format.
Karl Heuer <kwzh@gnu.org>
parents: 8525
diff changeset
270 (defun menu-bar-select-yank ()
441af4b664ac (yank-menu): New variable; kill-ring in menu format.
Karl Heuer <kwzh@gnu.org>
parents: 8525
diff changeset
271 (interactive "*")
441af4b664ac (yank-menu): New variable; kill-ring in menu format.
Karl Heuer <kwzh@gnu.org>
parents: 8525
diff changeset
272 (push-mark (point))
441af4b664ac (yank-menu): New variable; kill-ring in menu format.
Karl Heuer <kwzh@gnu.org>
parents: 8525
diff changeset
273 (insert last-command-event))
2181
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
274
7150
b78bfe054561 Make a sub-keymap for the Buffers menu bar item.
Richard M. Stallman <rms@gnu.org>
parents: 6948
diff changeset
275 (define-key global-map [menu-bar buffer] '("Buffers" . menu-bar-buffers))
b78bfe054561 Make a sub-keymap for the Buffers menu bar item.
Richard M. Stallman <rms@gnu.org>
parents: 6948
diff changeset
276
b78bfe054561 Make a sub-keymap for the Buffers menu bar item.
Richard M. Stallman <rms@gnu.org>
parents: 6948
diff changeset
277 (defalias 'menu-bar-buffers (make-sparse-keymap "Buffers"))
2178
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
278
2181
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
279 (defvar buffers-menu-max-size 10
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
280 "*Maximum number of entries which may appear on the Buffers menu.
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
281 If this is 10, then only the ten most-recently-selected buffers are shown.
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
282 If this is nil, then all buffers are shown.
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
283 A large number or nil slows down menu responsiveness.")
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
284
4628
e55cc9fdaa92 (list-buffers-directory): Add declaration.
Richard M. Stallman <rms@gnu.org>
parents: 4603
diff changeset
285 (defvar list-buffers-directory nil)
e55cc9fdaa92 (list-buffers-directory): Add declaration.
Richard M. Stallman <rms@gnu.org>
parents: 4603
diff changeset
286
9667
49eee3cb0ffa (menu-bar-file-menu): Add item `Make Frame On Display'.
Richard M. Stallman <rms@gnu.org>
parents: 9518
diff changeset
287 (defvar menu-bar-update-buffers-maxbuf)
49eee3cb0ffa (menu-bar-file-menu): Add item `Make Frame On Display'.
Richard M. Stallman <rms@gnu.org>
parents: 9518
diff changeset
288
7150
b78bfe054561 Make a sub-keymap for the Buffers menu bar item.
Richard M. Stallman <rms@gnu.org>
parents: 6948
diff changeset
289 (defun menu-bar-select-buffer ()
b78bfe054561 Make a sub-keymap for the Buffers menu bar item.
Richard M. Stallman <rms@gnu.org>
parents: 6948
diff changeset
290 (interactive)
b78bfe054561 Make a sub-keymap for the Buffers menu bar item.
Richard M. Stallman <rms@gnu.org>
parents: 6948
diff changeset
291 (switch-to-buffer last-command-event))
b78bfe054561 Make a sub-keymap for the Buffers menu bar item.
Richard M. Stallman <rms@gnu.org>
parents: 6948
diff changeset
292
b78bfe054561 Make a sub-keymap for the Buffers menu bar item.
Richard M. Stallman <rms@gnu.org>
parents: 6948
diff changeset
293 (defun menu-bar-select-frame ()
b78bfe054561 Make a sub-keymap for the Buffers menu bar item.
Richard M. Stallman <rms@gnu.org>
parents: 6948
diff changeset
294 (interactive)
b78bfe054561 Make a sub-keymap for the Buffers menu bar item.
Richard M. Stallman <rms@gnu.org>
parents: 6948
diff changeset
295 (make-frame-visible last-command-event)
b78bfe054561 Make a sub-keymap for the Buffers menu bar item.
Richard M. Stallman <rms@gnu.org>
parents: 6948
diff changeset
296 (raise-frame last-command-event)
b78bfe054561 Make a sub-keymap for the Buffers menu bar item.
Richard M. Stallman <rms@gnu.org>
parents: 6948
diff changeset
297 (select-frame last-command-event))
b78bfe054561 Make a sub-keymap for the Buffers menu bar item.
Richard M. Stallman <rms@gnu.org>
parents: 6948
diff changeset
298
9518
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
299 (defun menu-bar-update-buffers-1 (elt)
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
300 (cons (format
9667
49eee3cb0ffa (menu-bar-file-menu): Add item `Make Frame On Display'.
Richard M. Stallman <rms@gnu.org>
parents: 9518
diff changeset
301 (format "%%%ds %%s%%s %%s" menu-bar-update-buffers-maxbuf)
9518
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
302 (cdr elt)
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
303 (if (buffer-modified-p (car elt))
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
304 "*" " ")
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
305 (save-excursion
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
306 (set-buffer (car elt))
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
307 (if buffer-read-only "%" " "))
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
308 (let ((file
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
309 (or (buffer-file-name (car elt))
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
310 (save-excursion
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
311 (set-buffer (car elt))
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
312 list-buffers-directory)
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
313 "")))
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
314 (setq file (or (file-name-directory file)
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
315 ""))
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
316 (if (> (length file) 20)
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
317 (setq file (concat "..." (substring file -17))))
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
318 file))
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
319 (car elt)))
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
320
7150
b78bfe054561 Make a sub-keymap for the Buffers menu bar item.
Richard M. Stallman <rms@gnu.org>
parents: 6948
diff changeset
321 (defun menu-bar-update-buffers ()
8316
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
322 ;; If user discards the Buffers item, play along.
8347
0fff2106fa43 (menu-bar-update-buffers): Use (current-global-map), not global-map.
Richard M. Stallman <rms@gnu.org>
parents: 8320
diff changeset
323 (and (lookup-key (current-global-map) [menu-bar buffer])
8316
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
324 (frame-or-buffer-changed-p)
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
325 (let ((buffers (buffer-list))
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
326 (frames (frame-list))
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
327 buffers-menu frames-menu)
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
328 ;; If requested, list only the N most recently selected buffers.
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
329 (if (and (integerp buffers-menu-max-size)
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
330 (> buffers-menu-max-size 1))
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
331 (if (> (length buffers) buffers-menu-max-size)
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
332 (setcdr (nthcdr buffers-menu-max-size buffers) nil)))
7150
b78bfe054561 Make a sub-keymap for the Buffers menu bar item.
Richard M. Stallman <rms@gnu.org>
parents: 6948
diff changeset
333
8316
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
334 ;; Make the menu of buffers proper.
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
335 (setq buffers-menu
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
336 (cons "Select Buffer"
9518
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
337 (let* ((buffer-list
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
338 (mapcar 'list buffers))
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
339 tail
9667
49eee3cb0ffa (menu-bar-file-menu): Add item `Make Frame On Display'.
Richard M. Stallman <rms@gnu.org>
parents: 9518
diff changeset
340 (menu-bar-update-buffers-maxbuf 0)
9518
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
341 (maxlen 0)
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
342 alist
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
343 head)
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
344 ;; Put into each element of buffer-list
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
345 ;; the name for actual display,
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
346 ;; perhaps truncated in the middle.
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
347 (setq tail buffer-list)
8316
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
348 (while tail
9518
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
349 (let ((name (buffer-name (car (car tail)))))
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
350 (setcdr (car tail)
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
351 (if (> (length name) 27)
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
352 (concat (substring name 0 12)
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
353 "..."
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
354 (substring name -12))
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
355 name)))
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
356 (setq tail (cdr tail)))
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
357 ;; Compute the maximum length of any name.
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
358 (setq tail buffer-list)
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
359 (while tail
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
360 (or (eq ?\ (aref (cdr (car tail)) 0))
9667
49eee3cb0ffa (menu-bar-file-menu): Add item `Make Frame On Display'.
Richard M. Stallman <rms@gnu.org>
parents: 9518
diff changeset
361 (setq menu-bar-update-buffers-maxbuf
49eee3cb0ffa (menu-bar-file-menu): Add item `Make Frame On Display'.
Richard M. Stallman <rms@gnu.org>
parents: 9518
diff changeset
362 (max menu-bar-update-buffers-maxbuf
9518
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
363 (length (cdr (car tail))))))
8316
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
364 (setq tail (cdr tail)))
9518
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
365 ;; Set ALIST to an alist of the form
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
366 ;; ITEM-STRING . BUFFER
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
367 (setq tail buffer-list)
8316
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
368 (while tail
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
369 (let ((elt (car tail)))
9518
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
370 (or (eq ?\ (aref (cdr elt) 0))
8316
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
371 (setq alist (cons
9518
69072971d37e (menu-bar-update-buffers-1): New subroutine
Richard M. Stallman <rms@gnu.org>
parents: 9422
diff changeset
372 (menu-bar-update-buffers-1 elt)
8316
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
373 alist)))
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
374 (and alist (> (length (car (car alist))) maxlen)
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
375 (setq maxlen (length (car (car alist))))))
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
376 (setq tail (cdr tail)))
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
377 (setq alist (nreverse alist))
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
378 (nconc (mapcar '(lambda (pair)
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
379 ;; This is somewhat risque, to use
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
380 ;; the buffer name itself as the event
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
381 ;; type to define, but it works.
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
382 ;; It would not work to use the buffer
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
383 ;; since a buffer as an event has its
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
384 ;; own meaning.
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
385 (nconc (list (buffer-name (cdr pair))
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
386 (car pair)
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
387 (cons nil nil))
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
388 'menu-bar-select-buffer))
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
389 alist)
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
390 (list
7811
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
391 (cons
8316
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
392 'list-buffers
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
393 (cons
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
394 (concat (make-string (max (- (/ maxlen 2) 8) 0)
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
395 ?\ )
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
396 "List All Buffers")
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
397 'list-buffers)))))))
7150
b78bfe054561 Make a sub-keymap for the Buffers menu bar item.
Richard M. Stallman <rms@gnu.org>
parents: 6948
diff changeset
398
7239
385ac6718f28 (menu-bar-update-buffers): Fix misspelled variable.
Karl Heuer <kwzh@gnu.org>
parents: 7234
diff changeset
399
8316
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
400 ;; Make a Frames menu if we have more than one frame.
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
401 (if (cdr frames)
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
402 (setq frames-menu
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
403 (cons "Select Frame"
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
404 (mapcar '(lambda (frame)
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
405 (nconc (list frame
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
406 (cdr (assq 'name
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
407 (frame-parameters frame)))
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
408 (cons nil nil))
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
409 'menu-bar-select-frame))
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
410 frames))))
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
411 (if buffers-menu
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
412 (setq buffers-menu (cons 'keymap buffers-menu)))
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
413 (if frames-menu
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
414 (setq frames-menu (cons 'keymap frames-menu)))
8347
0fff2106fa43 (menu-bar-update-buffers): Use (current-global-map), not global-map.
Richard M. Stallman <rms@gnu.org>
parents: 8320
diff changeset
415 (define-key (current-global-map) [menu-bar buffer]
8316
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
416 (cons "Buffers"
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
417 (if (and buffers-menu frames-menu)
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
418 (list 'keymap "Buffers and Frames"
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
419 (cons 'buffers (cons "Buffers" buffers-menu))
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
420 (cons 'frames (cons "Frames" frames-menu)))
abf26f5c67e4 (menu-bar-update-buffers): If Buffers item is gone,
Richard M. Stallman <rms@gnu.org>
parents: 8229
diff changeset
421 (or buffers-menu frames-menu 'undefined)))))))
2181
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
422
7150
b78bfe054561 Make a sub-keymap for the Buffers menu bar item.
Richard M. Stallman <rms@gnu.org>
parents: 6948
diff changeset
423 (add-hook 'menu-bar-update-hook 'menu-bar-update-buffers)
2181
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
424
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
425 ;; this version is too slow
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
426 ;;;(defun format-buffers-menu-line (buffer)
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
427 ;;; "Returns a string to represent the given buffer in the Buffer menu.
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
428 ;;;nil means the buffer shouldn't be listed. You can redefine this."
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
429 ;;; (if (string-match "\\` " (buffer-name buffer))
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
430 ;;; nil
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
431 ;;; (save-excursion
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
432 ;;; (set-buffer buffer)
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
433 ;;; (let ((size (buffer-size)))
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
434 ;;; (format "%s%s %-19s %6s %-15s %s"
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
435 ;;; (if (buffer-modified-p) "*" " ")
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
436 ;;; (if buffer-read-only "%" " ")
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
437 ;;; (buffer-name)
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
438 ;;; size
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
439 ;;; mode-name
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
440 ;;; (or (buffer-file-name) ""))))))
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
441
8055
6a0af6085c1a (menu-bar-mode): Make this a global variable.
Richard M. Stallman <rms@gnu.org>
parents: 8010
diff changeset
442 (defvar menu-bar-mode nil)
6a0af6085c1a (menu-bar-mode): Make this a global variable.
Richard M. Stallman <rms@gnu.org>
parents: 8010
diff changeset
443
2847
01a46a8f1e1b (fill-region, kill-region, delete-region)
Richard M. Stallman <rms@gnu.org>
parents: 2765
diff changeset
444 (defun menu-bar-mode (flag)
3007
e41b3dc686bb (menu-bar-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 2847
diff changeset
445 "Toggle display of a menu bar on each frame.
2847
01a46a8f1e1b (fill-region, kill-region, delete-region)
Richard M. Stallman <rms@gnu.org>
parents: 2765
diff changeset
446 This command applies to all frames that exist and frames to be
01a46a8f1e1b (fill-region, kill-region, delete-region)
Richard M. Stallman <rms@gnu.org>
parents: 2765
diff changeset
447 created in the future.
01a46a8f1e1b (fill-region, kill-region, delete-region)
Richard M. Stallman <rms@gnu.org>
parents: 2765
diff changeset
448 With a numeric argument, if the argument is negative,
3007
e41b3dc686bb (menu-bar-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 2847
diff changeset
449 turn off menu bars; otherwise, turn on menu bars."
4470
6dd518d1f5aa (menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents: 4337
diff changeset
450 (interactive "P")
6dd518d1f5aa (menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents: 4337
diff changeset
451
8055
6a0af6085c1a (menu-bar-mode): Make this a global variable.
Richard M. Stallman <rms@gnu.org>
parents: 8010
diff changeset
452 ;; Make menu-bar-mode and default-frame-alist consistent.
6a0af6085c1a (menu-bar-mode): Make this a global variable.
Richard M. Stallman <rms@gnu.org>
parents: 8010
diff changeset
453 (let ((default (assq 'menu-bar-lines default-frame-alist)))
6a0af6085c1a (menu-bar-mode): Make this a global variable.
Richard M. Stallman <rms@gnu.org>
parents: 8010
diff changeset
454 (if default
6a0af6085c1a (menu-bar-mode): Make this a global variable.
Richard M. Stallman <rms@gnu.org>
parents: 8010
diff changeset
455 (setq menu-bar-mode (not (eq (cdr default) 0)))
6a0af6085c1a (menu-bar-mode): Make this a global variable.
Richard M. Stallman <rms@gnu.org>
parents: 8010
diff changeset
456 (setq default-frame-alist
6a0af6085c1a (menu-bar-mode): Make this a global variable.
Richard M. Stallman <rms@gnu.org>
parents: 8010
diff changeset
457 (cons (cons 'menu-bar-lines (if menu-bar-mode 1 0))
6a0af6085c1a (menu-bar-mode): Make this a global variable.
Richard M. Stallman <rms@gnu.org>
parents: 8010
diff changeset
458 default-frame-alist))))
4470
6dd518d1f5aa (menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents: 4337
diff changeset
459
8055
6a0af6085c1a (menu-bar-mode): Make this a global variable.
Richard M. Stallman <rms@gnu.org>
parents: 8010
diff changeset
460 ;; Toggle or set the mode, according to FLAG.
6a0af6085c1a (menu-bar-mode): Make this a global variable.
Richard M. Stallman <rms@gnu.org>
parents: 8010
diff changeset
461 (setq menu-bar-mode (if (null flag) (not menu-bar-mode)
6a0af6085c1a (menu-bar-mode): Make this a global variable.
Richard M. Stallman <rms@gnu.org>
parents: 8010
diff changeset
462 (> (prefix-numeric-value flag) 0)))
4470
6dd518d1f5aa (menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents: 4337
diff changeset
463
8055
6a0af6085c1a (menu-bar-mode): Make this a global variable.
Richard M. Stallman <rms@gnu.org>
parents: 8010
diff changeset
464 ;; Apply it to default-frame-alist.
6a0af6085c1a (menu-bar-mode): Make this a global variable.
Richard M. Stallman <rms@gnu.org>
parents: 8010
diff changeset
465 (let ((parameter (assq 'menu-bar-lines default-frame-alist)))
6a0af6085c1a (menu-bar-mode): Make this a global variable.
Richard M. Stallman <rms@gnu.org>
parents: 8010
diff changeset
466 (if (consp parameter)
6a0af6085c1a (menu-bar-mode): Make this a global variable.
Richard M. Stallman <rms@gnu.org>
parents: 8010
diff changeset
467 (setcdr parameter (if menu-bar-mode 1 0))
6a0af6085c1a (menu-bar-mode): Make this a global variable.
Richard M. Stallman <rms@gnu.org>
parents: 8010
diff changeset
468 (setq default-frame-alist
6a0af6085c1a (menu-bar-mode): Make this a global variable.
Richard M. Stallman <rms@gnu.org>
parents: 8010
diff changeset
469 (cons (cons 'menu-bar-lines (if menu-bar-mode 1 0))
6a0af6085c1a (menu-bar-mode): Make this a global variable.
Richard M. Stallman <rms@gnu.org>
parents: 8010
diff changeset
470 default-frame-alist))))
4470
6dd518d1f5aa (menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents: 4337
diff changeset
471
8055
6a0af6085c1a (menu-bar-mode): Make this a global variable.
Richard M. Stallman <rms@gnu.org>
parents: 8010
diff changeset
472 ;; Apply it to existing frames.
6a0af6085c1a (menu-bar-mode): Make this a global variable.
Richard M. Stallman <rms@gnu.org>
parents: 8010
diff changeset
473 (let ((frames (frame-list)))
6a0af6085c1a (menu-bar-mode): Make this a global variable.
Richard M. Stallman <rms@gnu.org>
parents: 8010
diff changeset
474 (while frames
6a0af6085c1a (menu-bar-mode): Make this a global variable.
Richard M. Stallman <rms@gnu.org>
parents: 8010
diff changeset
475 (let ((height (cdr (assq 'height (frame-parameters (car frames))))))
6a0af6085c1a (menu-bar-mode): Make this a global variable.
Richard M. Stallman <rms@gnu.org>
parents: 8010
diff changeset
476 (modify-frame-parameters (car frames)
6a0af6085c1a (menu-bar-mode): Make this a global variable.
Richard M. Stallman <rms@gnu.org>
parents: 8010
diff changeset
477 (list (cons 'menu-bar-lines
6a0af6085c1a (menu-bar-mode): Make this a global variable.
Richard M. Stallman <rms@gnu.org>
parents: 8010
diff changeset
478 (if menu-bar-mode 1 0))))
6a0af6085c1a (menu-bar-mode): Make this a global variable.
Richard M. Stallman <rms@gnu.org>
parents: 8010
diff changeset
479 (modify-frame-parameters (car frames)
6a0af6085c1a (menu-bar-mode): Make this a global variable.
Richard M. Stallman <rms@gnu.org>
parents: 8010
diff changeset
480 (list (cons 'height height))))
6a0af6085c1a (menu-bar-mode): Make this a global variable.
Richard M. Stallman <rms@gnu.org>
parents: 8010
diff changeset
481 (setq frames (cdr frames)))))
2485
c34bbe650160 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 2181
diff changeset
482
2765
0eb1a195f56e Provide 'menu-bar.
Richard M. Stallman <rms@gnu.org>
parents: 2695
diff changeset
483 (provide 'menu-bar)
0eb1a195f56e Provide 'menu-bar.
Richard M. Stallman <rms@gnu.org>
parents: 2695
diff changeset
484
2488
278580be9b4a Added and corrected library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2485
diff changeset
485 ;;; menu-bar.el ends here