annotate lisp/buff-menu.el @ 3697:994bb6dc9249

*** empty log message ***
author Richard M. Stallman <rms@gnu.org>
date Sat, 12 Jun 1993 20:53:59 +0000
parents 507f64624555
children d42c85701055
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
213978acbc1e entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 801
diff changeset
4
801
e9e34745ae3b *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 777
diff changeset
5 ;; Maintainer: FSF
194
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
7 ;; This file is part of GNU Emacs.
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
8
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
735
ea0823fe7df5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 662
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
194
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 ;; any later version.
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 ;; GNU General Public License for more details.
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20 ;; along with GNU Emacs; see the file COPYING. If not, write to
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48 ; Put buffer *Buffer List* into proper mode right away
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49 ; so that from now on even list-buffers is enough to get a buffer menu.
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51 (defvar Buffer-menu-mode-map nil "")
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 (if Buffer-menu-mode-map
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 ()
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55 (setq Buffer-menu-mode-map (make-keymap))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 (define-key Buffer-menu-mode-map "2" 'Buffer-menu-2-window)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 (define-key Buffer-menu-mode-map "1" 'Buffer-menu-1-window)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 (define-key Buffer-menu-mode-map "f" 'Buffer-menu-this-window)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62 (define-key Buffer-menu-mode-map "o" 'Buffer-menu-other-window)
735
ea0823fe7df5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 662
diff changeset
63 (define-key Buffer-menu-mode-map "\C-o" 'Buffer-menu-switch-other-window)
194
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64 (define-key Buffer-menu-mode-map "s" 'Buffer-menu-save)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65 (define-key Buffer-menu-mode-map "d" 'Buffer-menu-delete)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66 (define-key Buffer-menu-mode-map "k" 'Buffer-menu-delete)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67 (define-key Buffer-menu-mode-map "\C-d" 'Buffer-menu-delete-backwards)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68 (define-key Buffer-menu-mode-map "\C-k" 'Buffer-menu-delete)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69 (define-key Buffer-menu-mode-map "x" 'Buffer-menu-execute)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70 (define-key Buffer-menu-mode-map " " 'next-line)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71 (define-key Buffer-menu-mode-map "n" 'next-line)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72 (define-key Buffer-menu-mode-map "p" 'previous-line)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73 (define-key Buffer-menu-mode-map "\177" 'Buffer-menu-backup-unmark)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74 (define-key Buffer-menu-mode-map "~" 'Buffer-menu-not-modified)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75 (define-key Buffer-menu-mode-map "?" 'describe-mode)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76 (define-key Buffer-menu-mode-map "u" 'Buffer-menu-unmark)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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)
c5d0140aa7b6 (Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2334
diff changeset
80 )
194
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82 ;; Buffer Menu mode is suitable only for specially formatted data.
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
83 (put 'Buffer-menu-mode 'mode-class 'special)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85 (defun Buffer-menu-mode ()
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86 "Major mode for editing a list of buffers.
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87 Each line describes one of the buffers in Emacs.
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
88 Letters do not insert themselves; instead, they are commands.
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89 \\<Buffer-menu-mode-map>
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90 \\[Buffer-menu-mark] -- mark buffer to be displayed.
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
91 \\[Buffer-menu-select] -- select buffer of line point is on.
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
92 Also show buffers marked with m in other windows.
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
93 \\[Buffer-menu-1-window] -- select that buffer in full-frame window.
194
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 \\[Buffer-menu-2-window] -- select that buffer in one window,
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95 together with buffer selected before this one in another window.
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96 \\[Buffer-menu-this-window] -- select that buffer in place of the buffer menu buffer.
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97 \\[Buffer-menu-other-window] -- select that buffer in another window,
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98 so the buffer menu buffer remains visible in its window.
735
ea0823fe7df5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 662
diff changeset
99 \\[Buffer-menu-switch-other-window] -- switch the other window to this buffer.
194
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100 \\[Buffer-menu-visit-tags-table] -- visit-tags-table this buffer.
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
101 \\[Buffer-menu-not-modified] -- clear modified-flag on that buffer.
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
102 \\[Buffer-menu-save] -- mark that buffer to be saved, and move down.
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
103 \\[Buffer-menu-delete] -- mark that buffer to be deleted, and move down.
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104 \\[Buffer-menu-delete-backwards] -- mark that buffer to be deleted, and move up.
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
105 \\[Buffer-menu-execute] -- delete or save marked buffers.
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
106 \\[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
107 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
108 \\[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
109 \\[Buffer-menu-toggle-read-only] -- toggle read-only status of buffer on this line."
194
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110 (kill-all-local-variables)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111 (use-local-map Buffer-menu-mode-map)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
112 (setq truncate-lines t)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113 (setq buffer-read-only t)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114 (setq major-mode 'Buffer-menu-mode)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
115 (setq mode-name "Buffer Menu")
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116 (run-hooks 'buffer-menu-mode-hook))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
117
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
118 (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
119
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-size-column nil)
194
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
121
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
122 (defun Buffer-menu-buffer (error-if-non-existent-p)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
123 "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
124 (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
125 (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
126 (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
127 (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
128 (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
129 (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
130 (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
131 (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
132 (setq Buffer-menu-size-column (current-column))))
194
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133 (save-excursion
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134 (beginning-of-line)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 (forward-char Buffer-menu-buffer-column)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
136 (let ((start (point))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
137 string)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
138 ;; End of buffer name marked by tab or two spaces.
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
139 (re-search-forward "\t\\| ")
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
140 (skip-chars-backward " \t")
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
141 (setq string (buffer-substring start (point)))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
142 (or (get-buffer string)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
143 (if error-if-non-existent-p
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
144 (error "No buffer named \"%s\"" string)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145 nil)))))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
146
756
0276f8eb306f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 735
diff changeset
147 (defun buffer-menu (&optional arg)
194
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
148 "Make a menu of buffers so you can save, delete or select them.
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
149 With argument, show only buffers that are visiting files.
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
150 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
151 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
152 previous window configuration."
194
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
153 (interactive "P")
2736
d6ff54640930 (buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents: 2422
diff changeset
154 ;;; (setq Buffer-menu-window-config (current-window-configuration))
194
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155 (list-buffers arg)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
156 (pop-to-buffer "*Buffer List*")
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
157 (forward-line 2)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
158 (message
2736
d6ff54640930 (buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents: 2422
diff changeset
159 "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
160
d6ff54640930 (buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents: 2422
diff changeset
161 (defun Buffer-menu-quit ()
d6ff54640930 (buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents: 2422
diff changeset
162 "Quit the buffer menu."
d6ff54640930 (buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents: 2422
diff changeset
163 (interactive)
d6ff54640930 (buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents: 2422
diff changeset
164 (let ((buffer (current-buffer)))
d6ff54640930 (buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents: 2422
diff changeset
165 ;; 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
166 ;; selected buffers.
d6ff54640930 (buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents: 2422
diff changeset
167 (switch-to-buffer (other-buffer))
d6ff54640930 (buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents: 2422
diff changeset
168 (bury-buffer buffer)))
194
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
169
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
170 (defun Buffer-menu-mark ()
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
171 "Mark buffer on this line for being displayed by \\<Buffer-menu-mode-map>\\[Buffer-menu-select] command."
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
172 (interactive)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
173 (beginning-of-line)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
174 (if (looking-at " [-M]")
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
175 (ding)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
176 (let ((buffer-read-only nil))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
177 (delete-char 1)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
178 (insert ?>)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
179 (forward-line 1))))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
180
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
181 (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
182 "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
183 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
184 (interactive "P")
194
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
185 (beginning-of-line)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
186 (if (looking-at " [-M]")
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
187 (ding)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
188 (let* ((buf (Buffer-menu-buffer t))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
189 (mod (buffer-modified-p buf))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
190 (readonly (save-excursion (set-buffer buf) buffer-read-only))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
191 (buffer-read-only nil))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
192 (delete-char 3)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
193 (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
194 (forward-line (if backup -1 1)))
194
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
195
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
196 (defun Buffer-menu-backup-unmark ()
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
197 "Move up and cancel all requested operations on buffer on line above."
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
198 (interactive)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199 (forward-line -1)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
200 (Buffer-menu-unmark)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
201 (forward-line -1))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
202
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
203 (defun Buffer-menu-delete ()
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
204 "Mark buffer on this line to be deleted by \\<Buffer-menu-mode-map>\\[Buffer-menu-execute] command."
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
205 (interactive)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
206 (beginning-of-line)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207 (if (looking-at " [-M]") ;header lines
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
208 (ding)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
209 (let ((buffer-read-only nil))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
210 (delete-char 1)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
211 (insert ?D)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
212 (forward-line 1))))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
214 (defun Buffer-menu-delete-backwards ()
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215 "Mark buffer on this line to be deleted by \\<Buffer-menu-mode-map>\\[Buffer-menu-execute] command
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216 and then move up one line"
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 (interactive)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218 (Buffer-menu-delete)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
219 (forward-line -2)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220 (if (looking-at " [-M]") (forward-line 1)))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
221
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
222 (defun Buffer-menu-save ()
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223 "Mark buffer on this line to be saved by \\<Buffer-menu-mode-map>\\[Buffer-menu-execute] command."
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224 (interactive)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
225 (beginning-of-line)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
226 (forward-char 1)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
227 (if (looking-at " [-M]") ;header lines
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228 (ding)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229 (let ((buffer-read-only nil))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230 (delete-char 1)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
231 (insert ?S)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
232 (forward-line 1))))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
233
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
234 (defun Buffer-menu-not-modified ()
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
235 "Mark buffer on this line as unmodified (no changes to save)."
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
236 (interactive)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
237 (save-excursion
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
238 (set-buffer (Buffer-menu-buffer t))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
239 (set-buffer-modified-p nil))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
240 (save-excursion
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
241 (beginning-of-line)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
242 (forward-char 1)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
243 (if (looking-at "\\*")
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
244 (let ((buffer-read-only nil))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
245 (delete-char 1)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
246 (insert ? )))))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
247
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
248 (defun Buffer-menu-execute ()
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
249 "Save and/or delete buffers marked with \\<Buffer-menu-mode-map>\\[Buffer-menu-save] or \\<Buffer-menu-mode-map>\\[Buffer-menu-delete] commands."
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
250 (interactive)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
251 (save-excursion
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
252 (goto-char (point-min))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
253 (forward-line 1)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
254 (while (re-search-forward "^.S" nil t)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
255 (let ((modp nil))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
256 (save-excursion
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
257 (set-buffer (Buffer-menu-buffer t))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
258 (save-buffer)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
259 (setq modp (buffer-modified-p)))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
260 (let ((buffer-read-only nil))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
261 (delete-char -1)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
262 (insert (if modp ?* ? ))))))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
263 (save-excursion
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
264 (goto-char (point-min))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
265 (forward-line 1)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
266 (let ((buff-menu-buffer (current-buffer))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
267 (buffer-read-only nil))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
268 (while (search-forward "\nD" nil t)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
269 (forward-char -1)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
270 (let ((buf (Buffer-menu-buffer nil)))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
271 (or (eq buf nil)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
272 (eq buf buff-menu-buffer)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
273 (save-excursion (kill-buffer buf))))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
274 (if (Buffer-menu-buffer nil)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
275 (progn (delete-char 1)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
276 (insert ? ))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
277 (delete-region (point) (progn (forward-line 1) (point)))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
278 (forward-char -1))))))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
279
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
280 (defun Buffer-menu-select ()
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
281 "Select this line's buffer; also display buffers marked with `>'.
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
282 You can mark buffers with the \\<Buffer-menu-mode-map>\\[Buffer-menu-mark] command."
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
283 (interactive)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
284 (let ((buff (Buffer-menu-buffer t))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
285 (menu (current-buffer))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
286 (others ())
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
287 tem)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
288 (goto-char (point-min))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
289 (while (search-forward "\n>" nil t)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
290 (setq tem (Buffer-menu-buffer t))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
291 (let ((buffer-read-only nil))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
292 (delete-char -1)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
293 (insert ?\ ))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
294 (or (eq tem buff) (memq tem others) (setq others (cons tem others))))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
295 (setq others (nreverse others)
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
296 tem (/ (1- (frame-height)) (1+ (length others))))
194
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
297 (delete-other-windows)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
298 (switch-to-buffer buff)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
299 (or (eq menu buff)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
300 (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
301 (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
302 (progn
2736
d6ff54640930 (buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents: 2422
diff changeset
303 ;;; ;; 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
304 ;;; ;; selected buffers.
d6ff54640930 (buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents: 2422
diff changeset
305 ;;; (if Buffer-menu-window-config
d6ff54640930 (buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents: 2422
diff changeset
306 ;;; (progn
d6ff54640930 (buffer-menu): Don't save a window config.
Richard M. Stallman <rms@gnu.org>
parents: 2422
diff changeset
307 ;;; (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
308 ;;; (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
309 (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
310 (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
311 (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
312 (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
313 (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
314 (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
315 (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
316 )))
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
194
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
318
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
319 (defun Buffer-menu-visit-tags-table ()
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
320 "Visit the tags table in the buffer on this line. See `visit-tags-table'."
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
321 (interactive)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
322 (let ((file (buffer-file-name (Buffer-menu-buffer t))))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
323 (if file
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
324 (visit-tags-table file)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
325 (error "Specified buffer has no file"))))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
326
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
327 (defun Buffer-menu-1-window ()
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
328 "Select this line's buffer, alone, in full frame."
194
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
329 (interactive)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
330 (switch-to-buffer (Buffer-menu-buffer t))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
331 (bury-buffer (other-buffer))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
332 (delete-other-windows))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
333
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
334 (defun Buffer-menu-this-window ()
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
335 "Select this line's buffer in this window."
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
336 (interactive)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
337 (switch-to-buffer (Buffer-menu-buffer t)))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
338
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
339 (defun Buffer-menu-other-window ()
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
340 "Select this line's buffer in other window, leaving buffer menu visible."
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
341 (interactive)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
342 (switch-to-buffer-other-window (Buffer-menu-buffer t)))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
343
735
ea0823fe7df5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 662
diff changeset
344 (defun Buffer-menu-switch-other-window ()
ea0823fe7df5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 662
diff changeset
345 "Make the other window select this line's buffer.
ea0823fe7df5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 662
diff changeset
346 The current window remains selected."
ea0823fe7df5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 662
diff changeset
347 (interactive)
ea0823fe7df5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 662
diff changeset
348 (display-buffer (Buffer-menu-buffer t)))
ea0823fe7df5 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 662
diff changeset
349
194
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
350 (defun Buffer-menu-2-window ()
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
351 "Select this line's buffer, with previous buffer in second window."
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
352 (interactive)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
353 (let ((buff (Buffer-menu-buffer t))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
354 (menu (current-buffer))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
355 (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
356 (delete-other-windows)
194
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
357 (switch-to-buffer (other-buffer))
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
358 (pop-to-buffer buff)
5b0d1a9cf37e Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
359 (bury-buffer menu)))
662
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 194
diff changeset
360
2378
c5d0140aa7b6 (Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2334
diff changeset
361 (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
362 "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
363 (interactive)
c5d0140aa7b6 (Buffer-menu-toggle-read-only) Added, per Rob Austein's suggestion
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2334
diff changeset
364 (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
365 (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
366 (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
367 (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
368 (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
369 (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
370 (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
371 (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
372 (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
373 (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
374 (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
375 (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
376
662
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 194
diff changeset
377 ;;; buff-menu.el ends here