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