annotate lisp/packages/buff-menu.el @ 70:131b0175ea99 r20-0b30

Import from CVS: tag r20-0b30
author cvs
date Mon, 13 Aug 2007 09:02:59 +0200
parents bcdc7deadc19
children b9518feda344
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; buff-menu.el --- buffer menu main function and support functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1985, 86, 87, 93, 94, 95 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Maintainer: FSF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 12
diff changeset
20 ;; along with XEmacs; see the file COPYING. If not, write to the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 12
diff changeset
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 12
diff changeset
22 ;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 12
diff changeset
24 ;;; Synched up with: FSF 19.30 except as noted.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; Edit, delete, or change attributes of all currently active Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; buffers from a list summarizing their state. A good way to browse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; any special or scratch buffers you have loaded, since you can't find
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; them by filename. The single entry point is `Buffer-menu-mode',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; normally bound to C-x C-b.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;; Change Log:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; Merged by esr with recent mods to Emacs 19 buff-menu, 23 Mar 1993
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;; Modified by Bob Weiner, Motorola, Inc., 4/14/89
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;; Added optional backup argument to 'Buffer-menu-unmark' to make it undelete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;; current entry and then move to previous one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;; Based on FSF code dating back to 1985.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;;;Trying to preserve the old window configuration works well in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;;;simple scenarios, when you enter the buffer menu, use it, and exit it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;;;But it does strange things when you switch back to the buffer list buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;;;with C-x b, later on, when the window configuration is different.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;;;The choice seems to be, either restore the window configuration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;;;in all cases, or in no cases.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;;;I decided it was better not to restore the window config at all. -- rms.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;;;But since then, I changed buffer-menu to use the selected window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;;;so q now once again goes back to the previous window configuration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;;;(defvar Buffer-menu-window-config nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;;; "Window configuration saved from entry to `buffer-menu'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ; Put buffer *Buffer List* into proper mode right away
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ; so that from now on even list-buffers is enough to get a buffer menu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (defvar Buffer-menu-buffer-column 4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (defvar Buffer-menu-mode-map nil "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (if Buffer-menu-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (setq Buffer-menu-mode-map (make-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (suppress-keymap Buffer-menu-mode-map t)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 12
diff changeset
72 (set-keymap-name Buffer-menu-mode-map 'Buffer-menu-mode-map)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (define-key Buffer-menu-mode-map "q" 'Buffer-menu-quit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (define-key Buffer-menu-mode-map "v" 'Buffer-menu-select)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (define-key Buffer-menu-mode-map "2" 'Buffer-menu-2-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (define-key Buffer-menu-mode-map "1" 'Buffer-menu-1-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (define-key Buffer-menu-mode-map "f" 'Buffer-menu-this-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (define-key Buffer-menu-mode-map "\C-m" 'Buffer-menu-this-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (define-key Buffer-menu-mode-map "o" 'Buffer-menu-other-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (define-key Buffer-menu-mode-map "\C-o" 'Buffer-menu-switch-other-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (define-key Buffer-menu-mode-map "s" 'Buffer-menu-save)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (define-key Buffer-menu-mode-map "d" 'Buffer-menu-delete)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (define-key Buffer-menu-mode-map "k" 'Buffer-menu-delete)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (define-key Buffer-menu-mode-map "\C-d" 'Buffer-menu-delete-backwards)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (define-key Buffer-menu-mode-map "\C-k" 'Buffer-menu-delete)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (define-key Buffer-menu-mode-map "x" 'Buffer-menu-execute)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (define-key Buffer-menu-mode-map " " 'next-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (define-key Buffer-menu-mode-map "n" 'next-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (define-key Buffer-menu-mode-map "p" 'previous-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (define-key Buffer-menu-mode-map "\177" 'Buffer-menu-backup-unmark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (define-key Buffer-menu-mode-map "~" 'Buffer-menu-not-modified)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (define-key Buffer-menu-mode-map "?" 'describe-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (define-key Buffer-menu-mode-map "u" 'Buffer-menu-unmark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (define-key Buffer-menu-mode-map "m" 'Buffer-menu-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (define-key Buffer-menu-mode-map "t" 'Buffer-menu-visit-tags-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (define-key Buffer-menu-mode-map "%" 'Buffer-menu-toggle-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (define-key Buffer-menu-mode-map "g" 'revert-buffer)
6
27bc7f280385 Import from CVS: tag r19-15b4
cvs
parents: 4
diff changeset
98 (define-key Buffer-menu-mode-map 'button2 'Buffer-menu-mouse-select)
27bc7f280385 Import from CVS: tag r19-15b4
cvs
parents: 4
diff changeset
99 (define-key Buffer-menu-mode-map 'button3 'Buffer-menu-popup-menu)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ;; Buffer Menu mode is suitable only for specially formatted data.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (put 'Buffer-menu-mode 'mode-class 'special)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (defun Buffer-menu-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 "Major mode for editing a list of buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 Each line describes one of the buffers in Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 Letters do not insert themselves; instead, they are commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 \\<Buffer-menu-mode-map>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 \\[Buffer-menu-mouse-select] -- select buffer you click on, in place of the buffer menu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 \\[Buffer-menu-this-window] -- select current line's buffer in place of the buffer menu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 \\[Buffer-menu-other-window] -- select that buffer in another window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 so the buffer menu buffer remains visible in its window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 \\[Buffer-menu-switch-other-window] -- make another window display that buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 \\[Buffer-menu-mark] -- mark current line's buffer to be displayed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 \\[Buffer-menu-select] -- select current line's buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 Also show buffers marked with m, in other windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 \\[Buffer-menu-1-window] -- select that buffer in full-frame window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 \\[Buffer-menu-2-window] -- select that buffer in one window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 together with buffer selected before this one in another window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 \\[Buffer-menu-visit-tags-table] -- visit-tags-table this buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 \\[Buffer-menu-not-modified] -- clear modified-flag on that buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 \\[Buffer-menu-save] -- mark that buffer to be saved, and move down.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 \\[Buffer-menu-delete] -- mark that buffer to be deleted, and move down.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 \\[Buffer-menu-delete-backwards] -- mark that buffer to be deleted, and move up.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 \\[Buffer-menu-execute] -- delete or save marked buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 \\[Buffer-menu-unmark] -- remove all kinds of marks from current line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 With prefix argument, also move up one line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 \\[Buffer-menu-backup-unmark] -- back up a line and remove marks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 \\[Buffer-menu-toggle-read-only] -- toggle read-only status of buffer on this line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (kill-all-local-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (use-local-map Buffer-menu-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (setq major-mode 'Buffer-menu-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (setq mode-name "Buffer Menu")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (make-local-variable 'revert-buffer-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (setq revert-buffer-function 'Buffer-menu-revert-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (setq truncate-lines t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (setq buffer-read-only t)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 12
diff changeset
139 (make-local-variable 'mouse-track-click-hook)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 12
diff changeset
140 (add-hook 'mouse-track-click-hook 'Buffer-menu-maybe-mouse-select)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (run-hooks 'buffer-menu-mode-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (defun Buffer-menu-revert-function (ignore1 ignore2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (list-buffers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (defun Buffer-menu-buffer (error-if-non-existent-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 "Return buffer described by this line of buffer menu."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (let* ((where (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (+ (point) Buffer-menu-buffer-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (name (and (not (eobp)) (get-text-property where 'buffer-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (if name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (or (get-buffer name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (if error-if-non-existent-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (error "No buffer named `%s'" name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (if error-if-non-existent-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (error "No buffer on this line")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (defun buffer-menu (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 "Make a menu of buffers so you can save, delete or select them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 With argument, show only buffers that are visiting files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 Type ? after invocation to get help on commands available.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 Type q immediately to make the buffer menu go away."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;;; (setq Buffer-menu-window-config (current-window-configuration))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (switch-to-buffer (list-buffers-noselect arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 "Commands: d, s, x, u; f, o, 1, 2, m, v; ~, %%; q to quit; ? for help."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (defun buffer-menu-other-window (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 "Display a list of buffers in another window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 With the buffer list buffer, you can save, delete or select the buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 With argument, show only buffers that are visiting files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 Type ? after invocation to get help on commands available.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 Type q immediately to make the buffer menu go away."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ;;; (setq Buffer-menu-window-config (current-window-configuration))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (switch-to-buffer-other-window (list-buffers-noselect arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 "Commands: d, s, x, u; f, o, 1, 2, m, v; ~, %%; q to quit; ? for help."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (defun Buffer-menu-quit ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 "Quit the buffer menu."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (let ((buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 ;; Switch away from the buffer menu and bury it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (switch-to-buffer (other-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (bury-buffer buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (defun Buffer-menu-mark ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 "Mark buffer on this line for being displayed by \\<Buffer-menu-mode-map>\\[Buffer-menu-select] command."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (if (looking-at " [-M]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (ding)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (let ((buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (delete-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (insert ?>)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (forward-line 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (defun Buffer-menu-unmark (&optional backup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 "Cancel all requested operations on buffer on this line and move down.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 Optional ARG means move up."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (if (looking-at " [-M]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (ding)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (let* ((buf (Buffer-menu-buffer t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (mod (buffer-modified-p buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (readonly (save-excursion (set-buffer buf) buffer-read-only))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (delete-char 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (insert (if readonly (if mod " *%" " %") (if mod " * " " ")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (forward-line (if backup -1 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (defun Buffer-menu-backup-unmark ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 "Move up and cancel all requested operations on buffer on line above."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (Buffer-menu-unmark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (forward-line -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (defun Buffer-menu-delete (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 "Mark buffer on this line to be deleted by \\<Buffer-menu-mode-map>\\[Buffer-menu-execute] command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 Prefix arg is how many buffers to delete.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 Negative arg means delete backwards."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (if (looking-at " [-M]") ;header lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (ding)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (let ((buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (if (or (null arg) (= arg 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (setq arg 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (while (> arg 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (delete-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (insert ?D)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (setq arg (1- arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (while (< arg 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (delete-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (insert ?D)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (setq arg (1+ arg))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (defun Buffer-menu-delete-backwards (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 "Mark buffer on this line to be deleted by \\<Buffer-menu-mode-map>\\[Buffer-menu-execute] command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 and then move up one line. Prefix arg means move that many lines."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (Buffer-menu-delete (- (or arg 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (while (looking-at " [-M]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (forward-line 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (defun Buffer-menu-save ()
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 12
diff changeset
256 "Mark buffer on this line to be saved by \\[Buffer-menu-execute] command."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (if (looking-at " [-M]") ;header lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (ding)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (let ((buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (delete-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (insert ?S)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (forward-line 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (defun Buffer-menu-not-modified (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 "Mark buffer on this line as unmodified (no changes to save)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (set-buffer (Buffer-menu-buffer t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (set-buffer-modified-p arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (if (= (char-after (point)) (if arg ? ?*))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (let ((buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (delete-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (insert (if arg ?* ? ))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (defun Buffer-menu-execute ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 "Save and/or delete buffers marked with \\<Buffer-menu-mode-map>\\[Buffer-menu-save] or \\<Buffer-menu-mode-map>\\[Buffer-menu-delete] commands."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (while (re-search-forward "^.S" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (let ((modp nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (set-buffer (Buffer-menu-buffer t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (save-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (setq modp (buffer-modified-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (let ((buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (delete-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (insert (if modp ?* ? ))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (let ((buff-menu-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (while (search-forward "\nD" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (forward-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (let ((buf (Buffer-menu-buffer nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (or (eq buf nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (eq buf buff-menu-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (save-excursion (kill-buffer buf))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (if (Buffer-menu-buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (progn (delete-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (insert ? ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (delete-region (point) (progn (forward-line 1) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (forward-char -1))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (defun Buffer-menu-select ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 "Select this line's buffer; also display buffers marked with `>'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 You can mark buffers with the \\<Buffer-menu-mode-map>\\[Buffer-menu-mark] command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 This command deletes and replaces all the previously existing windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 in the selected frame."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (let ((buff (Buffer-menu-buffer t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (menu (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (others ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 tem)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (while (search-forward "\n>" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (setq tem (Buffer-menu-buffer t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (let ((buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (delete-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (insert ?\ ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (or (eq tem buff) (memq tem others) (setq others (cons tem others))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (setq others (nreverse others)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 tem (/ (1- (frame-height)) (1+ (length others))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (delete-other-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (switch-to-buffer buff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (or (eq menu buff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (bury-buffer menu))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (if (equal (length others) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 ;;; ;; Restore previous window configuration before displaying
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 ;;; ;; selected buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 ;;; (if Buffer-menu-window-config
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 ;;; (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 ;;; (set-window-configuration Buffer-menu-window-config)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 ;;; (setq Buffer-menu-window-config nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (switch-to-buffer buff))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (while others
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (split-window nil tem)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (other-window 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (switch-to-buffer (car others))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (setq others (cdr others)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (other-window 1) ;back to the beginning!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (defun Buffer-menu-visit-tags-table ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 "Visit the tags table in the buffer on this line. See `visit-tags-table'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (let ((file (buffer-file-name (Buffer-menu-buffer t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (if file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (visit-tags-table file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (error "Specified buffer has no file"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (defun Buffer-menu-1-window ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 "Select this line's buffer, alone, in full frame."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (switch-to-buffer (Buffer-menu-buffer t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (bury-buffer (other-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (delete-other-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 ;; This is to get w->force_start set to nil. Don't ask me, I only work here.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (set-window-buffer (selected-window) (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (defun Buffer-menu-mouse-select (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 "Select the buffer whose line you click on."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (let (buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (save-excursion
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 12
diff changeset
377 (set-buffer (event-buffer event))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (save-excursion
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 12
diff changeset
379 (goto-char (event-point event))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (setq buffer (Buffer-menu-buffer t))))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 12
diff changeset
381 (select-window (event-window event))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (if (and (window-dedicated-p (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (eq (selected-window) (frame-root-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (switch-to-buffer-other-frame buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (switch-to-buffer buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (defun Buffer-menu-maybe-mouse-select (event &optional click-count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (and (>= click-count 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (let ((buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (config (current-window-configuration)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (Buffer-menu-mouse-select event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (set-window-configuration config)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (goto-char point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (defun Buffer-menu-this-window ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 "Select this line's buffer in this window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (switch-to-buffer (Buffer-menu-buffer t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (defun Buffer-menu-other-window ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 "Select this line's buffer in other window, leaving buffer menu visible."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (switch-to-buffer-other-window (Buffer-menu-buffer t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (defun Buffer-menu-switch-other-window ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 "Make the other window select this line's buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 The current window remains selected."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (display-buffer (Buffer-menu-buffer t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (defun Buffer-menu-2-window ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 "Select this line's buffer, with previous buffer in second window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (let ((buff (Buffer-menu-buffer t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (menu (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (pop-up-windows t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (delete-other-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (switch-to-buffer (other-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (pop-to-buffer buff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (bury-buffer menu)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (defun Buffer-menu-toggle-read-only ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 "Toggle read-only status of buffer on this line, perhaps via version control."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (let (char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (set-buffer (Buffer-menu-buffer t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (vc-toggle-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (setq char (if buffer-read-only ?% ? )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (forward-char 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (if (/= (following-char) char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (let (buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (delete-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (insert char))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (defvar Buffer-menu-popup-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 '("Buffer Commands"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 ["Select Buffer" Buffer-menu-select t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 ["Select buffer Other Window" Buffer-menu-other-window t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 ["Clear Buffer Modification Flag" Buffer-menu-not-modified t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 ["Mark Buffer for Selection" Buffer-menu-mark t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 ["Mark Buffer for Save" Buffer-menu-save t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 ["Mark Buffer for Deletion" Buffer-menu-delete t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 ["Unmark Buffer" Buffer-menu-unmark t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 ["Delete/Save Marked Buffers" Buffer-menu-execute t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (defun Buffer-menu-popup-menu (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (mouse-set-point event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (let ((buffer (Buffer-menu-buffer nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (if buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (popup-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (nconc (list (car Buffer-menu-popup-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 "Commands on buffer \"" (buffer-name buffer) "\":")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 "----")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (cdr Buffer-menu-popup-menu)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (error "no buffer on this line"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (defvar list-buffers-header-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (purecopy (concat " MR Buffer Size Mode File\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 " -- ------ ---- ---- ----\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (defvar list-buffers-identification 'default-list-buffers-identification
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 "String used to identify this buffer, or a function of one argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 to generate such a string. This variable is always buffer-local.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (make-variable-buffer-local 'list-buffers-identification)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 12
diff changeset
484 (defvar list-buffers-directory)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (make-variable-buffer-local 'list-buffers-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 ;; #### not synched
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (defun default-list-buffers-identification (output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (let ((file (or (buffer-file-name (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (and (boundp 'list-buffers-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 list-buffers-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (size (buffer-size))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (mode mode-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 eob p s col)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (set-buffer output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (setq eob (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (prin1 size output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (setq p (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 ;; right-justify the size
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (move-to-column 19 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (setq col (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (if (> eob col)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (goto-char eob))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (setq s (- 6 (- p col)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (while (> s 0) ; speed/consing tradeoff...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (insert ? )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (setq s (1- s)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (indent-to 27 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (insert mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (if (not file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 ;; if the mode-name is really long, clip it for the filename
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (if (> 0 (setq s (- 39 (current-column))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (delete-char (max s (- eob (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (indent-to 40 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (insert file)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 ;; #### not synched
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (defun list-buffers-internal (output &optional predicate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (let ((current (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (buffers (buffer-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (set-buffer output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (setq buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (buffer-disable-undo output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (insert list-buffers-header-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (while buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (let* ((col1 19)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (buffer (car buffers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (name (buffer-name buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 this-buffer-line-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (setq buffers (cdr buffers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (cond ((null name)) ;deleted buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 ((and predicate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (not (if (stringp predicate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (string-match predicate name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (funcall predicate buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (let ((ro buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (id list-buffers-identification))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (set-buffer output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (setq this-buffer-line-start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (insert (if (eq buffer current)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (progn (setq current (point)) ?\.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 ?\ ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (insert (if (buffer-modified-p buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 ?\*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 ?\ ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (insert (if ro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 ?\%
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 ?\ ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (if (string-match "[\n\"\\ \t]" name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (let ((print-escape-newlines t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (prin1 name output))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (insert ?\ name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (indent-to col1 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (cond ((stringp id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (insert id))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (id
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (condition-case e
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (funcall id output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (princ "***" output) (prin1 e output)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (set-buffer output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (goto-char (point-max)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (put-nonduplicable-text-property this-buffer-line-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 'buffer-name name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (put-nonduplicable-text-property this-buffer-line-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 'highlight t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (insert ?\n)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (Buffer-menu-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (if (not (bufferp current))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (goto-char current)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (defun list-buffers (&optional files-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 "Display a list of names of existing buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 The list is displayed in a buffer named `*Buffer List*'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 Note that buffers with names starting with spaces are omitted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 Non-null optional arg FILES-ONLY means mention only file buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 The M column contains a * for buffers that are modified.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 The R column contains a % for buffers that are read-only."
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 12
diff changeset
594 (interactive (list (if current-prefix-arg t nil)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (display-buffer (list-buffers-noselect files-only)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 ;; #### not synched
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (defun list-buffers-noselect (&optional files-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 "Create and return a buffer with a list of names of existing buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 The buffer is named `*Buffer List*'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 Note that buffers with names starting with spaces are omitted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 Non-null optional arg FILES-ONLY means mention only file buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 The M column contains a * for buffers that are modified.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 The R column contains a % for buffers that are read-only."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (let ((buffer (get-buffer-create "*Buffer List*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (list-buffers-internal buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (if (memq files-only '(t nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 #'(lambda (b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (let ((n (buffer-name b)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (cond ((and (/= 0 (length n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (= (aref n 0) ?\ ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 ;;don't mention if starts with " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (files-only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (buffer-file-name b))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 files-only))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (provide 'buff-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 ;;; buff-menu.el ends here