Mercurial > emacs
annotate lisp/menu-bar.el @ 6268:43853122823f
(window_loop): Delete MULTI_FRAME
conditional within the loop, spuriously added in prev change.
Don't ignore invisible or iconified frames for GET_BUFFER_WINDOW;
instead, let Fnext_window skip them if appropriate.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 09 Mar 1994 05:59:08 +0000 |
parents | b593e9df4b44 |
children | 8ee9dcd3771e |
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 | 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 | 7 |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
23 | |
2488
278580be9b4a
Added and corrected library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2485
diff
changeset
|
24 ;;; Code: |
2485 | 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)) |
2175 | 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 | 40 '("Exit Emacs" . save-buffers-kill-emacs)) |
2178
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
41 (define-key menu-bar-file-menu [kill-buffer] |
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
42 '("Kill Buffer" . kill-this-buffer)) |
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
43 (define-key menu-bar-file-menu [delete-frame] '("Delete Frame" . delete-frame)) |
5797
c4fff7ff8bdd
Use > as convention for another menu follows.
Richard M. Stallman <rms@gnu.org>
parents:
5612
diff
changeset
|
44 (define-key menu-bar-file-menu [emerge] '("Emerge >" . menu-bar-emerge-menu)) |
5612
bf68550ececf
(menu-bar-file-menu): Add rmail, gnus, calendar items.
Richard M. Stallman <rms@gnu.org>
parents:
5473
diff
changeset
|
45 (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
|
46 (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
|
47 (define-key menu-bar-file-menu [gnus] '("Read Net News" . gnus)) |
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
|
48 (define-key menu-bar-file-menu [bookmark] |
5797
c4fff7ff8bdd
Use > as convention for another menu follows.
Richard M. Stallman <rms@gnu.org>
parents:
5612
diff
changeset
|
49 '("Bookmarks >" . menu-bar-bookmark-map)) |
2178
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
50 (define-key menu-bar-file-menu [print-buffer] '("Print Buffer" . print-buffer)) |
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
51 (define-key menu-bar-file-menu [revert-buffer] |
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
52 '("Revert Buffer" . revert-buffer)) |
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
53 (define-key menu-bar-file-menu [write-file] |
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
54 '("Save Buffer As..." . write-file)) |
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
55 (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
|
56 (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
|
57 (define-key menu-bar-file-menu [open-file] '("Open File..." . find-file)) |
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
58 (define-key menu-bar-file-menu [new-frame] '("New Frame" . new-frame)) |
2175 | 59 |
5797
c4fff7ff8bdd
Use > as convention for another menu follows.
Richard M. Stallman <rms@gnu.org>
parents:
5612
diff
changeset
|
60 (define-key menu-bar-edit-menu [spell] '("Spell >" . ispell-menu-map)) |
2847
01a46a8f1e1b
(fill-region, kill-region, delete-region)
Richard M. Stallman <rms@gnu.org>
parents:
2765
diff
changeset
|
61 (define-key menu-bar-edit-menu [fill] '("Fill" . fill-region)) |
01a46a8f1e1b
(fill-region, kill-region, delete-region)
Richard M. Stallman <rms@gnu.org>
parents:
2765
diff
changeset
|
62 (define-key menu-bar-edit-menu [clear] '("Clear" . delete-region)) |
5270
1136488153c0
(menu-bar-edit-menu): Add query-replace menu item.
Richard M. Stallman <rms@gnu.org>
parents:
5140
diff
changeset
|
63 (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
|
64 '("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
|
65 (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
|
66 '("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
|
67 (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
|
68 '("Search Backwards" . search-backward)) |
74c118ef608c
(menu-bar-edit-menu): Add menu items for searching.
Richard M. Stallman <rms@gnu.org>
parents:
4892
diff
changeset
|
69 (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
|
70 '("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
|
71 (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
|
72 '("Search" . search-forward)) |
4025
92cd14c9ea80
(mouse-menu-choose-yank): Change menu title to "Choose Next Yank".
Roland McGrath <roland@gnu.org>
parents:
3958
diff
changeset
|
73 (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
|
74 '("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
|
75 (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
|
76 (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
|
77 (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
|
78 (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
|
79 |
01a46a8f1e1b
(fill-region, kill-region, delete-region)
Richard M. Stallman <rms@gnu.org>
parents:
2765
diff
changeset
|
80 (put 'fill-region 'menu-enable 'mark-active) |
01a46a8f1e1b
(fill-region, kill-region, delete-region)
Richard M. Stallman <rms@gnu.org>
parents:
2765
diff
changeset
|
81 (put 'kill-region 'menu-enable 'mark-active) |
01a46a8f1e1b
(fill-region, kill-region, delete-region)
Richard M. Stallman <rms@gnu.org>
parents:
2765
diff
changeset
|
82 (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
|
83 (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
|
84 (put 'delete-region 'menu-enable 'mark-active) |
01a46a8f1e1b
(fill-region, kill-region, delete-region)
Richard M. Stallman <rms@gnu.org>
parents:
2765
diff
changeset
|
85 (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
|
86 pending-undo-list |
01a46a8f1e1b
(fill-region, kill-region, delete-region)
Richard M. Stallman <rms@gnu.org>
parents:
2765
diff
changeset
|
87 (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
|
88 (put 'query-replace 'menu-enable (not buffer-read-only)) |
2175 | 89 |
4061
7279958409fe
(ispell-menu-map): New autoload definition.
Richard M. Stallman <rms@gnu.org>
parents:
4048
diff
changeset
|
90 (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
|
91 |
2178
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
92 (define-key menu-bar-help-menu [emacs-tutorial] |
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
93 '("Emacs Tutorial" . help-with-tutorial)) |
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
94 (define-key menu-bar-help-menu [man] '("Man..." . manual-entry)) |
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
95 (define-key menu-bar-help-menu [describe-variable] |
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
96 '("Describe Variable..." . describe-variable)) |
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
97 (define-key menu-bar-help-menu [describe-function] |
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
98 '("Describe Function..." . describe-function)) |
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
99 (define-key menu-bar-help-menu [describe-key] |
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
100 '("Describe Key..." . describe-key)) |
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
101 (define-key menu-bar-help-menu [list-keybindings] |
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
102 '("List Keybindings" . describe-bindings)) |
2177
942a63709e37
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2175
diff
changeset
|
103 (define-key menu-bar-help-menu [command-apropos] |
2175 | 104 '("Command Apropos..." . command-apropos)) |
2178
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
105 (define-key menu-bar-help-menu [describe-mode] |
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
106 '("Describe Mode" . describe-mode)) |
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
107 (define-key menu-bar-help-menu [info] '("Info" . info)) |
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
108 |
2177
942a63709e37
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2175
diff
changeset
|
109 (define-key menu-bar-help-menu [emacs-news] '("Emacs News" . view-emacs-news)) |
2175 | 110 (defun kill-this-buffer () ; for the menubar |
111 "Kills the current buffer." | |
112 (interactive) | |
113 (kill-buffer (current-buffer))) | |
114 | |
2178
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
115 (defun kill-this-buffer-enabled-p () |
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
116 (let ((count 0) |
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
117 (buffers (buffer-list))) |
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
118 (while buffers |
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
119 (or (string-match "^ " (buffer-name (car buffers))) |
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
120 (setq count (1+ count))) |
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
121 (setq buffers (cdr buffers))) |
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
122 (> count 1))) |
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
123 |
2175 | 124 (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
|
125 (put 'revert-buffer 'menu-enable |
5746e25610f8
(revert-buffer): Make menu-enable form more accurate
Richard M. Stallman <rms@gnu.org>
parents:
4101
diff
changeset
|
126 '(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
|
127 (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
|
128 (or (buffer-modified-p) |
cafb372921c3
(revert-buffer): Enable menu item when the buffer is modified.
Roland McGrath <roland@gnu.org>
parents:
4668
diff
changeset
|
129 (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
|
130 ;; 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
|
131 (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
|
132 '(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
|
133 (count 0)) |
cda282328afd
(delete-frame): Permit it, if > 1 frame is vis or iconic.
Richard M. Stallman <rms@gnu.org>
parents:
4160
diff
changeset
|
134 (while frames |
cda282328afd
(delete-frame): Permit it, if > 1 frame is vis or iconic.
Richard M. Stallman <rms@gnu.org>
parents:
4160
diff
changeset
|
135 (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
|
136 (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
|
137 (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
|
138 (> count 1))) |
2178
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
139 (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
|
140 |
2175 | 141 (put 'advertised-undo 'menu-enable |
142 '(and (not (eq t buffer-undo-list)) | |
143 (if (eq last-command 'undo) | |
2178
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
144 (and (boundp 'pending-undo-list) |
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
145 pending-undo-list) |
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
146 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
|
147 |
d59af8c9bc65
(mouse-menu-choose-yank): New function. Put it in the edit menu.
Richard M. Stallman <rms@gnu.org>
parents:
3504
diff
changeset
|
148 (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
|
149 "*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
|
150 \\[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
|
151 |
d59af8c9bc65
(mouse-menu-choose-yank): New function. Put it in the edit menu.
Richard M. Stallman <rms@gnu.org>
parents:
3504
diff
changeset
|
152 (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
|
153 "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
|
154 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
|
155 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
|
156 (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
|
157 (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
|
158 (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
|
159 (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
|
160 (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
|
161 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
|
162 (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
|
163 (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
|
164 kill-ring)) |
877f540d9717
(mouse-menu-choose-yank): Just return when x-popup-menu returns nil.
Roland McGrath <roland@gnu.org>
parents:
3898
diff
changeset
|
165 (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
|
166 (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
|
167 (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
|
168 ;; 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
|
169 ;; 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
|
170 ;; 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
|
171 (if arg |
877f540d9717
(mouse-menu-choose-yank): Just return when x-popup-menu returns nil.
Roland McGrath <roland@gnu.org>
parents:
3898
diff
changeset
|
172 (progn |
5473
e080a27c1dd6
(mouse-menu-choose-yank): Don't use rotate-yank-pointer; set
Roland McGrath <roland@gnu.org>
parents:
5270
diff
changeset
|
173 ;; 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
|
174 ;; 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
|
175 ;; 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
|
176 ;; 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
|
177 ;; 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
|
178 (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
|
179 (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
|
180 (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
|
181 (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
|
182 (put 'mouse-menu-choose-yank 'menu-enable 'kill-ring) |
2181
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
183 |
3412
7d9b10bea55f
(mouse-menu-bar-buffers): Renamed from mouse-buffer-menu.
Richard M. Stallman <rms@gnu.org>
parents:
3007
diff
changeset
|
184 (define-key global-map [menu-bar buffer] '("Buffers" . mouse-menu-bar-buffers)) |
2178
76da020d14f8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2177
diff
changeset
|
185 |
2181
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
186 (defvar complex-buffers-menu-p nil |
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
187 "*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
|
188 This applies to the Buffers menu from the menu bar.") |
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
189 |
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
190 (defvar buffers-menu-max-size 10 |
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
191 "*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
|
192 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
|
193 If this is nil, then all buffers are shown. |
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
194 A large number or nil slows down menu responsiveness.") |
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
195 |
4628
e55cc9fdaa92
(list-buffers-directory): Add declaration.
Richard M. Stallman <rms@gnu.org>
parents:
4603
diff
changeset
|
196 (defvar list-buffers-directory nil) |
e55cc9fdaa92
(list-buffers-directory): Add declaration.
Richard M. Stallman <rms@gnu.org>
parents:
4603
diff
changeset
|
197 |
3412
7d9b10bea55f
(mouse-menu-bar-buffers): Renamed from mouse-buffer-menu.
Richard M. Stallman <rms@gnu.org>
parents:
3007
diff
changeset
|
198 (defun mouse-menu-bar-buffers (event) |
2181
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
199 "Pop up a menu of buffers for selection with the mouse. |
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
200 This switches buffers in the window that you clicked on, |
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
201 and selects that window." |
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
202 (interactive "e") |
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
203 (let ((buffers (buffer-list)) |
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
204 menu) |
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
205 ;; If requested, list only the N most recently selected buffers. |
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
206 (if (and (integerp buffers-menu-max-size) |
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
207 (> buffers-menu-max-size 1)) |
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
208 (if (> (length buffers) buffers-menu-max-size) |
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
209 (setcdr (nthcdr buffers-menu-max-size buffers) nil))) |
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
210 (setq menu |
4160
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
211 (cons "Select Buffer" |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
212 (let ((tail buffers) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
213 (maxbuf 0) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
214 (maxlen 0) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
215 head) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
216 (while tail |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
217 (or (eq ?\ (aref (buffer-name (car tail)) 0)) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
218 (setq maxbuf |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
219 (max maxbuf |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
220 (length (buffer-name (car tail)))))) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
221 (setq tail (cdr tail))) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
222 (setq tail buffers) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
223 (while tail |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
224 (let ((elt (car tail))) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
225 (if (not (string-match "^ " |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
226 (buffer-name elt))) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
227 (setq head (cons |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
228 (cons |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
229 (format |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
230 (format "%%%ds %%s%%s %%s" |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
231 maxbuf) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
232 (buffer-name elt) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
233 (if (buffer-modified-p elt) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
234 "*" " ") |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
235 (save-excursion |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
236 (set-buffer elt) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
237 (if buffer-read-only "%" " ")) |
4603
eb7d8f0543ab
(mouse-menu-bar-buffers): Use list-buffers-directory.
Richard M. Stallman <rms@gnu.org>
parents:
4470
diff
changeset
|
238 (or (buffer-file-name elt) |
eb7d8f0543ab
(mouse-menu-bar-buffers): Use list-buffers-directory.
Richard M. Stallman <rms@gnu.org>
parents:
4470
diff
changeset
|
239 (save-excursion |
eb7d8f0543ab
(mouse-menu-bar-buffers): Use list-buffers-directory.
Richard M. Stallman <rms@gnu.org>
parents:
4470
diff
changeset
|
240 (set-buffer elt) |
eb7d8f0543ab
(mouse-menu-bar-buffers): Use list-buffers-directory.
Richard M. Stallman <rms@gnu.org>
parents:
4470
diff
changeset
|
241 list-buffers-directory) |
eb7d8f0543ab
(mouse-menu-bar-buffers): Use list-buffers-directory.
Richard M. Stallman <rms@gnu.org>
parents:
4470
diff
changeset
|
242 "")) |
4160
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
243 elt) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
244 head))) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
245 (and head (> (length (car (car head))) maxlen) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
246 (setq maxlen (length (car (car head)))))) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
247 (setq tail (cdr tail))) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
248 (nconc (nreverse head) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
249 (list (cons |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
250 (concat (make-string (max (- (/ maxlen |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
251 2) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
252 8) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
253 0) ?\ ) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
254 "List All Buffers") |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
255 'list-buffers)))))) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
256 (setq menu (list menu)) |
2181
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
257 |
4160
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
258 (if (cdr (frame-list)) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
259 (setq menu |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
260 (cons (cons "Select Frame" |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
261 (mapcar (lambda (frame) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
262 (cons (cdr (assq 'name |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
263 (frame-parameters frame))) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
264 frame)) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
265 (frame-list))) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
266 menu))) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
267 (setq menu (cons "Buffer and Frame Menu" menu)) |
2181
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
268 |
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
269 (let ((buf (x-popup-menu (if (listp event) event |
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
270 (cons '(0 0) (selected-frame))) |
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
271 menu)) |
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
272 (window (and (listp event) (posn-window (event-start event))))) |
4160
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
273 (cond ((framep buf) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
274 (make-frame-visible buf) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
275 (raise-frame buf) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
276 (select-frame buf)) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
277 ((eq buf 'list-buffers) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
278 (list-buffers)) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
279 (buf |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
280 (if complex-buffers-menu-p |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
281 (let ((action (x-popup-menu |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
282 (if (listp event) event |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
283 (cons '(0 0) (selected-frame))) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
284 '("Buffer Action" |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
285 ("" |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
286 ("Save Buffer" . save-buffer) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
287 ("Kill Buffer" . kill-buffer) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
288 ("Select Buffer" . switch-to-buffer)))))) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
289 (if (eq action 'save-buffer) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
290 (save-excursion |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
291 (set-buffer buf) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
292 (save-buffer)) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
293 (funcall action buf))) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
294 (and (windowp window) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
295 (select-window window)) |
4c4910d66232
(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
Roland McGrath <roland@gnu.org>
parents:
4114
diff
changeset
|
296 (switch-to-buffer buf))))))) |
2181
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
297 |
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
298 ;; this version is too slow |
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
299 ;;;(defun format-buffers-menu-line (buffer) |
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
300 ;;; "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
|
301 ;;;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
|
302 ;;; (if (string-match "\\` " (buffer-name buffer)) |
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
303 ;;; nil |
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
304 ;;; (save-excursion |
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
305 ;;; (set-buffer buffer) |
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
306 ;;; (let ((size (buffer-size))) |
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
307 ;;; (format "%s%s %-19s %6s %-15s %s" |
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
308 ;;; (if (buffer-modified-p) "*" " ") |
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
309 ;;; (if buffer-read-only "%" " ") |
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
310 ;;; (buffer-name) |
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
311 ;;; size |
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
312 ;;; mode-name |
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
313 ;;; (or (buffer-file-name) "")))))) |
5a9d9dcc4750
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
2178
diff
changeset
|
314 |
2847
01a46a8f1e1b
(fill-region, kill-region, delete-region)
Richard M. Stallman <rms@gnu.org>
parents:
2765
diff
changeset
|
315 (defun menu-bar-mode (flag) |
3007
e41b3dc686bb
(menu-bar-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
2847
diff
changeset
|
316 "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
|
317 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
|
318 created in the future. |
01a46a8f1e1b
(fill-region, kill-region, delete-region)
Richard M. Stallman <rms@gnu.org>
parents:
2765
diff
changeset
|
319 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
|
320 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
|
321 (interactive "P") |
6dd518d1f5aa
(menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents:
4337
diff
changeset
|
322 |
6dd518d1f5aa
(menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents:
4337
diff
changeset
|
323 ;; 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
|
324 (let ((menu-bar-mode |
6dd518d1f5aa
(menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents:
4337
diff
changeset
|
325 (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
|
326 (if assq (cdr assq) 0)))))) |
6dd518d1f5aa
(menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents:
4337
diff
changeset
|
327 |
6dd518d1f5aa
(menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents:
4337
diff
changeset
|
328 ;; Tweedle it according to the argument. |
6dd518d1f5aa
(menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents:
4337
diff
changeset
|
329 (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
|
330 (> (prefix-numeric-value flag) 0))) |
4470
6dd518d1f5aa
(menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents:
4337
diff
changeset
|
331 |
6dd518d1f5aa
(menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents:
4337
diff
changeset
|
332 ;; Apply it to default-frame-alist. |
6dd518d1f5aa
(menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents:
4337
diff
changeset
|
333 (let ((parameter (assq 'menu-bar-lines default-frame-alist))) |
6dd518d1f5aa
(menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents:
4337
diff
changeset
|
334 (if (consp parameter) |
6dd518d1f5aa
(menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents:
4337
diff
changeset
|
335 (setcdr parameter (if menu-bar-mode 1 0)) |
6dd518d1f5aa
(menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents:
4337
diff
changeset
|
336 (setq default-frame-alist |
6dd518d1f5aa
(menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents:
4337
diff
changeset
|
337 (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
|
338 default-frame-alist)))) |
6dd518d1f5aa
(menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents:
4337
diff
changeset
|
339 |
6dd518d1f5aa
(menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents:
4337
diff
changeset
|
340 ;; Apply it to existing frames. |
6dd518d1f5aa
(menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents:
4337
diff
changeset
|
341 (let ((frames (frame-list))) |
6dd518d1f5aa
(menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents:
4337
diff
changeset
|
342 (while frames |
6dd518d1f5aa
(menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents:
4337
diff
changeset
|
343 (modify-frame-parameters (car frames) |
6dd518d1f5aa
(menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents:
4337
diff
changeset
|
344 (list (cons 'menu-bar-lines |
6dd518d1f5aa
(menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents:
4337
diff
changeset
|
345 (if menu-bar-mode 1 0)))) |
6dd518d1f5aa
(menu-bar-mode): Defvar removed.
Roland McGrath <roland@gnu.org>
parents:
4337
diff
changeset
|
346 (setq frames (cdr frames)))))) |
2485 | 347 |
348 ;; Make frames created from now on have a menu bar. | |
3500
78c1c1e9f4d2
(window-system): Enable menu bars only if
Richard M. Stallman <rms@gnu.org>
parents:
3412
diff
changeset
|
349 (if window-system |
78c1c1e9f4d2
(window-system): Enable menu bars only if
Richard M. Stallman <rms@gnu.org>
parents:
3412
diff
changeset
|
350 (menu-bar-mode t)) |
2485 | 351 |
2765 | 352 (provide 'menu-bar) |
353 | |
2488
278580be9b4a
Added and corrected library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2485
diff
changeset
|
354 ;;; menu-bar.el ends here |