Mercurial > emacs
annotate lisp/buff-menu.el @ 2340:f19f4582c04d
* keyboard.c [POLL_FOR_INPUT] (quit_throw_to_read_char): If
we're polling for input, abort; input polling should always be
suppressed while we're waiting for input.
* keyboard.c (interrupt_signal): Remove extern declaration of
Vwindow_system; this is no longer used.
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Wed, 24 Mar 1993 01:53:00 +0000 |
parents | ec4ffd67483d |
children | c5d0140aa7b6 |
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 |
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
|
3 ;; Copyright (C) 1993 Free Software Foundation, Inc. |
845 | 4 |
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
|
5 ;; Author: Bob Weiner <rsw@cs.brown.edu> |
801
e9e34745ae3b
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
777
diff
changeset
|
6 ;; Maintainer: FSF |
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
|
7 ;; Adapted-by: Eric S. Raymond <esr@snark.thyrsus.com> |
194 | 8 |
9 ;; This file is part of GNU Emacs. | |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
735 | 13 ;; the Free Software Foundation; either version 2, or (at your option) |
194 | 14 ;; any later version. |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
23 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
24 | |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
25 ;;; Commentary: |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
26 |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
27 ;; Edit, delete, or change attributes of all currently active Emacs |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
28 ;; buffers from a list summarizing thir state. A good way to browse |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
29 ;; 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
|
30 ;; 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
|
31 ;; 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
|
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 ;;; 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
|
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 ;; 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
|
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 ;; Modified by Bob Weiner, Motorola, Inc., 3/1/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
|
38 ;; |
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 ;; Save window configuration when 'buffer-menu' is called so that |
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 ;; previous window configuration is restored. prior to selecting |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
41 ;; buffers. |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
42 ;; Made 'Buffer-menu-select' also perform a 'Buffer-menu-execute'. |
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 ;; |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
44 ;; 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
|
45 ;; |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
46 ;; 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
|
47 ;; 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
|
48 ;; |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
49 ;; 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
|
50 |
801
e9e34745ae3b
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
777
diff
changeset
|
51 ;;; 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
|
52 |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
53 (defvar *buff-window-config* 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
|
54 "Stores window configuration upon entry of 'buffer-menu'. Used to |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
55 restore window configuration when only one buffer is selected.") |
194 | 56 |
57 ; Put buffer *Buffer List* into proper mode right away | |
58 ; so that from now on even list-buffers is enough to get a buffer menu. | |
59 | |
60 (defvar Buffer-menu-mode-map nil "") | |
61 | |
62 (if Buffer-menu-mode-map | |
63 () | |
64 (setq Buffer-menu-mode-map (make-keymap)) | |
65 (suppress-keymap Buffer-menu-mode-map t) | |
66 (define-key Buffer-menu-mode-map "q" 'Buffer-menu-select) | |
67 (define-key Buffer-menu-mode-map "2" 'Buffer-menu-2-window) | |
68 (define-key Buffer-menu-mode-map "1" 'Buffer-menu-1-window) | |
69 (define-key Buffer-menu-mode-map "f" 'Buffer-menu-this-window) | |
70 (define-key Buffer-menu-mode-map "o" 'Buffer-menu-other-window) | |
735 | 71 (define-key Buffer-menu-mode-map "\C-o" 'Buffer-menu-switch-other-window) |
194 | 72 (define-key Buffer-menu-mode-map "s" 'Buffer-menu-save) |
73 (define-key Buffer-menu-mode-map "d" 'Buffer-menu-delete) | |
74 (define-key Buffer-menu-mode-map "k" 'Buffer-menu-delete) | |
75 (define-key Buffer-menu-mode-map "\C-d" 'Buffer-menu-delete-backwards) | |
76 (define-key Buffer-menu-mode-map "\C-k" 'Buffer-menu-delete) | |
77 (define-key Buffer-menu-mode-map "x" 'Buffer-menu-execute) | |
78 (define-key Buffer-menu-mode-map " " 'next-line) | |
79 (define-key Buffer-menu-mode-map "n" 'next-line) | |
80 (define-key Buffer-menu-mode-map "p" 'previous-line) | |
81 (define-key Buffer-menu-mode-map "\177" 'Buffer-menu-backup-unmark) | |
82 (define-key Buffer-menu-mode-map "~" 'Buffer-menu-not-modified) | |
83 (define-key Buffer-menu-mode-map "?" 'describe-mode) | |
84 (define-key Buffer-menu-mode-map "u" 'Buffer-menu-unmark) | |
85 (define-key Buffer-menu-mode-map "m" 'Buffer-menu-mark) | |
86 (define-key Buffer-menu-mode-map "t" 'Buffer-menu-visit-tags-table)) | |
87 | |
88 ;; Buffer Menu mode is suitable only for specially formatted data. | |
89 (put 'Buffer-menu-mode 'mode-class 'special) | |
90 | |
91 (defun Buffer-menu-mode () | |
92 "Major mode for editing a list of buffers. | |
93 Each line describes one of the buffers in Emacs. | |
94 Letters do not insert themselves; instead, they are commands. | |
95 \\<Buffer-menu-mode-map> | |
96 \\[Buffer-menu-mark] -- mark buffer to be displayed. | |
97 \\[Buffer-menu-select] -- select buffer of line point is on. | |
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-this-window] -- select that buffer in place of the buffer menu buffer. | |
103 \\[Buffer-menu-other-window] -- select that buffer in another window, | |
104 so the buffer menu buffer remains visible in its window. | |
735 | 105 \\[Buffer-menu-switch-other-window] -- switch the other window to this buffer. |
194 | 106 \\[Buffer-menu-visit-tags-table] -- visit-tags-table this buffer. |
107 \\[Buffer-menu-not-modified] -- clear modified-flag on that buffer. | |
108 \\[Buffer-menu-save] -- mark that buffer to be saved, and move down. | |
109 \\[Buffer-menu-delete] -- mark that buffer to be deleted, and move down. | |
110 \\[Buffer-menu-delete-backwards] -- mark that buffer to be deleted, and move up. | |
111 \\[Buffer-menu-execute] -- delete or save marked buffers. | |
112 \\[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
|
113 With prefix argument, also move up one line. |
194 | 114 \\[Buffer-menu-backup-unmark] -- back up a line and remove marks." |
115 (kill-all-local-variables) | |
116 (use-local-map Buffer-menu-mode-map) | |
117 (setq truncate-lines t) | |
118 (setq buffer-read-only t) | |
119 (setq major-mode 'Buffer-menu-mode) | |
120 (setq mode-name "Buffer Menu") | |
121 (run-hooks 'buffer-menu-mode-hook)) | |
122 | |
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
|
123 (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
|
124 |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
125 (defvar Buffer-menu-size-column nil) |
194 | 126 |
127 (defun Buffer-menu-buffer (error-if-non-existent-p) | |
128 "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
|
129 (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
|
130 (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
|
131 (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
|
132 (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
|
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-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
|
135 (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
|
136 (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
|
137 (setq Buffer-menu-size-column (current-column)))) |
194 | 138 (save-excursion |
139 (beginning-of-line) | |
140 (forward-char Buffer-menu-buffer-column) | |
141 (let ((start (point)) | |
142 string) | |
143 ;; End of buffer name marked by tab or two spaces. | |
144 (re-search-forward "\t\\| ") | |
145 (skip-chars-backward " \t") | |
146 (setq string (buffer-substring start (point))) | |
147 (or (get-buffer string) | |
148 (if error-if-non-existent-p | |
149 (error "No buffer named \"%s\"" string) | |
150 nil))))) | |
151 | |
756 | 152 (defun buffer-menu (&optional arg) |
194 | 153 "Make a menu of buffers so you can save, delete or select them. |
154 With argument, show only buffers that are visiting files. | |
155 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
|
156 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
|
157 previous window configuration." |
194 | 158 (interactive "P") |
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
|
159 (setq *buff-window-config* (current-window-configuration)) |
194 | 160 (list-buffers arg) |
161 (pop-to-buffer "*Buffer List*") | |
162 (forward-line 2) | |
163 (message | |
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
|
164 "Commands: d, s, x; 1, 2, m, u; delete; ~; q to quit; ? for help.")) |
194 | 165 |
166 (defun Buffer-menu-mark () | |
167 "Mark buffer on this line for being displayed by \\<Buffer-menu-mode-map>\\[Buffer-menu-select] command." | |
168 (interactive) | |
169 (beginning-of-line) | |
170 (if (looking-at " [-M]") | |
171 (ding) | |
172 (let ((buffer-read-only nil)) | |
173 (delete-char 1) | |
174 (insert ?>) | |
175 (forward-line 1)))) | |
176 | |
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
|
177 (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
|
178 "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
|
179 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
|
180 (interactive "P") |
194 | 181 (beginning-of-line) |
182 (if (looking-at " [-M]") | |
183 (ding) | |
184 (let* ((buf (Buffer-menu-buffer t)) | |
185 (mod (buffer-modified-p buf)) | |
186 (readonly (save-excursion (set-buffer buf) buffer-read-only)) | |
187 (buffer-read-only nil)) | |
188 (delete-char 3) | |
189 (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
|
190 (forward-line (if backup -1 1))) |
194 | 191 |
192 (defun Buffer-menu-backup-unmark () | |
193 "Move up and cancel all requested operations on buffer on line above." | |
194 (interactive) | |
195 (forward-line -1) | |
196 (Buffer-menu-unmark) | |
197 (forward-line -1)) | |
198 | |
199 (defun Buffer-menu-delete () | |
200 "Mark buffer on this line to be deleted by \\<Buffer-menu-mode-map>\\[Buffer-menu-execute] command." | |
201 (interactive) | |
202 (beginning-of-line) | |
203 (if (looking-at " [-M]") ;header lines | |
204 (ding) | |
205 (let ((buffer-read-only nil)) | |
206 (delete-char 1) | |
207 (insert ?D) | |
208 (forward-line 1)))) | |
209 | |
210 (defun Buffer-menu-delete-backwards () | |
211 "Mark buffer on this line to be deleted by \\<Buffer-menu-mode-map>\\[Buffer-menu-execute] command | |
212 and then move up one line" | |
213 (interactive) | |
214 (Buffer-menu-delete) | |
215 (forward-line -2) | |
216 (if (looking-at " [-M]") (forward-line 1))) | |
217 | |
218 (defun Buffer-menu-save () | |
219 "Mark buffer on this line to be saved by \\<Buffer-menu-mode-map>\\[Buffer-menu-execute] command." | |
220 (interactive) | |
221 (beginning-of-line) | |
222 (forward-char 1) | |
223 (if (looking-at " [-M]") ;header lines | |
224 (ding) | |
225 (let ((buffer-read-only nil)) | |
226 (delete-char 1) | |
227 (insert ?S) | |
228 (forward-line 1)))) | |
229 | |
230 (defun Buffer-menu-not-modified () | |
231 "Mark buffer on this line as unmodified (no changes to save)." | |
232 (interactive) | |
233 (save-excursion | |
234 (set-buffer (Buffer-menu-buffer t)) | |
235 (set-buffer-modified-p nil)) | |
236 (save-excursion | |
237 (beginning-of-line) | |
238 (forward-char 1) | |
239 (if (looking-at "\\*") | |
240 (let ((buffer-read-only nil)) | |
241 (delete-char 1) | |
242 (insert ? ))))) | |
243 | |
244 (defun Buffer-menu-execute () | |
245 "Save and/or delete buffers marked with \\<Buffer-menu-mode-map>\\[Buffer-menu-save] or \\<Buffer-menu-mode-map>\\[Buffer-menu-delete] commands." | |
246 (interactive) | |
247 (save-excursion | |
248 (goto-char (point-min)) | |
249 (forward-line 1) | |
250 (while (re-search-forward "^.S" nil t) | |
251 (let ((modp nil)) | |
252 (save-excursion | |
253 (set-buffer (Buffer-menu-buffer t)) | |
254 (save-buffer) | |
255 (setq modp (buffer-modified-p))) | |
256 (let ((buffer-read-only nil)) | |
257 (delete-char -1) | |
258 (insert (if modp ?* ? )))))) | |
259 (save-excursion | |
260 (goto-char (point-min)) | |
261 (forward-line 1) | |
262 (let ((buff-menu-buffer (current-buffer)) | |
263 (buffer-read-only nil)) | |
264 (while (search-forward "\nD" nil t) | |
265 (forward-char -1) | |
266 (let ((buf (Buffer-menu-buffer nil))) | |
267 (or (eq buf nil) | |
268 (eq buf buff-menu-buffer) | |
269 (save-excursion (kill-buffer buf)))) | |
270 (if (Buffer-menu-buffer nil) | |
271 (progn (delete-char 1) | |
272 (insert ? )) | |
273 (delete-region (point) (progn (forward-line 1) (point))) | |
274 (forward-char -1)))))) | |
275 | |
276 (defun Buffer-menu-select () | |
277 "Select this line's buffer; also display buffers marked with `>'. | |
278 You can mark buffers with the \\<Buffer-menu-mode-map>\\[Buffer-menu-mark] command." | |
279 (interactive) | |
280 (let ((buff (Buffer-menu-buffer t)) | |
281 (menu (current-buffer)) | |
282 (others ()) | |
283 tem) | |
284 (goto-char (point-min)) | |
285 (while (search-forward "\n>" nil t) | |
286 (setq tem (Buffer-menu-buffer t)) | |
287 (let ((buffer-read-only nil)) | |
288 (delete-char -1) | |
289 (insert ?\ )) | |
290 (or (eq tem buff) (memq tem others) (setq others (cons tem others)))) | |
291 (setq others (nreverse others) | |
777 | 292 tem (/ (1- (frame-height)) (1+ (length others)))) |
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
|
293 (Buffer-menu-execute) |
194 | 294 (delete-other-windows) |
295 (switch-to-buffer buff) | |
296 (or (eq menu buff) | |
297 (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
|
298 (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
|
299 (progn |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
300 ;; Restore previous window configuration before displaying |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
301 ;; selected buffers. |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
302 (if *buff-window-config* |
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 (progn |
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 (set-window-configuration *buff-window-config*) |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
305 (setq *buff-window-config* 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
|
306 (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
|
307 (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
|
308 (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
|
309 (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
|
310 (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
|
311 (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
|
312 (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
|
313 ))) |
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 |
194 | 315 |
316 (defun Buffer-menu-visit-tags-table () | |
317 "Visit the tags table in the buffer on this line. See `visit-tags-table'." | |
318 (interactive) | |
319 (let ((file (buffer-file-name (Buffer-menu-buffer t)))) | |
320 (if file | |
321 (visit-tags-table file) | |
322 (error "Specified buffer has no file")))) | |
323 | |
324 (defun Buffer-menu-1-window () | |
777 | 325 "Select this line's buffer, alone, in full frame." |
194 | 326 (interactive) |
327 (switch-to-buffer (Buffer-menu-buffer t)) | |
328 (bury-buffer (other-buffer)) | |
329 (delete-other-windows)) | |
330 | |
331 (defun Buffer-menu-this-window () | |
332 "Select this line's buffer in this window." | |
333 (interactive) | |
334 (switch-to-buffer (Buffer-menu-buffer t))) | |
335 | |
336 (defun Buffer-menu-other-window () | |
337 "Select this line's buffer in other window, leaving buffer menu visible." | |
338 (interactive) | |
339 (switch-to-buffer-other-window (Buffer-menu-buffer t))) | |
340 | |
735 | 341 (defun Buffer-menu-switch-other-window () |
342 "Make the other window select this line's buffer. | |
343 The current window remains selected." | |
344 (interactive) | |
345 (display-buffer (Buffer-menu-buffer t))) | |
346 | |
194 | 347 (defun Buffer-menu-2-window () |
348 "Select this line's buffer, with previous buffer in second window." | |
349 (interactive) | |
350 (let ((buff (Buffer-menu-buffer t)) | |
351 (menu (current-buffer)) | |
352 (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
|
353 (delete-other-windows) |
194 | 354 (switch-to-buffer (other-buffer)) |
355 (pop-to-buffer buff) | |
356 (bury-buffer menu))) | |
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
194
diff
changeset
|
357 |
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
194
diff
changeset
|
358 ;;; buff-menu.el ends here |