Mercurial > emacs
annotate lisp/ebuff-menu.el @ 22416:a517da228cb9
(uce-message-text): Change the text of message that is sent.
(uce-reply-to-uce): Do not assume all Received lines
are on top of message without headers like `From' or `To'.
(uce-reply-to-uce): Parse Received lines better.
(uce-mail-reader): New user option.
(uce-reply-to uce): Add support for Gnus. User is supposed to set
uce-mail-reader to `gnus' if using Gnus to read mail. The default is
to assume Rmail. There's no magic to determine what mail reader is
currently active, so it is not possible to mix using uce.el with Rmail
and Gnus.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 09 Jun 1998 23:40:56 +0000 |
parents | cc3f3c1ea725 |
children | 62da6fd2d526 |
rev | line source |
---|---|
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
475
diff
changeset
|
1 ;;; ebuff-menu.el --- electric-buffer-list mode |
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
475
diff
changeset
|
2 |
7300 | 3 ;; Copyright (C) 1985, 1986, 1994 Free Software Foundation, Inc. |
846
20674ae6bf52
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
4 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
5 ;; Author: Richard Mlynarik <mly@ai.mit.edu> |
21045 | 6 ;; Maintainer: FSF |
475 | 7 |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
12 ;; the Free Software Foundation; either version 2, or (at your option) |
475 | 13 ;; any later version. |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
14169 | 21 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
475 | 24 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
25 ;;; Commentary: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
26 |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2026
diff
changeset
|
27 ;; Who says one can't have typeout windows in GNU Emacs? The entry |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2026
diff
changeset
|
28 ;; point, `electric-buffer-list' works like ^r select buffer from the |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2026
diff
changeset
|
29 ;; ITS Emacs lunar or tmacs libraries. |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
30 |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
31 ;;; Code: |
475 | 32 |
33 (require 'electric) | |
34 | |
35 ;; this depends on the format of list-buffers (from src/buffer.c) and | |
36 ;; on stuff in lisp/buff-menu.el | |
37 | |
38 (defvar electric-buffer-menu-mode-map nil) | |
39 | |
40 ;;;###autoload | |
41 (defun electric-buffer-list (arg) | |
42 "Pops up a buffer describing the set of Emacs buffers. | |
43 Vaguely like ITS lunar select buffer; combining typeoutoid buffer | |
44 listing with menuoid buffer selection. | |
45 | |
46 If the very next character typed is a space then the buffer list | |
47 window disappears. Otherwise, one may move around in the buffer list | |
48 window, marking buffers to be selected, saved or deleted. | |
49 | |
50 To exit and select a new buffer, type a space when the cursor is on | |
51 the appropriate line of the buffer-list window. Other commands are | |
52 much like those of buffer-menu-mode. | |
53 | |
54 Calls value of `electric-buffer-menu-mode-hook' on entry if non-nil. | |
55 | |
56 \\{electric-buffer-menu-mode-map}" | |
57 (interactive "P") | |
58 (let (select buffer) | |
59 (save-window-excursion | |
60 (save-window-excursion (list-buffers arg)) | |
61 (setq buffer (window-buffer (Electric-pop-up-window "*Buffer List*"))) | |
62 (unwind-protect | |
63 (progn | |
64 (set-buffer buffer) | |
65 (Electric-buffer-menu-mode) | |
66 (setq select | |
67 (catch 'electric-buffer-menu-select | |
8122
2fae14e8ae5d
(electric-buffer-list): Change prompt message.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
68 (message "<<< Press Return to bury the buffer list >>>") |
2026
3514a9bf50c5
(electric-buffer-list): Handle any kind of event.
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
69 (if (eq (setq unread-command-events (list (read-event))) |
3514a9bf50c5
(electric-buffer-list): Handle any kind of event.
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
70 ?\ ) |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1607
diff
changeset
|
71 (progn (setq unread-command-events nil) |
475 | 72 (throw 'electric-buffer-menu-select nil))) |
12568
94ee086557db
(electric-buffer-list): Save point before
Karl Heuer <kwzh@gnu.org>
parents:
11275
diff
changeset
|
73 (let ((start-point (point)) |
94ee086557db
(electric-buffer-list): Save point before
Karl Heuer <kwzh@gnu.org>
parents:
11275
diff
changeset
|
74 (first (progn (goto-char (point-min)) |
475 | 75 (forward-line 2) |
76 (point))) | |
77 (last (progn (goto-char (point-max)) | |
78 (forward-line -1) | |
79 (point))) | |
80 (goal-column 0)) | |
12568
94ee086557db
(electric-buffer-list): Save point before
Karl Heuer <kwzh@gnu.org>
parents:
11275
diff
changeset
|
81 ;; Use start-point if it is meaningful. |
94ee086557db
(electric-buffer-list): Save point before
Karl Heuer <kwzh@gnu.org>
parents:
11275
diff
changeset
|
82 (goto-char (if (or (< start-point first) |
94ee086557db
(electric-buffer-list): Save point before
Karl Heuer <kwzh@gnu.org>
parents:
11275
diff
changeset
|
83 (> start-point last)) |
94ee086557db
(electric-buffer-list): Save point before
Karl Heuer <kwzh@gnu.org>
parents:
11275
diff
changeset
|
84 first |
94ee086557db
(electric-buffer-list): Save point before
Karl Heuer <kwzh@gnu.org>
parents:
11275
diff
changeset
|
85 start-point)) |
475 | 86 (Electric-command-loop 'electric-buffer-menu-select |
87 nil | |
88 t | |
89 'electric-buffer-menu-looper | |
90 (cons first last)))))) | |
91 (set-buffer buffer) | |
92 (Buffer-menu-mode) | |
93 (bury-buffer buffer) | |
94 (message ""))) | |
95 (if select | |
96 (progn (set-buffer buffer) | |
97 (let ((opoint (point-marker))) | |
98 (Buffer-menu-execute) | |
99 (goto-char (point-min)) | |
100 (if (prog1 (search-forward "\n>" nil t) | |
101 (goto-char opoint) (set-marker opoint nil)) | |
102 (Buffer-menu-select) | |
103 (switch-to-buffer (Buffer-menu-buffer t)))))))) | |
104 | |
105 (defun electric-buffer-menu-looper (state condition) | |
106 (cond ((and condition | |
107 (not (memq (car condition) '(buffer-read-only | |
108 end-of-buffer | |
109 beginning-of-buffer)))) | |
110 (signal (car condition) (cdr condition))) | |
111 ((< (point) (car state)) | |
112 (goto-char (point-min)) | |
113 (forward-line 2)) | |
114 ((> (point) (cdr state)) | |
115 (goto-char (point-max)) | |
116 (forward-line -1) | |
117 (if (pos-visible-in-window-p (point-max)) | |
118 (recenter -1))))) | |
119 | |
120 (put 'Electric-buffer-menu-mode 'mode-class 'special) | |
121 (defun Electric-buffer-menu-mode () | |
122 "Major mode for editing a list of buffers. | |
123 Each line describes one of the buffers in Emacs. | |
124 Letters do not insert themselves; instead, they are commands. | |
125 \\<electric-buffer-menu-mode-map> | |
126 \\[keyboard-quit] or \\[Electric-buffer-menu-quit] -- exit buffer menu, returning to previous window and buffer | |
127 configuration. If the very first character typed is a space, it | |
128 also has this effect. | |
129 \\[Electric-buffer-menu-select] -- select buffer of line point is on. | |
130 Also show buffers marked with m in other windows, | |
131 deletes buffers marked with \"D\", and saves those marked with \"S\". | |
132 \\[Buffer-menu-mark] -- mark buffer to be displayed. | |
133 \\[Buffer-menu-not-modified] -- clear modified-flag on that buffer. | |
134 \\[Buffer-menu-save] -- mark that buffer to be saved. | |
135 \\[Buffer-menu-delete] or \\[Buffer-menu-delete-backwards] -- mark that buffer to be deleted. | |
136 \\[Buffer-menu-unmark] -- remove all kinds of marks from current line. | |
137 \\[Electric-buffer-menu-mode-view-buffer] -- view buffer, returning when done. | |
138 \\[Buffer-menu-backup-unmark] -- back up a line and remove marks. | |
139 | |
140 \\{electric-buffer-menu-mode-map} | |
141 | |
142 Entry to this mode via command electric-buffer-list calls the value of | |
143 electric-buffer-menu-mode-hook if it is non-nil." | |
144 (kill-all-local-variables) | |
145 (use-local-map electric-buffer-menu-mode-map) | |
146 (setq mode-name "Electric Buffer Menu") | |
147 (setq mode-line-buffer-identification "Electric Buffer List") | |
148 (make-local-variable 'Helper-return-blurb) | |
149 (setq Helper-return-blurb "return to buffer editing") | |
150 (setq truncate-lines t) | |
151 (setq buffer-read-only t) | |
152 (setq major-mode 'Electric-buffer-menu-mode) | |
153 (goto-char (point-min)) | |
154 (if (search-forward "\n." nil t) (forward-char -1)) | |
155 (run-hooks 'electric-buffer-menu-mode-hook)) | |
156 | |
157 ;; generally the same as Buffer-menu-mode-map | |
158 ;; (except we don't indirect to global-map) | |
159 (put 'Electric-buffer-menu-undefined 'suppress-keymap t) | |
160 (if electric-buffer-menu-mode-map | |
161 nil | |
2397
2b34a2ef4d63
(electric-buffer-menu-mode-map): fillarray isn't a valid operation on maps
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
162 (let ((map (make-keymap)) (submap (make-keymap))) |
2b34a2ef4d63
(electric-buffer-menu-mode-map): fillarray isn't a valid operation on maps
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
163 (fillarray (car (cdr map)) 'Electric-buffer-menu-undefined) |
2b34a2ef4d63
(electric-buffer-menu-mode-map): fillarray isn't a valid operation on maps
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
164 (define-key map "\e" submap) |
2b34a2ef4d63
(electric-buffer-menu-mode-map): fillarray isn't a valid operation on maps
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
165 (fillarray (car (cdr submap)) 'Electric-buffer-menu-undefined) |
475 | 166 (define-key map "\C-z" 'suspend-emacs) |
167 (define-key map "v" 'Electric-buffer-menu-mode-view-buffer) | |
918
94b50bbd43c3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
917
diff
changeset
|
168 (define-key map (char-to-string help-char) 'Helper-help) |
475 | 169 (define-key map "?" 'Helper-describe-bindings) |
170 (define-key map "\C-c" nil) | |
171 (define-key map "\C-c\C-c" 'Electric-buffer-menu-quit) | |
172 (define-key map "\C-]" 'Electric-buffer-menu-quit) | |
173 (define-key map "q" 'Electric-buffer-menu-quit) | |
174 (define-key map " " 'Electric-buffer-menu-select) | |
8122
2fae14e8ae5d
(electric-buffer-list): Change prompt message.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
175 (define-key map "\C-m" 'Electric-buffer-menu-select) |
475 | 176 (define-key map "\C-l" 'recenter) |
177 (define-key map "s" 'Buffer-menu-save) | |
178 (define-key map "d" 'Buffer-menu-delete) | |
179 (define-key map "k" 'Buffer-menu-delete) | |
180 (define-key map "\C-d" 'Buffer-menu-delete-backwards) | |
181 ;(define-key map "\C-k" 'Buffer-menu-delete) | |
182 (define-key map "\177" 'Buffer-menu-backup-unmark) | |
183 (define-key map "~" 'Buffer-menu-not-modified) | |
184 (define-key map "u" 'Buffer-menu-unmark) | |
185 (let ((i ?0)) | |
186 (while (<= i ?9) | |
187 (define-key map (char-to-string i) 'digit-argument) | |
188 (define-key map (concat "\e" (char-to-string i)) 'digit-argument) | |
189 (setq i (1+ i)))) | |
190 (define-key map "-" 'negative-argument) | |
191 (define-key map "\e-" 'negative-argument) | |
192 (define-key map "m" 'Buffer-menu-mark) | |
193 (define-key map "\C-u" 'universal-argument) | |
194 (define-key map "\C-p" 'previous-line) | |
195 (define-key map "\C-n" 'next-line) | |
196 (define-key map "p" 'previous-line) | |
197 (define-key map "n" 'next-line) | |
198 (define-key map "\C-v" 'scroll-up) | |
199 (define-key map "\ev" 'scroll-down) | |
200 (define-key map ">" 'scroll-right) | |
201 (define-key map "<" 'scroll-left) | |
202 (define-key map "\e\C-v" 'scroll-other-window) | |
203 (define-key map "\e>" 'end-of-buffer) | |
204 (define-key map "\e<" 'beginning-of-buffer) | |
11275
53f0ebe096f5
(electric-buffer-menu-mode-map): Undefine ESC ESC
Richard M. Stallman <rms@gnu.org>
parents:
10115
diff
changeset
|
205 (define-key map "\e\e" nil) |
10115
e55ee438bd10
(electric-buffer-menu-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
8122
diff
changeset
|
206 (define-key map "\e\e\e" 'Electric-buffer-menu-quit) |
e55ee438bd10
(electric-buffer-menu-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
8122
diff
changeset
|
207 (define-key map [escape escape escape] 'Electric-buffer-menu-quit) |
7006
5f1e5be68fcd
(Electric-buffer-menu-mouse-select): New function.
Karl Heuer <kwzh@gnu.org>
parents:
2397
diff
changeset
|
208 (define-key map [mouse-2] 'Electric-buffer-menu-mouse-select) |
475 | 209 (setq electric-buffer-menu-mode-map map))) |
210 | |
211 (defun Electric-buffer-menu-exit () | |
212 (interactive) | |
2026
3514a9bf50c5
(electric-buffer-list): Handle any kind of event.
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
213 (setq unread-command-events (listify-key-sequence (this-command-keys))) |
475 | 214 ;; for robustness |
215 (condition-case () | |
216 (throw 'electric-buffer-menu-select nil) | |
217 (error (Buffer-menu-mode) | |
218 (other-buffer)))) | |
219 | |
220 (defun Electric-buffer-menu-select () | |
221 "Leave Electric Buffer Menu, selecting buffers and executing changes. | |
222 Saves buffers marked \"S\". Deletes buffers marked \"K\". | |
223 Selects buffer at point and displays buffers marked \">\" in other windows." | |
224 (interactive) | |
225 (throw 'electric-buffer-menu-select (point))) | |
226 | |
7006
5f1e5be68fcd
(Electric-buffer-menu-mouse-select): New function.
Karl Heuer <kwzh@gnu.org>
parents:
2397
diff
changeset
|
227 (defun Electric-buffer-menu-mouse-select (event) |
5f1e5be68fcd
(Electric-buffer-menu-mouse-select): New function.
Karl Heuer <kwzh@gnu.org>
parents:
2397
diff
changeset
|
228 (interactive "e") |
5f1e5be68fcd
(Electric-buffer-menu-mouse-select): New function.
Karl Heuer <kwzh@gnu.org>
parents:
2397
diff
changeset
|
229 (select-window (posn-window (event-end event))) |
5f1e5be68fcd
(Electric-buffer-menu-mouse-select): New function.
Karl Heuer <kwzh@gnu.org>
parents:
2397
diff
changeset
|
230 (set-buffer (window-buffer (selected-window))) |
5f1e5be68fcd
(Electric-buffer-menu-mouse-select): New function.
Karl Heuer <kwzh@gnu.org>
parents:
2397
diff
changeset
|
231 (goto-char (posn-point (event-end event))) |
5f1e5be68fcd
(Electric-buffer-menu-mouse-select): New function.
Karl Heuer <kwzh@gnu.org>
parents:
2397
diff
changeset
|
232 (throw 'electric-buffer-menu-select (point))) |
5f1e5be68fcd
(Electric-buffer-menu-mouse-select): New function.
Karl Heuer <kwzh@gnu.org>
parents:
2397
diff
changeset
|
233 |
475 | 234 (defun Electric-buffer-menu-quit () |
235 "Leave Electric Buffer Menu, restoring previous window configuration. | |
236 Does not execute select, save, or delete commands." | |
237 (interactive) | |
238 (throw 'electric-buffer-menu-select nil)) | |
239 | |
240 (defun Electric-buffer-menu-undefined () | |
241 (interactive) | |
242 (ding) | |
14310
49af6e2bfaa8
(Electric-buffer-menu-undefined): Pass proper format string to message.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
243 (message "%s" |
49af6e2bfaa8
(Electric-buffer-menu-undefined): Pass proper format string to message.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
244 (if (and (eq (key-binding "\C-c\C-c") 'Electric-buffer-menu-quit) |
475 | 245 (eq (key-binding " ") 'Electric-buffer-menu-select) |
919 | 246 (eq (key-binding (char-to-string help-char)) 'Helper-help) |
475 | 247 (eq (key-binding "?") 'Helper-describe-bindings)) |
916
938f166a0874
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
915
diff
changeset
|
248 (substitute-command-keys "Type C-c C-c to exit, Space to select, \\[Helper-help] for help, ? for commands") |
475 | 249 (substitute-command-keys "\ |
250 Type \\[Electric-buffer-menu-quit] to exit, \ | |
251 \\[Electric-buffer-menu-select] to select, \ | |
252 \\[Helper-help] for help, \\[Helper-describe-bindings] for commands."))) | |
253 (sit-for 4)) | |
254 | |
255 (defun Electric-buffer-menu-mode-view-buffer () | |
256 "View buffer on current line in Electric Buffer Menu. | |
257 Returns to Electric Buffer Menu when done." | |
258 (interactive) | |
259 (let ((bufnam (Buffer-menu-buffer nil))) | |
260 (if bufnam | |
261 (view-buffer bufnam) | |
262 (ding) | |
263 (message "Buffer %s does not exist!" bufnam) | |
264 (sit-for 4)))) | |
265 | |
18383 | 266 (provide 'ebuff-menu) |
267 | |
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
475
diff
changeset
|
268 ;;; ebuff-menu.el ends here |