annotate lisp/electric/ebuff-menu.el @ 149:538048ae2ab8 r20-3b1

Import from CVS: tag r20-3b1
author cvs
date Mon, 13 Aug 2007 09:36:16 +0200
parents 0d2f883870bc
children
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 ;;; ebuff-menu.el --- electric-buffer-list mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
3 ;; Copyright (C) 1985, 1986, 1994 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Author: Richard Mlynarik <mly@ai.mit.edu>
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
6 ;; Keywords: frames
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
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
22 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
23 ;; 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
25 ;;; Synched up with: FSF 19.34.
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 ;; Who says one can't have typeout windows in GNU Emacs? The entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; point, `electric-buffer-list' works like ^r select buffer from the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; ITS Emacs lunar or tmacs libraries.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (require 'electric)
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
36 ;; XEmacs change
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (require 'buff-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; this depends on the format of list-buffers (from src/buffer.c) and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;; on stuff in lisp/buff-menu.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (defvar electric-buffer-menu-mode-map nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;;;###autoload
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 72
diff changeset
45 (defun electric-buffer-list (&optional files-only)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 "Pops up a buffer describing the set of Emacs buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 Vaguely like ITS lunar select buffer; combining typeoutoid buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 listing with menuoid buffer selection.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 If the very next character typed is a space then the buffer list
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
51 window disappears. Otherwise, one may move around in the buffer list
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
52 window, marking buffers to be selected, saved or deleted.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
54 To exit and select a new buffer, type a space when the cursor is on
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
55 the appropriate line of the buffer-list window. Other commands are
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
56 much like those of buffer-menu-mode.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 Calls value of `electric-buffer-menu-mode-hook' on entry if non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 72
diff changeset
60 Non-null optional arg FILES-ONLY means mention only file buffers.
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 72
diff changeset
61 When called from Lisp code, FILES-ONLY may be a regular expression,
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 72
diff changeset
62 in which case only buffers whose names match that expression are listed,
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 72
diff changeset
63 or an arbitrary predicate function.
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 72
diff changeset
64
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 \\{electric-buffer-menu-mode-map}"
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 72
diff changeset
66 (interactive (list (if current-prefix-arg t nil)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (let (select buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (save-window-excursion
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 72
diff changeset
69 (save-window-excursion (list-buffers files-only))
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
70 (setq buffer (window-buffer (Electric-pop-up-window "*Buffer List*")))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
71 (unwind-protect
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
72 (progn
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (set-buffer buffer)
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
74 (Electric-buffer-menu-mode)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
75 (setq select
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
76 (catch 'electric-buffer-menu-select
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
77 (message "<<< Press Return to bury the buffer list >>>")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
78 ;; XEmacs change
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
79 (if (eq (setq unread-command-events
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
80 (list (next-command-event)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
81 ?\ )
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
82 (progn (setq unread-command-events nil)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
83 (throw 'electric-buffer-menu-select nil)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
84 (let ((start-point (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
85 (first (progn (goto-char (point-min))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
86 (forward-line 2)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
87 (point)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
88 (last (progn (goto-char (point-max))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
89 (forward-line -1)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
90 (point)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
91 (goal-column 0))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
92 ;; Use start-point if it is meaningful.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
93 (goto-char (if (or (< start-point first)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
94 (> start-point last))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
95 first
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
96 start-point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
97 (Electric-command-loop 'electric-buffer-menu-select
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
98 nil
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
99 t
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
100 'electric-buffer-menu-looper
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
101 (cons first last))))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
102 (set-buffer buffer)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
103 (Buffer-menu-mode)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
104 (bury-buffer buffer)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
105 (message "")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (if select
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
107 (progn (set-buffer buffer)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
108 (let ((opoint (point-marker)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
109 (Buffer-menu-execute)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
110 (goto-char (point-min))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
111 (if (prog1 (search-forward "\n>" nil t)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
112 (goto-char opoint) (set-marker opoint nil))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
113 (Buffer-menu-select)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
114 (switch-to-buffer (Buffer-menu-buffer t))))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (defun electric-buffer-menu-looper (state condition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (cond ((and condition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (not (memq (car condition) '(buffer-read-only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 end-of-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 beginning-of-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (signal (car condition) (cdr condition)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ((< (point) (car state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (forward-line 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 ((> (point) (cdr state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (if (pos-visible-in-window-p (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (recenter -1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (put 'Electric-buffer-menu-mode 'mode-class 'special)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (defun Electric-buffer-menu-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 "Major mode for editing a list of buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 Each line describes one of the buffers in Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 Letters do not insert themselves; instead, they are commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 \\<electric-buffer-menu-mode-map>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 \\[keyboard-quit] or \\[Electric-buffer-menu-quit] -- exit buffer menu, returning to previous window and buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 configuration. If the very first character typed is a space, it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 also has this effect.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 \\[Electric-buffer-menu-select] -- select buffer of line point is on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 Also show buffers marked with m in other windows,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 deletes buffers marked with \"D\", and saves those marked with \"S\".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 \\[Buffer-menu-mark] -- mark buffer to be displayed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 \\[Buffer-menu-not-modified] -- clear modified-flag on that buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 \\[Buffer-menu-save] -- mark that buffer to be saved.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 \\[Buffer-menu-delete] or \\[Buffer-menu-delete-backwards] -- mark that buffer to be deleted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 \\[Buffer-menu-unmark] -- remove all kinds of marks from current line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 \\[Electric-buffer-menu-mode-view-buffer] -- view buffer, returning when done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 \\[Buffer-menu-backup-unmark] -- back up a line and remove marks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 \\{electric-buffer-menu-mode-map}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 Entry to this mode via command `electric-buffer-list' calls the value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 `electric-buffer-menu-mode-hook' if it is non-nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (kill-all-local-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (use-local-map electric-buffer-menu-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (setq mode-name "Electric Buffer Menu")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (setq mode-line-buffer-identification "Electric Buffer List")
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
159 ;; XEmacs
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (if (memq 'mode-name mode-line-format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (progn (setq mode-line-format (copy-sequence mode-line-format))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (setcar (memq 'mode-name mode-line-format) "Buffers")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (make-local-variable 'Helper-return-blurb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (setq Helper-return-blurb "return to buffer editing")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (setq truncate-lines t)
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
166 ;; XEmacs
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (setq buffer-scrollbar-height 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (setq buffer-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (setq major-mode 'Electric-buffer-menu-mode)
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
170 ;; XEmacs
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (setq mode-motion-hook 'mode-motion-highlight-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (if (search-forward "\n." nil t) (forward-char -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (run-hooks 'electric-buffer-menu-mode-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 ;; generally the same as Buffer-menu-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 ;; (except we don't indirect to global-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (put 'Electric-buffer-menu-undefined 'suppress-keymap t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (if electric-buffer-menu-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 nil
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
181 (let ((map (make-keymap)) (submap (make-keymap)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
182 ;(fillarray (car (cdr map)) 'Electric-buffer-menu-undefined) ; FSF
8
4b173ad71786 Import from CVS: tag r19-15b5
cvs
parents: 6
diff changeset
183 (let ((i 0))
4b173ad71786 Import from CVS: tag r19-15b5
cvs
parents: 6
diff changeset
184 (while (< i 128)
4b173ad71786 Import from CVS: tag r19-15b5
cvs
parents: 6
diff changeset
185 (define-key map (make-string 1 i) 'Electric-buffer-menu-undefined)
4b173ad71786 Import from CVS: tag r19-15b5
cvs
parents: 6
diff changeset
186 (setq i (1+ i))))
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
187 (define-key map "\e" submap)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
188 ;(fillarray (car (cdr submap)) 'Electric-buffer-menu-undefined) ; FSF
8
4b173ad71786 Import from CVS: tag r19-15b5
cvs
parents: 6
diff changeset
189 (let ((map2 (lookup-key map "\e"))
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
190 (i 0))
8
4b173ad71786 Import from CVS: tag r19-15b5
cvs
parents: 6
diff changeset
191 (while (< i 128)
4b173ad71786 Import from CVS: tag r19-15b5
cvs
parents: 6
diff changeset
192 (define-key map2 (make-string 1 i) 'Electric-buffer-menu-undefined)
4b173ad71786 Import from CVS: tag r19-15b5
cvs
parents: 6
diff changeset
193 (setq i (1+ i))))
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
194 (define-key map "\C-z" 'suspend-emacs)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (define-key map "v" 'Electric-buffer-menu-mode-view-buffer)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 74
diff changeset
196 (define-key map (vector help-char) 'Helper-help)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (define-key map "?" 'Helper-describe-bindings)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (define-key map "\C-c" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (define-key map "\C-c\C-c" 'Electric-buffer-menu-quit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (define-key map "\C-]" 'Electric-buffer-menu-quit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (define-key map "q" 'Electric-buffer-menu-quit)
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
202 (define-key map " " 'Electric-buffer-menu-select)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
203 (define-key map "\C-m" 'Electric-buffer-menu-select)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (define-key map "\C-l" 'recenter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (define-key map "s" 'Buffer-menu-save)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (define-key map "d" 'Buffer-menu-delete)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (define-key map "k" 'Buffer-menu-delete)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (define-key map "\C-d" 'Buffer-menu-delete-backwards)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 ;(define-key map "\C-k" 'Buffer-menu-delete)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (define-key map "\177" 'Buffer-menu-backup-unmark)
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
211 ;; XEmacs
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (define-key map 'backspace 'Buffer-menu-backup-unmark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (define-key map "~" 'Buffer-menu-not-modified)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (define-key map "u" 'Buffer-menu-unmark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (let ((i ?0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (while (<= i ?9)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (define-key map (char-to-string i) 'digit-argument)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 ;;#### Urk!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (define-key map (concat "\e" (char-to-string i)) 'digit-argument)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (setq i (1+ i))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (define-key map "-" 'negative-argument)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (define-key map "\e-" 'negative-argument)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (define-key map "m" 'Buffer-menu-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (define-key map "\C-u" 'universal-argument)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (define-key map "\C-p" 'previous-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (define-key map "\C-n" 'next-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (define-key map "p" 'previous-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (define-key map "n" 'next-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (define-key map "\C-v" 'scroll-up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (define-key map "\ev" 'scroll-down)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (define-key map ">" 'scroll-right)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (define-key map "<" 'scroll-left)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (define-key map "\e\C-v" 'scroll-other-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (define-key map "\e>" 'end-of-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (define-key map "\e<" 'beginning-of-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (define-key map "\e\e" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (define-key map "\e\e\e" 'Electric-buffer-menu-quit)
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
238 ;; XEmacs
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (define-key map [home] 'beginning-of-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (define-key map [down] 'next-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (define-key map [up] 'previous-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (define-key map [prior] 'scroll-down)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (define-key map [next] 'scroll-up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (define-key map 'button2 'Electric-buffer-menu-mouse-select)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (define-key map 'button3 'Buffer-menu-popup-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (setq electric-buffer-menu-mode-map map)))
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 Electric-buffer-menu-exit ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (interactive)
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
250 ;; XEmacs
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (setq unread-command-event last-input-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 ;; for robustness
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (throw 'electric-buffer-menu-select nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (error (Buffer-menu-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (other-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (defun Electric-buffer-menu-select ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 "Leave Electric Buffer Menu, selecting buffers and executing changes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 Saves buffers marked \"S\". Deletes buffers marked \"K\".
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
261 Selects buffer at point and displays buffers marked \">\" in other windows."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (throw 'electric-buffer-menu-select (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (defun Electric-buffer-menu-mouse-select (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (interactive "e")
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
267 ;; XEmacs is simpler
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (mouse-set-point event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (Electric-buffer-menu-select))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (defun Electric-buffer-menu-quit ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 "Leave Electric Buffer Menu, restoring previous window configuration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 Does not execute select, save, or delete commands."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (throw 'electric-buffer-menu-select nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (defun Electric-buffer-menu-undefined ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (ding)
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
280 (message "%s"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
281 (if (and (eq (key-binding "\C-c\C-c") 'Electric-buffer-menu-quit)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
282 (eq (key-binding " ") 'Electric-buffer-menu-select)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 74
diff changeset
283 (eq (key-binding (vector help-char)) 'Helper-help)
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
284 (eq (key-binding "?") 'Helper-describe-bindings))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
285 (substitute-command-keys "Type C-c C-c to exit, Space to select,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 Type \\[Electric-buffer-menu-quit] to exit, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 \\[Electric-buffer-menu-select] to select, \
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
288 \\[Helper-help] for help, \\[Helper-describe-bindings] for commands.")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (sit-for 4))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (defun Electric-buffer-menu-mode-view-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 "View buffer on current line in Electric Buffer Menu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 Returns to Electric Buffer Menu when done."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (let ((bufnam (Buffer-menu-buffer nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (if bufnam
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (view-buffer bufnam)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (ding)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (message "Buffer %s does not exist!" bufnam)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (sit-for 4))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 ;;; ebuff-menu.el ends here