]> code.delx.au - gnu-emacs/blob - lisp/mh-e/mh-e.el
* mh-alias.el (mh-alias-reload): Sync docstrings with manual.
[gnu-emacs] / lisp / mh-e / mh-e.el
1 ;;; mh-e.el --- GNU Emacs interface to the MH mail system
2
3 ;; Copyright (C) 1985, 1986, 1987, 1988,
4 ;; 1990, 1992, 1993, 1994, 1995, 1997, 1999,
5 ;; 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
6
7 ;; Author: Bill Wohler <wohler@newt.com>
8 ;; Maintainer: Bill Wohler <wohler@newt.com>
9 ;; Version: 7.85+cvs
10 ;; Keywords: mail
11
12 ;; This file is part of GNU Emacs.
13
14 ;; GNU Emacs is free software; you can redistribute it and/or modify
15 ;; it under the terms of the GNU General Public License as published by
16 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; any later version.
18
19 ;; GNU Emacs is distributed in the hope that it will be useful,
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;; GNU General Public License for more details.
23
24 ;; You should have received a copy of the GNU General Public License
25 ;; along with GNU Emacs; see the file COPYING. If not, write to the
26 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
27 ;; Boston, MA 02110-1301, USA.
28
29 ;;; Commentary:
30
31 ;; How to Use:
32 ;; M-x mh-rmail to read mail. Type C-h m there for a list of commands.
33 ;; C-u M-x mh-rmail to visit any folder.
34 ;; M-x mh-smail to send mail. From within the mail reader, "m" works, too.
35
36 ;; Your .emacs might benefit from these bindings:
37 ;; (global-set-key "\C-cr" 'mh-rmail)
38 ;; (global-set-key "\C-xm" 'mh-smail)
39 ;; (global-set-key "\C-x4m" 'mh-smail-other-window)
40
41 ;; MH (Message Handler) is a powerful mail reader.
42
43 ;; The MH newsgroup is comp.mail.mh; the mailing list is mh-users@ics.uci.edu
44 ;; (send to mh-users-request to be added). See the monthly Frequently Asked
45 ;; Questions posting there for information on getting MH and MH-E:
46 ;; http://www.faqs.org/faqs/mail/mh-faq/part1/preamble.html
47
48 ;; N.B. MH must have been compiled with the MHE compiler flag or several
49 ;; features necessary for MH-E will be missing from MH commands, specifically
50 ;; the -build switch to repl and forw.
51
52 ;; MH-E is an Emacs interface to the MH mail system.
53
54 ;; MH-E is supported in GNU Emacs 20 and 21, with MH 6.8.4 and nmh 1.0.4.
55
56 ;; Mailing Lists:
57 ;; mh-e-users@lists.sourceforge.net
58 ;; mh-e-announce@lists.sourceforge.net
59 ;; mh-e-devel@lists.sourceforge.net
60 ;;
61 ;; Subscribe by sending a "subscribe" message to
62 ;; <list>-request@lists.sourceforge.net, or by using the web interface at
63 ;; https://sourceforge.net/mail/?group_id=13357
64
65 ;; Bug Reports:
66 ;; https://sourceforge.net/tracker/?group_id=13357&atid=113357
67 ;; Include the output of M-x mh-version in any bug report.
68
69 ;; Feature Requests:
70 ;; https://sourceforge.net/tracker/?atid=363357&group_id=13357&func=browse
71
72 ;; Support:
73 ;; https://sourceforge.net/tracker/?group_id=13357&atid=213357
74
75 ;;; Change Log:
76
77 ;; Original version for Gosling emacs by Brian Reid, Stanford, 1982.
78 ;; Modified by James Larus, BBN, July 1984 and UCB, 1984 & 1985.
79 ;; Rewritten for GNU Emacs, James Larus, 1985.
80 ;; Modified by Stephen Gildea, 1988.
81 ;; Maintenance picked up by Bill Wohler and the
82 ;; SourceForge Crew <http://mh-e.sourceforge.net/>, 2001.
83
84 ;;; Code:
85
86 (provide 'mh-e)
87
88 (eval-when-compile (require 'mh-acros))
89 (mh-require-cl)
90 (require 'mh-utils)
91 (require 'mh-init)
92 (require 'mh-inc)
93 (require 'mh-seq)
94 (require 'gnus-util)
95 (require 'easymenu)
96
97 ;; Shush the byte-compiler
98 (defvar font-lock-auto-fontify)
99 (defvar font-lock-defaults)
100
101 (defconst mh-version "7.85+cvs" "Version number of MH-E.")
102
103 (defvar mh-partial-folder-mode-line-annotation "select"
104 "Annotation when displaying part of a folder.
105 The string is displayed after the folder's name. nil for no annotation.")
106
107 \f
108
109 ;;; Scan Line Formats
110
111 ;; Parameterize MH-E to work with different scan formats. The defaults work
112 ;; with the standard MH scan listings, in which the first 4 characters on
113 ;; the line are the message number, followed by two places for notations.
114
115 ;; The following scan formats are passed to the scan program if the setting of
116 ;; `mh-scan-format-file' is t. They are identical except the later one makes
117 ;; use of the nmh `decode' function to decode RFC 2047 encodings. If you just
118 ;; want to change the column of the notations, use the `mh-set-cmd-note'
119 ;; function.
120
121 (defvar mh-scan-format-mh
122 (concat
123 "%4(msg)"
124 "%<(cur)+%| %>"
125 "%<{replied}-"
126 "%?(nonnull(comp{to}))%<(mymbox{to})t%>"
127 "%?(nonnull(comp{cc}))%<(mymbox{cc})c%>"
128 "%?(nonnull(comp{bcc}))%<(mymbox{bcc})b%>"
129 "%?(nonnull(comp{newsgroups}))n%>"
130 "%<(zero) %>"
131 "%02(mon{date})/%02(mday{date})%<{date} %|*%>"
132 "%<(mymbox{from})%<{to}To:%14(friendly{to})%>%>"
133 "%<(zero)%17(friendly{from})%> "
134 "%{subject}%<{body}<<%{body}%>")
135 "*Scan format string for MH.
136 This string is passed to the scan program via the -format argument.
137 This format is identical to the default except that additional hints for
138 fontification have been added to the fifth column (remember that in Emacs, the
139 first column is 0).
140
141 The values of the fifth column, in priority order, are: `-' if the message has
142 been replied to, t if an address on the To: line matches one of the
143 mailboxes of the current user, `c' if the Cc: line matches, `b' if the Bcc:
144 line matches, and `n' if a non-empty Newsgroups: header is present.")
145
146 (defvar mh-scan-format-nmh
147 (concat
148 "%4(msg)"
149 "%<(cur)+%| %>"
150 "%<{replied}-"
151 "%?(nonnull(comp{to}))%<(mymbox{to})t%>"
152 "%?(nonnull(comp{cc}))%<(mymbox{cc})c%>"
153 "%?(nonnull(comp{bcc}))%<(mymbox{bcc})b%>"
154 "%?(nonnull(comp{newsgroups}))n%>"
155 "%<(zero) %>"
156 "%02(mon{date})/%02(mday{date})%<{date} %|*%>"
157 "%<(mymbox{from})%<{to}To:%14(decode(friendly{to}))%>%>"
158 "%<(zero)%17(decode(friendly{from}))%> "
159 "%(decode{subject})%<{body}<<%{body}%>")
160 "*Scan format string for nmh.
161 This string is passed to the scan program via the -format arg.
162 This format is identical to the default except that additional hints for
163 fontification have been added to the fifth column (remember that in Emacs, the
164 first column is 0).
165
166 The values of the fifth column, in priority order, are: `-' if the message has
167 been replied to, t if an address on the To: field matches one of the
168 mailboxes of the current user, `c' if the Cc: field matches, `b' if the Bcc:
169 field matches, and `n' if a non-empty Newsgroups: field is present.")
170
171 (defvar mh-note-deleted ?D
172 "Messages that have been deleted are marked by this character.
173 See also `mh-scan-deleted-msg-regexp'.")
174
175 (defvar mh-note-refiled ?^
176 "Messages that have been refiled are marked by this character.
177 See also `mh-scan-refiled-msg-regexp'.")
178
179 (defvar mh-note-cur ?+
180 "The current message (in MH, not in MH-E) is marked by this character.
181 See also `mh-scan-cur-msg-number-regexp'.")
182
183 (defvar mh-scan-good-msg-regexp "^\\( *[0-9]+\\)[^D^0-9]"
184 "This regular expression matches \"good\" messages.
185 It must match from the beginning of the line. Note that the default setting of
186 `mh-folder-font-lock-keywords' expects this expression to contain at least one
187 parenthesized expression which matches the message number as in the default of
188 \"^\\\\( *[0-9]+\\\\)[^D^0-9]\". This expression includes the leading space
189 within the parenthesis since it looks better to highlight it as well. This
190 regular expression should be correct as it is needed by non-fontification
191 functions.")
192
193 (defvar mh-scan-deleted-msg-regexp "^\\( *[0-9]+\\)D"
194 "This regular expression matches deleted messages.
195 It must match from the beginning of the line. Note that the default setting of
196 `mh-folder-font-lock-keywords' expects this expression to contain at least one
197 parenthesized expression which matches the message number as in the default of
198 \"^\\\\( *[0-9]+\\\\)D\". This expression includes the leading space within
199 the parenthesis since it looks better to highlight it as well. This regular
200 expression should be correct as it is needed by non-fontification functions.
201 See also `mh-note-deleted'.")
202
203 (defvar mh-scan-refiled-msg-regexp "^\\( *[0-9]+\\)\\^"
204 "This regular expression matches refiled messages.
205 It must match from the beginning of the line. Note that the default setting of
206 `mh-folder-font-lock-keywords' expects this expression to contain at least one
207 parenthesized expression which matches the message number as in the default of
208 \"^\\\\( *[0-9]+\\\\)\\\\^\". This expression includes the leading space
209 within the parenthesis since it looks better to highlight it as well. This
210 regular expression should be correct as it is needed by non-fontification
211 functions. See also `mh-note-refiled'.")
212
213 (defvar mh-scan-valid-regexp "^ *[0-9]"
214 "This regular expression describes a valid scan line.
215 This is used to eliminate error messages that are occasionally produced by
216 \"inc\".")
217
218 (defvar mh-scan-cur-msg-number-regexp "^\\( *[0-9]+\\+\\).*"
219 "This regular expression matches the current message.
220 It must match from the beginning of the line. Note that the default setting of
221 `mh-folder-font-lock-keywords' expects this expression to contain at least one
222 parenthesized expression which matches the message number as in the default of
223 \"^\\\\( *[0-9]+\\\\+\\\\).*\". This expression includes the leading space and
224 current message marker \"+\" within the parenthesis since it looks better to
225 highlight these items as well. This regular expression should be correct as it
226 is needed by non-fontification functions. See also `mh-note-cur'.")
227
228 (defvar mh-scan-date-regexp "\\([0-9][0-9]/[0-9][0-9]\\)"
229 "This regular expression matches a valid date.
230 It must not be anchored to the beginning or the end of the line. Note that the
231 default setting of `mh-folder-font-lock-keywords' expects this expression to
232 contain only one parenthesized expression which matches the date field as in
233 the default of \"\\\\([0-9][0-9]/[0-9][0-9]\\\\)\"}. If this regular
234 expression is not correct, the date will not be highlighted. See also
235 `mh-scan-format-regexp'.")
236
237 (defvar mh-scan-rcpt-regexp "\\(To:\\)\\(..............\\)"
238 "This regular expression specifies the recipient in messages you sent.
239 Note that the default setting of `mh-folder-font-lock-keywords'
240 expects this expression to contain two parenthesized expressions. The
241 first is expected to match the `To:' that the default scan format
242 file generates. The second is expected to match the recipient's name
243 as in the default of \"\\\\(To:\\\\)\\\\(..............\\\\)\". If this
244 regular expression is not correct, the recipient will not be highlighted.")
245
246 (defvar mh-scan-body-regexp "\\(<<\\([^\n]+\\)?\\)"
247 "This regular expression matches the message body fragment.
248 Note that the default setting of `mh-folder-font-lock-keywords' expects this
249 expression to contain at least one parenthesized expression which matches the
250 body text as in the default of \"\\\\(<<\\\\([^\\n]+\\\\)?\\\\)\". If this
251 regular expression is not correct, the body fragment will not be highlighted.")
252
253 (defvar mh-scan-subject-regexp
254 "^ *[0-9]+........[ ]*...................\\([Rr][Ee]\\(\\[[0-9]+\\]\\)?:\\s-*\\)*\\([^<\n]*\\)"
255 "This regular expression matches the subject.
256 It must match from the beginning of the line. Note that the default setting
257 of `mh-folder-font-lock-keywords' expects this expression to contain at least
258 three parenthesized expressions. The first is expected to match the `Re:'
259 string, if any. The second matches an optional bracketed number after `Re:',
260 such as in `Re[2]:' (and is thus a sub-expression of the first expression) and
261 the third is expected to match the subject line itself as in the default of
262 \(broken on multiple lines for readability):
263 ^ *[0-9]+........[ ]*...................
264 \\\\([Rr][Ee]\\\\(\\\\\\=[[0-9]+\\\\]\\\\)?:\\\\s-*\\\\)*
265 \\\\([^<\\n]*\\\\)
266 This regular expression should be correct as it is needed by non-fontification
267 functions.")
268
269 (defvar mh-scan-format-regexp
270 (concat "\\([bct]\\)" mh-scan-date-regexp " *\\(..................\\)")
271 "This regular expression matches the output of scan.
272 Note that the default setting of `mh-folder-font-lock-keywords' expects this
273 expression to contain at least three parenthesized expressions. The first
274 should match the fontification hint (see `mh-scan-format-nmh'), the second is
275 found in `mh-scan-date-regexp', and the third should match the user name as in
276 the default of \"(concat \"\\\\([bct]\\\\)\" mh-scan-date-regexp
277 \"*\\\\(..................\\\\)\")\".
278 If this regular expression is not correct, the notation hints and the sender
279 will not be highlighted.")
280
281 \f
282
283 (defvar mh-folder-font-lock-keywords
284 (list
285 ;; Folders when displaying index buffer
286 (list "^\\+.*"
287 '(0 mh-index-folder-face))
288 ;; Marked for deletion
289 (list (concat mh-scan-deleted-msg-regexp ".*")
290 '(0 mh-folder-deleted-face))
291 ;; Marked for refile
292 (list (concat mh-scan-refiled-msg-regexp ".*")
293 '(0 mh-folder-refiled-face))
294 ;;after subj
295 (list mh-scan-body-regexp '(1 mh-folder-body-face nil t))
296 '(mh-folder-font-lock-subject
297 (1 mh-folder-followup-face append t)
298 (2 mh-folder-subject-face append t))
299 ;;current msg
300 (list mh-scan-cur-msg-number-regexp
301 '(1 mh-folder-cur-msg-number-face))
302 (list mh-scan-good-msg-regexp
303 '(1 mh-folder-msg-number-face)) ;; Msg number
304 (list mh-scan-date-regexp '(1 mh-folder-date-face)) ;; Date
305 (list mh-scan-rcpt-regexp
306 '(1 mh-folder-to-face) ;; To:
307 '(2 mh-folder-address-face)) ;; address
308 ;; scan font-lock name
309 (list mh-scan-format-regexp
310 '(1 mh-folder-date-face)
311 '(3 mh-folder-scan-format-face)))
312 "Keywords (regular expressions) used to fontify the MH-Folder buffer.")
313
314 (defvar mh-scan-cmd-note-width 1
315 "Number of columns consumed by the cmd-note field in `mh-scan-format'.
316 This column will have one of the values: ` ', `D', `^', `+' and where
317 ` ' is the default value,
318 `D' is the `mh-note-deleted' character,
319 `^' is the `mh-note-refiled' character, and
320 `+' is the `mh-note-cur' character.")
321
322 (defvar mh-scan-destination-width 1
323 "Number of columns consumed by the destination field in `mh-scan-format'.
324 This column will have one of ' ', '%', '-', 't', 'c', 'b', or `n' in it.
325 A ' ' blank space is the default character.
326 A '%' indicates that the message in in a named MH sequence.
327 A '-' indicates that the message has been annotated with a replied field.
328 A 't' indicates that the message contains mymbox in the To: field.
329 A 'c' indicates that the message contains mymbox in the Cc: field.
330 A 'b' indicates that the message contains mymbox in the Bcc: field.
331 A 'n' indicates that the message contains a Newsgroups: field.")
332
333 (defvar mh-scan-date-width 5
334 "Number of columns consumed by the date field in `mh-scan-format'.
335 This column will typically be of the form mm/dd.")
336
337 (defvar mh-scan-date-flag-width 1
338 "Number of columns consumed to flag (in)valid dates in `mh-scan-format'.
339 This column will have ` ' for valid and `*' for invalid or missing dates.")
340
341 (defvar mh-scan-from-mbox-width 17
342 "Number of columns consumed with the \"From:\" line in `mh-scan-format'.
343 This column will have a friendly name or e-mail address of the
344 originator, or a \"To: address\" for outgoing e-mail messages.")
345
346 (defvar mh-scan-from-mbox-sep-width 2
347 "Number of columns consumed by whitespace after from-mbox in `mh-scan-format'.
348 This column will only ever have spaces in it.")
349
350 (defvar mh-scan-field-destination-offset
351 (+ mh-scan-cmd-note-width)
352 "The offset from the `mh-cmd-note' for the destination column.")
353
354 (defvar mh-scan-field-from-start-offset
355 (+ mh-scan-cmd-note-width
356 mh-scan-destination-width
357 mh-scan-date-width
358 mh-scan-date-flag-width)
359 "The offset from the `mh-cmd-note' to find the start of \"From:\" address.")
360
361 (defvar mh-scan-field-from-end-offset
362 (+ mh-scan-field-from-start-offset mh-scan-from-mbox-width)
363 "The offset from the `mh-cmd-note' to find the end of \"From:\" address.")
364
365 (defvar mh-scan-field-subject-start-offset
366 (+ mh-scan-cmd-note-width
367 mh-scan-destination-width
368 mh-scan-date-width
369 mh-scan-date-flag-width
370 mh-scan-from-mbox-width
371 mh-scan-from-mbox-sep-width)
372 "The offset from the `mh-cmd-note' to find the start of the subject.")
373
374 (defun mh-folder-font-lock-subject (limit)
375 "Return MH-E scan subject strings to font-lock between point and LIMIT."
376 (if (not (re-search-forward mh-scan-subject-regexp limit t))
377 nil
378 (if (match-beginning 1)
379 (set-match-data (list (match-beginning 1) (match-end 3)
380 (match-beginning 1) (match-end 3) nil nil))
381 (set-match-data (list (match-beginning 3) (match-end 3)
382 nil nil (match-beginning 3) (match-end 3))))
383 t))
384
385 \f
386
387 ;; Fontifify unseen mesages in bold.
388
389 (defmacro mh-generate-sequence-font-lock (seq prefix face)
390 "Generate the appropriate code to fontify messages in SEQ.
391 PREFIX is used to generate unique names for the variables and functions
392 defined by the macro. So a different prefix should be provided for every
393 invocation.
394 FACE is the font-lock face used to display the matching scan lines."
395 (let ((cache (intern (format "mh-folder-%s-seq-cache" prefix)))
396 (func (intern (format "mh-folder-font-lock-%s" prefix))))
397 `(progn
398 (defvar ,cache nil
399 "Internal cache variable used for font-lock in MH-E.
400 Should only be non-nil through font-lock stepping, and nil once font-lock
401 is done highlighting.")
402 (make-variable-buffer-local ',cache)
403
404 (defun ,func (limit)
405 "Return unseen message lines to font-lock between point and LIMIT."
406 (if (not ,cache) (setq ,cache (mh-seq-msgs (mh-find-seq ,seq))))
407 (let ((cur-msg (mh-get-msg-num nil)))
408 (cond ((not ,cache)
409 nil)
410 ((>= (point) limit) ;Presumably at end of buffer
411 (setq ,cache nil)
412 nil)
413 ((member cur-msg ,cache)
414 (let ((bpoint (progn (beginning-of-line)(point)))
415 (epoint (progn (forward-line 1)(point))))
416 (if (<= limit (point)) (setq ,cache nil))
417 (set-match-data (list bpoint epoint bpoint epoint))
418 t))
419 (t
420 ;; move forward one line at a time, checking each message
421 (while (and (= 0 (forward-line 1))
422 (> limit (point))
423 (not (member (mh-get-msg-num nil) ,cache))))
424 ;; Examine how we must have exited the loop...
425 (let ((cur-msg (mh-get-msg-num nil)))
426 (cond ((or (<= limit (point))
427 (not (member cur-msg ,cache)))
428 (setq ,cache nil)
429 nil)
430 ((member cur-msg ,cache)
431 (let ((bpoint (progn (beginning-of-line) (point)))
432 (epoint (progn (forward-line 1) (point))))
433 (if (<= limit (point)) (setq ,cache nil))
434 (set-match-data
435 (list bpoint epoint bpoint epoint))
436 t))))))))
437
438 (setq mh-folder-font-lock-keywords
439 (append mh-folder-font-lock-keywords
440 (list (list ',func (list 1 '',face 'prepend t))))))))
441
442 (mh-generate-sequence-font-lock mh-unseen-seq unseen bold)
443 (mh-generate-sequence-font-lock mh-tick-seq tick mh-folder-tick)
444
445 \f
446
447 ;;; Internal variables:
448
449 (defvar mh-last-destination nil
450 "Destination of last refile or write command.")
451
452 (defvar mh-last-destination-folder nil
453 "Destination of last refile command.")
454
455 (defvar mh-last-destination-write nil
456 "Destination of last write command.")
457
458 (defvar mh-folder-mode-map (make-keymap)
459 "Keymap for MH folders.")
460
461 (defvar mh-arrow-marker nil
462 "Marker for arrow display in fringe.")
463
464 (defvar mh-delete-list nil
465 "List of message numbers to delete.
466 This variable can be used by `mh-before-commands-processed-hook'.")
467
468 (defvar mh-refile-list nil
469 "List of folder names in `mh-seq-list'.
470 This variable can be used by `mh-before-commands-processed-hook'.")
471
472 (defvar mh-folders-changed nil
473 "Lists which folders were affected by deletes and refiles.
474 This list will always include the current folder `mh-current-folder'.
475 This variable can be used by `mh-before-commands-processed-hook'.")
476
477 (defvar mh-next-direction 'forward
478 "Direction to move to next message.")
479
480 (defvar mh-view-ops ()
481 "Stack of operations that change the folder view.
482 These operations include narrowing or threading.")
483
484 (defvar mh-folder-view-stack ()
485 "Stack of previous folder views.")
486
487 (defvar mh-index-data nil
488 "Info about index search results.")
489
490 (defvar mh-index-previous-search nil)
491 (defvar mh-index-msg-checksum-map nil)
492 (defvar mh-index-checksum-origin-map nil)
493 (defvar mh-index-sequence-search-flag nil)
494
495 (defvar mh-first-msg-num nil
496 "Number of first message in buffer.")
497
498 (defvar mh-last-msg-num nil
499 "Number of last msg in buffer.")
500
501 (defvar mh-mode-line-annotation nil
502 "Message range displayed in buffer.")
503
504 (defvar mh-sequence-notation-history nil
505 "Remember original notation that is overwritten by `mh-note-seq'.")
506
507 (defvar mh-colors-available-flag nil
508 "Non-nil means colors are available.")
509
510 \f
511
512 ;;; Macros and generic functions:
513
514 (defun mh-mapc (function list)
515 "Apply FUNCTION to each element of LIST for side effects only."
516 (while list
517 (funcall function (car list))
518 (setq list (cdr list))))
519
520 (defun mh-scan-format ()
521 "Return the output format argument for the scan program."
522 (if (equal mh-scan-format-file t)
523 (list "-format" (if (mh-variant-p 'nmh 'mu-mh)
524 (list (mh-update-scan-format
525 mh-scan-format-nmh mh-cmd-note))
526 (list (mh-update-scan-format
527 mh-scan-format-mh mh-cmd-note))))
528 (if (not (equal mh-scan-format-file nil))
529 (list "-form" mh-scan-format-file))))
530
531 \f
532
533 ;;; Entry points:
534
535 ;;;###autoload
536 (defun mh-rmail (&optional arg)
537 "Inc(orporate) new mail with MH.
538 Scan an MH folder if ARG is non-nil. This function is an entry point to MH-E,
539 the Emacs interface to the MH mail system."
540 (interactive "P")
541 (mh-find-path)
542 (if arg
543 (call-interactively 'mh-visit-folder)
544 (unless (get-buffer mh-inbox)
545 (mh-visit-folder mh-inbox (symbol-name mh-unseen-seq)))
546 (mh-inc-folder)))
547
548 ;;;###autoload
549 (defun mh-nmail (&optional arg)
550 "Check for new mail in inbox folder.
551 Scan an MH folder if ARG is non-nil. This function is an entry point to MH-E,
552 the Emacs interface to the MH mail system."
553 (interactive "P")
554 (mh-find-path) ; init mh-inbox
555 (if arg
556 (call-interactively 'mh-visit-folder)
557 (mh-visit-folder mh-inbox)))
558
559 \f
560
561 ;;; User executable MH-E commands:
562
563 (defun mh-delete-msg (range)
564 "Delete RANGE\\<mh-folder-mode-map>.
565
566 To mark a message for deletion, use this command. A \"D\" is placed by the
567 message in the scan window, and the next undeleted message is displayed. If
568 the previous command had been \\[mh-previous-undeleted-msg], then the next
569 message displayed is the first undeleted message previous to the message just
570 deleted. Use \\[mh-next-undeleted-msg] to force subsequent \\[mh-delete-msg]
571 commands to move forward to the next undeleted message after deleting the
572 message under the cursor.
573
574 The hook `mh-delete-msg-hook' is called after you mark a message for deletion.
575 For example, a past maintainer of MH-E used this once when he kept statistics
576 on his mail usage.
577
578 Check the documentation of `mh-interactive-range' to see how RANGE is read in
579 interactive use."
580 (interactive (list (mh-interactive-range "Delete")))
581 (mh-delete-msg-no-motion range)
582 (if (looking-at mh-scan-deleted-msg-regexp)
583 (mh-next-msg)))
584
585 (defun mh-delete-msg-no-motion (range)
586 "Delete RANGE, don't move to next message.
587
588 This command marks the RANGE for deletion but leaves the cursor at the current
589 message in case you wish to perform other operations on the message.
590
591 Check the documentation of `mh-interactive-range' to see how RANGE is read in
592 interactive use."
593 (interactive (list (mh-interactive-range "Delete")))
594 (mh-iterate-on-range () range
595 (mh-delete-a-msg nil)))
596
597 (defun mh-execute-commands ()
598 "Process outstanding delete and refile requests\\<mh-folder-mode-map>.
599
600 If you've marked messages to be deleted or refiled and you want to go ahead
601 and delete or refile the messages, use this command. Many MH-E commands that
602 may affect the numbering of the messages (such as \\[mh-rescan-folder] or
603 \\[mh-pack-folder]) will ask if you want to process refiles or deletes first
604 and then either run this command for you or undo the pending refiles and
605 deletes, which are lost.
606
607 This function runs `mh-before-commands-processed-hook' before the commands are
608 processed and `mh-after-commands-processed-hook' after the commands are
609 processed."
610 (interactive)
611 (if mh-folder-view-stack (mh-widen t))
612 (mh-process-commands mh-current-folder)
613 (mh-set-scan-mode)
614 (mh-goto-cur-msg) ; after mh-set-scan-mode for efficiency
615 (mh-make-folder-mode-line)
616 t) ; return t for write-file-functions
617
618 (defun mh-first-msg ()
619 "Display first message."
620 (interactive)
621 (goto-char (point-min))
622 (while (and (not (eobp)) (not (looking-at mh-scan-valid-regexp)))
623 (forward-line 1)))
624
625 (defun mh-header-display ()
626 "Display message with all header fields\\<mh-folder-mode-map>.
627
628 Use the command \\[mh-show] to show the message normally again."
629 (interactive)
630 (and (not mh-showing-with-headers)
631 (or mh-mhl-format-file mh-clean-message-header-flag)
632 (mh-invalidate-show-buffer))
633 (let ((mh-decode-mime-flag nil)
634 (mh-mhl-format-file nil)
635 (mh-clean-message-header-flag nil))
636 (mh-show-msg nil)
637 (mh-in-show-buffer (mh-show-buffer)
638 (goto-char (point-min))
639 (mh-recenter 0))
640 (setq mh-showing-with-headers t)))
641
642 (defun mh-inc-folder (&optional maildrop-name folder)
643 "Incorporate new mail into a folder.
644
645 You can incorporate mail from any file into the current folder by
646 specifying a prefix argument; you'll be prompted for the name of the
647 file to use as well as the destination folder
648
649 The hook `mh-inc-folder-hook' is run after incorporating new mail. Do
650 not call this function from outside MH-E; use \\[mh-rmail] instead.
651
652 In a program optional argument MAILDROP-NAME specifies an alternate
653 maildrop from the default. The optional argument FOLDER specifies
654 where to incorporate mail instead of the default named by `mh-inbox'."
655 (interactive (list (if current-prefix-arg
656 (expand-file-name
657 (read-file-name "inc mail from file: "
658 mh-user-path)))
659 (if current-prefix-arg
660 (mh-prompt-for-folder "inc mail into" mh-inbox t))))
661 (if (not folder)
662 (setq folder mh-inbox))
663 (let ((threading-needed-flag nil))
664 (let ((config (current-window-configuration)))
665 (when (and mh-show-buffer (get-buffer mh-show-buffer))
666 (delete-windows-on mh-show-buffer))
667 (cond ((not (get-buffer folder))
668 (mh-make-folder folder)
669 (setq threading-needed-flag mh-show-threads-flag)
670 (setq mh-previous-window-config config))
671 ((not (eq (current-buffer) (get-buffer folder)))
672 (switch-to-buffer folder)
673 (setq mh-previous-window-config config))))
674 (mh-get-new-mail maildrop-name)
675 (when (and threading-needed-flag
676 (save-excursion
677 (goto-char (point-min))
678 (or (null mh-large-folder)
679 (not (equal (forward-line (1+ mh-large-folder)) 0))
680 (and (message "Not threading since the number of messages exceeds `mh-large-folder'")
681 nil))))
682 (mh-toggle-threads))
683 (beginning-of-line)
684 (if (and mh-showing-mode (looking-at mh-scan-valid-regexp)) (mh-show))
685 (run-hooks 'mh-inc-folder-hook)))
686
687 (defun mh-last-msg ()
688 "Display last message."
689 (interactive)
690 (goto-char (point-max))
691 (while (and (not (bobp)) (not (looking-at mh-scan-valid-regexp)))
692 (forward-line -1))
693 (mh-recenter nil))
694
695 (defun mh-next-undeleted-msg (&optional count wait-after-complaining-flag)
696 "Display next message.
697
698 This command can be given a prefix argument COUNT to specify how many unread
699 messages to skip.
700
701 In a program, pause for a second after printing message if we are at the last
702 undeleted message and optional argument WAIT-AFTER-COMPLAINING-FLAG is
703 non-nil."
704 (interactive "p")
705 (setq mh-next-direction 'forward)
706 (forward-line 1)
707 (cond ((re-search-forward mh-scan-good-msg-regexp nil t count)
708 (beginning-of-line)
709 (mh-maybe-show))
710 (t (forward-line -1)
711 (message "No more undeleted messages")
712 (if wait-after-complaining-flag (sit-for 1)))))
713
714 (defun mh-folder-from-address ()
715 "Derive folder name from sender.
716
717 The name of the folder is derived as follows:
718
719 a) The folder name associated with the first address found in the list
720 `mh-default-folder-list' is used. Each element in this list contains a
721 `Check Recipient' item. If this item is turned on, then the address is
722 checked against the recipient instead of the sender. This is useful for
723 mailing lists.
724
725 b) An alias prefixed by `mh-default-folder-prefix' corresponding to the
726 address is used. The prefix is used to prevent clutter in your mail
727 directory.
728
729 Return nil if a folder name was not derived, or if the variable
730 `mh-default-folder-must-exist-flag' is t and the folder does not exist."
731 ;; Loop for all entries in mh-default-folder-list
732 (save-restriction
733 (goto-char (point-min))
734 (re-search-forward "\n\n" nil 'limit)
735 (narrow-to-region (point-min) (point))
736 (let ((to/cc (concat (or (message-fetch-field "to") "") ", "
737 (or (message-fetch-field "cc") "")))
738 (from (or (message-fetch-field "from") ""))
739 folder-name)
740 (setq folder-name
741 (loop for list in mh-default-folder-list
742 when (string-match (nth 0 list) (if (nth 2 list) to/cc from))
743 return (nth 1 list)
744 finally return nil))
745
746 ;; Make sure a result from `mh-default-folder-list' begins with "+"
747 ;; since 'mh-expand-file-name below depends on it
748 (when (and folder-name (not (eq (aref folder-name 0) ?+)))
749 (setq folder-name (concat "+" folder-name)))
750
751 ;; If not, is there an alias for the address?
752 (when (not folder-name)
753 (let* ((from-header (mh-extract-from-header-value))
754 (address (and from-header
755 (nth 1 (mail-extract-address-components
756 from-header))))
757 (alias (and address (mh-alias-address-to-alias address))))
758 (when alias
759 (setq folder-name
760 (and alias (concat "+" mh-default-folder-prefix alias))))))
761
762 ;; If mh-default-folder-must-exist-flag set, check that folder exists.
763 (if (and folder-name
764 (or (not mh-default-folder-must-exist-flag)
765 (file-exists-p (mh-expand-file-name folder-name))))
766 folder-name))))
767
768 (defun mh-prompt-for-refile-folder ()
769 "Prompt the user for a folder in which the message should be filed.
770 The folder is returned as a string.
771
772 The default folder name is generated by the option
773 `mh-default-folder-for-message-function' if it is non-nil or
774 `mh-folder-from-address'."
775 (mh-prompt-for-folder
776 "Destination"
777 (let ((refile-file (ignore-errors (mh-msg-filename (mh-get-msg-num t)))))
778 (if (null refile-file) ""
779 (save-excursion
780 (set-buffer (get-buffer-create mh-temp-buffer))
781 (erase-buffer)
782 (insert-file-contents refile-file)
783 (or (and mh-default-folder-for-message-function
784 (let ((buffer-file-name refile-file))
785 (funcall mh-default-folder-for-message-function)))
786 (mh-folder-from-address)
787 (and (eq 'refile (car mh-last-destination-folder))
788 (symbol-name (cdr mh-last-destination-folder)))
789 ""))))
790 t))
791
792 (defun mh-refile-msg (range folder &optional dont-update-last-destination-flag)
793 "Refile (output) RANGE into FOLDER.
794
795 You are prompted for the folder name. Note that this command can also be used
796 to create folders. If you specify a folder that does not exist, you will be
797 prompted to create it.
798
799 The hook `mh-refile-msg-hook' is called after a message is marked to be
800 refiled.
801
802 Check the documentation of `mh-interactive-range' to see how RANGE is read in
803 interactive use.
804
805 In a program, the variables `mh-last-destination' and
806 `mh-last-destination-folder' are not updated if
807 DONT-UPDATE-LAST-DESTINATION-FLAG is non-nil."
808 (interactive (list (mh-interactive-range "Refile")
809 (intern (mh-prompt-for-refile-folder))))
810 (unless dont-update-last-destination-flag
811 (setq mh-last-destination (cons 'refile folder)
812 mh-last-destination-folder mh-last-destination))
813 (mh-iterate-on-range () range
814 (mh-refile-a-msg nil folder))
815 (when (looking-at mh-scan-refiled-msg-regexp) (mh-next-msg)))
816
817 (defun mh-refile-or-write-again (range &optional interactive-flag)
818 "Repeat last output command.
819
820 If you are refiling several messages into the same folder, you can use this
821 command to repeat the last refile or write. You can use a range.
822
823 Check the documentation of `mh-interactive-range' to see how RANGE is read in
824 interactive use.
825
826 In a program, a non-nil INTERACTIVE-FLAG means that the function was called
827 interactively."
828 (interactive (list (mh-interactive-range "Redo") t))
829 (if (null mh-last-destination)
830 (error "No previous refile or write"))
831 (cond ((eq (car mh-last-destination) 'refile)
832 (mh-refile-msg range (cdr mh-last-destination))
833 (message "%s" (format "Destination folder: %s"
834 (cdr mh-last-destination))))
835 (t
836 (mh-iterate-on-range msg range
837 (apply 'mh-write-msg-to-file msg (cdr mh-last-destination)))
838 (mh-next-msg interactive-flag))))
839
840 (defun mh-quit ()
841 "Quit the current MH-E folder.
842
843 When you want to quit using MH-E and go back to editing, you can use this
844 command. This buries the buffers of the current MH-E folder and restores the
845 buffers that were present when you first ran \\[mh-rmail]. It also removes any
846 MH-E working buffers whose name begins with \" *mh-\" or \"*MH-E \". You can
847 later restore your MH-E session by selecting the \"+inbox\" buffer or by
848 running \\[mh-rmail] again.
849
850 The two hooks `mh-before-quit-hook' and `mh-quit-hook' are called by this
851 function. The former one is called before the quit occurs, so you might use it
852 to perform any MH-E operations; you could perform some query and abort the
853 quit or call `mh-execute-commands', for example. The latter is not run in an
854 MH-E context, so you might use it to modify the window setup."
855 (interactive)
856 (run-hooks 'mh-before-quit-hook)
857 (let ((show-buffer (get-buffer mh-show-buffer)))
858 (when show-buffer
859 (kill-buffer show-buffer)))
860 (mh-update-sequences)
861 (mh-destroy-postponed-handles)
862 (bury-buffer (current-buffer))
863
864 ;; Delete all MH-E temporary and working buffers.
865 (dolist (buffer (buffer-list))
866 (when (or (string-match "^ \\*mh-" (buffer-name buffer))
867 (string-match "^\\*MH-E " (buffer-name buffer)))
868 (kill-buffer buffer)))
869
870 (if mh-previous-window-config
871 (set-window-configuration mh-previous-window-config))
872 (run-hooks 'mh-quit-hook))
873
874 (defun mh-page-msg (&optional lines)
875 "Display next page in message.
876
877 You can give this command a prefix argument that specifies the number of LINES
878 to scroll. This command will also show the next undeleted message if it is
879 used at the bottom of a message."
880 (interactive "P")
881 (if mh-showing-mode
882 (if mh-page-to-next-msg-flag
883 (if (equal mh-next-direction 'backward)
884 (mh-previous-undeleted-msg)
885 (mh-next-undeleted-msg))
886 (if (mh-in-show-buffer (mh-show-buffer)
887 (pos-visible-in-window-p (point-max)))
888 (progn
889 (message
890 "End of message (Type %s to read %s undeleted message)"
891 (single-key-description last-input-event)
892 (if (equal mh-next-direction 'backward)
893 "previous"
894 "next"))
895 (setq mh-page-to-next-msg-flag t))
896 (scroll-other-window lines)))
897 (mh-show)))
898
899 (defun mh-previous-page (&optional lines)
900 "Display next page in message.
901
902 You can give this command a prefix argument that specifies the number of LINES
903 to scroll."
904 (interactive "P")
905 (mh-in-show-buffer (mh-show-buffer)
906 (scroll-down lines)))
907
908 (defun mh-previous-undeleted-msg (&optional count wait-after-complaining-flag)
909 "Display previous message.
910
911 This command can be given a prefix argument COUNT to specify how many unread
912 messages to skip.
913
914 In a program, pause for a second after printing message if we are at the last
915 undeleted message and optional argument WAIT-AFTER-COMPLAINING-FLAG is
916 non-nil."
917 (interactive "p")
918 (setq mh-next-direction 'backward)
919 (beginning-of-line)
920 (cond ((re-search-backward mh-scan-good-msg-regexp nil t count)
921 (mh-maybe-show))
922 (t (message "No previous undeleted message")
923 (if wait-after-complaining-flag (sit-for 1)))))
924
925 (defun mh-previous-unread-msg (&optional count)
926 "Display previous unread message.
927
928 This command can be given a prefix argument COUNT to specify how many unread
929 messages to skip."
930 (interactive "p")
931 (unless (> count 0)
932 (error "The function mh-previous-unread-msg expects positive argument"))
933 (setq count (1- count))
934 (let ((unread-sequence (cdr (assoc mh-unseen-seq mh-seq-list)))
935 (cur-msg (mh-get-msg-num nil)))
936 (cond ((and (not cur-msg) (not (bobp))
937 ;; If we are at the end of the buffer back up one line and go
938 ;; to unread message after that.
939 (progn
940 (forward-line -1)
941 (setq cur-msg (mh-get-msg-num nil)))
942 nil))
943 ((or (null unread-sequence) (not cur-msg))
944 ;; No unread message or there aren't any messages in buffer...
945 (message "No more unread messages"))
946 ((progn
947 ;; Skip count messages...
948 (while (and unread-sequence (>= (car unread-sequence) cur-msg))
949 (setq unread-sequence (cdr unread-sequence)))
950 (while (> count 0)
951 (setq unread-sequence (cdr unread-sequence))
952 (setq count (1- count)))
953 (not (car unread-sequence)))
954 (message "No more unread messages"))
955 (t (loop for msg in unread-sequence
956 when (mh-goto-msg msg t) return nil
957 finally (message "No more unread messages"))))))
958
959 (defun mh-goto-next-button (backward-flag &optional criterion)
960 "Search for next button satisfying criterion.
961 If BACKWARD-FLAG is non-nil search backward in the buffer for a mime button. If
962 CRITERION is a function or a symbol which has a function binding then that
963 function must return non-nil at the button we stop."
964 (unless (or (and (symbolp criterion) (fboundp criterion))
965 (functionp criterion))
966 (setq criterion (lambda (x) t)))
967 ;; Move to the next button in the buffer satisfying criterion
968 (goto-char (or (save-excursion
969 (beginning-of-line)
970 ;; Find point before current button
971 (let ((point-before-current-button
972 (save-excursion
973 (while (get-text-property (point) 'mh-data)
974 (unless (= (forward-line
975 (if backward-flag 1 -1))
976 0)
977 (if backward-flag
978 (goto-char (point-min))
979 (goto-char (point-max)))))
980 (point))))
981 ;; Skip over current button
982 (while (and (get-text-property (point) 'mh-data)
983 (not (if backward-flag (bobp) (eobp))))
984 (forward-line (if backward-flag -1 1)))
985 ;; Stop at next MIME button if any exists.
986 (block loop
987 (while (/= (progn
988 (unless (= (forward-line
989 (if backward-flag -1 1))
990 0)
991 (if backward-flag
992 (goto-char (point-max))
993 (goto-char (point-min)))
994 (beginning-of-line))
995 (point))
996 point-before-current-button)
997 (when (and (get-text-property (point) 'mh-data)
998 (funcall criterion (point)))
999 (return-from loop (point))))
1000 nil)))
1001 (point))))
1002
1003 (defun mh-next-button (&optional backward-flag)
1004 "Go to the next button.
1005
1006 If the end of the buffer is reached then the search wraps over to the start of
1007 the buffer.
1008
1009 If an optional prefix argument BACKWARD-FLAG is given, the cursor will move to
1010 the previous button."
1011 (interactive (list current-prefix-arg))
1012 (unless mh-showing-mode
1013 (mh-show))
1014 (mh-in-show-buffer (mh-show-buffer)
1015 (mh-goto-next-button backward-flag)))
1016
1017 (defun mh-prev-button ()
1018 "Go to the previous button.
1019
1020 If the beginning of the buffer is reached then the search wraps over to the
1021 end of the buffer."
1022 (interactive)
1023 (mh-next-button t))
1024
1025 (defun mh-folder-mime-action (part-index action include-security-flag)
1026 "Go to PART-INDEX and carry out ACTION.
1027 If PART-INDEX is nil then go to the next part in the buffer. The search for
1028 the next buffer wraps around if end of buffer is reached. If argument
1029 INCLUDE-SECURITY-FLAG is non-nil then include security info buttons when
1030 searching for a suitable parts."
1031 (unless mh-showing-mode
1032 (mh-show))
1033 (mh-in-show-buffer (mh-show-buffer)
1034 (let ((criterion
1035 (cond (part-index
1036 (lambda (p)
1037 (let ((part (get-text-property p 'mh-part)))
1038 (and (integerp part) (= part part-index)))))
1039 (t (lambda (p)
1040 (if include-security-flag
1041 (get-text-property p 'mh-data)
1042 (integerp (get-text-property p 'mh-part)))))))
1043 (point (point)))
1044 (cond ((and (get-text-property point 'mh-part)
1045 (or (null part-index)
1046 (= (get-text-property point 'mh-part) part-index)))
1047 (funcall action))
1048 ((and (get-text-property point 'mh-data)
1049 include-security-flag
1050 (null part-index))
1051 (funcall action))
1052 (t
1053 (mh-goto-next-button nil criterion)
1054 (if (= (point) point)
1055 (message "No matching MIME part found")
1056 (funcall action)))))))
1057
1058 (defun mh-folder-toggle-mime-part (part-index)
1059 "View attachment.
1060
1061 This command displays (or hides) the attachment associated with the button
1062 under the cursor. If the cursor is not located over a button, then the cursor
1063 first moves to the next button, wrapping to the beginning of the message if
1064 necessary. This command has the advantage over related commands of working
1065 from the MH-Folder buffer.
1066
1067 You can also provide a numeric prefix argument PART-INDEX to view the
1068 attachment labeled with that number. If Emacs does not know how to display the
1069 attachment, then Emacs offers to save the attachment in a file."
1070 (interactive "P")
1071 (when (consp part-index) (setq part-index (car part-index)))
1072 (mh-folder-mime-action part-index #'mh-press-button t))
1073
1074 (defun mh-folder-inline-mime-part (part-index)
1075 "Show attachment verbatim.
1076
1077 You can view the raw contents of an attachment with this command. This command
1078 displays (or hides) the contents of the attachment associated with the button
1079 under the cursor verbatim. If the cursor is not located over a button, then
1080 the cursor first moves to the next button, wrapping to the beginning of the
1081 message if necessary.
1082
1083 You can also provide a numeric prefix argument PART-INDEX to view the
1084 attachment labeled with that number."
1085 (interactive "P")
1086 (when (consp part-index) (setq part-index (car part-index)))
1087 (mh-folder-mime-action part-index #'mh-mime-inline-part nil))
1088
1089 (defun mh-folder-save-mime-part (part-index)
1090 "Save (output) attachment.
1091
1092 This command saves the attachment associated with the button under the cursor.
1093 If the cursor is not located over a button, then the cursor first moves to the
1094 next button, wrapping to the beginning of the message if necessary.
1095
1096 You can also provide a numeric prefix argument PART-INDEX to save the
1097 attachment labeled with that number.
1098
1099 This command prompts you for a filename and suggests a specific name if it is
1100 available."
1101 (interactive "P")
1102 (when (consp part-index) (setq part-index (car part-index)))
1103 (mh-folder-mime-action part-index #'mh-mime-save-part nil))
1104
1105 (defvar mh-thread-scan-line-map-stack)
1106
1107 (defun mh-reset-threads-and-narrowing ()
1108 "Reset all variables pertaining to threads and narrowing.
1109 Also removes all content from the folder buffer."
1110 (setq mh-view-ops ())
1111 (setq mh-folder-view-stack ())
1112 (setq mh-thread-scan-line-map-stack ())
1113 (let ((buffer-read-only nil)) (erase-buffer)))
1114
1115 (defun mh-rescan-folder (&optional range dont-exec-pending)
1116 "Rescan folder\\<mh-folder-mode-map>.
1117
1118 This command is useful to grab all messages in your \"+inbox\" after
1119 processing your new mail for the first time. If you don't want to rescan the
1120 entire folder, this command will accept a RANGE. Check the documentation of
1121 `mh-interactive-range' to see how RANGE is read in interactive use.
1122
1123 This command will ask if you want to process refiles or deletes first and then
1124 either run \\[mh-execute-commands] for you or undo the pending refiles and
1125 deletes, which are lost.
1126
1127 In a program, the processing of outstanding commands is not performed if
1128 DONT-EXEC-PENDING is non-nil."
1129 (interactive (list (if current-prefix-arg
1130 (mh-read-range "Rescan" mh-current-folder t nil t
1131 mh-interpret-number-as-range-flag)
1132 nil)))
1133 (setq mh-next-direction 'forward)
1134 (let ((threaded-flag (memq 'unthread mh-view-ops)))
1135 (mh-scan-folder mh-current-folder (or range "all") dont-exec-pending)
1136 (cond (threaded-flag (mh-toggle-threads))
1137 (mh-index-data (mh-index-insert-folder-headers)))))
1138
1139 (defun mh-write-msg-to-file (message file no-header)
1140 "Append MESSAGE to end of FILE\\<mh-folder-mode-map>.
1141
1142 You are prompted for the filename. If the file already exists, the message is
1143 appended to it. You can also write the message to the file without the header
1144 by specifying a prefix argument NO-HEADER. Subsequent writes to the same file
1145 can be made with the command \\[mh-refile-or-write-again]."
1146 (interactive
1147 (list (mh-get-msg-num t)
1148 (let ((default-dir (if (eq 'write (car mh-last-destination-write))
1149 (file-name-directory
1150 (car (cdr mh-last-destination-write)))
1151 default-directory)))
1152 (read-file-name (format "Save message%s in file: "
1153 (if current-prefix-arg " body" ""))
1154 default-dir
1155 (if (eq 'write (car mh-last-destination-write))
1156 (car (cdr mh-last-destination-write))
1157 (expand-file-name "mail.out" default-dir))))
1158 current-prefix-arg))
1159 (let ((msg-file-to-output (mh-msg-filename message))
1160 (output-file (mh-expand-file-name file)))
1161 (setq mh-last-destination (list 'write file (if no-header 'no-header))
1162 mh-last-destination-write mh-last-destination)
1163 (save-excursion
1164 (set-buffer (get-buffer-create mh-temp-buffer))
1165 (erase-buffer)
1166 (insert-file-contents msg-file-to-output)
1167 (goto-char (point-min))
1168 (if no-header (search-forward "\n\n"))
1169 (append-to-file (point) (point-max) output-file))))
1170
1171 (defun mh-toggle-showing ()
1172 "Toggle the scanning mode/showing mode of displaying messages."
1173 (interactive)
1174 (if mh-showing-mode
1175 (mh-set-scan-mode)
1176 (mh-show)))
1177
1178 (defun mh-undo (range)
1179 "Undo pending deletes or refiles in RANGE.
1180
1181 If you've deleted a message or refiled it, but changed your mind, you can
1182 cancel the action before you've executed it. Use this command to undo a refile
1183 on or deletion of a single message. You can also undo refiles and deletes for
1184 messages that are found in a given RANGE.
1185
1186 Check the documentation of `mh-interactive-range' to see how RANGE is read in
1187 interactive use."
1188 (interactive (list (mh-interactive-range "Undo")))
1189 (cond ((numberp range)
1190 (let ((original-position (point)))
1191 (beginning-of-line)
1192 (while (not (or (looking-at mh-scan-deleted-msg-regexp)
1193 (looking-at mh-scan-refiled-msg-regexp)
1194 (and (eq mh-next-direction 'forward) (bobp))
1195 (and (eq mh-next-direction 'backward)
1196 (save-excursion (forward-line) (eobp)))))
1197 (forward-line (if (eq mh-next-direction 'forward) -1 1)))
1198 (if (or (looking-at mh-scan-deleted-msg-regexp)
1199 (looking-at mh-scan-refiled-msg-regexp))
1200 (progn
1201 (mh-undo-msg (mh-get-msg-num t))
1202 (mh-maybe-show))
1203 (goto-char original-position)
1204 (error "Nothing to undo"))))
1205 (t (mh-iterate-on-range () range
1206 (mh-undo-msg nil))))
1207 (if (not (mh-outstanding-commands-p))
1208 (mh-set-folder-modified-p nil)))
1209
1210
1211 (defun mh-folder-line-matches-show-buffer-p ()
1212 "Return t if the message under point in folder-mode is in the show buffer.
1213 Return nil in any other circumstance (no message under point, no show buffer,
1214 the message in the show buffer doesn't match."
1215 (and (eq major-mode 'mh-folder-mode)
1216 (mh-get-msg-num nil)
1217 mh-show-buffer
1218 (get-buffer mh-show-buffer)
1219 (buffer-file-name (get-buffer mh-show-buffer))
1220 (string-match ".*/\\([0-9]+\\)$"
1221 (buffer-file-name (get-buffer mh-show-buffer)))
1222 (string-equal
1223 (match-string 1 (buffer-file-name (get-buffer mh-show-buffer)))
1224 (int-to-string (mh-get-msg-num nil)))))
1225
1226 (eval-when-compile (require 'gnus))
1227
1228 (defmacro mh-macro-expansion-time-gnus-version ()
1229 "Return Gnus version available at macro expansion time.
1230 The macro evaluates the Gnus version at macro expansion time. If MH-E was
1231 compiled then macro expansion happens at compile time."
1232 gnus-version)
1233
1234 (defun mh-run-time-gnus-version ()
1235 "Return Gnus version available at run time."
1236 (require 'gnus)
1237 gnus-version)
1238
1239 ;;;###autoload
1240 (defun mh-version ()
1241 "Display version information about MH-E and the MH mail handling system."
1242 (interactive)
1243 (set-buffer (get-buffer-create mh-info-buffer))
1244 (erase-buffer)
1245 ;; MH-E version.
1246 (insert "MH-E " mh-version "\n\n")
1247 ;; MH-E compilation details.
1248 (insert "MH-E compilation details:\n")
1249 (let* ((compiled-mhe (byte-code-function-p (symbol-function 'mh-version)))
1250 (gnus-compiled-version (if compiled-mhe
1251 (mh-macro-expansion-time-gnus-version)
1252 "N/A")))
1253 (insert " Byte compiled:\t\t" (if compiled-mhe "yes" "no") "\n"
1254 " Gnus (compile-time):\t" gnus-compiled-version "\n"
1255 " Gnus (run-time):\t" (mh-run-time-gnus-version) "\n\n"))
1256 ;; Emacs version.
1257 (insert (emacs-version) "\n\n")
1258 ;; MH version.
1259 (if mh-variant-in-use
1260 (insert mh-variant-in-use "\n"
1261 " mh-progs:\t" mh-progs "\n"
1262 " mh-lib:\t" mh-lib "\n"
1263 " mh-lib-progs:\t" mh-lib-progs "\n\n")
1264 (insert "No MH variant detected\n"))
1265 ;; Linux version.
1266 (condition-case ()
1267 (call-process "uname" nil t nil "-a")
1268 (file-error))
1269 (goto-char (point-min))
1270 (display-buffer mh-info-buffer))
1271
1272 (defun mh-parse-flist-output-line (line &optional current-folder)
1273 "Parse LINE to generate folder name, unseen messages and total messages.
1274 If CURRENT-FOLDER is non-nil then it contains the current folder name and it is
1275 used to avoid problems in corner cases involving folders whose names end with a
1276 '+' character."
1277 (with-temp-buffer
1278 (insert line)
1279 (goto-char (point-max))
1280 (let (folder unseen total p)
1281 (when (search-backward " out of " (point-min) t)
1282 (setq total (read-from-string
1283 (buffer-substring-no-properties
1284 (match-end 0) (line-end-position))))
1285 (when (search-backward " in sequence " (point-min) t)
1286 (setq p (point))
1287 (when (search-backward " has " (point-min) t)
1288 (setq unseen (read-from-string (buffer-substring-no-properties
1289 (match-end 0) p)))
1290 (while (eq (char-after) ? )
1291 (backward-char))
1292 (setq folder (buffer-substring-no-properties
1293 (point-min) (1+ (point))))
1294 (when (and (equal (aref folder (1- (length folder))) ?+)
1295 (equal current-folder folder))
1296 (setq folder (substring folder 0 (1- (length folder)))))
1297 (values (format "+%s" folder) (car unseen) (car total))))))))
1298
1299 (defun mh-folder-size-folder (folder)
1300 "Find size of FOLDER using `folder'."
1301 (with-temp-buffer
1302 (let ((u (length (cdr (assoc mh-unseen-seq
1303 (mh-read-folder-sequences folder nil))))))
1304 (call-process (expand-file-name "folder" mh-progs) nil t nil
1305 "-norecurse" folder)
1306 (goto-char (point-min))
1307 (if (re-search-forward " has \\([0-9]+\\) " nil t)
1308 (values (car (read-from-string (match-string 1))) u folder)
1309 (values 0 u folder)))))
1310
1311 (defun mh-folder-size-flist (folder)
1312 "Find size of FOLDER using `flist'."
1313 (with-temp-buffer
1314 (call-process (expand-file-name "flist" mh-progs) nil t nil "-showzero"
1315 "-norecurse" folder "-sequence" (symbol-name mh-unseen-seq))
1316 (goto-char (point-min))
1317 (multiple-value-bind (folder unseen total)
1318 (mh-parse-flist-output-line
1319 (buffer-substring (point) (line-end-position)))
1320 (values total unseen folder))))
1321
1322 (defun mh-folder-size (folder)
1323 "Find size of FOLDER."
1324 (if mh-flists-present-flag
1325 (mh-folder-size-flist folder)
1326 (mh-folder-size-folder folder)))
1327
1328 (defun mh-visit-folder (folder &optional range index-data)
1329 "Visit FOLDER.
1330
1331 When you want to read the messages that you have refiled into folders, use
1332 this command to visit the folder. You are prompted for the folder name.
1333
1334 The folder buffer will show just unseen messages if there are any; otherwise,
1335 it will show all the messages in the buffer as long there are fewer than
1336 `mh-large-folder' messages. If there are more, then you are prompted for a
1337 range of messages to scan.
1338
1339 You can provide a prefix argument in order to specify a RANGE of messages to
1340 show when you visit the folder. In this case, regions are not used to specify
1341 the range and `mh-large-folder' is ignored. Check the documentation of
1342 `mh-interactive-range' to see how RANGE is read in interactive use.
1343
1344 Note that this command can also be used to create folders. If you specify a
1345 folder that does not exist, you will be prompted to create it.
1346
1347 Do not call this function from outside MH-E; use \\[mh-rmail] instead.
1348
1349 If, in a program, RANGE is nil (the default), then all messages in FOLDER are
1350 displayed. If an index buffer is being created then INDEX-DATA is used to
1351 initialize the index buffer specific data structures."
1352 (interactive (let ((folder-name (mh-prompt-for-folder "Visit" mh-inbox t)))
1353 (list folder-name
1354 (mh-read-range "Scan" folder-name t nil
1355 current-prefix-arg
1356 mh-interpret-number-as-range-flag))))
1357 (let ((config (current-window-configuration))
1358 (current-buffer (current-buffer))
1359 (threaded-view-flag mh-show-threads-flag))
1360 (delete-other-windows)
1361 (save-excursion
1362 (when (get-buffer folder)
1363 (set-buffer folder)
1364 (setq threaded-view-flag (memq 'unthread mh-view-ops))))
1365 (when index-data
1366 (mh-make-folder folder)
1367 (setq mh-index-data (car index-data)
1368 mh-index-msg-checksum-map (make-hash-table :test #'equal)
1369 mh-index-checksum-origin-map (make-hash-table :test #'equal))
1370 (mh-index-update-maps folder (cadr index-data))
1371 (mh-index-create-sequences))
1372 (mh-scan-folder folder (or range "all"))
1373 (cond ((and threaded-view-flag
1374 (save-excursion
1375 (goto-char (point-min))
1376 (or (null mh-large-folder)
1377 (not (equal (forward-line (1+ mh-large-folder)) 0))
1378 (and (message "Not threading since the number of messages exceeds `mh-large-folder'")
1379 nil))))
1380 (mh-toggle-threads))
1381 (mh-index-data
1382 (mh-index-insert-folder-headers)))
1383 (unless (eq current-buffer (current-buffer))
1384 (setq mh-previous-window-config config)))
1385 nil)
1386
1387
1388 (defun mh-update-sequences ()
1389 "Flush MH-E's state out to MH.
1390 This function updates the sequence specified by your \"Unseen-Sequence:\"
1391 profile component, \"cur\", and the sequence listed by the `mh-tick-seq'
1392 option which is \"tick\" by default. The message at the cursor is used for
1393 \"cur\"."
1394 (interactive)
1395 ;; mh-update-sequences is the opposite of mh-read-folder-sequences,
1396 ;; which updates MH-E's state from MH.
1397 (let ((folder-set (mh-update-unseen))
1398 (new-cur (mh-get-msg-num nil)))
1399 (if new-cur
1400 (let ((seq-entry (mh-find-seq 'cur)))
1401 (mh-remove-cur-notation)
1402 (setcdr seq-entry
1403 (list new-cur)) ;delete-seq-locally, add-msgs-to-seq
1404 (mh-define-sequence 'cur (list new-cur))
1405 (beginning-of-line)
1406 (if (looking-at mh-scan-good-msg-regexp)
1407 (mh-notate-cur)))
1408 (or folder-set
1409 (save-excursion
1410 ;; psg - mh-current-folder is nil if mh-summary-height < 4 !
1411 ;; So I added this sanity check.
1412 (if (stringp mh-current-folder)
1413 (mh-exec-cmd-quiet t "folder" mh-current-folder "-fast")
1414 (mh-exec-cmd-quiet t "folder" "-fast")))))))
1415
1416 \f
1417
1418 ;;; Support routines.
1419
1420 (defun mh-delete-a-msg (message)
1421 "Delete MESSAGE.
1422 If MESSAGE is nil then the message at point is deleted.
1423
1424 The hook `mh-delete-msg-hook' is called after you mark a message for deletion.
1425 For example, a past maintainer of MH-E used this once when he kept statistics
1426 on his mail usage."
1427 (save-excursion
1428 (if (numberp message)
1429 (mh-goto-msg message nil t)
1430 (beginning-of-line)
1431 (setq message (mh-get-msg-num t)))
1432 (if (looking-at mh-scan-refiled-msg-regexp)
1433 (error "Message %d is refiled. Undo refile before deleting" message))
1434 (if (looking-at mh-scan-deleted-msg-regexp)
1435 nil
1436 (mh-set-folder-modified-p t)
1437 (setq mh-delete-list (cons message mh-delete-list))
1438 (mh-notate nil mh-note-deleted mh-cmd-note)
1439 (run-hooks 'mh-delete-msg-hook))))
1440
1441 (defun mh-refile-a-msg (message folder)
1442 "Refile MESSAGE in FOLDER.
1443 If MESSAGE is nil then the message at point is refiled.
1444
1445 Folder is a symbol, not a string.
1446 The hook `mh-refile-msg-hook' is called after a message is marked to be
1447 refiled."
1448 (save-excursion
1449 (if (numberp message)
1450 (mh-goto-msg message nil t)
1451 (beginning-of-line)
1452 (setq message (mh-get-msg-num t)))
1453 (cond ((looking-at mh-scan-deleted-msg-regexp)
1454 (error "Message %d is deleted. Undo delete before moving" message))
1455 ((looking-at mh-scan-refiled-msg-regexp)
1456 (if (y-or-n-p
1457 (format "Message %d already refiled. Copy to %s as well? "
1458 message folder))
1459 (mh-exec-cmd "refile" (mh-get-msg-num t) "-link"
1460 "-src" mh-current-folder
1461 (symbol-name folder))
1462 (message "Message not copied")))
1463 (t
1464 (mh-set-folder-modified-p t)
1465 (cond ((null (assoc folder mh-refile-list))
1466 (push (list folder message) mh-refile-list))
1467 ((not (member message (cdr (assoc folder mh-refile-list))))
1468 (push message (cdr (assoc folder mh-refile-list)))))
1469 (mh-notate nil mh-note-refiled mh-cmd-note)
1470 (run-hooks 'mh-refile-msg-hook)))))
1471
1472 (defun mh-next-msg (&optional wait-after-complaining-flag)
1473 "Move backward or forward to the next undeleted message in the buffer.
1474 If optional argument WAIT-AFTER-COMPLAINING-FLAG is non-nil and we are at the
1475 last message, then wait for a second after telling the user that there aren't
1476 any more unread messages."
1477 (if (eq mh-next-direction 'forward)
1478 (mh-next-undeleted-msg 1 wait-after-complaining-flag)
1479 (mh-previous-undeleted-msg 1 wait-after-complaining-flag)))
1480
1481 (defun mh-next-unread-msg (&optional count)
1482 "Display next unread message.
1483
1484 This command can be given a prefix argument COUNT to specify how many unread
1485 messages to skip."
1486 (interactive "p")
1487 (unless (> count 0)
1488 (error "The function mh-next-unread-msg expects positive argument"))
1489 (setq count (1- count))
1490 (let ((unread-sequence (reverse (cdr (assoc mh-unseen-seq mh-seq-list))))
1491 (cur-msg (mh-get-msg-num nil)))
1492 (cond ((and (not cur-msg) (not (bobp))
1493 ;; If we are at the end of the buffer back up one line and go
1494 ;; to unread message after that.
1495 (progn
1496 (forward-line -1)
1497 (setq cur-msg (mh-get-msg-num nil)))
1498 nil))
1499 ((or (null unread-sequence) (not cur-msg))
1500 ;; No unread message or there aren't any messages in buffer...
1501 (message "No more unread messages"))
1502 ((progn
1503 ;; Skip messages
1504 (while (and unread-sequence (>= cur-msg (car unread-sequence)))
1505 (setq unread-sequence (cdr unread-sequence)))
1506 (while (> count 0)
1507 (setq unread-sequence (cdr unread-sequence))
1508 (setq count (1- count)))
1509 (not (car unread-sequence)))
1510 (message "No more unread messages"))
1511 (t (loop for msg in unread-sequence
1512 when (mh-goto-msg msg t) return nil
1513 finally (message "No more unread messages"))))))
1514
1515 (defun mh-set-scan-mode ()
1516 "Display the scan listing buffer, but do not show a message."
1517 (if (get-buffer mh-show-buffer)
1518 (delete-windows-on mh-show-buffer))
1519 (mh-showing-mode 0)
1520 (force-mode-line-update)
1521 (if mh-recenter-summary-flag
1522 (mh-recenter nil)))
1523
1524 (defun mh-undo-msg (msg)
1525 "Undo the deletion or refile of one MSG.
1526 If MSG is nil then act on the message at point"
1527 (save-excursion
1528 (if (numberp msg)
1529 (mh-goto-msg msg t t)
1530 (beginning-of-line)
1531 (setq msg (mh-get-msg-num t)))
1532 (cond ((memq msg mh-delete-list)
1533 (setq mh-delete-list (delq msg mh-delete-list)))
1534 (t
1535 (dolist (folder-msg-list mh-refile-list)
1536 (setf (cdr folder-msg-list) (remove msg (cdr folder-msg-list))))
1537 (setq mh-refile-list (loop for x in mh-refile-list
1538 unless (null (cdr x)) collect x))))
1539 (mh-notate nil ? mh-cmd-note)))
1540
1541 \f
1542
1543 ;;; The folder data abstraction.
1544
1545 (defvar mh-index-data-file ".mhe_index"
1546 "MH-E specific file where index seach info is stored.")
1547
1548 (defun mh-make-folder (name)
1549 "Create a new mail folder called NAME.
1550 Make it the current folder."
1551 (switch-to-buffer name)
1552 (setq buffer-read-only nil)
1553 (erase-buffer)
1554 (if mh-adaptive-cmd-note-flag
1555 (mh-set-cmd-note (mh-msg-num-width-to-column (mh-msg-num-width name))))
1556 (setq buffer-read-only t)
1557 (mh-folder-mode)
1558 (mh-set-folder-modified-p nil)
1559 (setq buffer-file-name mh-folder-filename)
1560 (when (and (not mh-index-data)
1561 (file-exists-p (concat buffer-file-name mh-index-data-file)))
1562 (mh-index-read-data))
1563 (mh-make-folder-mode-line))
1564
1565 ;; Ensure new buffers won't get this mode if default-major-mode is nil.
1566 (put 'mh-folder-mode 'mode-class 'special)
1567
1568 \f
1569
1570 ;;; Build mh-folder-mode menu
1571
1572 ;; Menu extracted from mh-menubar.el V1.1 (31 July 2001)
1573 ;; Menus for folder mode: folder, message, sequence (in that order)
1574 ;; folder-mode "Sequence" menu
1575 (easy-menu-define
1576 mh-folder-sequence-menu mh-folder-mode-map "Menu for MH-E folder-sequence."
1577 '("Sequence"
1578 ["Add Message to Sequence..." mh-put-msg-in-seq (mh-get-msg-num nil)]
1579 ["List Sequences for Message" mh-msg-is-in-seq (mh-get-msg-num nil)]
1580 ["Delete Message from Sequence..." mh-delete-msg-from-seq
1581 (mh-get-msg-num nil)]
1582 ["List Sequences in Folder..." mh-list-sequences t]
1583 ["Delete Sequence..." mh-delete-seq t]
1584 ["Narrow to Sequence..." mh-narrow-to-seq t]
1585 ["Widen from Sequence" mh-widen mh-folder-view-stack]
1586 "--"
1587 ["Narrow to Subject Sequence" mh-narrow-to-subject t]
1588 ["Narrow to Tick Sequence" mh-narrow-to-tick
1589 (and mh-tick-seq (mh-seq-msgs (mh-find-seq mh-tick-seq)))]
1590 ["Delete Rest of Same Subject" mh-delete-subject t]
1591 ["Toggle Tick Mark" mh-toggle-tick t]
1592 "--"
1593 ["Push State Out to MH" mh-update-sequences t]))
1594
1595 ;; folder-mode "Message" menu
1596 (easy-menu-define
1597 mh-folder-message-menu mh-folder-mode-map "Menu for MH-E folder-message."
1598 '("Message"
1599 ["Show Message" mh-show (mh-get-msg-num nil)]
1600 ["Show Message with Header" mh-header-display (mh-get-msg-num nil)]
1601 ["Next Message" mh-next-undeleted-msg t]
1602 ["Previous Message" mh-previous-undeleted-msg t]
1603 ["Go to First Message" mh-first-msg t]
1604 ["Go to Last Message" mh-last-msg t]
1605 ["Go to Message by Number..." mh-goto-msg t]
1606 ["Modify Message" mh-modify t]
1607 ["Delete Message" mh-delete-msg (mh-get-msg-num nil)]
1608 ["Refile Message" mh-refile-msg (mh-get-msg-num nil)]
1609 ["Undo Delete/Refile" mh-undo (mh-outstanding-commands-p)]
1610 ["Execute Delete/Refile" mh-execute-commands
1611 (mh-outstanding-commands-p)]
1612 "--"
1613 ["Compose a New Message" mh-send t]
1614 ["Reply to Message..." mh-reply (mh-get-msg-num nil)]
1615 ["Forward Message..." mh-forward (mh-get-msg-num nil)]
1616 ["Redistribute Message..." mh-redistribute (mh-get-msg-num nil)]
1617 ["Edit Message Again" mh-edit-again (mh-get-msg-num nil)]
1618 ["Re-edit a Bounced Message" mh-extract-rejected-mail t]
1619 "--"
1620 ["Copy Message to Folder..." mh-copy-msg (mh-get-msg-num nil)]
1621 ["Print Message" mh-print-msg (mh-get-msg-num nil)]
1622 ["Write Message to File..." mh-write-msg-to-file
1623 (mh-get-msg-num nil)]
1624 ["Pipe Message to Command..." mh-pipe-msg (mh-get-msg-num nil)]
1625 ["Unpack Uuencoded Message..." mh-store-msg (mh-get-msg-num nil)]
1626 ["Burst Digest Message" mh-burst-digest (mh-get-msg-num nil)]))
1627
1628 ;; folder-mode "Folder" menu
1629 (easy-menu-define
1630 mh-folder-folder-menu mh-folder-mode-map "Menu for MH-E folder."
1631 '("Folder"
1632 ["Incorporate New Mail" mh-inc-folder t]
1633 ["Toggle Show/Folder" mh-toggle-showing t]
1634 ["Execute Delete/Refile" mh-execute-commands
1635 (mh-outstanding-commands-p)]
1636 ["Rescan Folder" mh-rescan-folder t]
1637 ["Thread Folder" mh-toggle-threads
1638 (not (memq 'unthread mh-view-ops))]
1639 ["Pack Folder" mh-pack-folder t]
1640 ["Sort Folder" mh-sort-folder t]
1641 "--"
1642 ["List Folders" mh-list-folders t]
1643 ["Visit a Folder..." mh-visit-folder t]
1644 ["View New Messages" mh-index-new-messages t]
1645 ["Search a Folder..." mh-search-folder t]
1646 ["Indexed Search..." mh-index-search t]
1647 "--"
1648 ["Quit MH-E" mh-quit t]))
1649
1650 \f
1651
1652 (defmacro mh-remove-xemacs-horizontal-scrollbar ()
1653 "Get rid of the horizontal scrollbar that XEmacs insists on putting in."
1654 (when mh-xemacs-flag
1655 `(if (and (featurep 'scrollbar)
1656 (fboundp 'set-specifier))
1657 (set-specifier horizontal-scrollbar-visible-p nil
1658 (cons (current-buffer) nil)))))
1659
1660 (defmacro mh-write-file-functions-compat ()
1661 "Return `write-file-functions' if it exists.
1662 Otherwise return `local-write-file-hooks'. This macro exists purely for
1663 compatibility. The former symbol is used in Emacs 21.4 onward while the latter
1664 is used in previous versions and XEmacs."
1665 (if (boundp 'write-file-functions)
1666 ''write-file-functions ;Emacs 21.4
1667 ''local-write-file-hooks)) ;<Emacs 21.4, XEmacs
1668
1669 ;; Avoid compiler warnings in non-bleeding edge versions of Emacs.
1670 (eval-when-compile
1671 (defvar tool-bar-mode)
1672 (defvar tool-bar-map)
1673 (defvar desktop-save-buffer)) ;Emacs 21.4
1674
1675 ;; Register mh-folder-mode as supporting which-function-mode...
1676 (load "which-func" t t)
1677 (when (and (boundp 'which-func-modes)
1678 (not (member 'mh-folder-mode which-func-modes)))
1679 (push 'mh-folder-mode which-func-modes))
1680
1681 (defvar mh-folder-buttons-init-flag nil)
1682
1683 ;; Autoload cookie needed by desktop.el
1684 ;;;###autoload
1685 (define-derived-mode mh-folder-mode fundamental-mode "MH-Folder"
1686 "Major MH-E mode for \"editing\" an MH folder scan listing.\\<mh-folder-mode-map>
1687
1688 You can show the message the cursor is pointing to, and step through the
1689 messages. Messages can be marked for deletion or refiling into another
1690 folder; these commands are executed all at once with a separate command.
1691
1692 Options that control this mode can be changed with \\[customize-group];
1693 specify the \"mh\" group. In particular, please see the `mh-scan-format-file'
1694 option if you wish to modify scan's format.
1695
1696 When a folder is visited, the hook `mh-folder-mode-hook' is run.
1697
1698 Ranges
1699 ======
1700 Many commands that operate on individual messages, such as `mh-forward' or
1701 `mh-refile-msg' take a RANGE argument. This argument can be used in several
1702 ways.
1703
1704 If you provide the prefix argument (\\[universal-argument]) to these commands,
1705 then you will be prompted for the message range. This can be any valid MH
1706 range which can include messages, sequences, and the abbreviations (described
1707 in the mh(1) man page):
1708
1709 <num1>-<num2>
1710 Indicates all messages in the range <num1> to <num2>, inclusive. The range
1711 must be nonempty.
1712
1713 `<num>:N'
1714 `<num>:+N'
1715 `<num>:-N'
1716 Up to N messages beginning with (or ending with) message num. Num may be
1717 any of the predefined symbols: first, prev, cur, next or last.
1718
1719 `first:N'
1720 `prev:N'
1721 `next:N'
1722 `last:N'
1723 The first, previous, next or last messages, if they exist.
1724
1725 `all'
1726 All of the messages.
1727
1728 For example, a range that shows all of these things is `1 2 3 5-10 last:5
1729 unseen'.
1730
1731 If the option `transient-mark-mode' is set to t and you set a region in the
1732 MH-Folder buffer, then the MH-E command will perform the operation on all
1733 messages in that region.
1734
1735 \\{mh-folder-mode-map}"
1736 (mh-do-in-gnu-emacs
1737 (unless mh-folder-buttons-init-flag
1738 (mh-tool-bar-folder-buttons-init)
1739 (setq mh-folder-buttons-init-flag t)))
1740 (make-local-variable 'font-lock-defaults)
1741 (setq font-lock-defaults '(mh-folder-font-lock-keywords t))
1742 (make-local-variable 'desktop-save-buffer)
1743 (setq desktop-save-buffer t)
1744 (mh-make-local-vars
1745 'mh-colors-available-flag (mh-colors-available-p)
1746 ; Do we have colors available
1747 'mh-current-folder (buffer-name) ; Name of folder, a string
1748 'mh-show-buffer (format "show-%s" (buffer-name)) ; Buffer that displays msgs
1749 'mh-folder-filename ; e.g. "/usr/foobar/Mail/inbox/"
1750 (file-name-as-directory (mh-expand-file-name (buffer-name)))
1751 'mh-display-buttons-for-inline-parts-flag
1752 mh-display-buttons-for-inline-parts-flag ; Allow for display of buttons to
1753 ; be toggled.
1754 'mh-arrow-marker (make-marker) ; Marker where arrow is displayed
1755 'overlay-arrow-position nil ; Allow for simultaneous display in
1756 'overlay-arrow-string ">" ; different MH-E buffers.
1757 'mh-showing-mode nil ; Show message also?
1758 'mh-delete-list nil ; List of msgs nums to delete
1759 'mh-refile-list nil ; List of folder names in mh-seq-list
1760 'mh-seq-list nil ; Alist of (seq . msgs) nums
1761 'mh-seen-list nil ; List of displayed messages
1762 'mh-next-direction 'forward ; Direction to move to next message
1763 'mh-view-ops () ; Stack that keeps track of the order
1764 ; in which narrowing/threading has been
1765 ; carried out.
1766 'mh-folder-view-stack () ; Stack of previous views of the
1767 ; folder.
1768 'mh-index-data nil ; If the folder was created by a call
1769 ; to mh-index-search this contains info
1770 ; about the search results.
1771 'mh-index-previous-search nil ; Previous folder and search-regexp
1772 'mh-index-msg-checksum-map nil ; msg -> checksum map
1773 'mh-index-checksum-origin-map nil ; checksum -> ( orig-folder, orig-msg )
1774 'mh-index-sequence-search-flag nil ; folder resulted from sequence search
1775 'mh-first-msg-num nil ; Number of first msg in buffer
1776 'mh-last-msg-num nil ; Number of last msg in buffer
1777 'mh-msg-count nil ; Number of msgs in buffer
1778 'mh-mode-line-annotation nil ; Indicates message range
1779 'mh-sequence-notation-history (make-hash-table)
1780 ; Remember what is overwritten by
1781 ; mh-note-seq.
1782 'imenu-create-index-function 'mh-index-create-imenu-index
1783 ; Setup imenu support
1784 'mh-previous-window-config nil) ; Previous window configuration
1785 (mh-remove-xemacs-horizontal-scrollbar)
1786 (setq truncate-lines t)
1787 (auto-save-mode -1)
1788 (setq buffer-offer-save t)
1789 (mh-make-local-hook (mh-write-file-functions-compat))
1790 (add-hook (mh-write-file-functions-compat) 'mh-execute-commands nil t)
1791 (make-local-variable 'revert-buffer-function)
1792 (make-local-variable 'hl-line-mode) ; avoid pollution
1793 (mh-funcall-if-exists hl-line-mode 1)
1794 (setq revert-buffer-function 'mh-undo-folder)
1795 (or (assq 'mh-showing-mode minor-mode-alist)
1796 (setq minor-mode-alist
1797 (cons '(mh-showing-mode " Show") minor-mode-alist)))
1798 (easy-menu-add mh-folder-sequence-menu)
1799 (easy-menu-add mh-folder-message-menu)
1800 (easy-menu-add mh-folder-folder-menu)
1801 (set (make-local-variable 'tool-bar-map) mh-folder-tool-bar-map)
1802 (mh-funcall-if-exists mh-tool-bar-init :folder)
1803 (if (and mh-xemacs-flag
1804 font-lock-auto-fontify)
1805 (turn-on-font-lock))) ; Force font-lock in XEmacs.
1806
1807 (defun mh-toggle-mime-buttons ()
1808 "Toggle option `mh-display-buttons-for-inline-parts-flag'."
1809 (interactive)
1810 (setq mh-display-buttons-for-inline-parts-flag
1811 (not mh-display-buttons-for-inline-parts-flag))
1812 (mh-show nil t))
1813
1814 (defun mh-colors-available-p ()
1815 "Check if colors are available in the Emacs being used."
1816 (or mh-xemacs-flag
1817 (let ((color-cells
1818 (or (ignore-errors (mh-funcall-if-exists display-color-cells))
1819 (ignore-errors (mh-funcall-if-exists
1820 x-display-color-cells)))))
1821 (and (numberp color-cells) (>= color-cells 8)))))
1822
1823 (defun mh-colors-in-use-p ()
1824 "Check if colors are being used in the folder buffer."
1825 (and mh-colors-available-flag font-lock-mode))
1826
1827 (defun mh-make-local-vars (&rest pairs)
1828 "Initialize local variables according to the variable-value PAIRS."
1829
1830 (while pairs
1831 (set (make-local-variable (car pairs)) (car (cdr pairs)))
1832 (setq pairs (cdr (cdr pairs)))))
1833
1834 (defun mh-restore-desktop-buffer (desktop-buffer-file-name
1835 desktop-buffer-name
1836 desktop-buffer-misc)
1837 "Restore an MH folder buffer specified in a desktop file.
1838 When desktop creates a buffer, DESKTOP-BUFFER-FILE-NAME holds the file name to
1839 visit, DESKTOP-BUFFER-NAME holds the desired buffer name, and
1840 DESKTOP-BUFFER-MISC holds a list of miscellaneous info used by the
1841 `desktop-buffer-handlers' functions."
1842 (mh-find-path)
1843 (mh-visit-folder desktop-buffer-name)
1844 (current-buffer))
1845
1846 ;; desktop-buffer-mode-handlers appeared in Emacs 22.
1847 (if (fboundp 'desktop-buffer-mode-handlers)
1848 (add-to-list 'desktop-buffer-mode-handlers
1849 '(mh-folder-mode . mh-restore-desktop-buffer)))
1850
1851 (defun mh-scan-folder (folder range &optional dont-exec-pending)
1852 "Scan FOLDER over RANGE.
1853
1854 After the scan is performed, switch to the buffer associated with FOLDER.
1855
1856 Check the documentation of `mh-interactive-range' to see how RANGE is read in
1857 interactive use.
1858
1859 The processing of outstanding commands is not performed if DONT-EXEC-PENDING
1860 is non-nil."
1861 (when (stringp range)
1862 (setq range (delete "" (split-string range "[ \t\n]"))))
1863 (cond ((null (get-buffer folder))
1864 (mh-make-folder folder))
1865 (t
1866 (unless dont-exec-pending
1867 (mh-process-or-undo-commands folder)
1868 (mh-reset-threads-and-narrowing))
1869 (switch-to-buffer folder)))
1870 (mh-regenerate-headers range)
1871 (if (zerop (buffer-size))
1872 (if (equal range "all")
1873 (message "Folder %s is empty" folder)
1874 (message "No messages in %s, range %s" folder range))
1875 (mh-goto-cur-msg))
1876 (when (mh-outstanding-commands-p)
1877 (mh-notate-deleted-and-refiled)))
1878
1879 (defun mh-msg-num-width-to-column (width)
1880 "Return the column for notations given message number WIDTH.
1881 Note that columns in Emacs start with 0.
1882
1883 If `mh-scan-format-file' is set to \"Use MH-E scan Format\" this means that
1884 either `mh-scan-format-mh' or `mh-scan-format-nmh' are in use. This function
1885 therefore assumes that the first column is empty (to provide room for the
1886 cursor), the following WIDTH columns contain the message number, and the
1887 column for notations comes after that."
1888 (if (eq mh-scan-format-file t)
1889 (max (1+ width) 2)
1890 (error "%s %s" "Can't call mh-msg-num-width-to-column"
1891 "when mh-scan-format-file is not t")))
1892
1893 (defun mh-set-cmd-note (column)
1894 "Set `mh-cmd-note' to COLUMN.
1895 Note that columns in Emacs start with 0."
1896 (setq mh-cmd-note column))
1897
1898 (defun mh-regenerate-headers (range &optional update)
1899 "Scan folder over RANGE.
1900 If UPDATE, append the scan lines, otherwise replace."
1901 (let ((folder mh-current-folder)
1902 (range (if (and range (atom range)) (list range) range))
1903 scan-start)
1904 (message "Scanning %s..." folder)
1905 (mh-remove-all-notation)
1906 (with-mh-folder-updating (nil)
1907 (if update
1908 (goto-char (point-max))
1909 (delete-region (point-min) (point-max))
1910 (if mh-adaptive-cmd-note-flag
1911 (mh-set-cmd-note (mh-msg-num-width-to-column (mh-msg-num-width
1912 folder)))))
1913 (setq scan-start (point))
1914 (apply #'mh-exec-cmd-output
1915 mh-scan-prog nil
1916 (mh-scan-format)
1917 "-noclear" "-noheader"
1918 "-width" (window-width)
1919 folder range)
1920 (goto-char scan-start)
1921 (cond ((looking-at "scan: no messages in")
1922 (keep-lines mh-scan-valid-regexp)) ; Flush random scan lines
1923 ((looking-at (if (mh-variant-p 'mu-mh)
1924 "scan: message set .* does not exist"
1925 "scan: bad message list "))
1926 (keep-lines mh-scan-valid-regexp))
1927 ((looking-at "scan: ")) ; Keep error messages
1928 (t
1929 (keep-lines mh-scan-valid-regexp))) ; Flush random scan lines
1930 (setq mh-seq-list (mh-read-folder-sequences folder nil))
1931 (mh-notate-user-sequences)
1932 (or update
1933 (setq mh-mode-line-annotation
1934 (if (equal range '("all"))
1935 nil
1936 mh-partial-folder-mode-line-annotation)))
1937 (mh-make-folder-mode-line))
1938 (message "Scanning %s...done" folder)))
1939
1940 (defun mh-generate-new-cmd-note (folder)
1941 "Fix the `mh-cmd-note' value for this FOLDER.
1942
1943 After doing an `mh-get-new-mail' operation in this FOLDER, at least
1944 one line that looks like a truncated message number was found.
1945
1946 Remove the text added by the last `mh-inc' command. It should be the messages
1947 cur-last. Call `mh-set-cmd-note', adjusting the notation column with the width
1948 of the largest message number in FOLDER.
1949
1950 Reformat the message number width on each line in the buffer and trim
1951 the line length to fit in the window.
1952
1953 Rescan the FOLDER in the range cur-last in order to display the
1954 messages that were removed earlier. They should all fit in the scan
1955 line now with no message truncation."
1956 (save-excursion
1957 (let ((maxcol (1- (window-width)))
1958 (old-cmd-note mh-cmd-note)
1959 mh-cmd-note-fmt
1960 msgnum)
1961 ;; Nuke all of the lines just added by the last inc
1962 (delete-char (- (point-max) (point)))
1963 ;; Update the current buffer to reflect the new mh-cmd-note
1964 ;; value needed to display messages.
1965 (mh-set-cmd-note (mh-msg-num-width-to-column (mh-msg-num-width folder)))
1966 (setq mh-cmd-note-fmt (concat "%" (format "%d" mh-cmd-note) "d"))
1967 ;; Cleanup the messages that are in the buffer right now
1968 (goto-char (point-min))
1969 (cond ((memq 'unthread mh-view-ops)
1970 (mh-thread-add-spaces (- mh-cmd-note old-cmd-note)))
1971 (t (while (re-search-forward mh-scan-msg-number-regexp nil 0 1)
1972 ;; reformat the number to fix in mh-cmd-note columns
1973 (setq msgnum (string-to-number
1974 (buffer-substring
1975 (match-beginning 1) (match-end 1))))
1976 (replace-match (format mh-cmd-note-fmt msgnum))
1977 ;; trim the line to fix in the window
1978 (end-of-line)
1979 (let ((eol (point)))
1980 (move-to-column maxcol)
1981 (if (<= (point) eol)
1982 (delete-char (- eol (point))))))))
1983 ;; now re-read the lost messages
1984 (goto-char (point-max))
1985 (prog1 (point)
1986 (mh-regenerate-headers "cur-last" t)))))
1987
1988 (defun mh-get-new-mail (maildrop-name)
1989 "Read new mail from MAILDROP-NAME into the current buffer.
1990 Return in the current buffer."
1991 (let ((point-before-inc (point))
1992 (folder mh-current-folder)
1993 (new-mail-flag nil))
1994 (with-mh-folder-updating (t)
1995 (if maildrop-name
1996 (message "inc %s -file %s..." folder maildrop-name)
1997 (message "inc %s..." folder))
1998 (setq mh-next-direction 'forward)
1999 (goto-char (point-max))
2000 (mh-remove-cur-notation)
2001 (let ((start-of-inc (point)))
2002 (if maildrop-name
2003 ;; I think MH 5 used "-ms-file" instead of "-file",
2004 ;; which would make inc'ing from maildrops fail.
2005 (mh-exec-cmd-output mh-inc-prog nil folder
2006 (mh-scan-format)
2007 "-file" (expand-file-name maildrop-name)
2008 "-width" (window-width)
2009 "-truncate")
2010 (mh-exec-cmd-output mh-inc-prog nil
2011 (mh-scan-format)
2012 "-width" (window-width)))
2013 (if maildrop-name
2014 (message "inc %s -file %s...done" folder maildrop-name)
2015 (message "inc %s...done" folder))
2016 (goto-char start-of-inc)
2017 (cond ((save-excursion
2018 (re-search-forward "^inc: no mail" nil t))
2019 (message "No new mail%s%s" (if maildrop-name " in " "")
2020 (if maildrop-name maildrop-name "")))
2021 ((and (when mh-folder-view-stack
2022 (let ((saved-text (buffer-substring-no-properties
2023 start-of-inc (point-max))))
2024 (delete-region start-of-inc (point-max))
2025 (unwind-protect (mh-widen t)
2026 (mh-remove-cur-notation)
2027 (goto-char (point-max))
2028 (setq start-of-inc (point))
2029 (insert saved-text)
2030 (goto-char start-of-inc))))
2031 nil))
2032 ((re-search-forward "^inc:" nil t) ; Error messages
2033 (error "Error incorporating mail"))
2034 ((and
2035 (equal mh-scan-format-file t)
2036 mh-adaptive-cmd-note-flag
2037 ;; Have we reached an edge condition?
2038 (save-excursion
2039 (re-search-forward mh-scan-msg-overflow-regexp nil 0 1))
2040 (setq start-of-inc (mh-generate-new-cmd-note folder))
2041 nil))
2042 (t
2043 (setq new-mail-flag t)))
2044 (keep-lines mh-scan-valid-regexp) ; Flush random scan lines
2045 (let* ((sequences (mh-read-folder-sequences folder t))
2046 (new-cur (assoc 'cur sequences))
2047 (new-unseen (assoc mh-unseen-seq sequences)))
2048 (unless (assoc 'cur mh-seq-list)
2049 (push (list 'cur) mh-seq-list))
2050 (unless (assoc mh-unseen-seq mh-seq-list)
2051 (push (list mh-unseen-seq) mh-seq-list))
2052 (setcdr (assoc 'cur mh-seq-list) (cdr new-cur))
2053 (setcdr (assoc mh-unseen-seq mh-seq-list) (cdr new-unseen)))
2054 (when (equal (point-max) start-of-inc)
2055 (mh-notate-cur))
2056 (if new-mail-flag
2057 (progn
2058 (mh-make-folder-mode-line)
2059 (when (mh-speed-flists-active-p)
2060 (mh-speed-flists t mh-current-folder))
2061 (when (memq 'unthread mh-view-ops)
2062 (mh-thread-inc folder start-of-inc))
2063 (mh-goto-cur-msg))
2064 (goto-char point-before-inc))
2065 (mh-notate-user-sequences (cons start-of-inc (point-max)))))))
2066
2067 (defun mh-make-folder-mode-line (&optional ignored)
2068 "Set the fields of the mode line for a folder buffer.
2069 The optional argument is now obsolete and IGNORED. It used to be used to pass
2070 in what is now stored in the buffer-local variable `mh-mode-line-annotation'."
2071 (save-excursion
2072 (save-window-excursion
2073 (mh-first-msg)
2074 (let ((new-first-msg-num (mh-get-msg-num nil)))
2075 (when (or (not (memq 'unthread mh-view-ops))
2076 (null mh-first-msg-num)
2077 (null new-first-msg-num)
2078 (< new-first-msg-num mh-first-msg-num))
2079 (setq mh-first-msg-num new-first-msg-num)))
2080 (mh-last-msg)
2081 (let ((new-last-msg-num (mh-get-msg-num nil)))
2082 (when (or (not (memq 'unthread mh-view-ops))
2083 (null mh-last-msg-num)
2084 (null new-last-msg-num)
2085 (> new-last-msg-num mh-last-msg-num))
2086 (setq mh-last-msg-num new-last-msg-num)))
2087 (setq mh-msg-count (if mh-first-msg-num
2088 (count-lines (point-min) (point-max))
2089 0))
2090 (setq mode-line-buffer-identification
2091 (list (format " {%%b%s} %s msg%s"
2092 (if mh-mode-line-annotation
2093 (format "/%s" mh-mode-line-annotation)
2094 "")
2095 (if (zerop mh-msg-count)
2096 "no"
2097 (format "%d" mh-msg-count))
2098 (if (zerop mh-msg-count)
2099 "s"
2100 (cond ((> mh-msg-count 1)
2101 (format "s (%d-%d)" mh-first-msg-num
2102 mh-last-msg-num))
2103 (mh-first-msg-num
2104 (format " (%d)" mh-first-msg-num))
2105 (""))))))
2106 (mh-logo-display))))
2107
2108 (defun mh-add-sequence-notation (msg internal-seq-flag)
2109 "Add sequence notation to the MSG on the current line.
2110 If INTERNAL-SEQ-FLAG is non-nil, then refontify the scan line if font-lock is
2111 turned on."
2112 (with-mh-folder-updating (t)
2113 (save-excursion
2114 (beginning-of-line)
2115 (if internal-seq-flag
2116 (progn
2117 ;; Change the buffer so that if transient-mark-mode is active
2118 ;; and there is an active region it will get deactivated as in
2119 ;; the case of user sequences.
2120 (mh-notate nil nil mh-cmd-note)
2121 (when font-lock-mode
2122 (font-lock-fontify-region (point) (line-end-position))))
2123 (forward-char (+ mh-cmd-note mh-scan-field-destination-offset))
2124 (let ((stack (gethash msg mh-sequence-notation-history)))
2125 (setf (gethash msg mh-sequence-notation-history)
2126 (cons (char-after) stack)))
2127 (mh-notate nil mh-note-seq
2128 (+ mh-cmd-note mh-scan-field-destination-offset))))))
2129
2130 (defun mh-remove-sequence-notation (msg internal-seq-flag &optional all)
2131 "Remove sequence notation from the MSG on the current line.
2132 If INTERNAL-SEQ-FLAG is non-nil, then `font-lock' was used to highlight the
2133 sequence. In that case, no notation needs to be removed. Otherwise the effect
2134 of inserting `mh-note-seq' needs to be reversed.
2135 If ALL is non-nil, then all sequence marks on the scan line are removed."
2136 (with-mh-folder-updating (t)
2137 ;; This takes care of internal sequences...
2138 (mh-notate nil nil mh-cmd-note)
2139 (unless internal-seq-flag
2140 ;; ... and this takes care of user sequences.
2141 (let ((stack (gethash msg mh-sequence-notation-history)))
2142 (while (and all (cdr stack))
2143 (setq stack (cdr stack)))
2144 (when stack
2145 (save-excursion
2146 (beginning-of-line)
2147 (forward-char (+ mh-cmd-note mh-scan-field-destination-offset))
2148 (delete-char 1)
2149 (insert (car stack))))
2150 (setf (gethash msg mh-sequence-notation-history) (cdr stack))))))
2151
2152 (defun mh-remove-cur-notation ()
2153 "Remove old cur notation."
2154 (let ((cur-msg (car (mh-seq-to-msgs 'cur))))
2155 (save-excursion
2156 (when (and cur-msg
2157 (mh-goto-msg cur-msg t t)
2158 (looking-at mh-scan-cur-msg-number-regexp))
2159 (mh-notate nil ? mh-cmd-note)
2160 (setq overlay-arrow-position nil)))))
2161
2162 (defun mh-remove-all-notation ()
2163 "Remove all notations on all scan lines that MH-E introduces."
2164 (save-excursion
2165 (setq overlay-arrow-position nil)
2166 (goto-char (point-min))
2167 (mh-iterate-on-range msg (cons (point-min) (point-max))
2168 (mh-notate nil ? mh-cmd-note)
2169 (mh-remove-sequence-notation msg nil t))
2170 (clrhash mh-sequence-notation-history)))
2171
2172
2173 (defun mh-goto-cur-msg (&optional minimal-changes-flag)
2174 "Position the cursor at the current message.
2175 When optional argument MINIMAL-CHANGES-FLAG is non-nil, the function doesn't
2176 recenter the folder buffer."
2177 (let ((cur-msg (car (mh-seq-to-msgs 'cur))))
2178 (cond ((and cur-msg
2179 (mh-goto-msg cur-msg t t))
2180 (unless minimal-changes-flag
2181 (mh-notate-cur)
2182 (mh-recenter 0)
2183 (mh-maybe-show cur-msg)))
2184 (t
2185 (setq overlay-arrow-position nil)
2186 (message "No current message")))))
2187
2188 (defun mh-process-or-undo-commands (folder)
2189 "If FOLDER has outstanding commands, then either process or discard them.
2190 Called by functions like `mh-sort-folder', so also invalidate show buffer."
2191 (set-buffer folder)
2192 (if (mh-outstanding-commands-p)
2193 (if (or mh-do-not-confirm-flag
2194 (y-or-n-p
2195 "Process outstanding deletes and refiles? "))
2196 (mh-process-commands folder)
2197 (set-buffer folder)
2198 (mh-undo-folder)))
2199 (mh-update-unseen)
2200 (mh-invalidate-show-buffer))
2201
2202 (defun mh-process-commands (folder)
2203 "Process outstanding commands for FOLDER.
2204
2205 This function runs `mh-before-commands-processed-hook' before the commands are
2206 processed and `mh-after-commands-processed-hook' after the commands are
2207 processed."
2208 (message "Processing deletes and refiles for %s..." folder)
2209 (set-buffer folder)
2210 (with-mh-folder-updating (nil)
2211 ;; Run the before hook -- the refile and delete lists are still valid
2212 (run-hooks 'mh-before-commands-processed-hook)
2213
2214 ;; Update the unseen sequence if it exists
2215 (mh-update-unseen)
2216
2217 (let ((redraw-needed-flag mh-index-data)
2218 (folders-changed (list mh-current-folder))
2219 (seq-map (and mh-refile-list mh-refile-preserves-sequences-flag
2220 (mh-create-sequence-map mh-seq-list)))
2221 (dest-map (and mh-refile-list mh-refile-preserves-sequences-flag
2222 (make-hash-table))))
2223 ;; Remove invalid scan lines if we are in an index folder and then remove
2224 ;; the real messages
2225 (when mh-index-data
2226 (mh-index-delete-folder-headers)
2227 (setq folders-changed
2228 (append folders-changed (mh-index-execute-commands))))
2229
2230 ;; Then refile messages
2231 (mh-mapc #'(lambda (folder-msg-list)
2232 (let* ((dest-folder (symbol-name (car folder-msg-list)))
2233 (last (car (mh-translate-range dest-folder "last")))
2234 (msgs (cdr folder-msg-list)))
2235 (push dest-folder folders-changed)
2236 (setq redraw-needed-flag t)
2237 (apply #'mh-exec-cmd
2238 "refile" "-src" folder dest-folder
2239 (mh-coalesce-msg-list msgs))
2240 (mh-delete-scan-msgs msgs)
2241 ;; Preserve sequences in destination folder...
2242 (when mh-refile-preserves-sequences-flag
2243 (clrhash dest-map)
2244 (loop for i from (1+ (or last 0))
2245 for msg in (sort (copy-sequence msgs) #'<)
2246 do (loop for seq-name in (gethash msg seq-map)
2247 do (push i (gethash seq-name dest-map))))
2248 (maphash
2249 #'(lambda (seq msgs)
2250 ;; Can't be run in the background, since the
2251 ;; current folder is changed by mark this could
2252 ;; lead to a race condition with the next refile.
2253 (apply #'mh-exec-cmd "mark"
2254 "-sequence" (symbol-name seq) dest-folder
2255 "-add" (mapcar #'(lambda (x) (format "%s" x))
2256 (mh-coalesce-msg-list msgs))))
2257 dest-map))))
2258 mh-refile-list)
2259 (setq mh-refile-list ())
2260
2261 ;; Now delete messages
2262 (cond (mh-delete-list
2263 (setq redraw-needed-flag t)
2264 (apply 'mh-exec-cmd "rmm" folder
2265 (mh-coalesce-msg-list mh-delete-list))
2266 (mh-delete-scan-msgs mh-delete-list)
2267 (setq mh-delete-list nil)))
2268
2269 ;; Don't need to remove sequences since delete and refile do so.
2270 ;; Mark cur message
2271 (if (> (buffer-size) 0)
2272 (mh-define-sequence 'cur (list (or (mh-get-msg-num nil) "last"))))
2273
2274 ;; Redraw folder buffer if needed
2275 (when (and redraw-needed-flag)
2276 (when (mh-speed-flists-active-p)
2277 (apply #'mh-speed-flists t folders-changed))
2278 (cond ((memq 'unthread mh-view-ops) (mh-thread-inc folder (point-max)))
2279 (mh-index-data (mh-index-insert-folder-headers))))
2280
2281 (and (buffer-file-name (get-buffer mh-show-buffer))
2282 (not (file-exists-p (buffer-file-name (get-buffer mh-show-buffer))))
2283 ;; If "inc" were to put a new msg in this file,
2284 ;; we would not notice, so mark it invalid now.
2285 (mh-invalidate-show-buffer))
2286
2287 (setq mh-seq-list (mh-read-folder-sequences mh-current-folder nil))
2288 (mh-remove-all-notation)
2289 (mh-notate-user-sequences)
2290
2291 ;; Run the after hook -- now folders-changed is valid,
2292 ;; but not the lists of specific messages.
2293 (let ((mh-folders-changed folders-changed))
2294 (run-hooks 'mh-after-commands-processed-hook)))
2295
2296 (message "Processing deletes and refiles for %s...done" folder)))
2297
2298 (defun mh-update-unseen ()
2299 "Synchronize the unseen sequence with MH.
2300 Return non-nil iff the MH folder was set.
2301 The hook `mh-unseen-updated-hook' is called after the unseen sequence
2302 is updated."
2303 (if mh-seen-list
2304 (let* ((unseen-seq (mh-find-seq mh-unseen-seq))
2305 (unseen-msgs (mh-seq-msgs unseen-seq)))
2306 (if unseen-msgs
2307 (progn
2308 (mh-undefine-sequence mh-unseen-seq mh-seen-list)
2309 (run-hooks 'mh-unseen-updated-hook)
2310 (while mh-seen-list
2311 (setq unseen-msgs (delq (car mh-seen-list) unseen-msgs))
2312 (setq mh-seen-list (cdr mh-seen-list)))
2313 (setcdr unseen-seq unseen-msgs)
2314 t) ;since we set the folder
2315 (setq mh-seen-list nil)))))
2316
2317 (defun mh-delete-scan-msgs (msgs)
2318 "Delete the scan listing lines for MSGS."
2319 (save-excursion
2320 (while msgs
2321 (when (mh-goto-msg (car msgs) t t)
2322 (when (memq 'unthread mh-view-ops)
2323 (mh-thread-forget-message (car msgs)))
2324 (mh-delete-line 1))
2325 (setq msgs (cdr msgs)))))
2326
2327 (defun mh-outstanding-commands-p ()
2328 "Return non-nil if there are outstanding deletes or refiles."
2329 (save-excursion
2330 (when (eq major-mode 'mh-show-mode)
2331 (set-buffer mh-show-folder-buffer))
2332 (or mh-delete-list mh-refile-list)))
2333
2334 (defun mh-coalesce-msg-list (messages)
2335 "Given a list of MESSAGES, return a list of message number ranges.
2336 This is the inverse of `mh-read-msg-list', which expands ranges.
2337 Message lists passed to MH programs should be processed by this function
2338 to avoid exceeding system command line argument limits."
2339 (let ((msgs (sort (copy-sequence messages) 'mh-greaterp))
2340 (range-high nil)
2341 (prev -1)
2342 (ranges nil))
2343 (while prev
2344 (if range-high
2345 (if (or (not (numberp prev))
2346 (not (equal (car msgs) (1- prev))))
2347 (progn ;non-sequential, flush old range
2348 (if (eq prev range-high)
2349 (setq ranges (cons range-high ranges))
2350 (setq ranges (cons (format "%s-%s" prev range-high) ranges)))
2351 (setq range-high nil))))
2352 (or range-high
2353 (setq range-high (car msgs))) ;start new or first range
2354 (setq prev (car msgs))
2355 (setq msgs (cdr msgs)))
2356 ranges))
2357
2358 (defun mh-greaterp (msg1 msg2)
2359 "Return the greater of two message indicators MSG1 and MSG2.
2360 Strings are \"smaller\" than numbers.
2361 Valid values are things like \"cur\", \"last\", 1, and 1820."
2362 (if (numberp msg1)
2363 (if (numberp msg2)
2364 (> msg1 msg2)
2365 t)
2366 (if (numberp msg2)
2367 nil
2368 (string-lessp msg2 msg1))))
2369
2370 (defun mh-lessp (msg1 msg2)
2371 "Return the lesser of two message indicators MSG1 and MSG2.
2372 Strings are \"smaller\" than numbers.
2373 Valid values are things like \"cur\", \"last\", 1, and 1820."
2374 (not (mh-greaterp msg1 msg2)))
2375
2376 \f
2377
2378 ;;; Basic sequence handling
2379
2380 (defun mh-delete-seq-locally (seq)
2381 "Remove MH-E's record of SEQ."
2382 (let ((entry (mh-find-seq seq)))
2383 (setq mh-seq-list (delq entry mh-seq-list))))
2384
2385 (defun mh-read-folder-sequences (folder save-refiles)
2386 "Read and return the predefined sequences for a FOLDER.
2387 If SAVE-REFILES is non-nil, then keep the sequences
2388 that note messages to be refiled."
2389 (let ((seqs ()))
2390 (cond (save-refiles
2391 (mh-mapc (function (lambda (seq) ; Save the refiling sequences
2392 (if (mh-folder-name-p (mh-seq-name seq))
2393 (setq seqs (cons seq seqs)))))
2394 mh-seq-list)))
2395 (save-excursion
2396 (if (eq 0 (mh-exec-cmd-quiet nil "mark" folder "-list"))
2397 (progn
2398 ;; look for name in line of form "cur: 4" or "myseq (private): 23"
2399 (while (re-search-forward "^[^: ]+" nil t)
2400 (setq seqs (cons (mh-make-seq (intern (buffer-substring
2401 (match-beginning 0)
2402 (match-end 0)))
2403 (mh-read-msg-list))
2404 seqs)))
2405 (delete-region (point-min) (point))))) ; avoid race with
2406 ; mh-process-daemon
2407 seqs))
2408
2409 (defun mh-read-msg-list ()
2410 "Return a list of message numbers from point to the end of the line.
2411 Expands ranges into set of individual numbers."
2412 (let ((msgs ())
2413 (end-of-line (save-excursion (end-of-line) (point)))
2414 num)
2415 (while (re-search-forward "[0-9]+" end-of-line t)
2416 (setq num (string-to-number (buffer-substring (match-beginning 0)
2417 (match-end 0))))
2418 (cond ((looking-at "-") ; Message range
2419 (forward-char 1)
2420 (re-search-forward "[0-9]+" end-of-line t)
2421 (let ((num2 (string-to-number
2422 (buffer-substring (match-beginning 0)
2423 (match-end 0)))))
2424 (if (< num2 num)
2425 (error "Bad message range: %d-%d" num num2))
2426 (while (<= num num2)
2427 (setq msgs (cons num msgs))
2428 (setq num (1+ num)))))
2429 ((not (zerop num)) ;"pick" outputs "0" to mean no match
2430 (setq msgs (cons num msgs)))))
2431 msgs))
2432
2433 (defun mh-notate-user-sequences (&optional range)
2434 "Mark user-defined sequences in RANGE.
2435
2436 Check the documentation of `mh-interactive-range' to see how RANGE is read in
2437 interactive use; if nil all messages are notated."
2438 (unless range
2439 (setq range (cons (point-min) (point-max))))
2440 (let ((seqs mh-seq-list)
2441 (msg-hash (make-hash-table)))
2442 (dolist (seq seqs)
2443 (dolist (msg (mh-seq-msgs seq))
2444 (push (car seq) (gethash msg msg-hash))))
2445 (mh-iterate-on-range msg range
2446 (loop for seq in (gethash msg msg-hash)
2447 do (mh-add-sequence-notation msg (mh-internal-seq seq))))))
2448
2449 (defvar mh-internal-seqs '(answered cur deleted forwarded printed))
2450
2451 (defun mh-internal-seq (name)
2452 "Return non-nil if NAME is the name of an internal MH-E sequence."
2453 (or (memq name mh-internal-seqs)
2454 (eq name mh-unseen-seq)
2455 (and (mh-colors-in-use-p) mh-tick-seq (eq name mh-tick-seq))
2456 (eq name mh-previous-seq)
2457 (mh-folder-name-p name)))
2458
2459 (defun mh-valid-seq-p (name)
2460 "Return non-nil if NAME is a valid MH sequence name."
2461 (and (symbolp name)
2462 (string-match "^[a-zA-Z][a-zA-Z0-9]*$" (symbol-name name))))
2463
2464 (defun mh-delete-msg-from-seq (range sequence &optional internal-flag)
2465 "Delete RANGE from SEQUENCE.
2466
2467 Check the documentation of `mh-interactive-range' to see how RANGE is read in
2468 interactive use.
2469
2470 In a program, non-nil INTERNAL-FLAG means do not inform MH of the change."
2471 (interactive (list (mh-interactive-range "Delete")
2472 (mh-read-seq-default "Delete from" t)
2473 nil))
2474 (let ((entry (mh-find-seq sequence))
2475 (user-sequence-flag (not (mh-internal-seq sequence)))
2476 (folders-changed (list mh-current-folder))
2477 (msg-list ()))
2478 (when entry
2479 (mh-iterate-on-range msg range
2480 (push msg msg-list)
2481 ;; Calling "mark" repeatedly takes too long. So we will pretend here
2482 ;; that we are just modifying an internal sequence...
2483 (when (memq msg (cdr entry))
2484 (mh-remove-sequence-notation msg (not user-sequence-flag)))
2485 (mh-delete-a-msg-from-seq msg sequence t))
2486 ;; ... and here we will "mark" all the messages at one go.
2487 (unless internal-flag (mh-undefine-sequence sequence msg-list))
2488 (when (and mh-index-data (not internal-flag))
2489 (setq folders-changed
2490 (append folders-changed
2491 (mh-index-delete-from-sequence sequence msg-list))))
2492 (when (and (eq sequence mh-unseen-seq) (mh-speed-flists-active-p))
2493 (apply #'mh-speed-flists t folders-changed)))))
2494
2495 (defun mh-catchup (range)
2496 "Delete RANGE from the \"unseen\" sequence.
2497
2498 Check the documentation of `mh-interactive-range' to see how RANGE is read in
2499 interactive use."
2500 (interactive (list (mh-interactive-range "Catchup"
2501 (cons (point-min) (point-max)))))
2502 (mh-delete-msg-from-seq range mh-unseen-seq))
2503
2504 (defun mh-delete-a-msg-from-seq (msg sequence internal-flag)
2505 "Delete MSG from SEQUENCE.
2506 If INTERNAL-FLAG is non-nil, then do not inform MH of the change."
2507 (let ((entry (mh-find-seq sequence)))
2508 (when (and entry (memq msg (mh-seq-msgs entry)))
2509 (if (not internal-flag)
2510 (mh-undefine-sequence sequence (list msg)))
2511 (setcdr entry (delq msg (mh-seq-msgs entry))))))
2512
2513 (defun mh-undefine-sequence (seq msgs)
2514 "Remove from the SEQ the list of MSGS."
2515 (when (and (mh-valid-seq-p seq) msgs)
2516 (apply #'mh-exec-cmd "mark" mh-current-folder "-delete"
2517 "-sequence" (symbol-name seq) (mh-coalesce-msg-list msgs))))
2518
2519 (defun mh-define-sequence (seq msgs)
2520 "Define the SEQ to contain the list of MSGS.
2521 Do not mark pseudo-sequences or empty sequences.
2522 Signals an error if SEQ is an invalid name."
2523 (if (and msgs
2524 (mh-valid-seq-p seq)
2525 (not (mh-folder-name-p seq)))
2526 (save-excursion
2527 (mh-exec-cmd-error nil "mark" mh-current-folder "-add" "-zero"
2528 "-sequence" (symbol-name seq)
2529 (mh-coalesce-msg-list msgs)))))
2530
2531 (defun mh-seq-containing-msg (msg &optional include-internal-flag)
2532 "Return a list of the sequences containing MSG.
2533 If INCLUDE-INTERNAL-FLAG non-nil, include MH-E internal sequences in list."
2534 (let ((l mh-seq-list)
2535 (seqs ()))
2536 (while l
2537 (and (memq msg (mh-seq-msgs (car l)))
2538 (or include-internal-flag
2539 (not (mh-internal-seq (mh-seq-name (car l)))))
2540 (setq seqs (cons (mh-seq-name (car l)) seqs)))
2541 (setq l (cdr l)))
2542 seqs))
2543
2544 \f
2545
2546 ;;; Build mh-folder-mode keymap:
2547
2548 (suppress-keymap mh-folder-mode-map)
2549
2550 ;; Use defalias to make sure the documented primary key bindings
2551 ;; appear in menu lists.
2552 (defalias 'mh-alt-show 'mh-show)
2553 (defalias 'mh-alt-refile-msg 'mh-refile-msg)
2554 (defalias 'mh-alt-send 'mh-send)
2555 (defalias 'mh-alt-visit-folder 'mh-visit-folder)
2556
2557 ;; Save the `b' binding for a future `back'. Maybe?
2558 (gnus-define-keys mh-folder-mode-map
2559 " " mh-page-msg
2560 "!" mh-refile-or-write-again
2561 "'" mh-toggle-tick
2562 "," mh-header-display
2563 "." mh-alt-show
2564 ";" mh-toggle-mh-decode-mime-flag
2565 ">" mh-write-msg-to-file
2566 "?" mh-help
2567 "E" mh-extract-rejected-mail
2568 "M" mh-modify
2569 "\177" mh-previous-page
2570 "\C-d" mh-delete-msg-no-motion
2571 "\t" mh-index-next-folder
2572 [backtab] mh-index-previous-folder
2573 "\M-\t" mh-index-previous-folder
2574 "\e<" mh-first-msg
2575 "\e>" mh-last-msg
2576 "\ed" mh-redistribute
2577 "\r" mh-show
2578 "^" mh-alt-refile-msg
2579 "c" mh-copy-msg
2580 "d" mh-delete-msg
2581 "e" mh-edit-again
2582 "f" mh-forward
2583 "g" mh-goto-msg
2584 "i" mh-inc-folder
2585 "k" mh-delete-subject-or-thread
2586 "m" mh-alt-send
2587 "n" mh-next-undeleted-msg
2588 "\M-n" mh-next-unread-msg
2589 "o" mh-refile-msg
2590 "p" mh-previous-undeleted-msg
2591 "\M-p" mh-previous-unread-msg
2592 "q" mh-quit
2593 "r" mh-reply
2594 "s" mh-send
2595 "t" mh-toggle-showing
2596 "u" mh-undo
2597 "v" mh-index-visit-folder
2598 "x" mh-execute-commands
2599 "|" mh-pipe-msg)
2600
2601 (gnus-define-keys (mh-folder-map "F" mh-folder-mode-map)
2602 "?" mh-prefix-help
2603 "'" mh-index-ticked-messages
2604 "S" mh-sort-folder
2605 "c" mh-catchup
2606 "f" mh-alt-visit-folder
2607 "i" mh-index-search
2608 "k" mh-kill-folder
2609 "l" mh-list-folders
2610 "n" mh-index-new-messages
2611 "o" mh-alt-visit-folder
2612 "p" mh-pack-folder
2613 "q" mh-index-sequenced-messages
2614 "r" mh-rescan-folder
2615 "s" mh-search-folder
2616 "u" mh-undo-folder
2617 "v" mh-visit-folder)
2618
2619 (define-key mh-folder-mode-map "I" mh-inc-spool-map)
2620
2621 (gnus-define-keys (mh-junk-map "J" mh-folder-mode-map)
2622 "?" mh-prefix-help
2623 "b" mh-junk-blacklist
2624 "w" mh-junk-whitelist)
2625
2626 (gnus-define-keys (mh-ps-print-map "P" mh-folder-mode-map)
2627 "?" mh-prefix-help
2628 "C" mh-ps-print-toggle-color
2629 "F" mh-ps-print-toggle-faces
2630 "f" mh-ps-print-msg-file
2631 "l" mh-print-msg
2632 "p" mh-ps-print-msg)
2633
2634 (gnus-define-keys (mh-sequence-map "S" mh-folder-mode-map)
2635 "'" mh-narrow-to-tick
2636 "?" mh-prefix-help
2637 "d" mh-delete-msg-from-seq
2638 "k" mh-delete-seq
2639 "l" mh-list-sequences
2640 "n" mh-narrow-to-seq
2641 "p" mh-put-msg-in-seq
2642 "s" mh-msg-is-in-seq
2643 "w" mh-widen)
2644
2645 (gnus-define-keys (mh-thread-map "T" mh-folder-mode-map)
2646 "?" mh-prefix-help
2647 "u" mh-thread-ancestor
2648 "p" mh-thread-previous-sibling
2649 "n" mh-thread-next-sibling
2650 "t" mh-toggle-threads
2651 "d" mh-thread-delete
2652 "o" mh-thread-refile)
2653
2654 (gnus-define-keys (mh-limit-map "/" mh-folder-mode-map)
2655 "'" mh-narrow-to-tick
2656 "?" mh-prefix-help
2657 "c" mh-narrow-to-cc
2658 "f" mh-narrow-to-from
2659 "r" mh-narrow-to-range
2660 "s" mh-narrow-to-subject
2661 "t" mh-narrow-to-to
2662 "w" mh-widen)
2663
2664 (gnus-define-keys (mh-extract-map "X" mh-folder-mode-map)
2665 "?" mh-prefix-help
2666 "s" mh-store-msg ;shar
2667 "u" mh-store-msg) ;uuencode
2668
2669 (gnus-define-keys (mh-digest-map "D" mh-folder-mode-map)
2670 " " mh-page-digest
2671 "?" mh-prefix-help
2672 "\177" mh-page-digest-backwards
2673 "b" mh-burst-digest)
2674
2675 (gnus-define-keys (mh-mime-map "K" mh-folder-mode-map)
2676 "?" mh-prefix-help
2677 "a" mh-mime-save-parts
2678 "e" mh-display-with-external-viewer
2679 "i" mh-folder-inline-mime-part
2680 "o" mh-folder-save-mime-part
2681 "t" mh-toggle-mime-buttons
2682 "v" mh-folder-toggle-mime-part
2683 "\t" mh-next-button
2684 [backtab] mh-prev-button
2685 "\M-\t" mh-prev-button)
2686
2687 (cond
2688 (mh-xemacs-flag
2689 (define-key mh-folder-mode-map [button2] 'mh-show-mouse))
2690 (t
2691 (define-key mh-folder-mode-map [mouse-2] 'mh-show-mouse)))
2692
2693 ;; "C-c /" prefix is used in mh-folder-mode by pgp.el and mailcrypt
2694
2695 \f
2696
2697 ;;; Help Messages
2698
2699 ;; If you add a new prefix, add appropriate text to the nil key.
2700 ;;
2701 ;; In general, messages are grouped logically. Taking the main commands for
2702 ;; example, the first line is "ways to view messages," the second line is
2703 ;; "things you can do with messages", and the third is "composing" messages.
2704 ;;
2705 ;; When adding a new prefix, ensure that the help message contains "what" the
2706 ;; prefix is for. For example, if the word "folder" were not present in the
2707 ;; `F' entry, it would not be clear what these commands operated upon.
2708 (defvar mh-help-messages
2709 '((nil "[i]nc, [.]show, [,]show all, [n]ext, [p]revious,\n"
2710 "[d]elete, [o]refile, e[x]ecute,\n"
2711 "[s]end, [r]eply,\n"
2712 "[;]toggle MIME decoding.\n"
2713 "Prefix characters:\n [F]older, [S]equence, [J]unk, MIME [K]eys,"
2714 "\n [T]hread, [/]limit, e[X]tract, [D]igest, [I]nc spools.")
2715
2716 (?F "[l]ist; [v]isit folder;\n"
2717 "[n]ew messages; [']ticked messages; [s]earch; [i]ndexed search;\n"
2718 "[p]ack; [S]ort; [r]escan; [k]ill")
2719 (?P "[p]rint message to [f]ile; old-style [l]pr printing;\n"
2720 "Toggle printing of [C]olors, [F]aces")
2721 (?S "[p]ut message in sequence, [n]arrow, [']narrow to ticked, [w]iden,\n"
2722 "[s]equences, [l]ist,\n"
2723 "[d]elete message from sequence, [k]ill sequence")
2724 (?T "[t]oggle, [d]elete, [o]refile thread")
2725 (?/ "Limit to [c]c, [f]rom, [r]ange, [s]ubject, [t]o; [w]iden")
2726 (?X "un[s]har, [u]udecode message")
2727 (?D "[b]urst digest")
2728 (?K "[v]iew, [i]nline, [o]utput/save MIME part; save [a]ll parts; \n"
2729 "[TAB] next; [SHIFT-TAB] previous")
2730 (?J "[b]lacklist, [w]hitelist message"))
2731 "Key binding cheat sheet.
2732
2733 This is an associative array which is used to show the most common commands.
2734 The key is a prefix char. The value is one or more strings which are
2735 concatenated together and displayed in the minibuffer if ? is pressed after
2736 the prefix character. The special key nil is used to display the
2737 non-prefixed commands.
2738
2739 The substitutions described in `substitute-command-keys' are performed as
2740 well.")
2741
2742 \f
2743
2744 (dolist (mess '("^Cursor not pointing to message$"
2745 "^There is no other window$"))
2746 (add-to-list 'debug-ignored-errors mess))
2747
2748 (provide 'mh-e)
2749
2750 ;; Local Variables:
2751 ;; indent-tabs-mode: nil
2752 ;; sentence-end-double-space: nil
2753 ;; End:
2754
2755 ;; arch-tag: cce884de-bd37-4104-9963-e4439d5ed22b
2756 ;;; mh-e.el ends here