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