annotate lisp/buff-menu.el @ 219:262b8bb4a523 r20-4b8

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