Mercurial > emacs
annotate lisp/buff-menu.el @ 6613:b872dcd6cbbd
(Man-filter-list): New footer format to delete.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Thu, 31 Mar 1994 22:01:12 +0000 |
parents | 3b1eb7f1eba1 |
children | 61e40a447c92 |
rev | line source |
---|---|
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
194
diff
changeset
|
1 ;;; buff-menu.el --- buffer menu main function and support functions. |
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
194
diff
changeset
|
2 |
2422
4ecde980a8f5
Put back removed years in copyright notice.
Richard M. Stallman <rms@gnu.org>
parents:
2420
diff
changeset
|
3 ;; Copyright (C) 1985, 1986, 1987, 1993 Free Software Foundation, Inc. |
845 | 4 |
801
e9e34745ae3b
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
777
diff
changeset
|
5 ;; Maintainer: FSF |
194 | 6 |
7 ;; This file is part of GNU Emacs. | |
8 | |
9 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
10 ;; it under the terms of the GNU General Public License as published by | |
735 | 11 ;; the Free Software Foundation; either version 2, or (at your option) |
194 | 12 ;; any later version. |
13 | |
14 ;; GNU Emacs is distributed in the hope that it will be useful, | |
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 ;; GNU General Public License for more details. | |
18 | |
19 ;; You should have received a copy of the GNU General Public License | |
20 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
21 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
22 | |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
23 ;;; Commentary: |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
24 |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
25 ;; Edit, delete, or change attributes of all currently active Emacs |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
2736
diff
changeset
|
26 ;; buffers from a list summarizing their state. A good way to browse |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
27 ;; any special or scratch buffers you have loaded, since you can't find |
2334
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
28 ;; them by filename. The single entry point is `Buffer-menu-mode', |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
29 ;; normally bound to C-x C-b. |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
30 |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
31 ;;; Change Log: |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
32 |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
33 ;; Merged by esr with recent mods to Emacs 19 buff-menu, 23 Mar 1993 |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
34 ;; |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
35 ;; Modified by Bob Weiner, Motorola, Inc., 4/14/89 |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
36 ;; |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
37 ;; Added optional backup argument to 'Buffer-menu-unmark' to make it undelete |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
38 ;; current entry and then move to previous one. |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
39 ;; |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
40 ;; Based on FSF code dating back to 1985. |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
41 |
801
e9e34745ae3b
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
777
diff
changeset
|
42 ;;; Code: |
2334
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
43 |
2736
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
44 ;;;Not needed, now that q is now just quit and Buffer-menu-select is v. |
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
45 ;;;(defvar Buffer-menu-window-config nil |
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
46 ;;; "Window configuration saved from entry to `buffer-menu'.") |
194 | 47 |
48 ; Put buffer *Buffer List* into proper mode right away | |
49 ; so that from now on even list-buffers is enough to get a buffer menu. | |
50 | |
51 (defvar Buffer-menu-mode-map nil "") | |
52 | |
53 (if Buffer-menu-mode-map | |
54 () | |
55 (setq Buffer-menu-mode-map (make-keymap)) | |
56 (suppress-keymap Buffer-menu-mode-map t) | |
2736
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
57 (define-key Buffer-menu-mode-map "q" 'Buffer-menu-quit) |
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
58 (define-key Buffer-menu-mode-map "v" 'Buffer-menu-select) |
194 | 59 (define-key Buffer-menu-mode-map "2" 'Buffer-menu-2-window) |
60 (define-key Buffer-menu-mode-map "1" 'Buffer-menu-1-window) | |
61 (define-key Buffer-menu-mode-map "f" 'Buffer-menu-this-window) | |
62 (define-key Buffer-menu-mode-map "o" 'Buffer-menu-other-window) | |
735 | 63 (define-key Buffer-menu-mode-map "\C-o" 'Buffer-menu-switch-other-window) |
194 | 64 (define-key Buffer-menu-mode-map "s" 'Buffer-menu-save) |
65 (define-key Buffer-menu-mode-map "d" 'Buffer-menu-delete) | |
66 (define-key Buffer-menu-mode-map "k" 'Buffer-menu-delete) | |
67 (define-key Buffer-menu-mode-map "\C-d" 'Buffer-menu-delete-backwards) | |
68 (define-key Buffer-menu-mode-map "\C-k" 'Buffer-menu-delete) | |
69 (define-key Buffer-menu-mode-map "x" 'Buffer-menu-execute) | |
70 (define-key Buffer-menu-mode-map " " 'next-line) | |
71 (define-key Buffer-menu-mode-map "n" 'next-line) | |
72 (define-key Buffer-menu-mode-map "p" 'previous-line) | |
73 (define-key Buffer-menu-mode-map "\177" 'Buffer-menu-backup-unmark) | |
74 (define-key Buffer-menu-mode-map "~" 'Buffer-menu-not-modified) | |
75 (define-key Buffer-menu-mode-map "?" 'describe-mode) | |
76 (define-key Buffer-menu-mode-map "u" 'Buffer-menu-unmark) | |
77 (define-key Buffer-menu-mode-map "m" 'Buffer-menu-mark) | |
2378
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
78 (define-key Buffer-menu-mode-map "t" 'Buffer-menu-visit-tags-table) |
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
79 (define-key Buffer-menu-mode-map "%" 'Buffer-menu-toggle-read-only) |
6609
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
80 (define-key Buffer-menu-mode-map [mouse-2] 'Buffer-menu-mouse-select) |
2378
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
81 ) |
194 | 82 |
83 ;; Buffer Menu mode is suitable only for specially formatted data. | |
84 (put 'Buffer-menu-mode 'mode-class 'special) | |
85 | |
86 (defun Buffer-menu-mode () | |
87 "Major mode for editing a list of buffers. | |
88 Each line describes one of the buffers in Emacs. | |
89 Letters do not insert themselves; instead, they are commands. | |
90 \\<Buffer-menu-mode-map> | |
6609
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
91 \\[Buffer-menu-mouse-select] -- select buffer you click on, in place of the buffer menu. |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
92 \\[Buffer-menu-this-window] -- select current line's buffer in place of the buffer menu. |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
93 \\[Buffer-menu-other-window] -- select that buffer in another window, |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
94 so the buffer menu buffer remains visible in its window. |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
95 \\[Buffer-menu-switch-other-window] -- make another window display that buffer. |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
96 \\[Buffer-menu-mark] -- mark current line's buffer to be displayed. |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
97 \\[Buffer-menu-select] -- select current line's buffer. |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
98 Also show buffers marked with m, in other windows. |
777 | 99 \\[Buffer-menu-1-window] -- select that buffer in full-frame window. |
194 | 100 \\[Buffer-menu-2-window] -- select that buffer in one window, |
101 together with buffer selected before this one in another window. | |
102 \\[Buffer-menu-visit-tags-table] -- visit-tags-table this buffer. | |
103 \\[Buffer-menu-not-modified] -- clear modified-flag on that buffer. | |
104 \\[Buffer-menu-save] -- mark that buffer to be saved, and move down. | |
105 \\[Buffer-menu-delete] -- mark that buffer to be deleted, and move down. | |
106 \\[Buffer-menu-delete-backwards] -- mark that buffer to be deleted, and move up. | |
107 \\[Buffer-menu-execute] -- delete or save marked buffers. | |
108 \\[Buffer-menu-unmark] -- remove all kinds of marks from current line. | |
2334
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
109 With prefix argument, also move up one line. |
2378
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
110 \\[Buffer-menu-backup-unmark] -- back up a line and remove marks. |
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
111 \\[Buffer-menu-toggle-read-only] -- toggle read-only status of buffer on this line." |
194 | 112 (kill-all-local-variables) |
113 (use-local-map Buffer-menu-mode-map) | |
114 (setq truncate-lines t) | |
115 (setq buffer-read-only t) | |
116 (setq major-mode 'Buffer-menu-mode) | |
117 (setq mode-name "Buffer Menu") | |
118 (run-hooks 'buffer-menu-mode-hook)) | |
119 | |
2334
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
120 (defvar Buffer-menu-buffer-column nil) |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
121 |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
122 (defvar Buffer-menu-size-column nil) |
194 | 123 |
124 (defun Buffer-menu-buffer (error-if-non-existent-p) | |
125 "Return buffer described by this line of buffer menu." | |
2334
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
126 (if (null Buffer-menu-buffer-column) |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
127 (save-excursion |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
128 (goto-char (point-min)) |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
129 (search-forward "Buffer") |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
130 (backward-word 1) |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
131 (setq Buffer-menu-buffer-column (current-column)) |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
132 (search-forward "Size") |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
133 (backward-word 1) |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
134 (setq Buffer-menu-size-column (current-column)))) |
194 | 135 (save-excursion |
136 (beginning-of-line) | |
137 (forward-char Buffer-menu-buffer-column) | |
138 (let ((start (point)) | |
139 string) | |
140 ;; End of buffer name marked by tab or two spaces. | |
141 (re-search-forward "\t\\| ") | |
142 (skip-chars-backward " \t") | |
143 (setq string (buffer-substring start (point))) | |
144 (or (get-buffer string) | |
145 (if error-if-non-existent-p | |
146 (error "No buffer named \"%s\"" string) | |
147 nil))))) | |
148 | |
756 | 149 (defun buffer-menu (&optional arg) |
194 | 150 "Make a menu of buffers so you can save, delete or select them. |
151 With argument, show only buffers that are visiting files. | |
152 Type ? after invocation to get help on commands available. | |
2334
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
153 Type q immediately to make the buffer menu go away and to restore |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
154 previous window configuration." |
194 | 155 (interactive "P") |
2736
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
156 ;;; (setq Buffer-menu-window-config (current-window-configuration)) |
194 | 157 (list-buffers arg) |
158 (pop-to-buffer "*Buffer List*") | |
159 (forward-line 2) | |
160 (message | |
2736
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
161 "Commands: d, s, x, u; f, o, 1, 2, m, v; ~, %%; q to quit; ? for help.")) |
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
162 |
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
163 (defun Buffer-menu-quit () |
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
164 "Quit the buffer menu." |
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
165 (interactive) |
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
166 (let ((buffer (current-buffer))) |
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
167 ;; Restore previous window configuration before displaying |
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
168 ;; selected buffers. |
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
169 (switch-to-buffer (other-buffer)) |
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
170 (bury-buffer buffer))) |
194 | 171 |
172 (defun Buffer-menu-mark () | |
173 "Mark buffer on this line for being displayed by \\<Buffer-menu-mode-map>\\[Buffer-menu-select] command." | |
174 (interactive) | |
175 (beginning-of-line) | |
176 (if (looking-at " [-M]") | |
177 (ding) | |
178 (let ((buffer-read-only nil)) | |
179 (delete-char 1) | |
180 (insert ?>) | |
181 (forward-line 1)))) | |
182 | |
2334
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
183 (defun Buffer-menu-unmark (&optional backup) |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
184 "Cancel all requested operations on buffer on this line and move down. |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
185 Optional ARG means move up." |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
186 (interactive "P") |
194 | 187 (beginning-of-line) |
188 (if (looking-at " [-M]") | |
189 (ding) | |
190 (let* ((buf (Buffer-menu-buffer t)) | |
191 (mod (buffer-modified-p buf)) | |
192 (readonly (save-excursion (set-buffer buf) buffer-read-only)) | |
193 (buffer-read-only nil)) | |
194 (delete-char 3) | |
195 (insert (if readonly (if mod " *%" " %") (if mod " * " " "))))) | |
2334
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
196 (forward-line (if backup -1 1))) |
194 | 197 |
198 (defun Buffer-menu-backup-unmark () | |
199 "Move up and cancel all requested operations on buffer on line above." | |
200 (interactive) | |
201 (forward-line -1) | |
202 (Buffer-menu-unmark) | |
203 (forward-line -1)) | |
204 | |
205 (defun Buffer-menu-delete () | |
206 "Mark buffer on this line to be deleted by \\<Buffer-menu-mode-map>\\[Buffer-menu-execute] command." | |
207 (interactive) | |
208 (beginning-of-line) | |
209 (if (looking-at " [-M]") ;header lines | |
210 (ding) | |
211 (let ((buffer-read-only nil)) | |
212 (delete-char 1) | |
213 (insert ?D) | |
214 (forward-line 1)))) | |
215 | |
216 (defun Buffer-menu-delete-backwards () | |
217 "Mark buffer on this line to be deleted by \\<Buffer-menu-mode-map>\\[Buffer-menu-execute] command | |
218 and then move up one line" | |
219 (interactive) | |
220 (Buffer-menu-delete) | |
221 (forward-line -2) | |
222 (if (looking-at " [-M]") (forward-line 1))) | |
223 | |
224 (defun Buffer-menu-save () | |
225 "Mark buffer on this line to be saved by \\<Buffer-menu-mode-map>\\[Buffer-menu-execute] command." | |
226 (interactive) | |
227 (beginning-of-line) | |
228 (forward-char 1) | |
229 (if (looking-at " [-M]") ;header lines | |
230 (ding) | |
231 (let ((buffer-read-only nil)) | |
232 (delete-char 1) | |
233 (insert ?S) | |
234 (forward-line 1)))) | |
235 | |
236 (defun Buffer-menu-not-modified () | |
237 "Mark buffer on this line as unmodified (no changes to save)." | |
238 (interactive) | |
239 (save-excursion | |
240 (set-buffer (Buffer-menu-buffer t)) | |
241 (set-buffer-modified-p nil)) | |
242 (save-excursion | |
243 (beginning-of-line) | |
244 (forward-char 1) | |
245 (if (looking-at "\\*") | |
246 (let ((buffer-read-only nil)) | |
247 (delete-char 1) | |
248 (insert ? ))))) | |
249 | |
250 (defun Buffer-menu-execute () | |
251 "Save and/or delete buffers marked with \\<Buffer-menu-mode-map>\\[Buffer-menu-save] or \\<Buffer-menu-mode-map>\\[Buffer-menu-delete] commands." | |
252 (interactive) | |
253 (save-excursion | |
254 (goto-char (point-min)) | |
255 (forward-line 1) | |
256 (while (re-search-forward "^.S" nil t) | |
257 (let ((modp nil)) | |
258 (save-excursion | |
259 (set-buffer (Buffer-menu-buffer t)) | |
260 (save-buffer) | |
261 (setq modp (buffer-modified-p))) | |
262 (let ((buffer-read-only nil)) | |
263 (delete-char -1) | |
264 (insert (if modp ?* ? )))))) | |
265 (save-excursion | |
266 (goto-char (point-min)) | |
267 (forward-line 1) | |
268 (let ((buff-menu-buffer (current-buffer)) | |
269 (buffer-read-only nil)) | |
270 (while (search-forward "\nD" nil t) | |
271 (forward-char -1) | |
272 (let ((buf (Buffer-menu-buffer nil))) | |
273 (or (eq buf nil) | |
274 (eq buf buff-menu-buffer) | |
275 (save-excursion (kill-buffer buf)))) | |
276 (if (Buffer-menu-buffer nil) | |
277 (progn (delete-char 1) | |
278 (insert ? )) | |
279 (delete-region (point) (progn (forward-line 1) (point))) | |
280 (forward-char -1)))))) | |
281 | |
282 (defun Buffer-menu-select () | |
283 "Select this line's buffer; also display buffers marked with `>'. | |
284 You can mark buffers with the \\<Buffer-menu-mode-map>\\[Buffer-menu-mark] command." | |
285 (interactive) | |
286 (let ((buff (Buffer-menu-buffer t)) | |
287 (menu (current-buffer)) | |
288 (others ()) | |
289 tem) | |
290 (goto-char (point-min)) | |
291 (while (search-forward "\n>" nil t) | |
292 (setq tem (Buffer-menu-buffer t)) | |
293 (let ((buffer-read-only nil)) | |
294 (delete-char -1) | |
295 (insert ?\ )) | |
296 (or (eq tem buff) (memq tem others) (setq others (cons tem others)))) | |
297 (setq others (nreverse others) | |
777 | 298 tem (/ (1- (frame-height)) (1+ (length others)))) |
194 | 299 (delete-other-windows) |
300 (switch-to-buffer buff) | |
301 (or (eq menu buff) | |
302 (bury-buffer menu)) | |
2334
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
303 (if (equal (length others) 0) |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
304 (progn |
2736
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
305 ;;; ;; Restore previous window configuration before displaying |
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
306 ;;; ;; selected buffers. |
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
307 ;;; (if Buffer-menu-window-config |
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
308 ;;; (progn |
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
309 ;;; (set-window-configuration Buffer-menu-window-config) |
d6ff54640930
(buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents:
2422
diff
changeset
|
310 ;;; (setq Buffer-menu-window-config nil))) |
2334
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
311 (switch-to-buffer buff)) |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
312 (while others |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
313 (split-window nil tem) |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
314 (other-window 1) |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
315 (switch-to-buffer (car others)) |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
316 (setq others (cdr others))) |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
317 (other-window 1) ;back to the beginning! |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
318 ))) |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
319 |
194 | 320 |
321 (defun Buffer-menu-visit-tags-table () | |
322 "Visit the tags table in the buffer on this line. See `visit-tags-table'." | |
323 (interactive) | |
324 (let ((file (buffer-file-name (Buffer-menu-buffer t)))) | |
325 (if file | |
326 (visit-tags-table file) | |
327 (error "Specified buffer has no file")))) | |
328 | |
329 (defun Buffer-menu-1-window () | |
777 | 330 "Select this line's buffer, alone, in full frame." |
194 | 331 (interactive) |
332 (switch-to-buffer (Buffer-menu-buffer t)) | |
333 (bury-buffer (other-buffer)) | |
334 (delete-other-windows)) | |
335 | |
6609
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
336 (defun Buffer-menu-mouse-select (event) |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
337 "Select the buffer whose line you click on." |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
338 (interactive "e") |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
339 (let (buffer) |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
340 (save-excursion |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
341 (set-buffer (window-buffer (posn-window (event-end event)))) |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
342 (save-excursion |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
343 (goto-char (posn-point (event-end event))) |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
344 (setq buffer (Buffer-menu-buffer t)))) |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
345 (select-window (posn-window (event-end event))) |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
346 (switch-to-buffer buffer))) |
3b1eb7f1eba1
(Buffer-menu-mouse-select): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6084
diff
changeset
|
347 |
194 | 348 (defun Buffer-menu-this-window () |
349 "Select this line's buffer in this window." | |
350 (interactive) | |
351 (switch-to-buffer (Buffer-menu-buffer t))) | |
352 | |
353 (defun Buffer-menu-other-window () | |
354 "Select this line's buffer in other window, leaving buffer menu visible." | |
355 (interactive) | |
356 (switch-to-buffer-other-window (Buffer-menu-buffer t))) | |
357 | |
735 | 358 (defun Buffer-menu-switch-other-window () |
359 "Make the other window select this line's buffer. | |
360 The current window remains selected." | |
361 (interactive) | |
362 (display-buffer (Buffer-menu-buffer t))) | |
363 | |
194 | 364 (defun Buffer-menu-2-window () |
365 "Select this line's buffer, with previous buffer in second window." | |
366 (interactive) | |
367 (let ((buff (Buffer-menu-buffer t)) | |
368 (menu (current-buffer)) | |
369 (pop-up-windows t)) | |
2334
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
370 (delete-other-windows) |
194 | 371 (switch-to-buffer (other-buffer)) |
372 (pop-to-buffer buff) | |
373 (bury-buffer menu))) | |
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
194
diff
changeset
|
374 |
2378
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
375 (defun Buffer-menu-toggle-read-only () |
6084
d42c85701055
(Buffer-menu-toggle-read-only): Change toggle-read-only to
Karl Heuer <kwzh@gnu.org>
parents:
3591
diff
changeset
|
376 "Toggle read-only status of buffer on this line, perhaps via version control." |
2378
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
377 (interactive) |
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
378 (let (char) |
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
379 (save-excursion |
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
380 (set-buffer (Buffer-menu-buffer t)) |
6084
d42c85701055
(Buffer-menu-toggle-read-only): Change toggle-read-only to
Karl Heuer <kwzh@gnu.org>
parents:
3591
diff
changeset
|
381 (vc-toggle-read-only) |
2378
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
382 (setq char (if buffer-read-only ?% ? ))) |
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
383 (save-excursion |
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
384 (beginning-of-line) |
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
385 (forward-char 2) |
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
386 (if (/= (following-char) char) |
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
387 (let (buffer-read-only) |
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
388 (delete-char 1) |
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
389 (insert char)))))) |
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
390 |
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
194
diff
changeset
|
391 ;;; buff-menu.el ends here |