101360
|
1 ;;; rmailsum.el --- make summary buffers for the mail reader
|
|
2
|
|
3 ;; Copyright (C) 1985, 1993, 1994, 1995, 1996, 2000, 2001, 2002, 2003,
|
|
4 ;; 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
|
|
5
|
|
6 ;; Maintainer: FSF
|
|
7 ;; Keywords: mail
|
|
8
|
|
9 ;; This file is part of GNU Emacs.
|
|
10
|
|
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
|
|
12 ;; it under the terms of the GNU General Public License as published by
|
|
13 ;; the Free Software Foundation, either version 3 of the License, or
|
|
14 ;; (at your option) any later version.
|
|
15
|
|
16 ;; GNU Emacs is distributed in the hope that it will be useful,
|
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19 ;; GNU General Public License for more details.
|
|
20
|
|
21 ;; You should have received a copy of the GNU General Public License
|
|
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
|
23
|
|
24 ;;; Commentary:
|
|
25
|
|
26 ;; Extended by Bob Weiner of Motorola
|
|
27 ;; Provided all commands from rmail-mode in rmail-summary-mode and made key
|
|
28 ;; bindings in both modes wholly compatible.
|
|
29
|
|
30 ;;; Code:
|
|
31
|
101990
|
32 ;; For rmail-select-summary.
|
101360
|
33 (require 'rmail)
|
|
34
|
|
35 (defcustom rmail-summary-scroll-between-messages t
|
102367
|
36 "Non-nil means Rmail summary scroll commands move between messages.
|
|
37 That is, after `rmail-summary-scroll-msg-up' reaches the end of a
|
|
38 message, it moves to the next message; and similarly for
|
|
39 `rmail-summary-scroll-msg-down'."
|
101360
|
40 :type 'boolean
|
|
41 :group 'rmail-summary)
|
|
42
|
102367
|
43 ;; FIXME could do with a :set function that regenerates the summary
|
|
44 ;; and updates rmail-summary-vector.
|
101360
|
45 (defcustom rmail-summary-line-count-flag t
|
102367
|
46 "Non-nil means Rmail summary should show the number of lines in each message.
|
|
47 Setting this option to nil might speed up the generation of summaries."
|
101360
|
48 :type 'boolean
|
|
49 :group 'rmail-summary)
|
|
50
|
|
51 (defvar rmail-summary-font-lock-keywords
|
|
52 '(("^.....D.*" . font-lock-string-face) ; Deleted.
|
|
53 ("^.....-.*" . font-lock-type-face) ; Unread.
|
|
54 ;; Neither of the below will be highlighted if either of the above are:
|
|
55 ("^.....[^D-] \\(......\\)" 1 font-lock-keyword-face) ; Date.
|
|
56 ("{ \\([^\n}]+\\) }" 1 font-lock-comment-face)) ; Labels.
|
|
57 "Additional expressions to highlight in Rmail Summary mode.")
|
|
58
|
101990
|
59 (defvar rmail-summary-redo nil
|
101360
|
60 "(FUNCTION . ARGS) to regenerate this Rmail summary buffer.")
|
|
61
|
101990
|
62 (defvar rmail-summary-overlay nil
|
|
63 "Overlay used to highlight the current message in the Rmail summary.")
|
101360
|
64 (put 'rmail-summary-overlay 'permanent-local t)
|
|
65
|
101990
|
66 (defvar rmail-summary-mode-map nil
|
|
67 "Keymap used in Rmail summary mode.")
|
101360
|
68
|
|
69 ;; Entry points for making a summary buffer.
|
|
70
|
|
71 ;; Regenerate the contents of the summary
|
|
72 ;; using the same selection criterion as last time.
|
|
73 ;; M-x revert-buffer in a summary buffer calls this function.
|
|
74 (defun rmail-update-summary (&rest ignore)
|
|
75 (apply (car rmail-summary-redo) (cdr rmail-summary-redo)))
|
|
76
|
|
77 ;;;###autoload
|
|
78 (defun rmail-summary ()
|
|
79 "Display a summary of all messages, one line per message."
|
|
80 (interactive)
|
|
81 (rmail-new-summary "All" '(rmail-summary) nil)
|
|
82 (unless (get-buffer-window rmail-buffer)
|
|
83 (rmail-summary-beginning-of-message)))
|
|
84
|
|
85 ;;;###autoload
|
|
86 (defun rmail-summary-by-labels (labels)
|
|
87 "Display a summary of all messages with one or more LABELS.
|
|
88 LABELS should be a string containing the desired labels, separated by commas."
|
|
89 (interactive "sLabels to summarize by: ")
|
|
90 (if (string= labels "")
|
|
91 (setq labels (or rmail-last-multi-labels
|
|
92 (error "No label specified"))))
|
|
93 (setq rmail-last-multi-labels labels)
|
|
94 (rmail-new-summary (concat "labels " labels)
|
|
95 (list 'rmail-summary-by-labels labels)
|
|
96 'rmail-message-labels-p
|
101416
|
97 (concat " \\("
|
|
98 (mail-comma-list-regexp labels)
|
|
99 "\\)\\(,\\|\\'\\)")))
|
101360
|
100
|
102367
|
101 ;; FIXME "a string of regexps separated by commas" makes no sense because:
|
|
102 ;; i) it's pointless (you can just use \\|)
|
|
103 ;; ii) it's broken (you can't specify a literal comma)
|
|
104 ;; rmail-summary-by-topic and rmail-summary-by-senders have the same issue.
|
101360
|
105 ;;;###autoload
|
|
106 (defun rmail-summary-by-recipients (recipients &optional primary-only)
|
|
107 "Display a summary of all messages with the given RECIPIENTS.
|
|
108 Normally checks the To, From and Cc fields of headers;
|
|
109 but if PRIMARY-ONLY is non-nil (prefix arg given),
|
|
110 only look in the To and From fields.
|
|
111 RECIPIENTS is a string of regexps separated by commas."
|
|
112 (interactive "sRecipients to summarize by: \nP")
|
|
113 (rmail-new-summary
|
|
114 (concat "recipients " recipients)
|
|
115 (list 'rmail-summary-by-recipients recipients primary-only)
|
|
116 'rmail-message-recipients-p
|
|
117 (mail-comma-list-regexp recipients) primary-only))
|
|
118
|
|
119 (defun rmail-message-recipients-p (msg recipients &optional primary-only)
|
|
120 (rmail-apply-in-message msg 'rmail-message-recipients-p-1
|
|
121 recipients primary-only))
|
|
122
|
|
123 (defun rmail-message-recipients-p-1 (recipients &optional primary-only)
|
101594
|
124 ;; mail-fetch-field does not care where it starts from.
|
|
125 (narrow-to-region (point) (progn (search-forward "\n\n") (point)))
|
101360
|
126 (or (string-match recipients (or (mail-fetch-field "To") ""))
|
|
127 (string-match recipients (or (mail-fetch-field "From") ""))
|
|
128 (if (not primary-only)
|
|
129 (string-match recipients (or (mail-fetch-field "Cc") "")))))
|
|
130
|
102367
|
131 ;; FIXME I find this a non-obvious name for what this function does.
|
|
132 ;; Also, the optional WHOLE-MESSAGE argument of r-s-by-topic would
|
|
133 ;; seem more natural here.
|
101360
|
134 ;;;###autoload
|
|
135 (defun rmail-summary-by-regexp (regexp)
|
|
136 "Display a summary of all messages according to regexp REGEXP.
|
|
137 If the regular expression is found in the header of the message
|
|
138 \(including in the date and other lines, as well as the subject line),
|
102367
|
139 Emacs will list the message in the summary."
|
101360
|
140 (interactive "sRegexp to summarize by: ")
|
|
141 (if (string= regexp "")
|
|
142 (setq regexp (or rmail-last-regexp
|
|
143 (error "No regexp specified"))))
|
|
144 (setq rmail-last-regexp regexp)
|
|
145 (rmail-new-summary (concat "regexp " regexp)
|
|
146 (list 'rmail-summary-by-regexp regexp)
|
|
147 'rmail-message-regexp-p
|
|
148 regexp))
|
|
149
|
|
150 (defun rmail-message-regexp-p (msg regexp)
|
|
151 "Return t, if for message number MSG, regexp REGEXP matches in the header."
|
|
152 (rmail-apply-in-message msg 'rmail-message-regexp-p-1 msg regexp))
|
|
153
|
|
154 (defun rmail-message-regexp-p-1 (msg regexp)
|
101594
|
155 ;; Search functions can expect to start from the beginning.
|
101535
8b115b281787
(rmail-message-recipients-p-1, rmail-message-regexp-p-1): Avoid clobbering the mark.
Chong Yidong <cyd@stupidchicken.com>
diff
changeset
|
156 (narrow-to-region (point) (save-excursion (search-forward "\n\n") (point)))
|
101360
|
157 (if rmail-enable-mime
|
101537
|
158 (if rmail-search-mime-header-function
|
|
159 (funcall rmail-search-mime-header-function msg regexp (point))
|
|
160 (error "You must set `rmail-search-mime-header-function'"))
|
101360
|
161 (re-search-forward regexp nil t)))
|
|
162
|
|
163 ;;;###autoload
|
|
164 (defun rmail-summary-by-topic (subject &optional whole-message)
|
|
165 "Display a summary of all messages with the given SUBJECT.
|
102113
|
166 Normally checks just the Subject field of headers; but with prefix
|
|
167 argument WHOLE-MESSAGE is non-nil, looks in the whole message.
|
101360
|
168 SUBJECT is a string of regexps separated by commas."
|
|
169 (interactive
|
102113
|
170 ;; We quote the default subject, because if it contains regexp
|
|
171 ;; special characters (eg "?"), it can fail to match itself. (Bug#2333)
|
|
172 (let* ((subject (regexp-quote (rmail-simplified-subject)))
|
101360
|
173 (prompt (concat "Topics to summarize by (regexp"
|
|
174 (if subject ", default current subject" "")
|
|
175 "): ")))
|
|
176 (list (read-string prompt nil nil subject) current-prefix-arg)))
|
|
177 (rmail-new-summary
|
|
178 (concat "about " subject)
|
|
179 (list 'rmail-summary-by-topic subject whole-message)
|
|
180 'rmail-message-subject-p
|
|
181 (mail-comma-list-regexp subject) whole-message))
|
|
182
|
|
183 (defun rmail-message-subject-p (msg subject &optional whole-message)
|
|
184 (if whole-message
|
|
185 (rmail-apply-in-message msg 're-search-forward subject nil t)
|
|
186 (string-match subject (rmail-simplified-subject msg))))
|
|
187
|
|
188 ;;;###autoload
|
|
189 (defun rmail-summary-by-senders (senders)
|
102374
|
190 "Display a summary of all messages whose \"From\" field matches SENDERS.
|
|
191 SENDERS is a string of regexps separated by commas."
|
101360
|
192 (interactive "sSenders to summarize by: ")
|
|
193 (rmail-new-summary
|
|
194 (concat "senders " senders)
|
|
195 (list 'rmail-summary-by-senders senders)
|
|
196 'rmail-message-senders-p
|
|
197 (mail-comma-list-regexp senders)))
|
|
198
|
|
199 (defun rmail-message-senders-p (msg senders)
|
|
200 (string-match senders (or (rmail-get-header "From" msg) "")))
|
|
201
|
|
202 ;; General making of a summary buffer.
|
|
203
|
|
204 (defvar rmail-summary-symbol-number 0)
|
|
205
|
|
206 (defvar rmail-new-summary-line-count)
|
|
207
|
|
208 (defun rmail-new-summary (desc redo func &rest args)
|
|
209 "Create a summary of selected messages.
|
|
210 DESC makes part of the mode line of the summary buffer. REDO is form ...
|
|
211 For each message, FUNC is applied to the message number and ARGS...
|
|
212 and if the result is non-nil, that message is included.
|
|
213 nil for FUNCTION means all messages."
|
|
214 (message "Computing summary lines...")
|
|
215 (unless rmail-buffer
|
|
216 (error "No RMAIL buffer found"))
|
|
217 (let (mesg was-in-summary)
|
|
218 (if (eq major-mode 'rmail-summary-mode)
|
|
219 (setq was-in-summary t))
|
|
220 (with-current-buffer rmail-buffer
|
101701
|
221 (if (zerop (setq mesg rmail-current-message))
|
|
222 (error "No messages to summarize"))
|
|
223 (setq rmail-summary-buffer (rmail-new-summary-1 desc redo func args)))
|
101360
|
224 ;; Now display the summary buffer and go to the right place in it.
|
|
225 (unless was-in-summary
|
|
226 (if (and (one-window-p)
|
|
227 pop-up-windows
|
|
228 (not pop-up-frames))
|
|
229 ;; If there is just one window, put the summary on the top.
|
|
230 (progn
|
|
231 (split-window (selected-window) rmail-summary-window-size)
|
|
232 (select-window (next-window (frame-first-window)))
|
|
233 (pop-to-buffer rmail-summary-buffer)
|
|
234 ;; If pop-to-buffer did not use that window, delete that
|
|
235 ;; window. (This can happen if it uses another frame.)
|
|
236 (if (not (eq rmail-summary-buffer
|
|
237 (window-buffer (frame-first-window))))
|
|
238 (delete-other-windows)))
|
|
239 (pop-to-buffer rmail-summary-buffer))
|
|
240 (set-buffer rmail-buffer)
|
|
241 ;; This is how rmail makes the summary buffer reappear.
|
|
242 ;; We do this here to make the window the proper size.
|
|
243 (rmail-select-summary nil)
|
|
244 (set-buffer rmail-summary-buffer))
|
|
245 (rmail-summary-goto-msg mesg t t)
|
|
246 (rmail-summary-construct-io-menu)
|
|
247 (message "Computing summary lines...done")))
|
|
248
|
|
249 (defun rmail-new-summary-1 (description form function args)
|
|
250 "Filter messages to obtain summary lines.
|
|
251 DESCRIPTION is added to the mode line.
|
|
252
|
|
253 Return the summary buffer by invoking FUNCTION on each message
|
|
254 passing the message number and ARGS...
|
|
255
|
|
256 REDO is a form ...
|
|
257
|
|
258 The current buffer must be a Rmail buffer either containing a
|
|
259 collection of mbox formatted messages or displaying a single
|
|
260 message."
|
|
261 (let ((summary-msgs ())
|
|
262 (rmail-new-summary-line-count 0)
|
|
263 (sumbuf (rmail-get-create-summary-buffer)))
|
|
264 ;; Scan the messages, getting their summary strings
|
|
265 ;; and putting the list of them in SUMMARY-MSGS.
|
|
266 (let ((msgnum 1)
|
|
267 (main-buffer (current-buffer))
|
|
268 (total rmail-total-messages)
|
|
269 (inhibit-read-only t))
|
|
270 (save-excursion
|
|
271 ;; Go where the mbox text is.
|
|
272 (if (rmail-buffers-swapped-p)
|
|
273 (set-buffer rmail-view-buffer))
|
|
274 (let ((old-min (point-min-marker))
|
|
275 (old-max (point-max-marker)))
|
|
276 (unwind-protect
|
|
277 ;; Can't use save-restriction here; that doesn't work if we
|
|
278 ;; plan to modify text outside the original restriction.
|
|
279 (save-excursion
|
|
280 (widen)
|
|
281 (goto-char (point-min))
|
|
282 (while (>= total msgnum)
|
|
283 ;; Go back to the Rmail buffer so
|
|
284 ;; so FUNCTION and rmail-get-summary can see its local vars.
|
|
285 (with-current-buffer main-buffer
|
|
286 ;; First test whether to include this message.
|
|
287 (if (or (null function)
|
|
288 (apply function msgnum args))
|
|
289 (setq summary-msgs
|
|
290 (cons (cons msgnum (rmail-get-summary msgnum))
|
|
291 summary-msgs))))
|
|
292 (setq msgnum (1+ msgnum))
|
|
293 ;; Provide a periodic User progress message.
|
|
294 (if (zerop (% rmail-new-summary-line-count 10))
|
|
295 (message "Computing summary lines...%d"
|
|
296 rmail-new-summary-line-count)))
|
|
297 (setq summary-msgs (nreverse summary-msgs)))
|
|
298 (narrow-to-region old-min old-max)))))
|
|
299 ;; Temporarily, while summary buffer is unfinished,
|
|
300 ;; we "don't have" a summary.
|
102113
|
301 (setq rmail-summary-buffer nil)
|
|
302 (unless summary-msgs
|
|
303 (kill-buffer sumbuf)
|
|
304 (error "Nothing to summarize"))
|
101360
|
305 ;; I have not a clue what this clause is doing. If you read this
|
|
306 ;; chunk of code and have a clue, then please email that clue to
|
|
307 ;; pmr@pajato.com
|
|
308 (if rmail-enable-mime
|
|
309 (with-current-buffer rmail-buffer
|
|
310 (setq rmail-summary-buffer nil)))
|
|
311 (save-excursion
|
|
312 (let ((rbuf (current-buffer))
|
|
313 (total rmail-total-messages))
|
|
314 (set-buffer sumbuf)
|
|
315 ;; Set up the summary buffer's contents.
|
|
316 (let ((buffer-read-only nil))
|
|
317 (erase-buffer)
|
|
318 (while summary-msgs
|
|
319 (princ (cdr (car summary-msgs)) sumbuf)
|
|
320 (setq summary-msgs (cdr summary-msgs)))
|
|
321 (goto-char (point-min)))
|
|
322 ;; Set up the rest of its state and local variables.
|
|
323 (setq buffer-read-only t)
|
|
324 (rmail-summary-mode)
|
|
325 (make-local-variable 'minor-mode-alist)
|
|
326 (setq minor-mode-alist (list (list t (concat ": " description))))
|
|
327 (setq rmail-buffer rbuf
|
|
328 rmail-summary-redo form
|
|
329 rmail-total-messages total)))
|
|
330 sumbuf))
|
|
331
|
|
332 (defun rmail-get-create-summary-buffer ()
|
102386
|
333 "Return the Rmail summary buffer.
|
|
334 If necessary, it is created and undo is disabled."
|
101360
|
335 (if (and rmail-summary-buffer (buffer-name rmail-summary-buffer))
|
|
336 rmail-summary-buffer
|
102386
|
337 (let ((buff (generate-new-buffer (concat (buffer-name) "-summary"))))
|
|
338 (with-current-buffer buff
|
|
339 (setq buffer-undo-list t))
|
|
340 buff)))
|
101537
|
341
|
101360
|
342
|
|
343 ;; Low levels of generating a summary.
|
|
344
|
|
345 (defun rmail-get-summary (msgnum)
|
|
346 "Return the summary line for message MSGNUM.
|
|
347 The mbox buffer must be current when you call this function
|
|
348 even if its text is swapped.
|
|
349
|
|
350 If the message has a summary line already, it will be stored in
|
|
351 the message as a header and simply returned, otherwise the
|
|
352 summary line is created, saved in the message header, cached and
|
|
353 returned.
|
|
354
|
|
355 The current buffer contains the unrestricted message collection."
|
|
356 (let ((line (aref rmail-summary-vector (1- msgnum))))
|
|
357 (unless line
|
|
358 ;; Register a summary line for MSGNUM.
|
|
359 (setq rmail-new-summary-line-count (1+ rmail-new-summary-line-count)
|
|
360 line (rmail-create-summary-line msgnum))
|
|
361 ;; Cache the summary line for use during this Rmail session.
|
|
362 (aset rmail-summary-vector (1- msgnum) line))
|
|
363 line))
|
|
364
|
|
365 (defcustom rmail-summary-line-decoder (function identity)
|
101537
|
366 "Function to decode a Rmail summary line.
|
101360
|
367 It receives the summary line for one message as a string
|
|
368 and should return the decoded string.
|
|
369
|
|
370 By default, it is `identity', which returns the string unaltered."
|
|
371 :type 'function
|
|
372 :group 'rmail-summary)
|
|
373
|
|
374 (defun rmail-create-summary-line (msgnum)
|
|
375 "Return the summary line for message MSGNUM.
|
|
376 Obtain the message summary from the header if it is available
|
|
377 otherwise create it and store it in the message header.
|
|
378
|
|
379 The mbox buffer must be current when you call this function
|
|
380 even if its text is swapped."
|
|
381 (let ((beg (rmail-msgbeg msgnum))
|
|
382 (end (rmail-msgend msgnum))
|
|
383 (deleted (rmail-message-deleted-p msgnum))
|
101594
|
384 ;; Does not work (swapped?)
|
|
385 ;;; (unseen (rmail-message-unseen-p msgnum))
|
|
386 unseen lines)
|
101360
|
387 (save-excursion
|
|
388 ;; Switch to the buffer that has the whole mbox text.
|
|
389 (if (rmail-buffers-swapped-p)
|
|
390 (set-buffer rmail-view-buffer))
|
|
391 ;; Now we can compute the line count.
|
|
392 (if rmail-summary-line-count-flag
|
|
393 (setq lines (count-lines beg end)))
|
|
394 ;; Narrow to the message header.
|
|
395 (save-excursion
|
101841
|
396 (save-restriction
|
|
397 (widen)
|
|
398 (goto-char beg)
|
|
399 (if (search-forward "\n\n" end t)
|
|
400 (progn
|
|
401 (narrow-to-region beg (point))
|
|
402 ;; Replace rmail-message-unseen-p from above.
|
|
403 (goto-char beg)
|
|
404 (setq unseen (and (search-forward
|
|
405 (concat rmail-attribute-header ": ") nil t)
|
|
406 (looking-at "......U")))
|
|
407 ;; Generate a status line from the message.
|
|
408 (rmail-create-summary msgnum deleted unseen lines))
|
|
409 (rmail-error-bad-format msgnum)))))))
|
101360
|
410
|
101594
|
411 ;; FIXME this is now unused.
|
|
412 ;; The intention was to display in the summary something like {E}
|
|
413 ;; for an edited messaged, similarly for answered, etc.
|
|
414 ;; But that conflicts with the previous rmail usage, where
|
|
415 ;; any user-defined { labels } occupied this space.
|
|
416 ;; So whilst it would be nice to have this information in the summary,
|
|
417 ;; it would need to go somewhere else.
|
|
418 (defun rmail-get-summary-status ()
|
|
419 "Return a coded string wrapped in curly braces denoting the status.
|
101360
|
420
|
|
421 The current buffer must already be narrowed to the message headers for
|
|
422 the message being processed."
|
|
423 (let ((status (mail-fetch-field rmail-attribute-header))
|
|
424 (index 0)
|
|
425 (result "")
|
|
426 char)
|
|
427 ;; Strip off the read/unread and the deleted attribute which are
|
|
428 ;; handled separately.
|
|
429 (setq status
|
|
430 (if status
|
|
431 (concat (substring status 0 1) (substring status 2 6))
|
|
432 ""))
|
|
433 (while (< index (length status))
|
|
434 (unless (string= "-" (setq char (substring status index (1+ index))))
|
|
435 (setq result (concat result char)))
|
|
436 (setq index (1+ index)))
|
|
437 (when (> (length result) 0)
|
|
438 (setq result (concat "{" result "}")))
|
|
439 result))
|
|
440
|
101950
|
441 (autoload 'rmail-make-label "rmailkwd")
|
|
442
|
101594
|
443 (defun rmail-get-summary-labels ()
|
|
444 "Return a string wrapped in curly braces with the current message labels.
|
|
445 Returns nil if there are no labels. The current buffer must
|
|
446 already be narrowed to the message headers for the message being
|
|
447 processed."
|
|
448 (let ((labels (mail-fetch-field rmail-keyword-header)))
|
101767
|
449 (and labels
|
|
450 (not (string-equal labels ""))
|
101950
|
451 (progn
|
|
452 ;; Intern so that rmail-read-label can offer completion.
|
|
453 (mapc 'rmail-make-label (split-string labels ", "))
|
|
454 (format "{ %s } " labels)))))
|
101594
|
455
|
101360
|
456 (defun rmail-create-summary (msgnum deleted unseen lines)
|
|
457 "Return the summary line for message MSGNUM.
|
|
458 The current buffer should already be narrowed to the header for that message.
|
|
459 It could be either buffer, so don't access Rmail local variables.
|
|
460 DELETED is t if this message is marked deleted.
|
|
461 UNSEEN is t if it is marked unseen.
|
|
462 LINES is the number of lines in the message (if we should display that)
|
|
463 or else nil."
|
|
464 (goto-char (point-min))
|
|
465 (let ((line (rmail-header-summary))
|
|
466 (labels (rmail-get-summary-labels))
|
|
467 pos status prefix basic-start basic-end linecount-string)
|
|
468
|
|
469 (setq linecount-string
|
|
470 (cond
|
|
471 ((not lines) " ")
|
|
472 ((<= lines 9) (format " [%d]" lines))
|
|
473 ((<= lines 99) (format " [%d]" lines))
|
|
474 ((<= lines 999) (format " [%d]" lines))
|
|
475 ((<= lines 9999) (format " [%dk]" (/ lines 1000)))
|
|
476 ((<= lines 99999) (format " [%dk]" (/ lines 1000)))
|
|
477 (t (format "[%dk]" (/ lines 1000)))))
|
|
478
|
|
479 (setq status (cond
|
|
480 (deleted ?D)
|
|
481 (unseen ?-)
|
|
482 (t ? ))
|
101594
|
483 prefix (format "%5d%c " msgnum status)
|
101360
|
484 basic-start (car line)
|
|
485 basic-end (cadr line))
|
|
486 (funcall rmail-summary-line-decoder
|
|
487 (concat prefix basic-start linecount-string " "
|
|
488 labels basic-end))))
|
|
489
|
101537
|
490 ;; FIXME move to rmail.el?
|
101360
|
491 ;;;###autoload
|
|
492 (defcustom rmail-user-mail-address-regexp nil
|
101537
|
493 "Regexp matching user mail addresses.
|
101360
|
494 If non-nil, this variable is used to identify the correspondent
|
|
495 when receiving new mail. If it matches the address of the sender,
|
|
496 the recipient is taken as correspondent of a mail.
|
|
497 If nil \(default value\), your `user-login-name' and `user-mail-address'
|
|
498 are used to exclude yourself as correspondent.
|
|
499
|
|
500 Usually you don't have to set this variable, except if you collect mails
|
|
501 sent by you under different user names.
|
|
502 Then it should be a regexp matching your mail addresses.
|
|
503
|
|
504 Setting this variable has an effect only before reading a mail."
|
|
505 :type '(choice (const :tag "None" nil) regexp)
|
|
506 :group 'rmail-retrieve
|
|
507 :version "21.1")
|
|
508
|
|
509 (defun rmail-header-summary ()
|
|
510 "Return a message summary based on the message headers.
|
|
511 The value is a list of two strings, the first and second parts of the summary.
|
|
512
|
|
513 The current buffer must already be narrowed to the message headers for
|
|
514 the message being processed."
|
|
515 (goto-char (point-min))
|
|
516 (list
|
|
517 (concat (save-excursion
|
|
518 (if (not (re-search-forward "^Date:" nil t))
|
|
519 " "
|
|
520 (cond ((re-search-forward "\\([^0-9:]\\)\\([0-3]?[0-9]\\)\\([- \t_]+\\)\\([adfjmnos][aceopu][bcglnprtvy]\\)"
|
101666
|
521 (line-end-position) t)
|
101360
|
522 (format "%2d-%3s"
|
|
523 (string-to-number (buffer-substring
|
|
524 (match-beginning 2)
|
|
525 (match-end 2)))
|
|
526 (buffer-substring
|
|
527 (match-beginning 4) (match-end 4))))
|
|
528 ((re-search-forward "\\([^a-z]\\)\\([adfjmnos][acepou][bcglnprtvy]\\)\\([-a-z \t_]*\\)\\([0-9][0-9]?\\)"
|
101666
|
529 (line-end-position) t)
|
101360
|
530 (format "%2d-%3s"
|
|
531 (string-to-number (buffer-substring
|
|
532 (match-beginning 4)
|
|
533 (match-end 4)))
|
|
534 (buffer-substring
|
|
535 (match-beginning 2) (match-end 2))))
|
|
536 ((re-search-forward "\\(19\\|20\\)\\([0-9][0-9]\\)-\\([01][0-9]\\)-\\([0-3][0-9]\\)"
|
101666
|
537 (line-end-position) t)
|
101360
|
538 (format "%2s%2s%2s"
|
|
539 (buffer-substring
|
|
540 (match-beginning 2) (match-end 2))
|
|
541 (buffer-substring
|
|
542 (match-beginning 3) (match-end 3))
|
|
543 (buffer-substring
|
|
544 (match-beginning 4) (match-end 4))))
|
|
545 (t "??????"))))
|
|
546 " "
|
|
547 (save-excursion
|
|
548 (let* ((from (and (re-search-forward "^From:[ \t]*" nil t)
|
|
549 (mail-strip-quoted-names
|
|
550 (buffer-substring
|
|
551 (1- (point))
|
|
552 ;; Get all the lines of the From field
|
|
553 ;; so that we get a whole comment if there is one,
|
|
554 ;; so that mail-strip-quoted-names can discard it.
|
|
555 (let ((opoint (point)))
|
|
556 (while (progn (forward-line 1)
|
|
557 (looking-at "[ \t]")))
|
|
558 ;; Back up over newline, then trailing spaces or tabs
|
|
559 (forward-char -1)
|
|
560 (skip-chars-backward " \t")
|
|
561 (point))))))
|
|
562 len mch lo)
|
|
563 (if (or (null from)
|
|
564 (string-match
|
|
565 (or rmail-user-mail-address-regexp
|
|
566 (concat "^\\("
|
|
567 (regexp-quote (user-login-name))
|
|
568 "\\($\\|@\\)\\|"
|
|
569 (regexp-quote
|
|
570 ;; Don't lose if run from init file
|
|
571 ;; where user-mail-address is not
|
|
572 ;; set yet.
|
|
573 (or user-mail-address
|
|
574 (concat (user-login-name) "@"
|
|
575 (or mail-host-address
|
|
576 (system-name)))))
|
|
577 "\\>\\)"))
|
|
578 from))
|
|
579 ;; No From field, or it's this user.
|
|
580 (save-excursion
|
|
581 (goto-char (point-min))
|
|
582 (if (not (re-search-forward "^To:[ \t]*" nil t))
|
|
583 nil
|
|
584 (setq from
|
|
585 (concat "to: "
|
|
586 (mail-strip-quoted-names
|
|
587 (buffer-substring
|
|
588 (point)
|
|
589 (progn (end-of-line)
|
|
590 (skip-chars-backward " \t")
|
|
591 (point)))))))))
|
|
592 (if (null from)
|
|
593 " "
|
|
594 (setq len (length from))
|
|
595 (setq mch (string-match "[@%]" from))
|
|
596 (format "%25s"
|
|
597 (if (or (not mch) (<= len 25))
|
|
598 (substring from (max 0 (- len 25)))
|
|
599 (substring from
|
|
600 (setq lo (cond ((< (- mch 14) 0) 0)
|
|
601 ((< len (+ mch 11))
|
|
602 (- len 25))
|
|
603 (t (- mch 14))))
|
|
604 (min len (+ lo 25)))))))))
|
|
605 (concat (if (re-search-forward "^Subject:" nil t)
|
|
606 (progn (skip-chars-forward " \t")
|
|
607 (buffer-substring (point)
|
|
608 (progn (end-of-line)
|
|
609 (point))))
|
|
610 (re-search-forward "[\n][\n]+" nil t)
|
|
611 (buffer-substring (point) (progn (end-of-line) (point))))
|
|
612 "\n")))
|
|
613
|
|
614 ;; Simple motion in a summary buffer.
|
|
615
|
|
616 (defun rmail-summary-next-all (&optional number)
|
|
617 (interactive "p")
|
|
618 (forward-line (if number number 1))
|
|
619 ;; It doesn't look nice to move forward past the last message line.
|
|
620 (and (eobp) (> number 0)
|
|
621 (forward-line -1))
|
|
622 (display-buffer rmail-buffer))
|
|
623
|
|
624 (defun rmail-summary-previous-all (&optional number)
|
|
625 (interactive "p")
|
|
626 (forward-line (- (if number number 1)))
|
|
627 ;; It doesn't look nice to move forward past the last message line.
|
|
628 (and (eobp) (< number 0)
|
|
629 (forward-line -1))
|
|
630 (display-buffer rmail-buffer))
|
|
631
|
|
632 (defun rmail-summary-next-msg (&optional number)
|
|
633 "Display next non-deleted msg from rmail file.
|
|
634 With optional prefix argument NUMBER, moves forward this number of non-deleted
|
|
635 messages, or backward if NUMBER is negative."
|
|
636 (interactive "p")
|
|
637 (forward-line 0)
|
|
638 (and (> number 0) (end-of-line))
|
|
639 (let ((count (if (< number 0) (- number) number))
|
|
640 (search (if (> number 0) 're-search-forward 're-search-backward))
|
|
641 (non-del-msg-found nil))
|
|
642 (while (and (> count 0) (setq non-del-msg-found
|
|
643 (or (funcall search "^.....[^D]" nil t)
|
|
644 non-del-msg-found)))
|
|
645 (setq count (1- count))))
|
|
646 (beginning-of-line)
|
|
647 (display-buffer rmail-buffer))
|
|
648
|
|
649 (defun rmail-summary-previous-msg (&optional number)
|
|
650 "Display previous non-deleted msg from rmail file.
|
|
651 With optional prefix argument NUMBER, moves backward this number of
|
|
652 non-deleted messages."
|
|
653 (interactive "p")
|
|
654 (rmail-summary-next-msg (- (if number number 1))))
|
|
655
|
|
656 (defun rmail-summary-next-labeled-message (n labels)
|
|
657 "Show next message with LABELS. Defaults to last labels used.
|
|
658 With prefix argument N moves forward N messages with these labels."
|
|
659 (interactive "p\nsMove to next msg with labels: ")
|
|
660 (let (msg)
|
|
661 (save-excursion
|
|
662 (set-buffer rmail-buffer)
|
|
663 (rmail-next-labeled-message n labels)
|
|
664 (setq msg rmail-current-message))
|
|
665 (rmail-summary-goto-msg msg)))
|
|
666
|
|
667 (defun rmail-summary-previous-labeled-message (n labels)
|
|
668 "Show previous message with LABELS. Defaults to last labels used.
|
|
669 With prefix argument N moves backward N messages with these labels."
|
|
670 (interactive "p\nsMove to previous msg with labels: ")
|
|
671 (let (msg)
|
|
672 (save-excursion
|
|
673 (set-buffer rmail-buffer)
|
|
674 (rmail-previous-labeled-message n labels)
|
|
675 (setq msg rmail-current-message))
|
|
676 (rmail-summary-goto-msg msg)))
|
|
677
|
|
678 (defun rmail-summary-next-same-subject (n)
|
|
679 "Go to the next message in the summary having the same subject.
|
|
680 With prefix argument N, do this N times.
|
|
681 If N is negative, go backwards."
|
|
682 (interactive "p")
|
|
683 (let ((forward (> n 0))
|
|
684 subject i found)
|
|
685 (with-current-buffer rmail-buffer
|
|
686 (setq subject (rmail-simplified-subject)
|
|
687 i rmail-current-message))
|
|
688 (save-excursion
|
|
689 (while (and (/= n 0)
|
|
690 (if forward
|
|
691 (not (eobp))
|
|
692 (not (bobp))))
|
|
693 (let (done)
|
|
694 (while (and (not done)
|
|
695 (if forward
|
|
696 (not (eobp))
|
|
697 (not (bobp))))
|
|
698 ;; Advance thru summary.
|
|
699 (forward-line (if forward 1 -1))
|
|
700 ;; Get msg number of this line.
|
|
701 (setq i (string-to-number
|
|
702 (buffer-substring (point)
|
|
703 (min (point-max) (+ 6 (point))))))
|
|
704 (setq done (string-equal subject (rmail-simplified-subject i))))
|
|
705 (if done (setq found i)))
|
|
706 (setq n (if forward (1- n) (1+ n)))))
|
|
707 (if found
|
|
708 (rmail-summary-goto-msg found)
|
|
709 (error "No %s message with same subject"
|
|
710 (if forward "following" "previous")))))
|
|
711
|
|
712 (defun rmail-summary-previous-same-subject (n)
|
|
713 "Go to the previous message in the summary having the same subject.
|
|
714 With prefix argument N, do this N times.
|
|
715 If N is negative, go forwards instead."
|
|
716 (interactive "p")
|
|
717 (rmail-summary-next-same-subject (- n)))
|
|
718
|
|
719 ;; Delete and undelete summary commands.
|
|
720
|
|
721 (defun rmail-summary-delete-forward (&optional count)
|
|
722 "Delete this message and move to next nondeleted one.
|
|
723 Deleted messages stay in the file until the \\[rmail-expunge] command is given.
|
|
724 A prefix argument serves as a repeat count;
|
|
725 a negative argument means to delete and move backward."
|
|
726 (interactive "p")
|
|
727 (unless (numberp count) (setq count 1))
|
|
728 (let (end del-msg
|
|
729 (backward (< count 0)))
|
|
730 (while (/= count 0)
|
|
731 (rmail-summary-goto-msg)
|
|
732 (with-current-buffer rmail-buffer
|
|
733 (rmail-delete-message)
|
|
734 (setq del-msg rmail-current-message))
|
|
735 (rmail-summary-mark-deleted del-msg)
|
|
736 (while (and (not (if backward (bobp) (eobp)))
|
|
737 (save-excursion (beginning-of-line)
|
|
738 (looking-at " *[0-9]+D")))
|
|
739 (forward-line (if backward -1 1)))
|
|
740 ;; It looks ugly to move to the empty line at end of buffer.
|
|
741 (and (eobp) (not backward)
|
|
742 (forward-line -1))
|
|
743 (setq count
|
|
744 (if (> count 0) (1- count) (1+ count))))))
|
|
745
|
|
746 (defun rmail-summary-delete-backward (&optional count)
|
|
747 "Delete this message and move to previous nondeleted one.
|
|
748 Deleted messages stay in the file until the \\[rmail-expunge] command is given.
|
|
749 A prefix argument serves as a repeat count;
|
|
750 a negative argument means to delete and move forward."
|
|
751 (interactive "p")
|
|
752 (rmail-summary-delete-forward (- count)))
|
|
753
|
|
754 (defun rmail-summary-mark-deleted (&optional n undel)
|
|
755 ;; Since third arg is t, this only alters the summary, not the Rmail buf.
|
|
756 (and n (rmail-summary-goto-msg n t t))
|
|
757 (or (eobp)
|
|
758 (not (overlay-get rmail-summary-overlay 'face))
|
|
759 (let ((buffer-read-only nil))
|
|
760 (skip-chars-forward " ")
|
101990
|
761 (skip-chars-forward "0-9")
|
101360
|
762 (if undel
|
|
763 (if (looking-at "D")
|
|
764 (progn (delete-char 1) (insert " ")))
|
|
765 (delete-char 1)
|
101533
|
766 (insert "D"))
|
|
767 ;; Register a new summary line.
|
|
768 (with-current-buffer rmail-buffer
|
|
769 (aset rmail-summary-vector (1- n) (rmail-create-summary-line n)))))
|
101360
|
770 (beginning-of-line))
|
|
771
|
101630
|
772 (defun rmail-summary-update-line (n)
|
|
773 "Update the summary line for message N."
|
|
774 (when (rmail-summary-goto-msg n t t)
|
|
775 (let* ((buffer-read-only nil)
|
|
776 (start (line-beginning-position))
|
|
777 (end (line-beginning-position 2))
|
|
778 (overlays (overlays-in start end))
|
|
779 high ov)
|
|
780 (while (and (setq ov (car overlays))
|
|
781 (not (setq high (overlay-get ov 'rmail-summary))))
|
|
782 (setq overlays (cdr overlays)))
|
101662
e18d6fe1381d
(rmail-summary-update-line): Replace duplicate line-beginning-position calls.
Glenn Morris <rgm@gnu.org>
diff
changeset
|
783 (delete-region start end)
|
101630
|
784 (princ
|
|
785 (with-current-buffer rmail-buffer
|
|
786 (aset rmail-summary-vector (1- n) (rmail-create-summary-line n)))
|
|
787 (current-buffer))
|
|
788 (when high
|
|
789 (forward-line -1)
|
|
790 (rmail-summary-update-highlight nil)))))
|
|
791
|
101360
|
792 (defun rmail-summary-mark-undeleted (n)
|
|
793 (rmail-summary-mark-deleted n t))
|
|
794
|
|
795 (defun rmail-summary-deleted-p (&optional n)
|
|
796 (save-excursion
|
|
797 (and n (rmail-summary-goto-msg n nil t))
|
|
798 (skip-chars-forward " ")
|
101990
|
799 (skip-chars-forward "0-9")
|
101360
|
800 (looking-at "D")))
|
|
801
|
|
802 (defun rmail-summary-undelete (&optional arg)
|
|
803 "Undelete current message.
|
|
804 Optional prefix ARG means undelete ARG previous messages."
|
|
805 (interactive "p")
|
|
806 (if (/= arg 1)
|
|
807 (rmail-summary-undelete-many arg)
|
|
808 (let ((buffer-read-only nil)
|
|
809 (opoint (point)))
|
|
810 (end-of-line)
|
|
811 (cond ((re-search-backward "\\(^ *[0-9]*\\)\\(D\\)" nil t)
|
|
812 (replace-match "\\1 ")
|
|
813 (rmail-summary-goto-msg)
|
|
814 (if rmail-enable-mime
|
|
815 (set-buffer rmail-buffer)
|
|
816 (pop-to-buffer rmail-buffer))
|
|
817 (and (rmail-message-deleted-p rmail-current-message)
|
|
818 (rmail-undelete-previous-message))
|
|
819 (if rmail-enable-mime
|
|
820 (pop-to-buffer rmail-buffer))
|
|
821 (pop-to-buffer rmail-summary-buffer))
|
|
822 (t (goto-char opoint))))))
|
|
823
|
|
824 (defun rmail-summary-undelete-many (&optional n)
|
|
825 "Undelete all deleted msgs, optional prefix arg N means undelete N prev msgs."
|
|
826 (interactive "P")
|
|
827 (save-excursion
|
|
828 (set-buffer rmail-buffer)
|
|
829 (let* ((init-msg (if n rmail-current-message rmail-total-messages))
|
|
830 (rmail-current-message init-msg)
|
|
831 (n (or n rmail-total-messages))
|
|
832 (msgs-undeled 0))
|
|
833 (while (and (> rmail-current-message 0)
|
|
834 (< msgs-undeled n))
|
|
835 (if (rmail-message-deleted-p rmail-current-message)
|
101841
|
836 (progn (rmail-set-attribute rmail-deleted-attr-index nil)
|
101360
|
837 (setq msgs-undeled (1+ msgs-undeled))))
|
|
838 (setq rmail-current-message (1- rmail-current-message)))
|
|
839 (set-buffer rmail-summary-buffer)
|
|
840 (setq rmail-current-message init-msg msgs-undeled 0)
|
|
841 (while (and (> rmail-current-message 0)
|
|
842 (< msgs-undeled n))
|
|
843 (if (rmail-summary-deleted-p rmail-current-message)
|
|
844 (progn (rmail-summary-mark-undeleted rmail-current-message)
|
|
845 (setq msgs-undeled (1+ msgs-undeled))))
|
|
846 (setq rmail-current-message (1- rmail-current-message))))
|
|
847 (rmail-summary-goto-msg)))
|
|
848
|
|
849 ;; Rmail Summary mode is suitable only for specially formatted data.
|
|
850 (put 'rmail-summary-mode 'mode-class 'special)
|
|
851
|
|
852 (defun rmail-summary-mode ()
|
|
853 "Rmail Summary Mode is invoked from Rmail Mode by using \\<rmail-mode-map>\\[rmail-summary].
|
|
854 As commands are issued in the summary buffer, they are applied to the
|
|
855 corresponding mail messages in the rmail buffer.
|
|
856
|
|
857 All normal editing commands are turned off.
|
|
858 Instead, nearly all the Rmail mode commands are available,
|
|
859 though many of them move only among the messages in the summary.
|
|
860
|
|
861 These additional commands exist:
|
|
862
|
|
863 \\[rmail-summary-undelete-many] Undelete all or prefix arg deleted messages.
|
|
864 \\[rmail-summary-wipe] Delete the summary and go to the Rmail buffer.
|
|
865
|
|
866 Commands for sorting the summary:
|
|
867
|
|
868 \\[rmail-summary-sort-by-date] Sort by date.
|
|
869 \\[rmail-summary-sort-by-subject] Sort by subject.
|
|
870 \\[rmail-summary-sort-by-author] Sort by author.
|
|
871 \\[rmail-summary-sort-by-recipient] Sort by recipient.
|
|
872 \\[rmail-summary-sort-by-correspondent] Sort by correspondent.
|
|
873 \\[rmail-summary-sort-by-lines] Sort by lines.
|
|
874 \\[rmail-summary-sort-by-labels] Sort by labels."
|
|
875 (interactive)
|
|
876 (kill-all-local-variables)
|
|
877 (setq major-mode 'rmail-summary-mode)
|
|
878 (setq mode-name "RMAIL Summary")
|
|
879 (setq truncate-lines t)
|
|
880 (setq buffer-read-only t)
|
|
881 (set-syntax-table text-mode-syntax-table)
|
|
882 (make-local-variable 'rmail-buffer)
|
|
883 (make-local-variable 'rmail-total-messages)
|
|
884 (make-local-variable 'rmail-current-message)
|
|
885 (setq rmail-current-message nil)
|
|
886 (make-local-variable 'rmail-summary-redo)
|
|
887 (setq rmail-summary-redo nil)
|
|
888 (make-local-variable 'revert-buffer-function)
|
|
889 (make-local-variable 'font-lock-defaults)
|
|
890 (setq font-lock-defaults '(rmail-summary-font-lock-keywords t))
|
|
891 (rmail-summary-enable)
|
|
892 (run-mode-hooks 'rmail-summary-mode-hook))
|
|
893
|
|
894 ;; Summary features need to be disabled during edit mode.
|
|
895 (defun rmail-summary-disable ()
|
|
896 (use-local-map text-mode-map)
|
|
897 (remove-hook 'post-command-hook 'rmail-summary-rmail-update t)
|
|
898 (setq revert-buffer-function nil))
|
|
899
|
|
900 (defun rmail-summary-enable ()
|
|
901 (use-local-map rmail-summary-mode-map)
|
|
902 (add-hook 'post-command-hook 'rmail-summary-rmail-update nil t)
|
|
903 (setq revert-buffer-function 'rmail-update-summary))
|
|
904
|
102282
|
905 (defun rmail-summary-mark-seen (n &optional nomove unseen)
|
101990
|
906 "Remove the unseen mark from the current message, update the summary vector.
|
|
907 N is the number of the current message. Optional argument NOMOVE
|
102282
|
908 non-nil means we are already at the right column. Optional argument
|
|
909 UNSEEN non-nil means mark the message as unseen."
|
101990
|
910 (save-excursion
|
|
911 (unless nomove
|
|
912 (beginning-of-line)
|
|
913 (skip-chars-forward " ")
|
|
914 (skip-chars-forward "0-9"))
|
102282
|
915 (when (char-equal (following-char) (if unseen ?\s ?-))
|
101990
|
916 (let ((buffer-read-only nil))
|
|
917 (delete-char 1)
|
102282
|
918 (insert (if unseen "-" " ")))
|
101990
|
919 (let ((line (buffer-substring-no-properties (line-beginning-position)
|
|
920 (line-beginning-position 2))))
|
|
921 (with-current-buffer rmail-buffer
|
|
922 (aset rmail-summary-vector (1- n) line))))))
|
|
923
|
101360
|
924 (defvar rmail-summary-put-back-unseen nil
|
|
925 "Used for communicating between calls to `rmail-summary-rmail-update'.
|
|
926 If it moves to a message within an Incremental Search, and removes
|
|
927 the `unseen' attribute from that message, it sets this flag
|
|
928 so that if the next motion between messages is in the same Incremental
|
|
929 Search, the `unseen' attribute is restored.")
|
|
930
|
|
931 ;; Show in Rmail the message described by the summary line that point is on,
|
|
932 ;; but only if the Rmail buffer is already visible.
|
|
933 ;; This is a post-command-hook in summary buffers.
|
|
934 (defun rmail-summary-rmail-update ()
|
|
935 (let (buffer-read-only)
|
|
936 (save-excursion
|
|
937 ;; If at end of buffer, pretend we are on the last text line.
|
|
938 (if (eobp)
|
|
939 (forward-line -1))
|
|
940 (beginning-of-line)
|
|
941 (skip-chars-forward " ")
|
|
942 (let ((msg-num (string-to-number (buffer-substring
|
|
943 (point)
|
|
944 (progn (skip-chars-forward "0-9")
|
|
945 (point))))))
|
|
946 ;; Always leave `unseen' removed
|
|
947 ;; if we get out of isearch mode.
|
|
948 ;; Don't let a subsequent isearch restore that `unseen'.
|
|
949 (if (not isearch-mode)
|
|
950 (setq rmail-summary-put-back-unseen nil))
|
|
951
|
|
952 (or (eq rmail-current-message msg-num)
|
|
953 (let ((window (get-buffer-window rmail-buffer t))
|
|
954 (owin (selected-window)))
|
|
955 (if isearch-mode
|
102282
|
956 (progn
|
101360
|
957 ;; If we first saw the previous message in this search,
|
|
958 ;; and we have gone to a different message while searching,
|
|
959 ;; put back `unseen' on the former one.
|
102282
|
960 (when rmail-summary-put-back-unseen
|
|
961 (rmail-set-attribute rmail-unseen-attr-index t
|
|
962 rmail-current-message)
|
|
963 (save-excursion
|
|
964 (goto-char rmail-summary-put-back-unseen)
|
|
965 (rmail-summary-mark-seen rmail-current-message t t)))
|
101360
|
966 ;; Arrange to do that later, for the new current message,
|
|
967 ;; if it still has `unseen'.
|
|
968 (setq rmail-summary-put-back-unseen
|
102282
|
969 (if (rmail-message-unseen-p msg-num)
|
|
970 (point))))
|
101360
|
971 (setq rmail-summary-put-back-unseen nil))
|
|
972 ;; Go to the desired message.
|
|
973 (setq rmail-current-message msg-num)
|
|
974 ;; Update the summary to show the message has been seen.
|
101990
|
975 (rmail-summary-mark-seen msg-num t)
|
101360
|
976 (if window
|
|
977 ;; Using save-window-excursion would cause the new value
|
|
978 ;; of point to get lost.
|
|
979 (unwind-protect
|
|
980 (progn
|
|
981 (select-window window)
|
101995
|
982 (rmail-show-message msg-num t))
|
101360
|
983 (select-window owin))
|
|
984 (if (buffer-name rmail-buffer)
|
|
985 (save-excursion
|
|
986 (set-buffer rmail-buffer)
|
101995
|
987 (rmail-show-message msg-num t))))))
|
101360
|
988 (rmail-summary-update-highlight nil)))))
|
|
989
|
|
990 (defun rmail-summary-save-buffer ()
|
|
991 "Save the buffer associated with this RMAIL summary."
|
|
992 (interactive)
|
|
993 (save-window-excursion
|
|
994 (save-excursion
|
|
995 (switch-to-buffer rmail-buffer)
|
|
996 (save-buffer))))
|
|
997
|
|
998
|
|
999 (if rmail-summary-mode-map
|
|
1000 nil
|
|
1001 (setq rmail-summary-mode-map (make-keymap))
|
|
1002 (suppress-keymap rmail-summary-mode-map)
|
|
1003
|
|
1004 (define-key rmail-summary-mode-map [mouse-2] 'rmail-summary-mouse-goto-message)
|
|
1005 (define-key rmail-summary-mode-map "a" 'rmail-summary-add-label)
|
|
1006 (define-key rmail-summary-mode-map "b" 'rmail-summary-bury)
|
|
1007 (define-key rmail-summary-mode-map "c" 'rmail-summary-continue)
|
|
1008 (define-key rmail-summary-mode-map "d" 'rmail-summary-delete-forward)
|
|
1009 (define-key rmail-summary-mode-map "\C-d" 'rmail-summary-delete-backward)
|
|
1010 (define-key rmail-summary-mode-map "e" 'rmail-summary-edit-current-message)
|
|
1011 (define-key rmail-summary-mode-map "f" 'rmail-summary-forward)
|
|
1012 (define-key rmail-summary-mode-map "g" 'rmail-summary-get-new-mail)
|
|
1013 (define-key rmail-summary-mode-map "h" 'rmail-summary)
|
|
1014 (define-key rmail-summary-mode-map "i" 'rmail-summary-input)
|
|
1015 (define-key rmail-summary-mode-map "j" 'rmail-summary-goto-msg)
|
|
1016 (define-key rmail-summary-mode-map "\C-m" 'rmail-summary-goto-msg)
|
|
1017 (define-key rmail-summary-mode-map "k" 'rmail-summary-kill-label)
|
|
1018 (define-key rmail-summary-mode-map "l" 'rmail-summary-by-labels)
|
|
1019 (define-key rmail-summary-mode-map "\e\C-h" 'rmail-summary)
|
|
1020 (define-key rmail-summary-mode-map "\e\C-l" 'rmail-summary-by-labels)
|
|
1021 (define-key rmail-summary-mode-map "\e\C-r" 'rmail-summary-by-recipients)
|
|
1022 (define-key rmail-summary-mode-map "\e\C-s" 'rmail-summary-by-regexp)
|
102374
|
1023 ;; `f' for "from".
|
|
1024 (define-key rmail-summary-mode-map "\e\C-f" 'rmail-summary-by-senders)
|
101360
|
1025 (define-key rmail-summary-mode-map "\e\C-t" 'rmail-summary-by-topic)
|
|
1026 (define-key rmail-summary-mode-map "m" 'rmail-summary-mail)
|
|
1027 (define-key rmail-summary-mode-map "\M-m" 'rmail-summary-retry-failure)
|
|
1028 (define-key rmail-summary-mode-map "n" 'rmail-summary-next-msg)
|
|
1029 (define-key rmail-summary-mode-map "\en" 'rmail-summary-next-all)
|
|
1030 (define-key rmail-summary-mode-map "\e\C-n" 'rmail-summary-next-labeled-message)
|
|
1031 (define-key rmail-summary-mode-map "o" 'rmail-summary-output)
|
102367
|
1032 (define-key rmail-summary-mode-map "\C-o" 'rmail-summary-output-as-seen)
|
101360
|
1033 (define-key rmail-summary-mode-map "p" 'rmail-summary-previous-msg)
|
|
1034 (define-key rmail-summary-mode-map "\ep" 'rmail-summary-previous-all)
|
|
1035 (define-key rmail-summary-mode-map "\e\C-p" 'rmail-summary-previous-labeled-message)
|
|
1036 (define-key rmail-summary-mode-map "q" 'rmail-summary-quit)
|
|
1037 (define-key rmail-summary-mode-map "Q" 'rmail-summary-wipe)
|
|
1038 (define-key rmail-summary-mode-map "r" 'rmail-summary-reply)
|
|
1039 (define-key rmail-summary-mode-map "s" 'rmail-summary-expunge-and-save)
|
102375
|
1040 ;; See rms's comment in rmail.el
|
|
1041 ;;; (define-key rmail-summary-mode-map "\er" 'rmail-summary-search-backward)
|
101360
|
1042 (define-key rmail-summary-mode-map "\es" 'rmail-summary-search)
|
|
1043 (define-key rmail-summary-mode-map "t" 'rmail-summary-toggle-header)
|
|
1044 (define-key rmail-summary-mode-map "u" 'rmail-summary-undelete)
|
|
1045 (define-key rmail-summary-mode-map "\M-u" 'rmail-summary-undelete-many)
|
|
1046 (define-key rmail-summary-mode-map "x" 'rmail-summary-expunge)
|
|
1047 (define-key rmail-summary-mode-map "w" 'rmail-summary-output-body)
|
102316
|
1048 (define-key rmail-summary-mode-map "v" 'rmail-mime)
|
101360
|
1049 (define-key rmail-summary-mode-map "." 'rmail-summary-beginning-of-message)
|
|
1050 (define-key rmail-summary-mode-map "/" 'rmail-summary-end-of-message)
|
|
1051 (define-key rmail-summary-mode-map "<" 'rmail-summary-first-message)
|
|
1052 (define-key rmail-summary-mode-map ">" 'rmail-summary-last-message)
|
|
1053 (define-key rmail-summary-mode-map " " 'rmail-summary-scroll-msg-up)
|
|
1054 (define-key rmail-summary-mode-map "\177" 'rmail-summary-scroll-msg-down)
|
|
1055 (define-key rmail-summary-mode-map "?" 'describe-mode)
|
|
1056 (define-key rmail-summary-mode-map "\C-c\C-n" 'rmail-summary-next-same-subject)
|
|
1057 (define-key rmail-summary-mode-map "\C-c\C-p" 'rmail-summary-previous-same-subject)
|
|
1058 (define-key rmail-summary-mode-map "\C-c\C-s\C-d"
|
|
1059 'rmail-summary-sort-by-date)
|
|
1060 (define-key rmail-summary-mode-map "\C-c\C-s\C-s"
|
|
1061 'rmail-summary-sort-by-subject)
|
|
1062 (define-key rmail-summary-mode-map "\C-c\C-s\C-a"
|
|
1063 'rmail-summary-sort-by-author)
|
|
1064 (define-key rmail-summary-mode-map "\C-c\C-s\C-r"
|
|
1065 'rmail-summary-sort-by-recipient)
|
|
1066 (define-key rmail-summary-mode-map "\C-c\C-s\C-c"
|
|
1067 'rmail-summary-sort-by-correspondent)
|
|
1068 (define-key rmail-summary-mode-map "\C-c\C-s\C-l"
|
|
1069 'rmail-summary-sort-by-lines)
|
|
1070 (define-key rmail-summary-mode-map "\C-c\C-s\C-k"
|
|
1071 'rmail-summary-sort-by-labels)
|
|
1072 (define-key rmail-summary-mode-map "\C-x\C-s" 'rmail-summary-save-buffer)
|
|
1073 )
|
|
1074
|
|
1075 ;;; Menu bar bindings.
|
|
1076
|
|
1077 (define-key rmail-summary-mode-map [menu-bar] (make-sparse-keymap))
|
|
1078
|
|
1079 (define-key rmail-summary-mode-map [menu-bar classify]
|
|
1080 (cons "Classify" (make-sparse-keymap "Classify")))
|
|
1081
|
|
1082 (define-key rmail-summary-mode-map [menu-bar classify output-menu]
|
|
1083 '("Output (Rmail Menu)..." . rmail-summary-output-menu))
|
|
1084
|
|
1085 (define-key rmail-summary-mode-map [menu-bar classify input-menu]
|
|
1086 '("Input Rmail File (menu)..." . rmail-input-menu))
|
|
1087
|
|
1088 (define-key rmail-summary-mode-map [menu-bar classify input-menu]
|
|
1089 '(nil))
|
|
1090
|
|
1091 (define-key rmail-summary-mode-map [menu-bar classify output-menu]
|
|
1092 '(nil))
|
|
1093
|
|
1094 (define-key rmail-summary-mode-map [menu-bar classify output-body]
|
102367
|
1095 '("Output body..." . rmail-summary-output-body))
|
101360
|
1096
|
|
1097 (define-key rmail-summary-mode-map [menu-bar classify output-inbox]
|
102367
|
1098 '("Output..." . rmail-summary-output))
|
101360
|
1099
|
|
1100 (define-key rmail-summary-mode-map [menu-bar classify output]
|
102367
|
1101 '("Output as seen..." . rmail-summary-output-as-seen))
|
101360
|
1102
|
|
1103 (define-key rmail-summary-mode-map [menu-bar classify kill-label]
|
|
1104 '("Kill Label..." . rmail-summary-kill-label))
|
|
1105
|
|
1106 (define-key rmail-summary-mode-map [menu-bar classify add-label]
|
|
1107 '("Add Label..." . rmail-summary-add-label))
|
|
1108
|
|
1109 (define-key rmail-summary-mode-map [menu-bar summary]
|
|
1110 (cons "Summary" (make-sparse-keymap "Summary")))
|
|
1111
|
|
1112 (define-key rmail-summary-mode-map [menu-bar summary senders]
|
|
1113 '("By Senders..." . rmail-summary-by-senders))
|
|
1114
|
|
1115 (define-key rmail-summary-mode-map [menu-bar summary labels]
|
|
1116 '("By Labels..." . rmail-summary-by-labels))
|
|
1117
|
|
1118 (define-key rmail-summary-mode-map [menu-bar summary recipients]
|
|
1119 '("By Recipients..." . rmail-summary-by-recipients))
|
|
1120
|
|
1121 (define-key rmail-summary-mode-map [menu-bar summary topic]
|
|
1122 '("By Topic..." . rmail-summary-by-topic))
|
|
1123
|
|
1124 (define-key rmail-summary-mode-map [menu-bar summary regexp]
|
|
1125 '("By Regexp..." . rmail-summary-by-regexp))
|
|
1126
|
|
1127 (define-key rmail-summary-mode-map [menu-bar summary all]
|
|
1128 '("All" . rmail-summary))
|
|
1129
|
|
1130 (define-key rmail-summary-mode-map [menu-bar mail]
|
|
1131 (cons "Mail" (make-sparse-keymap "Mail")))
|
|
1132
|
|
1133 (define-key rmail-summary-mode-map [menu-bar mail rmail-summary-get-new-mail]
|
|
1134 '("Get New Mail" . rmail-summary-get-new-mail))
|
|
1135
|
|
1136 (define-key rmail-summary-mode-map [menu-bar mail lambda]
|
|
1137 '("----"))
|
|
1138
|
|
1139 (define-key rmail-summary-mode-map [menu-bar mail continue]
|
|
1140 '("Continue" . rmail-summary-continue))
|
|
1141
|
|
1142 (define-key rmail-summary-mode-map [menu-bar mail resend]
|
|
1143 '("Re-send..." . rmail-summary-resend))
|
|
1144
|
|
1145 (define-key rmail-summary-mode-map [menu-bar mail forward]
|
|
1146 '("Forward" . rmail-summary-forward))
|
|
1147
|
|
1148 (define-key rmail-summary-mode-map [menu-bar mail retry]
|
|
1149 '("Retry" . rmail-summary-retry-failure))
|
|
1150
|
|
1151 (define-key rmail-summary-mode-map [menu-bar mail reply]
|
|
1152 '("Reply" . rmail-summary-reply))
|
|
1153
|
|
1154 (define-key rmail-summary-mode-map [menu-bar mail mail]
|
|
1155 '("Mail" . rmail-summary-mail))
|
|
1156
|
|
1157 (define-key rmail-summary-mode-map [menu-bar delete]
|
|
1158 (cons "Delete" (make-sparse-keymap "Delete")))
|
|
1159
|
|
1160 (define-key rmail-summary-mode-map [menu-bar delete expunge/save]
|
|
1161 '("Expunge/Save" . rmail-summary-expunge-and-save))
|
|
1162
|
|
1163 (define-key rmail-summary-mode-map [menu-bar delete expunge]
|
|
1164 '("Expunge" . rmail-summary-expunge))
|
|
1165
|
|
1166 (define-key rmail-summary-mode-map [menu-bar delete undelete]
|
|
1167 '("Undelete" . rmail-summary-undelete))
|
|
1168
|
|
1169 (define-key rmail-summary-mode-map [menu-bar delete delete]
|
|
1170 '("Delete" . rmail-summary-delete-forward))
|
|
1171
|
|
1172 (define-key rmail-summary-mode-map [menu-bar move]
|
|
1173 (cons "Move" (make-sparse-keymap "Move")))
|
|
1174
|
|
1175 (define-key rmail-summary-mode-map [menu-bar move search-back]
|
|
1176 '("Search Back..." . rmail-summary-search-backward))
|
|
1177
|
|
1178 (define-key rmail-summary-mode-map [menu-bar move search]
|
|
1179 '("Search..." . rmail-summary-search))
|
|
1180
|
|
1181 (define-key rmail-summary-mode-map [menu-bar move previous]
|
|
1182 '("Previous Nondeleted" . rmail-summary-previous-msg))
|
|
1183
|
|
1184 (define-key rmail-summary-mode-map [menu-bar move next]
|
|
1185 '("Next Nondeleted" . rmail-summary-next-msg))
|
|
1186
|
|
1187 (define-key rmail-summary-mode-map [menu-bar move last]
|
|
1188 '("Last" . rmail-summary-last-message))
|
|
1189
|
|
1190 (define-key rmail-summary-mode-map [menu-bar move first]
|
|
1191 '("First" . rmail-summary-first-message))
|
|
1192
|
|
1193 (define-key rmail-summary-mode-map [menu-bar move previous]
|
|
1194 '("Previous" . rmail-summary-previous-all))
|
|
1195
|
|
1196 (define-key rmail-summary-mode-map [menu-bar move next]
|
|
1197 '("Next" . rmail-summary-next-all))
|
|
1198
|
|
1199 (defun rmail-summary-mouse-goto-message (event)
|
|
1200 "Select the message whose summary line you click on."
|
|
1201 (interactive "@e")
|
|
1202 (goto-char (posn-point (event-end event)))
|
|
1203 (rmail-summary-goto-msg))
|
|
1204
|
|
1205 (defun rmail-summary-goto-msg (&optional n nowarn skip-rmail)
|
|
1206 "Go to message N in the summary buffer and the Rmail buffer.
|
|
1207 If N is nil, use the message corresponding to point in the summary
|
|
1208 and move to that message in the Rmail buffer.
|
|
1209
|
|
1210 If NOWARN, don't say anything if N is out of range.
|
101630
|
1211 If SKIP-RMAIL, don't do anything to the Rmail buffer.
|
|
1212 Returns non-nil if message N was found."
|
101360
|
1213 (interactive "P")
|
|
1214 (if (consp n) (setq n (prefix-numeric-value n)))
|
|
1215 (if (eobp) (forward-line -1))
|
|
1216 (beginning-of-line)
|
|
1217 (let* ((obuf (current-buffer))
|
|
1218 (buf rmail-buffer)
|
|
1219 (cur (point))
|
|
1220 message-not-found
|
|
1221 (curmsg (string-to-number
|
|
1222 (buffer-substring (point)
|
|
1223 (min (point-max) (+ 6 (point))))))
|
|
1224 (total (save-excursion (set-buffer buf) rmail-total-messages)))
|
|
1225 ;; If message number N was specified, find that message's line
|
|
1226 ;; or set message-not-found.
|
|
1227 ;; If N wasn't specified or that message can't be found.
|
|
1228 ;; set N by default.
|
|
1229 (if (not n)
|
|
1230 (setq n curmsg)
|
|
1231 (if (< n 1)
|
|
1232 (progn (message "No preceding message")
|
|
1233 (setq n 1)))
|
|
1234 (if (and (> n total)
|
|
1235 (> total 0))
|
|
1236 (progn (message "No following message")
|
|
1237 (goto-char (point-max))
|
|
1238 (rmail-summary-goto-msg nil nowarn skip-rmail)))
|
|
1239 (goto-char (point-min))
|
|
1240 (if (not (re-search-forward (format "^%5d[^0-9]" n) nil t))
|
|
1241 (progn (or nowarn (message "Message %d not found" n))
|
|
1242 (setq n curmsg)
|
|
1243 (setq message-not-found t)
|
|
1244 (goto-char cur))))
|
101990
|
1245 (rmail-summary-mark-seen n)
|
101360
|
1246 (rmail-summary-update-highlight message-not-found)
|
|
1247 (beginning-of-line)
|
101990
|
1248 (unless skip-rmail
|
101360
|
1249 (let ((selwin (selected-window)))
|
|
1250 (unwind-protect
|
|
1251 (progn (pop-to-buffer buf)
|
101995
|
1252 (rmail-show-message n))
|
101360
|
1253 (select-window selwin)
|
|
1254 ;; The actions above can alter the current buffer. Preserve it.
|
101630
|
1255 (set-buffer obuf))))
|
|
1256 (not message-not-found)))
|
101360
|
1257
|
|
1258 ;; Update the highlighted line in an rmail summary buffer.
|
|
1259 ;; That should be current. We highlight the line point is on.
|
|
1260 ;; If NOT-FOUND is non-nil, we turn off highlighting.
|
|
1261 (defun rmail-summary-update-highlight (not-found)
|
|
1262 ;; Make sure we have an overlay to use.
|
|
1263 (or rmail-summary-overlay
|
|
1264 (progn
|
|
1265 (make-local-variable 'rmail-summary-overlay)
|
101630
|
1266 (setq rmail-summary-overlay (make-overlay (point) (point)))
|
|
1267 (overlay-put rmail-summary-overlay 'rmail-summary t)))
|
101360
|
1268 ;; If this message is in the summary, use the overlay to highlight it.
|
|
1269 ;; Otherwise, don't highlight anything.
|
|
1270 (if not-found
|
|
1271 (overlay-put rmail-summary-overlay 'face nil)
|
|
1272 (move-overlay rmail-summary-overlay
|
|
1273 (save-excursion (beginning-of-line)
|
|
1274 (skip-chars-forward " ")
|
|
1275 (point))
|
101630
|
1276 (line-end-position))
|
101360
|
1277 (overlay-put rmail-summary-overlay 'face 'highlight)))
|
|
1278
|
|
1279 (defun rmail-summary-scroll-msg-up (&optional dist)
|
|
1280 "Scroll the Rmail window forward.
|
|
1281 If the Rmail window is displaying the end of a message,
|
|
1282 advance to the next message."
|
|
1283 (interactive "P")
|
|
1284 (if (eq dist '-)
|
|
1285 (rmail-summary-scroll-msg-down nil)
|
|
1286 (let ((rmail-buffer-window (get-buffer-window rmail-buffer)))
|
|
1287 (if rmail-buffer-window
|
|
1288 (if (let ((rmail-summary-window (selected-window)))
|
|
1289 (select-window rmail-buffer-window)
|
|
1290 (prog1
|
|
1291 ;; Is EOB visible in the buffer?
|
|
1292 (save-excursion
|
|
1293 (let ((ht (window-height (selected-window))))
|
|
1294 (move-to-window-line (- ht 2))
|
|
1295 (end-of-line)
|
|
1296 (eobp)))
|
|
1297 (select-window rmail-summary-window)))
|
|
1298 (if (not rmail-summary-scroll-between-messages)
|
|
1299 (error "End of buffer")
|
|
1300 (rmail-summary-next-msg (or dist 1)))
|
|
1301 (let ((other-window-scroll-buffer rmail-buffer))
|
|
1302 (scroll-other-window dist)))
|
|
1303 ;; If it isn't visible at all, show the beginning.
|
|
1304 (rmail-summary-beginning-of-message)))))
|
|
1305
|
|
1306 (defun rmail-summary-scroll-msg-down (&optional dist)
|
|
1307 "Scroll the Rmail window backward.
|
|
1308 If the Rmail window is now displaying the beginning of a message,
|
|
1309 move to the previous message."
|
|
1310 (interactive "P")
|
|
1311 (if (eq dist '-)
|
|
1312 (rmail-summary-scroll-msg-up nil)
|
|
1313 (let ((rmail-buffer-window (get-buffer-window rmail-buffer)))
|
|
1314 (if rmail-buffer-window
|
|
1315 (if (let ((rmail-summary-window (selected-window)))
|
|
1316 (select-window rmail-buffer-window)
|
|
1317 (prog1
|
|
1318 ;; Is BOB visible in the buffer?
|
|
1319 (save-excursion
|
|
1320 (move-to-window-line 0)
|
|
1321 (beginning-of-line)
|
|
1322 (bobp))
|
|
1323 (select-window rmail-summary-window)))
|
|
1324 (if (not rmail-summary-scroll-between-messages)
|
|
1325 (error "Beginning of buffer")
|
|
1326 (rmail-summary-previous-msg (or dist 1)))
|
|
1327 (let ((other-window-scroll-buffer rmail-buffer))
|
|
1328 (scroll-other-window-down dist)))
|
|
1329 ;; If it isn't visible at all, show the beginning.
|
|
1330 (rmail-summary-beginning-of-message)))))
|
|
1331
|
|
1332 (defun rmail-summary-beginning-of-message ()
|
|
1333 "Show current message from the beginning."
|
|
1334 (interactive)
|
|
1335 (rmail-summary-show-message 'BEG))
|
|
1336
|
|
1337 (defun rmail-summary-end-of-message ()
|
|
1338 "Show bottom of current message."
|
|
1339 (interactive)
|
|
1340 (rmail-summary-show-message 'END))
|
|
1341
|
|
1342 (defun rmail-summary-show-message (where)
|
|
1343 "Show current mail message.
|
|
1344 Position it according to WHERE which can be BEG or END"
|
|
1345 (if (and (one-window-p) (not pop-up-frames))
|
|
1346 ;; If there is just one window, put the summary on the top.
|
|
1347 (let ((buffer rmail-buffer))
|
|
1348 (split-window (selected-window) rmail-summary-window-size)
|
|
1349 (select-window (frame-first-window))
|
|
1350 (pop-to-buffer rmail-buffer)
|
|
1351 ;; If pop-to-buffer did not use that window, delete that
|
|
1352 ;; window. (This can happen if it uses another frame.)
|
|
1353 (or (eq buffer (window-buffer (next-window (frame-first-window))))
|
|
1354 (delete-other-windows)))
|
|
1355 (pop-to-buffer rmail-buffer))
|
|
1356 (cond
|
|
1357 ((eq where 'BEG)
|
|
1358 (goto-char (point-min))
|
|
1359 (search-forward "\n\n"))
|
|
1360 ((eq where 'END)
|
|
1361 (goto-char (point-max))
|
|
1362 (recenter (1- (window-height))))
|
|
1363 )
|
|
1364 (pop-to-buffer rmail-summary-buffer))
|
|
1365
|
|
1366 (defun rmail-summary-bury ()
|
|
1367 "Bury the Rmail buffer and the Rmail summary buffer."
|
|
1368 (interactive)
|
|
1369 (let ((buffer-to-bury (current-buffer)))
|
|
1370 (let (window)
|
|
1371 (while (setq window (get-buffer-window rmail-buffer))
|
|
1372 (set-window-buffer window (other-buffer rmail-buffer)))
|
|
1373 (bury-buffer rmail-buffer))
|
|
1374 (switch-to-buffer (other-buffer buffer-to-bury))
|
|
1375 (bury-buffer buffer-to-bury)))
|
|
1376
|
|
1377 (defun rmail-summary-quit ()
|
|
1378 "Quit out of Rmail and Rmail summary."
|
|
1379 (interactive)
|
|
1380 (rmail-summary-wipe)
|
|
1381 (rmail-quit))
|
|
1382
|
|
1383 (defun rmail-summary-wipe ()
|
|
1384 "Kill and wipe away Rmail summary, remaining within Rmail."
|
|
1385 (interactive)
|
|
1386 (save-excursion (set-buffer rmail-buffer) (setq rmail-summary-buffer nil))
|
|
1387 (let ((local-rmail-buffer rmail-buffer))
|
|
1388 (kill-buffer (current-buffer))
|
|
1389 ;; Delete window if not only one.
|
|
1390 (if (not (eq (selected-window) (next-window nil 'no-minibuf)))
|
|
1391 (delete-window))
|
|
1392 ;; Switch windows to the rmail buffer, or switch to it in this window.
|
|
1393 (pop-to-buffer local-rmail-buffer)))
|
|
1394
|
|
1395 (defun rmail-summary-expunge ()
|
|
1396 "Actually erase all deleted messages and recompute summary headers."
|
|
1397 (interactive)
|
|
1398 (save-excursion
|
|
1399 (set-buffer rmail-buffer)
|
|
1400 (when (rmail-expunge-confirmed)
|
|
1401 (rmail-only-expunge)))
|
|
1402 (rmail-update-summary))
|
|
1403
|
|
1404 (defun rmail-summary-expunge-and-save ()
|
|
1405 "Expunge and save RMAIL file."
|
|
1406 (interactive)
|
|
1407 (save-excursion
|
|
1408 (rmail-expunge-and-save))
|
|
1409 (rmail-update-summary)
|
|
1410 (set-buffer-modified-p nil))
|
|
1411
|
|
1412 (defun rmail-summary-get-new-mail (&optional file-name)
|
|
1413 "Get new mail and recompute summary headers.
|
|
1414
|
|
1415 Optionally you can specify the file to get new mail from. In this case,
|
|
1416 the file of new mail is not changed or deleted. Noninteractively, you can
|
|
1417 pass the inbox file name as an argument. Interactively, a prefix
|
|
1418 argument says to read a file name and use that file as the inbox."
|
|
1419 (interactive
|
|
1420 (list (if current-prefix-arg
|
|
1421 (read-file-name "Get new mail from file: "))))
|
|
1422 (let (msg)
|
|
1423 (save-excursion
|
|
1424 (set-buffer rmail-buffer)
|
|
1425 (rmail-get-new-mail file-name)
|
|
1426 ;; Get the proper new message number.
|
|
1427 (setq msg rmail-current-message))
|
|
1428 ;; Make sure that message is displayed.
|
|
1429 (or (zerop msg)
|
|
1430 (rmail-summary-goto-msg msg))))
|
|
1431
|
|
1432 (defun rmail-summary-input (filename)
|
|
1433 "Run Rmail on file FILENAME."
|
|
1434 (interactive "FRun rmail on RMAIL file: ")
|
|
1435 ;; We switch windows here, then display the other Rmail file there.
|
|
1436 (pop-to-buffer rmail-buffer)
|
|
1437 (rmail filename))
|
|
1438
|
|
1439 (defun rmail-summary-first-message ()
|
|
1440 "Show first message in Rmail file from summary buffer."
|
|
1441 (interactive)
|
|
1442 (with-no-warnings
|
|
1443 (beginning-of-buffer)))
|
|
1444
|
|
1445 (defun rmail-summary-last-message ()
|
|
1446 "Show last message in Rmail file from summary buffer."
|
|
1447 (interactive)
|
|
1448 (with-no-warnings
|
|
1449 (end-of-buffer))
|
|
1450 (forward-line -1))
|
|
1451
|
|
1452 (declare-function rmail-abort-edit "rmailedit" ())
|
|
1453 (declare-function rmail-cease-edit "rmailedit"())
|
|
1454 (declare-function rmail-set-label "rmailkwd" (l state &optional n))
|
|
1455 (declare-function rmail-output-read-file-name "rmailout" ())
|
|
1456 (declare-function mail-send-and-exit "sendmail" (&optional arg))
|
|
1457
|
|
1458 (defvar rmail-summary-edit-map nil)
|
|
1459 (if rmail-summary-edit-map
|
|
1460 nil
|
|
1461 (setq rmail-summary-edit-map
|
|
1462 (nconc (make-sparse-keymap) text-mode-map))
|
|
1463 (define-key rmail-summary-edit-map "\C-c\C-c" 'rmail-cease-edit)
|
|
1464 (define-key rmail-summary-edit-map "\C-c\C-]" 'rmail-abort-edit))
|
|
1465
|
|
1466 (defun rmail-summary-edit-current-message ()
|
|
1467 "Edit the contents of this message."
|
|
1468 (interactive)
|
|
1469 (pop-to-buffer rmail-buffer)
|
|
1470 (rmail-edit-current-message)
|
|
1471 (use-local-map rmail-summary-edit-map))
|
|
1472
|
|
1473 (defun rmail-summary-cease-edit ()
|
|
1474 "Finish editing message, then go back to Rmail summary buffer."
|
|
1475 (interactive)
|
|
1476 (rmail-cease-edit)
|
|
1477 (pop-to-buffer rmail-summary-buffer))
|
|
1478
|
|
1479 (defun rmail-summary-abort-edit ()
|
|
1480 "Abort edit of current message; restore original contents.
|
|
1481 Go back to summary buffer."
|
|
1482 (interactive)
|
|
1483 (rmail-abort-edit)
|
|
1484 (pop-to-buffer rmail-summary-buffer))
|
|
1485
|
|
1486 (defun rmail-summary-search-backward (regexp &optional n)
|
|
1487 "Show message containing next match for REGEXP.
|
|
1488 Prefix argument gives repeat count; negative argument means search
|
|
1489 backwards (through earlier messages).
|
|
1490 Interactively, empty argument means use same regexp used last time."
|
|
1491 (interactive
|
|
1492 (let* ((reversep (>= (prefix-numeric-value current-prefix-arg) 0))
|
|
1493 (prompt
|
|
1494 (concat (if reversep "Reverse " "") "Rmail search (regexp"))
|
|
1495 regexp)
|
|
1496 (setq prompt
|
|
1497 (concat prompt
|
|
1498 (if rmail-search-last-regexp
|
|
1499 (concat ", default "
|
|
1500 rmail-search-last-regexp "): ")
|
|
1501 "): ")))
|
|
1502 (setq regexp (read-string prompt))
|
|
1503 (cond ((not (equal regexp ""))
|
|
1504 (setq rmail-search-last-regexp regexp))
|
|
1505 ((not rmail-search-last-regexp)
|
|
1506 (error "No previous Rmail search string")))
|
|
1507 (list rmail-search-last-regexp
|
|
1508 (prefix-numeric-value current-prefix-arg))))
|
|
1509 ;; Don't use save-excursion because that prevents point from moving
|
|
1510 ;; properly in the summary buffer.
|
|
1511 (let ((buffer (current-buffer)))
|
|
1512 (unwind-protect
|
|
1513 (progn
|
|
1514 (set-buffer rmail-buffer)
|
|
1515 (rmail-search regexp (- n)))
|
|
1516 (set-buffer buffer))))
|
|
1517
|
|
1518 (defun rmail-summary-search (regexp &optional n)
|
|
1519 "Show message containing next match for REGEXP.
|
|
1520 Prefix argument gives repeat count; negative argument means search
|
|
1521 backwards (through earlier messages).
|
|
1522 Interactively, empty argument means use same regexp used last time."
|
|
1523 (interactive
|
|
1524 (let* ((reversep (< (prefix-numeric-value current-prefix-arg) 0))
|
|
1525 (prompt
|
|
1526 (concat (if reversep "Reverse " "") "Rmail search (regexp"))
|
|
1527 regexp)
|
|
1528 (setq prompt
|
|
1529 (concat prompt
|
|
1530 (if rmail-search-last-regexp
|
|
1531 (concat ", default "
|
|
1532 rmail-search-last-regexp "): ")
|
|
1533 "): ")))
|
|
1534 (setq regexp (read-string prompt))
|
|
1535 (cond ((not (equal regexp ""))
|
|
1536 (setq rmail-search-last-regexp regexp))
|
|
1537 ((not rmail-search-last-regexp)
|
|
1538 (error "No previous Rmail search string")))
|
|
1539 (list rmail-search-last-regexp
|
|
1540 (prefix-numeric-value current-prefix-arg))))
|
|
1541 ;; Don't use save-excursion because that prevents point from moving
|
|
1542 ;; properly in the summary buffer.
|
102375
|
1543 (let ((buffer (current-buffer))
|
|
1544 (selwin (selected-window)))
|
101360
|
1545 (unwind-protect
|
|
1546 (progn
|
102375
|
1547 (pop-to-buffer rmail-buffer)
|
101360
|
1548 (rmail-search regexp n))
|
102375
|
1549 (select-window selwin)
|
101360
|
1550 (set-buffer buffer))))
|
|
1551
|
|
1552 (defun rmail-summary-toggle-header ()
|
|
1553 "Show original message header if pruned header currently shown, or vice versa."
|
|
1554 (interactive)
|
|
1555 (save-window-excursion
|
|
1556 (set-buffer rmail-buffer)
|
|
1557 (rmail-toggle-header))
|
|
1558 ;; Inside save-excursion, some changes to point in the RMAIL buffer are lost.
|
|
1559 ;; Set point to point-min in the RMAIL buffer, if it is visible.
|
|
1560 (let ((window (get-buffer-window rmail-buffer)))
|
|
1561 (if window
|
|
1562 ;; Using save-window-excursion would lose the new value of point.
|
|
1563 (let ((owin (selected-window)))
|
|
1564 (unwind-protect
|
|
1565 (progn
|
|
1566 (select-window window)
|
|
1567 (goto-char (point-min)))
|
|
1568 (select-window owin))))))
|
|
1569
|
|
1570
|
|
1571 (defun rmail-summary-add-label (label)
|
|
1572 "Add LABEL to labels associated with current Rmail message.
|
|
1573 Completion is performed over known labels when reading."
|
|
1574 (interactive (list (save-excursion
|
|
1575 (set-buffer rmail-buffer)
|
|
1576 (rmail-read-label "Add label"))))
|
|
1577 (save-excursion
|
|
1578 (set-buffer rmail-buffer)
|
|
1579 (rmail-add-label label)))
|
|
1580
|
|
1581 (defun rmail-summary-kill-label (label)
|
|
1582 "Remove LABEL from labels associated with current Rmail message.
|
|
1583 Completion is performed over known labels when reading."
|
|
1584 (interactive (list (save-excursion
|
|
1585 (set-buffer rmail-buffer)
|
|
1586 (rmail-read-label "Kill label"))))
|
|
1587 (save-excursion
|
|
1588 (set-buffer rmail-buffer)
|
|
1589 (rmail-set-label label nil)))
|
|
1590
|
|
1591 ;;;; *** Rmail Summary Mailing Commands ***
|
|
1592
|
|
1593 (defun rmail-summary-override-mail-send-and-exit ()
|
|
1594 "Replace bindings to `mail-send-and-exit' with `rmail-summary-send-and-exit'."
|
|
1595 (use-local-map (copy-keymap (current-local-map)))
|
|
1596 (dolist (key (where-is-internal 'mail-send-and-exit))
|
|
1597 (define-key (current-local-map) key 'rmail-summary-send-and-exit)))
|
|
1598
|
|
1599 (defun rmail-summary-mail ()
|
|
1600 "Send mail in another window.
|
|
1601 While composing the message, use \\[mail-yank-original] to yank the
|
|
1602 original message into it."
|
|
1603 (interactive)
|
|
1604 (let ((window (get-buffer-window rmail-buffer)))
|
|
1605 (if window
|
|
1606 (select-window window)
|
|
1607 (set-buffer rmail-buffer)))
|
|
1608 (rmail-start-mail nil nil nil nil nil (current-buffer))
|
|
1609 (rmail-summary-override-mail-send-and-exit))
|
|
1610
|
|
1611 (defun rmail-summary-continue ()
|
|
1612 "Continue composing outgoing message previously being composed."
|
|
1613 (interactive)
|
|
1614 (let ((window (get-buffer-window rmail-buffer)))
|
|
1615 (if window
|
|
1616 (select-window window)
|
|
1617 (set-buffer rmail-buffer)))
|
|
1618 (rmail-start-mail t))
|
|
1619
|
|
1620 (defun rmail-summary-reply (just-sender)
|
|
1621 "Reply to the current message.
|
|
1622 Normally include CC: to all other recipients of original message;
|
|
1623 prefix argument means ignore them. While composing the reply,
|
|
1624 use \\[mail-yank-original] to yank the original message into it."
|
|
1625 (interactive "P")
|
|
1626 (let ((window (get-buffer-window rmail-buffer)))
|
|
1627 (if window
|
|
1628 (select-window window)
|
|
1629 (set-buffer rmail-buffer)))
|
|
1630 (rmail-reply just-sender)
|
|
1631 (rmail-summary-override-mail-send-and-exit))
|
|
1632
|
|
1633 (defun rmail-summary-retry-failure ()
|
|
1634 "Edit a mail message which is based on the contents of the current message.
|
|
1635 For a message rejected by the mail system, extract the interesting headers and
|
|
1636 the body of the original message; otherwise copy the current message."
|
|
1637 (interactive)
|
|
1638 (let ((window (get-buffer-window rmail-buffer)))
|
|
1639 (if window
|
|
1640 (select-window window)
|
|
1641 (set-buffer rmail-buffer)))
|
|
1642 (rmail-retry-failure)
|
|
1643 (rmail-summary-override-mail-send-and-exit))
|
|
1644
|
|
1645 (defun rmail-summary-send-and-exit ()
|
|
1646 "Send mail reply and return to summary buffer."
|
|
1647 (interactive)
|
|
1648 (mail-send-and-exit t))
|
|
1649
|
|
1650 (defun rmail-summary-forward (resend)
|
|
1651 "Forward the current message to another user.
|
|
1652 With prefix argument, \"resend\" the message instead of forwarding it;
|
|
1653 see the documentation of `rmail-resend'."
|
|
1654 (interactive "P")
|
|
1655 (save-excursion
|
|
1656 (let ((window (get-buffer-window rmail-buffer)))
|
|
1657 (if window
|
|
1658 (select-window window)
|
|
1659 (set-buffer rmail-buffer)))
|
|
1660 (rmail-forward resend)
|
|
1661 (rmail-summary-override-mail-send-and-exit)))
|
|
1662
|
|
1663 (defun rmail-summary-resend ()
|
|
1664 "Resend current message using `rmail-resend'."
|
|
1665 (interactive)
|
|
1666 (save-excursion
|
|
1667 (let ((window (get-buffer-window rmail-buffer)))
|
|
1668 (if window
|
|
1669 (select-window window)
|
|
1670 (set-buffer rmail-buffer)))
|
|
1671 (call-interactively 'rmail-resend)))
|
|
1672
|
|
1673 ;; Summary output commands.
|
|
1674
|
|
1675 (defun rmail-summary-output (&optional file-name n)
|
|
1676 "Append this message to mail file FILE-NAME.
|
|
1677 This works with both mbox format and Babyl format files,
|
|
1678 outputting in the appropriate format for each.
|
|
1679 The default file name comes from `rmail-default-file',
|
|
1680 which is updated to the name you use in this command.
|
|
1681
|
|
1682 A prefix argument N says to output that many consecutive messages
|
|
1683 from those in the summary, starting with the current one.
|
|
1684 Deleted messages are skipped and don't count.
|
|
1685 When called from Lisp code, N may be omitted and defaults to 1.
|
|
1686
|
|
1687 This command always outputs the complete message header,
|
|
1688 even the header display is currently pruned."
|
|
1689 (interactive
|
|
1690 (progn (require 'rmailout)
|
|
1691 (list (rmail-output-read-file-name)
|
|
1692 (prefix-numeric-value current-prefix-arg))))
|
|
1693 (let ((i 0) prev-msg)
|
|
1694 (while
|
|
1695 (and (< i n)
|
|
1696 (progn (rmail-summary-goto-msg)
|
|
1697 (not (eq prev-msg
|
|
1698 (setq prev-msg
|
|
1699 (with-current-buffer rmail-buffer
|
|
1700 rmail-current-message))))))
|
|
1701 (setq i (1+ i))
|
|
1702 (with-current-buffer rmail-buffer
|
|
1703 (let ((rmail-delete-after-output nil))
|
|
1704 (rmail-output file-name 1)))
|
|
1705 (if rmail-delete-after-output
|
|
1706 (rmail-summary-delete-forward nil)
|
|
1707 (if (< i n)
|
|
1708 (rmail-summary-next-msg 1))))))
|
|
1709
|
|
1710 (defalias 'rmail-summary-output-to-rmail-file 'rmail-summary-output)
|
|
1711
|
|
1712 (declare-function rmail-output-as-seen "rmailout"
|
|
1713 (file-name &optional count noattribute from-gnus))
|
|
1714
|
|
1715 (defun rmail-summary-output-as-seen (&optional file-name n)
|
102049
|
1716 "Append this message to mbox file named FILE-NAME.
|
101360
|
1717 A prefix argument N says to output that many consecutive messages,
|
|
1718 from the summary, starting with the current one.
|
|
1719 Deleted messages are skipped and don't count.
|
|
1720 When called from Lisp code, N may be omitted and defaults to 1.
|
|
1721
|
|
1722 This outputs the message header as you see it (or would see it)
|
|
1723 displayed in Rmail.
|
|
1724
|
|
1725 The default file name comes from `rmail-default-file',
|
|
1726 which is updated to the name you use in this command."
|
|
1727 (interactive
|
|
1728 (progn (require 'rmailout)
|
|
1729 (list (rmail-output-read-file-name)
|
|
1730 (prefix-numeric-value current-prefix-arg))))
|
|
1731 (require 'rmailout) ; for rmail-output-as-seen in non-interactive case
|
|
1732 (let ((i 0) prev-msg)
|
|
1733 (while
|
|
1734 (and (< i n)
|
|
1735 (progn (rmail-summary-goto-msg)
|
|
1736 (not (eq prev-msg
|
|
1737 (setq prev-msg
|
|
1738 (with-current-buffer rmail-buffer
|
|
1739 rmail-current-message))))))
|
|
1740 (setq i (1+ i))
|
|
1741 (with-current-buffer rmail-buffer
|
|
1742 (let ((rmail-delete-after-output nil))
|
|
1743 (rmail-output-as-seen file-name 1)))
|
|
1744 (if rmail-delete-after-output
|
|
1745 (rmail-summary-delete-forward nil)
|
|
1746 (if (< i n)
|
|
1747 (rmail-summary-next-msg 1))))))
|
|
1748
|
|
1749 (defun rmail-summary-output-menu ()
|
|
1750 "Output current message to another Rmail file, chosen with a menu.
|
|
1751 Also set the default for subsequent \\[rmail-output-to-babyl-file] commands.
|
|
1752 The variables `rmail-secondary-file-directory' and
|
|
1753 `rmail-secondary-file-regexp' control which files are offered in the menu."
|
|
1754 (interactive)
|
|
1755 (save-excursion
|
|
1756 (set-buffer rmail-buffer)
|
|
1757 (let ((rmail-delete-after-output nil))
|
|
1758 (call-interactively 'rmail-output-menu)))
|
|
1759 (if rmail-delete-after-output
|
|
1760 (rmail-summary-delete-forward nil)))
|
|
1761
|
|
1762 (defun rmail-summary-construct-io-menu ()
|
|
1763 (let ((files (rmail-find-all-files rmail-secondary-file-directory)))
|
|
1764 (if files
|
|
1765 (progn
|
|
1766 (define-key rmail-summary-mode-map [menu-bar classify input-menu]
|
|
1767 (cons "Input Rmail File"
|
|
1768 (rmail-list-to-menu "Input Rmail File"
|
|
1769 files
|
|
1770 'rmail-summary-input)))
|
|
1771 (define-key rmail-summary-mode-map [menu-bar classify output-menu]
|
|
1772 (cons "Output Rmail File"
|
|
1773 (rmail-list-to-menu "Output Rmail File"
|
|
1774 files
|
|
1775 'rmail-summary-output))))
|
|
1776 (define-key rmail-summary-mode-map [menu-bar classify input-menu]
|
|
1777 '("Input Rmail File" . rmail-disable-menu))
|
|
1778 (define-key rmail-summary-mode-map [menu-bar classify output-menu]
|
|
1779 '("Output Rmail File" . rmail-disable-menu)))))
|
|
1780
|
|
1781 (defun rmail-summary-output-body (&optional file-name)
|
|
1782 "Write this message body to the file FILE-NAME.
|
|
1783 FILE-NAME defaults, interactively, from the Subject field of the message."
|
|
1784 (interactive)
|
|
1785 (save-excursion
|
|
1786 (set-buffer rmail-buffer)
|
|
1787 (let ((rmail-delete-after-output nil))
|
|
1788 (if file-name
|
|
1789 (rmail-output-body-to-file file-name)
|
|
1790 (call-interactively 'rmail-output-body-to-file))))
|
|
1791 (if rmail-delete-after-output
|
|
1792 (rmail-summary-delete-forward nil)))
|
|
1793
|
|
1794 ;; Sorting messages in Rmail Summary buffer.
|
|
1795
|
|
1796 (defun rmail-summary-sort-by-date (reverse)
|
102386
|
1797 "Sort messages of current Rmail summary by \"Date\" header.
|
|
1798 If prefix argument REVERSE is non-nil, sorts in reverse order."
|
101360
|
1799 (interactive "P")
|
|
1800 (rmail-sort-from-summary (function rmail-sort-by-date) reverse))
|
|
1801
|
|
1802 (defun rmail-summary-sort-by-subject (reverse)
|
102386
|
1803 "Sort messages of current Rmail summary by \"Subject\" header.
|
|
1804 Ignores any \"Re: \" prefix. If prefix argument REVERSE is
|
|
1805 non-nil, sorts in reverse order."
|
101360
|
1806 (interactive "P")
|
|
1807 (rmail-sort-from-summary (function rmail-sort-by-subject) reverse))
|
|
1808
|
|
1809 (defun rmail-summary-sort-by-author (reverse)
|
|
1810 "Sort messages of current Rmail summary by author.
|
102386
|
1811 This uses either the \"From\" or \"Sender\" header, downcased.
|
|
1812 If prefix argument REVERSE is non-nil, sorts in reverse order."
|
101360
|
1813 (interactive "P")
|
|
1814 (rmail-sort-from-summary (function rmail-sort-by-author) reverse))
|
|
1815
|
|
1816 (defun rmail-summary-sort-by-recipient (reverse)
|
|
1817 "Sort messages of current Rmail summary by recipient.
|
102386
|
1818 This uses either the \"To\" or \"Apparently-To\" header, downcased.
|
|
1819 If prefix argument REVERSE is non-nil, sorts in reverse order."
|
101360
|
1820 (interactive "P")
|
|
1821 (rmail-sort-from-summary (function rmail-sort-by-recipient) reverse))
|
|
1822
|
|
1823 (defun rmail-summary-sort-by-correspondent (reverse)
|
|
1824 "Sort messages of current Rmail summary by other correspondent.
|
102386
|
1825 This uses either the \"From\", \"Sender\", \"To\", or
|
|
1826 \"Apparently-To\" header, downcased. Uses the first header not
|
|
1827 excluded by `rmail-dont-reply-to-names'. If prefix argument
|
|
1828 REVERSE is non-nil, sorts in reverse order."
|
101360
|
1829 (interactive "P")
|
|
1830 (rmail-sort-from-summary (function rmail-sort-by-correspondent) reverse))
|
|
1831
|
|
1832 (defun rmail-summary-sort-by-lines (reverse)
|
102386
|
1833 "Sort messages of current Rmail summary by the number of lines.
|
|
1834 If prefix argument REVERSE is non-nil, sorts in reverse order."
|
101360
|
1835 (interactive "P")
|
|
1836 (rmail-sort-from-summary (function rmail-sort-by-lines) reverse))
|
|
1837
|
|
1838 (defun rmail-summary-sort-by-labels (reverse labels)
|
|
1839 "Sort messages of current Rmail summary by labels.
|
102386
|
1840 LABELS is a comma-separated list of labels.
|
|
1841 If prefix argument REVERSE is non-nil, sorts in reverse order."
|
101360
|
1842 (interactive "P\nsSort by labels: ")
|
|
1843 (rmail-sort-from-summary
|
102386
|
1844 (lambda (reverse) (rmail-sort-by-labels reverse labels))
|
101360
|
1845 reverse))
|
|
1846
|
|
1847 (defun rmail-sort-from-summary (sortfun reverse)
|
102386
|
1848 "Sort the Rmail buffer using sorting function SORTFUN.
|
|
1849 Passes REVERSE to SORTFUN as its sole argument. Then regenerates
|
|
1850 the summary. Note that the whole Rmail buffer is sorted, even if
|
|
1851 the summary is only showing a subset of messages."
|
101360
|
1852 (require 'rmailsort)
|
|
1853 (let ((selwin (selected-window)))
|
|
1854 (unwind-protect
|
|
1855 (progn (pop-to-buffer rmail-buffer)
|
|
1856 (funcall sortfun reverse))
|
|
1857 (select-window selwin))))
|
|
1858
|
|
1859 (provide 'rmailsum)
|
|
1860
|
|
1861 ;; arch-tag: 80b0a27a-a50d-4f37-9466-83d32d1e0ca8
|
|
1862 ;;; rmailsum.el ends here
|