1 ;;; mh-e.el --- GNU Emacs interface to the MH mail system
3 ;; Copyright (C) 1985, 86, 87, 88, 90, 92, 93, 94, 95, 97, 1999,
4 ;; 2000, 01, 02, 03, 2004 Free Software Foundation, Inc.
6 ;; Author: Bill Wohler <wohler@newt.com>
7 ;; Maintainer: Bill Wohler <wohler@newt.com>
11 ;; This file is part of GNU Emacs.
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation; either version 2, or (at your option)
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26 ;; Boston, MA 02111-1307, USA.
31 ;; M-x mh-rmail to read mail. Type C-h m there for a list of commands.
32 ;; C-u M-x mh-rmail to visit any folder.
33 ;; M-x mh-smail to send mail. From within the mail reader, "m" works, too.
35 ;; Your .emacs might benefit from these bindings:
36 ;; (global-set-key "\C-cr" 'mh-rmail)
37 ;; (global-set-key "\C-xm" 'mh-smail)
38 ;; (global-set-key "\C-x4m" 'mh-smail-other-window)
40 ;; MH (Message Handler) is a powerful mail reader.
42 ;; The MH newsgroup is comp.mail.mh; the mailing list is mh-users@ics.uci.edu
43 ;; (send to mh-users-request to be added). See the monthly Frequently Asked
44 ;; Questions posting there for information on getting MH and MH-E:
45 ;; http://www.faqs.org/faqs/mail/mh-faq/part1/preamble.html
47 ;; N.B. MH must have been compiled with the MHE compiler flag or several
48 ;; features necessary for MH-E will be missing from MH commands, specifically
49 ;; the -build switch to repl and forw.
51 ;; MH-E is an Emacs interface to the MH mail system.
53 ;; MH-E is supported in GNU Emacs 20 and 21, with MH 6.8.4 and nmh 1.0.4.
56 ;; mh-e-users@lists.sourceforge.net
57 ;; mh-e-announce@lists.sourceforge.net
58 ;; mh-e-devel@lists.sourceforge.net
60 ;; Subscribe by sending a "subscribe" message to
61 ;; <list>-request@lists.sourceforge.net, or by using the web interface at
62 ;; https://sourceforge.net/mail/?group_id=13357
65 ;; https://sourceforge.net/tracker/?group_id=13357&atid=113357
66 ;; Include the output of M-x mh-version in any bug report.
69 ;; https://sourceforge.net/tracker/?atid=363357&group_id=13357&func=browse
72 ;; https://sourceforge.net/tracker/?group_id=13357&atid=213357
76 ;; Original version for Gosling emacs by Brian Reid, Stanford, 1982.
77 ;; Modified by James Larus, BBN, July 1984 and UCB, 1984 & 1985.
78 ;; Rewritten for GNU Emacs, James Larus, 1985.
79 ;; Modified by Stephen Gildea, 1988.
80 ;; Maintenance picked up by Bill Wohler and the
81 ;; SourceForge Crew <http://mh-e.sourceforge.net/>, 2001.
87 (eval-when-compile (require 'mh-acros))
95 ;; Shush the byte-compiler
96 (defvar font-lock-auto-fontify)
97 (defvar font-lock-defaults)
99 (defconst mh-version "7.81" "Version number of MH-E.")
102 (autoload 'Info-goto-node "info")
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 annotation.")
109 ;;; Scan Line Formats
111 ;;; Parameterize MH-E to work with different scan formats. The defaults work
112 ;;; with the standard MH scan listings, in which the first 4 characters on
113 ;;; the line are the message number, followed by two places for notations.
115 ;; The following scan formats are passed to the scan program if the setting of
116 ;; `mh-scan-format-file' is t. They are identical except the later one makes
117 ;; use of the nmh `decode' function to decode RFC 2047 encodings. If you just
118 ;; want to change the width of the msg number, use the `mh-set-cmd-note'
121 (defvar mh-scan-format-mh
126 "%?(nonnull(comp{to}))%<(mymbox{to})t%>"
127 "%?(nonnull(comp{cc}))%<(mymbox{cc})c%>"
128 "%?(nonnull(comp{bcc}))%<(mymbox{bcc})b%>"
129 "%?(nonnull(comp{newsgroups}))n%>"
131 "%02(mon{date})/%02(mday{date})%<{date} %|*%>"
132 "%<(mymbox{from})%<{to}To:%14(friendly{to})%>%>"
133 "%<(zero)%17(friendly{from})%> "
134 "%{subject}%<{body}<<%{body}%>")
135 "*Scan format string for MH, provided to the scan program via the -format arg.
136 This format is identical to the default except that additional hints for
137 fontification have been added to the fifth column (remember that in Emacs, the
140 The values of the fifth column, in priority order, are: `-' if the message has
141 been replied to, t if an address on the To: line matches one of the
142 mailboxes of the current user, `c' if the Cc: line matches, `b' if the Bcc:
143 line matches, and `n' if a non-empty Newsgroups: header is present.")
145 (defvar mh-scan-format-nmh
150 "%?(nonnull(comp{to}))%<(mymbox{to})t%>"
151 "%?(nonnull(comp{cc}))%<(mymbox{cc})c%>"
152 "%?(nonnull(comp{bcc}))%<(mymbox{bcc})b%>"
153 "%?(nonnull(comp{newsgroups}))n%>"
155 "%02(mon{date})/%02(mday{date})%<{date} %|*%>"
156 "%<(mymbox{from})%<{to}To:%14(decode(friendly{to}))%>%>"
157 "%<(zero)%17(decode(friendly{from}))%> "
158 "%(decode{subject})%<{body}<<%{body}%>")
159 "*Scan format string for nmh.
160 This string is passed to the scan program via the -format arg.
161 This format is identical to the default except that additional hints for
162 fontification have been added to the fifth column (remember that in Emacs, the
165 The values of the fifth column, in priority order, are: `-' if the message has
166 been replied to, t if an address on the To: field matches one of the
167 mailboxes of the current user, `c' if the Cc: field matches, `b' if the Bcc:
168 field matches, and `n' if a non-empty Newsgroups: field is present.")
170 (defvar mh-note-deleted ?D
171 "Deleted messages are marked by this character.
172 See also `mh-scan-deleted-msg-regexp'.")
174 (defvar mh-note-refiled ?^
175 "Refiled messages are marked by this character.
176 See also `mh-scan-refiled-msg-regexp'.")
178 (defvar mh-note-cur ?+
179 "The current message (in MH) is marked by this character.
180 See also `mh-scan-cur-msg-number-regexp'.")
182 (defvar mh-scan-good-msg-regexp "^\\( *[0-9]+\\)[^D^0-9]"
183 "This regexp specifies the scan lines that are 'good' messages.
184 Note that the default setting of `mh-folder-font-lock-keywords' expects this
185 expression to contain at least one parenthesized expression which matches the
186 message number as in the default of \"^\\\\( *[0-9]+\\\\)[^D^0-9]\".")
188 (defvar mh-scan-deleted-msg-regexp "^\\( *[0-9]+\\)D"
189 "This regexp matches deleted messages.
190 Note that the default setting of `mh-folder-font-lock-keywords' expects this
191 expression to contain at least one parenthesized expression which matches the
192 message number as in the default of \"^\\\\( *[0-9]+\\\\)D\".
193 See also `mh-note-deleted'.")
195 (defvar mh-scan-refiled-msg-regexp "^\\( *[0-9]+\\)\\^"
196 "This regexp matches refiled messages.
197 Note that the default setting of `mh-folder-font-lock-keywords' expects this
198 expression to contain at least one parenthesized expression which matches the
199 message number as in the default of \"^\\\\( *[0-9]+\\\\)\\\\^\".
200 See also `mh-note-refiled'.")
202 (defvar mh-scan-valid-regexp "^ *[0-9]"
203 "This regexp matches scan lines for messages (not error messages).")
205 (defvar mh-scan-cur-msg-number-regexp "^\\( *[0-9]+\\+\\).*"
206 "This regexp matches the current message.
207 Note that the default setting of `mh-folder-font-lock-keywords' expects this
208 expression to contain at least one parenthesized expression which matches the
209 message number as in the default of \"^\\\\( *[0-9]+\\\\+\\\\).*\". Don't
210 disable this regexp as it's needed by non-fontifying functions.
211 See also `mh-note-cur'.")
213 (defvar mh-scan-date-regexp "\\([0-9][0-9]/[0-9][0-9]\\)"
214 "This regexp matches a valid date.
215 Note that the default setting of `mh-folder-font-lock-keywords' expects this
216 expression to contain only one parenthesized expression which matches the date
217 field as in the default of \"\\\\([0-9][0-9]/[0-9][0-9]\\\\)\"}.
218 See also `mh-scan-format-regexp'.")
220 (defvar mh-scan-rcpt-regexp "\\(To:\\)\\(..............\\)"
221 "This regexp specifies the recipient in messages you sent.
222 Note that the default setting of `mh-folder-font-lock-keywords'
223 expects this expression to contain two parenthesized expressions. The
224 first is expected to match the `To:' that the default scan format
225 file generates. The second is expected to match the recipient's name
226 as in the default of \"\\\\(To:\\\\)\\\\(..............\\\\)\".")
228 (defvar mh-scan-body-regexp "\\(<<\\([^\n]+\\)?\\)"
229 "This regexp matches the message body fragment displayed in scan lines.
230 Note that the default setting of `mh-folder-font-lock-keywords' expects this
231 expression to contain at least one parenthesized expression which matches the
232 body text as in the default of \"\\\\(<<\\\\([^\\n]+\\\\)?\\\\)\".")
234 (defvar mh-scan-subject-regexp
235 "^ *[0-9]+........[ ]*...................\\([Rr][Ee]\\(\\[[0-9]+\\]\\)?:\\s-*\\)*\\([^<\n]*\\)"
236 "This regexp matches the subject.
237 Note that the default setting of `mh-folder-font-lock-keywords' expects this
238 expression to contain at least three parenthesized expressions. The first is
239 expected to match the `Re:' string, if any. The second matches an optional
240 bracketed number after `Re:', such as in `Re[2]:' (and is thus a
241 sub-expression of the first expression) and the third is expected to match
242 the subject line itself as in the default of \"^ *[0-9]+........[ ]*...................\\\\([Rr][Ee]\\\\(\\\\\\=[[0-9]+\\\\]\\\\)?:\\\\s-*\\\\)*\\\\([^<\\n]*\\\\)\".")
244 (defvar mh-scan-format-regexp
245 (concat "\\([bct]\\)" mh-scan-date-regexp " *\\(..................\\)")
246 "This regexp matches the output of scan.
247 Note that the default setting of `mh-folder-font-lock-keywords' expects this
248 expression to contain at least three parenthesized expressions. The first
249 should match the fontification hint, the second is found in
250 `mh-scan-date-regexp', and the third should match the user name as in the
251 default of \"(concat \"\\\\([bct]\\\\)\" mh-scan-date-regexp
252 \"*\\\\(..................\\\\)\")\".")
256 (defvar mh-folder-font-lock-keywords
258 ;; Folders when displaying index buffer
260 '(0 mh-index-folder-face))
261 ;; Marked for deletion
262 (list (concat mh-scan-deleted-msg-regexp ".*")
263 '(0 mh-folder-deleted-face))
265 (list (concat mh-scan-refiled-msg-regexp ".*")
266 '(0 mh-folder-refiled-face))
268 (list mh-scan-body-regexp '(1 mh-folder-body-face nil t))
269 '(mh-folder-font-lock-subject
270 (1 mh-folder-followup-face append t)
271 (2 mh-folder-subject-face append t))
273 (list mh-scan-cur-msg-number-regexp
274 '(1 mh-folder-cur-msg-number-face))
275 (list mh-scan-good-msg-regexp
276 '(1 mh-folder-msg-number-face)) ;; Msg number
277 (list mh-scan-date-regexp '(1 mh-folder-date-face)) ;; Date
278 (list mh-scan-rcpt-regexp
279 '(1 mh-folder-to-face) ;; To:
280 '(2 mh-folder-address-face)) ;; address
281 ;; scan font-lock name
282 (list mh-scan-format-regexp
283 '(1 mh-folder-date-face)
284 '(3 mh-folder-scan-format-face)))
285 "Regexp keywords used to fontify the MH-Folder buffer.")
287 (defvar mh-scan-cmd-note-width 1
288 "Number of columns consumed by the cmd-note field in `mh-scan-format'.
289 This column will have one of the values: ` ', `D', `^', `+' and where
290 ` ' is the default value,
291 `D' is the `mh-note-deleted' character,
292 `^' is the `mh-note-refiled' character, and
293 `+' is the `mh-note-cur' character.")
295 (defvar mh-scan-destination-width 1
296 "Number of columns consumed by the destination field in `mh-scan-format'.
297 This column will have one of ' ', '%', '-', 't', 'c', 'b', or `n' in it.
298 A ' ' blank space is the default character.
299 A '%' indicates that the message in in a named MH sequence.
300 A '-' indicates that the message has been annotated with a replied field.
301 A 't' indicates that the message contains mymbox in the To: field.
302 A 'c' indicates that the message contains mymbox in the Cc: field.
303 A 'b' indicates that the message contains mymbox in the Bcc: field.
304 A 'n' indicates that the message contains a Newsgroups: field.")
306 (defvar mh-scan-date-width 5
307 "Number of columns consumed by the date field in `mh-scan-format'.
308 This column will typically be of the form mm/dd.")
310 (defvar mh-scan-date-flag-width 1
311 "Number of columns consumed to flag (in)valid dates in `mh-scan-format'.
312 This column will have ` ' for valid and `*' for invalid or missing dates.")
314 (defvar mh-scan-from-mbox-width 17
315 "Number of columns consumed with the \"From:\" line in `mh-scan-format'.
316 This column will have a friendly name or e-mail address of the
317 originator, or a \"To: address\" for outgoing e-mail messages.")
319 (defvar mh-scan-from-mbox-sep-width 2
320 "Number of columns consumed by whitespace after from-mbox in `mh-scan-format'.
321 This column will only ever have spaces in it.")
323 (defvar mh-scan-field-from-start-offset
324 (+ mh-scan-cmd-note-width
325 mh-scan-destination-width
327 mh-scan-date-flag-width)
328 "The offset from the `mh-cmd-note' to find the start of \"From:\" address.")
330 (defvar mh-scan-field-from-end-offset
331 (+ mh-scan-field-from-start-offset mh-scan-from-mbox-width)
332 "The offset from the `mh-cmd-note' to find the end of \"From:\" address.")
334 (defvar mh-scan-field-subject-start-offset
335 (+ mh-scan-cmd-note-width
336 mh-scan-destination-width
338 mh-scan-date-flag-width
339 mh-scan-from-mbox-width
340 mh-scan-from-mbox-sep-width)
341 "The offset from the `mh-cmd-note' to find the start of the subject.")
343 (defun mh-folder-font-lock-subject (limit)
344 "Return MH-E scan subject strings to font-lock between point and LIMIT."
345 (if (not (re-search-forward mh-scan-subject-regexp limit t))
347 (if (match-beginning 1)
348 (set-match-data (list (match-beginning 1) (match-end 3)
349 (match-beginning 1) (match-end 3) nil nil))
350 (set-match-data (list (match-beginning 3) (match-end 3)
351 nil nil (match-beginning 3) (match-end 3))))
356 ;; Fontifify unseen mesages in bold.
358 (defmacro mh-generate-sequence-font-lock (seq prefix face)
359 "Generate the appropriate code to fontify messages in SEQ.
360 PREFIX is used to generate unique names for the variables and functions
361 defined by the macro. So a different prefix should be provided for every
363 FACE is the font-lock face used to display the matching scan lines."
364 (let ((cache (intern (format "mh-folder-%s-seq-cache" prefix)))
365 (func (intern (format "mh-folder-font-lock-%s" prefix))))
368 "Internal cache variable used for font-lock in MH-E.
369 Should only be non-nil through font-lock stepping, and nil once font-lock
370 is done highlighting.")
371 (make-variable-buffer-local ',cache)
374 "Return unseen message lines to font-lock between point and LIMIT."
375 (if (not ,cache) (setq ,cache (mh-seq-msgs (mh-find-seq ,seq))))
376 (let ((cur-msg (mh-get-msg-num nil)))
379 ((>= (point) limit) ;Presumably at end of buffer
382 ((member cur-msg ,cache)
383 (let ((bpoint (progn (beginning-of-line)(point)))
384 (epoint (progn (forward-line 1)(point))))
385 (if (<= limit (point)) (setq ,cache nil))
386 (set-match-data (list bpoint epoint bpoint epoint))
389 ;; move forward one line at a time, checking each message
390 (while (and (= 0 (forward-line 1))
392 (not (member (mh-get-msg-num nil) ,cache))))
393 ;; Examine how we must have exited the loop...
394 (let ((cur-msg (mh-get-msg-num nil)))
395 (cond ((or (<= limit (point))
396 (not (member cur-msg ,cache)))
399 ((member cur-msg ,cache)
400 (let ((bpoint (progn (beginning-of-line) (point)))
401 (epoint (progn (forward-line 1) (point))))
402 (if (<= limit (point)) (setq ,cache nil))
404 (list bpoint epoint bpoint epoint))
407 (setq mh-folder-font-lock-keywords
408 (append mh-folder-font-lock-keywords
409 (list (list ',func (list 1 '',face 'prepend t))))))))
411 (mh-generate-sequence-font-lock mh-unseen-seq unseen bold)
412 (mh-generate-sequence-font-lock mh-tick-seq tick mh-folder-tick-face)
416 ;;; Internal variables:
418 (defvar mh-last-destination nil) ;Destination of last refile or write
420 (defvar mh-last-destination-folder nil) ;Destination of last refile command.
421 (defvar mh-last-destination-write nil) ;Destination of last write command.
423 (defvar mh-folder-mode-map (make-keymap)
424 "Keymap for MH folders.")
426 (defvar mh-arrow-marker nil) ;Marker for arrow display in fringe.
428 (defvar mh-delete-list nil) ;List of msg numbers to delete.
430 (defvar mh-refile-list nil) ;List of folder names in mh-seq-list.
432 (defvar mh-next-direction 'forward) ;Direction to move to next message.
434 (defvar mh-view-ops ()) ;Stack of ops that change the folder
435 ;view (such as narrowing or threading).
436 (defvar mh-folder-view-stack ()) ;Stack of previous folder views.
438 (defvar mh-index-data nil) ;Info about index search results
439 (defvar mh-index-previous-search nil)
440 (defvar mh-index-msg-checksum-map nil)
441 (defvar mh-index-checksum-origin-map nil)
442 (defvar mh-index-sequence-search-flag nil)
444 (defvar mh-first-msg-num nil) ;Number of first msg in buffer.
446 (defvar mh-last-msg-num nil) ;Number of last msg in buffer.
448 (defvar mh-mode-line-annotation nil) ;Message range displayed in buffer.
450 (defvar mh-sequence-notation-history nil)
451 ;Rememeber original notation that
452 ;is overwritten by `mh-note-seq'.
454 (defvar mh-colors-available-flag nil) ;Are colors available?
456 ;;; Macros and generic functions:
458 (defun mh-mapc (function list)
459 "Apply FUNCTION to each element of LIST for side effects only."
461 (funcall function (car list))
462 (setq list (cdr list))))
464 (defun mh-scan-format ()
465 "Return the output format argument for the scan program."
466 (if (equal mh-scan-format-file t)
467 (list "-format" (if (mh-variant-p 'nmh 'mu-mh)
468 (list (mh-update-scan-format
469 mh-scan-format-nmh mh-cmd-note))
470 (list (mh-update-scan-format
471 mh-scan-format-mh mh-cmd-note))))
472 (if (not (equal mh-scan-format-file nil))
473 (list "-form" mh-scan-format-file))))
480 (defun mh-rmail (&optional arg)
481 "Inc(orporate) new mail with MH.
482 Scan an MH folder if ARG is non-nil. This function is an entry point to MH-E,
483 the Emacs interface to the MH mail system."
487 (call-interactively 'mh-visit-folder)
488 (unless (get-buffer mh-inbox)
489 (mh-visit-folder mh-inbox (symbol-name mh-unseen-seq)))
493 (defun mh-nmail (&optional arg)
494 "Check for new mail in inbox folder.
495 Scan an MH folder if ARG is non-nil. This function is an entry point to MH-E,
496 the Emacs interface to the MH mail system."
498 (mh-find-path) ; init mh-inbox
500 (call-interactively 'mh-visit-folder)
501 (mh-visit-folder mh-inbox)))
505 ;;; User executable MH-E commands:
507 (defun mh-delete-msg (range)
508 "Mark the specified RANGE for subsequent deletion and move to the next.
509 Default is the displayed message.
511 Check the documentation of `mh-interactive-range' to see how RANGE is read in
513 (interactive (list (mh-interactive-range "Delete")))
514 (mh-delete-msg-no-motion range)
515 (if (looking-at mh-scan-deleted-msg-regexp) (mh-next-msg)))
517 (defun mh-delete-msg-no-motion (range)
518 "Mark the specified RANGE for subsequent deletion.
520 Check the documentation of `mh-interactive-range' to see how RANGE is read in
522 (interactive (list (mh-interactive-range "Delete")))
523 (mh-iterate-on-range () range
524 (mh-delete-a-msg nil)))
526 (defun mh-execute-commands ()
527 "Process outstanding delete and refile requests."
529 (if mh-folder-view-stack (mh-widen t))
530 (mh-process-commands mh-current-folder)
532 (mh-goto-cur-msg) ; after mh-set-scan-mode for efficiency
533 (mh-make-folder-mode-line)
534 t) ; return t for write-file-functions
536 (defun mh-first-msg ()
537 "Move to the first message."
539 (goto-char (point-min))
540 (while (and (not (eobp)) (not (looking-at mh-scan-valid-regexp)))
543 (defun mh-header-display ()
544 "Show the current message with all its headers.
545 Displays headers that might have been suppressed by setting the
546 variables `mh-clean-message-header-flag' or `mhl-formfile', or by the fallback
547 behavior of scrolling uninteresting headers off the top of the window.
548 Type \"\\[mh-show]\" to show the message normally again."
550 (and (not mh-showing-with-headers)
551 (or mhl-formfile mh-clean-message-header-flag)
552 (mh-invalidate-show-buffer))
553 (let ((mh-decode-mime-flag nil)
555 (mh-clean-message-header-flag nil))
557 (mh-in-show-buffer (mh-show-buffer)
558 (goto-char (point-min))
560 (setq mh-showing-with-headers t)))
562 (defun mh-inc-folder (&optional maildrop-name folder)
563 "Inc(orporate)s new mail into the Inbox folder.
564 Optional argument MAILDROP-NAME specifies an alternate maildrop from the
565 default. The optional argument FOLDER specifies where to incorporate mail
566 instead of the default named by `mh-inbox'.
567 The value of `mh-inc-folder-hook' is a list of functions to be called, with no
568 arguments, after incorporating new mail.
569 Do not call this function from outside MH-E; use \\[mh-rmail] instead."
570 (interactive (list (if current-prefix-arg
572 (read-file-name "inc mail from file: "
574 (if current-prefix-arg
575 (mh-prompt-for-folder "inc mail into" mh-inbox t))))
577 (setq folder mh-inbox))
578 (let ((threading-needed-flag nil))
579 (let ((config (current-window-configuration)))
580 (delete-other-windows)
581 (cond ((not (get-buffer folder))
582 (mh-make-folder folder)
583 (setq threading-needed-flag mh-show-threads-flag)
584 (setq mh-previous-window-config config))
585 ((not (eq (current-buffer) (get-buffer folder)))
586 (switch-to-buffer folder)
587 (setq mh-previous-window-config config))))
588 (mh-get-new-mail maildrop-name)
589 (when (and threading-needed-flag
591 (goto-char (point-min))
592 (or (null mh-large-folder)
593 (not (equal (forward-line (1+ mh-large-folder)) 0))
594 (and (message "Not threading since the number of messages exceeds `mh-large-folder'")
598 (if (and mh-showing-mode (looking-at mh-scan-valid-regexp)) (mh-show))
599 (run-hooks 'mh-inc-folder-hook)))
601 (defun mh-last-msg ()
602 "Move to the last message."
604 (goto-char (point-max))
605 (while (and (not (bobp)) (not (looking-at mh-scan-valid-regexp)))
609 (defun mh-next-undeleted-msg (&optional arg wait-after-complaining-flag)
610 "Move to the next undeleted message ARG in window.
611 If optional argument WAIT-AFTER-COMPLAINING-FLAG is non-nil and we are at the
612 last undeleted message then pause for a second after printing message."
614 (setq mh-next-direction 'forward)
616 (cond ((re-search-forward mh-scan-good-msg-regexp nil t arg)
620 (message "No more undeleted messages")
621 (if wait-after-complaining-flag (sit-for 1)))))
623 (defun mh-folder-from-address ()
624 "Derive folder name from sender.
626 The name of the folder is derived as follows:
628 a) The folder name associated with the first address found in the list
629 `mh-default-folder-list' is used. Each element in this list contains a
630 `Check Recipient' item. If this item is turned on, then the address is
631 checked against the recipient instead of the sender. This is useful for
634 b) An alias prefixed by `mh-default-folder-prefix' corresponding to the
635 address is used. The prefix is used to prevent clutter in your mail
638 Return nil if a folder name was not derived, or if the variable
639 `mh-default-folder-must-exist-flag' is t and the folder does not exist."
640 ;; Loop for all entries in mh-default-folder-list
642 (goto-char (point-min))
643 (re-search-forward "\n\n" nil 'limit)
644 (narrow-to-region (point-min) (point))
645 (let ((to/cc (concat (or (message-fetch-field "to") "") ", "
646 (or (message-fetch-field "cc") "")))
647 (from (or (message-fetch-field "from") ""))
650 (loop for list in mh-default-folder-list
651 when (string-match (nth 0 list) (if (nth 2 list) to/cc from))
655 ;; Make sure a result from `mh-default-folder-list' begins with "+"
656 ;; since 'mh-expand-file-name below depends on it
657 (when (and folder-name (not (eq (aref folder-name 0) ?+)))
658 (setq folder-name (concat "+" folder-name)))
660 ;; If not, is there an alias for the address?
661 (when (not folder-name)
662 (let* ((from-header (mh-extract-from-header-value))
663 (address (and from-header
664 (nth 1 (mail-extract-address-components
666 (alias (and address (mh-alias-address-to-alias address))))
669 (and alias (concat "+" mh-default-folder-prefix alias))))))
671 ;; If mh-default-folder-must-exist-flag set, check that folder exists.
673 (or (not mh-default-folder-must-exist-flag)
674 (file-exists-p (mh-expand-file-name folder-name))))
677 (defun mh-prompt-for-refile-folder ()
678 "Prompt the user for a folder in which the message should be filed.
679 The folder is returned as a string.
681 The default folder name is generated by the option
682 `mh-default-folder-for-message-function' if it is non-nil or
683 `mh-folder-from-address'."
684 (mh-prompt-for-folder
686 (let ((refile-file (ignore-errors (mh-msg-filename (mh-get-msg-num t)))))
687 (if (null refile-file) ""
689 (set-buffer (get-buffer-create mh-temp-buffer))
691 (insert-file-contents refile-file)
692 (or (and mh-default-folder-for-message-function
693 (let ((buffer-file-name refile-file))
694 (funcall mh-default-folder-for-message-function)))
695 (mh-folder-from-address)
696 (and (eq 'refile (car mh-last-destination-folder))
697 (symbol-name (cdr mh-last-destination-folder)))
701 (defun mh-refile-msg (range folder &optional dont-update-last-destination-flag)
702 "Refile RANGE into FOLDER.
704 Check the documentation of `mh-interactive-range' to see how RANGE is read in
707 If optional argument DONT-UPDATE-LAST-DESTINATION-FLAG is non-nil then the
708 variables `mh-last-destination' and `mh-last-destination-folder' are not
710 (interactive (list (mh-interactive-range "Refile")
711 (intern (mh-prompt-for-refile-folder))))
712 (unless dont-update-last-destination-flag
713 (setq mh-last-destination (cons 'refile folder)
714 mh-last-destination-folder mh-last-destination))
715 (mh-iterate-on-range () range
716 (mh-refile-a-msg nil folder))
717 (when (looking-at mh-scan-refiled-msg-regexp) (mh-next-msg)))
719 (defun mh-refile-or-write-again (message)
720 "Re-execute the last refile or write command on the given MESSAGE.
721 Default is the displayed message. Use the same folder or file as the previous
722 refile or write command."
723 (interactive (list (mh-get-msg-num t)))
724 (if (null mh-last-destination)
725 (error "No previous refile or write"))
728 (cond ((eq (car mh-last-destination) 'refile)
729 (mh-refile-a-msg message (cdr mh-last-destination))
730 (format "Destination folder: %s" (cdr mh-last-destination)))
732 (apply 'mh-write-msg-to-file message (cdr mh-last-destination))
733 (format "Destination: %s" (cdr mh-last-destination)))))
734 (mh-next-msg (interactive-p))
738 "Quit the current MH-E folder.
739 Restore the previous window configuration, if one exists.
740 The value of `mh-before-quit-hook' is a list of functions to be called, with
741 no arguments, immediately upon entry to this function.
742 The value of `mh-quit-hook' is a list of functions to be called, with no
743 arguments, upon exit of this function.
744 MH-E working buffers (whose name begins with \" *mh-\" or \"*MH-E \") are
747 (run-hooks 'mh-before-quit-hook)
748 (let ((show-buffer (get-buffer mh-show-buffer)))
750 (kill-buffer show-buffer)))
751 (mh-update-sequences)
752 (mh-destroy-postponed-handles)
753 (bury-buffer (current-buffer))
755 ;; Delete all MH-E temporary and working buffers.
756 (dolist (buffer (buffer-list))
757 (when (or (string-match "^ \\*mh-" (buffer-name buffer))
758 (string-match "^\\*MH-E " (buffer-name buffer)))
759 (kill-buffer buffer)))
761 (if mh-previous-window-config
762 (set-window-configuration mh-previous-window-config))
763 (run-hooks 'mh-quit-hook))
765 (defun mh-page-msg (&optional arg)
766 "Page the displayed message forwards.
767 Scrolls ARG lines or a full screen if no argument is supplied. Show buffer
768 first if not displayed. Show the next undeleted message if looking at the
769 bottom of the current message."
772 (if mh-page-to-next-msg-flag
773 (if (equal mh-next-direction 'backward)
774 (mh-previous-undeleted-msg)
775 (mh-next-undeleted-msg))
776 (if (mh-in-show-buffer (mh-show-buffer)
777 (pos-visible-in-window-p (point-max)))
780 "End of message (Type %s to read %s undeleted message)"
781 (single-key-description last-input-event)
782 (if (equal mh-next-direction 'backward)
785 (setq mh-page-to-next-msg-flag t))
786 (scroll-other-window arg)))
789 (defun mh-previous-page (&optional arg)
790 "Page the displayed message backwards.
791 Scrolls ARG lines or a full screen if no argument is supplied."
793 (mh-in-show-buffer (mh-show-buffer)
796 (defun mh-previous-undeleted-msg (&optional arg wait-after-complaining-flag)
797 "Move to the previous undeleted message ARG in window.
798 If optional argument WAIT-AFTER-COMPLAINING-FLAG is non-nil and we are at the
799 first undeleted message then pause for a second after printing message."
801 (setq mh-next-direction 'backward)
803 (cond ((re-search-backward mh-scan-good-msg-regexp nil t arg)
805 (t (message "No previous undeleted message")
806 (if wait-after-complaining-flag (sit-for 1)))))
808 (defun mh-previous-unread-msg (&optional count)
809 "Move to previous unread message.
810 With optional argument COUNT, COUNT-1 unread messages before current message
814 (error "The function mh-previous-unread-msg expects positive argument"))
815 (setq count (1- count))
816 (let ((unread-sequence (cdr (assoc mh-unseen-seq mh-seq-list)))
817 (cur-msg (mh-get-msg-num nil)))
818 (cond ((and (not cur-msg) (not (bobp))
819 ;; If we are at the end of the buffer back up one line and go
820 ;; to unread message after that.
823 (setq cur-msg (mh-get-msg-num nil)))
825 ((or (null unread-sequence) (not cur-msg))
826 ;; No unread message or there aren't any messages in buffer...
827 (message "No more unread messages"))
829 ;; Skip count messages...
830 (while (and unread-sequence (>= (car unread-sequence) cur-msg))
831 (setq unread-sequence (cdr unread-sequence)))
833 (setq unread-sequence (cdr unread-sequence))
834 (setq count (1- count)))
835 (not (car unread-sequence)))
836 (message "No more unread messages"))
837 (t (loop for msg in unread-sequence
838 when (mh-goto-msg msg t) return nil
839 finally (message "No more unread messages"))))))
841 (defun mh-goto-next-button (backward-flag &optional criterion)
842 "Search for next button satisfying criterion.
843 If BACKWARD-FLAG is non-nil search backward in the buffer for a mime button. If
844 CRITERION is a function or a symbol which has a function binding then that
845 function must return non-nil at the button we stop."
846 (unless (or (and (symbolp criterion) (fboundp criterion))
847 (functionp criterion))
848 (setq criterion (lambda (x) t)))
849 ;; Move to the next button in the buffer satisfying criterion
850 (goto-char (or (save-excursion
852 ;; Find point before current button
853 (let ((point-before-current-button
855 (while (get-text-property (point) 'mh-data)
856 (unless (= (forward-line
857 (if backward-flag 1 -1))
860 (goto-char (point-min))
861 (goto-char (point-max)))))
863 ;; Skip over current button
864 (while (and (get-text-property (point) 'mh-data)
865 (not (if backward-flag (bobp) (eobp))))
866 (forward-line (if backward-flag -1 1)))
867 ;; Stop at next MIME button if any exists.
870 (unless (= (forward-line
871 (if backward-flag -1 1))
874 (goto-char (point-max))
875 (goto-char (point-min)))
878 point-before-current-button)
879 (when (and (get-text-property (point) 'mh-data)
880 (funcall criterion (point)))
881 (return-from loop (point))))
885 (defun mh-next-button (&optional backward-flag)
886 "Go to the next MIME button.
887 Advance point to the next MIME button in the show buffer. If the end
888 of buffer is reached then the search wraps over to the start of the
889 buffer. With prefix argument, BACKWARD-FLAG the point will move to the
890 previous MIME button."
891 (interactive (list current-prefix-arg))
892 (unless mh-showing-mode
894 (mh-in-show-buffer (mh-show-buffer)
895 (mh-goto-next-button backward-flag)))
897 (defun mh-prev-button ()
898 "Go to the prev MIME button.
899 Move point to the previous MIME button in the show buffer. If the beginning
900 of the buffer is reached then the search wraps over to the end of the
905 (defun mh-folder-mime-action (part-index action include-security-flag)
906 "Go to PART-INDEX and carry out ACTION.
907 If PART-INDEX is nil then go to the next part in the buffer. The search for
908 the next buffer wraps around if end of buffer is reached. If argument
909 INCLUDE-SECURITY-FLAG is non-nil then include security info buttons when
910 searching for a suitable parts."
911 (unless mh-showing-mode
913 (mh-in-show-buffer (mh-show-buffer)
917 (let ((part (get-text-property p 'mh-part)))
918 (and (integerp part) (= part part-index)))))
920 (if include-security-flag
921 (get-text-property p 'mh-data)
922 (integerp (get-text-property p 'mh-part)))))))
924 (cond ((and (get-text-property point 'mh-part)
925 (or (null part-index)
926 (= (get-text-property point 'mh-part) part-index)))
928 ((and (get-text-property point 'mh-data)
929 include-security-flag
933 (mh-goto-next-button nil criterion)
934 (if (= (point) point)
935 (message "No matching MIME part found")
936 (funcall action)))))))
938 (defun mh-folder-toggle-mime-part (part-index)
939 "Toggle display of button.
940 If point in show buffer is at a button then that part is toggled.
941 If not at a button and PART-INDEX is non-nil point is moved to that part.
942 With nil PART-INDEX find the first button after point (search wraps around if
943 end of buffer is reached) and toggle it."
945 (when (consp part-index) (setq part-index (car part-index)))
946 (mh-folder-mime-action part-index #'mh-press-button t))
948 (defun mh-folder-inline-mime-part (part-index)
949 "Show the raw bytes of MIME part inline.
950 If point in show buffer is at a mime part then that part is inlined.
951 If not at a mime-part and PART-INDEX is non-nil point is moved to that part.
952 With nil PART-INDEX find the first button after point (search wraps around if
953 end of buffer is reached) and inline it."
955 (when (consp part-index) (setq part-index (car part-index)))
956 (mh-folder-mime-action part-index #'mh-mime-inline-part nil))
958 (defun mh-folder-save-mime-part (part-index)
960 If point in show buffer is at a mime part then that part is saved.
961 If not at a mime-part and PART-INDEX is non-nil point is moved to that part.
962 With nil PART-INDEX find the first button after point (search wraps around if
963 end of buffer is reached) and save it."
965 (when (consp part-index) (setq part-index (car part-index)))
966 (mh-folder-mime-action part-index #'mh-mime-save-part nil))
968 (defvar mh-thread-scan-line-map-stack)
970 (defun mh-reset-threads-and-narrowing ()
971 "Reset all variables pertaining to threads and narrowing.
972 Also removes all content from the folder buffer."
973 (setq mh-view-ops ())
974 (setq mh-folder-view-stack ())
975 (setq mh-thread-scan-line-map-stack ())
976 (let ((buffer-read-only nil)) (erase-buffer)))
978 (defun mh-rescan-folder (&optional range dont-exec-pending)
979 "Rescan a folder after optionally processing the outstanding commands.
980 If optional prefix argument RANGE is provided, prompt for the range of
981 messages to display. Otherwise show the entire folder.
982 If optional argument DONT-EXEC-PENDING is non-nil then pending deletes and
983 refiles aren't carried out."
984 (interactive (list (if current-prefix-arg
985 (mh-read-range "Rescan" mh-current-folder t nil t
986 mh-interpret-number-as-range-flag)
988 (setq mh-next-direction 'forward)
989 (let ((threaded-flag (memq 'unthread mh-view-ops)))
990 (mh-scan-folder mh-current-folder (or range "all") dont-exec-pending)
991 (cond (threaded-flag (mh-toggle-threads))
992 (mh-index-data (mh-index-insert-folder-headers)))))
994 (defun mh-write-msg-to-file (msg file no-headers)
995 "Append MSG to the end of a FILE.
996 If prefix argument NO-HEADERS is provided, write only the message body.
997 Otherwise send the entire message including the headers."
999 (list (mh-get-msg-num t)
1000 (let ((default-dir (if (eq 'write (car mh-last-destination-write))
1001 (file-name-directory
1002 (car (cdr mh-last-destination-write)))
1003 default-directory)))
1004 (read-file-name (format "Save message%s in file: "
1005 (if current-prefix-arg " body" ""))
1007 (if (eq 'write (car mh-last-destination-write))
1008 (car (cdr mh-last-destination-write))
1009 (expand-file-name "mail.out" default-dir))))
1010 current-prefix-arg))
1011 (let ((msg-file-to-output (mh-msg-filename msg))
1012 (output-file (mh-expand-file-name file)))
1013 (setq mh-last-destination (list 'write file (if no-headers 'no-headers))
1014 mh-last-destination-write mh-last-destination)
1016 (set-buffer (get-buffer-create mh-temp-buffer))
1018 (insert-file-contents msg-file-to-output)
1019 (goto-char (point-min))
1020 (if no-headers (search-forward "\n\n"))
1021 (append-to-file (point) (point-max) output-file))))
1023 (defun mh-toggle-showing ()
1024 "Toggle the scanning mode/showing mode of displaying messages."
1030 (defun mh-undo (range)
1031 "Undo the pending deletion or refile of the specified RANGE.
1033 Check the documentation of `mh-interactive-range' to see how RANGE is read in
1035 (interactive (list (mh-interactive-range "Undo")))
1036 (cond ((numberp range)
1037 (let ((original-position (point)))
1039 (while (not (or (looking-at mh-scan-deleted-msg-regexp)
1040 (looking-at mh-scan-refiled-msg-regexp)
1041 (and (eq mh-next-direction 'forward) (bobp))
1042 (and (eq mh-next-direction 'backward)
1043 (save-excursion (forward-line) (eobp)))))
1044 (forward-line (if (eq mh-next-direction 'forward) -1 1)))
1045 (if (or (looking-at mh-scan-deleted-msg-regexp)
1046 (looking-at mh-scan-refiled-msg-regexp))
1048 (mh-undo-msg (mh-get-msg-num t))
1050 (goto-char original-position)
1051 (error "Nothing to undo"))))
1052 (t (mh-iterate-on-range () range
1053 (mh-undo-msg nil))))
1054 (if (not (mh-outstanding-commands-p))
1055 (mh-set-folder-modified-p nil)))
1058 (defun mh-folder-line-matches-show-buffer-p ()
1059 "Return t if the message under point in folder-mode is in the show buffer.
1060 Return nil in any other circumstance (no message under point, no show buffer,
1061 the message in the show buffer doesn't match."
1062 (and (eq major-mode 'mh-folder-mode)
1063 (mh-get-msg-num nil)
1065 (get-buffer mh-show-buffer)
1066 (buffer-file-name (get-buffer mh-show-buffer))
1067 (string-match ".*/\\([0-9]+\\)$"
1068 (buffer-file-name (get-buffer mh-show-buffer)))
1070 (match-string 1 (buffer-file-name (get-buffer mh-show-buffer)))
1071 (int-to-string (mh-get-msg-num nil)))))
1073 (eval-when-compile (require 'gnus))
1075 (defmacro mh-macro-expansion-time-gnus-version ()
1076 "Return Gnus version available at macro expansion time.
1077 The macro evaluates the Gnus version at macro expansion time. If MH-E was
1078 compiled then macro expansion happens at compile time."
1081 (defun mh-run-time-gnus-version ()
1082 "Return Gnus version available at run time."
1087 (defun mh-version ()
1088 "Display version information about MH-E and the MH mail handling system."
1090 (set-buffer (get-buffer-create mh-info-buffer))
1093 (insert "MH-E " mh-version "\n\n")
1094 ;; MH-E compilation details.
1095 (insert "MH-E compilation details:\n")
1096 (let* ((compiled-mhe (byte-code-function-p (symbol-function 'mh-version)))
1097 (gnus-compiled-version (if compiled-mhe
1098 (mh-macro-expansion-time-gnus-version)
1100 (insert " Byte compiled:\t\t" (if compiled-mhe "yes" "no") "\n"
1101 " Gnus (compile-time):\t" gnus-compiled-version "\n"
1102 " Gnus (run-time):\t" (mh-run-time-gnus-version) "\n\n"))
1104 (insert (emacs-version) "\n\n")
1106 (if mh-variant-in-use
1107 (insert mh-variant-in-use "\n"
1108 " mh-progs:\t" mh-progs "\n"
1109 " mh-lib:\t" mh-lib "\n"
1110 " mh-lib-progs:\t" mh-lib-progs "\n\n")
1111 (insert "No MH variant detected\n"))
1114 (call-process "uname" nil t nil "-a")
1116 (goto-char (point-min))
1117 (display-buffer mh-info-buffer))
1119 (defun mh-parse-flist-output-line (line &optional current-folder)
1120 "Parse LINE to generate folder name, unseen messages and total messages.
1121 If CURRENT-FOLDER is non-nil then it contains the current folder name and it is
1122 used to avoid problems in corner cases involving folders whose names end with a
1126 (goto-char (point-max))
1127 (let (folder unseen total p)
1128 (when (search-backward " out of " (point-min) t)
1129 (setq total (read-from-string
1130 (buffer-substring-no-properties
1131 (match-end 0) (line-end-position))))
1132 (when (search-backward " in sequence " (point-min) t)
1134 (when (search-backward " has " (point-min) t)
1135 (setq unseen (read-from-string (buffer-substring-no-properties
1137 (while (eq (char-after) ? )
1139 (setq folder (buffer-substring-no-properties
1140 (point-min) (1+ (point))))
1141 (when (and (equal (aref folder (1- (length folder))) ?+)
1142 (equal current-folder folder))
1143 (setq folder (substring folder 0 (1- (length folder)))))
1144 (values (format "+%s" folder) (car unseen) (car total))))))))
1146 (defun mh-folder-size-folder (folder)
1147 "Find size of FOLDER using `folder'."
1149 (let ((u (length (cdr (assoc mh-unseen-seq
1150 (mh-read-folder-sequences folder nil))))))
1151 (call-process (expand-file-name "folder" mh-progs) nil t nil
1152 "-norecurse" folder)
1153 (goto-char (point-min))
1154 (if (re-search-forward " has \\([0-9]+\\) " nil t)
1155 (values (car (read-from-string (match-string 1))) u folder)
1156 (values 0 u folder)))))
1158 (defun mh-folder-size-flist (folder)
1159 "Find size of FOLDER using `flist'."
1161 (call-process (expand-file-name "flist" mh-progs) nil t nil "-showzero"
1162 "-norecurse" folder "-sequence" (symbol-name mh-unseen-seq))
1163 (goto-char (point-min))
1164 (multiple-value-bind (folder unseen total)
1165 (mh-parse-flist-output-line
1166 (buffer-substring (point) (line-end-position)))
1167 (values total unseen folder))))
1169 (defun mh-folder-size (folder)
1170 "Find size of FOLDER."
1171 (if mh-flists-present-flag
1172 (mh-folder-size-flist folder)
1173 (mh-folder-size-folder folder)))
1175 (defun mh-visit-folder (folder &optional range index-data)
1176 "Visit FOLDER and display RANGE of messages.
1177 Do not call this function from outside MH-E; see \\[mh-rmail] instead.
1179 If RANGE is nil (the default if it is omitted when called non-interactively),
1180 then all messages in FOLDER are displayed.
1182 If an index buffer is being created then INDEX-DATA is used to initialize the
1183 index buffer specific data structures.
1185 A prefix argument will cause a prompt for the RANGE of messages
1186 regardless of the size of the `mh-large-folder' variable."
1187 (interactive (let ((folder-name (mh-prompt-for-folder "Visit" mh-inbox t)))
1189 (mh-read-range "Scan" folder-name t nil
1191 mh-interpret-number-as-range-flag))))
1192 (let ((config (current-window-configuration))
1193 (current-buffer (current-buffer))
1194 (threaded-view-flag mh-show-threads-flag))
1195 (delete-other-windows)
1197 (when (get-buffer folder)
1199 (setq threaded-view-flag (memq 'unthread mh-view-ops))))
1201 (mh-make-folder folder)
1202 (setq mh-index-data (car index-data)
1203 mh-index-msg-checksum-map (make-hash-table :test #'equal)
1204 mh-index-checksum-origin-map (make-hash-table :test #'equal))
1205 (mh-index-update-maps folder (cadr index-data))
1206 (mh-index-create-sequences))
1207 (mh-scan-folder folder (or range "all"))
1208 (cond ((and threaded-view-flag
1210 (goto-char (point-min))
1211 (or (null mh-large-folder)
1212 (not (equal (forward-line (1+ mh-large-folder)) 0))
1213 (and (message "Not threading since the number of messages exceeds `mh-large-folder'")
1215 (mh-toggle-threads))
1217 (mh-index-insert-folder-headers)))
1218 (unless (eq current-buffer (current-buffer))
1219 (setq mh-previous-window-config config)))
1223 (defun mh-update-sequences ()
1224 "Update MH's Unseen-Sequence and current folder and message.
1225 Flush MH-E's state out to MH. The message at the cursor becomes current."
1227 ;; mh-update-sequences is the opposite of mh-read-folder-sequences,
1228 ;; which updates MH-E's state from MH.
1229 (let ((folder-set (mh-update-unseen))
1230 (new-cur (mh-get-msg-num nil)))
1232 (let ((seq-entry (mh-find-seq 'cur)))
1233 (mh-remove-cur-notation)
1235 (list new-cur)) ;delete-seq-locally, add-msgs-to-seq
1236 (mh-define-sequence 'cur (list new-cur))
1238 (if (looking-at mh-scan-good-msg-regexp)
1242 ;; psg - mh-current-folder is nil if mh-summary-height < 4 !
1243 ;; So I added this sanity check.
1244 (if (stringp mh-current-folder)
1245 (mh-exec-cmd-quiet t "folder" mh-current-folder "-fast")
1246 (mh-exec-cmd-quiet t "folder" "-fast")))))))
1250 ;;; Support routines.
1252 (defun mh-delete-a-msg (msg)
1254 If MSG is nil then the message at point is deleted.
1256 The value of `mh-delete-msg-hook' is a list of functions to be called, with no
1257 arguments, after the message has been deleted."
1260 (mh-goto-msg msg nil t)
1262 (setq msg (mh-get-msg-num t)))
1263 (if (looking-at mh-scan-refiled-msg-regexp)
1264 (error "Message %d is refiled. Undo refile before deleting" msg))
1265 (if (looking-at mh-scan-deleted-msg-regexp)
1267 (mh-set-folder-modified-p t)
1268 (setq mh-delete-list (cons msg mh-delete-list))
1269 (mh-notate nil mh-note-deleted mh-cmd-note)
1270 (run-hooks 'mh-delete-msg-hook))))
1272 (defun mh-refile-a-msg (msg folder)
1273 "Refile MSG in FOLDER.
1274 If MSG is nil then the message at point is refiled.
1276 Folder is a symbol, not a string.
1277 The value of `mh-refile-msg-hook' is a list of functions to be called, with no
1278 arguments, after the message has been refiled."
1281 (mh-goto-msg msg nil t)
1283 (setq msg (mh-get-msg-num t)))
1284 (cond ((looking-at mh-scan-deleted-msg-regexp)
1285 (error "Message %d is deleted. Undo delete before moving" msg))
1286 ((looking-at mh-scan-refiled-msg-regexp)
1288 (format "Message %d already refiled. Copy to %s as well? "
1290 (mh-exec-cmd "refile" (mh-get-msg-num t) "-link"
1291 "-src" mh-current-folder
1292 (symbol-name folder))
1293 (message "Message not copied")))
1295 (mh-set-folder-modified-p t)
1296 (cond ((null (assoc folder mh-refile-list))
1297 (push (list folder msg) mh-refile-list))
1298 ((not (member msg (cdr (assoc folder mh-refile-list))))
1299 (push msg (cdr (assoc folder mh-refile-list)))))
1300 (mh-notate nil mh-note-refiled mh-cmd-note)
1301 (run-hooks 'mh-refile-msg-hook)))))
1303 (defun mh-next-msg (&optional wait-after-complaining-flag)
1304 "Move backward or forward to the next undeleted message in the buffer.
1305 If optional argument WAIT-AFTER-COMPLAINING-FLAG is non-nil and we are at the
1306 last message, then wait for a second after telling the user that there aren't
1307 any more unread messages."
1308 (if (eq mh-next-direction 'forward)
1309 (mh-next-undeleted-msg 1 wait-after-complaining-flag)
1310 (mh-previous-undeleted-msg 1 wait-after-complaining-flag)))
1312 (defun mh-next-unread-msg (&optional count)
1313 "Move to next unread message.
1314 With optional argument COUNT, COUNT-1 unread messages are skipped."
1317 (error "The function mh-next-unread-msg expects positive argument"))
1318 (setq count (1- count))
1319 (let ((unread-sequence (reverse (cdr (assoc mh-unseen-seq mh-seq-list))))
1320 (cur-msg (mh-get-msg-num nil)))
1321 (cond ((and (not cur-msg) (not (bobp))
1322 ;; If we are at the end of the buffer back up one line and go
1323 ;; to unread message after that.
1326 (setq cur-msg (mh-get-msg-num nil)))
1328 ((or (null unread-sequence) (not cur-msg))
1329 ;; No unread message or there aren't any messages in buffer...
1330 (message "No more unread messages"))
1333 (while (and unread-sequence (>= cur-msg (car unread-sequence)))
1334 (setq unread-sequence (cdr unread-sequence)))
1336 (setq unread-sequence (cdr unread-sequence))
1337 (setq count (1- count)))
1338 (not (car unread-sequence)))
1339 (message "No more unread messages"))
1340 (t (loop for msg in unread-sequence
1341 when (mh-goto-msg msg t) return nil
1342 finally (message "No more unread messages"))))))
1344 (defun mh-set-scan-mode ()
1345 "Display the scan listing buffer, but do not show a message."
1346 (if (get-buffer mh-show-buffer)
1347 (delete-windows-on mh-show-buffer))
1349 (force-mode-line-update)
1350 (if mh-recenter-summary-flag
1353 (defun mh-undo-msg (msg)
1354 "Undo the deletion or refile of one MSG.
1355 If MSG is nil then act on the message at point"
1358 (mh-goto-msg msg t t)
1360 (setq msg (mh-get-msg-num t)))
1361 (cond ((memq msg mh-delete-list)
1362 (setq mh-delete-list (delq msg mh-delete-list)))
1364 (dolist (folder-msg-list mh-refile-list)
1365 (setf (cdr folder-msg-list) (remove msg (cdr folder-msg-list))))
1366 (setq mh-refile-list (loop for x in mh-refile-list
1367 unless (null (cdr x)) collect x))))
1368 (mh-notate nil ? mh-cmd-note)))
1372 ;;; The folder data abstraction.
1374 (defvar mh-index-data-file ".mhe_index"
1375 "MH-E specific file where index seach info is stored.")
1377 (defun mh-make-folder (name)
1378 "Create a new mail folder called NAME.
1379 Make it the current folder."
1380 (switch-to-buffer name)
1381 (setq buffer-read-only nil)
1383 (if mh-adaptive-cmd-note-flag
1384 (mh-set-cmd-note (mh-message-number-width name)))
1385 (setq buffer-read-only t)
1387 (mh-set-folder-modified-p nil)
1388 (setq buffer-file-name mh-folder-filename)
1389 (when (and (not mh-index-data)
1390 (file-exists-p (concat buffer-file-name mh-index-data-file)))
1391 (mh-index-read-data))
1392 (mh-make-folder-mode-line))
1394 ;;; Ensure new buffers won't get this mode if default-major-mode is nil.
1395 (put 'mh-folder-mode 'mode-class 'special)
1399 ;;; Menu extracted from mh-menubar.el V1.1 (31 July 2001)
1400 ;;; Menus for folder mode: folder, message, sequence (in that order)
1401 ;;; folder-mode "Sequence" menu
1403 mh-folder-sequence-menu mh-folder-mode-map "Menu for MH-E folder-sequence."
1405 ["Add Message to Sequence..." mh-put-msg-in-seq (mh-get-msg-num nil)]
1406 ["List Sequences for Message" mh-msg-is-in-seq (mh-get-msg-num nil)]
1407 ["Delete Message from Sequence..." mh-delete-msg-from-seq
1408 (mh-get-msg-num nil)]
1409 ["List Sequences in Folder..." mh-list-sequences t]
1410 ["Delete Sequence..." mh-delete-seq t]
1411 ["Narrow to Sequence..." mh-narrow-to-seq t]
1412 ["Widen from Sequence" mh-widen mh-folder-view-stack]
1414 ["Narrow to Subject Sequence" mh-narrow-to-subject t]
1415 ["Narrow to Tick Sequence" mh-narrow-to-tick
1416 (and mh-tick-seq (mh-seq-msgs (mh-find-seq mh-tick-seq)))]
1417 ["Delete Rest of Same Subject" mh-delete-subject t]
1418 ["Toggle Tick Mark" mh-toggle-tick t]
1420 ["Push State Out to MH" mh-update-sequences t]))
1422 ;;; folder-mode "Message" menu
1424 mh-folder-message-menu mh-folder-mode-map "Menu for MH-E folder-message."
1426 ["Show Message" mh-show (mh-get-msg-num nil)]
1427 ["Show Message with Header" mh-header-display (mh-get-msg-num nil)]
1428 ["Next Message" mh-next-undeleted-msg t]
1429 ["Previous Message" mh-previous-undeleted-msg t]
1430 ["Go to First Message" mh-first-msg t]
1431 ["Go to Last Message" mh-last-msg t]
1432 ["Go to Message by Number..." mh-goto-msg t]
1433 ["Modify Message" mh-modify t]
1434 ["Delete Message" mh-delete-msg (mh-get-msg-num nil)]
1435 ["Refile Message" mh-refile-msg (mh-get-msg-num nil)]
1436 ["Undo Delete/Refile" mh-undo (mh-outstanding-commands-p)]
1437 ["Execute Delete/Refile" mh-execute-commands
1438 (mh-outstanding-commands-p)]
1440 ["Compose a New Message" mh-send t]
1441 ["Reply to Message..." mh-reply (mh-get-msg-num nil)]
1442 ["Forward Message..." mh-forward (mh-get-msg-num nil)]
1443 ["Redistribute Message..." mh-redistribute (mh-get-msg-num nil)]
1444 ["Edit Message Again" mh-edit-again (mh-get-msg-num nil)]
1445 ["Re-edit a Bounced Message" mh-extract-rejected-mail t]
1447 ["Copy Message to Folder..." mh-copy-msg (mh-get-msg-num nil)]
1448 ["Print Message" mh-print-msg (mh-get-msg-num nil)]
1449 ["Write Message to File..." mh-write-msg-to-file
1450 (mh-get-msg-num nil)]
1451 ["Pipe Message to Command..." mh-pipe-msg (mh-get-msg-num nil)]
1452 ["Unpack Uuencoded Message..." mh-store-msg (mh-get-msg-num nil)]
1453 ["Burst Digest Message" mh-burst-digest (mh-get-msg-num nil)]))
1455 ;;; folder-mode "Folder" menu
1457 mh-folder-folder-menu mh-folder-mode-map "Menu for MH-E folder."
1459 ["Incorporate New Mail" mh-inc-folder t]
1460 ["Toggle Show/Folder" mh-toggle-showing t]
1461 ["Execute Delete/Refile" mh-execute-commands
1462 (mh-outstanding-commands-p)]
1463 ["Rescan Folder" mh-rescan-folder t]
1464 ["Thread Folder" mh-toggle-threads
1465 (not (memq 'unthread mh-view-ops))]
1466 ["Pack Folder" mh-pack-folder t]
1467 ["Sort Folder" mh-sort-folder t]
1469 ["List Folders" mh-list-folders t]
1470 ["Visit a Folder..." mh-visit-folder t]
1471 ["View New Messages" mh-index-new-messages t]
1472 ["Search a Folder..." mh-search-folder t]
1473 ["Indexed Search..." mh-index-search t]
1475 ["Quit MH-E" mh-quit t]))
1479 (defmacro mh-remove-xemacs-horizontal-scrollbar ()
1480 "Get rid of the horizontal scrollbar that XEmacs insists on putting in."
1481 (when mh-xemacs-flag
1482 `(if (and (featurep 'scrollbar)
1483 (fboundp 'set-specifier))
1484 (set-specifier horizontal-scrollbar-visible-p nil
1485 (cons (current-buffer) nil)))))
1487 (defmacro mh-write-file-functions-compat ()
1488 "Return `write-file-functions' if it exists.
1489 Otherwise return `local-write-file-hooks'. This macro exists purely for
1490 compatibility. The former symbol is used in Emacs 21.4 onward while the latter
1491 is used in previous versions and XEmacs."
1492 (if (boundp 'write-file-functions)
1493 ''write-file-functions ;Emacs 21.4
1494 ''local-write-file-hooks)) ;<Emacs 21.4, XEmacs
1496 ;; Avoid compiler warnings in non-bleeding edge versions of Emacs.
1498 (defvar tool-bar-mode)
1499 (defvar tool-bar-map)
1500 (defvar desktop-save-buffer)) ;Emacs 21.4
1502 ;; Register mh-folder-mode as supporting which-function-mode...
1503 (load "which-func" t t)
1504 (when (and (boundp 'which-func-modes)
1505 (not (member 'mh-folder-mode which-func-modes)))
1506 (push 'mh-folder-mode which-func-modes))
1508 (define-derived-mode mh-folder-mode fundamental-mode "MH-Folder"
1509 "Major MH-E mode for \"editing\" an MH folder scan listing.\\<mh-folder-mode-map>
1511 You can show the message the cursor is pointing to, and step through the
1512 messages. Messages can be marked for deletion or refiling into another
1513 folder; these commands are executed all at once with a separate command.
1515 Options that control this mode can be changed with \\[customize-group];
1516 specify the \"mh\" group. In particular, please see the `mh-scan-format-file'
1517 option if you wish to modify scan's format.
1519 When a folder is visited, the hook `mh-folder-mode-hook' is run.
1523 Many commands that operate on individual messages, such as `mh-forward' or
1524 `mh-refile-msg' take a RANGE argument. This argument can be used in several
1527 If you provide the prefix argument (\\[universal-argument]) to these commands,
1528 then you will be prompted for the message range. This can be any legal MH
1529 range which can include messages, sequences, and the abbreviations (described
1530 in the mh(1) man page):
1533 Indicates all messages in the range <num1> to <num2>, inclusive. The range
1539 Up to N messages beginning with (or ending with) message num. Num may be
1540 any of the pre-defined symbols: first, prev, cur, next or last.
1546 The first, previous, next or last messages, if they exist.
1549 All of the messages.
1551 For example, a range that shows all of these things is `1 2 3 5-10 last:5
1554 If the option `transient-mark-mode' is set to t and you set a region in the
1555 MH-Folder buffer, then the MH-E command will perform the operation on all
1556 messages in that region.
1558 \\{mh-folder-mode-map}"
1560 (make-local-variable 'font-lock-defaults)
1561 (setq font-lock-defaults '(mh-folder-font-lock-keywords t))
1562 (make-local-variable 'desktop-save-buffer)
1563 (setq desktop-save-buffer t)
1565 'mh-colors-available-flag (mh-colors-available-p)
1566 ; Do we have colors available
1567 'mh-current-folder (buffer-name) ; Name of folder, a string
1568 'mh-show-buffer (format "show-%s" (buffer-name)) ; Buffer that displays msgs
1569 'mh-folder-filename ; e.g. "/usr/foobar/Mail/inbox/"
1570 (file-name-as-directory (mh-expand-file-name (buffer-name)))
1571 'mh-display-buttons-for-inline-parts-flag
1572 mh-display-buttons-for-inline-parts-flag ; Allow for display of buttons to
1574 'mh-arrow-marker (make-marker) ; Marker where arrow is displayed
1575 'overlay-arrow-position nil ; Allow for simultaneous display in
1576 'overlay-arrow-string ">" ; different MH-E buffers.
1577 'mh-showing-mode nil ; Show message also?
1578 'mh-delete-list nil ; List of msgs nums to delete
1579 'mh-refile-list nil ; List of folder names in mh-seq-list
1580 'mh-seq-list nil ; Alist of (seq . msgs) nums
1581 'mh-seen-list nil ; List of displayed messages
1582 'mh-next-direction 'forward ; Direction to move to next message
1583 'mh-view-ops () ; Stack that keeps track of the order
1584 ; in which narrowing/threading has been
1586 'mh-folder-view-stack () ; Stack of previous views of the
1588 'mh-index-data nil ; If the folder was created by a call
1589 ; to mh-index-search this contains info
1590 ; about the search results.
1591 'mh-index-previous-search nil ; Previous folder and search-regexp
1592 'mh-index-msg-checksum-map nil ; msg -> checksum map
1593 'mh-index-checksum-origin-map nil ; checksum -> ( orig-folder, orig-msg )
1594 'mh-index-sequence-search-flag nil ; folder resulted from sequence search
1595 'mh-first-msg-num nil ; Number of first msg in buffer
1596 'mh-last-msg-num nil ; Number of last msg in buffer
1597 'mh-msg-count nil ; Number of msgs in buffer
1598 'mh-mode-line-annotation nil ; Indicates message range
1599 'mh-sequence-notation-history (make-hash-table)
1600 ; Remember what is overwritten by
1602 'imenu-create-index-function 'mh-index-create-imenu-index
1603 ; Setup imenu support
1604 'mh-previous-window-config nil) ; Previous window configuration
1605 (mh-remove-xemacs-horizontal-scrollbar)
1606 (setq truncate-lines t)
1608 (setq buffer-offer-save t)
1609 (mh-make-local-hook (mh-write-file-functions-compat))
1610 (add-hook (mh-write-file-functions-compat) 'mh-execute-commands nil t)
1611 (make-local-variable 'revert-buffer-function)
1612 (make-local-variable 'hl-line-mode) ; avoid pollution
1613 (mh-funcall-if-exists hl-line-mode 1)
1614 (setq revert-buffer-function 'mh-undo-folder)
1615 (or (assq 'mh-showing-mode minor-mode-alist)
1616 (setq minor-mode-alist
1617 (cons '(mh-showing-mode " Show") minor-mode-alist)))
1618 (easy-menu-add mh-folder-sequence-menu)
1619 (easy-menu-add mh-folder-message-menu)
1620 (easy-menu-add mh-folder-folder-menu)
1621 (set (make-local-variable 'tool-bar-map) mh-folder-tool-bar-map)
1622 (mh-funcall-if-exists mh-toolbar-init :folder)
1623 (if (and mh-xemacs-flag
1624 font-lock-auto-fontify)
1625 (turn-on-font-lock))) ; Force font-lock in XEmacs.
1627 (defun mh-toggle-mime-buttons ()
1628 "Toggle display of buttons for inline MIME parts."
1630 (setq mh-display-buttons-for-inline-parts-flag
1631 (not mh-display-buttons-for-inline-parts-flag))
1634 (defun mh-colors-available-p ()
1635 "Check if colors are available in the Emacs being used."
1638 (or (ignore-errors (mh-funcall-if-exists display-color-cells))
1639 (ignore-errors (mh-funcall-if-exists
1640 x-display-color-cells)))))
1641 (and (numberp color-cells) (>= color-cells 8)))))
1643 (defun mh-colors-in-use-p ()
1644 "Check if colors are being used in the folder buffer."
1645 (and mh-colors-available-flag font-lock-mode))
1647 (defun mh-make-local-vars (&rest pairs)
1648 "Initialize local variables according to the variable-value PAIRS."
1651 (set (make-local-variable (car pairs)) (car (cdr pairs)))
1652 (setq pairs (cdr (cdr pairs)))))
1655 (defun mh-restore-desktop-buffer (desktop-buffer-file-name
1657 desktop-buffer-misc)
1658 "Restore an MH folder buffer specified in a desktop file.
1659 When desktop creates a buffer, DESKTOP-BUFFER-FILE-NAME holds the file name to
1660 visit, DESKTOP-BUFFER-NAME holds the desired buffer name, and
1661 DESKTOP-BUFFER-MISC holds a list of miscellaneous info used by the
1662 `desktop-buffer-handlers' functions."
1664 (mh-visit-folder desktop-buffer-name)
1667 (defun mh-scan-folder (folder range &optional dont-exec-pending)
1668 "Scan the FOLDER over the RANGE.
1669 If the optional argument DONT-EXEC-PENDING is non-nil then pending deletes and
1670 refiles aren't carried out.
1671 Return in the folder's buffer."
1672 (when (stringp range)
1673 (setq range (delete "" (split-string range "[ \t\n]"))))
1674 (cond ((null (get-buffer folder))
1675 (mh-make-folder folder))
1677 (unless dont-exec-pending
1678 (mh-process-or-undo-commands folder)
1679 (mh-reset-threads-and-narrowing))
1680 (switch-to-buffer folder)))
1681 (mh-regenerate-headers range)
1682 (if (zerop (buffer-size))
1683 (if (equal range "all")
1684 (message "Folder %s is empty" folder)
1685 (message "No messages in %s, range %s" folder range))
1687 (when (mh-outstanding-commands-p)
1688 (mh-notate-deleted-and-refiled)))
1690 (defun mh-set-cmd-note (width)
1691 "Set `mh-cmd-note' to WIDTH characters (minimum of 2).
1693 If `mh-scan-format-file' specifies nil or a filename, then this function
1694 will NOT update `mh-cmd-note'."
1695 ;; Add one to the width to always have whitespace in column zero.
1696 (setq width (max (1+ width) 2))
1697 (if (and (equal mh-scan-format-file t)
1698 (not (eq mh-cmd-note width)))
1699 (setq mh-cmd-note width))
1702 (defun mh-regenerate-headers (range &optional update)
1703 "Scan folder over range RANGE.
1704 If UPDATE, append the scan lines, otherwise replace."
1705 (let ((folder mh-current-folder)
1706 (range (if (and range (atom range)) (list range) range))
1708 (message "Scanning %s..." folder)
1709 (mh-remove-all-notation)
1710 (with-mh-folder-updating (nil)
1712 (goto-char (point-max))
1713 (delete-region (point-min) (point-max))
1714 (if mh-adaptive-cmd-note-flag
1715 (mh-set-cmd-note (mh-message-number-width folder))))
1716 (setq scan-start (point))
1717 (apply #'mh-exec-cmd-output
1720 "-noclear" "-noheader"
1721 "-width" (window-width)
1723 (goto-char scan-start)
1724 (cond ((looking-at "scan: no messages in")
1725 (keep-lines mh-scan-valid-regexp)) ; Flush random scan lines
1726 ((looking-at (if (mh-variant-p 'mu-mh)
1727 "scan: message set .* does not exist"
1728 "scan: bad message list "))
1729 (keep-lines mh-scan-valid-regexp))
1730 ((looking-at "scan: ")) ; Keep error messages
1732 (keep-lines mh-scan-valid-regexp))) ; Flush random scan lines
1733 (setq mh-seq-list (mh-read-folder-sequences folder nil))
1734 (mh-notate-user-sequences)
1736 (setq mh-mode-line-annotation
1737 (if (equal range '("all"))
1739 mh-partial-folder-mode-line-annotation)))
1740 (mh-make-folder-mode-line))
1741 (message "Scanning %s...done" folder)))
1743 (defun mh-generate-new-cmd-note (folder)
1744 "Fix the `mh-cmd-note' value for this FOLDER.
1746 After doing an `mh-get-new-mail' operation in this FOLDER, at least
1747 one line that looks like a truncated message number was found.
1749 Remove the text added by the last `mh-inc' command. It should be the
1750 messages cur-last. Call `mh-set-cmd-note' with the widest message number
1753 Reformat the message number width on each line in the buffer and trim
1754 the line length to fit in the window.
1756 Rescan the FOLDER in the range cur-last in order to display the
1757 messages that were removed earlier. They should all fit in the scan
1758 line now with no message truncation."
1760 (let ((maxcol (1- (window-width)))
1761 (old-cmd-note mh-cmd-note)
1764 ;; Nuke all of the lines just added by the last inc
1765 (delete-char (- (point-max) (point)))
1766 ;; Update the current buffer to reflect the new mh-cmd-note
1767 ;; value needed to display messages.
1768 (mh-set-cmd-note (mh-message-number-width folder))
1769 (setq mh-cmd-note-fmt (concat "%" (format "%d" mh-cmd-note) "d"))
1770 ;; Cleanup the messages that are in the buffer right now
1771 (goto-char (point-min))
1772 (cond ((memq 'unthread mh-view-ops)
1773 (mh-thread-add-spaces (- mh-cmd-note old-cmd-note)))
1774 (t (while (re-search-forward mh-scan-msg-number-regexp nil 0 1)
1775 ;; reformat the number to fix in mh-cmd-note columns
1776 (setq msgnum (string-to-number
1778 (match-beginning 1) (match-end 1))))
1779 (replace-match (format mh-cmd-note-fmt msgnum))
1780 ;; trim the line to fix in the window
1782 (let ((eol (point)))
1783 (move-to-column maxcol)
1784 (if (<= (point) eol)
1785 (delete-char (- eol (point))))))))
1786 ;; now re-read the lost messages
1787 (goto-char (point-max))
1789 (mh-regenerate-headers "cur-last" t)))))
1791 (defun mh-get-new-mail (maildrop-name)
1792 "Read new mail from MAILDROP-NAME into the current buffer.
1793 Return in the current buffer."
1794 (let ((point-before-inc (point))
1795 (folder mh-current-folder)
1796 (new-mail-flag nil))
1797 (with-mh-folder-updating (t)
1799 (message "inc %s -file %s..." folder maildrop-name)
1800 (message "inc %s..." folder))
1801 (setq mh-next-direction 'forward)
1802 (goto-char (point-max))
1803 (mh-remove-all-notation)
1804 (let ((start-of-inc (point)))
1806 ;; I think MH 5 used "-ms-file" instead of "-file",
1807 ;; which would make inc'ing from maildrops fail.
1808 (mh-exec-cmd-output mh-inc-prog nil folder
1810 "-file" (expand-file-name maildrop-name)
1811 "-width" (window-width)
1813 (mh-exec-cmd-output mh-inc-prog nil
1815 "-width" (window-width)))
1817 (message "inc %s -file %s...done" folder maildrop-name)
1818 (message "inc %s...done" folder))
1819 (goto-char start-of-inc)
1820 (cond ((save-excursion
1821 (re-search-forward "^inc: no mail" nil t))
1822 (message "No new mail%s%s" (if maildrop-name " in " "")
1823 (if maildrop-name maildrop-name "")))
1824 ((and (when mh-folder-view-stack
1825 (let ((saved-text (buffer-substring-no-properties
1826 start-of-inc (point-max))))
1827 (delete-region start-of-inc (point-max))
1828 (unwind-protect (mh-widen t)
1829 (mh-remove-all-notation)
1830 (goto-char (point-max))
1831 (setq start-of-inc (point))
1833 (goto-char start-of-inc))))
1835 ((re-search-forward "^inc:" nil t) ; Error messages
1836 (error "Error incorporating mail"))
1838 (equal mh-scan-format-file t)
1839 mh-adaptive-cmd-note-flag
1840 ;; Have we reached an edge condition?
1842 (re-search-forward mh-scan-msg-overflow-regexp nil 0 1))
1843 (setq start-of-inc (mh-generate-new-cmd-note folder))
1846 (setq new-mail-flag t)))
1847 (keep-lines mh-scan-valid-regexp) ; Flush random scan lines
1848 (setq mh-seq-list (mh-read-folder-sequences folder t))
1849 (when (equal (point-max) start-of-inc)
1853 (mh-make-folder-mode-line)
1854 (when (mh-speed-flists-active-p)
1855 (mh-speed-flists t mh-current-folder))
1856 (when (memq 'unthread mh-view-ops)
1857 (mh-thread-inc folder start-of-inc))
1859 (goto-char point-before-inc))
1860 (mh-notate-user-sequences)
1861 (mh-notate-deleted-and-refiled)))))
1863 (defun mh-make-folder-mode-line (&optional ignored)
1864 "Set the fields of the mode line for a folder buffer.
1865 The optional argument is now obsolete and IGNORED. It used to be used to pass
1866 in what is now stored in the buffer-local variable `mh-mode-line-annotation'."
1868 (save-window-excursion
1870 (let ((new-first-msg-num (mh-get-msg-num nil)))
1871 (when (or (not (memq 'unthread mh-view-ops))
1872 (null mh-first-msg-num)
1873 (null new-first-msg-num)
1874 (< new-first-msg-num mh-first-msg-num))
1875 (setq mh-first-msg-num new-first-msg-num)))
1877 (let ((new-last-msg-num (mh-get-msg-num nil)))
1878 (when (or (not (memq 'unthread mh-view-ops))
1879 (null mh-last-msg-num)
1880 (null new-last-msg-num)
1881 (> new-last-msg-num mh-last-msg-num))
1882 (setq mh-last-msg-num new-last-msg-num)))
1883 (setq mh-msg-count (if mh-first-msg-num
1884 (count-lines (point-min) (point-max))
1886 (setq mode-line-buffer-identification
1887 (list (format " {%%b%s} %s msg%s"
1888 (if mh-mode-line-annotation
1889 (format "/%s" mh-mode-line-annotation)
1891 (if (zerop mh-msg-count)
1893 (format "%d" mh-msg-count))
1894 (if (zerop mh-msg-count)
1896 (cond ((> mh-msg-count 1)
1897 (format "s (%d-%d)" mh-first-msg-num
1900 (format " (%d)" mh-first-msg-num))
1902 (mh-logo-display))))
1904 (defun mh-add-sequence-notation (msg internal-seq-flag)
1905 "Add sequence notation to the MSG on the current line.
1906 If INTERNAL-SEQ-FLAG is non-nil, then refontify the scan line if font-lock is
1908 (with-mh-folder-updating (t)
1911 (if internal-seq-flag
1913 ;; Change the buffer so that if transient-mark-mode is active
1914 ;; and there is an active region it will get deactivated as in
1915 ;; the case of user sequences.
1916 (mh-notate nil nil mh-cmd-note)
1917 (when font-lock-mode
1918 (font-lock-fontify-region (point) (line-end-position))))
1919 (forward-char (1+ mh-cmd-note))
1920 (let ((stack (gethash msg mh-sequence-notation-history)))
1921 (setf (gethash msg mh-sequence-notation-history)
1922 (cons (char-after) stack)))
1923 (mh-notate nil mh-note-seq (1+ mh-cmd-note))))))
1925 (defun mh-remove-sequence-notation (msg internal-seq-flag &optional all)
1926 "Remove sequence notation from the MSG on the current line.
1927 If INTERNAL-SEQ-FLAG is non-nil, then `font-lock' was used to highlight the
1928 sequence. In that case, no notation needs to be removed. Otherwise the effect
1929 of inserting `mh-note-seq' needs to be reversed.
1930 If ALL is non-nil, then all sequence marks on the scan line are removed."
1931 (with-mh-folder-updating (t)
1932 ;; This takes care of internal sequences...
1933 (mh-notate nil nil mh-cmd-note)
1934 (unless internal-seq-flag
1935 ;; ... and this takes care of user sequences.
1936 (let ((stack (gethash msg mh-sequence-notation-history)))
1937 (while (and all (cdr stack))
1938 (setq stack (cdr stack)))
1942 (forward-char (1+ mh-cmd-note))
1944 (insert (car stack))))
1945 (setf (gethash msg mh-sequence-notation-history) (cdr stack))))))
1947 (defun mh-remove-cur-notation ()
1948 "Remove old cur notation."
1949 (let ((cur-msg (car (mh-seq-to-msgs 'cur))))
1952 (mh-goto-msg cur-msg t t)
1953 (looking-at mh-scan-cur-msg-number-regexp))
1954 (mh-notate nil ? mh-cmd-note)
1955 (setq overlay-arrow-position nil)))))
1957 (defun mh-remove-all-notation ()
1958 "Remove all notations on all scan lines that MH-E introduces."
1960 (setq overlay-arrow-position nil)
1961 (goto-char (point-min))
1962 (mh-iterate-on-range msg (cons (point-min) (point-max))
1963 (mh-notate nil ? mh-cmd-note)
1964 (mh-remove-sequence-notation msg nil t))
1965 (clrhash mh-sequence-notation-history)))
1968 (defun mh-goto-cur-msg (&optional minimal-changes-flag)
1969 "Position the cursor at the current message.
1970 When optional argument MINIMAL-CHANGES-FLAG is non-nil, the function doesn't
1971 recenter the folder buffer."
1972 (let ((cur-msg (car (mh-seq-to-msgs 'cur))))
1974 (mh-goto-msg cur-msg t t))
1975 (unless minimal-changes-flag
1978 (mh-maybe-show cur-msg)))
1980 (setq overlay-arrow-position nil)
1981 (message "No current message")))))
1983 (defun mh-process-or-undo-commands (folder)
1984 "If FOLDER has outstanding commands, then either process or discard them.
1985 Called by functions like `mh-sort-folder', so also invalidate show buffer."
1987 (if (mh-outstanding-commands-p)
1988 (if (or mh-do-not-confirm-flag
1990 "Process outstanding deletes and refiles? "))
1991 (mh-process-commands folder)
1995 (mh-invalidate-show-buffer))
1997 (defun mh-process-commands (folder)
1998 "Process outstanding commands for FOLDER.
1999 The value of `mh-folder-updated-hook' is a list of functions to be called,
2000 with no arguments, before the commands are processed."
2001 (message "Processing deletes and refiles for %s..." folder)
2003 (with-mh-folder-updating (nil)
2004 ;; Run the hook while the lists are still valid
2005 (run-hooks 'mh-folder-updated-hook)
2007 ;; Update the unseen sequence if it exists
2010 (let ((redraw-needed-flag mh-index-data)
2011 (folders-changed (list mh-current-folder))
2012 (seq-map (and mh-refile-list mh-refile-preserves-sequences-flag
2013 (mh-create-sequence-map mh-seq-list)))
2014 (dest-map (and mh-refile-list mh-refile-preserves-sequences-flag
2015 (make-hash-table))))
2016 ;; Remove invalid scan lines if we are in an index folder and then remove
2017 ;; the real messages
2019 (mh-index-delete-folder-headers)
2020 (setq folders-changed
2021 (append folders-changed (mh-index-execute-commands))))
2023 ;; Then refile messages
2024 (mh-mapc #'(lambda (folder-msg-list)
2025 (let* ((dest-folder (symbol-name (car folder-msg-list)))
2026 (last (car (mh-translate-range dest-folder "last")))
2027 (msgs (cdr folder-msg-list)))
2028 (push dest-folder folders-changed)
2029 (setq redraw-needed-flag t)
2030 (apply #'mh-exec-cmd
2031 "refile" "-src" folder dest-folder
2032 (mh-coalesce-msg-list msgs))
2033 (mh-delete-scan-msgs msgs)
2034 ;; Preserve sequences in destination folder...
2035 (when (and mh-refile-preserves-sequences-flag
2038 (loop for i from (1+ last)
2039 for msg in (sort (copy-sequence msgs) #'<)
2040 do (loop for seq-name in (gethash msg seq-map)
2041 do (push i (gethash seq-name dest-map))))
2043 #'(lambda (seq msgs)
2044 ;; Run it in the background, since we don't care
2045 ;; about the results.
2046 (apply #'mh-exec-cmd-daemon "mark" #'ignore
2047 "-sequence" (symbol-name seq) dest-folder
2048 "-add" (mapcar #'(lambda (x) (format "%s" x))
2049 (mh-coalesce-msg-list msgs))))
2052 (setq mh-refile-list ())
2054 ;; Now delete messages
2055 (cond (mh-delete-list
2056 (setq redraw-needed-flag t)
2057 (apply 'mh-exec-cmd "rmm" folder
2058 (mh-coalesce-msg-list mh-delete-list))
2059 (mh-delete-scan-msgs mh-delete-list)
2060 (setq mh-delete-list nil)))
2062 ;; Don't need to remove sequences since delete and refile do so.
2064 (if (> (buffer-size) 0)
2065 (mh-define-sequence 'cur (list (or (mh-get-msg-num nil) "last"))))
2067 ;; Redraw folder buffer if needed
2068 (when (and redraw-needed-flag)
2069 (when (mh-speed-flists-active-p)
2070 (apply #'mh-speed-flists t folders-changed))
2071 (cond ((memq 'unthread mh-view-ops) (mh-thread-inc folder (point-max)))
2072 (mh-index-data (mh-index-insert-folder-headers)))))
2074 (and (buffer-file-name (get-buffer mh-show-buffer))
2075 (not (file-exists-p (buffer-file-name (get-buffer mh-show-buffer))))
2076 ;; If "inc" were to put a new msg in this file,
2077 ;; we would not notice, so mark it invalid now.
2078 (mh-invalidate-show-buffer))
2080 (setq mh-seq-list (mh-read-folder-sequences mh-current-folder nil))
2081 (mh-remove-all-notation)
2082 (mh-notate-user-sequences)
2083 (message "Processing deletes and refiles for %s...done" folder)))
2085 (defun mh-update-unseen ()
2086 "Synchronize the unseen sequence with MH.
2087 Return non-nil iff the MH folder was set.
2088 The value of `mh-unseen-updated-hook' is a list of functions to be called,
2089 with no arguments, after the unseen sequence is updated."
2091 (let* ((unseen-seq (mh-find-seq mh-unseen-seq))
2092 (unseen-msgs (mh-seq-msgs unseen-seq)))
2095 (mh-undefine-sequence mh-unseen-seq mh-seen-list)
2096 (run-hooks 'mh-unseen-updated-hook)
2098 (setq unseen-msgs (delq (car mh-seen-list) unseen-msgs))
2099 (setq mh-seen-list (cdr mh-seen-list)))
2100 (setcdr unseen-seq unseen-msgs)
2101 t) ;since we set the folder
2102 (setq mh-seen-list nil)))))
2104 (defun mh-delete-scan-msgs (msgs)
2105 "Delete the scan listing lines for MSGS."
2108 (when (mh-goto-msg (car msgs) t t)
2109 (when (memq 'unthread mh-view-ops)
2110 (mh-thread-forget-message (car msgs)))
2112 (setq msgs (cdr msgs)))))
2114 (defun mh-outstanding-commands-p ()
2115 "Return non-nil if there are outstanding deletes or refiles."
2117 (when (eq major-mode 'mh-show-mode)
2118 (set-buffer mh-show-folder-buffer))
2119 (or mh-delete-list mh-refile-list)))
2121 (defun mh-coalesce-msg-list (messages)
2122 "Given a list of MESSAGES, return a list of message number ranges.
2123 This is the inverse of `mh-read-msg-list', which expands ranges.
2124 Message lists passed to MH programs should be processed by this function
2125 to avoid exceeding system command line argument limits."
2126 (let ((msgs (sort (copy-sequence messages) 'mh-greaterp))
2132 (if (or (not (numberp prev))
2133 (not (equal (car msgs) (1- prev))))
2134 (progn ;non-sequential, flush old range
2135 (if (eq prev range-high)
2136 (setq ranges (cons range-high ranges))
2137 (setq ranges (cons (format "%s-%s" prev range-high) ranges)))
2138 (setq range-high nil))))
2140 (setq range-high (car msgs))) ;start new or first range
2141 (setq prev (car msgs))
2142 (setq msgs (cdr msgs)))
2145 (defun mh-greaterp (msg1 msg2)
2146 "Return the greater of two message indicators MSG1 and MSG2.
2147 Strings are \"smaller\" than numbers.
2148 Legal values are things like \"cur\", \"last\", 1, and 1820."
2155 (string-lessp msg2 msg1))))
2157 (defun mh-lessp (msg1 msg2)
2158 "Return the lesser of two message indicators MSG1 and MSG2.
2159 Strings are \"smaller\" than numbers.
2160 Legal values are things like \"cur\", \"last\", 1, and 1820."
2161 (not (mh-greaterp msg1 msg2)))
2165 ;;; Basic sequence handling
2167 (defun mh-delete-seq-locally (seq)
2168 "Remove MH-E's record of SEQ."
2169 (let ((entry (mh-find-seq seq)))
2170 (setq mh-seq-list (delq entry mh-seq-list))))
2172 (defun mh-read-folder-sequences (folder save-refiles)
2173 "Read and return the predefined sequences for a FOLDER.
2174 If SAVE-REFILES is non-nil, then keep the sequences
2175 that note messages to be refiled."
2178 (mh-mapc (function (lambda (seq) ; Save the refiling sequences
2179 (if (mh-folder-name-p (mh-seq-name seq))
2180 (setq seqs (cons seq seqs)))))
2183 (if (eq 0 (mh-exec-cmd-quiet nil "mark" folder "-list"))
2185 ;; look for name in line of form "cur: 4" or "myseq (private): 23"
2186 (while (re-search-forward "^[^: ]+" nil t)
2187 (setq seqs (cons (mh-make-seq (intern (buffer-substring
2192 (delete-region (point-min) (point))))) ; avoid race with
2196 (defun mh-read-msg-list ()
2197 "Return a list of message numbers from point to the end of the line.
2198 Expands ranges into set of individual numbers."
2200 (end-of-line (save-excursion (end-of-line) (point)))
2202 (while (re-search-forward "[0-9]+" end-of-line t)
2203 (setq num (string-to-int (buffer-substring (match-beginning 0)
2205 (cond ((looking-at "-") ; Message range
2207 (re-search-forward "[0-9]+" end-of-line t)
2208 (let ((num2 (string-to-int (buffer-substring (match-beginning 0)
2211 (error "Bad message range: %d-%d" num num2))
2212 (while (<= num num2)
2213 (setq msgs (cons num msgs))
2214 (setq num (1+ num)))))
2215 ((not (zerop num)) ;"pick" outputs "0" to mean no match
2216 (setq msgs (cons num msgs)))))
2219 (defun mh-notate-user-sequences (&optional range)
2220 "Mark user-defined sequences in the messages specified by RANGE.
2221 The optional argument RANGE can be a message number, a list of message
2222 numbers, a sequence, a region in a cons cell. If nil all messages are notated."
2224 (setq range (cons (point-min) (point-max))))
2225 (let ((seqs mh-seq-list)
2226 (msg-hash (make-hash-table)))
2228 (dolist (msg (mh-seq-msgs seq))
2229 (push (car seq) (gethash msg msg-hash))))
2230 (mh-iterate-on-range msg range
2231 (loop for seq in (gethash msg msg-hash)
2232 do (mh-add-sequence-notation msg (mh-internal-seq seq))))))
2234 (defvar mh-internal-seqs '(answered cur deleted forwarded printed))
2236 (defun mh-internal-seq (name)
2237 "Return non-nil if NAME is the name of an internal MH-E sequence."
2238 (or (memq name mh-internal-seqs)
2239 (eq name mh-unseen-seq)
2240 (and (mh-colors-in-use-p) mh-tick-seq (eq name mh-tick-seq))
2241 (eq name mh-previous-seq)
2242 (mh-folder-name-p name)))
2244 (defun mh-valid-seq-p (name)
2245 "Return non-nil if NAME is a valid MH sequence name."
2247 (string-match "^[a-zA-Z][a-zA-Z0-9]*$" (symbol-name name))))
2249 (defun mh-delete-msg-from-seq (range sequence &optional internal-flag)
2250 "Delete RANGE from SEQUENCE.
2252 Check the documentation of `mh-interactive-range' to see how RANGE is read in
2255 Optional third arg INTERNAL-FLAG non-nil means do not inform MH of the
2257 (interactive (list (mh-interactive-range "Delete")
2258 (mh-read-seq-default "Delete from" t)
2260 (let ((entry (mh-find-seq sequence))
2261 (user-sequence-flag (not (mh-internal-seq sequence)))
2262 (folders-changed (list mh-current-folder))
2265 (mh-iterate-on-range msg range
2267 ;; Calling "mark" repeatedly takes too long. So we will pretend here
2268 ;; that we are just modifying an internal sequence...
2269 (when (memq msg (cdr entry))
2270 (mh-remove-sequence-notation msg (not user-sequence-flag)))
2271 (mh-delete-a-msg-from-seq msg sequence t))
2272 ;; ... and here we will "mark" all the messages at one go.
2273 (unless internal-flag (mh-undefine-sequence sequence msg-list))
2274 (when (and mh-index-data (not internal-flag))
2275 (setq folders-changed
2276 (append folders-changed
2277 (mh-index-delete-from-sequence sequence msg-list))))
2278 (when (and (eq sequence mh-unseen-seq) (mh-speed-flists-active-p))
2279 (apply #'mh-speed-flists t folders-changed)))))
2281 (defun mh-catchup (range)
2282 "Delete RANGE from the `mh-unseen-seq' sequence.
2284 Check the document of `mh-interactive-range' to see how RANGE is read in
2286 (interactive (list (mh-interactive-range "Catchup"
2287 (cons (point-min) (point-max)))))
2288 (mh-delete-msg-from-seq range mh-unseen-seq))
2290 (defun mh-delete-a-msg-from-seq (msg sequence internal-flag)
2291 "Delete MSG from SEQUENCE.
2292 If INTERNAL-FLAG is non-nil, then do not inform MH of the change."
2293 (let ((entry (mh-find-seq sequence)))
2294 (when (and entry (memq msg (mh-seq-msgs entry)))
2295 (if (not internal-flag)
2296 (mh-undefine-sequence sequence (list msg)))
2297 (setcdr entry (delq msg (mh-seq-msgs entry))))))
2299 (defun mh-undefine-sequence (seq msgs)
2300 "Remove from the SEQ the list of MSGS."
2301 (when (and (mh-valid-seq-p seq) msgs)
2302 (apply #'mh-exec-cmd "mark" mh-current-folder "-delete"
2303 "-sequence" (symbol-name seq) (mh-coalesce-msg-list msgs))))
2305 (defun mh-define-sequence (seq msgs)
2306 "Define the SEQ to contain the list of MSGS.
2307 Do not mark pseudo-sequences or empty sequences.
2308 Signals an error if SEQ is an illegal name."
2310 (mh-valid-seq-p seq)
2311 (not (mh-folder-name-p seq)))
2313 (mh-exec-cmd-error nil "mark" mh-current-folder "-add" "-zero"
2314 "-sequence" (symbol-name seq)
2315 (mh-coalesce-msg-list msgs)))))
2317 (defun mh-seq-containing-msg (msg &optional include-internal-flag)
2318 "Return a list of the sequences containing MSG.
2319 If INCLUDE-INTERNAL-FLAG non-nil, include MH-E internal sequences in list."
2320 (let ((l mh-seq-list)
2323 (and (memq msg (mh-seq-msgs (car l)))
2324 (or include-internal-flag
2325 (not (mh-internal-seq (mh-seq-name (car l)))))
2326 (setq seqs (cons (mh-seq-name (car l)) seqs)))
2332 ;;; Build the folder-mode keymap:
2334 (suppress-keymap mh-folder-mode-map)
2336 ;; Use defalias to make sure the documented primary key bindings
2337 ;; appear in menu lists.
2338 (defalias 'mh-alt-show 'mh-show)
2339 (defalias 'mh-alt-refile-msg 'mh-refile-msg)
2340 (defalias 'mh-alt-send 'mh-send)
2341 (defalias 'mh-alt-visit-folder 'mh-visit-folder)
2343 ;; Save the `b' binding for a future `back'. Maybe?
2344 (gnus-define-keys mh-folder-mode-map
2346 "!" mh-refile-or-write-again
2348 "," mh-header-display
2350 ";" mh-toggle-mh-decode-mime-flag
2351 ">" mh-write-msg-to-file
2353 "E" mh-extract-rejected-mail
2355 "\177" mh-previous-page
2356 "\C-d" mh-delete-msg-no-motion
2357 "\t" mh-index-next-folder
2358 [backtab] mh-index-previous-folder
2359 "\M-\t" mh-index-previous-folder
2362 "\ed" mh-redistribute
2364 "^" mh-alt-refile-msg
2371 "k" mh-delete-subject-or-thread
2373 "n" mh-next-undeleted-msg
2374 "\M-n" mh-next-unread-msg
2376 "p" mh-previous-undeleted-msg
2377 "\M-p" mh-previous-unread-msg
2381 "t" mh-toggle-showing
2383 "v" mh-index-visit-folder
2384 "x" mh-execute-commands
2387 (gnus-define-keys (mh-folder-map "F" mh-folder-mode-map)
2389 "'" mh-index-ticked-messages
2392 "f" mh-alt-visit-folder
2396 "n" mh-index-new-messages
2397 "o" mh-alt-visit-folder
2399 "q" mh-index-sequenced-messages
2400 "r" mh-rescan-folder
2401 "s" mh-search-folder
2403 "v" mh-visit-folder)
2405 (define-key mh-folder-mode-map "I" mh-inc-spool-map)
2407 (gnus-define-keys (mh-junk-map "J" mh-folder-mode-map)
2409 "b" mh-junk-blacklist
2410 "w" mh-junk-whitelist)
2412 (gnus-define-keys (mh-ps-print-map "P" mh-folder-mode-map)
2414 "A" mh-ps-print-toggle-mime
2415 "C" mh-ps-print-toggle-color
2416 "F" mh-ps-print-toggle-faces
2417 "M" mh-ps-print-toggle-mime
2418 "f" mh-ps-print-msg-file
2421 "s" mh-ps-print-msg-show)
2423 (gnus-define-keys (mh-sequence-map "S" mh-folder-mode-map)
2424 "'" mh-narrow-to-tick
2426 "d" mh-delete-msg-from-seq
2428 "l" mh-list-sequences
2429 "n" mh-narrow-to-seq
2430 "p" mh-put-msg-in-seq
2431 "s" mh-msg-is-in-seq
2434 (gnus-define-keys (mh-thread-map "T" mh-folder-mode-map)
2436 "u" mh-thread-ancestor
2437 "p" mh-thread-previous-sibling
2438 "n" mh-thread-next-sibling
2439 "t" mh-toggle-threads
2440 "d" mh-thread-delete
2441 "o" mh-thread-refile)
2443 (gnus-define-keys (mh-limit-map "/" mh-folder-mode-map)
2444 "'" mh-narrow-to-tick
2447 "f" mh-narrow-to-from
2448 "r" mh-narrow-to-range
2449 "s" mh-narrow-to-subject
2453 (gnus-define-keys (mh-extract-map "X" mh-folder-mode-map)
2455 "s" mh-store-msg ;shar
2456 "u" mh-store-msg) ;uuencode
2458 (gnus-define-keys (mh-digest-map "D" mh-folder-mode-map)
2461 "\177" mh-page-digest-backwards
2462 "b" mh-burst-digest)
2464 (gnus-define-keys (mh-mime-map "K" mh-folder-mode-map)
2466 "a" mh-mime-save-parts
2467 "e" mh-display-with-external-viewer
2468 "i" mh-folder-inline-mime-part
2469 "o" mh-folder-save-mime-part
2470 "t" mh-toggle-mime-buttons
2471 "v" mh-folder-toggle-mime-part
2473 [backtab] mh-prev-button
2474 "\M-\t" mh-prev-button)
2478 (define-key mh-folder-mode-map [button2] 'mh-show-mouse))
2480 (define-key mh-folder-mode-map [mouse-2] 'mh-show-mouse)))
2482 ;; "C-c /" prefix is used in mh-folder-mode by pgp.el and mailcrypt
2488 ;;; If you add a new prefix, add appropriate text to the nil key.
2490 ;;; In general, messages are grouped logically. Taking the main commands for
2491 ;;; example, the first line is "ways to view messages," the second line is
2492 ;;; "things you can do with messages", and the third is "composing" messages.
2494 ;;; When adding a new prefix, ensure that the help message contains "what" the
2495 ;;; prefix is for. For example, if the word "folder" were not present in the
2496 ;;; `F' entry, it would not be clear what these commands operated upon.
2497 (defvar mh-help-messages
2498 '((nil "[i]nc, [.]show, [,]show all, [n]ext, [p]revious,\n"
2499 "[d]elete, [o]refile, e[x]ecute,\n"
2500 "[s]end, [r]eply,\n"
2501 "[;]toggle MIME decoding.\n"
2502 "Prefix characters:\n [F]older, [S]equence, [J]unk, MIME [K]eys,"
2503 "\n [T]hread, [/]limit, e[X]tract, [D]igest, [I]nc spools.")
2505 (?F "[l]ist; [v]isit folder;\n"
2506 "[n]ew messages; [']ticked messages; [s]earch; [i]ndexed search;\n"
2507 "[p]ack; [S]ort; [r]escan; [k]ill")
2508 (?P "PS [p]rint message; [l]non-PS print;\n"
2509 "PS Print [s]how window, message to [f]ile;\n"
2510 "Toggle printing of [M]IME parts, [C]olor, [F]aces")
2511 (?S "[p]ut message in sequence, [n]arrow, [']narrow to ticked, [w]iden,\n"
2512 "[s]equences, [l]ist,\n"
2513 "[d]elete message from sequence, [k]ill sequence")
2514 (?T "[t]oggle, [d]elete, [o]refile thread")
2515 (?/ "Limit to [c]c, [f]rom, [r]ange, [s]ubject, [t]o; [w]iden")
2516 (?X "un[s]har, [u]udecode message")
2517 (?D "[b]urst digest")
2518 (?K "[v]iew, [i]nline, [o]utput/save MIME part; save [a]ll parts; \n"
2519 "[TAB] next; [SHIFT-TAB] previous")
2520 (?J "[b]lacklist, [w]hitelist message"))
2521 "Key binding cheat sheet.
2523 This is an associative array which is used to show the most common commands.
2524 The key is a prefix char. The value is one or more strings which are
2525 concatenated together and displayed in the minibuffer if ? is pressed after
2526 the prefix character. The special key nil is used to display the
2527 non-prefixed commands.
2529 The substitutions described in `substitute-command-keys' are performed as
2534 (dolist (mess '("^Cursor not pointing to message$"
2535 "^There is no other window$"))
2536 (add-to-list 'debug-ignored-errors mess))
2540 ;;; Local Variables:
2541 ;;; indent-tabs-mode: nil
2542 ;;; sentence-end-double-space: nil
2545 ;;; arch-tag: cce884de-bd37-4104-9963-e4439d5ed22b
2546 ;;; mh-e.el ends here