annotate lisp/packages/buff-menu.el @ 12:bcdc7deadc19 r19-15b7

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