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. larus@ginger.berkeley.edu
79 ;; Modified by Stephen Gildea 1988. gildea@lcs.mit.edu
80 ;; Maintenance picked up by Bill Wohler <wohler@newt.com> and the
81 ;; SourceForge Crew <http://mh-e.sourceforge.net/>. 2001.
89 (defvar recursive-load-depth-limit)
90 (eval-when (compile load eval)
91 (if (and (boundp 'recursive-load-depth-limit)
92 (integerp recursive-load-depth-limit)
93 (> 50 recursive-load-depth-limit))
94 (setq recursive-load-depth-limit 50)))
100 ;; Shush the byte-compiler
101 (defvar font-lock-auto-fontify)
102 (defvar font-lock-defaults)
104 (defconst mh-version "7.4.4" "Version number of MH-E.")
107 (autoload 'Info-goto-node "info")
111 (defvar mh-note-deleted "D"
112 "String whose first character is used to notate deleted messages.")
114 (defvar mh-note-refiled "^"
115 "String whose first character is used to notate refiled messages.")
117 (defvar mh-note-cur "+"
118 "String whose first character is used to notate the current message.")
120 (defvar mh-partial-folder-mode-line-annotation "select"
121 "Annotation when displaying part of a folder.
122 The string is displayed after the folder's name. nil for no annotation.")
124 ;;; Parameterize MH-E to work with different scan formats. The defaults work
125 ;;; with the standard MH scan listings, in which the first 4 characters on
126 ;;; the line are the message number, followed by two places for notations.
128 ;; The following scan formats are passed to the scan program if the
129 ;; setting of `mh-scan-format-file' above is nil. They are identical
130 ;; except the later one makes use of the nmh `decode' function to
131 ;; decode RFC 2047 encodings. If you just want to change the width of
132 ;; the msg number, use the `mh-set-cmd-note' function.
134 (defvar mh-scan-format-mh
139 "%?(nonnull(comp{to}))%<(mymbox{to})t%>"
140 "%?(nonnull(comp{cc}))%<(mymbox{cc})c%>"
141 "%?(nonnull(comp{bcc}))%<(mymbox{bcc})b%>"
142 "%?(nonnull(comp{newsgroups}))n%>"
144 "%02(mon{date})/%02(mday{date})%<{date} %|*%>"
145 "%<(mymbox{from})%<{to}To:%14(friendly{to})%>%>"
146 "%<(zero)%17(friendly{from})%> "
147 "%{subject}%<{body}<<%{body}%>")
148 "*Scan format string for MH, provided to the scan program via the -format arg.
149 This format is identical to the default except that additional hints for
150 fontification have been added to the fifth column (remember that in Emacs, the
153 The values of the fifth column, in priority order, are: `-' if the
154 message has been replied to, t if an address on the To: line matches
155 one of the mailboxes of the current user, `c' if the Cc: line matches,
156 `b' if the Bcc: line matches, and `n' if a non-empty Newsgroups: header
159 (defvar mh-scan-format-nmh
164 "%?(nonnull(comp{to}))%<(mymbox{to})t%>"
165 "%?(nonnull(comp{cc}))%<(mymbox{cc})c%>"
166 "%?(nonnull(comp{bcc}))%<(mymbox{bcc})b%>"
167 "%?(nonnull(comp{newsgroups}))n%>"
169 "%02(mon{date})/%02(mday{date})%<{date} %|*%>"
170 "%<(mymbox{from})%<{to}To:%14(decode(friendly{to}))%>%>"
171 "%<(zero)%17(decode(friendly{from}))%> "
172 "%(decode{subject})%<{body}<<%{body}%>")
173 "*Scan format string for nmh.
174 This string is passed to the scan program via the -format arg.
175 This format is identical to the default except that additional hints for
176 fontification have been added to the fifth column (remember that in Emacs, the
179 The values of the fifth column, in priority order, are: `-' if the
180 message has been replied to, t if an address on the To: line matches
181 one of the mailboxes of the current user, `c' if the Cc: line matches,
182 `b' if the Bcc: line matches, and `n' if a non-empty Newsgroups: header
185 (defvar mh-scan-good-msg-regexp "^\\( *[0-9]+\\)[^D^0-9]"
186 "Regexp specifying the scan lines that are 'good' messages.
187 The default `mh-folder-font-lock-keywords' expects this expression to contain
188 at least one parenthesized expression which matches the message number.")
190 (defvar mh-scan-deleted-msg-regexp "^\\( *[0-9]+\\)D"
191 "Regexp matching scan lines of deleted messages.
192 The default `mh-folder-font-lock-keywords' expects this expression to contain
193 at least one parenthesized expression which matches the message number.")
195 (defvar mh-scan-refiled-msg-regexp "^\\( *[0-9]+\\)\\^"
196 "Regexp matching scan lines of refiled messages.
197 The default `mh-folder-font-lock-keywords' expects this expression to contain
198 at least one parenthesized expression which matches the message number.")
200 (defvar mh-scan-valid-regexp "^ *[0-9]"
201 "Regexp matching scan lines for messages (not error messages).")
203 (defvar mh-scan-cur-msg-number-regexp "^\\( *[0-9]+\\+\\).*"
204 "Regexp matching scan line for the current message.
205 The default `mh-folder-font-lock-keywords' expects this expression to contain
206 at least one parenthesized expression which matches the message number.
207 Don't disable this regexp as it's needed by non fontifying functions.")
209 (defvar mh-scan-cur-msg-regexp "^\\( *[0-9]+\\+DISABLED.*\\)"
210 "Regexp matching scan line for the current message.
211 The default `mh-folder-font-lock-keywords' expects this expression to contain
212 at least one parenthesized expression which matches the whole line.
213 To enable this feature, remove the string DISABLED from the regexp.")
215 (defvar mh-scan-date-regexp "\\([0-9][0-9]/[0-9][0-9]\\)"
216 "Regexp matching a valid date in scan lines.
217 The default `mh-folder-font-lock-keywords' expects this expression to contain
218 only one parenthesized expression which matches the date field
219 \(see `mh-scan-format-regexp').")
221 (defvar mh-scan-rcpt-regexp "\\(To:\\)\\(..............\\)"
222 "Regexp specifying the recipient in scan lines for messages we sent.
223 The default `mh-folder-font-lock-keywords' expects this expression to contain
224 two parenthesized expressions. The first is expected to match the To:
225 that the default scan format file generates. The second is expected to match
226 the recipient's name.")
228 (defvar mh-scan-body-regexp "\\(<<\\([^\n]+\\)?\\)"
229 "Regexp matching the message body beginning displayed in scan lines.
230 The default `mh-folder-font-lock-keywords' expects this expression to contain
231 at least one parenthesized expression which matches the body text.")
233 (defvar mh-scan-subject-regexp
234 ;;"^ *[0-9]+........[ ]*...................\\([Rr][Ee]:\\s-*\\)*\\([^<\n]*\\)"
235 "^ *[0-9]+........[ ]*...................\\([Rr][Ee]\\(\\[[0-9]+\\]\\)?:\\s-*\\)*\\([^<\n]*\\)"
236 "*Regexp matching the subject string in MH folder mode.
237 The default `mh-folder-font-lock-keywords' expects this expression to contain
238 at least tree parenthesized expressions. The first is expected to match the Re:
239 string, if any. The second matches an optional bracketed number after Re,
240 such as in Re[2]: and the third is expected to match the subject line itself.")
242 (defvar mh-scan-format-regexp
243 (concat "\\([bct]\\)" mh-scan-date-regexp " *\\(..................\\)")
244 "Regexp matching the output of scan.
245 The default value is based upon the default values of either
246 `mh-scan-format-mh' or `mh-scan-format-nmh'.
247 The default `mh-folder-font-lock-keywords' expects this expression to contain
248 at least three parenthesized expressions. The first should match the
249 fontification hint, the second is found in `mh-scan-date-regexp', and the
250 third should match the user name.")
254 (defvar mh-folder-font-lock-keywords
256 ;; Folders when displaying index buffer
258 '(0 mh-index-folder-face))
259 ;; Marked for deletion
260 (list (concat mh-scan-deleted-msg-regexp ".*")
261 '(0 mh-folder-deleted-face))
263 (list (concat mh-scan-refiled-msg-regexp ".*")
264 '(0 mh-folder-refiled-face))
266 (list mh-scan-body-regexp '(1 mh-folder-body-face nil t))
267 '(mh-folder-font-lock-subject
268 (1 mh-folder-followup-face append t)
269 (2 mh-folder-subject-face append t))
271 (list mh-scan-cur-msg-number-regexp
272 '(1 mh-folder-cur-msg-number-face))
273 (list mh-scan-good-msg-regexp
274 '(1 mh-folder-msg-number-face)) ;; Msg number
275 (list mh-scan-date-regexp '(1 mh-folder-date-face)) ;; Date
276 (list mh-scan-rcpt-regexp
277 '(1 mh-folder-to-face) ;; To:
278 '(2 mh-folder-address-face)) ;; address
279 ;; scan font-lock name
280 (list mh-scan-format-regexp
281 '(1 mh-folder-date-face)
282 '(3 mh-folder-scan-format-face))
283 ;; Current message line
284 (list mh-scan-cur-msg-regexp
285 '(1 mh-folder-cur-msg-face prepend t)))
286 "Regexp keywords used to fontify the MH-Folder buffer.")
288 (defvar mh-scan-cmd-note-width 1
289 "Number of columns consumed by the cmd-note field in `mh-scan-format'.
290 This column will have one of the values: ` ', `D', `^', `+' and where
291 ` ' is the default value,
292 `D' is the `mh-note-deleted' character,
293 `^' is the `mh-note-refiled' character, and
294 `+' is the `mh-note-cur' character.")
296 (defvar mh-scan-destination-width 1
297 "Number of columns consumed by the destination field in `mh-scan-format'.
298 This column will have one of ' ', '%', '-', 't', 'c', 'b', or `n' in it.
299 A ' ' blank space is the default character.
300 A '%' indicates that the message in in a named MH sequence.
301 A '-' indicates that the message has been annotated with a replied field.
302 A 't' indicates that the message contains mymbox in the To: field.
303 A 'c' indicates that the message contains mymbox in the Cc: field.
304 A 'b' indicates that the message contains mymbox in the Bcc: field.
305 A 'n' indicates that the message contains a Newsgroups: field.")
307 (defvar mh-scan-date-width 5
308 "Number of columns consumed by the date field in `mh-scan-format'.
309 This column will typically be of the form mm/dd.")
311 (defvar mh-scan-date-flag-width 1
312 "Number of columns consumed to flag (in)valid dates in `mh-scan-format'.
313 This column will have ` ' for valid and `*' for invalid or missing dates.")
315 (defvar mh-scan-from-mbox-width 17
316 "Number of columns consumed with the \"From:\" line in `mh-scan-format'.
317 This column will have a friendly name or e-mail address of the
318 originator, or a \"To: address\" for outgoing e-mail messages.")
320 (defvar mh-scan-from-mbox-sep-width 2
321 "Number of columns consumed by whitespace after from-mbox in `mh-scan-format'.
322 This column will only ever have spaces in it.")
324 (defvar mh-scan-field-from-start-offset
325 (+ mh-scan-cmd-note-width
326 mh-scan-destination-width
328 mh-scan-date-flag-width)
329 "The offset from the `mh-cmd-note' to find the start of \"From:\" address.")
331 (defvar mh-scan-field-from-end-offset
332 (+ mh-scan-field-from-start-offset mh-scan-from-mbox-width)
333 "The offset from the `mh-cmd-note' to find the end of \"From:\" address.")
335 (defvar mh-scan-field-subject-start-offset
336 (+ mh-scan-cmd-note-width
337 mh-scan-destination-width
339 mh-scan-date-flag-width
340 mh-scan-from-mbox-width
341 mh-scan-from-mbox-sep-width)
342 "The offset from the `mh-cmd-note' to find the start of the subject.")
344 (defun mh-folder-font-lock-subject (limit)
345 "Return MH-E scan subject strings to font-lock between point and LIMIT."
346 (if (not (re-search-forward mh-scan-subject-regexp limit t))
348 (if (match-beginning 1)
349 (set-match-data (list (match-beginning 1) (match-end 3)
350 (match-beginning 1) (match-end 3) nil nil))
351 (set-match-data (list (match-beginning 3) (match-end 3)
352 nil nil (match-beginning 3) (match-end 3))))
357 ;; Fontifify unseen mesages in bold.
359 (defvar mh-folder-unseen-seq-name nil
360 "Name of unseen sequence.
361 The default for this is provided by the function `mh-folder-unseen-seq-name'
364 (defun mh-folder-unseen-seq-name ()
365 "Provide name of unseen sequence from mhparam."
366 (or mh-progs (mh-find-path))
368 (let ((unseen-seq-name "unseen"))
372 (call-process (expand-file-name "mhparam" mh-progs)
373 nil '(t t) nil "-component" "Unseen-Sequence")
374 (goto-char (point-min))
375 (if (re-search-forward "Unseen-Sequence: \\(.*\\)$" nil t)
376 (setq unseen-seq-name (match-string 1))))))
379 (defun mh-folder-unseen-seq-list ()
380 "Return a list of unseen message numbers for current folder."
381 (if (not mh-folder-unseen-seq-name)
382 (setq mh-folder-unseen-seq-name (mh-folder-unseen-seq-name)))
384 ((not mh-folder-unseen-seq-name)
387 (let ((folder mh-current-folder))
392 (call-process (expand-file-name "mark" mh-progs)
394 folder "-seq" mh-folder-unseen-seq-name
396 (goto-char (point-min))
397 (sort (mh-read-msg-list) '<)))))))))
399 (defmacro mh-generate-sequence-font-lock (seq prefix face)
400 "Generate the appropriate code to fontify messages in SEQ.
401 PREFIX is used to generate unique names for the variables and functions
402 defined by the macro. So a different prefix should be provided for every
404 FACE is the font-lock face used to display the matching scan lines."
405 (let ((cache (intern (format "mh-folder-%s-seq-cache" prefix)))
406 (func (intern (format "mh-folder-font-lock-%s" prefix))))
409 "Internal cache variable used for font-lock in MH-E.
410 Should only be non-nil through font-lock stepping, and nil once font-lock
411 is done highlighting.")
412 (make-variable-buffer-local ',cache)
415 "Return unseen message lines to font-lock between point and LIMIT."
416 (if (not ,cache) (setq ,cache (mh-seq-msgs (mh-find-seq ,seq))))
417 (let ((cur-msg (mh-get-msg-num nil)))
420 ((>= (point) limit) ;Presumably at end of buffer
423 ((member cur-msg ,cache)
424 (let ((bpoint (progn (beginning-of-line)(point)))
425 (epoint (progn (forward-line 1)(point))))
426 (if (<= limit (point)) (setq ,cache nil))
427 (set-match-data (list bpoint epoint bpoint epoint))
430 ;; move forward one line at a time, checking each message
431 (while (and (= 0 (forward-line 1))
433 (not (member (mh-get-msg-num nil) ,cache))))
434 ;; Examine how we must have exited the loop...
435 (let ((cur-msg (mh-get-msg-num nil)))
436 (cond ((or (<= limit (point))
437 (not (member cur-msg ,cache)))
440 ((member cur-msg ,cache)
441 (let ((bpoint (progn (beginning-of-line) (point)))
442 (epoint (progn (forward-line 1) (point))))
443 (if (<= limit (point)) (setq ,cache nil))
445 (list bpoint epoint bpoint epoint))
448 (setq mh-folder-font-lock-keywords
449 (append mh-folder-font-lock-keywords
450 (list (list ',func (list 1 '',face 'prepend t))))))))
452 (mh-generate-sequence-font-lock mh-unseen-seq unseen bold)
453 (mh-generate-sequence-font-lock mh-tick-seq tick mh-folder-tick-face)
457 ;;; Internal variables:
459 (defvar mh-last-destination nil) ;Destination of last refile or write
461 (defvar mh-last-destination-folder nil) ;Destination of last refile command.
462 (defvar mh-last-destination-write nil) ;Destination of last write command.
464 (defvar mh-folder-mode-map (make-keymap)
465 "Keymap for MH folders.")
467 (defvar mh-arrow-marker nil) ;Marker for arrow display in fringe.
469 (defvar mh-delete-list nil) ;List of msg numbers to delete.
471 (defvar mh-refile-list nil) ;List of folder names in mh-seq-list.
473 (defvar mh-next-direction 'forward) ;Direction to move to next message.
475 (defvar mh-view-ops ()) ;Stack of ops that change the folder
476 ;view (such as narrowing or threading).
477 (defvar mh-folder-view-stack ()) ;Stack of previous folder views.
479 (defvar mh-index-data nil) ;Info about index search results
480 (defvar mh-index-previous-search nil)
481 (defvar mh-index-msg-checksum-map nil)
482 (defvar mh-index-checksum-origin-map nil)
483 (defvar mh-index-sequence-search-flag nil)
485 (defvar mh-first-msg-num nil) ;Number of first msg in buffer.
487 (defvar mh-last-msg-num nil) ;Number of last msg in buffer.
489 (defvar mh-mode-line-annotation nil) ;Message range displayed in buffer.
491 (defvar mh-sequence-notation-history nil)
492 ;Rememeber original notation that
493 ;is overwritten by `mh-note-seq'.
495 ;;; Macros and generic functions:
497 (defun mh-mapc (function list)
498 "Apply FUNCTION to each element of LIST for side effects only."
500 (funcall function (car list))
501 (setq list (cdr list))))
503 (defun mh-scan-format ()
504 "Return the output format argument for the scan program."
505 (if (equal mh-scan-format-file t)
506 (list "-format" (if mh-nmh-flag
507 (list (mh-update-scan-format
508 mh-scan-format-nmh mh-cmd-note))
509 (list (mh-update-scan-format
510 mh-scan-format-mh mh-cmd-note))))
511 (if (not (equal mh-scan-format-file nil))
512 (list "-form" mh-scan-format-file))))
519 (defun mh-rmail (&optional arg)
520 "Inc(orporate) new mail with MH.
521 Scan an MH folder if ARG is non-nil. This function is an entry point to MH-E,
522 the Emacs front end to the MH mail system."
526 (call-interactively 'mh-visit-folder)
527 (unless (get-buffer mh-inbox)
528 (mh-visit-folder mh-inbox (symbol-name mh-unseen-seq)))
532 (defun mh-nmail (&optional arg)
533 "Check for new mail in inbox folder.
534 Scan an MH folder if ARG is non-nil. This function is an entry point to MH-E,
535 the Emacs front end to the MH mail system."
537 (mh-find-path) ; init mh-inbox
539 (call-interactively 'mh-visit-folder)
540 (mh-visit-folder mh-inbox)))
544 ;;; User executable MH-E commands:
546 (defun mh-delete-msg (range)
547 "Mark the specified RANGE for subsequent deletion and move to the next.
548 Default is the displayed message.
550 Check the documentation of `mh-interactive-range' to see how RANGE is read in
552 (interactive (list (mh-interactive-range "Delete")))
553 (mh-delete-msg-no-motion range)
554 (if (looking-at mh-scan-deleted-msg-regexp) (mh-next-msg)))
556 (defun mh-delete-msg-no-motion (range)
557 "Mark the specified RANGE for subsequent deletion.
559 Check the documentation of `mh-interactive-range' to see how RANGE is read in
561 (interactive (list (mh-interactive-range "Delete")))
562 (mh-iterate-on-range () range
563 (mh-delete-a-msg nil)))
565 (defun mh-execute-commands ()
566 "Process outstanding delete and refile requests."
568 (if mh-folder-view-stack (mh-widen t))
569 (mh-process-commands mh-current-folder)
571 (mh-goto-cur-msg) ; after mh-set-scan-mode for efficiency
572 (mh-make-folder-mode-line)
573 t) ; return t for write-file-functions
575 (defun mh-first-msg ()
576 "Move to the first message."
578 (goto-char (point-min))
579 (while (and (not (eobp)) (not (looking-at mh-scan-valid-regexp)))
582 (defun mh-header-display ()
583 "Show the current message with all its headers.
584 Displays headers that might have been suppressed by setting the
585 variables `mh-clean-message-header-flag' or `mhl-formfile', or by the fallback
586 behavior of scrolling uninteresting headers off the top of the window.
587 Type \"\\[mh-show]\" to show the message normally again."
589 (and (not mh-showing-with-headers)
590 (or mhl-formfile mh-clean-message-header-flag)
591 (mh-invalidate-show-buffer))
592 (let ((mh-decode-mime-flag nil)
594 (mh-clean-message-header-flag nil))
596 (mh-in-show-buffer (mh-show-buffer)
597 (goto-char (point-min))
599 (setq mh-showing-with-headers t)))
601 (defun mh-inc-folder (&optional maildrop-name folder)
602 "Inc(orporate)s new mail into the Inbox folder.
603 Optional argument MAILDROP-NAME specifies an alternate maildrop from the
604 default. The optional argument FOLDER specifies where to incorporate mail
605 instead of the default named by `mh-inbox'.
606 The value of `mh-inc-folder-hook' is a list of functions to be called, with no
607 arguments, after incorporating new mail.
608 Do not call this function from outside MH-E; use \\[mh-rmail] instead."
609 (interactive (list (if current-prefix-arg
611 (read-file-name "inc mail from file: "
613 (if current-prefix-arg
614 (mh-prompt-for-folder "inc mail into" mh-inbox t))))
616 (setq folder mh-inbox))
617 (let ((threading-needed-flag nil))
618 (let ((config (current-window-configuration)))
619 (cond ((not (get-buffer folder))
620 (mh-make-folder folder)
621 (setq threading-needed-flag mh-show-threads-flag)
622 (setq mh-previous-window-config config))
623 ((not (eq (current-buffer) (get-buffer folder)))
624 (switch-to-buffer folder)
625 (setq mh-previous-window-config config))))
626 (mh-get-new-mail maildrop-name)
627 (when (and threading-needed-flag
629 (goto-char (point-min))
630 (or (null mh-large-folder)
631 (not (equal (forward-line (1+ mh-large-folder)) 0))
632 (and (message "Not threading since the number of messages exceeds `mh-large-folder'")
636 (if (and mh-showing-mode (looking-at mh-scan-valid-regexp)) (mh-show))
637 (run-hooks 'mh-inc-folder-hook)))
639 (defun mh-last-msg ()
640 "Move to the last message."
642 (goto-char (point-max))
643 (while (and (not (bobp)) (not (looking-at mh-scan-valid-regexp)))
647 (defun mh-next-undeleted-msg (&optional arg wait-after-complaining-flag)
648 "Move to the next undeleted message ARG in window.
649 If optional argument WAIT-AFTER-COMPLAINING-FLAG is non-nil and we are at the
650 last undeleted message then pause for a second after printing message."
652 (setq mh-next-direction 'forward)
654 (cond ((re-search-forward mh-scan-good-msg-regexp nil t arg)
658 (message "No more undeleted messages")
659 (if wait-after-complaining-flag (sit-for 1)))))
661 (defun mh-folder-from-address ()
662 "Determine folder name from address in From field.
663 Takes the address in the From: header field, and returns one of:
665 a) The folder name associated with the address in the alist
666 `mh-default-folder-list'. If the `Check Recipient' boolean
667 is set, then the `mh-default-folder-list' addresses are
668 checked against the recipient instead of the originator
669 (making possible to use this feature for mailing lists).
670 The first match found in `mh-default-folder-list' is used.
672 b) The address' corresponding alias from the user's personal
673 aliases file prefixed by `mh-default-folder-prefix'.
675 Returns nil if the address was not found in either place or if the variable
676 `mh-default-folder-must-exist-flag' is nil and the folder does not exist."
677 ;; Loop for all entries in mh-default-folder-list
679 (goto-char (point-min))
680 (re-search-forward "\n\n" nil t)
681 (narrow-to-region (point-min) (point))
682 (let ((to/cc (concat (or (message-fetch-field "to") "") ", "
683 (or (message-fetch-field "cc") "")))
684 (from (or (message-fetch-field "from") ""))
687 (loop for list in mh-default-folder-list
688 when (string-match (nth 0 list) (if (nth 2 list) to/cc from))
692 ;; Make sure a result from `mh-default-folder-list' begins with "+"
693 ;; since 'mh-expand-file-name below depends on it
694 (when (and folder-name (not (eq (aref folder-name 0) ?+)))
695 (setq folder-name (concat "+" folder-name)))
697 ;; If not, is there an alias for the address?
698 (when (not folder-name)
699 (let* ((from-header (mh-extract-from-header-value))
700 (address (and from-header
701 (nth 1 (mail-extract-address-components
703 (alias (and address (mh-alias-address-to-alias address))))
706 (and alias (concat "+" mh-default-folder-prefix alias))))))
708 ;; If mh-default-folder-must-exist-flag set, check that folder exists.
710 (or (not mh-default-folder-must-exist-flag)
711 (file-exists-p (mh-expand-file-name folder-name))))
714 (defun mh-prompt-for-refile-folder ()
715 "Prompt the user for a folder in which the message should be filed.
716 The folder is returned as a string.
718 If `mh-default-folder-for-message-function' is a function then the message
719 being refiled is yanked into a temporary buffer and the function is called to
720 intelligently guess where the message is to be refiled.
722 Otherwise, a default folder name is generated by `mh-folder-from-address'."
723 (mh-prompt-for-folder
725 (let ((refile-file (mh-msg-filename (mh-get-msg-num t))))
727 (set-buffer (get-buffer-create mh-temp-buffer))
729 (insert-file-contents refile-file)
730 (or (and mh-default-folder-for-message-function
731 (let ((buffer-file-name refile-file))
732 (funcall mh-default-folder-for-message-function)))
733 (mh-folder-from-address)
734 (and (eq 'refile (car mh-last-destination-folder))
735 (symbol-name (cdr mh-last-destination-folder)))
739 (defun mh-refile-msg (range folder &optional dont-update-last-destination-flag)
740 "Refile RANGE into FOLDER.
742 Check the documentation of `mh-interactive-range' to see how RANGE is read in
745 If optional argument DONT-UPDATE-LAST-DESTINATION-FLAG is non-nil then the
746 variables `mh-last-destination' and `mh-last-destination-folder' are not
748 (interactive (list (mh-interactive-range "Refile")
749 (intern (mh-prompt-for-refile-folder))))
750 (unless dont-update-last-destination-flag
751 (setq mh-last-destination (cons 'refile folder)
752 mh-last-destination-folder mh-last-destination))
753 (mh-iterate-on-range () range
754 (mh-refile-a-msg nil folder))
755 (when (looking-at mh-scan-refiled-msg-regexp) (mh-next-msg)))
757 (defun mh-refile-or-write-again (message)
758 "Re-execute the last refile or write command on the given MESSAGE.
759 Default is the displayed message. Use the same folder or file as the previous
760 refile or write command."
761 (interactive (list (mh-get-msg-num t)))
762 (if (null mh-last-destination)
763 (error "No previous refile or write"))
766 (cond ((eq (car mh-last-destination) 'refile)
767 (mh-refile-a-msg message (cdr mh-last-destination))
768 (format "Destination folder: %s" (cdr mh-last-destination)))
770 (apply 'mh-write-msg-to-file message (cdr mh-last-destination))
771 (format "Destination: %s" (cdr mh-last-destination)))))
772 (mh-next-msg (interactive-p))
776 "Quit the current MH-E folder.
777 Restore the previous window configuration, if one exists.
778 The value of `mh-before-quit-hook' is a list of functions to be called, with
779 no arguments, immediately upon entry to this function.
780 The value of `mh-quit-hook' is a list of functions to be called, with no
781 arguments, upon exit of this function.
782 MH-E working buffers (whose name begins with \" *mh-\" or \"*MH-E \") are
785 (run-hooks 'mh-before-quit-hook)
786 (let ((show-buffer (get-buffer mh-show-buffer)))
788 (kill-buffer show-buffer)))
789 (mh-update-sequences)
790 (mh-destroy-postponed-handles)
791 (bury-buffer (current-buffer))
793 ;; Delete all MH-E temporary and working buffers.
794 (dolist (buffer (buffer-list))
795 (when (or (string-match "^ \\*mh-" (buffer-name buffer))
796 (string-match "^\\*MH-E " (buffer-name buffer)))
797 (kill-buffer buffer)))
799 (if mh-previous-window-config
800 (set-window-configuration mh-previous-window-config))
801 (run-hooks 'mh-quit-hook))
803 (defun mh-page-msg (&optional arg)
804 "Page the displayed message forwards.
805 Scrolls ARG lines or a full screen if no argument is supplied. Show buffer
806 first if not displayed. Show the next undeleted message if looking at the
807 bottom of the current message."
810 (if mh-page-to-next-msg-flag
811 (if (equal mh-next-direction 'backward)
812 (mh-previous-undeleted-msg)
813 (mh-next-undeleted-msg))
814 (if (mh-in-show-buffer (mh-show-buffer)
815 (pos-visible-in-window-p (point-max)))
818 "End of message (Type %s to read %s undeleted message)"
819 (single-key-description last-input-event)
820 (if (equal mh-next-direction 'backward)
823 (setq mh-page-to-next-msg-flag t))
824 (scroll-other-window arg)))
827 (defun mh-previous-page (&optional arg)
828 "Page the displayed message backwards.
829 Scrolls ARG lines or a full screen if no argument is supplied."
831 (mh-in-show-buffer (mh-show-buffer)
834 (defun mh-previous-undeleted-msg (&optional arg wait-after-complaining-flag)
835 "Move to the previous undeleted message ARG in window.
836 If optional argument WAIT-AFTER-COMPLAINING-FLAG is non-nil and we are at the
837 first undeleted message then pause for a second after printing message."
839 (setq mh-next-direction 'backward)
841 (cond ((re-search-backward mh-scan-good-msg-regexp nil t arg)
843 (t (message "No previous undeleted message")
844 (if wait-after-complaining-flag (sit-for 1)))))
846 (defun mh-previous-unread-msg (&optional count)
847 "Move to previous unread message.
848 With optional argument COUNT, COUNT-1 unread messages before current message
852 (error "The function mh-previous-unread-msg expects positive argument"))
853 (setq count (1- count))
854 (let ((unread-sequence (cdr (assoc mh-unseen-seq mh-seq-list)))
855 (cur-msg (mh-get-msg-num nil)))
856 (cond ((and (not cur-msg) (not (bobp))
857 ;; If we are at the end of the buffer back up one line and go
858 ;; to unread message after that.
861 (setq cur-msg (mh-get-msg-num nil)))
863 ((or (null unread-sequence) (not cur-msg))
864 ;; No unread message or there aren't any messages in buffer...
865 (message "No more unread messages"))
867 ;; Skip count messages...
868 (while (and unread-sequence (>= (car unread-sequence) cur-msg))
869 (setq unread-sequence (cdr unread-sequence)))
871 (setq unread-sequence (cdr unread-sequence))
872 (setq count (1- count)))
873 (not (car unread-sequence)))
874 (message "No more unread messages"))
875 (t (mh-goto-msg (car unread-sequence))))))
877 (defun mh-goto-next-button (backward-flag &optional criterion)
878 "Search for next button satisfying criterion.
879 If BACKWARD-FLAG is non-nil search backward in the buffer for a mime button. If
880 CRITERION is a function or a symbol which has a function binding then that
881 function must return non-nil at the button we stop."
882 (unless (or (and (symbolp criterion) (fboundp criterion))
883 (functionp criterion))
884 (setq criterion (lambda (x) t)))
885 ;; Move to the next button in the buffer satisfying criterion
886 (goto-char (or (save-excursion
888 ;; Find point before current button
889 (let ((point-before-current-button
891 (while (get-text-property (point) 'mh-data)
892 (unless (= (forward-line
893 (if backward-flag 1 -1))
896 (goto-char (point-min))
897 (goto-char (point-max)))))
899 ;; Skip over current button
900 (while (and (get-text-property (point) 'mh-data)
901 (not (if backward-flag (bobp) (eobp))))
902 (forward-line (if backward-flag -1 1)))
903 ;; Stop at next MIME button if any exists.
906 (unless (= (forward-line
907 (if backward-flag -1 1))
910 (goto-char (point-max))
911 (goto-char (point-min)))
914 point-before-current-button)
915 (when (and (get-text-property (point) 'mh-data)
916 (funcall criterion (point)))
917 (return-from loop (point))))
921 (defun mh-next-button (&optional backward-flag)
922 "Go to the next MIME button.
923 Advance point to the next MIME button in the show buffer. If the end
924 of buffer is reached then the search wraps over to the start of the
925 buffer. With prefix argument, BACKWARD-FLAG the point will move to the
926 previous MIME button."
927 (interactive (list current-prefix-arg))
928 (unless mh-showing-mode
930 (mh-in-show-buffer (mh-show-buffer)
931 (mh-goto-next-button backward-flag)))
933 (defun mh-prev-button ()
934 "Go to the prev MIME button.
935 Move point to the previous MIME button in the show buffer. If the beginning
936 of the buffer is reached then the search wraps over to the end of the
941 (defun mh-folder-mime-action (part-index action include-security-flag)
942 "Go to PART-INDEX and carry out ACTION.
943 If PART-INDEX is nil then go to the next part in the buffer. The search for
944 the next buffer wraps around if end of buffer is reached. If argument
945 INCLUDE-SECURITY-FLAG is non-nil then include security info buttons when
946 searching for a suitable parts."
947 (unless mh-showing-mode
949 (mh-in-show-buffer (mh-show-buffer)
953 (let ((part (get-text-property p 'mh-part)))
954 (and (integerp part) (= part part-index)))))
956 (if include-security-flag
957 (get-text-property p 'mh-data)
958 (integerp (get-text-property p 'mh-part)))))))
960 (cond ((and (get-text-property point 'mh-part)
961 (or (null part-index)
962 (= (get-text-property point 'mh-part) part-index)))
964 ((and (get-text-property point 'mh-data)
965 include-security-flag
969 (mh-goto-next-button nil criterion)
970 (if (= (point) point)
971 (message "No matching MIME part found")
972 (funcall action)))))))
974 (defun mh-folder-toggle-mime-part (part-index)
975 "Toggle display of button.
976 If point in show buffer is at a button then that part is toggled.
977 If not at a button and PART-INDEX is non-nil point is moved to that part.
978 With nil PART-INDEX find the first button after point (search wraps around if
979 end of buffer is reached) and toggle it."
981 (when (consp part-index) (setq part-index (car part-index)))
982 (mh-folder-mime-action part-index #'mh-press-button t))
984 (defun mh-folder-inline-mime-part (part-index)
985 "Show the raw bytes of MIME part inline.
986 If point in show buffer is at a mime part then that part is inlined.
987 If not at a mime-part and PART-INDEX is non-nil point is moved to that part.
988 With nil PART-INDEX find the first button after point (search wraps around if
989 end of buffer is reached) and inline it."
991 (when (consp part-index) (setq part-index (car part-index)))
992 (mh-folder-mime-action part-index #'mh-mime-inline-part nil))
994 (defun mh-folder-save-mime-part (part-index)
996 If point in show buffer is at a mime part then that part is saved.
997 If not at a mime-part and PART-INDEX is non-nil point is moved to that part.
998 With nil PART-INDEX find the first button after point (search wraps around if
999 end of buffer is reached) and save it."
1001 (when (consp part-index) (setq part-index (car part-index)))
1002 (mh-folder-mime-action part-index #'mh-mime-save-part nil))
1004 (defvar mh-thread-scan-line-map-stack)
1006 (defun mh-reset-threads-and-narrowing ()
1007 "Reset all variables pertaining to threads and narrowing.
1008 Also removes all content from the folder buffer."
1009 (setq mh-view-ops ())
1010 (setq mh-folder-view-stack ())
1011 (setq mh-thread-scan-line-map-stack ())
1012 (let ((buffer-read-only nil)) (erase-buffer)))
1014 (defun mh-rescan-folder (&optional range dont-exec-pending)
1015 "Rescan a folder after optionally processing the outstanding commands.
1016 If optional prefix argument RANGE is provided, prompt for the range of
1017 messages to display. Otherwise show the entire folder.
1018 If optional argument DONT-EXEC-PENDING is non-nil then pending deletes and
1019 refiles aren't carried out."
1020 (interactive (list (if current-prefix-arg
1021 (mh-read-range "Rescan" mh-current-folder t nil t
1022 mh-interpret-number-as-range-flag)
1024 (setq mh-next-direction 'forward)
1025 (let ((threaded-flag (memq 'unthread mh-view-ops)))
1026 (mh-scan-folder mh-current-folder (or range "all") dont-exec-pending)
1027 (cond (threaded-flag (mh-toggle-threads))
1028 (mh-index-data (mh-index-insert-folder-headers)))))
1030 (defun mh-write-msg-to-file (msg file no-headers)
1031 "Append MSG to the end of a FILE.
1032 If prefix argument NO-HEADERS is provided, write only the message body.
1033 Otherwise send the entire message including the headers."
1035 (list (mh-get-msg-num t)
1036 (let ((default-dir (if (eq 'write (car mh-last-destination-write))
1037 (file-name-directory
1038 (car (cdr mh-last-destination-write)))
1039 default-directory)))
1040 (read-file-name (format "Save message%s in file: "
1041 (if current-prefix-arg " body" ""))
1043 (if (eq 'write (car mh-last-destination-write))
1044 (car (cdr mh-last-destination-write))
1045 (expand-file-name "mail.out" default-dir))))
1046 current-prefix-arg))
1047 (let ((msg-file-to-output (mh-msg-filename msg))
1048 (output-file (mh-expand-file-name file)))
1049 (setq mh-last-destination (list 'write file (if no-headers 'no-headers))
1050 mh-last-destination-write mh-last-destination)
1052 (set-buffer (get-buffer-create mh-temp-buffer))
1054 (insert-file-contents msg-file-to-output)
1055 (goto-char (point-min))
1056 (if no-headers (search-forward "\n\n"))
1057 (append-to-file (point) (point-max) output-file))))
1059 (defun mh-toggle-showing ()
1060 "Toggle the scanning mode/showing mode of displaying messages."
1066 (defun mh-undo (range)
1067 "Undo the pending deletion or refile of the specified RANGE.
1069 Check the documentation of `mh-interactive-range' to see how RANGE is read in
1071 (interactive (list (mh-interactive-range "Undo")))
1072 (cond ((numberp range)
1073 (let ((original-position (point)))
1075 (while (not (or (looking-at mh-scan-deleted-msg-regexp)
1076 (looking-at mh-scan-refiled-msg-regexp)
1077 (and (eq mh-next-direction 'forward) (bobp))
1078 (and (eq mh-next-direction 'backward)
1079 (save-excursion (forward-line) (eobp)))))
1080 (forward-line (if (eq mh-next-direction 'forward) -1 1)))
1081 (if (or (looking-at mh-scan-deleted-msg-regexp)
1082 (looking-at mh-scan-refiled-msg-regexp))
1084 (mh-undo-msg (mh-get-msg-num t))
1086 (goto-char original-position)
1087 (error "Nothing to undo"))))
1088 (t (mh-iterate-on-range () range
1089 (mh-undo-msg nil))))
1090 (if (not (mh-outstanding-commands-p))
1091 (mh-set-folder-modified-p nil)))
1094 (defun mh-folder-line-matches-show-buffer-p ()
1095 "Return t if the message under point in folder-mode is in the show buffer.
1096 Return nil in any other circumstance (no message under point, no show buffer,
1097 the message in the show buffer doesn't match."
1098 (and (eq major-mode 'mh-folder-mode)
1099 (mh-get-msg-num nil)
1101 (get-buffer mh-show-buffer)
1102 (buffer-file-name (get-buffer mh-show-buffer))
1103 (string-match ".*/\\([0-9]+\\)$"
1104 (buffer-file-name (get-buffer mh-show-buffer)))
1106 (match-string 1 (buffer-file-name (get-buffer mh-show-buffer)))
1107 (int-to-string (mh-get-msg-num nil)))))
1109 (eval-when-compile (require 'gnus))
1111 (defmacro mh-macro-expansion-time-gnus-version ()
1112 "Return Gnus version available at macro expansion time.
1113 The macro evaluates the Gnus version at macro expansion time. If MH-E was
1114 compiled then macro expansion happens at compile time."
1117 (defun mh-run-time-gnus-version ()
1118 "Return Gnus version available at run time."
1123 (defun mh-version ()
1124 "Display version information about MH-E and the MH mail handling system."
1127 (set-buffer (get-buffer-create mh-info-buffer))
1130 (insert "MH-E " mh-version "\n\n")
1131 ;; MH-E compilation details.
1132 (insert "MH-E compilation details:\n")
1133 (let* ((compiled-mhe (byte-code-function-p (symbol-function 'mh-version)))
1134 (gnus-compiled-version (if compiled-mhe
1135 (mh-macro-expansion-time-gnus-version)
1137 (insert " Byte compiled:\t\t" (if compiled-mhe "yes" "no") "\n"
1138 " Gnus (compile-time):\t" gnus-compiled-version "\n"
1139 " Gnus (run-time):\t" (mh-run-time-gnus-version) "\n\n"))
1141 (insert (emacs-version) "\n\n")
1143 (let ((help-start (point)))
1144 (condition-case err-data
1145 (mh-exec-cmd-output "inc" nil (if mh-nmh-flag "-version" "-help"))
1146 (file-error (insert (mapconcat 'concat (cdr err-data) ": ") "\n")))
1147 (goto-char help-start)
1149 (search-forward "inc -- " nil t)
1150 (search-forward "version: " nil t))
1151 (delete-region help-start (point)))
1152 (goto-char (point-max))
1153 (insert " mh-progs:\t" mh-progs "\n"
1154 " mh-lib:\t" mh-lib "\n"
1155 " mh-lib-progs:\t" mh-lib-progs "\n\n")
1158 (call-process "uname" nil t nil "-a")
1160 (goto-char (point-min))
1161 (display-buffer mh-info-buffer))
1163 (defun mh-parse-flist-output-line (line &optional current-folder)
1164 "Parse LINE to generate folder name, unseen messages and total messages.
1165 If CURRENT-FOLDER is non-nil then it contains the current folder name and it is
1166 used to avoid problems in corner cases involving folders whose names end with a
1170 (goto-char (point-max))
1171 (let (folder unseen total p)
1172 (when (search-backward " out of " (point-min) t)
1173 (setq total (read-from-string
1174 (buffer-substring-no-properties
1175 (match-end 0) (line-end-position))))
1176 (when (search-backward " in sequence " (point-min) t)
1178 (when (search-backward " has " (point-min) t)
1179 (setq unseen (read-from-string (buffer-substring-no-properties
1181 (while (eq (char-after) ? )
1183 (setq folder (buffer-substring-no-properties
1184 (point-min) (1+ (point))))
1185 (when (and (equal (aref folder (1- (length folder))) ?+)
1186 (equal current-folder folder))
1187 (setq folder (substring folder 0 (1- (length folder)))))
1188 (values (format "+%s" folder) (car unseen) (car total))))))))
1190 (defun mh-folder-size-folder (folder)
1191 "Find size of FOLDER using `folder'."
1193 (let ((u (length (cdr (assoc mh-unseen-seq
1194 (mh-read-folder-sequences folder nil))))))
1195 (call-process (expand-file-name "folder" mh-progs) nil t nil
1196 "-norecurse" folder)
1197 (goto-char (point-min))
1198 (if (re-search-forward " has \\([0-9]+\\) " nil t)
1199 (values (car (read-from-string (match-string 1))) u folder)
1200 (values 0 u folder)))))
1202 (defun mh-folder-size-flist (folder)
1203 "Find size of FOLDER using `flist'."
1205 (call-process (expand-file-name "flist" mh-progs) nil t nil
1206 "-norecurse" folder "-sequence" (symbol-name mh-unseen-seq))
1207 (goto-char (point-min))
1208 (multiple-value-bind (folder unseen total)
1209 (mh-parse-flist-output-line
1210 (buffer-substring (point) (line-end-position)))
1211 (values total unseen folder))))
1213 (defun mh-folder-size (folder)
1214 "Find size of FOLDER."
1215 (if mh-flists-present-flag
1216 (mh-folder-size-flist folder)
1217 (mh-folder-size-folder folder)))
1219 (defun mh-visit-folder (folder &optional range index-data)
1220 "Visit FOLDER and display RANGE of messages.
1221 Do not call this function from outside MH-E; see \\[mh-rmail] instead.
1223 If RANGE is nil (the default if it is omitted when called non-interactively),
1224 then all messages in FOLDER are displayed.
1226 If an index buffer is being created then INDEX-DATA is used to initialize the
1227 index buffer specific data structures.
1229 A prefix argument will cause a prompt for the RANGE of messages
1230 regardless of the size of the `mh-large-folder' variable."
1231 (interactive (let ((folder-name (mh-prompt-for-folder "Visit" mh-inbox t)))
1233 (mh-read-range "Scan" folder-name t nil
1235 mh-interpret-number-as-range-flag))))
1236 (let ((config (current-window-configuration))
1237 (current-buffer (current-buffer))
1238 (threaded-view-flag mh-show-threads-flag))
1240 (when (get-buffer folder)
1242 (setq threaded-view-flag (memq 'unthread mh-view-ops))))
1244 (mh-make-folder folder)
1245 (setq mh-index-data (car index-data)
1246 mh-index-msg-checksum-map (make-hash-table :test #'equal)
1247 mh-index-checksum-origin-map (make-hash-table :test #'equal))
1248 (mh-index-update-maps folder (cadr index-data))
1249 (mh-index-create-sequences))
1250 (mh-scan-folder folder (or range "all"))
1251 (cond ((and threaded-view-flag
1253 (goto-char (point-min))
1254 (or (null mh-large-folder)
1255 (not (equal (forward-line (1+ mh-large-folder)) 0))
1256 (and (message "Not threading since the number of messages exceeds `mh-large-folder'")
1258 (mh-toggle-threads))
1260 (mh-index-insert-folder-headers)))
1261 (unless mh-showing-mode (delete-other-windows))
1262 (unless (eq current-buffer (current-buffer))
1263 (setq mh-previous-window-config config)))
1267 (defun mh-update-sequences ()
1268 "Update MH's Unseen-Sequence and current folder and message.
1269 Flush MH-E's state out to MH. The message at the cursor becomes current."
1271 ;; mh-update-sequences is the opposite of mh-read-folder-sequences,
1272 ;; which updates MH-E's state from MH.
1273 (let ((folder-set (mh-update-unseen))
1274 (new-cur (mh-get-msg-num nil)))
1276 (let ((seq-entry (mh-find-seq 'cur)))
1277 (mh-remove-cur-notation)
1279 (list new-cur)) ;delete-seq-locally, add-msgs-to-seq
1280 (mh-define-sequence 'cur (list new-cur))
1282 (if (looking-at mh-scan-good-msg-regexp)
1286 ;; psg - mh-current-folder is nil if mh-summary-height < 4 !
1287 ;; So I added this sanity check.
1288 (if (stringp mh-current-folder)
1289 (mh-exec-cmd-quiet t "folder" mh-current-folder "-fast")
1290 (mh-exec-cmd-quiet t "folder" "-fast")))))))
1294 ;;; Support routines.
1296 (defun mh-delete-a-msg (msg)
1298 If MSG is nil then the message at point is deleted.
1300 The value of `mh-delete-msg-hook' is a list of functions to be called, with no
1301 arguments, after the message has been deleted."
1304 (mh-goto-msg msg nil t)
1306 (setq msg (mh-get-msg-num t)))
1307 (if (looking-at mh-scan-refiled-msg-regexp)
1308 (error "Message %d is refiled. Undo refile before deleting" msg))
1309 (if (looking-at mh-scan-deleted-msg-regexp)
1311 (mh-set-folder-modified-p t)
1312 (setq mh-delete-list (cons msg mh-delete-list))
1313 (mh-notate nil mh-note-deleted mh-cmd-note)
1314 (run-hooks 'mh-delete-msg-hook))))
1316 (defun mh-refile-a-msg (msg folder)
1317 "Refile MSG in FOLDER.
1318 If MSG is nil then the message at point is refiled.
1320 Folder is a symbol, not a string.
1321 The value of `mh-refile-msg-hook' is a list of functions to be called, with no
1322 arguments, after the message has been refiled."
1325 (mh-goto-msg msg nil t)
1327 (setq msg (mh-get-msg-num t)))
1328 (cond ((looking-at mh-scan-deleted-msg-regexp)
1329 (error "Message %d is deleted. Undo delete before moving" msg))
1330 ((looking-at mh-scan-refiled-msg-regexp)
1332 (format "Message %d already refiled. Copy to %s as well? "
1334 (mh-exec-cmd "refile" (mh-get-msg-num t) "-link"
1335 "-src" mh-current-folder
1336 (symbol-name folder))
1337 (message "Message not copied.")))
1339 (mh-set-folder-modified-p t)
1340 (cond ((null (assoc folder mh-refile-list))
1341 (push (list folder msg) mh-refile-list))
1342 ((not (member msg (cdr (assoc folder mh-refile-list))))
1343 (push msg (cdr (assoc folder mh-refile-list)))))
1344 (mh-notate nil mh-note-refiled mh-cmd-note)
1345 (run-hooks 'mh-refile-msg-hook)))))
1347 (defun mh-next-msg (&optional wait-after-complaining-flag)
1348 "Move backward or forward to the next undeleted message in the buffer.
1349 If optional argument WAIT-AFTER-COMPLAINING-FLAG is non-nil and we are at the
1350 last message, then wait for a second after telling the user that there aren't
1351 any more unread messages."
1352 (if (eq mh-next-direction 'forward)
1353 (mh-next-undeleted-msg 1 wait-after-complaining-flag)
1354 (mh-previous-undeleted-msg 1 wait-after-complaining-flag)))
1356 (defun mh-next-unread-msg (&optional count)
1357 "Move to next unread message.
1358 With optional argument COUNT, COUNT-1 unread messages are skipped."
1361 (error "The function mh-next-unread-msg expects positive argument"))
1362 (setq count (1- count))
1363 (let ((unread-sequence (reverse (cdr (assoc mh-unseen-seq mh-seq-list))))
1364 (cur-msg (mh-get-msg-num nil)))
1365 (cond ((and (not cur-msg) (not (bobp))
1366 ;; If we are at the end of the buffer back up one line and go
1367 ;; to unread message after that.
1370 (setq cur-msg (mh-get-msg-num nil)))
1372 ((or (null unread-sequence) (not cur-msg))
1373 ;; No unread message or there aren't any messages in buffer...
1374 (message "No more unread messages"))
1377 (while (and unread-sequence (>= cur-msg (car unread-sequence)))
1378 (setq unread-sequence (cdr unread-sequence)))
1380 (setq unread-sequence (cdr unread-sequence))
1381 (setq count (1- count)))
1382 (not (car unread-sequence)))
1383 (message "No more unread messages"))
1384 (t (mh-goto-msg (car unread-sequence))))))
1386 (defun mh-set-scan-mode ()
1387 "Display the scan listing buffer, but do not show a message."
1388 (if (get-buffer mh-show-buffer)
1389 (delete-windows-on mh-show-buffer))
1391 (force-mode-line-update)
1392 (if mh-recenter-summary-flag
1395 (defun mh-undo-msg (msg)
1396 "Undo the deletion or refile of one MSG.
1397 If MSG is nil then act on the message at point"
1400 (mh-goto-msg msg t t)
1402 (setq msg (mh-get-msg-num t)))
1403 (cond ((memq msg mh-delete-list)
1404 (setq mh-delete-list (delq msg mh-delete-list)))
1406 (dolist (folder-msg-list mh-refile-list)
1407 (setf (cdr folder-msg-list) (remove msg (cdr folder-msg-list))))
1408 (setq mh-refile-list (loop for x in mh-refile-list
1409 unless (null (cdr x)) collect x))))
1410 (mh-notate nil ? mh-cmd-note)))
1414 ;;; The folder data abstraction.
1416 (defvar mh-index-data-file ".mhe_index"
1417 "MH-E specific file where index seach info is stored.")
1419 (defun mh-make-folder (name)
1420 "Create a new mail folder called NAME.
1421 Make it the current folder."
1422 (switch-to-buffer name)
1423 (setq buffer-read-only nil)
1425 (if mh-adaptive-cmd-note-flag
1426 (mh-set-cmd-note (mh-message-number-width name)))
1427 (setq buffer-read-only t)
1429 (mh-set-folder-modified-p nil)
1430 (setq buffer-file-name mh-folder-filename)
1431 (when (and (not mh-index-data)
1432 (file-exists-p (concat buffer-file-name mh-index-data-file)))
1433 (mh-index-read-data))
1434 (mh-make-folder-mode-line))
1436 ;;; Ensure new buffers won't get this mode if default-major-mode is nil.
1437 (put 'mh-folder-mode 'mode-class 'special)
1441 ;;; Menu extracted from mh-menubar.el V1.1 (31 July 2001)
1442 ;;; Menus for folder mode: folder, message, sequence (in that order)
1443 ;;; folder-mode "Sequence" menu
1445 mh-folder-sequence-menu mh-folder-mode-map "Menu for MH-E folder-sequence."
1447 ["Add Message to Sequence..." mh-put-msg-in-seq (mh-get-msg-num nil)]
1448 ["List Sequences for Message" mh-msg-is-in-seq (mh-get-msg-num nil)]
1449 ["Delete Message from Sequence..." mh-delete-msg-from-seq
1450 (mh-get-msg-num nil)]
1451 ["List Sequences in Folder..." mh-list-sequences t]
1452 ["Delete Sequence..." mh-delete-seq t]
1453 ["Narrow to Sequence..." mh-narrow-to-seq t]
1454 ["Widen from Sequence" mh-widen mh-folder-view-stack]
1456 ["Narrow to Subject Sequence" mh-narrow-to-subject t]
1457 ["Narrow to Tick Sequence" mh-narrow-to-tick
1458 (and mh-tick-seq (mh-seq-msgs (mh-find-seq mh-tick-seq)))]
1459 ["Delete Rest of Same Subject" mh-delete-subject t]
1460 ["Toggle Tick Mark" mh-toggle-tick t]
1462 ["Push State Out to MH" mh-update-sequences t]))
1464 ;;; folder-mode "Message" menu
1466 mh-folder-message-menu mh-folder-mode-map "Menu for MH-E folder-message."
1468 ["Show Message" mh-show (mh-get-msg-num nil)]
1469 ["Show Message with Header" mh-header-display (mh-get-msg-num nil)]
1470 ["Next Message" mh-next-undeleted-msg t]
1471 ["Previous Message" mh-previous-undeleted-msg t]
1472 ["Go to First Message" mh-first-msg t]
1473 ["Go to Last Message" mh-last-msg t]
1474 ["Go to Message by Number..." mh-goto-msg t]
1475 ["Modify Message" mh-modify]
1476 ["Delete Message" mh-delete-msg (mh-get-msg-num nil)]
1477 ["Refile Message" mh-refile-msg (mh-get-msg-num nil)]
1478 ["Undo Delete/Refile" mh-undo t]
1479 ["Process Delete/Refile" mh-execute-commands
1480 (or mh-refile-list mh-delete-list)]
1482 ["Compose a New Message" mh-send t]
1483 ["Reply to Message..." mh-reply (mh-get-msg-num nil)]
1484 ["Forward Message..." mh-forward (mh-get-msg-num nil)]
1485 ["Redistribute Message..." mh-redistribute (mh-get-msg-num nil)]
1486 ["Edit Message Again" mh-edit-again (mh-get-msg-num nil)]
1487 ["Re-edit a Bounced Message" mh-extract-rejected-mail t]
1489 ["Copy Message to Folder..." mh-copy-msg (mh-get-msg-num nil)]
1490 ["Print Message" mh-print-msg (mh-get-msg-num nil)]
1491 ["Write Message to File..." mh-write-msg-to-file
1492 (mh-get-msg-num nil)]
1493 ["Pipe Message to Command..." mh-pipe-msg (mh-get-msg-num nil)]
1494 ["Unpack Uuencoded Message..." mh-store-msg (mh-get-msg-num nil)]
1495 ["Burst Digest Message" mh-burst-digest (mh-get-msg-num nil)]))
1497 ;;; folder-mode "Folder" menu
1499 mh-folder-folder-menu mh-folder-mode-map "Menu for MH-E folder."
1501 ["Incorporate New Mail" mh-inc-folder t]
1502 ["Toggle Show/Folder" mh-toggle-showing t]
1503 ["Execute Delete/Refile" mh-execute-commands
1504 (or mh-refile-list mh-delete-list)]
1505 ["Rescan Folder" mh-rescan-folder t]
1506 ["Thread Folder" mh-toggle-threads
1507 (not (memq 'unthread mh-view-ops))]
1508 ["Pack Folder" mh-pack-folder t]
1509 ["Sort Folder" mh-sort-folder t]
1511 ["List Folders" mh-list-folders t]
1512 ["Visit a Folder..." mh-visit-folder t]
1513 ["View New Messages" mh-index-new-messages t]
1514 ["Search a Folder..." mh-search-folder t]
1515 ["Indexed Search..." mh-index-search t]
1517 ["Quit MH-E" mh-quit t]))
1521 (defmacro mh-remove-xemacs-horizontal-scrollbar ()
1522 "Get rid of the horizontal scrollbar that XEmacs insists on putting in."
1523 (when mh-xemacs-flag
1524 `(if (and (featurep 'scrollbar)
1525 (fboundp 'set-specifier))
1526 (set-specifier horizontal-scrollbar-visible-p nil
1527 (cons (current-buffer) nil)))))
1529 (defmacro mh-write-file-functions-compat ()
1530 "Return `write-file-functions' if it exists.
1531 Otherwise return `local-write-file-hooks'. This macro exists purely for
1532 compatibility. The former symbol is used in Emacs 21.4 onward while the latter
1533 is used in previous versions and XEmacs."
1534 (if (boundp 'write-file-functions)
1535 ''write-file-functions ;Emacs 21.4
1536 ''local-write-file-hooks)) ;<Emacs 21.4, XEmacs
1538 ;; Avoid compiler warnings in non-bleeding edge versions of Emacs.
1540 (defvar tool-bar-mode)
1541 (defvar tool-bar-map)
1542 (defvar desktop-save-buffer)) ;Emacs 21.4
1544 (define-derived-mode mh-folder-mode fundamental-mode "MH-Folder"
1545 "Major MH-E mode for \"editing\" an MH folder scan listing.\\<mh-folder-mode-map>
1547 You can show the message the cursor is pointing to, and step through the
1548 messages. Messages can be marked for deletion or refiling into another
1549 folder; these commands are executed all at once with a separate command.
1551 A prefix argument (\\[universal-argument]) to delete, refile, list, or undo
1552 applies the action to a message sequence. If `transient-mark-mode',
1553 is non-nil, the action is applied to the region.
1555 Options that control this mode can be changed with \\[customize-group];
1556 specify the \"mh\" group. In particular, please see the `mh-scan-format-file'
1557 option if you wish to modify scan's format.
1559 When a folder is visited, the hook `mh-folder-mode-hook' is run.
1561 \\{mh-folder-mode-map}"
1563 (make-local-variable 'font-lock-defaults)
1564 (setq font-lock-defaults '(mh-folder-font-lock-keywords t))
1565 (make-local-variable 'desktop-save-buffer)
1566 (setq desktop-save-buffer t)
1568 'mh-current-folder (buffer-name) ; Name of folder, a string
1569 'mh-show-buffer (format "show-%s" (buffer-name)) ; Buffer that displays msgs
1570 'mh-folder-filename ; e.g. "/usr/foobar/Mail/inbox/"
1571 (file-name-as-directory (mh-expand-file-name (buffer-name)))
1572 'mh-arrow-marker (make-marker) ; Marker where arrow is displayed
1573 'overlay-arrow-position nil ; Allow for simultaneous display in
1574 'overlay-arrow-string ">" ; different MH-E buffers.
1575 'mh-showing-mode nil ; Show message also?
1576 'mh-delete-list nil ; List of msgs nums to delete
1577 'mh-refile-list nil ; List of folder names in mh-seq-list
1578 'mh-seq-list nil ; Alist of (seq . msgs) nums
1579 'mh-seen-list nil ; List of displayed messages
1580 'mh-next-direction 'forward ; Direction to move to next message
1581 'mh-view-ops () ; Stack that keeps track of the order
1582 ; in which narrowing/threading has been
1584 'mh-folder-view-stack () ; Stack of previous views of the
1586 'mh-index-data nil ; If the folder was created by a call
1587 ; to mh-index-search this contains info
1588 ; about the search results.
1589 'mh-index-previous-search nil ; Previous folder and search-regexp
1590 'mh-index-msg-checksum-map nil ; msg -> checksum map
1591 'mh-index-checksum-origin-map nil ; checksum -> ( orig-folder, orig-msg )
1592 'mh-index-sequence-search-flag nil ; folder resulted from sequence search
1593 'mh-first-msg-num nil ; Number of first msg in buffer
1594 'mh-last-msg-num nil ; Number of last msg in buffer
1595 'mh-msg-count nil ; Number of msgs in buffer
1596 'mh-mode-line-annotation nil ; Indicates message range
1597 'mh-sequence-notation-history (make-hash-table)
1598 ; Remember what is overwritten by
1600 'mh-previous-window-config nil) ; Previous window configuration
1601 (mh-remove-xemacs-horizontal-scrollbar)
1602 (setq truncate-lines t)
1604 (setq buffer-offer-save t)
1605 (mh-make-local-hook (mh-write-file-functions-compat))
1606 (add-hook (mh-write-file-functions-compat) 'mh-execute-commands nil t)
1607 (make-local-variable 'revert-buffer-function)
1608 (make-local-variable 'hl-line-mode) ; avoid pollution
1609 (mh-funcall-if-exists hl-line-mode 1)
1610 (setq revert-buffer-function 'mh-undo-folder)
1611 (or (assq 'mh-showing-mode minor-mode-alist)
1612 (setq minor-mode-alist
1613 (cons '(mh-showing-mode " Show") minor-mode-alist)))
1614 (easy-menu-add mh-folder-sequence-menu)
1615 (easy-menu-add mh-folder-message-menu)
1616 (easy-menu-add mh-folder-folder-menu)
1617 (set (make-local-variable 'tool-bar-map) mh-folder-tool-bar-map)
1618 (mh-funcall-if-exists mh-toolbar-init :folder)
1619 (if (and mh-xemacs-flag
1620 font-lock-auto-fontify)
1621 (turn-on-font-lock))) ; Force font-lock in XEmacs.
1623 (defun mh-make-local-vars (&rest pairs)
1624 "Initialize local variables according to the variable-value PAIRS."
1627 (set (make-local-variable (car pairs)) (car (cdr pairs)))
1628 (setq pairs (cdr (cdr pairs)))))
1631 (defun mh-restore-desktop-buffer (desktop-buffer-file-name
1633 desktop-buffer-misc)
1634 "Restore an MH folder buffer specified in a desktop file."
1636 (mh-visit-folder desktop-buffer-name)
1639 (defun mh-scan-folder (folder range &optional dont-exec-pending)
1640 "Scan the FOLDER over the RANGE.
1641 If the optional argument DONT-EXEC-PENDING is non-nil then pending deletes and
1642 refiles aren't carried out.
1643 Return in the folder's buffer."
1644 (cond ((null (get-buffer folder))
1645 (mh-make-folder folder))
1647 (unless dont-exec-pending
1648 (mh-process-or-undo-commands folder)
1649 (mh-reset-threads-and-narrowing))
1650 (switch-to-buffer folder)))
1651 (mh-regenerate-headers range)
1652 (if (zerop (buffer-size))
1653 (if (equal range "all")
1654 (message "Folder %s is empty" folder)
1655 (message "No messages in %s, range %s" folder range))
1657 (when (mh-outstanding-commands-p)
1658 (mh-notate-deleted-and-refiled)))
1660 (defun mh-set-cmd-note (width)
1661 "Set `mh-cmd-note' to WIDTH characters (minimum of 2).
1663 If `mh-scan-format-file' specifies nil or a filename, then this function
1664 will NOT update `mh-cmd-note'."
1665 ;; Add one to the width to always have whitespace in column zero.
1666 (setq width (max (1+ width) 2))
1667 (if (and (equal mh-scan-format-file t)
1668 (not (eq mh-cmd-note width)))
1669 (setq mh-cmd-note width))
1672 (defun mh-regenerate-headers (range &optional update)
1673 "Scan folder over range RANGE.
1674 If UPDATE, append the scan lines, otherwise replace."
1675 (let ((folder mh-current-folder)
1676 (range (if (and range (atom range)) (list range) range))
1678 (message "Scanning %s..." folder)
1679 (mh-remove-all-notation)
1680 (with-mh-folder-updating (nil)
1682 (goto-char (point-max))
1683 (delete-region (point-min) (point-max))
1684 (if mh-adaptive-cmd-note-flag
1685 (mh-set-cmd-note (mh-message-number-width folder))))
1686 (setq scan-start (point))
1687 (apply #'mh-exec-cmd-output
1690 "-noclear" "-noheader"
1691 "-width" (window-width)
1693 (goto-char scan-start)
1694 (cond ((looking-at "scan: no messages in")
1695 (keep-lines mh-scan-valid-regexp)) ; Flush random scan lines
1696 ((looking-at "scan: bad message list ")
1697 (keep-lines mh-scan-valid-regexp))
1698 ((looking-at "scan: ")) ; Keep error messages
1700 (keep-lines mh-scan-valid-regexp))) ; Flush random scan lines
1701 (setq mh-seq-list (mh-read-folder-sequences folder nil))
1702 (mh-notate-user-sequences)
1704 (setq mh-mode-line-annotation
1705 (if (equal range '("all"))
1707 mh-partial-folder-mode-line-annotation)))
1708 (mh-make-folder-mode-line))
1709 (message "Scanning %s...done" folder)))
1711 (defun mh-generate-new-cmd-note (folder)
1712 "Fix the `mh-cmd-note' value for this FOLDER.
1714 After doing an `mh-get-new-mail' operation in this FOLDER, at least
1715 one line that looks like a truncated message number was found.
1717 Remove the text added by the last `mh-inc' command. It should be the
1718 messages cur-last. Call `mh-set-cmd-note' with the widest message number
1721 Reformat the message number width on each line in the buffer and trim
1722 the line length to fit in the window.
1724 Rescan the FOLDER in the range cur-last in order to display the
1725 messages that were removed earlier. They should all fit in the scan
1726 line now with no message truncation."
1728 (let ((maxcol (1- (window-width)))
1729 (old-cmd-note mh-cmd-note)
1732 ;; Nuke all of the lines just added by the last inc
1733 (delete-char (- (point-max) (point)))
1734 ;; Update the current buffer to reflect the new mh-cmd-note
1735 ;; value needed to display messages.
1736 (mh-set-cmd-note (mh-message-number-width folder))
1737 (setq mh-cmd-note-fmt (concat "%" (format "%d" mh-cmd-note) "d"))
1738 ;; Cleanup the messages that are in the buffer right now
1739 (goto-char (point-min))
1740 (cond ((memq 'unthread mh-view-ops)
1741 (mh-thread-add-spaces (- mh-cmd-note old-cmd-note)))
1742 (t (while (re-search-forward mh-scan-msg-number-regexp nil 0 1)
1743 ;; reformat the number to fix in mh-cmd-note columns
1744 (setq msgnum (string-to-number
1746 (match-beginning 1) (match-end 1))))
1747 (replace-match (format mh-cmd-note-fmt msgnum))
1748 ;; trim the line to fix in the window
1750 (let ((eol (point)))
1751 (move-to-column maxcol)
1752 (if (<= (point) eol)
1753 (delete-char (- eol (point))))))))
1754 ;; now re-read the lost messages
1755 (goto-char (point-max))
1757 (mh-regenerate-headers "cur-last" t)))))
1759 (defun mh-get-new-mail (maildrop-name)
1760 "Read new mail from MAILDROP-NAME into the current buffer.
1761 Return in the current buffer."
1762 (let ((point-before-inc (point))
1763 (folder mh-current-folder)
1764 (new-mail-flag nil))
1765 (with-mh-folder-updating (t)
1767 (message "inc %s -file %s..." folder maildrop-name)
1768 (message "inc %s..." folder))
1769 (setq mh-next-direction 'forward)
1770 (goto-char (point-max))
1771 (mh-remove-all-notation)
1772 (let ((start-of-inc (point)))
1774 ;; I think MH 5 used "-ms-file" instead of "-file",
1775 ;; which would make inc'ing from maildrops fail.
1776 (mh-exec-cmd-output mh-inc-prog nil folder
1778 "-file" (expand-file-name maildrop-name)
1779 "-width" (window-width)
1781 (mh-exec-cmd-output mh-inc-prog nil
1783 "-width" (window-width)))
1785 (message "inc %s -file %s...done" folder maildrop-name)
1786 (message "inc %s...done" folder))
1787 (goto-char start-of-inc)
1788 (cond ((save-excursion
1789 (re-search-forward "^inc: no mail" nil t))
1790 (message "No new mail%s%s" (if maildrop-name " in " "")
1791 (if maildrop-name maildrop-name "")))
1792 ((and (when mh-folder-view-stack
1793 (let ((saved-text (buffer-substring-no-properties
1794 start-of-inc (point-max))))
1795 (delete-region start-of-inc (point-max))
1796 (unwind-protect (mh-widen t)
1797 (mh-remove-all-notation)
1798 (goto-char (point-max))
1799 (setq start-of-inc (point))
1801 (goto-char start-of-inc))))
1803 ((re-search-forward "^inc:" nil t) ; Error messages
1804 (error "Error incorporating mail"))
1806 (equal mh-scan-format-file t)
1807 mh-adaptive-cmd-note-flag
1808 ;; Have we reached an edge condition?
1810 (re-search-forward mh-scan-msg-overflow-regexp nil 0 1))
1811 (setq start-of-inc (mh-generate-new-cmd-note folder))
1814 (setq new-mail-flag t)))
1815 (keep-lines mh-scan-valid-regexp) ; Flush random scan lines
1816 (setq mh-seq-list (mh-read-folder-sequences folder t))
1817 (when (equal (point-max) start-of-inc)
1821 (mh-make-folder-mode-line)
1822 (when (mh-speed-flists-active-p)
1823 (mh-speed-flists t mh-current-folder))
1824 (when (memq 'unthread mh-view-ops)
1825 (mh-thread-inc folder start-of-inc))
1827 (goto-char point-before-inc))
1828 (mh-notate-user-sequences)
1829 (mh-notate-deleted-and-refiled)))))
1831 (defun mh-make-folder-mode-line (&optional ignored)
1832 "Set the fields of the mode line for a folder buffer.
1833 The optional argument is now obsolete and IGNORED. It used to be used to pass
1834 in what is now stored in the buffer-local variable `mh-mode-line-annotation'."
1836 (save-window-excursion
1838 (let ((new-first-msg-num (mh-get-msg-num nil)))
1839 (when (or (not (memq 'unthread mh-view-ops))
1840 (null mh-first-msg-num)
1841 (null new-first-msg-num)
1842 (< new-first-msg-num mh-first-msg-num))
1843 (setq mh-first-msg-num new-first-msg-num)))
1845 (let ((new-last-msg-num (mh-get-msg-num nil)))
1846 (when (or (not (memq 'unthread mh-view-ops))
1847 (null mh-last-msg-num)
1848 (null new-last-msg-num)
1849 (> new-last-msg-num mh-last-msg-num))
1850 (setq mh-last-msg-num new-last-msg-num)))
1851 (setq mh-msg-count (if mh-first-msg-num
1852 (count-lines (point-min) (point-max))
1854 (setq mode-line-buffer-identification
1855 (list (format " {%%b%s} %s msg%s"
1856 (if mh-mode-line-annotation
1857 (format "/%s" mh-mode-line-annotation)
1859 (if (zerop mh-msg-count)
1861 (format "%d" mh-msg-count))
1862 (if (zerop mh-msg-count)
1864 (cond ((> mh-msg-count 1)
1865 (format "s (%d-%d)" mh-first-msg-num
1868 (format " (%d)" mh-first-msg-num))
1870 (mh-logo-display))))
1872 ;;; XXX: Remove this function, if no one uses it any more...
1873 (defun mh-unmark-all-headers (remove-all-flags)
1874 "Remove all '+' flags from the folder listing.
1875 With non-nil argument REMOVE-ALL-FLAGS, remove all 'D', '^' and '%' flags too.
1876 Optimized for speed (i.e., no regular expressions).
1878 This function is deprecated. Use `mh-remove-all-notation' instead."
1880 (let ((case-fold-search nil)
1881 (last-line (1- (point-max)))
1884 (while (<= (point) last-line)
1885 (forward-char mh-cmd-note)
1886 (setq char (following-char))
1887 (if (or (and remove-all-flags
1888 (or (= char (aref mh-note-deleted 0))
1889 (= char (aref mh-note-refiled 0))))
1890 (= char (aref mh-note-cur 0)))
1894 (if remove-all-flags
1897 (if (= (following-char) (aref mh-note-seq 0))
1903 (defun mh-add-sequence-notation (msg internal-seq-flag)
1904 "Add sequence notation to the MSG on the current line.
1905 If INTERNAL-SEQ-FLAG is non-nil, then just remove text properties from the
1906 current line, so that font-lock would automatically refontify it."
1907 (with-mh-folder-updating (t)
1910 (if internal-seq-flag
1911 (mh-notate nil nil mh-cmd-note)
1912 (forward-char (1+ mh-cmd-note))
1913 (let ((stack (gethash msg mh-sequence-notation-history)))
1914 (setf (gethash msg mh-sequence-notation-history)
1915 (cons (char-after) stack)))
1916 (mh-notate nil mh-note-seq (1+ mh-cmd-note))))))
1918 (defun mh-remove-sequence-notation (msg internal-seq-flag &optional all)
1919 "Remove sequence notation from the MSG on the current line.
1920 If INTERNAL-SEQ-FLAG is non-nil, then `font-lock' was used to highlight the
1921 sequence. In that case, no notation needs to be removed. Otherwise the effect
1922 of inserting `mh-note-seq' needs to be reversed.
1923 If ALL is non-nil, then all sequence marks on the scan line are removed."
1924 (with-mh-folder-updating (t)
1925 ;; This takes care of internal sequences...
1926 (mh-notate nil nil mh-cmd-note)
1927 (unless internal-seq-flag
1928 ;; ... and this takes care of user sequences.
1929 (let ((stack (gethash msg mh-sequence-notation-history)))
1930 (while (and all (cdr stack))
1931 (setq stack (cdr stack)))
1933 (mh-notate nil (car stack) (1+ mh-cmd-note)))
1934 (setf (gethash msg mh-sequence-notation-history) (cdr stack))))))
1936 (defun mh-remove-cur-notation ()
1937 "Remove old cur notation."
1938 (let ((cur-msg (car (mh-seq-to-msgs 'cur))))
1941 (mh-goto-msg cur-msg t t)
1942 (looking-at mh-scan-cur-msg-number-regexp))
1943 (mh-notate nil ? mh-cmd-note)
1944 (setq overlay-arrow-position nil)))))
1946 (defun mh-remove-all-notation ()
1947 "Remove all notations on all scan lines that MH-E introduces."
1949 (setq overlay-arrow-position nil)
1950 (goto-char (point-min))
1951 (mh-iterate-on-range msg (cons (point-min) (point-max))
1952 (mh-notate nil ? mh-cmd-note)
1953 (mh-remove-sequence-notation msg nil t))
1954 (clrhash mh-sequence-notation-history)))
1957 (defun mh-goto-cur-msg (&optional minimal-changes-flag)
1958 "Position the cursor at the current message.
1959 When optional argument MINIMAL-CHANGES-FLAG is non-nil, the function doesn't
1960 recenter the folder buffer."
1961 (let ((cur-msg (car (mh-seq-to-msgs 'cur))))
1963 (mh-goto-msg cur-msg t t))
1964 (unless minimal-changes-flag
1967 (mh-maybe-show cur-msg)))
1969 (setq overlay-arrow-position nil)
1970 (message "No current message")))))
1972 (defun mh-process-or-undo-commands (folder)
1973 "If FOLDER has outstanding commands, then either process or discard them.
1974 Called by functions like `mh-sort-folder', so also invalidate show buffer."
1976 (if (mh-outstanding-commands-p)
1977 (if (or mh-do-not-confirm-flag
1979 "Process outstanding deletes and refiles? "))
1980 (mh-process-commands folder)
1984 (mh-invalidate-show-buffer))
1986 (defun mh-process-commands (folder)
1987 "Process outstanding commands for FOLDER.
1988 The value of `mh-folder-updated-hook' is a list of functions to be called,
1989 with no arguments, before the commands are processed."
1990 (message "Processing deletes and refiles for %s..." folder)
1992 (with-mh-folder-updating (nil)
1993 ;; Run the hook while the lists are still valid
1994 (run-hooks 'mh-folder-updated-hook)
1996 ;; Update the unseen sequence if it exists
1999 (let ((redraw-needed-flag mh-index-data)
2000 (folders-changed (list mh-current-folder))
2001 (seq-map (and mh-refile-list mh-refile-preserves-sequences-flag
2002 (mh-create-sequence-map mh-seq-list)))
2003 (dest-map (and mh-refile-list mh-refile-preserves-sequences-flag
2004 (make-hash-table))))
2005 ;; Remove invalid scan lines if we are in an index folder and then remove
2006 ;; the real messages
2008 (mh-index-delete-folder-headers)
2009 (setq folders-changed
2010 (append folders-changed (mh-index-execute-commands))))
2012 ;; Then refile messages
2013 (mh-mapc #'(lambda (folder-msg-list)
2014 (let* ((dest-folder (symbol-name (car folder-msg-list)))
2015 (last (car (mh-translate-range dest-folder "last")))
2016 (msgs (cdr folder-msg-list)))
2017 (push dest-folder folders-changed)
2018 (setq redraw-needed-flag t)
2019 (apply #'mh-exec-cmd
2020 "refile" "-src" folder dest-folder
2021 (mh-coalesce-msg-list msgs))
2022 (mh-delete-scan-msgs msgs)
2023 ;; Preserve sequences in destination folder...
2024 (when (and mh-refile-preserves-sequences-flag
2027 (loop for i from (1+ last)
2028 for msg in (sort (copy-sequence msgs) #'<)
2029 do (loop for seq-name in (gethash msg seq-map)
2030 do (push i (gethash seq-name dest-map))))
2032 #'(lambda (seq msgs)
2033 ;; Run it in the background, since we don't care
2034 ;; about the results.
2035 (apply #'mh-exec-cmd-daemon "mark" #'ignore
2036 "-sequence" (symbol-name seq) dest-folder
2037 "-add" (mapcar #'(lambda (x) (format "%s" x))
2038 (mh-coalesce-msg-list msgs))))
2041 (setq mh-refile-list ())
2043 ;; Now delete messages
2044 (cond (mh-delete-list
2045 (setq redraw-needed-flag t)
2046 (apply 'mh-exec-cmd "rmm" folder
2047 (mh-coalesce-msg-list mh-delete-list))
2048 (mh-delete-scan-msgs mh-delete-list)
2049 (setq mh-delete-list nil)))
2051 ;; Don't need to remove sequences since delete and refile do so.
2053 (if (> (buffer-size) 0)
2054 (mh-define-sequence 'cur (list (or (mh-get-msg-num nil) "last"))))
2056 ;; Redraw folder buffer if needed
2057 (when (and redraw-needed-flag)
2058 (when (mh-speed-flists-active-p)
2059 (apply #'mh-speed-flists t folders-changed))
2060 (cond ((memq 'unthread mh-view-ops) (mh-thread-inc folder (point-max)))
2061 (mh-index-data (mh-index-insert-folder-headers)))))
2063 (and (buffer-file-name (get-buffer mh-show-buffer))
2064 (not (file-exists-p (buffer-file-name (get-buffer mh-show-buffer))))
2065 ;; If "inc" were to put a new msg in this file,
2066 ;; we would not notice, so mark it invalid now.
2067 (mh-invalidate-show-buffer))
2069 (setq mh-seq-list (mh-read-folder-sequences mh-current-folder nil))
2070 (mh-remove-all-notation)
2071 (mh-notate-user-sequences)
2072 (message "Processing deletes and refiles for %s...done" folder)))
2074 (defun mh-update-unseen ()
2075 "Synchronize the unseen sequence with MH.
2076 Return non-nil iff the MH folder was set.
2077 The value of `mh-unseen-updated-hook' is a list of functions to be called,
2078 with no arguments, after the unseen sequence is updated."
2080 (let* ((unseen-seq (mh-find-seq mh-unseen-seq))
2081 (unseen-msgs (mh-seq-msgs unseen-seq)))
2084 (mh-undefine-sequence mh-unseen-seq mh-seen-list)
2085 (run-hooks 'mh-unseen-updated-hook)
2087 (setq unseen-msgs (delq (car mh-seen-list) unseen-msgs))
2088 (setq mh-seen-list (cdr mh-seen-list)))
2089 (setcdr unseen-seq unseen-msgs)
2090 t) ;since we set the folder
2091 (setq mh-seen-list nil)))))
2093 (defun mh-delete-scan-msgs (msgs)
2094 "Delete the scan listing lines for MSGS."
2097 (when (mh-goto-msg (car msgs) t t)
2098 (when (memq 'unthread mh-view-ops)
2099 (mh-thread-forget-message (car msgs)))
2101 (setq msgs (cdr msgs)))))
2103 (defun mh-outstanding-commands-p ()
2104 "Return non-nil if there are outstanding deletes or refiles."
2105 (or mh-delete-list mh-refile-list))
2107 (defun mh-coalesce-msg-list (messages)
2108 "Given a list of MESSAGES, return a list of message number ranges.
2109 This is the inverse of `mh-read-msg-list', which expands ranges.
2110 Message lists passed to MH programs should be processed by this function
2111 to avoid exceeding system command line argument limits."
2112 (let ((msgs (sort (copy-sequence messages) 'mh-greaterp))
2118 (if (or (not (numberp prev))
2119 (not (equal (car msgs) (1- prev))))
2120 (progn ;non-sequential, flush old range
2121 (if (eq prev range-high)
2122 (setq ranges (cons range-high ranges))
2123 (setq ranges (cons (format "%s-%s" prev range-high) ranges)))
2124 (setq range-high nil))))
2126 (setq range-high (car msgs))) ;start new or first range
2127 (setq prev (car msgs))
2128 (setq msgs (cdr msgs)))
2131 (defun mh-greaterp (msg1 msg2)
2132 "Return the greater of two message indicators MSG1 and MSG2.
2133 Strings are \"smaller\" than numbers.
2134 Legal values are things like \"cur\", \"last\", 1, and 1820."
2141 (string-lessp msg2 msg1))))
2143 (defun mh-lessp (msg1 msg2)
2144 "Return the lesser of two message indicators MSG1 and MSG2.
2145 Strings are \"smaller\" than numbers.
2146 Legal values are things like \"cur\", \"last\", 1, and 1820."
2147 (not (mh-greaterp msg1 msg2)))
2151 ;;; Basic sequence handling
2153 (defun mh-delete-seq-locally (seq)
2154 "Remove MH-E's record of SEQ."
2155 (let ((entry (mh-find-seq seq)))
2156 (setq mh-seq-list (delq entry mh-seq-list))))
2158 (defun mh-read-folder-sequences (folder save-refiles)
2159 "Read and return the predefined sequences for a FOLDER.
2160 If SAVE-REFILES is non-nil, then keep the sequences
2161 that note messages to be refiled."
2164 (mh-mapc (function (lambda (seq) ; Save the refiling sequences
2165 (if (mh-folder-name-p (mh-seq-name seq))
2166 (setq seqs (cons seq seqs)))))
2169 (if (eq 0 (mh-exec-cmd-quiet nil "mark" folder "-list"))
2171 ;; look for name in line of form "cur: 4" or "myseq (private): 23"
2172 (while (re-search-forward "^[^: ]+" nil t)
2173 (setq seqs (cons (mh-make-seq (intern (buffer-substring
2178 (delete-region (point-min) (point))))) ; avoid race with
2182 (defun mh-read-msg-list ()
2183 "Return a list of message numbers from point to the end of the line.
2184 Expands ranges into set of individual numbers."
2186 (end-of-line (save-excursion (end-of-line) (point)))
2188 (while (re-search-forward "[0-9]+" end-of-line t)
2189 (setq num (string-to-int (buffer-substring (match-beginning 0)
2191 (cond ((looking-at "-") ; Message range
2193 (re-search-forward "[0-9]+" end-of-line t)
2194 (let ((num2 (string-to-int (buffer-substring (match-beginning 0)
2197 (error "Bad message range: %d-%d" num num2))
2198 (while (<= num num2)
2199 (setq msgs (cons num msgs))
2200 (setq num (1+ num)))))
2201 ((not (zerop num)) ;"pick" outputs "0" to mean no match
2202 (setq msgs (cons num msgs)))))
2205 (defun mh-notate-user-sequences (&optional range)
2206 "Mark user-defined sequences in the messages specified by RANGE.
2207 The optional argument RANGE can be a message number, a list of message
2208 numbers, a sequence, a region in a cons cell. If nil all messages are notated."
2210 (setq range (cons (point-min) (point-max))))
2211 (let ((seqs mh-seq-list)
2212 (msg-hash (make-hash-table)))
2214 (dolist (msg (mh-seq-msgs seq))
2215 (push (car seq) (gethash msg msg-hash))))
2216 (mh-iterate-on-range msg range
2217 (loop for seq in (gethash msg msg-hash)
2218 do (mh-add-sequence-notation msg (mh-internal-seq seq))))))
2220 (defvar mh-internal-seqs '(answered cur deleted forwarded printed))
2222 (defun mh-internal-seq (name)
2223 "Return non-nil if NAME is the name of an internal MH-E sequence."
2224 (or (memq name mh-internal-seqs)
2225 (eq name mh-unseen-seq)
2226 (and mh-tick-seq (eq name mh-tick-seq))
2227 (eq name mh-previous-seq)
2228 (mh-folder-name-p name)))
2230 (defun mh-valid-seq-p (name)
2231 "Return non-nil if NAME is a valid MH sequence name."
2233 (string-match "^[a-zA-Z][a-zA-Z0-9]*$" (symbol-name name))))
2235 (defun mh-delete-msg-from-seq (range sequence &optional internal-flag)
2236 "Delete RANGE from SEQUENCE.
2238 Check the documentation of `mh-interactive-range' to see how RANGE is read in
2241 Optional third arg INTERNAL-FLAG non-nil means do not inform MH of the
2243 (interactive (list (mh-interactive-range "Delete")
2244 (mh-read-seq-default "Delete from" t)
2246 (let ((entry (mh-find-seq sequence))
2247 (user-sequence-flag (not (mh-internal-seq sequence)))
2248 (folders-changed (list mh-current-folder))
2251 (mh-iterate-on-range msg range
2253 ;; Calling "mark" repeatedly takes too long. So we will pretend here
2254 ;; that we are just modifying an internal sequence...
2255 (when (memq msg (cdr entry))
2256 (mh-remove-sequence-notation msg (not user-sequence-flag)))
2257 (mh-delete-a-msg-from-seq msg sequence t))
2258 ;; ... and here we will "mark" all the messages at one go.
2259 (unless internal-flag (mh-undefine-sequence sequence msg-list))
2260 (when (and mh-index-data (not internal-flag))
2261 (setq folders-changed
2262 (append folders-changed
2263 (mh-index-delete-from-sequence sequence msg-list))))
2264 (when (and (eq sequence mh-unseen-seq) (mh-speed-flists-active-p))
2265 (apply #'mh-speed-flists t folders-changed)))))
2267 (defun mh-delete-a-msg-from-seq (msg sequence internal-flag)
2268 "Delete MSG from SEQUENCE.
2269 If INTERNAL-FLAG is non-nil, then do not inform MH of the change."
2270 (let ((entry (mh-find-seq sequence)))
2271 (when (and entry (memq msg (mh-seq-msgs entry)))
2272 (if (not internal-flag)
2273 (mh-undefine-sequence sequence (list msg)))
2274 (setcdr entry (delq msg (mh-seq-msgs entry))))))
2276 (defun mh-undefine-sequence (seq msgs)
2277 "Remove from the SEQ the list of MSGS."
2278 (when (and (mh-valid-seq-p seq) msgs)
2279 (apply #'mh-exec-cmd "mark" mh-current-folder "-delete"
2280 "-sequence" (symbol-name seq) (mh-coalesce-msg-list msgs))))
2282 (defun mh-define-sequence (seq msgs)
2283 "Define the SEQ to contain the list of MSGS.
2284 Do not mark pseudo-sequences or empty sequences.
2285 Signals an error if SEQ is an illegal name."
2287 (mh-valid-seq-p seq)
2288 (not (mh-folder-name-p seq)))
2290 (mh-exec-cmd-error nil "mark" mh-current-folder "-add" "-zero"
2291 "-sequence" (symbol-name seq)
2292 (mh-coalesce-msg-list msgs)))))
2294 (defun mh-map-over-seqs (function seq-list)
2295 "Apply FUNCTION to each sequence in SEQ-LIST.
2296 The sequence name and the list of messages are passed as arguments."
2299 (mh-seq-name (car seq-list))
2300 (mh-seq-msgs (car seq-list)))
2301 (setq seq-list (cdr seq-list))))
2303 (defun mh-notate-if-in-one-seq (msg character offset seq)
2305 The CHARACTER is placed at the given OFFSET from the beginning of the listing.
2306 The notation is performed if the MSG is only in SEQ."
2307 (let ((in-seqs (mh-seq-containing-msg msg nil)))
2308 (if (and (eq seq (car in-seqs)) (null (cdr in-seqs)))
2309 (mh-notate msg character offset))))
2311 (defun mh-seq-containing-msg (msg &optional include-internal-flag)
2312 "Return a list of the sequences containing MSG.
2313 If INCLUDE-INTERNAL-FLAG non-nil, include MH-E internal sequences in list."
2314 (let ((l mh-seq-list)
2317 (and (memq msg (mh-seq-msgs (car l)))
2318 (or include-internal-flag
2319 (not (mh-internal-seq (mh-seq-name (car l)))))
2320 (setq seqs (cons (mh-seq-name (car l)) seqs)))
2326 ;;; Build the folder-mode keymap:
2328 (suppress-keymap mh-folder-mode-map)
2330 ;; Use defalias to make sure the documented primary key bindings
2331 ;; appear in menu lists.
2332 (defalias 'mh-alt-show 'mh-show)
2333 (defalias 'mh-alt-refile-msg 'mh-refile-msg)
2334 (defalias 'mh-alt-send 'mh-send)
2335 (defalias 'mh-alt-visit-folder 'mh-visit-folder)
2337 ;; Save the `b' binding for a future `back'. Maybe?
2338 (gnus-define-keys mh-folder-mode-map
2340 "!" mh-refile-or-write-again
2342 "," mh-header-display
2344 ">" mh-write-msg-to-file
2346 "E" mh-extract-rejected-mail
2348 "\177" mh-previous-page
2349 "\C-d" mh-delete-msg-no-motion
2350 "\t" mh-index-next-folder
2351 [backtab] mh-index-previous-folder
2352 "\M-\t" mh-index-previous-folder
2355 "\ed" mh-redistribute
2357 "^" mh-alt-refile-msg
2364 "k" mh-delete-subject-or-thread
2367 "n" mh-next-undeleted-msg
2368 "\M-n" mh-next-unread-msg
2370 "p" mh-previous-undeleted-msg
2371 "\M-p" mh-previous-unread-msg
2375 "t" mh-toggle-showing
2377 "v" mh-index-visit-folder
2378 "x" mh-execute-commands
2381 (gnus-define-keys (mh-folder-map "F" mh-folder-mode-map)
2383 "'" mh-index-ticked-messages
2385 "f" mh-alt-visit-folder
2389 "n" mh-index-new-messages
2390 "o" mh-alt-visit-folder
2392 "q" mh-index-sequenced-messages
2393 "r" mh-rescan-folder
2394 "s" mh-search-folder
2396 "v" mh-visit-folder)
2398 (define-key mh-folder-mode-map "I" mh-inc-spool-map)
2400 (gnus-define-keys (mh-junk-map "J" mh-folder-mode-map)
2402 "b" mh-junk-blacklist
2403 "w" mh-junk-whitelist)
2405 (gnus-define-keys (mh-sequence-map "S" mh-folder-mode-map)
2406 "'" mh-narrow-to-tick
2408 "d" mh-delete-msg-from-seq
2410 "l" mh-list-sequences
2411 "n" mh-narrow-to-seq
2412 "p" mh-put-msg-in-seq
2413 "s" mh-msg-is-in-seq
2416 (gnus-define-keys (mh-thread-map "T" mh-folder-mode-map)
2418 "u" mh-thread-ancestor
2419 "p" mh-thread-previous-sibling
2420 "n" mh-thread-next-sibling
2421 "t" mh-toggle-threads
2422 "d" mh-thread-delete
2423 "o" mh-thread-refile)
2425 (gnus-define-keys (mh-limit-map "/" mh-folder-mode-map)
2426 "'" mh-narrow-to-tick
2429 "f" mh-narrow-to-from
2430 "r" mh-narrow-to-range
2431 "s" mh-narrow-to-subject
2435 (gnus-define-keys (mh-extract-map "X" mh-folder-mode-map)
2437 "s" mh-store-msg ;shar
2438 "u" mh-store-msg) ;uuencode
2440 (gnus-define-keys (mh-digest-map "D" mh-folder-mode-map)
2443 "\177" mh-page-digest-backwards
2444 "b" mh-burst-digest)
2446 (gnus-define-keys (mh-mime-map "K" mh-folder-mode-map)
2448 "a" mh-mime-save-parts
2449 "i" mh-folder-inline-mime-part
2450 "o" mh-folder-save-mime-part
2451 "v" mh-folder-toggle-mime-part
2453 [backtab] mh-prev-button
2454 "\M-\t" mh-prev-button)
2458 (define-key mh-folder-mode-map [button2] 'mh-show-mouse))
2460 (define-key mh-folder-mode-map [mouse-2] 'mh-show-mouse)))
2462 ;; "C-c /" prefix is used in mh-folder-mode by pgp.el and mailcrypt
2468 ;;; If you add a new prefix, add appropriate text to the nil key.
2470 ;;; In general, messages are grouped logically. Taking the main commands for
2471 ;;; example, the first line is "ways to view messages," the second line is
2472 ;;; "things you can do with messages", and the third is "composing" messages.
2474 ;;; When adding a new prefix, ensure that the help message contains "what" the
2475 ;;; prefix is for. For example, if the word "folder" were not present in the
2476 ;;; `F' entry, it would not be clear what these commands operated upon.
2477 (defvar mh-help-messages
2478 '((nil "[i]nc, [.]show, [,]show all, [n]ext, [p]revious,\n"
2479 "[d]elete, [o]refile, e[x]ecute,\n"
2480 "[s]end, [r]eply.\n"
2481 "Prefix characters:\n [F]older, [S]equence, [J]unk, MIME [K]eys,"
2482 "\n [T]hread, [/]limit, e[X]tract, [D]igest, [I]nc spools.")
2484 (?F "[l]ist; [v]isit folder;\n"
2485 "[n]ew messages; [']ticked messages; [s]earch; [i]ndexed search;\n"
2486 "[p]ack; [S]ort; [r]escan; [k]ill")
2487 (?S "[p]ut message in sequence, [n]arrow, [']narrow to ticked, [w]iden,\n"
2488 "[s]equences, [l]ist,\n"
2489 "[d]elete message from sequence, [k]ill sequence")
2490 (?T "[t]oggle, [d]elete, [o]refile thread")
2491 (?/ "Limit to [c]c, [f]rom, [r]ange, [s]ubject, [t]o; [w]iden")
2492 (?X "un[s]har, [u]udecode message")
2493 (?D "[b]urst digest")
2494 (?K "[v]iew, [i]nline, [o]utput/save MIME part; save [a]ll parts; \n"
2495 "[TAB] next; [SHIFT-TAB] previous")
2496 (?J "[b]lacklist, [w]hitelist message"))
2497 "Key binding cheat sheet.
2499 This is an associative array which is used to show the most common commands.
2500 The key is a prefix char. The value is one or more strings which are
2501 concatenated together and displayed in the minibuffer if ? is pressed after
2502 the prefix character. The special key nil is used to display the
2503 non-prefixed commands.
2505 The substitutions described in `substitute-command-keys' are performed as
2510 (dolist (mess '("^Cursor not pointing to message$"
2511 "^There is no other window$"))
2512 (add-to-list 'debug-ignored-errors mess))
2516 ;;; Local Variables:
2517 ;;; indent-tabs-mode: nil
2518 ;;; sentence-end-double-space: nil
2521 ;;; arch-tag: cce884de-bd37-4104-9963-e4439d5ed22b
2522 ;;; mh-e.el ends here