Mercurial > emacs
annotate lisp/buff-menu.el @ 2499:da67547eda51
* configure.in: When checking for X windows, search for an X11
subdirectory of ${x_includes}.
* configure.in: Check for gettimeofday function, for getdate.y.
Change `configure' to a mixture of custom code and autoconf stuff.
autoconf can't derive all the information we need, but we'd really
like to be able to take advantage of some of its tests, and its
file-editing facilities.
* configure.in: Renamed from configure.
Quote the sections of shell script we want copied literally to
the configure script.
(compile): Initialize this to make the autoconf macros' code happy.
Use AC_PROG_CC, AC_CONST, and AC_RETSIGTYPE instead of writing out
code to do their jobs.
Use autoconf to produce Makefile and src/config.h.
Remove the Makefile-style comment that autoconf places at the top
of src/config.h.
(config_h_opts): Removed - no longer necessary.
* Makefile.in (configname): Renamed to configuration.
(CONFIG_CFLAGS): Renamed to DEFS.
(CC, DEFS, C_SWITCH_SYSTEM, version, configuration): Adjusted to
get values via autoload @cookies@.
(libsrc_libs): Get this from autoconf. We used to do nothing
about this.
(${SUBDIR}): Pass DEFS to submakes instead of CONFIG_CFLAGS.
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Sat, 10 Apr 1993 06:02:36 +0000 |
parents | 4ecde980a8f5 |
children | d6ff54640930 |
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 |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
26 ;; 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
|
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., 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
|
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 ;; 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
|
38 ;; 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
|
39 ;; 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
|
40 ;; 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
|
41 ;; |
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 ;; 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
|
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 ;; 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
|
45 ;; 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
|
46 ;; |
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 ;; 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
|
48 |
801
e9e34745ae3b
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
777
diff
changeset
|
49 ;;; 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
|
50 |
ec4ffd67483d
Incorporated changes from Bob Weiner's enhanced buff-menu from the LCD
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
51 (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
|
52 "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
|
53 restore window configuration when only one buffer is selected.") |
194 | 54 |
55 ; Put buffer *Buffer List* into proper mode right away | |
56 ; so that from now on even list-buffers is enough to get a buffer menu. | |
57 | |
58 (defvar Buffer-menu-mode-map nil "") | |
59 | |
60 (if Buffer-menu-mode-map | |
61 () | |
62 (setq Buffer-menu-mode-map (make-keymap)) | |
63 (suppress-keymap Buffer-menu-mode-map t) | |
64 (define-key Buffer-menu-mode-map "q" 'Buffer-menu-select) | |
65 (define-key Buffer-menu-mode-map "2" 'Buffer-menu-2-window) | |
66 (define-key Buffer-menu-mode-map "1" 'Buffer-menu-1-window) | |
67 (define-key Buffer-menu-mode-map "f" 'Buffer-menu-this-window) | |
68 (define-key Buffer-menu-mode-map "o" 'Buffer-menu-other-window) | |
735 | 69 (define-key Buffer-menu-mode-map "\C-o" 'Buffer-menu-switch-other-window) |
194 | 70 (define-key Buffer-menu-mode-map "s" 'Buffer-menu-save) |
71 (define-key Buffer-menu-mode-map "d" 'Buffer-menu-delete) | |
72 (define-key Buffer-menu-mode-map "k" 'Buffer-menu-delete) | |
73 (define-key Buffer-menu-mode-map "\C-d" 'Buffer-menu-delete-backwards) | |
74 (define-key Buffer-menu-mode-map "\C-k" 'Buffer-menu-delete) | |
75 (define-key Buffer-menu-mode-map "x" 'Buffer-menu-execute) | |
76 (define-key Buffer-menu-mode-map " " 'next-line) | |
77 (define-key Buffer-menu-mode-map "n" 'next-line) | |
78 (define-key Buffer-menu-mode-map "p" 'previous-line) | |
79 (define-key Buffer-menu-mode-map "\177" 'Buffer-menu-backup-unmark) | |
80 (define-key Buffer-menu-mode-map "~" 'Buffer-menu-not-modified) | |
81 (define-key Buffer-menu-mode-map "?" 'describe-mode) | |
82 (define-key Buffer-menu-mode-map "u" 'Buffer-menu-unmark) | |
83 (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
|
84 (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
|
85 (define-key Buffer-menu-mode-map "%" 'Buffer-menu-toggle-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
|
86 ) |
194 | 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. |
2378
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
114 \\[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
|
115 \\[Buffer-menu-toggle-read-only] -- toggle read-only status of buffer on this line." |
194 | 116 (kill-all-local-variables) |
117 (use-local-map Buffer-menu-mode-map) | |
118 (setq truncate-lines t) | |
119 (setq buffer-read-only t) | |
120 (setq major-mode 'Buffer-menu-mode) | |
121 (setq mode-name "Buffer Menu") | |
122 (run-hooks 'buffer-menu-mode-hook)) | |
123 | |
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
|
124 (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
|
125 |
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 (defvar Buffer-menu-size-column nil) |
194 | 127 |
128 (defun Buffer-menu-buffer (error-if-non-existent-p) | |
129 "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
|
130 (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
|
131 (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
|
132 (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
|
133 (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
|
134 (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
|
135 (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
|
136 (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
|
137 (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
|
138 (setq Buffer-menu-size-column (current-column)))) |
194 | 139 (save-excursion |
140 (beginning-of-line) | |
141 (forward-char Buffer-menu-buffer-column) | |
142 (let ((start (point)) | |
143 string) | |
144 ;; End of buffer name marked by tab or two spaces. | |
145 (re-search-forward "\t\\| ") | |
146 (skip-chars-backward " \t") | |
147 (setq string (buffer-substring start (point))) | |
148 (or (get-buffer string) | |
149 (if error-if-non-existent-p | |
150 (error "No buffer named \"%s\"" string) | |
151 nil))))) | |
152 | |
756 | 153 (defun buffer-menu (&optional arg) |
194 | 154 "Make a menu of buffers so you can save, delete or select them. |
155 With argument, show only buffers that are visiting files. | |
156 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
|
157 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
|
158 previous window configuration." |
194 | 159 (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
|
160 (setq *buff-window-config* (current-window-configuration)) |
194 | 161 (list-buffers arg) |
162 (pop-to-buffer "*Buffer List*") | |
163 (forward-line 2) | |
164 (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
|
165 "Commands: d, s, x; 1, 2, m, u; delete; ~; q to quit; ? for help.")) |
194 | 166 |
167 (defun Buffer-menu-mark () | |
168 "Mark buffer on this line for being displayed by \\<Buffer-menu-mode-map>\\[Buffer-menu-select] command." | |
169 (interactive) | |
170 (beginning-of-line) | |
171 (if (looking-at " [-M]") | |
172 (ding) | |
173 (let ((buffer-read-only nil)) | |
174 (delete-char 1) | |
175 (insert ?>) | |
176 (forward-line 1)))) | |
177 | |
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
|
178 (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
|
179 "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
|
180 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
|
181 (interactive "P") |
194 | 182 (beginning-of-line) |
183 (if (looking-at " [-M]") | |
184 (ding) | |
185 (let* ((buf (Buffer-menu-buffer t)) | |
186 (mod (buffer-modified-p buf)) | |
187 (readonly (save-excursion (set-buffer buf) buffer-read-only)) | |
188 (buffer-read-only nil)) | |
189 (delete-char 3) | |
190 (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
|
191 (forward-line (if backup -1 1))) |
194 | 192 |
193 (defun Buffer-menu-backup-unmark () | |
194 "Move up and cancel all requested operations on buffer on line above." | |
195 (interactive) | |
196 (forward-line -1) | |
197 (Buffer-menu-unmark) | |
198 (forward-line -1)) | |
199 | |
200 (defun Buffer-menu-delete () | |
201 "Mark buffer on this line to be deleted by \\<Buffer-menu-mode-map>\\[Buffer-menu-execute] command." | |
202 (interactive) | |
203 (beginning-of-line) | |
204 (if (looking-at " [-M]") ;header lines | |
205 (ding) | |
206 (let ((buffer-read-only nil)) | |
207 (delete-char 1) | |
208 (insert ?D) | |
209 (forward-line 1)))) | |
210 | |
211 (defun Buffer-menu-delete-backwards () | |
212 "Mark buffer on this line to be deleted by \\<Buffer-menu-mode-map>\\[Buffer-menu-execute] command | |
213 and then move up one line" | |
214 (interactive) | |
215 (Buffer-menu-delete) | |
216 (forward-line -2) | |
217 (if (looking-at " [-M]") (forward-line 1))) | |
218 | |
219 (defun Buffer-menu-save () | |
220 "Mark buffer on this line to be saved by \\<Buffer-menu-mode-map>\\[Buffer-menu-execute] command." | |
221 (interactive) | |
222 (beginning-of-line) | |
223 (forward-char 1) | |
224 (if (looking-at " [-M]") ;header lines | |
225 (ding) | |
226 (let ((buffer-read-only nil)) | |
227 (delete-char 1) | |
228 (insert ?S) | |
229 (forward-line 1)))) | |
230 | |
231 (defun Buffer-menu-not-modified () | |
232 "Mark buffer on this line as unmodified (no changes to save)." | |
233 (interactive) | |
234 (save-excursion | |
235 (set-buffer (Buffer-menu-buffer t)) | |
236 (set-buffer-modified-p nil)) | |
237 (save-excursion | |
238 (beginning-of-line) | |
239 (forward-char 1) | |
240 (if (looking-at "\\*") | |
241 (let ((buffer-read-only nil)) | |
242 (delete-char 1) | |
243 (insert ? ))))) | |
244 | |
245 (defun Buffer-menu-execute () | |
246 "Save and/or delete buffers marked with \\<Buffer-menu-mode-map>\\[Buffer-menu-save] or \\<Buffer-menu-mode-map>\\[Buffer-menu-delete] commands." | |
247 (interactive) | |
248 (save-excursion | |
249 (goto-char (point-min)) | |
250 (forward-line 1) | |
251 (while (re-search-forward "^.S" nil t) | |
252 (let ((modp nil)) | |
253 (save-excursion | |
254 (set-buffer (Buffer-menu-buffer t)) | |
255 (save-buffer) | |
256 (setq modp (buffer-modified-p))) | |
257 (let ((buffer-read-only nil)) | |
258 (delete-char -1) | |
259 (insert (if modp ?* ? )))))) | |
260 (save-excursion | |
261 (goto-char (point-min)) | |
262 (forward-line 1) | |
263 (let ((buff-menu-buffer (current-buffer)) | |
264 (buffer-read-only nil)) | |
265 (while (search-forward "\nD" nil t) | |
266 (forward-char -1) | |
267 (let ((buf (Buffer-menu-buffer nil))) | |
268 (or (eq buf nil) | |
269 (eq buf buff-menu-buffer) | |
270 (save-excursion (kill-buffer buf)))) | |
271 (if (Buffer-menu-buffer nil) | |
272 (progn (delete-char 1) | |
273 (insert ? )) | |
274 (delete-region (point) (progn (forward-line 1) (point))) | |
275 (forward-char -1)))))) | |
276 | |
277 (defun Buffer-menu-select () | |
278 "Select this line's buffer; also display buffers marked with `>'. | |
279 You can mark buffers with the \\<Buffer-menu-mode-map>\\[Buffer-menu-mark] command." | |
280 (interactive) | |
281 (let ((buff (Buffer-menu-buffer t)) | |
282 (menu (current-buffer)) | |
283 (others ()) | |
284 tem) | |
285 (goto-char (point-min)) | |
286 (while (search-forward "\n>" nil t) | |
287 (setq tem (Buffer-menu-buffer t)) | |
288 (let ((buffer-read-only nil)) | |
289 (delete-char -1) | |
290 (insert ?\ )) | |
291 (or (eq tem buff) (memq tem others) (setq others (cons tem others)))) | |
292 (setq others (nreverse others) | |
777 | 293 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
|
294 (Buffer-menu-execute) |
194 | 295 (delete-other-windows) |
296 (switch-to-buffer buff) | |
297 (or (eq menu buff) | |
298 (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
|
299 (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
|
300 (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
|
301 ;; 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
|
302 ;; 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
|
303 (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
|
304 (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
|
305 (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
|
306 (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
|
307 (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
|
308 (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
|
309 (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
|
310 (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
|
311 (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
|
312 (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
|
313 (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
|
314 ))) |
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 |
194 | 316 |
317 (defun Buffer-menu-visit-tags-table () | |
318 "Visit the tags table in the buffer on this line. See `visit-tags-table'." | |
319 (interactive) | |
320 (let ((file (buffer-file-name (Buffer-menu-buffer t)))) | |
321 (if file | |
322 (visit-tags-table file) | |
323 (error "Specified buffer has no file")))) | |
324 | |
325 (defun Buffer-menu-1-window () | |
777 | 326 "Select this line's buffer, alone, in full frame." |
194 | 327 (interactive) |
328 (switch-to-buffer (Buffer-menu-buffer t)) | |
329 (bury-buffer (other-buffer)) | |
330 (delete-other-windows)) | |
331 | |
332 (defun Buffer-menu-this-window () | |
333 "Select this line's buffer in this window." | |
334 (interactive) | |
335 (switch-to-buffer (Buffer-menu-buffer t))) | |
336 | |
337 (defun Buffer-menu-other-window () | |
338 "Select this line's buffer in other window, leaving buffer menu visible." | |
339 (interactive) | |
340 (switch-to-buffer-other-window (Buffer-menu-buffer t))) | |
341 | |
735 | 342 (defun Buffer-menu-switch-other-window () |
343 "Make the other window select this line's buffer. | |
344 The current window remains selected." | |
345 (interactive) | |
346 (display-buffer (Buffer-menu-buffer t))) | |
347 | |
194 | 348 (defun Buffer-menu-2-window () |
349 "Select this line's buffer, with previous buffer in second window." | |
350 (interactive) | |
351 (let ((buff (Buffer-menu-buffer t)) | |
352 (menu (current-buffer)) | |
353 (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
|
354 (delete-other-windows) |
194 | 355 (switch-to-buffer (other-buffer)) |
356 (pop-to-buffer buff) | |
357 (bury-buffer menu))) | |
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
194
diff
changeset
|
358 |
2378
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
359 (defun Buffer-menu-toggle-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
|
360 "Toggle read-only status of buffer on this line." |
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
361 (interactive) |
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
362 (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
|
363 (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
|
364 (set-buffer (Buffer-menu-buffer t)) |
c5d0140aa7b6
(Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2334
diff
changeset
|
365 (toggle-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
|
366 (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
|
367 (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
|
368 (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
|
369 (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
|
370 (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
|
371 (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
|
372 (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
|
373 (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
|
374 |
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
194
diff
changeset
|
375 ;;; buff-menu.el ends here |