1 ;;; mh-e.el --- GNU Emacs interface to the MH mail system
3 ;; Copyright (C) 1985, 1986, 1987, 1988,
4 ;; 1990, 1992, 1993, 1994, 1995, 1997, 1999,
5 ;; 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
7 ;; Author: Bill Wohler <wohler@newt.com>
8 ;; Maintainer: Bill Wohler <wohler@newt.com>
12 ;; This file is part of GNU Emacs.
14 ;; GNU Emacs is free software; you can redistribute it and/or modify
15 ;; it under the terms of the GNU General Public License as published by
16 ;; the Free Software Foundation; either version 2, or (at your option)
19 ;; GNU Emacs is distributed in the hope that it will be useful,
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;; GNU General Public License for more details.
24 ;; You should have received a copy of the GNU General Public License
25 ;; along with GNU Emacs; see the file COPYING. If not, write to the
26 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
27 ;; Boston, MA 02110-1301, USA.
32 ;; M-x mh-rmail to read mail. Type C-h m there for a list of commands.
33 ;; C-u M-x mh-rmail to visit any folder.
34 ;; M-x mh-smail to send mail. From within the mail reader, "m" works, too.
36 ;; Your .emacs might benefit from these bindings:
37 ;; (global-set-key "\C-cr" 'mh-rmail)
38 ;; (global-set-key "\C-xm" 'mh-smail)
39 ;; (global-set-key "\C-x4m" 'mh-smail-other-window)
41 ;; MH (Message Handler) is a powerful mail reader.
43 ;; The MH newsgroup is comp.mail.mh; the mailing list is mh-users@ics.uci.edu
44 ;; (send to mh-users-request to be added). See the monthly Frequently Asked
45 ;; Questions posting there for information on getting MH and MH-E:
46 ;; http://www.faqs.org/faqs/mail/mh-faq/part1/preamble.html
48 ;; N.B. MH must have been compiled with the MHE compiler flag or several
49 ;; features necessary for MH-E will be missing from MH commands, specifically
50 ;; the -build switch to repl and forw.
52 ;; MH-E is an Emacs interface to the MH mail system.
54 ;; MH-E is supported in GNU Emacs 20 and 21, with MH 6.8.4 and nmh 1.0.4.
57 ;; mh-e-users@lists.sourceforge.net
58 ;; mh-e-announce@lists.sourceforge.net
59 ;; mh-e-devel@lists.sourceforge.net
61 ;; Subscribe by sending a "subscribe" message to
62 ;; <list>-request@lists.sourceforge.net, or by using the web interface at
63 ;; https://sourceforge.net/mail/?group_id=13357
66 ;; https://sourceforge.net/tracker/?group_id=13357&atid=113357
67 ;; Include the output of M-x mh-version in any bug report.
70 ;; https://sourceforge.net/tracker/?atid=363357&group_id=13357&func=browse
73 ;; https://sourceforge.net/tracker/?group_id=13357&atid=213357
77 ;; Original version for Gosling emacs by Brian Reid, Stanford, 1982.
78 ;; Modified by James Larus, BBN, July 1984 and UCB, 1984 & 1985.
79 ;; Rewritten for GNU Emacs, James Larus, 1985.
80 ;; Modified by Stephen Gildea, 1988.
81 ;; Maintenance picked up by Bill Wohler and the
82 ;; SourceForge Crew <http://mh-e.sourceforge.net/>, 2001.
88 (eval-when-compile (require 'mh-acros))
97 ;; Shush the byte-compiler
98 (defvar font-lock-auto-fontify)
99 (defvar font-lock-defaults)
101 (defconst mh-version "7.84" "Version number of MH-E.")
103 (defvar mh-partial-folder-mode-line-annotation "select"
104 "Annotation when displaying part of a folder.
105 The string is displayed after the folder's name. nil for no annotation.")
108 ;;; Scan Line Formats
110 ;;; Parameterize MH-E to work with different scan formats. The defaults work
111 ;;; with the standard MH scan listings, in which the first 4 characters on
112 ;;; the line are the message number, followed by two places for notations.
114 ;; The following scan formats are passed to the scan program if the setting of
115 ;; `mh-scan-format-file' is t. They are identical except the later one makes
116 ;; use of the nmh `decode' function to decode RFC 2047 encodings. If you just
117 ;; want to change the width of the msg number, use the `mh-set-cmd-note'
120 (defvar mh-scan-format-mh
125 "%?(nonnull(comp{to}))%<(mymbox{to})t%>"
126 "%?(nonnull(comp{cc}))%<(mymbox{cc})c%>"
127 "%?(nonnull(comp{bcc}))%<(mymbox{bcc})b%>"
128 "%?(nonnull(comp{newsgroups}))n%>"
130 "%02(mon{date})/%02(mday{date})%<{date} %|*%>"
131 "%<(mymbox{from})%<{to}To:%14(friendly{to})%>%>"
132 "%<(zero)%17(friendly{from})%> "
133 "%{subject}%<{body}<<%{body}%>")
134 "*Scan format string for MH, provided to the scan program via the -format arg.
135 This format is identical to the default except that additional hints for
136 fontification have been added to the fifth column (remember that in Emacs, the
139 The values of the fifth column, in priority order, are: `-' if the message has
140 been replied to, t if an address on the To: line matches one of the
141 mailboxes of the current user, `c' if the Cc: line matches, `b' if the Bcc:
142 line matches, and `n' if a non-empty Newsgroups: header is present.")
144 (defvar mh-scan-format-nmh
149 "%?(nonnull(comp{to}))%<(mymbox{to})t%>"
150 "%?(nonnull(comp{cc}))%<(mymbox{cc})c%>"
151 "%?(nonnull(comp{bcc}))%<(mymbox{bcc})b%>"
152 "%?(nonnull(comp{newsgroups}))n%>"
154 "%02(mon{date})/%02(mday{date})%<{date} %|*%>"
155 "%<(mymbox{from})%<{to}To:%14(decode(friendly{to}))%>%>"
156 "%<(zero)%17(decode(friendly{from}))%> "
157 "%(decode{subject})%<{body}<<%{body}%>")
158 "*Scan format string for nmh.
159 This string is passed to the scan program via the -format arg.
160 This format is identical to the default except that additional hints for
161 fontification have been added to the fifth column (remember that in Emacs, the
164 The values of the fifth column, in priority order, are: `-' if the message has
165 been replied to, t if an address on the To: field matches one of the
166 mailboxes of the current user, `c' if the Cc: field matches, `b' if the Bcc:
167 field matches, and `n' if a non-empty Newsgroups: field is present.")
169 (defvar mh-note-deleted ?D
170 "Deleted messages are marked by this character.
171 See also `mh-scan-deleted-msg-regexp'.")
173 (defvar mh-note-refiled ?^
174 "Refiled messages are marked by this character.
175 See also `mh-scan-refiled-msg-regexp'.")
177 (defvar mh-note-cur ?+
178 "The current message (in MH) is marked by this character.
179 See also `mh-scan-cur-msg-number-regexp'.")
181 (defvar mh-scan-good-msg-regexp "^\\( *[0-9]+\\)[^D^0-9]"
182 "This regexp specifies the scan lines that are 'good' messages.
183 Note that the default setting of `mh-folder-font-lock-keywords' expects this
184 expression to contain at least one parenthesized expression which matches the
185 message number as in the default of \"^\\\\( *[0-9]+\\\\)[^D^0-9]\".")
187 (defvar mh-scan-deleted-msg-regexp "^\\( *[0-9]+\\)D"
188 "This regexp matches deleted messages.
189 Note that the default setting of `mh-folder-font-lock-keywords' expects this
190 expression to contain at least one parenthesized expression which matches the
191 message number as in the default of \"^\\\\( *[0-9]+\\\\)D\".
192 See also `mh-note-deleted'.")
194 (defvar mh-scan-refiled-msg-regexp "^\\( *[0-9]+\\)\\^"
195 "This regexp matches refiled messages.
196 Note that the default setting of `mh-folder-font-lock-keywords' expects this
197 expression to contain at least one parenthesized expression which matches the
198 message number as in the default of \"^\\\\( *[0-9]+\\\\)\\\\^\".
199 See also `mh-note-refiled'.")
201 (defvar mh-scan-valid-regexp "^ *[0-9]"
202 "This regexp matches scan lines for messages (not error messages).")
204 (defvar mh-scan-cur-msg-number-regexp "^\\( *[0-9]+\\+\\).*"
205 "This regexp matches the current message.
206 Note that the default setting of `mh-folder-font-lock-keywords' expects this
207 expression to contain at least one parenthesized expression which matches the
208 message number as in the default of \"^\\\\( *[0-9]+\\\\+\\\\).*\". Don't
209 disable this regexp as it's needed by non-fontifying functions.
210 See also `mh-note-cur'.")
212 (defvar mh-scan-date-regexp "\\([0-9][0-9]/[0-9][0-9]\\)"
213 "This regexp matches a valid date.
214 Note that the default setting of `mh-folder-font-lock-keywords' expects this
215 expression to contain only one parenthesized expression which matches the date
216 field as in the default of \"\\\\([0-9][0-9]/[0-9][0-9]\\\\)\"}.
217 See also `mh-scan-format-regexp'.")
219 (defvar mh-scan-rcpt-regexp "\\(To:\\)\\(..............\\)"
220 "This regexp specifies the recipient in messages you sent.
221 Note that the default setting of `mh-folder-font-lock-keywords'
222 expects this expression to contain two parenthesized expressions. The
223 first is expected to match the `To:' that the default scan format
224 file generates. The second is expected to match the recipient's name
225 as in the default of \"\\\\(To:\\\\)\\\\(..............\\\\)\".")
227 (defvar mh-scan-body-regexp "\\(<<\\([^\n]+\\)?\\)"
228 "This regexp matches the message body fragment displayed in scan lines.
229 Note that the default setting of `mh-folder-font-lock-keywords' expects this
230 expression to contain at least one parenthesized expression which matches the
231 body text as in the default of \"\\\\(<<\\\\([^\\n]+\\\\)?\\\\)\".")
233 (defvar mh-scan-subject-regexp
234 "^ *[0-9]+........[ ]*...................\\([Rr][Ee]\\(\\[[0-9]+\\]\\)?:\\s-*\\)*\\([^<\n]*\\)"
235 "This regexp matches the subject.
236 Note that the default setting of `mh-folder-font-lock-keywords' expects this
237 expression to contain at least three parenthesized expressions. The first is
238 expected to match the `Re:' string, if any. The second matches an optional
239 bracketed number after `Re:', such as in `Re[2]:' (and is thus a
240 sub-expression of the first expression) and the third is expected to match
241 the subject line itself as in the default of \"^ *[0-9]+........[ ]*...................\\\\([Rr][Ee]\\\\(\\\\\\=[[0-9]+\\\\]\\\\)?:\\\\s-*\\\\)*\\\\([^<\\n]*\\\\)\".")
243 (defvar mh-scan-format-regexp
244 (concat "\\([bct]\\)" mh-scan-date-regexp " *\\(..................\\)")
245 "This regexp matches the output of scan.
246 Note that the default setting of `mh-folder-font-lock-keywords' expects this
247 expression to contain at least three parenthesized expressions. The first
248 should match the fontification hint, the second is found in
249 `mh-scan-date-regexp', and the third should match the user name as in the
250 default of \"(concat \"\\\\([bct]\\\\)\" mh-scan-date-regexp
251 \"*\\\\(..................\\\\)\")\".")
255 (defvar mh-folder-font-lock-keywords
257 ;; Folders when displaying index buffer
259 '(0 mh-index-folder-face))
260 ;; Marked for deletion
261 (list (concat mh-scan-deleted-msg-regexp ".*")
262 '(0 mh-folder-deleted-face))
264 (list (concat mh-scan-refiled-msg-regexp ".*")
265 '(0 mh-folder-refiled-face))
267 (list mh-scan-body-regexp '(1 mh-folder-body-face nil t))
268 '(mh-folder-font-lock-subject
269 (1 mh-folder-followup-face append t)
270 (2 mh-folder-subject-face append t))
272 (list mh-scan-cur-msg-number-regexp
273 '(1 mh-folder-cur-msg-number-face))
274 (list mh-scan-good-msg-regexp
275 '(1 mh-folder-msg-number-face)) ;; Msg number
276 (list mh-scan-date-regexp '(1 mh-folder-date-face)) ;; Date
277 (list mh-scan-rcpt-regexp
278 '(1 mh-folder-to-face) ;; To:
279 '(2 mh-folder-address-face)) ;; address
280 ;; scan font-lock name
281 (list mh-scan-format-regexp
282 '(1 mh-folder-date-face)
283 '(3 mh-folder-scan-format-face)))
284 "Regexp keywords used to fontify the MH-Folder buffer.")
286 (defvar mh-scan-cmd-note-width 1
287 "Number of columns consumed by the cmd-note field in `mh-scan-format'.
288 This column will have one of the values: ` ', `D', `^', `+' and where
289 ` ' is the default value,
290 `D' is the `mh-note-deleted' character,
291 `^' is the `mh-note-refiled' character, and
292 `+' is the `mh-note-cur' character.")
294 (defvar mh-scan-destination-width 1
295 "Number of columns consumed by the destination field in `mh-scan-format'.
296 This column will have one of ' ', '%', '-', 't', 'c', 'b', or `n' in it.
297 A ' ' blank space is the default character.
298 A '%' indicates that the message in in a named MH sequence.
299 A '-' indicates that the message has been annotated with a replied field.
300 A 't' indicates that the message contains mymbox in the To: field.
301 A 'c' indicates that the message contains mymbox in the Cc: field.
302 A 'b' indicates that the message contains mymbox in the Bcc: field.
303 A 'n' indicates that the message contains a Newsgroups: field.")
305 (defvar mh-scan-date-width 5
306 "Number of columns consumed by the date field in `mh-scan-format'.
307 This column will typically be of the form mm/dd.")
309 (defvar mh-scan-date-flag-width 1
310 "Number of columns consumed to flag (in)valid dates in `mh-scan-format'.
311 This column will have ` ' for valid and `*' for invalid or missing dates.")
313 (defvar mh-scan-from-mbox-width 17
314 "Number of columns consumed with the \"From:\" line in `mh-scan-format'.
315 This column will have a friendly name or e-mail address of the
316 originator, or a \"To: address\" for outgoing e-mail messages.")
318 (defvar mh-scan-from-mbox-sep-width 2
319 "Number of columns consumed by whitespace after from-mbox in `mh-scan-format'.
320 This column will only ever have spaces in it.")
322 (defvar mh-scan-field-from-start-offset
323 (+ mh-scan-cmd-note-width
324 mh-scan-destination-width
326 mh-scan-date-flag-width)
327 "The offset from the `mh-cmd-note' to find the start of \"From:\" address.")
329 (defvar mh-scan-field-from-end-offset
330 (+ mh-scan-field-from-start-offset mh-scan-from-mbox-width)
331 "The offset from the `mh-cmd-note' to find the end of \"From:\" address.")
333 (defvar mh-scan-field-subject-start-offset
334 (+ mh-scan-cmd-note-width
335 mh-scan-destination-width
337 mh-scan-date-flag-width
338 mh-scan-from-mbox-width
339 mh-scan-from-mbox-sep-width)
340 "The offset from the `mh-cmd-note' to find the start of the subject.")
342 (defun mh-folder-font-lock-subject (limit)
343 "Return MH-E scan subject strings to font-lock between point and LIMIT."
344 (if (not (re-search-forward mh-scan-subject-regexp limit t))
346 (if (match-beginning 1)
347 (set-match-data (list (match-beginning 1) (match-end 3)
348 (match-beginning 1) (match-end 3) nil nil))
349 (set-match-data (list (match-beginning 3) (match-end 3)
350 nil nil (match-beginning 3) (match-end 3))))
355 ;; Fontifify unseen mesages in bold.
357 (defmacro mh-generate-sequence-font-lock (seq prefix face)
358 "Generate the appropriate code to fontify messages in SEQ.
359 PREFIX is used to generate unique names for the variables and functions
360 defined by the macro. So a different prefix should be provided for every
362 FACE is the font-lock face used to display the matching scan lines."
363 (let ((cache (intern (format "mh-folder-%s-seq-cache" prefix)))
364 (func (intern (format "mh-folder-font-lock-%s" prefix))))
367 "Internal cache variable used for font-lock in MH-E.
368 Should only be non-nil through font-lock stepping, and nil once font-lock
369 is done highlighting.")
370 (make-variable-buffer-local ',cache)
373 "Return unseen message lines to font-lock between point and LIMIT."
374 (if (not ,cache) (setq ,cache (mh-seq-msgs (mh-find-seq ,seq))))
375 (let ((cur-msg (mh-get-msg-num nil)))
378 ((>= (point) limit) ;Presumably at end of buffer
381 ((member cur-msg ,cache)
382 (let ((bpoint (progn (beginning-of-line)(point)))
383 (epoint (progn (forward-line 1)(point))))
384 (if (<= limit (point)) (setq ,cache nil))
385 (set-match-data (list bpoint epoint bpoint epoint))
388 ;; move forward one line at a time, checking each message
389 (while (and (= 0 (forward-line 1))
391 (not (member (mh-get-msg-num nil) ,cache))))
392 ;; Examine how we must have exited the loop...
393 (let ((cur-msg (mh-get-msg-num nil)))
394 (cond ((or (<= limit (point))
395 (not (member cur-msg ,cache)))
398 ((member cur-msg ,cache)
399 (let ((bpoint (progn (beginning-of-line) (point)))
400 (epoint (progn (forward-line 1) (point))))
401 (if (<= limit (point)) (setq ,cache nil))
403 (list bpoint epoint bpoint epoint))
406 (setq mh-folder-font-lock-keywords
407 (append mh-folder-font-lock-keywords
408 (list (list ',func (list 1 '',face 'prepend t))))))))
410 (mh-generate-sequence-font-lock mh-unseen-seq unseen bold)
411 (mh-generate-sequence-font-lock mh-tick-seq tick mh-folder-tick-face)
415 ;;; Internal variables:
417 (defvar mh-last-destination nil) ;Destination of last refile or write
419 (defvar mh-last-destination-folder nil) ;Destination of last refile command.
420 (defvar mh-last-destination-write nil) ;Destination of last write command.
422 (defvar mh-folder-mode-map (make-keymap)
423 "Keymap for MH folders.")
425 (defvar mh-arrow-marker nil) ;Marker for arrow display in fringe.
427 (defvar mh-delete-list nil) ;List of msg numbers to delete.
429 (defvar mh-refile-list nil) ;List of folder names in mh-seq-list.
431 (defvar mh-next-direction 'forward) ;Direction to move to next message.
433 (defvar mh-view-ops ()) ;Stack of ops that change the folder
434 ;view (such as narrowing or threading).
435 (defvar mh-folder-view-stack ()) ;Stack of previous folder views.
437 (defvar mh-index-data nil) ;Info about index search results
438 (defvar mh-index-previous-search nil)
439 (defvar mh-index-msg-checksum-map nil)
440 (defvar mh-index-checksum-origin-map nil)
441 (defvar mh-index-sequence-search-flag nil)
443 (defvar mh-first-msg-num nil) ;Number of first msg in buffer.
445 (defvar mh-last-msg-num nil) ;Number of last msg in buffer.
447 (defvar mh-mode-line-annotation nil) ;Message range displayed in buffer.
449 (defvar mh-sequence-notation-history nil)
450 ;Rememeber original notation that
451 ;is overwritten by `mh-note-seq'.
453 (defvar mh-colors-available-flag nil) ;Are colors available?
455 ;;; Macros and generic functions:
457 (defun mh-mapc (function list)
458 "Apply FUNCTION to each element of LIST for side effects only."
460 (funcall function (car list))
461 (setq list (cdr list))))
463 (defun mh-scan-format ()
464 "Return the output format argument for the scan program."
465 (if (equal mh-scan-format-file t)
466 (list "-format" (if (mh-variant-p 'nmh 'mu-mh)
467 (list (mh-update-scan-format
468 mh-scan-format-nmh mh-cmd-note))
469 (list (mh-update-scan-format
470 mh-scan-format-mh mh-cmd-note))))
471 (if (not (equal mh-scan-format-file nil))
472 (list "-form" mh-scan-format-file))))
479 (defun mh-rmail (&optional arg)
480 "Inc(orporate) new mail with MH.
481 Scan an MH folder if ARG is non-nil. This function is an entry point to MH-E,
482 the Emacs interface to the MH mail system."
486 (call-interactively 'mh-visit-folder)
487 (unless (get-buffer mh-inbox)
488 (mh-visit-folder mh-inbox (symbol-name mh-unseen-seq)))
492 (defun mh-nmail (&optional arg)
493 "Check for new mail in inbox folder.
494 Scan an MH folder if ARG is non-nil. This function is an entry point to MH-E,
495 the Emacs interface to the MH mail system."
497 (mh-find-path) ; init mh-inbox
499 (call-interactively 'mh-visit-folder)
500 (mh-visit-folder mh-inbox)))
504 ;;; User executable MH-E commands:
506 (defun mh-delete-msg (range)
507 "Mark the specified RANGE for subsequent deletion and move to the next.
508 Default is the displayed message.
510 Check the documentation of `mh-interactive-range' to see how RANGE is read in
512 (interactive (list (mh-interactive-range "Delete")))
513 (mh-delete-msg-no-motion range)
514 (if (looking-at mh-scan-deleted-msg-regexp) (mh-next-msg)))
516 (defun mh-delete-msg-no-motion (range)
517 "Mark the specified RANGE for subsequent deletion.
519 Check the documentation of `mh-interactive-range' to see how RANGE is read in
521 (interactive (list (mh-interactive-range "Delete")))
522 (mh-iterate-on-range () range
523 (mh-delete-a-msg nil)))
525 (defun mh-execute-commands ()
526 "Process outstanding delete and refile requests."
528 (if mh-folder-view-stack (mh-widen t))
529 (mh-process-commands mh-current-folder)
531 (mh-goto-cur-msg) ; after mh-set-scan-mode for efficiency
532 (mh-make-folder-mode-line)
533 t) ; return t for write-file-functions
535 (defun mh-first-msg ()
536 "Move to the first message."
538 (goto-char (point-min))
539 (while (and (not (eobp)) (not (looking-at mh-scan-valid-regexp)))
542 (defun mh-header-display ()
543 "Show the current message with all its headers.
544 Displays headers that might have been suppressed by setting the
545 variables `mh-clean-message-header-flag' or `mhl-formfile', or by the fallback
546 behavior of scrolling uninteresting headers off the top of the window.
547 Type \"\\[mh-show]\" to show the message normally again."
549 (and (not mh-showing-with-headers)
550 (or mhl-formfile mh-clean-message-header-flag)
551 (mh-invalidate-show-buffer))
552 (let ((mh-decode-mime-flag nil)
554 (mh-clean-message-header-flag nil))
556 (mh-in-show-buffer (mh-show-buffer)
557 (goto-char (point-min))
559 (setq mh-showing-with-headers t)))
561 (defun mh-inc-folder (&optional maildrop-name folder)
562 "Inc(orporate)s new mail into the Inbox folder.
563 Optional argument MAILDROP-NAME specifies an alternate maildrop from the
564 default. The optional argument FOLDER specifies where to incorporate mail
565 instead of the default named by `mh-inbox'.
566 The value of `mh-inc-folder-hook' is a list of functions to be called, with no
567 arguments, after incorporating new mail.
568 Do not call this function from outside MH-E; use \\[mh-rmail] instead."
569 (interactive (list (if current-prefix-arg
571 (read-file-name "inc mail from file: "
573 (if current-prefix-arg
574 (mh-prompt-for-folder "inc mail into" mh-inbox t))))
576 (setq folder mh-inbox))
577 (let ((threading-needed-flag nil))
578 (let ((config (current-window-configuration)))
579 (when (and mh-show-buffer (get-buffer mh-show-buffer))
580 (delete-windows-on mh-show-buffer))
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 (range &optional interactive-flag)
720 "Re-execute the last refile or write command on the given RANGE.
721 Default is the displayed message. Use the same folder or file as the previous
722 refile or write command.
723 If INTERACTIVE-FLAG is non-nil then the function was called interactively."
724 (interactive (list (mh-interactive-range "Redo") t))
725 (if (null mh-last-destination)
726 (error "No previous refile or write"))
729 (cond ((eq (car mh-last-destination) 'refile)
730 (mh-refile-msg range (cdr mh-last-destination))
731 (format "Destination folder: %s" (cdr mh-last-destination)))
733 (mh-iterate-on-range msg range
734 (apply 'mh-write-msg-to-file msg (cdr mh-last-destination)))
735 (mh-next-msg interactive-flag)
736 (format "Destination: %s" (cdr mh-last-destination)))))
740 "Quit the current MH-E folder.
741 Restore the previous window configuration, if one exists.
742 The value of `mh-before-quit-hook' is a list of functions to be called, with
743 no arguments, immediately upon entry to this function.
744 The value of `mh-quit-hook' is a list of functions to be called, with no
745 arguments, upon exit of this function.
746 MH-E working buffers (whose name begins with \" *mh-\" or \"*MH-E \") are
749 (run-hooks 'mh-before-quit-hook)
750 (let ((show-buffer (get-buffer mh-show-buffer)))
752 (kill-buffer show-buffer)))
753 (mh-update-sequences)
754 (mh-destroy-postponed-handles)
755 (bury-buffer (current-buffer))
757 ;; Delete all MH-E temporary and working buffers.
758 (dolist (buffer (buffer-list))
759 (when (or (string-match "^ \\*mh-" (buffer-name buffer))
760 (string-match "^\\*MH-E " (buffer-name buffer)))
761 (kill-buffer buffer)))
763 (if mh-previous-window-config
764 (set-window-configuration mh-previous-window-config))
765 (run-hooks 'mh-quit-hook))
767 (defun mh-page-msg (&optional arg)
768 "Page the displayed message forwards.
769 Scrolls ARG lines or a full screen if no argument is supplied. Show buffer
770 first if not displayed. Show the next undeleted message if looking at the
771 bottom of the current message."
774 (if mh-page-to-next-msg-flag
775 (if (equal mh-next-direction 'backward)
776 (mh-previous-undeleted-msg)
777 (mh-next-undeleted-msg))
778 (if (mh-in-show-buffer (mh-show-buffer)
779 (pos-visible-in-window-p (point-max)))
782 "End of message (Type %s to read %s undeleted message)"
783 (single-key-description last-input-event)
784 (if (equal mh-next-direction 'backward)
787 (setq mh-page-to-next-msg-flag t))
788 (scroll-other-window arg)))
791 (defun mh-previous-page (&optional arg)
792 "Page the displayed message backwards.
793 Scrolls ARG lines or a full screen if no argument is supplied."
795 (mh-in-show-buffer (mh-show-buffer)
798 (defun mh-previous-undeleted-msg (&optional arg wait-after-complaining-flag)
799 "Move to the previous undeleted message ARG in window.
800 If optional argument WAIT-AFTER-COMPLAINING-FLAG is non-nil and we are at the
801 first undeleted message then pause for a second after printing message."
803 (setq mh-next-direction 'backward)
805 (cond ((re-search-backward mh-scan-good-msg-regexp nil t arg)
807 (t (message "No previous undeleted message")
808 (if wait-after-complaining-flag (sit-for 1)))))
810 (defun mh-previous-unread-msg (&optional count)
811 "Move to previous unread message.
812 With optional argument COUNT, COUNT-1 unread messages before current message
816 (error "The function mh-previous-unread-msg expects positive argument"))
817 (setq count (1- count))
818 (let ((unread-sequence (cdr (assoc mh-unseen-seq mh-seq-list)))
819 (cur-msg (mh-get-msg-num nil)))
820 (cond ((and (not cur-msg) (not (bobp))
821 ;; If we are at the end of the buffer back up one line and go
822 ;; to unread message after that.
825 (setq cur-msg (mh-get-msg-num nil)))
827 ((or (null unread-sequence) (not cur-msg))
828 ;; No unread message or there aren't any messages in buffer...
829 (message "No more unread messages"))
831 ;; Skip count messages...
832 (while (and unread-sequence (>= (car unread-sequence) cur-msg))
833 (setq unread-sequence (cdr unread-sequence)))
835 (setq unread-sequence (cdr unread-sequence))
836 (setq count (1- count)))
837 (not (car unread-sequence)))
838 (message "No more unread messages"))
839 (t (loop for msg in unread-sequence
840 when (mh-goto-msg msg t) return nil
841 finally (message "No more unread messages"))))))
843 (defun mh-goto-next-button (backward-flag &optional criterion)
844 "Search for next button satisfying criterion.
845 If BACKWARD-FLAG is non-nil search backward in the buffer for a mime button. If
846 CRITERION is a function or a symbol which has a function binding then that
847 function must return non-nil at the button we stop."
848 (unless (or (and (symbolp criterion) (fboundp criterion))
849 (functionp criterion))
850 (setq criterion (lambda (x) t)))
851 ;; Move to the next button in the buffer satisfying criterion
852 (goto-char (or (save-excursion
854 ;; Find point before current button
855 (let ((point-before-current-button
857 (while (get-text-property (point) 'mh-data)
858 (unless (= (forward-line
859 (if backward-flag 1 -1))
862 (goto-char (point-min))
863 (goto-char (point-max)))))
865 ;; Skip over current button
866 (while (and (get-text-property (point) 'mh-data)
867 (not (if backward-flag (bobp) (eobp))))
868 (forward-line (if backward-flag -1 1)))
869 ;; Stop at next MIME button if any exists.
872 (unless (= (forward-line
873 (if backward-flag -1 1))
876 (goto-char (point-max))
877 (goto-char (point-min)))
880 point-before-current-button)
881 (when (and (get-text-property (point) 'mh-data)
882 (funcall criterion (point)))
883 (return-from loop (point))))
887 (defun mh-next-button (&optional backward-flag)
888 "Go to the next MIME button.
889 Advance point to the next MIME button in the show buffer. If the end
890 of buffer is reached then the search wraps over to the start of the
891 buffer. With prefix argument, BACKWARD-FLAG the point will move to the
892 previous MIME button."
893 (interactive (list current-prefix-arg))
894 (unless mh-showing-mode
896 (mh-in-show-buffer (mh-show-buffer)
897 (mh-goto-next-button backward-flag)))
899 (defun mh-prev-button ()
900 "Go to the prev MIME button.
901 Move point to the previous MIME button in the show buffer. If the beginning
902 of the buffer is reached then the search wraps over to the end of the
907 (defun mh-folder-mime-action (part-index action include-security-flag)
908 "Go to PART-INDEX and carry out ACTION.
909 If PART-INDEX is nil then go to the next part in the buffer. The search for
910 the next buffer wraps around if end of buffer is reached. If argument
911 INCLUDE-SECURITY-FLAG is non-nil then include security info buttons when
912 searching for a suitable parts."
913 (unless mh-showing-mode
915 (mh-in-show-buffer (mh-show-buffer)
919 (let ((part (get-text-property p 'mh-part)))
920 (and (integerp part) (= part part-index)))))
922 (if include-security-flag
923 (get-text-property p 'mh-data)
924 (integerp (get-text-property p 'mh-part)))))))
926 (cond ((and (get-text-property point 'mh-part)
927 (or (null part-index)
928 (= (get-text-property point 'mh-part) part-index)))
930 ((and (get-text-property point 'mh-data)
931 include-security-flag
935 (mh-goto-next-button nil criterion)
936 (if (= (point) point)
937 (message "No matching MIME part found")
938 (funcall action)))))))
940 (defun mh-folder-toggle-mime-part (part-index)
941 "Toggle display of button.
942 If point in show buffer is at a button then that part is toggled.
943 If not at a button and PART-INDEX is non-nil point is moved to that part.
944 With nil PART-INDEX find the first button after point (search wraps around if
945 end of buffer is reached) and toggle it."
947 (when (consp part-index) (setq part-index (car part-index)))
948 (mh-folder-mime-action part-index #'mh-press-button t))
950 (defun mh-folder-inline-mime-part (part-index)
951 "Show the raw bytes of MIME part inline.
952 If point in show buffer is at a mime part then that part is inlined.
953 If not at a mime-part and PART-INDEX is non-nil point is moved to that part.
954 With nil PART-INDEX find the first button after point (search wraps around if
955 end of buffer is reached) and inline it."
957 (when (consp part-index) (setq part-index (car part-index)))
958 (mh-folder-mime-action part-index #'mh-mime-inline-part nil))
960 (defun mh-folder-save-mime-part (part-index)
962 If point in show buffer is at a mime part then that part is saved.
963 If not at a mime-part and PART-INDEX is non-nil point is moved to that part.
964 With nil PART-INDEX find the first button after point (search wraps around if
965 end of buffer is reached) and save it."
967 (when (consp part-index) (setq part-index (car part-index)))
968 (mh-folder-mime-action part-index #'mh-mime-save-part nil))
970 (defvar mh-thread-scan-line-map-stack)
972 (defun mh-reset-threads-and-narrowing ()
973 "Reset all variables pertaining to threads and narrowing.
974 Also removes all content from the folder buffer."
975 (setq mh-view-ops ())
976 (setq mh-folder-view-stack ())
977 (setq mh-thread-scan-line-map-stack ())
978 (let ((buffer-read-only nil)) (erase-buffer)))
980 (defun mh-rescan-folder (&optional range dont-exec-pending)
981 "Rescan a folder after optionally processing the outstanding commands.
982 If optional prefix argument RANGE is provided, prompt for the range of
983 messages to display. Otherwise show the entire folder.
984 If optional argument DONT-EXEC-PENDING is non-nil then pending deletes and
985 refiles aren't carried out."
986 (interactive (list (if current-prefix-arg
987 (mh-read-range "Rescan" mh-current-folder t nil t
988 mh-interpret-number-as-range-flag)
990 (setq mh-next-direction 'forward)
991 (let ((threaded-flag (memq 'unthread mh-view-ops)))
992 (mh-scan-folder mh-current-folder (or range "all") dont-exec-pending)
993 (cond (threaded-flag (mh-toggle-threads))
994 (mh-index-data (mh-index-insert-folder-headers)))))
996 (defun mh-write-msg-to-file (msg file no-headers)
997 "Append MSG to the end of a FILE.
998 If prefix argument NO-HEADERS is provided, write only the message body.
999 Otherwise send the entire message including the headers."
1001 (list (mh-get-msg-num t)
1002 (let ((default-dir (if (eq 'write (car mh-last-destination-write))
1003 (file-name-directory
1004 (car (cdr mh-last-destination-write)))
1005 default-directory)))
1006 (read-file-name (format "Save message%s in file: "
1007 (if current-prefix-arg " body" ""))
1009 (if (eq 'write (car mh-last-destination-write))
1010 (car (cdr mh-last-destination-write))
1011 (expand-file-name "mail.out" default-dir))))
1012 current-prefix-arg))
1013 (let ((msg-file-to-output (mh-msg-filename msg))
1014 (output-file (mh-expand-file-name file)))
1015 (setq mh-last-destination (list 'write file (if no-headers 'no-headers))
1016 mh-last-destination-write mh-last-destination)
1018 (set-buffer (get-buffer-create mh-temp-buffer))
1020 (insert-file-contents msg-file-to-output)
1021 (goto-char (point-min))
1022 (if no-headers (search-forward "\n\n"))
1023 (append-to-file (point) (point-max) output-file))))
1025 (defun mh-toggle-showing ()
1026 "Toggle the scanning mode/showing mode of displaying messages."
1032 (defun mh-undo (range)
1033 "Undo the pending deletion or refile of the specified RANGE.
1035 Check the documentation of `mh-interactive-range' to see how RANGE is read in
1037 (interactive (list (mh-interactive-range "Undo")))
1038 (cond ((numberp range)
1039 (let ((original-position (point)))
1041 (while (not (or (looking-at mh-scan-deleted-msg-regexp)
1042 (looking-at mh-scan-refiled-msg-regexp)
1043 (and (eq mh-next-direction 'forward) (bobp))
1044 (and (eq mh-next-direction 'backward)
1045 (save-excursion (forward-line) (eobp)))))
1046 (forward-line (if (eq mh-next-direction 'forward) -1 1)))
1047 (if (or (looking-at mh-scan-deleted-msg-regexp)
1048 (looking-at mh-scan-refiled-msg-regexp))
1050 (mh-undo-msg (mh-get-msg-num t))
1052 (goto-char original-position)
1053 (error "Nothing to undo"))))
1054 (t (mh-iterate-on-range () range
1055 (mh-undo-msg nil))))
1056 (if (not (mh-outstanding-commands-p))
1057 (mh-set-folder-modified-p nil)))
1060 (defun mh-folder-line-matches-show-buffer-p ()
1061 "Return t if the message under point in folder-mode is in the show buffer.
1062 Return nil in any other circumstance (no message under point, no show buffer,
1063 the message in the show buffer doesn't match."
1064 (and (eq major-mode 'mh-folder-mode)
1065 (mh-get-msg-num nil)
1067 (get-buffer mh-show-buffer)
1068 (buffer-file-name (get-buffer mh-show-buffer))
1069 (string-match ".*/\\([0-9]+\\)$"
1070 (buffer-file-name (get-buffer mh-show-buffer)))
1072 (match-string 1 (buffer-file-name (get-buffer mh-show-buffer)))
1073 (int-to-string (mh-get-msg-num nil)))))
1075 (eval-when-compile (require 'gnus))
1077 (defmacro mh-macro-expansion-time-gnus-version ()
1078 "Return Gnus version available at macro expansion time.
1079 The macro evaluates the Gnus version at macro expansion time. If MH-E was
1080 compiled then macro expansion happens at compile time."
1083 (defun mh-run-time-gnus-version ()
1084 "Return Gnus version available at run time."
1089 (defun mh-version ()
1090 "Display version information about MH-E and the MH mail handling system."
1092 (set-buffer (get-buffer-create mh-info-buffer))
1095 (insert "MH-E " mh-version "\n\n")
1096 ;; MH-E compilation details.
1097 (insert "MH-E compilation details:\n")
1098 (let* ((compiled-mhe (byte-code-function-p (symbol-function 'mh-version)))
1099 (gnus-compiled-version (if compiled-mhe
1100 (mh-macro-expansion-time-gnus-version)
1102 (insert " Byte compiled:\t\t" (if compiled-mhe "yes" "no") "\n"
1103 " Gnus (compile-time):\t" gnus-compiled-version "\n"
1104 " Gnus (run-time):\t" (mh-run-time-gnus-version) "\n\n"))
1106 (insert (emacs-version) "\n\n")
1108 (if mh-variant-in-use
1109 (insert mh-variant-in-use "\n"
1110 " mh-progs:\t" mh-progs "\n"
1111 " mh-lib:\t" mh-lib "\n"
1112 " mh-lib-progs:\t" mh-lib-progs "\n\n")
1113 (insert "No MH variant detected\n"))
1116 (call-process "uname" nil t nil "-a")
1118 (goto-char (point-min))
1119 (display-buffer mh-info-buffer))
1121 (defun mh-parse-flist-output-line (line &optional current-folder)
1122 "Parse LINE to generate folder name, unseen messages and total messages.
1123 If CURRENT-FOLDER is non-nil then it contains the current folder name and it is
1124 used to avoid problems in corner cases involving folders whose names end with a
1128 (goto-char (point-max))
1129 (let (folder unseen total p)
1130 (when (search-backward " out of " (point-min) t)
1131 (setq total (read-from-string
1132 (buffer-substring-no-properties
1133 (match-end 0) (line-end-position))))
1134 (when (search-backward " in sequence " (point-min) t)
1136 (when (search-backward " has " (point-min) t)
1137 (setq unseen (read-from-string (buffer-substring-no-properties
1139 (while (eq (char-after) ? )
1141 (setq folder (buffer-substring-no-properties
1142 (point-min) (1+ (point))))
1143 (when (and (equal (aref folder (1- (length folder))) ?+)
1144 (equal current-folder folder))
1145 (setq folder (substring folder 0 (1- (length folder)))))
1146 (values (format "+%s" folder) (car unseen) (car total))))))))
1148 (defun mh-folder-size-folder (folder)
1149 "Find size of FOLDER using `folder'."
1151 (let ((u (length (cdr (assoc mh-unseen-seq
1152 (mh-read-folder-sequences folder nil))))))
1153 (call-process (expand-file-name "folder" mh-progs) nil t nil
1154 "-norecurse" folder)
1155 (goto-char (point-min))
1156 (if (re-search-forward " has \\([0-9]+\\) " nil t)
1157 (values (car (read-from-string (match-string 1))) u folder)
1158 (values 0 u folder)))))
1160 (defun mh-folder-size-flist (folder)
1161 "Find size of FOLDER using `flist'."
1163 (call-process (expand-file-name "flist" mh-progs) nil t nil "-showzero"
1164 "-norecurse" folder "-sequence" (symbol-name mh-unseen-seq))
1165 (goto-char (point-min))
1166 (multiple-value-bind (folder unseen total)
1167 (mh-parse-flist-output-line
1168 (buffer-substring (point) (line-end-position)))
1169 (values total unseen folder))))
1171 (defun mh-folder-size (folder)
1172 "Find size of FOLDER."
1173 (if mh-flists-present-flag
1174 (mh-folder-size-flist folder)
1175 (mh-folder-size-folder folder)))
1177 (defun mh-visit-folder (folder &optional range index-data)
1178 "Visit FOLDER and display RANGE of messages.
1179 Do not call this function from outside MH-E; see \\[mh-rmail] instead.
1181 If RANGE is nil (the default if it is omitted when called non-interactively),
1182 then all messages in FOLDER are displayed.
1184 If an index buffer is being created then INDEX-DATA is used to initialize the
1185 index buffer specific data structures.
1187 A prefix argument will cause a prompt for the RANGE of messages
1188 regardless of the size of the `mh-large-folder' variable."
1189 (interactive (let ((folder-name (mh-prompt-for-folder "Visit" mh-inbox t)))
1191 (mh-read-range "Scan" folder-name t nil
1193 mh-interpret-number-as-range-flag))))
1194 (let ((config (current-window-configuration))
1195 (current-buffer (current-buffer))
1196 (threaded-view-flag mh-show-threads-flag))
1197 (delete-other-windows)
1199 (when (get-buffer folder)
1201 (setq threaded-view-flag (memq 'unthread mh-view-ops))))
1203 (mh-make-folder folder)
1204 (setq mh-index-data (car index-data)
1205 mh-index-msg-checksum-map (make-hash-table :test #'equal)
1206 mh-index-checksum-origin-map (make-hash-table :test #'equal))
1207 (mh-index-update-maps folder (cadr index-data))
1208 (mh-index-create-sequences))
1209 (mh-scan-folder folder (or range "all"))
1210 (cond ((and threaded-view-flag
1212 (goto-char (point-min))
1213 (or (null mh-large-folder)
1214 (not (equal (forward-line (1+ mh-large-folder)) 0))
1215 (and (message "Not threading since the number of messages exceeds `mh-large-folder'")
1217 (mh-toggle-threads))
1219 (mh-index-insert-folder-headers)))
1220 (unless (eq current-buffer (current-buffer))
1221 (setq mh-previous-window-config config)))
1225 (defun mh-update-sequences ()
1226 "Update MH's Unseen-Sequence and current folder and message.
1227 Flush MH-E's state out to MH. The message at the cursor becomes current."
1229 ;; mh-update-sequences is the opposite of mh-read-folder-sequences,
1230 ;; which updates MH-E's state from MH.
1231 (let ((folder-set (mh-update-unseen))
1232 (new-cur (mh-get-msg-num nil)))
1234 (let ((seq-entry (mh-find-seq 'cur)))
1235 (mh-remove-cur-notation)
1237 (list new-cur)) ;delete-seq-locally, add-msgs-to-seq
1238 (mh-define-sequence 'cur (list new-cur))
1240 (if (looking-at mh-scan-good-msg-regexp)
1244 ;; psg - mh-current-folder is nil if mh-summary-height < 4 !
1245 ;; So I added this sanity check.
1246 (if (stringp mh-current-folder)
1247 (mh-exec-cmd-quiet t "folder" mh-current-folder "-fast")
1248 (mh-exec-cmd-quiet t "folder" "-fast")))))))
1252 ;;; Support routines.
1254 (defun mh-delete-a-msg (msg)
1256 If MSG is nil then the message at point is deleted.
1258 The value of `mh-delete-msg-hook' is a list of functions to be called, with no
1259 arguments, after the message has been deleted."
1262 (mh-goto-msg msg nil t)
1264 (setq msg (mh-get-msg-num t)))
1265 (if (looking-at mh-scan-refiled-msg-regexp)
1266 (error "Message %d is refiled. Undo refile before deleting" msg))
1267 (if (looking-at mh-scan-deleted-msg-regexp)
1269 (mh-set-folder-modified-p t)
1270 (setq mh-delete-list (cons msg mh-delete-list))
1271 (mh-notate nil mh-note-deleted mh-cmd-note)
1272 (run-hooks 'mh-delete-msg-hook))))
1274 (defun mh-refile-a-msg (msg folder)
1275 "Refile MSG in FOLDER.
1276 If MSG is nil then the message at point is refiled.
1278 Folder is a symbol, not a string.
1279 The value of `mh-refile-msg-hook' is a list of functions to be called, with no
1280 arguments, after the message has been refiled."
1283 (mh-goto-msg msg nil t)
1285 (setq msg (mh-get-msg-num t)))
1286 (cond ((looking-at mh-scan-deleted-msg-regexp)
1287 (error "Message %d is deleted. Undo delete before moving" msg))
1288 ((looking-at mh-scan-refiled-msg-regexp)
1290 (format "Message %d already refiled. Copy to %s as well? "
1292 (mh-exec-cmd "refile" (mh-get-msg-num t) "-link"
1293 "-src" mh-current-folder
1294 (symbol-name folder))
1295 (message "Message not copied")))
1297 (mh-set-folder-modified-p t)
1298 (cond ((null (assoc folder mh-refile-list))
1299 (push (list folder msg) mh-refile-list))
1300 ((not (member msg (cdr (assoc folder mh-refile-list))))
1301 (push msg (cdr (assoc folder mh-refile-list)))))
1302 (mh-notate nil mh-note-refiled mh-cmd-note)
1303 (run-hooks 'mh-refile-msg-hook)))))
1305 (defun mh-next-msg (&optional wait-after-complaining-flag)
1306 "Move backward or forward to the next undeleted message in the buffer.
1307 If optional argument WAIT-AFTER-COMPLAINING-FLAG is non-nil and we are at the
1308 last message, then wait for a second after telling the user that there aren't
1309 any more unread messages."
1310 (if (eq mh-next-direction 'forward)
1311 (mh-next-undeleted-msg 1 wait-after-complaining-flag)
1312 (mh-previous-undeleted-msg 1 wait-after-complaining-flag)))
1314 (defun mh-next-unread-msg (&optional count)
1315 "Move to next unread message.
1316 With optional argument COUNT, COUNT-1 unread messages are skipped."
1319 (error "The function mh-next-unread-msg expects positive argument"))
1320 (setq count (1- count))
1321 (let ((unread-sequence (reverse (cdr (assoc mh-unseen-seq mh-seq-list))))
1322 (cur-msg (mh-get-msg-num nil)))
1323 (cond ((and (not cur-msg) (not (bobp))
1324 ;; If we are at the end of the buffer back up one line and go
1325 ;; to unread message after that.
1328 (setq cur-msg (mh-get-msg-num nil)))
1330 ((or (null unread-sequence) (not cur-msg))
1331 ;; No unread message or there aren't any messages in buffer...
1332 (message "No more unread messages"))
1335 (while (and unread-sequence (>= cur-msg (car unread-sequence)))
1336 (setq unread-sequence (cdr unread-sequence)))
1338 (setq unread-sequence (cdr unread-sequence))
1339 (setq count (1- count)))
1340 (not (car unread-sequence)))
1341 (message "No more unread messages"))
1342 (t (loop for msg in unread-sequence
1343 when (mh-goto-msg msg t) return nil
1344 finally (message "No more unread messages"))))))
1346 (defun mh-set-scan-mode ()
1347 "Display the scan listing buffer, but do not show a message."
1348 (if (get-buffer mh-show-buffer)
1349 (delete-windows-on mh-show-buffer))
1351 (force-mode-line-update)
1352 (if mh-recenter-summary-flag
1355 (defun mh-undo-msg (msg)
1356 "Undo the deletion or refile of one MSG.
1357 If MSG is nil then act on the message at point"
1360 (mh-goto-msg msg t t)
1362 (setq msg (mh-get-msg-num t)))
1363 (cond ((memq msg mh-delete-list)
1364 (setq mh-delete-list (delq msg mh-delete-list)))
1366 (dolist (folder-msg-list mh-refile-list)
1367 (setf (cdr folder-msg-list) (remove msg (cdr folder-msg-list))))
1368 (setq mh-refile-list (loop for x in mh-refile-list
1369 unless (null (cdr x)) collect x))))
1370 (mh-notate nil ? mh-cmd-note)))
1374 ;;; The folder data abstraction.
1376 (defvar mh-index-data-file ".mhe_index"
1377 "MH-E specific file where index seach info is stored.")
1379 (defun mh-make-folder (name)
1380 "Create a new mail folder called NAME.
1381 Make it the current folder."
1382 (switch-to-buffer name)
1383 (setq buffer-read-only nil)
1385 (if mh-adaptive-cmd-note-flag
1386 (mh-set-cmd-note (mh-message-number-width name)))
1387 (setq buffer-read-only t)
1389 (mh-set-folder-modified-p nil)
1390 (setq buffer-file-name mh-folder-filename)
1391 (when (and (not mh-index-data)
1392 (file-exists-p (concat buffer-file-name mh-index-data-file)))
1393 (mh-index-read-data))
1394 (mh-make-folder-mode-line))
1396 ;;; Ensure new buffers won't get this mode if default-major-mode is nil.
1397 (put 'mh-folder-mode 'mode-class 'special)
1401 ;;; Menu extracted from mh-menubar.el V1.1 (31 July 2001)
1402 ;;; Menus for folder mode: folder, message, sequence (in that order)
1403 ;;; folder-mode "Sequence" menu
1405 mh-folder-sequence-menu mh-folder-mode-map "Menu for MH-E folder-sequence."
1407 ["Add Message to Sequence..." mh-put-msg-in-seq (mh-get-msg-num nil)]
1408 ["List Sequences for Message" mh-msg-is-in-seq (mh-get-msg-num nil)]
1409 ["Delete Message from Sequence..." mh-delete-msg-from-seq
1410 (mh-get-msg-num nil)]
1411 ["List Sequences in Folder..." mh-list-sequences t]
1412 ["Delete Sequence..." mh-delete-seq t]
1413 ["Narrow to Sequence..." mh-narrow-to-seq t]
1414 ["Widen from Sequence" mh-widen mh-folder-view-stack]
1416 ["Narrow to Subject Sequence" mh-narrow-to-subject t]
1417 ["Narrow to Tick Sequence" mh-narrow-to-tick
1418 (and mh-tick-seq (mh-seq-msgs (mh-find-seq mh-tick-seq)))]
1419 ["Delete Rest of Same Subject" mh-delete-subject t]
1420 ["Toggle Tick Mark" mh-toggle-tick t]
1422 ["Push State Out to MH" mh-update-sequences t]))
1424 ;;; folder-mode "Message" menu
1426 mh-folder-message-menu mh-folder-mode-map "Menu for MH-E folder-message."
1428 ["Show Message" mh-show (mh-get-msg-num nil)]
1429 ["Show Message with Header" mh-header-display (mh-get-msg-num nil)]
1430 ["Next Message" mh-next-undeleted-msg t]
1431 ["Previous Message" mh-previous-undeleted-msg t]
1432 ["Go to First Message" mh-first-msg t]
1433 ["Go to Last Message" mh-last-msg t]
1434 ["Go to Message by Number..." mh-goto-msg t]
1435 ["Modify Message" mh-modify t]
1436 ["Delete Message" mh-delete-msg (mh-get-msg-num nil)]
1437 ["Refile Message" mh-refile-msg (mh-get-msg-num nil)]
1438 ["Undo Delete/Refile" mh-undo (mh-outstanding-commands-p)]
1439 ["Execute Delete/Refile" mh-execute-commands
1440 (mh-outstanding-commands-p)]
1442 ["Compose a New Message" mh-send t]
1443 ["Reply to Message..." mh-reply (mh-get-msg-num nil)]
1444 ["Forward Message..." mh-forward (mh-get-msg-num nil)]
1445 ["Redistribute Message..." mh-redistribute (mh-get-msg-num nil)]
1446 ["Edit Message Again" mh-edit-again (mh-get-msg-num nil)]
1447 ["Re-edit a Bounced Message" mh-extract-rejected-mail t]
1449 ["Copy Message to Folder..." mh-copy-msg (mh-get-msg-num nil)]
1450 ["Print Message" mh-print-msg (mh-get-msg-num nil)]
1451 ["Write Message to File..." mh-write-msg-to-file
1452 (mh-get-msg-num nil)]
1453 ["Pipe Message to Command..." mh-pipe-msg (mh-get-msg-num nil)]
1454 ["Unpack Uuencoded Message..." mh-store-msg (mh-get-msg-num nil)]
1455 ["Burst Digest Message" mh-burst-digest (mh-get-msg-num nil)]))
1457 ;;; folder-mode "Folder" menu
1459 mh-folder-folder-menu mh-folder-mode-map "Menu for MH-E folder."
1461 ["Incorporate New Mail" mh-inc-folder t]
1462 ["Toggle Show/Folder" mh-toggle-showing t]
1463 ["Execute Delete/Refile" mh-execute-commands
1464 (mh-outstanding-commands-p)]
1465 ["Rescan Folder" mh-rescan-folder t]
1466 ["Thread Folder" mh-toggle-threads
1467 (not (memq 'unthread mh-view-ops))]
1468 ["Pack Folder" mh-pack-folder t]
1469 ["Sort Folder" mh-sort-folder t]
1471 ["List Folders" mh-list-folders t]
1472 ["Visit a Folder..." mh-visit-folder t]
1473 ["View New Messages" mh-index-new-messages t]
1474 ["Search a Folder..." mh-search-folder t]
1475 ["Indexed Search..." mh-index-search t]
1477 ["Quit MH-E" mh-quit t]))
1481 (defmacro mh-remove-xemacs-horizontal-scrollbar ()
1482 "Get rid of the horizontal scrollbar that XEmacs insists on putting in."
1483 (when mh-xemacs-flag
1484 `(if (and (featurep 'scrollbar)
1485 (fboundp 'set-specifier))
1486 (set-specifier horizontal-scrollbar-visible-p nil
1487 (cons (current-buffer) nil)))))
1489 (defmacro mh-write-file-functions-compat ()
1490 "Return `write-file-functions' if it exists.
1491 Otherwise return `local-write-file-hooks'. This macro exists purely for
1492 compatibility. The former symbol is used in Emacs 21.4 onward while the latter
1493 is used in previous versions and XEmacs."
1494 (if (boundp 'write-file-functions)
1495 ''write-file-functions ;Emacs 21.4
1496 ''local-write-file-hooks)) ;<Emacs 21.4, XEmacs
1498 ;; Avoid compiler warnings in non-bleeding edge versions of Emacs.
1500 (defvar tool-bar-mode)
1501 (defvar tool-bar-map)
1502 (defvar desktop-save-buffer)) ;Emacs 21.4
1504 ;; Register mh-folder-mode as supporting which-function-mode...
1505 (load "which-func" t t)
1506 (when (and (boundp 'which-func-modes)
1507 (not (member 'mh-folder-mode which-func-modes)))
1508 (push 'mh-folder-mode which-func-modes))
1510 ;; Autoload cookie needed by desktop.el
1512 (define-derived-mode mh-folder-mode fundamental-mode "MH-Folder"
1513 "Major MH-E mode for \"editing\" an MH folder scan listing.\\<mh-folder-mode-map>
1515 You can show the message the cursor is pointing to, and step through the
1516 messages. Messages can be marked for deletion or refiling into another
1517 folder; these commands are executed all at once with a separate command.
1519 Options that control this mode can be changed with \\[customize-group];
1520 specify the \"mh\" group. In particular, please see the `mh-scan-format-file'
1521 option if you wish to modify scan's format.
1523 When a folder is visited, the hook `mh-folder-mode-hook' is run.
1527 Many commands that operate on individual messages, such as `mh-forward' or
1528 `mh-refile-msg' take a RANGE argument. This argument can be used in several
1531 If you provide the prefix argument (\\[universal-argument]) to these commands,
1532 then you will be prompted for the message range. This can be any valid MH
1533 range which can include messages, sequences, and the abbreviations (described
1534 in the mh(1) man page):
1537 Indicates all messages in the range <num1> to <num2>, inclusive. The range
1543 Up to N messages beginning with (or ending with) message num. Num may be
1544 any of the pre-defined symbols: first, prev, cur, next or last.
1550 The first, previous, next or last messages, if they exist.
1553 All of the messages.
1555 For example, a range that shows all of these things is `1 2 3 5-10 last:5
1558 If the option `transient-mark-mode' is set to t and you set a region in the
1559 MH-Folder buffer, then the MH-E command will perform the operation on all
1560 messages in that region.
1562 \\{mh-folder-mode-map}"
1564 (make-local-variable 'font-lock-defaults)
1565 (setq font-lock-defaults '(mh-folder-font-lock-keywords t))
1566 (make-local-variable 'desktop-save-buffer)
1567 (setq desktop-save-buffer t)
1569 'mh-colors-available-flag (mh-colors-available-p)
1570 ; Do we have colors available
1571 'mh-current-folder (buffer-name) ; Name of folder, a string
1572 'mh-show-buffer (format "show-%s" (buffer-name)) ; Buffer that displays msgs
1573 'mh-folder-filename ; e.g. "/usr/foobar/Mail/inbox/"
1574 (file-name-as-directory (mh-expand-file-name (buffer-name)))
1575 'mh-display-buttons-for-inline-parts-flag
1576 mh-display-buttons-for-inline-parts-flag ; Allow for display of buttons to
1578 'mh-arrow-marker (make-marker) ; Marker where arrow is displayed
1579 'overlay-arrow-position nil ; Allow for simultaneous display in
1580 'overlay-arrow-string ">" ; different MH-E buffers.
1581 'mh-showing-mode nil ; Show message also?
1582 'mh-delete-list nil ; List of msgs nums to delete
1583 'mh-refile-list nil ; List of folder names in mh-seq-list
1584 'mh-seq-list nil ; Alist of (seq . msgs) nums
1585 'mh-seen-list nil ; List of displayed messages
1586 'mh-next-direction 'forward ; Direction to move to next message
1587 'mh-view-ops () ; Stack that keeps track of the order
1588 ; in which narrowing/threading has been
1590 'mh-folder-view-stack () ; Stack of previous views of the
1592 'mh-index-data nil ; If the folder was created by a call
1593 ; to mh-index-search this contains info
1594 ; about the search results.
1595 'mh-index-previous-search nil ; Previous folder and search-regexp
1596 'mh-index-msg-checksum-map nil ; msg -> checksum map
1597 'mh-index-checksum-origin-map nil ; checksum -> ( orig-folder, orig-msg )
1598 'mh-index-sequence-search-flag nil ; folder resulted from sequence search
1599 'mh-first-msg-num nil ; Number of first msg in buffer
1600 'mh-last-msg-num nil ; Number of last msg in buffer
1601 'mh-msg-count nil ; Number of msgs in buffer
1602 'mh-mode-line-annotation nil ; Indicates message range
1603 'mh-sequence-notation-history (make-hash-table)
1604 ; Remember what is overwritten by
1606 'imenu-create-index-function 'mh-index-create-imenu-index
1607 ; Setup imenu support
1608 'mh-previous-window-config nil) ; Previous window configuration
1609 (mh-remove-xemacs-horizontal-scrollbar)
1610 (setq truncate-lines t)
1612 (setq buffer-offer-save t)
1613 (mh-make-local-hook (mh-write-file-functions-compat))
1614 (add-hook (mh-write-file-functions-compat) 'mh-execute-commands nil t)
1615 (make-local-variable 'revert-buffer-function)
1616 (make-local-variable 'hl-line-mode) ; avoid pollution
1617 (mh-funcall-if-exists hl-line-mode 1)
1618 (setq revert-buffer-function 'mh-undo-folder)
1619 (or (assq 'mh-showing-mode minor-mode-alist)
1620 (setq minor-mode-alist
1621 (cons '(mh-showing-mode " Show") minor-mode-alist)))
1622 (easy-menu-add mh-folder-sequence-menu)
1623 (easy-menu-add mh-folder-message-menu)
1624 (easy-menu-add mh-folder-folder-menu)
1625 (set (make-local-variable 'tool-bar-map) mh-folder-tool-bar-map)
1626 (mh-funcall-if-exists mh-toolbar-init :folder)
1627 (if (and mh-xemacs-flag
1628 font-lock-auto-fontify)
1629 (turn-on-font-lock))) ; Force font-lock in XEmacs.
1631 (defun mh-toggle-mime-buttons ()
1632 "Toggle display of buttons for inline MIME parts."
1634 (setq mh-display-buttons-for-inline-parts-flag
1635 (not mh-display-buttons-for-inline-parts-flag))
1638 (defun mh-colors-available-p ()
1639 "Check if colors are available in the Emacs being used."
1642 (or (ignore-errors (mh-funcall-if-exists display-color-cells))
1643 (ignore-errors (mh-funcall-if-exists
1644 x-display-color-cells)))))
1645 (and (numberp color-cells) (>= color-cells 8)))))
1647 (defun mh-colors-in-use-p ()
1648 "Check if colors are being used in the folder buffer."
1649 (and mh-colors-available-flag font-lock-mode))
1651 (defun mh-make-local-vars (&rest pairs)
1652 "Initialize local variables according to the variable-value PAIRS."
1655 (set (make-local-variable (car pairs)) (car (cdr pairs)))
1656 (setq pairs (cdr (cdr pairs)))))
1658 (defun mh-restore-desktop-buffer (desktop-buffer-file-name
1660 desktop-buffer-misc)
1661 "Restore an MH folder buffer specified in a desktop file.
1662 When desktop creates a buffer, DESKTOP-BUFFER-FILE-NAME holds the file name to
1663 visit, DESKTOP-BUFFER-NAME holds the desired buffer name, and
1664 DESKTOP-BUFFER-MISC holds a list of miscellaneous info used by the
1665 `desktop-buffer-handlers' functions."
1667 (mh-visit-folder desktop-buffer-name)
1670 (add-to-list 'desktop-buffer-mode-handlers
1671 '(mh-folder-mode . mh-restore-desktop-buffer))
1673 (defun mh-scan-folder (folder range &optional dont-exec-pending)
1674 "Scan the FOLDER over the RANGE.
1675 If the optional argument DONT-EXEC-PENDING is non-nil then pending deletes and
1676 refiles aren't carried out.
1677 Return in the folder's buffer."
1678 (when (stringp range)
1679 (setq range (delete "" (split-string range "[ \t\n]"))))
1680 (cond ((null (get-buffer folder))
1681 (mh-make-folder folder))
1683 (unless dont-exec-pending
1684 (mh-process-or-undo-commands folder)
1685 (mh-reset-threads-and-narrowing))
1686 (switch-to-buffer folder)))
1687 (mh-regenerate-headers range)
1688 (if (zerop (buffer-size))
1689 (if (equal range "all")
1690 (message "Folder %s is empty" folder)
1691 (message "No messages in %s, range %s" folder range))
1693 (when (mh-outstanding-commands-p)
1694 (mh-notate-deleted-and-refiled)))
1696 (defun mh-set-cmd-note (width)
1697 "Set `mh-cmd-note' to WIDTH characters (minimum of 2).
1699 If `mh-scan-format-file' specifies nil or a filename, then this function
1700 will NOT update `mh-cmd-note'."
1701 ;; Add one to the width to always have whitespace in column zero.
1702 (setq width (max (1+ width) 2))
1703 (if (and (equal mh-scan-format-file t)
1704 (not (eq mh-cmd-note width)))
1705 (setq mh-cmd-note width))
1708 (defun mh-regenerate-headers (range &optional update)
1709 "Scan folder over range RANGE.
1710 If UPDATE, append the scan lines, otherwise replace."
1711 (let ((folder mh-current-folder)
1712 (range (if (and range (atom range)) (list range) range))
1714 (message "Scanning %s..." folder)
1715 (mh-remove-all-notation)
1716 (with-mh-folder-updating (nil)
1718 (goto-char (point-max))
1719 (delete-region (point-min) (point-max))
1720 (if mh-adaptive-cmd-note-flag
1721 (mh-set-cmd-note (mh-message-number-width folder))))
1722 (setq scan-start (point))
1723 (apply #'mh-exec-cmd-output
1726 "-noclear" "-noheader"
1727 "-width" (window-width)
1729 (goto-char scan-start)
1730 (cond ((looking-at "scan: no messages in")
1731 (keep-lines mh-scan-valid-regexp)) ; Flush random scan lines
1732 ((looking-at (if (mh-variant-p 'mu-mh)
1733 "scan: message set .* does not exist"
1734 "scan: bad message list "))
1735 (keep-lines mh-scan-valid-regexp))
1736 ((looking-at "scan: ")) ; Keep error messages
1738 (keep-lines mh-scan-valid-regexp))) ; Flush random scan lines
1739 (setq mh-seq-list (mh-read-folder-sequences folder nil))
1740 (mh-notate-user-sequences)
1742 (setq mh-mode-line-annotation
1743 (if (equal range '("all"))
1745 mh-partial-folder-mode-line-annotation)))
1746 (mh-make-folder-mode-line))
1747 (message "Scanning %s...done" folder)))
1749 (defun mh-generate-new-cmd-note (folder)
1750 "Fix the `mh-cmd-note' value for this FOLDER.
1752 After doing an `mh-get-new-mail' operation in this FOLDER, at least
1753 one line that looks like a truncated message number was found.
1755 Remove the text added by the last `mh-inc' command. It should be the
1756 messages cur-last. Call `mh-set-cmd-note' with the widest message number
1759 Reformat the message number width on each line in the buffer and trim
1760 the line length to fit in the window.
1762 Rescan the FOLDER in the range cur-last in order to display the
1763 messages that were removed earlier. They should all fit in the scan
1764 line now with no message truncation."
1766 (let ((maxcol (1- (window-width)))
1767 (old-cmd-note mh-cmd-note)
1770 ;; Nuke all of the lines just added by the last inc
1771 (delete-char (- (point-max) (point)))
1772 ;; Update the current buffer to reflect the new mh-cmd-note
1773 ;; value needed to display messages.
1774 (mh-set-cmd-note (mh-message-number-width folder))
1775 (setq mh-cmd-note-fmt (concat "%" (format "%d" mh-cmd-note) "d"))
1776 ;; Cleanup the messages that are in the buffer right now
1777 (goto-char (point-min))
1778 (cond ((memq 'unthread mh-view-ops)
1779 (mh-thread-add-spaces (- mh-cmd-note old-cmd-note)))
1780 (t (while (re-search-forward mh-scan-msg-number-regexp nil 0 1)
1781 ;; reformat the number to fix in mh-cmd-note columns
1782 (setq msgnum (string-to-number
1784 (match-beginning 1) (match-end 1))))
1785 (replace-match (format mh-cmd-note-fmt msgnum))
1786 ;; trim the line to fix in the window
1788 (let ((eol (point)))
1789 (move-to-column maxcol)
1790 (if (<= (point) eol)
1791 (delete-char (- eol (point))))))))
1792 ;; now re-read the lost messages
1793 (goto-char (point-max))
1795 (mh-regenerate-headers "cur-last" t)))))
1797 (defun mh-get-new-mail (maildrop-name)
1798 "Read new mail from MAILDROP-NAME into the current buffer.
1799 Return in the current buffer."
1800 (let ((point-before-inc (point))
1801 (folder mh-current-folder)
1802 (new-mail-flag nil))
1803 (with-mh-folder-updating (t)
1805 (message "inc %s -file %s..." folder maildrop-name)
1806 (message "inc %s..." folder))
1807 (setq mh-next-direction 'forward)
1808 (goto-char (point-max))
1809 (mh-remove-cur-notation)
1810 (let ((start-of-inc (point)))
1812 ;; I think MH 5 used "-ms-file" instead of "-file",
1813 ;; which would make inc'ing from maildrops fail.
1814 (mh-exec-cmd-output mh-inc-prog nil folder
1816 "-file" (expand-file-name maildrop-name)
1817 "-width" (window-width)
1819 (mh-exec-cmd-output mh-inc-prog nil
1821 "-width" (window-width)))
1823 (message "inc %s -file %s...done" folder maildrop-name)
1824 (message "inc %s...done" folder))
1825 (goto-char start-of-inc)
1826 (cond ((save-excursion
1827 (re-search-forward "^inc: no mail" nil t))
1828 (message "No new mail%s%s" (if maildrop-name " in " "")
1829 (if maildrop-name maildrop-name "")))
1830 ((and (when mh-folder-view-stack
1831 (let ((saved-text (buffer-substring-no-properties
1832 start-of-inc (point-max))))
1833 (delete-region start-of-inc (point-max))
1834 (unwind-protect (mh-widen t)
1835 (mh-remove-cur-notation)
1836 (goto-char (point-max))
1837 (setq start-of-inc (point))
1839 (goto-char start-of-inc))))
1841 ((re-search-forward "^inc:" nil t) ; Error messages
1842 (error "Error incorporating mail"))
1844 (equal mh-scan-format-file t)
1845 mh-adaptive-cmd-note-flag
1846 ;; Have we reached an edge condition?
1848 (re-search-forward mh-scan-msg-overflow-regexp nil 0 1))
1849 (setq start-of-inc (mh-generate-new-cmd-note folder))
1852 (setq new-mail-flag t)))
1853 (keep-lines mh-scan-valid-regexp) ; Flush random scan lines
1854 (let* ((sequences (mh-read-folder-sequences folder t))
1855 (new-cur (assoc 'cur sequences))
1856 (new-unseen (assoc mh-unseen-seq sequences)))
1857 (unless (assoc 'cur mh-seq-list)
1858 (push (list 'cur) mh-seq-list))
1859 (unless (assoc mh-unseen-seq mh-seq-list)
1860 (push (list mh-unseen-seq) mh-seq-list))
1861 (setcdr (assoc 'cur mh-seq-list) (cdr new-cur))
1862 (setcdr (assoc mh-unseen-seq mh-seq-list) (cdr new-unseen)))
1863 (when (equal (point-max) start-of-inc)
1867 (mh-make-folder-mode-line)
1868 (when (mh-speed-flists-active-p)
1869 (mh-speed-flists t mh-current-folder))
1870 (when (memq 'unthread mh-view-ops)
1871 (mh-thread-inc folder start-of-inc))
1873 (goto-char point-before-inc))
1874 (mh-notate-user-sequences (cons start-of-inc (point-max)))))))
1876 (defun mh-make-folder-mode-line (&optional ignored)
1877 "Set the fields of the mode line for a folder buffer.
1878 The optional argument is now obsolete and IGNORED. It used to be used to pass
1879 in what is now stored in the buffer-local variable `mh-mode-line-annotation'."
1881 (save-window-excursion
1883 (let ((new-first-msg-num (mh-get-msg-num nil)))
1884 (when (or (not (memq 'unthread mh-view-ops))
1885 (null mh-first-msg-num)
1886 (null new-first-msg-num)
1887 (< new-first-msg-num mh-first-msg-num))
1888 (setq mh-first-msg-num new-first-msg-num)))
1890 (let ((new-last-msg-num (mh-get-msg-num nil)))
1891 (when (or (not (memq 'unthread mh-view-ops))
1892 (null mh-last-msg-num)
1893 (null new-last-msg-num)
1894 (> new-last-msg-num mh-last-msg-num))
1895 (setq mh-last-msg-num new-last-msg-num)))
1896 (setq mh-msg-count (if mh-first-msg-num
1897 (count-lines (point-min) (point-max))
1899 (setq mode-line-buffer-identification
1900 (list (format " {%%b%s} %s msg%s"
1901 (if mh-mode-line-annotation
1902 (format "/%s" mh-mode-line-annotation)
1904 (if (zerop mh-msg-count)
1906 (format "%d" mh-msg-count))
1907 (if (zerop mh-msg-count)
1909 (cond ((> mh-msg-count 1)
1910 (format "s (%d-%d)" mh-first-msg-num
1913 (format " (%d)" mh-first-msg-num))
1915 (mh-logo-display))))
1917 (defun mh-add-sequence-notation (msg internal-seq-flag)
1918 "Add sequence notation to the MSG on the current line.
1919 If INTERNAL-SEQ-FLAG is non-nil, then refontify the scan line if font-lock is
1921 (with-mh-folder-updating (t)
1924 (if internal-seq-flag
1926 ;; Change the buffer so that if transient-mark-mode is active
1927 ;; and there is an active region it will get deactivated as in
1928 ;; the case of user sequences.
1929 (mh-notate nil nil mh-cmd-note)
1930 (when font-lock-mode
1931 (font-lock-fontify-region (point) (line-end-position))))
1932 (forward-char (1+ mh-cmd-note))
1933 (let ((stack (gethash msg mh-sequence-notation-history)))
1934 (setf (gethash msg mh-sequence-notation-history)
1935 (cons (char-after) stack)))
1936 (mh-notate nil mh-note-seq (1+ mh-cmd-note))))))
1938 (defun mh-remove-sequence-notation (msg internal-seq-flag &optional all)
1939 "Remove sequence notation from the MSG on the current line.
1940 If INTERNAL-SEQ-FLAG is non-nil, then `font-lock' was used to highlight the
1941 sequence. In that case, no notation needs to be removed. Otherwise the effect
1942 of inserting `mh-note-seq' needs to be reversed.
1943 If ALL is non-nil, then all sequence marks on the scan line are removed."
1944 (with-mh-folder-updating (t)
1945 ;; This takes care of internal sequences...
1946 (mh-notate nil nil mh-cmd-note)
1947 (unless internal-seq-flag
1948 ;; ... and this takes care of user sequences.
1949 (let ((stack (gethash msg mh-sequence-notation-history)))
1950 (while (and all (cdr stack))
1951 (setq stack (cdr stack)))
1955 (forward-char (1+ mh-cmd-note))
1957 (insert (car stack))))
1958 (setf (gethash msg mh-sequence-notation-history) (cdr stack))))))
1960 (defun mh-remove-cur-notation ()
1961 "Remove old cur notation."
1962 (let ((cur-msg (car (mh-seq-to-msgs 'cur))))
1965 (mh-goto-msg cur-msg t t)
1966 (looking-at mh-scan-cur-msg-number-regexp))
1967 (mh-notate nil ? mh-cmd-note)
1968 (setq overlay-arrow-position nil)))))
1970 (defun mh-remove-all-notation ()
1971 "Remove all notations on all scan lines that MH-E introduces."
1973 (setq overlay-arrow-position nil)
1974 (goto-char (point-min))
1975 (mh-iterate-on-range msg (cons (point-min) (point-max))
1976 (mh-notate nil ? mh-cmd-note)
1977 (mh-remove-sequence-notation msg nil t))
1978 (clrhash mh-sequence-notation-history)))
1981 (defun mh-goto-cur-msg (&optional minimal-changes-flag)
1982 "Position the cursor at the current message.
1983 When optional argument MINIMAL-CHANGES-FLAG is non-nil, the function doesn't
1984 recenter the folder buffer."
1985 (let ((cur-msg (car (mh-seq-to-msgs 'cur))))
1987 (mh-goto-msg cur-msg t t))
1988 (unless minimal-changes-flag
1991 (mh-maybe-show cur-msg)))
1993 (setq overlay-arrow-position nil)
1994 (message "No current message")))))
1996 (defun mh-process-or-undo-commands (folder)
1997 "If FOLDER has outstanding commands, then either process or discard them.
1998 Called by functions like `mh-sort-folder', so also invalidate show buffer."
2000 (if (mh-outstanding-commands-p)
2001 (if (or mh-do-not-confirm-flag
2003 "Process outstanding deletes and refiles? "))
2004 (mh-process-commands folder)
2008 (mh-invalidate-show-buffer))
2010 (defun mh-process-commands (folder)
2011 "Process outstanding commands for FOLDER.
2012 The value of `mh-folder-updated-hook' is a list of functions to be called,
2013 with no arguments, before the commands are processed."
2014 (message "Processing deletes and refiles for %s..." folder)
2016 (with-mh-folder-updating (nil)
2017 ;; Run the hook while the lists are still valid
2018 (run-hooks 'mh-folder-updated-hook)
2020 ;; Update the unseen sequence if it exists
2023 (let ((redraw-needed-flag mh-index-data)
2024 (folders-changed (list mh-current-folder))
2025 (seq-map (and mh-refile-list mh-refile-preserves-sequences-flag
2026 (mh-create-sequence-map mh-seq-list)))
2027 (dest-map (and mh-refile-list mh-refile-preserves-sequences-flag
2028 (make-hash-table))))
2029 ;; Remove invalid scan lines if we are in an index folder and then remove
2030 ;; the real messages
2032 (mh-index-delete-folder-headers)
2033 (setq folders-changed
2034 (append folders-changed (mh-index-execute-commands))))
2036 ;; Then refile messages
2037 (mh-mapc #'(lambda (folder-msg-list)
2038 (let* ((dest-folder (symbol-name (car folder-msg-list)))
2039 (last (car (mh-translate-range dest-folder "last")))
2040 (msgs (cdr folder-msg-list)))
2041 (push dest-folder folders-changed)
2042 (setq redraw-needed-flag t)
2043 (apply #'mh-exec-cmd
2044 "refile" "-src" folder dest-folder
2045 (mh-coalesce-msg-list msgs))
2046 (mh-delete-scan-msgs msgs)
2047 ;; Preserve sequences in destination folder...
2048 (when mh-refile-preserves-sequences-flag
2050 (loop for i from (1+ (or last 0))
2051 for msg in (sort (copy-sequence msgs) #'<)
2052 do (loop for seq-name in (gethash msg seq-map)
2053 do (push i (gethash seq-name dest-map))))
2055 #'(lambda (seq msgs)
2056 ;; Can't be run in the background, since the
2057 ;; current folder is changed by mark this could
2058 ;; lead to a race condition with the next refile.
2059 (apply #'mh-exec-cmd "mark"
2060 "-sequence" (symbol-name seq) dest-folder
2061 "-add" (mapcar #'(lambda (x) (format "%s" x))
2062 (mh-coalesce-msg-list msgs))))
2065 (setq mh-refile-list ())
2067 ;; Now delete messages
2068 (cond (mh-delete-list
2069 (setq redraw-needed-flag t)
2070 (apply 'mh-exec-cmd "rmm" folder
2071 (mh-coalesce-msg-list mh-delete-list))
2072 (mh-delete-scan-msgs mh-delete-list)
2073 (setq mh-delete-list nil)))
2075 ;; Don't need to remove sequences since delete and refile do so.
2077 (if (> (buffer-size) 0)
2078 (mh-define-sequence 'cur (list (or (mh-get-msg-num nil) "last"))))
2080 ;; Redraw folder buffer if needed
2081 (when (and redraw-needed-flag)
2082 (when (mh-speed-flists-active-p)
2083 (apply #'mh-speed-flists t folders-changed))
2084 (cond ((memq 'unthread mh-view-ops) (mh-thread-inc folder (point-max)))
2085 (mh-index-data (mh-index-insert-folder-headers)))))
2087 (and (buffer-file-name (get-buffer mh-show-buffer))
2088 (not (file-exists-p (buffer-file-name (get-buffer mh-show-buffer))))
2089 ;; If "inc" were to put a new msg in this file,
2090 ;; we would not notice, so mark it invalid now.
2091 (mh-invalidate-show-buffer))
2093 (setq mh-seq-list (mh-read-folder-sequences mh-current-folder nil))
2094 (mh-remove-all-notation)
2095 (mh-notate-user-sequences)
2096 (message "Processing deletes and refiles for %s...done" folder)))
2098 (defun mh-update-unseen ()
2099 "Synchronize the unseen sequence with MH.
2100 Return non-nil iff the MH folder was set.
2101 The value of `mh-unseen-updated-hook' is a list of functions to be called,
2102 with no arguments, after the unseen sequence is updated."
2104 (let* ((unseen-seq (mh-find-seq mh-unseen-seq))
2105 (unseen-msgs (mh-seq-msgs unseen-seq)))
2108 (mh-undefine-sequence mh-unseen-seq mh-seen-list)
2109 (run-hooks 'mh-unseen-updated-hook)
2111 (setq unseen-msgs (delq (car mh-seen-list) unseen-msgs))
2112 (setq mh-seen-list (cdr mh-seen-list)))
2113 (setcdr unseen-seq unseen-msgs)
2114 t) ;since we set the folder
2115 (setq mh-seen-list nil)))))
2117 (defun mh-delete-scan-msgs (msgs)
2118 "Delete the scan listing lines for MSGS."
2121 (when (mh-goto-msg (car msgs) t t)
2122 (when (memq 'unthread mh-view-ops)
2123 (mh-thread-forget-message (car msgs)))
2125 (setq msgs (cdr msgs)))))
2127 (defun mh-outstanding-commands-p ()
2128 "Return non-nil if there are outstanding deletes or refiles."
2130 (when (eq major-mode 'mh-show-mode)
2131 (set-buffer mh-show-folder-buffer))
2132 (or mh-delete-list mh-refile-list)))
2134 (defun mh-coalesce-msg-list (messages)
2135 "Given a list of MESSAGES, return a list of message number ranges.
2136 This is the inverse of `mh-read-msg-list', which expands ranges.
2137 Message lists passed to MH programs should be processed by this function
2138 to avoid exceeding system command line argument limits."
2139 (let ((msgs (sort (copy-sequence messages) 'mh-greaterp))
2145 (if (or (not (numberp prev))
2146 (not (equal (car msgs) (1- prev))))
2147 (progn ;non-sequential, flush old range
2148 (if (eq prev range-high)
2149 (setq ranges (cons range-high ranges))
2150 (setq ranges (cons (format "%s-%s" prev range-high) ranges)))
2151 (setq range-high nil))))
2153 (setq range-high (car msgs))) ;start new or first range
2154 (setq prev (car msgs))
2155 (setq msgs (cdr msgs)))
2158 (defun mh-greaterp (msg1 msg2)
2159 "Return the greater of two message indicators MSG1 and MSG2.
2160 Strings are \"smaller\" than numbers.
2161 Valid values are things like \"cur\", \"last\", 1, and 1820."
2168 (string-lessp msg2 msg1))))
2170 (defun mh-lessp (msg1 msg2)
2171 "Return the lesser of two message indicators MSG1 and MSG2.
2172 Strings are \"smaller\" than numbers.
2173 Valid values are things like \"cur\", \"last\", 1, and 1820."
2174 (not (mh-greaterp msg1 msg2)))
2178 ;;; Basic sequence handling
2180 (defun mh-delete-seq-locally (seq)
2181 "Remove MH-E's record of SEQ."
2182 (let ((entry (mh-find-seq seq)))
2183 (setq mh-seq-list (delq entry mh-seq-list))))
2185 (defun mh-read-folder-sequences (folder save-refiles)
2186 "Read and return the predefined sequences for a FOLDER.
2187 If SAVE-REFILES is non-nil, then keep the sequences
2188 that note messages to be refiled."
2191 (mh-mapc (function (lambda (seq) ; Save the refiling sequences
2192 (if (mh-folder-name-p (mh-seq-name seq))
2193 (setq seqs (cons seq seqs)))))
2196 (if (eq 0 (mh-exec-cmd-quiet nil "mark" folder "-list"))
2198 ;; look for name in line of form "cur: 4" or "myseq (private): 23"
2199 (while (re-search-forward "^[^: ]+" nil t)
2200 (setq seqs (cons (mh-make-seq (intern (buffer-substring
2205 (delete-region (point-min) (point))))) ; avoid race with
2209 (defun mh-read-msg-list ()
2210 "Return a list of message numbers from point to the end of the line.
2211 Expands ranges into set of individual numbers."
2213 (end-of-line (save-excursion (end-of-line) (point)))
2215 (while (re-search-forward "[0-9]+" end-of-line t)
2216 (setq num (string-to-number (buffer-substring (match-beginning 0)
2218 (cond ((looking-at "-") ; Message range
2220 (re-search-forward "[0-9]+" end-of-line t)
2221 (let ((num2 (string-to-number
2222 (buffer-substring (match-beginning 0)
2225 (error "Bad message range: %d-%d" num num2))
2226 (while (<= num num2)
2227 (setq msgs (cons num msgs))
2228 (setq num (1+ num)))))
2229 ((not (zerop num)) ;"pick" outputs "0" to mean no match
2230 (setq msgs (cons num msgs)))))
2233 (defun mh-notate-user-sequences (&optional range)
2234 "Mark user-defined sequences in the messages specified by RANGE.
2235 The optional argument RANGE can be a message number, a list of message
2236 numbers, a sequence, a region in a cons cell. If nil all messages are notated."
2238 (setq range (cons (point-min) (point-max))))
2239 (let ((seqs mh-seq-list)
2240 (msg-hash (make-hash-table)))
2242 (dolist (msg (mh-seq-msgs seq))
2243 (push (car seq) (gethash msg msg-hash))))
2244 (mh-iterate-on-range msg range
2245 (loop for seq in (gethash msg msg-hash)
2246 do (mh-add-sequence-notation msg (mh-internal-seq seq))))))
2248 (defvar mh-internal-seqs '(answered cur deleted forwarded printed))
2250 (defun mh-internal-seq (name)
2251 "Return non-nil if NAME is the name of an internal MH-E sequence."
2252 (or (memq name mh-internal-seqs)
2253 (eq name mh-unseen-seq)
2254 (and (mh-colors-in-use-p) mh-tick-seq (eq name mh-tick-seq))
2255 (eq name mh-previous-seq)
2256 (mh-folder-name-p name)))
2258 (defun mh-valid-seq-p (name)
2259 "Return non-nil if NAME is a valid MH sequence name."
2261 (string-match "^[a-zA-Z][a-zA-Z0-9]*$" (symbol-name name))))
2263 (defun mh-delete-msg-from-seq (range sequence &optional internal-flag)
2264 "Delete RANGE from SEQUENCE.
2266 Check the documentation of `mh-interactive-range' to see how RANGE is read in
2269 Optional third arg INTERNAL-FLAG non-nil means do not inform MH of the
2271 (interactive (list (mh-interactive-range "Delete")
2272 (mh-read-seq-default "Delete from" t)
2274 (let ((entry (mh-find-seq sequence))
2275 (user-sequence-flag (not (mh-internal-seq sequence)))
2276 (folders-changed (list mh-current-folder))
2279 (mh-iterate-on-range msg range
2281 ;; Calling "mark" repeatedly takes too long. So we will pretend here
2282 ;; that we are just modifying an internal sequence...
2283 (when (memq msg (cdr entry))
2284 (mh-remove-sequence-notation msg (not user-sequence-flag)))
2285 (mh-delete-a-msg-from-seq msg sequence t))
2286 ;; ... and here we will "mark" all the messages at one go.
2287 (unless internal-flag (mh-undefine-sequence sequence msg-list))
2288 (when (and mh-index-data (not internal-flag))
2289 (setq folders-changed
2290 (append folders-changed
2291 (mh-index-delete-from-sequence sequence msg-list))))
2292 (when (and (eq sequence mh-unseen-seq) (mh-speed-flists-active-p))
2293 (apply #'mh-speed-flists t folders-changed)))))
2295 (defun mh-catchup (range)
2296 "Delete RANGE from the `mh-unseen-seq' sequence.
2298 Check the document of `mh-interactive-range' to see how RANGE is read in
2300 (interactive (list (mh-interactive-range "Catchup"
2301 (cons (point-min) (point-max)))))
2302 (mh-delete-msg-from-seq range mh-unseen-seq))
2304 (defun mh-delete-a-msg-from-seq (msg sequence internal-flag)
2305 "Delete MSG from SEQUENCE.
2306 If INTERNAL-FLAG is non-nil, then do not inform MH of the change."
2307 (let ((entry (mh-find-seq sequence)))
2308 (when (and entry (memq msg (mh-seq-msgs entry)))
2309 (if (not internal-flag)
2310 (mh-undefine-sequence sequence (list msg)))
2311 (setcdr entry (delq msg (mh-seq-msgs entry))))))
2313 (defun mh-undefine-sequence (seq msgs)
2314 "Remove from the SEQ the list of MSGS."
2315 (when (and (mh-valid-seq-p seq) msgs)
2316 (apply #'mh-exec-cmd "mark" mh-current-folder "-delete"
2317 "-sequence" (symbol-name seq) (mh-coalesce-msg-list msgs))))
2319 (defun mh-define-sequence (seq msgs)
2320 "Define the SEQ to contain the list of MSGS.
2321 Do not mark pseudo-sequences or empty sequences.
2322 Signals an error if SEQ is an invalid name."
2324 (mh-valid-seq-p seq)
2325 (not (mh-folder-name-p seq)))
2327 (mh-exec-cmd-error nil "mark" mh-current-folder "-add" "-zero"
2328 "-sequence" (symbol-name seq)
2329 (mh-coalesce-msg-list msgs)))))
2331 (defun mh-seq-containing-msg (msg &optional include-internal-flag)
2332 "Return a list of the sequences containing MSG.
2333 If INCLUDE-INTERNAL-FLAG non-nil, include MH-E internal sequences in list."
2334 (let ((l mh-seq-list)
2337 (and (memq msg (mh-seq-msgs (car l)))
2338 (or include-internal-flag
2339 (not (mh-internal-seq (mh-seq-name (car l)))))
2340 (setq seqs (cons (mh-seq-name (car l)) seqs)))
2346 ;;; Build the folder-mode keymap:
2348 (suppress-keymap mh-folder-mode-map)
2350 ;; Use defalias to make sure the documented primary key bindings
2351 ;; appear in menu lists.
2352 (defalias 'mh-alt-show 'mh-show)
2353 (defalias 'mh-alt-refile-msg 'mh-refile-msg)
2354 (defalias 'mh-alt-send 'mh-send)
2355 (defalias 'mh-alt-visit-folder 'mh-visit-folder)
2357 ;; Save the `b' binding for a future `back'. Maybe?
2358 (gnus-define-keys mh-folder-mode-map
2360 "!" mh-refile-or-write-again
2362 "," mh-header-display
2364 ";" mh-toggle-mh-decode-mime-flag
2365 ">" mh-write-msg-to-file
2367 "E" mh-extract-rejected-mail
2369 "\177" mh-previous-page
2370 "\C-d" mh-delete-msg-no-motion
2371 "\t" mh-index-next-folder
2372 [backtab] mh-index-previous-folder
2373 "\M-\t" mh-index-previous-folder
2376 "\ed" mh-redistribute
2378 "^" mh-alt-refile-msg
2385 "k" mh-delete-subject-or-thread
2387 "n" mh-next-undeleted-msg
2388 "\M-n" mh-next-unread-msg
2390 "p" mh-previous-undeleted-msg
2391 "\M-p" mh-previous-unread-msg
2395 "t" mh-toggle-showing
2397 "v" mh-index-visit-folder
2398 "x" mh-execute-commands
2401 (gnus-define-keys (mh-folder-map "F" mh-folder-mode-map)
2403 "'" mh-index-ticked-messages
2406 "f" mh-alt-visit-folder
2410 "n" mh-index-new-messages
2411 "o" mh-alt-visit-folder
2413 "q" mh-index-sequenced-messages
2414 "r" mh-rescan-folder
2415 "s" mh-search-folder
2417 "v" mh-visit-folder)
2419 (define-key mh-folder-mode-map "I" mh-inc-spool-map)
2421 (gnus-define-keys (mh-junk-map "J" mh-folder-mode-map)
2423 "b" mh-junk-blacklist
2424 "w" mh-junk-whitelist)
2426 (gnus-define-keys (mh-ps-print-map "P" mh-folder-mode-map)
2428 "A" mh-ps-print-toggle-mime
2429 "C" mh-ps-print-toggle-color
2430 "F" mh-ps-print-toggle-faces
2431 "M" mh-ps-print-toggle-mime
2432 "f" mh-ps-print-msg-file
2435 "s" mh-ps-print-msg-show)
2437 (gnus-define-keys (mh-sequence-map "S" mh-folder-mode-map)
2438 "'" mh-narrow-to-tick
2440 "d" mh-delete-msg-from-seq
2442 "l" mh-list-sequences
2443 "n" mh-narrow-to-seq
2444 "p" mh-put-msg-in-seq
2445 "s" mh-msg-is-in-seq
2448 (gnus-define-keys (mh-thread-map "T" mh-folder-mode-map)
2450 "u" mh-thread-ancestor
2451 "p" mh-thread-previous-sibling
2452 "n" mh-thread-next-sibling
2453 "t" mh-toggle-threads
2454 "d" mh-thread-delete
2455 "o" mh-thread-refile)
2457 (gnus-define-keys (mh-limit-map "/" mh-folder-mode-map)
2458 "'" mh-narrow-to-tick
2461 "f" mh-narrow-to-from
2462 "r" mh-narrow-to-range
2463 "s" mh-narrow-to-subject
2467 (gnus-define-keys (mh-extract-map "X" mh-folder-mode-map)
2469 "s" mh-store-msg ;shar
2470 "u" mh-store-msg) ;uuencode
2472 (gnus-define-keys (mh-digest-map "D" mh-folder-mode-map)
2475 "\177" mh-page-digest-backwards
2476 "b" mh-burst-digest)
2478 (gnus-define-keys (mh-mime-map "K" mh-folder-mode-map)
2480 "a" mh-mime-save-parts
2481 "e" mh-display-with-external-viewer
2482 "i" mh-folder-inline-mime-part
2483 "o" mh-folder-save-mime-part
2484 "t" mh-toggle-mime-buttons
2485 "v" mh-folder-toggle-mime-part
2487 [backtab] mh-prev-button
2488 "\M-\t" mh-prev-button)
2492 (define-key mh-folder-mode-map [button2] 'mh-show-mouse))
2494 (define-key mh-folder-mode-map [mouse-2] 'mh-show-mouse)))
2496 ;; "C-c /" prefix is used in mh-folder-mode by pgp.el and mailcrypt
2502 ;;; If you add a new prefix, add appropriate text to the nil key.
2504 ;;; In general, messages are grouped logically. Taking the main commands for
2505 ;;; example, the first line is "ways to view messages," the second line is
2506 ;;; "things you can do with messages", and the third is "composing" messages.
2508 ;;; When adding a new prefix, ensure that the help message contains "what" the
2509 ;;; prefix is for. For example, if the word "folder" were not present in the
2510 ;;; `F' entry, it would not be clear what these commands operated upon.
2511 (defvar mh-help-messages
2512 '((nil "[i]nc, [.]show, [,]show all, [n]ext, [p]revious,\n"
2513 "[d]elete, [o]refile, e[x]ecute,\n"
2514 "[s]end, [r]eply,\n"
2515 "[;]toggle MIME decoding.\n"
2516 "Prefix characters:\n [F]older, [S]equence, [J]unk, MIME [K]eys,"
2517 "\n [T]hread, [/]limit, e[X]tract, [D]igest, [I]nc spools.")
2519 (?F "[l]ist; [v]isit folder;\n"
2520 "[n]ew messages; [']ticked messages; [s]earch; [i]ndexed search;\n"
2521 "[p]ack; [S]ort; [r]escan; [k]ill")
2522 (?P "PS [p]rint message; [l]non-PS print;\n"
2523 "PS Print [s]how window, message to [f]ile;\n"
2524 "Toggle printing of [M]IME parts, [C]olor, [F]aces")
2525 (?S "[p]ut message in sequence, [n]arrow, [']narrow to ticked, [w]iden,\n"
2526 "[s]equences, [l]ist,\n"
2527 "[d]elete message from sequence, [k]ill sequence")
2528 (?T "[t]oggle, [d]elete, [o]refile thread")
2529 (?/ "Limit to [c]c, [f]rom, [r]ange, [s]ubject, [t]o; [w]iden")
2530 (?X "un[s]har, [u]udecode message")
2531 (?D "[b]urst digest")
2532 (?K "[v]iew, [i]nline, [o]utput/save MIME part; save [a]ll parts; \n"
2533 "[TAB] next; [SHIFT-TAB] previous")
2534 (?J "[b]lacklist, [w]hitelist message"))
2535 "Key binding cheat sheet.
2537 This is an associative array which is used to show the most common commands.
2538 The key is a prefix char. The value is one or more strings which are
2539 concatenated together and displayed in the minibuffer if ? is pressed after
2540 the prefix character. The special key nil is used to display the
2541 non-prefixed commands.
2543 The substitutions described in `substitute-command-keys' are performed as
2548 (dolist (mess '("^Cursor not pointing to message$"
2549 "^There is no other window$"))
2550 (add-to-list 'debug-ignored-errors mess))
2554 ;;; Local Variables:
2555 ;;; indent-tabs-mode: nil
2556 ;;; sentence-end-double-space: nil
2559 ;;; arch-tag: cce884de-bd37-4104-9963-e4439d5ed22b
2560 ;;; mh-e.el ends here