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