annotate lisp/menu-bar.el @ 8047:fb950b66d754

(Finsert_file_contents): Fix check for non-regular files.
author Karl Heuer <kwzh@gnu.org>
date Sat, 25 Jun 1994 00:13:53 +0000
parents e199eda519b5
children 6a0af6085c1a
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
2177
942a63709e37 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2175
diff changeset
39 (define-key menu-bar-file-menu [exit-emacs]
2175
61d3483521d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 '("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
41
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
42 (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
43 '("--"))
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
44
7420
6207bb464d7b (menu-bar-file-menu): Add Apply Patch and Compare Files
Richard M. Stallman <rms@gnu.org>
parents: 7367
diff changeset
45 (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
46 '("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
47 (define-key menu-bar-file-menu [ediff]
6207bb464d7b (menu-bar-file-menu): Add Apply Patch and Compare Files
Richard M. Stallman <rms@gnu.org>
parents: 7367
diff changeset
48 '("Compare Files" . menu-bar-ediff-menu))
6279
8ee9dcd3771e Delete the `>' from various menu item strings.
Richard M. Stallman <rms@gnu.org>
parents: 6100
diff changeset
49 (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
50
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
51 (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
52 '("--"))
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
53
5612
bf68550ececf (menu-bar-file-menu): Add rmail, gnus, calendar items.
Richard M. Stallman <rms@gnu.org>
parents: 5473
diff changeset
54 (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
55 (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
56 (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
57
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
58 (define-key menu-bar-file-menu [separator-frames]
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
59 '("--"))
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
60
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
61 (define-key menu-bar-file-menu [delete-frame] '("Delete Frame" . delete-frame))
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
62 (define-key menu-bar-file-menu [make-frame] '("Make New Frame" . make-frame))
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
63
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
64 (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
65 '("--"))
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
66
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
67 (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
68 '("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
69 (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
70 '("Print Buffer" . print-buffer))
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
71 (define-key menu-bar-file-menu [kill-buffer]
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
72 '("Kill Buffer" . kill-this-buffer))
2178
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
73 (define-key menu-bar-file-menu [revert-buffer]
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
74 '("Revert Buffer" . revert-buffer))
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
75 (define-key menu-bar-file-menu [write-file]
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
76 '("Save Buffer As..." . write-file))
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
77 (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
78 (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
79 (define-key menu-bar-file-menu [open-file] '("Open File..." . find-file))
8010
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
80
5270
1136488153c0 (menu-bar-edit-menu): Add query-replace menu item.
Richard M. Stallman <rms@gnu.org>
parents: 5140
diff changeset
81 (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
82 '("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
83 (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
84 '("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
85 (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
86 '("Search Backwards" . search-backward))
74c118ef608c (menu-bar-edit-menu): Add menu items for searching.
Richard M. Stallman <rms@gnu.org>
parents: 4892
diff changeset
87 (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
88 '("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
89 (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
90 '("Search" . search-forward))
8010
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
91
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
92 (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
93 '("--"))
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
94
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
95 (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
96 (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
97
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
98 (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
99 '("--"))
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
100
e199eda519b5 Rearrange the edit and file menus, and add separators.
Richard M. Stallman <rms@gnu.org>
parents: 7811
diff changeset
101 (define-key menu-bar-edit-menu [clear] '("Clear" . delete-region))
4025
92cd14c9ea80 (mouse-menu-choose-yank): Change menu title to "Choose Next Yank".
Roland McGrath <roland@gnu.org>
parents: 3958
diff changeset
102 (define-key menu-bar-edit-menu [choose-next-paste]
5797
c4fff7ff8bdd Use > as convention for another menu follows.
Richard M. Stallman <rms@gnu.org>
parents: 5612
diff changeset
103 '("Choose Next Paste >" . mouse-menu-choose-yank))
2847
01a46a8f1e1b (fill-region, kill-region, delete-region)
Richard M. Stallman <rms@gnu.org>
parents: 2765
diff changeset
104 (define-key menu-bar-edit-menu [paste] '("Paste" . yank))
01a46a8f1e1b (fill-region, kill-region, delete-region)
Richard M. Stallman <rms@gnu.org>
parents: 2765
diff changeset
105 (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
106 (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
107 (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
108
01a46a8f1e1b (fill-region, kill-region, delete-region)
Richard M. Stallman <rms@gnu.org>
parents: 2765
diff changeset
109 (put 'fill-region 'menu-enable 'mark-active)
01a46a8f1e1b (fill-region, kill-region, delete-region)
Richard M. Stallman <rms@gnu.org>
parents: 2765
diff changeset
110 (put 'kill-region 'menu-enable 'mark-active)
01a46a8f1e1b (fill-region, kill-region, delete-region)
Richard M. Stallman <rms@gnu.org>
parents: 2765
diff changeset
111 (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
112 (put 'yank 'menu-enable '(x-selection-exists-p))
01a46a8f1e1b (fill-region, kill-region, delete-region)
Richard M. Stallman <rms@gnu.org>
parents: 2765
diff changeset
113 (put 'delete-region 'menu-enable 'mark-active)
01a46a8f1e1b (fill-region, kill-region, delete-region)
Richard M. Stallman <rms@gnu.org>
parents: 2765
diff changeset
114 (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
115 pending-undo-list
01a46a8f1e1b (fill-region, kill-region, delete-region)
Richard M. Stallman <rms@gnu.org>
parents: 2765
diff changeset
116 (consp buffer-undo-list)))
5270
1136488153c0 (menu-bar-edit-menu): Add query-replace menu item.
Richard M. Stallman <rms@gnu.org>
parents: 5140
diff changeset
117 (put 'query-replace 'menu-enable (not buffer-read-only))
2175
61d3483521d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118
4061
7279958409fe (ispell-menu-map): New autoload definition.
Richard M. Stallman <rms@gnu.org>
parents: 4048
diff changeset
119 (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
120
6699
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
121 ;; 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
122 ;; 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
123
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
124 (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
125 (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
126 (put 'clipboard-yank 'menu-enable
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
127 '(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
128
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
129 (defun clipboard-yank ()
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
130 "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
131 (interactive)
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
132 (let ((x-select-enable-clipboard t))
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
133 (yank)))
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
134
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
135 (defun clipboard-kill-ring-save (beg end)
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
136 "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
137 (interactive "r")
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
138 (let ((x-select-enable-clipboard t))
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
139 (kill-ring-save beg end)))
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
140
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
141 (defun clipboard-kill-region (beg end)
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
142 "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
143 (interactive "r")
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
144 (let ((x-select-enable-clipboard t))
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
145 (kill-region beg end)))
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
146
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
147 (defun menu-bar-enable-clipboard ()
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
148 "Make the menu bar CUT, PASTE and COPY items use the clipboard."
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
149 (interactive)
6948
54b252f540ea (menu-bar-enable-clipboard): Construct new cons cells.
Richard M. Stallman <rms@gnu.org>
parents: 6843
diff changeset
150 ;; 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
151 ;; 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
152 (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
153 (cons "Paste" 'clipboard-yank))
54b252f540ea (menu-bar-enable-clipboard): Construct new cons cells.
Richard M. Stallman <rms@gnu.org>
parents: 6843
diff changeset
154 (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
155 (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
156 (define-key menu-bar-edit-menu [cut]
54b252f540ea (menu-bar-enable-clipboard): Construct new cons cells.
Richard M. Stallman <rms@gnu.org>
parents: 6843
diff changeset
157 (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
158
469d679ca338 (global-map): Bind function keys f16, f18 and f20,
Richard M. Stallman <rms@gnu.org>
parents: 6699
diff changeset
159 ;; Sun expects these commands on these keys, so why not?
469d679ca338 (global-map): Bind function keys f16, f18 and f20,
Richard M. Stallman <rms@gnu.org>
parents: 6699
diff changeset
160 (define-key global-map [f20] 'clipboard-kill-region)
469d679ca338 (global-map): Bind function keys f16, f18 and f20,
Richard M. Stallman <rms@gnu.org>
parents: 6699
diff changeset
161 (define-key global-map [f16] 'clipboard-kill-ring-save)
469d679ca338 (global-map): Bind function keys f16, f18 and f20,
Richard M. Stallman <rms@gnu.org>
parents: 6699
diff changeset
162 (define-key global-map [f18] 'clipboard-yank)
6699
59e74bc34228 (clipboard-yank, clipboard-kill-ring-save)
Richard M. Stallman <rms@gnu.org>
parents: 6513
diff changeset
163
7153
4e0683b070f8 (menu-bar-help-menu): Add item for emacs-version.
Richard M. Stallman <rms@gnu.org>
parents: 7150
diff changeset
164 (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
165 '("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
166 (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
167 '("Send Bug Report" . report-emacs-bug))
2178
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
168 (define-key menu-bar-help-menu [emacs-tutorial]
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
169 '("Emacs Tutorial" . help-with-tutorial))
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
170 (define-key menu-bar-help-menu [man] '("Man..." . manual-entry))
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
171 (define-key menu-bar-help-menu [describe-variable]
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
172 '("Describe Variable..." . describe-variable))
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
173 (define-key menu-bar-help-menu [describe-function]
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
174 '("Describe Function..." . describe-function))
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
175 (define-key menu-bar-help-menu [describe-key]
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
176 '("Describe Key..." . describe-key))
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
177 (define-key menu-bar-help-menu [list-keybindings]
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
178 '("List Keybindings" . describe-bindings))
2177
942a63709e37 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2175
diff changeset
179 (define-key menu-bar-help-menu [command-apropos]
2175
61d3483521d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 '("Command Apropos..." . command-apropos))
2178
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
181 (define-key menu-bar-help-menu [describe-mode]
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
182 '("Describe Mode" . describe-mode))
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
183 (define-key menu-bar-help-menu [info] '("Info" . info))
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
184
2177
942a63709e37 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2175
diff changeset
185 (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
186 (defun kill-this-buffer () ; for the menubar
61d3483521d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 "Kills the current buffer."
61d3483521d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 (interactive)
61d3483521d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 (kill-buffer (current-buffer)))
61d3483521d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190
2178
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
191 (defun kill-this-buffer-enabled-p ()
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
192 (let ((count 0)
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
193 (buffers (buffer-list)))
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
194 (while buffers
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
195 (or (string-match "^ " (buffer-name (car buffers)))
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
196 (setq count (1+ count)))
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
197 (setq buffers (cdr buffers)))
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
198 (> count 1)))
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
199
2175
61d3483521d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 (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
201 (put 'revert-buffer 'menu-enable
5746e25610f8 (revert-buffer): Make menu-enable form more accurate
Richard M. Stallman <rms@gnu.org>
parents: 4101
diff changeset
202 '(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
203 (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
204 (or (buffer-modified-p)
cafb372921c3 (revert-buffer): Enable menu item when the buffer is modified.
Roland McGrath <roland@gnu.org>
parents: 4668
diff changeset
205 (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
206 ;; 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
207 (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
208 '(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
209 (count 0))
cda282328afd (delete-frame): Permit it, if > 1 frame is vis or iconic.
Richard M. Stallman <rms@gnu.org>
parents: 4160
diff changeset
210 (while frames
cda282328afd (delete-frame): Permit it, if > 1 frame is vis or iconic.
Richard M. Stallman <rms@gnu.org>
parents: 4160
diff changeset
211 (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
212 (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
213 (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
214 (> count 1)))
2178
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
215 (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
216
2175
61d3483521d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 (put 'advertised-undo 'menu-enable
61d3483521d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 '(and (not (eq t buffer-undo-list))
61d3483521d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 (if (eq last-command 'undo)
2178
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
220 (and (boundp 'pending-undo-list)
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
221 pending-undo-list)
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
222 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
223
d59af8c9bc65 (mouse-menu-choose-yank): New function. Put it in the edit menu.
Richard M. Stallman <rms@gnu.org>
parents: 3504
diff changeset
224 (defvar yank-menu-length 100
d59af8c9bc65 (mouse-menu-choose-yank): New function. Put it in the edit menu.
Richard M. Stallman <rms@gnu.org>
parents: 3504
diff changeset
225 "*Maximum length of an item in the menu for \
d59af8c9bc65 (mouse-menu-choose-yank): New function. Put it in the edit menu.
Richard M. Stallman <rms@gnu.org>
parents: 3504
diff changeset
226 \\[mouse-menu-choose-yank].")
d59af8c9bc65 (mouse-menu-choose-yank): New function. Put it in the edit menu.
Richard M. Stallman <rms@gnu.org>
parents: 3504
diff changeset
227
d59af8c9bc65 (mouse-menu-choose-yank): New function. Put it in the edit menu.
Richard M. Stallman <rms@gnu.org>
parents: 3504
diff changeset
228 (defun mouse-menu-choose-yank (event)
d59af8c9bc65 (mouse-menu-choose-yank): New function. Put it in the edit menu.
Richard M. Stallman <rms@gnu.org>
parents: 3504
diff changeset
229 "Pop up a menu of the kill-ring for selection with the mouse.
d59af8c9bc65 (mouse-menu-choose-yank): New function. Put it in the edit menu.
Richard M. Stallman <rms@gnu.org>
parents: 3504
diff changeset
230 The kill-ring-yank-pointer is moved to the selected element.
d59af8c9bc65 (mouse-menu-choose-yank): New function. Put it in the edit menu.
Richard M. Stallman <rms@gnu.org>
parents: 3504
diff changeset
231 A subsequent \\[yank] yanks the choice just selected."
d59af8c9bc65 (mouse-menu-choose-yank): New function. Put it in the edit menu.
Richard M. Stallman <rms@gnu.org>
parents: 3504
diff changeset
232 (interactive "e")
d59af8c9bc65 (mouse-menu-choose-yank): New function. Put it in the edit menu.
Richard M. Stallman <rms@gnu.org>
parents: 3504
diff changeset
233 (let* ((count 0)
d59af8c9bc65 (mouse-menu-choose-yank): New function. Put it in the edit menu.
Richard M. Stallman <rms@gnu.org>
parents: 3504
diff changeset
234 (menu (mapcar (lambda (string)
d59af8c9bc65 (mouse-menu-choose-yank): New function. Put it in the edit menu.
Richard M. Stallman <rms@gnu.org>
parents: 3504
diff changeset
235 (if (> (length string) yank-menu-length)
d59af8c9bc65 (mouse-menu-choose-yank): New function. Put it in the edit menu.
Richard M. Stallman <rms@gnu.org>
parents: 3504
diff changeset
236 (setq string (substring string
d59af8c9bc65 (mouse-menu-choose-yank): New function. Put it in the edit menu.
Richard M. Stallman <rms@gnu.org>
parents: 3504
diff changeset
237 0 yank-menu-length)))
d59af8c9bc65 (mouse-menu-choose-yank): New function. Put it in the edit menu.
Richard M. Stallman <rms@gnu.org>
parents: 3504
diff changeset
238 (prog1 (cons string count)
d59af8c9bc65 (mouse-menu-choose-yank): New function. Put it in the edit menu.
Richard M. Stallman <rms@gnu.org>
parents: 3504
diff changeset
239 (setq count (1+ count))))
3942
877f540d9717 (mouse-menu-choose-yank): Just return when x-popup-menu returns nil.
Roland McGrath <roland@gnu.org>
parents: 3898
diff changeset
240 kill-ring))
877f540d9717 (mouse-menu-choose-yank): Just return when x-popup-menu returns nil.
Roland McGrath <roland@gnu.org>
parents: 3898
diff changeset
241 (arg (x-popup-menu event
877f540d9717 (mouse-menu-choose-yank): Just return when x-popup-menu returns nil.
Roland McGrath <roland@gnu.org>
parents: 3898
diff changeset
242 (list "Yank Menu"
4025
92cd14c9ea80 (mouse-menu-choose-yank): Change menu title to "Choose Next Yank".
Roland McGrath <roland@gnu.org>
parents: 3958
diff changeset
243 (cons "Choose Next Yank" menu)))))
3942
877f540d9717 (mouse-menu-choose-yank): Just return when x-popup-menu returns nil.
Roland McGrath <roland@gnu.org>
parents: 3898
diff changeset
244 ;; A mouse click outside the menu returns nil.
877f540d9717 (mouse-menu-choose-yank): Just return when x-popup-menu returns nil.
Roland McGrath <roland@gnu.org>
parents: 3898
diff changeset
245 ;; Avoid a confusing error from passing nil to rotate-yank-pointer.
877f540d9717 (mouse-menu-choose-yank): Just return when x-popup-menu returns nil.
Roland McGrath <roland@gnu.org>
parents: 3898
diff changeset
246 ;; XXX should this perhaps do something other than simply return? -rm
877f540d9717 (mouse-menu-choose-yank): Just return when x-popup-menu returns nil.
Roland McGrath <roland@gnu.org>
parents: 3898
diff changeset
247 (if arg
877f540d9717 (mouse-menu-choose-yank): Just return when x-popup-menu returns nil.
Roland McGrath <roland@gnu.org>
parents: 3898
diff changeset
248 (progn
5473
e080a27c1dd6 (mouse-menu-choose-yank): Don't use rotate-yank-pointer; set
Roland McGrath <roland@gnu.org>
parents: 5270
diff changeset
249 ;; We don't use `rotate-yank-pointer' because we want to move
e080a27c1dd6 (mouse-menu-choose-yank): Don't use rotate-yank-pointer; set
Roland McGrath <roland@gnu.org>
parents: 5270
diff changeset
250 ;; relative to the beginning of kill-ring, not the current
e080a27c1dd6 (mouse-menu-choose-yank): Don't use rotate-yank-pointer; set
Roland McGrath <roland@gnu.org>
parents: 5270
diff changeset
251 ;; position. Also, that would ask for any new X selection and
e080a27c1dd6 (mouse-menu-choose-yank): Don't use rotate-yank-pointer; set
Roland McGrath <roland@gnu.org>
parents: 5270
diff changeset
252 ;; thus change the list of items the user just chose from, which
e080a27c1dd6 (mouse-menu-choose-yank): Don't use rotate-yank-pointer; set
Roland McGrath <roland@gnu.org>
parents: 5270
diff changeset
253 ;; would be highly confusing.
e080a27c1dd6 (mouse-menu-choose-yank): Don't use rotate-yank-pointer; set
Roland McGrath <roland@gnu.org>
parents: 5270
diff changeset
254 (setq kill-ring-yank-pointer (nthcdr arg kill-ring))
3942
877f540d9717 (mouse-menu-choose-yank): Just return when x-popup-menu returns nil.
Roland McGrath <roland@gnu.org>
parents: 3898
diff changeset
255 (if (interactive-p)
877f540d9717 (mouse-menu-choose-yank): Just return when x-popup-menu returns nil.
Roland McGrath <roland@gnu.org>
parents: 3898
diff changeset
256 (message "The next yank will insert the selected text.")
877f540d9717 (mouse-menu-choose-yank): Just return when x-popup-menu returns nil.
Roland McGrath <roland@gnu.org>
parents: 3898
diff changeset
257 (current-kill 0))))))
877f540d9717 (mouse-menu-choose-yank): Just return when x-popup-menu returns nil.
Roland McGrath <roland@gnu.org>
parents: 3898
diff changeset
258 (put 'mouse-menu-choose-yank 'menu-enable 'kill-ring)
2181
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
259
7150
b78bfe054561 Make a sub-keymap for the Buffers menu bar item.
Richard M. Stallman <rms@gnu.org>
parents: 6948
diff changeset
260 (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
261
b78bfe054561 Make a sub-keymap for the Buffers menu bar item.
Richard M. Stallman <rms@gnu.org>
parents: 6948
diff changeset
262 (defalias 'menu-bar-buffers (make-sparse-keymap "Buffers"))
2178
76da020d14f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2177
diff changeset
263
2181
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
264 (defvar complex-buffers-menu-p nil
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
265 "*Non-nil says, offer a choice of actions after you pick a buffer.
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
266 This applies to the Buffers menu from the menu bar.")
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
267
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
268 (defvar buffers-menu-max-size 10
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
269 "*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
270 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
271 If this is nil, then all buffers are shown.
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
272 A large number or nil slows down menu responsiveness.")
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
273
4628
e55cc9fdaa92 (list-buffers-directory): Add declaration.
Richard M. Stallman <rms@gnu.org>
parents: 4603
diff changeset
274 (defvar list-buffers-directory nil)
e55cc9fdaa92 (list-buffers-directory): Add declaration.
Richard M. Stallman <rms@gnu.org>
parents: 4603
diff changeset
275
7150
b78bfe054561 Make a sub-keymap for the Buffers menu bar item.
Richard M. Stallman <rms@gnu.org>
parents: 6948
diff changeset
276 (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
277 (interactive)
b78bfe054561 Make a sub-keymap for the Buffers menu bar item.
Richard M. Stallman <rms@gnu.org>
parents: 6948
diff changeset
278 (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
279
b78bfe054561 Make a sub-keymap for the Buffers menu bar item.
Richard M. Stallman <rms@gnu.org>
parents: 6948
diff changeset
280 (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
281 (interactive)
b78bfe054561 Make a sub-keymap for the Buffers menu bar item.
Richard M. Stallman <rms@gnu.org>
parents: 6948
diff changeset
282 (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
283 (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
284 (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
285
b78bfe054561 Make a sub-keymap for the Buffers menu bar item.
Richard M. Stallman <rms@gnu.org>
parents: 6948
diff changeset
286 (defun menu-bar-update-buffers ()
7811
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
287 (if (frame-or-buffer-changed-p)
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
288 (let ((buffers (buffer-list))
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
289 (frames (frame-list))
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
290 buffers-menu frames-menu)
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
291 ;; If requested, list only the N most recently selected buffers.
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
292 (if (and (integerp buffers-menu-max-size)
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
293 (> buffers-menu-max-size 1))
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
294 (if (> (length buffers) buffers-menu-max-size)
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
295 (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
296
7811
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
297 ;; Make the menu of buffers proper.
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
298 (setq buffers-menu
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
299 (cons "Select Buffer"
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
300 (let ((tail buffers)
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
301 (maxbuf 0)
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
302 (maxlen 0)
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
303 alist
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
304 head)
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
305 (while tail
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
306 (or (eq ?\ (aref (buffer-name (car tail)) 0))
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
307 (setq maxbuf
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
308 (max maxbuf
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
309 (length (buffer-name (car tail))))))
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
310 (setq tail (cdr tail)))
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
311 (setq tail buffers)
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
312 (while tail
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
313 (let ((elt (car tail)))
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
314 (or (eq ?\ (aref (buffer-name elt) 0))
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
315 (setq alist (cons
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
316 (cons
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
317 (format
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
318 (format "%%%ds %%s%%s %%s"
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
319 maxbuf)
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
320 (buffer-name elt)
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
321 (if (buffer-modified-p elt)
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
322 "*" " ")
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
323 (save-excursion
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
324 (set-buffer elt)
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
325 (if buffer-read-only "%" " "))
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
326 (or (buffer-file-name elt)
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
327 (save-excursion
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
328 (set-buffer elt)
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
329 list-buffers-directory)
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
330 ""))
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
331 elt)
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
332 alist)))
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
333 (and alist (> (length (car (car alist))) maxlen)
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
334 (setq maxlen (length (car (car alist))))))
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
335 (setq tail (cdr tail)))
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
336 (setq alist (nreverse alist))
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
337 (nconc (mapcar '(lambda (pair)
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
338 ;; This is somewhat risque, to use
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
339 ;; the buffer name itself as the event
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
340 ;; type to define, but it works.
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
341 ;; It would not work to use the buffer
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
342 ;; since a buffer as an event has its
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
343 ;; own meaning.
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
344 (nconc (list (buffer-name (cdr pair))
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
345 (car pair)
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
346 (cons nil nil))
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
347 'menu-bar-select-buffer))
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
348 alist)
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
349 (list
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
350 (cons
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
351 'list-buffers
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
352 (cons
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
353 (concat (make-string (max (- (/ maxlen 2) 8) 0)
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
354 ?\ )
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
355 "List All Buffers")
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
356 'list-buffers)))))))
7150
b78bfe054561 Make a sub-keymap for the Buffers menu bar item.
Richard M. Stallman <rms@gnu.org>
parents: 6948
diff changeset
357
7239
385ac6718f28 (menu-bar-update-buffers): Fix misspelled variable.
Karl Heuer <kwzh@gnu.org>
parents: 7234
diff changeset
358
7811
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
359 ;; Make a Frames menu if we have more than one frame.
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
360 (if (cdr frames)
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
361 (setq frames-menu
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
362 (cons "Select Frame"
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
363 (mapcar '(lambda (frame)
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
364 (nconc (list frame
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
365 (cdr (assq 'name
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
366 (frame-parameters frame)))
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
367 (cons nil nil))
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
368 'menu-bar-select-frame))
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
369 frames))))
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
370 (if buffers-menu
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
371 (setq buffers-menu (cons 'keymap buffers-menu)))
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
372 (if frames-menu
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
373 (setq frames-menu (cons 'keymap frames-menu)))
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
374 (define-key global-map [menu-bar buffer]
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
375 (cons "Buffers"
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
376 (if (and buffers-menu frames-menu)
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
377 (list 'keymap "Buffers and Frames"
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
378 (cons 'buffers (cons "Buffers" buffers-menu))
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
379 (cons 'frames (cons "Frames" frames-menu)))
81b1a17562fe (menu-bar-update-buffers): Avoid excessive consing.
Karl Heuer <kwzh@gnu.org>
parents: 7745
diff changeset
380 (or buffers-menu frames-menu 'undefined)))))))
2181
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
381
7150
b78bfe054561 Make a sub-keymap for the Buffers menu bar item.
Richard M. Stallman <rms@gnu.org>
parents: 6948
diff changeset
382 (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
383
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
384 ;; this version is too slow
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
385 ;;;(defun format-buffers-menu-line (buffer)
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
386 ;;; "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
387 ;;;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
388 ;;; (if (string-match "\\` " (buffer-name buffer))
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
389 ;;; nil
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
390 ;;; (save-excursion
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
391 ;;; (set-buffer buffer)
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
392 ;;; (let ((size (buffer-size)))
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
393 ;;; (format "%s%s %-19s %6s %-15s %s"
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
394 ;;; (if (buffer-modified-p) "*" " ")
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
395 ;;; (if buffer-read-only "%" " ")
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
396 ;;; (buffer-name)
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
397 ;;; size
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
398 ;;; mode-name
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
399 ;;; (or (buffer-file-name) ""))))))
5a9d9dcc4750 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 2178
diff changeset
400
2847
01a46a8f1e1b (fill-region, kill-region, delete-region)
Richard M. Stallman <rms@gnu.org>
parents: 2765
diff changeset
401 (defun menu-bar-mode (flag)
3007
e41b3dc686bb (menu-bar-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 2847
diff changeset
402 "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
403 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
404 created in the future.
01a46a8f1e1b (fill-region, kill-region, delete-region)
Richard M. Stallman <rms@gnu.org>
parents: 2765
diff changeset
405 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
406 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
407 (interactive "P")
6dd518d1f5aa (menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents: 4337
diff changeset
408
6dd518d1f5aa (menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents: 4337
diff changeset
409 ;; Obtain the current setting by looking at default-frame-alist.
6dd518d1f5aa (menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents: 4337
diff changeset
410 (let ((menu-bar-mode
6dd518d1f5aa (menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents: 4337
diff changeset
411 (not (zerop (let ((assq (assq 'menu-bar-lines default-frame-alist)))
6dd518d1f5aa (menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents: 4337
diff changeset
412 (if assq (cdr assq) 0))))))
6dd518d1f5aa (menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents: 4337
diff changeset
413
6dd518d1f5aa (menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents: 4337
diff changeset
414 ;; Tweedle it according to the argument.
6dd518d1f5aa (menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents: 4337
diff changeset
415 (setq menu-bar-mode (if (null flag) (not menu-bar-mode)
6100
b593e9df4b44 (menu-bar-mode): Make menu-bar-mode without an argument toggle display of a
Karl Heuer <kwzh@gnu.org>
parents: 5797
diff changeset
416 (> (prefix-numeric-value flag) 0)))
4470
6dd518d1f5aa (menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents: 4337
diff changeset
417
6dd518d1f5aa (menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents: 4337
diff changeset
418 ;; Apply it to default-frame-alist.
6dd518d1f5aa (menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents: 4337
diff changeset
419 (let ((parameter (assq 'menu-bar-lines default-frame-alist)))
6dd518d1f5aa (menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents: 4337
diff changeset
420 (if (consp parameter)
6dd518d1f5aa (menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents: 4337
diff changeset
421 (setcdr parameter (if menu-bar-mode 1 0))
6dd518d1f5aa (menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents: 4337
diff changeset
422 (setq default-frame-alist
6dd518d1f5aa (menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents: 4337
diff changeset
423 (cons (cons 'menu-bar-lines (if menu-bar-mode 1 0))
6dd518d1f5aa (menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents: 4337
diff changeset
424 default-frame-alist))))
6dd518d1f5aa (menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents: 4337
diff changeset
425
6dd518d1f5aa (menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents: 4337
diff changeset
426 ;; Apply it to existing frames.
6dd518d1f5aa (menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents: 4337
diff changeset
427 (let ((frames (frame-list)))
6dd518d1f5aa (menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents: 4337
diff changeset
428 (while frames
7745
7259e377c81f (menu-bar-mode): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 7569
diff changeset
429 (let ((height (cdr (assq 'height (frame-parameters (car frames))))))
7569
50a6cd8563b6 (menu-bar-mode): Preserve window height.
Richard M. Stallman <rms@gnu.org>
parents: 7550
diff changeset
430 (modify-frame-parameters (car frames)
50a6cd8563b6 (menu-bar-mode): Preserve window height.
Richard M. Stallman <rms@gnu.org>
parents: 7550
diff changeset
431 (list (cons 'menu-bar-lines
4470
6dd518d1f5aa (menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents: 4337
diff changeset
432 (if menu-bar-mode 1 0))))
7569
50a6cd8563b6 (menu-bar-mode): Preserve window height.
Richard M. Stallman <rms@gnu.org>
parents: 7550
diff changeset
433 (modify-frame-parameters (car frames)
50a6cd8563b6 (menu-bar-mode): Preserve window height.
Richard M. Stallman <rms@gnu.org>
parents: 7550
diff changeset
434 (list (cons 'height height))))
4470
6dd518d1f5aa (menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents: 4337
diff changeset
435 (setq frames (cdr frames))))))
2485
c34bbe650160 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 2181
diff changeset
436
2765
0eb1a195f56e Provide 'menu-bar.
Richard M. Stallman <rms@gnu.org>
parents: 2695
diff changeset
437 (provide 'menu-bar)
0eb1a195f56e Provide 'menu-bar.
Richard M. Stallman <rms@gnu.org>
parents: 2695
diff changeset
438
2488
278580be9b4a Added and corrected library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2485
diff changeset
439 ;;; menu-bar.el ends here