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.85+cvs" "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.
135 This string is passed to the scan program via the -format arg.
136 This format is identical to the default except that additional hints for
137 fontification have been added to the fifth column (remember that in Emacs, the
140 The values of the fifth column, in priority order, are: `-' if the message has
141 been replied to, t if an address on the To: line matches one of the
142 mailboxes of the current user, `c' if the Cc: line matches, `b' if the Bcc:
143 line matches, and `n' if a non-empty Newsgroups: header is present.")
145 (defvar mh-scan-format-nmh
150 "%?(nonnull(comp{to}))%<(mymbox{to})t%>"
151 "%?(nonnull(comp{cc}))%<(mymbox{cc})c%>"
152 "%?(nonnull(comp{bcc}))%<(mymbox{bcc})b%>"
153 "%?(nonnull(comp{newsgroups}))n%>"
155 "%02(mon{date})/%02(mday{date})%<{date} %|*%>"
156 "%<(mymbox{from})%<{to}To:%14(decode(friendly{to}))%>%>"
157 "%<(zero)%17(decode(friendly{from}))%> "
158 "%(decode{subject})%<{body}<<%{body}%>")
159 "*Scan format string for nmh.
160 This string is passed to the scan program via the -format arg.
161 This format is identical to the default except that additional hints for
162 fontification have been added to the fifth column (remember that in Emacs, the
165 The values of the fifth column, in priority order, are: `-' if the message has
166 been replied to, t if an address on the To: field matches one of the
167 mailboxes of the current user, `c' if the Cc: field matches, `b' if the Bcc:
168 field matches, and `n' if a non-empty Newsgroups: field is present.")
170 (defvar mh-note-deleted ?D
171 "Messages that have been deleted are marked by this character.
172 See also `mh-scan-deleted-msg-regexp'.")
174 (defvar mh-note-refiled ?^
175 "Messages that have been refiled are marked by this character.
176 See also `mh-scan-refiled-msg-regexp'.")
178 (defvar mh-note-cur ?+
179 "The current message (in MH, not in MH-E) is marked by this character.
180 See also `mh-scan-cur-msg-number-regexp'.")
182 (defvar mh-scan-good-msg-regexp "^\\( *[0-9]+\\)[^D^0-9]"
183 "This regular expression matches \"good\" messages.
184 It must match from the beginning of the line. Note that the default setting of
185 `mh-folder-font-lock-keywords' expects this expression to contain at least one
186 parenthesized expression which matches the message number as in the default of
187 \"^\\\\( *[0-9]+\\\\)[^D^0-9]\". This regular expression should be correct as
188 it is needed by non-fontifying functions.")
190 (defvar mh-scan-deleted-msg-regexp "^\\( *[0-9]+\\)D"
191 "This regular expression matches deleted messages.
192 It must match from the beginning of the line. Note that the default setting of
193 `mh-folder-font-lock-keywords' expects this expression to contain at least one
194 parenthesized expression which matches the message number as in the default of
195 \"^\\\\( *[0-9]+\\\\)D\". This regular expression should be correct as it is
196 needed by non-fontifying functions. See also `mh-note-deleted'.")
198 (defvar mh-scan-refiled-msg-regexp "^\\( *[0-9]+\\)\\^"
199 "This regular expression matches refiled messages.
200 It must match from the beginning of the line. Note that the default setting of
201 `mh-folder-font-lock-keywords' expects this expression to contain at least one
202 parenthesized expression which matches the message number as in the default of
203 \"^\\\\( *[0-9]+\\\\)\\\\^\". This regular expression should be correct as it
204 is needed by non-fontifying functions. See also `mh-note-refiled'.")
206 (defvar mh-scan-valid-regexp "^ *[0-9]"
207 "This regular expression describes a valid scan line.
208 This is used to eliminate error messages that are occasionally produced by
211 (defvar mh-scan-cur-msg-number-regexp "^\\( *[0-9]+\\+\\).*"
212 "This regular expression matches the current message.
213 It must match from the beginning of the line. Note that the default setting of
214 `mh-folder-font-lock-keywords' expects this expression to contain at least one
215 parenthesized expression which matches the message number as in the default of
216 \"^\\\\( *[0-9]+\\\\+\\\\).*\". This regular expression should be correct as
217 it is needed by non-fontifying functions. See also `mh-note-cur'.")
219 (defvar mh-scan-date-regexp "\\([0-9][0-9]/[0-9][0-9]\\)"
220 "This regular expression matches a valid date.
221 It must not be anchored to the beginning or the end of the line. Note that the
222 default setting of `mh-folder-font-lock-keywords' expects this expression to
223 contain only one parenthesized expression which matches the date field as in
224 the default of \"\\\\([0-9][0-9]/[0-9][0-9]\\\\)\"}. If this regular
225 expression is not correct, the date will not be highlighted. See also
226 `mh-scan-format-regexp'.")
228 (defvar mh-scan-rcpt-regexp "\\(To:\\)\\(..............\\)"
229 "This regular expression specifies the recipient in messages you sent.
230 Note that the default setting of `mh-folder-font-lock-keywords'
231 expects this expression to contain two parenthesized expressions. The
232 first is expected to match the `To:' that the default scan format
233 file generates. The second is expected to match the recipient's name
234 as in the default of \"\\\\(To:\\\\)\\\\(..............\\\\)\". If this
235 regular expression is not correct, the recipient will not be highlighted.")
237 (defvar mh-scan-body-regexp "\\(<<\\([^\n]+\\)?\\)"
238 "This regular expression matches the message body fragment.
239 Note that the default setting of `mh-folder-font-lock-keywords' expects this
240 expression to contain at least one parenthesized expression which matches the
241 body text as in the default of \"\\\\(<<\\\\([^\\n]+\\\\)?\\\\)\". If this
242 regular expression is not correct, the body fragment will not be highlighted.")
244 (defvar mh-scan-subject-regexp
245 "^ *[0-9]+........[ ]*...................\\([Rr][Ee]\\(\\[[0-9]+\\]\\)?:\\s-*\\)*\\([^<\n]*\\)"
246 "This regular expression matches the subject.
247 It must match from the beginning of the line. Note that the default setting
248 of `mh-folder-font-lock-keywords' expects this expression to contain at least
249 three parenthesized expressions. The first is expected to match the `Re:'
250 string, if any. The second matches an optional bracketed number after `Re:',
251 such as in `Re[2]:' (and is thus a sub-expression of the first expression) and
252 the third is expected to match the subject line itself as in the default of
253 \(broken on multiple lines for readability):
254 ^ *[0-9]+........[ ]*...................
255 \\\\([Rr][Ee]\\\\(\\\\\\=[[0-9]+\\\\]\\\\)?:\\\\s-*\\\\)*
257 This regular expression should be correct as it is needed by non-fontifying
260 (defvar mh-scan-format-regexp
261 (concat "\\([bct]\\)" mh-scan-date-regexp " *\\(..................\\)")
262 "This regular expression matches the output of scan.
263 Note that the default setting of `mh-folder-font-lock-keywords' expects this
264 expression to contain at least three parenthesized expressions. The first
265 should match the fontification hint (see `mh-scan-format-nmh'), the second is
266 found in `mh-scan-date-regexp', and the third should match the user name as in
267 the default of \"(concat \"\\\\([bct]\\\\)\" mh-scan-date-regexp
268 \"*\\\\(..................\\\\)\")\".
269 If this regular expression is not correct, the notation hints and the sender
270 will not be highlighted.")
274 (defvar mh-folder-font-lock-keywords
276 ;; Folders when displaying index buffer
278 '(0 mh-index-folder-face))
279 ;; Marked for deletion
280 (list (concat mh-scan-deleted-msg-regexp ".*")
281 '(0 mh-folder-deleted-face))
283 (list (concat mh-scan-refiled-msg-regexp ".*")
284 '(0 mh-folder-refiled-face))
286 (list mh-scan-body-regexp '(1 mh-folder-body-face nil t))
287 '(mh-folder-font-lock-subject
288 (1 mh-folder-followup-face append t)
289 (2 mh-folder-subject-face append t))
291 (list mh-scan-cur-msg-number-regexp
292 '(1 mh-folder-cur-msg-number-face))
293 (list mh-scan-good-msg-regexp
294 '(1 mh-folder-msg-number-face)) ;; Msg number
295 (list mh-scan-date-regexp '(1 mh-folder-date-face)) ;; Date
296 (list mh-scan-rcpt-regexp
297 '(1 mh-folder-to-face) ;; To:
298 '(2 mh-folder-address-face)) ;; address
299 ;; scan font-lock name
300 (list mh-scan-format-regexp
301 '(1 mh-folder-date-face)
302 '(3 mh-folder-scan-format-face)))
303 "Keywords (regular expressions) used to fontify the MH-Folder buffer.")
305 (defvar mh-scan-cmd-note-width 1
306 "Number of columns consumed by the cmd-note field in `mh-scan-format'.
307 This column will have one of the values: ` ', `D', `^', `+' and where
308 ` ' is the default value,
309 `D' is the `mh-note-deleted' character,
310 `^' is the `mh-note-refiled' character, and
311 `+' is the `mh-note-cur' character.")
313 (defvar mh-scan-destination-width 1
314 "Number of columns consumed by the destination field in `mh-scan-format'.
315 This column will have one of ' ', '%', '-', 't', 'c', 'b', or `n' in it.
316 A ' ' blank space is the default character.
317 A '%' indicates that the message in in a named MH sequence.
318 A '-' indicates that the message has been annotated with a replied field.
319 A 't' indicates that the message contains mymbox in the To: field.
320 A 'c' indicates that the message contains mymbox in the Cc: field.
321 A 'b' indicates that the message contains mymbox in the Bcc: field.
322 A 'n' indicates that the message contains a Newsgroups: field.")
324 (defvar mh-scan-date-width 5
325 "Number of columns consumed by the date field in `mh-scan-format'.
326 This column will typically be of the form mm/dd.")
328 (defvar mh-scan-date-flag-width 1
329 "Number of columns consumed to flag (in)valid dates in `mh-scan-format'.
330 This column will have ` ' for valid and `*' for invalid or missing dates.")
332 (defvar mh-scan-from-mbox-width 17
333 "Number of columns consumed with the \"From:\" line in `mh-scan-format'.
334 This column will have a friendly name or e-mail address of the
335 originator, or a \"To: address\" for outgoing e-mail messages.")
337 (defvar mh-scan-from-mbox-sep-width 2
338 "Number of columns consumed by whitespace after from-mbox in `mh-scan-format'.
339 This column will only ever have spaces in it.")
341 (defvar mh-scan-field-from-start-offset
342 (+ mh-scan-cmd-note-width
343 mh-scan-destination-width
345 mh-scan-date-flag-width)
346 "The offset from the `mh-cmd-note' to find the start of \"From:\" address.")
348 (defvar mh-scan-field-from-end-offset
349 (+ mh-scan-field-from-start-offset mh-scan-from-mbox-width)
350 "The offset from the `mh-cmd-note' to find the end of \"From:\" address.")
352 (defvar mh-scan-field-subject-start-offset
353 (+ mh-scan-cmd-note-width
354 mh-scan-destination-width
356 mh-scan-date-flag-width
357 mh-scan-from-mbox-width
358 mh-scan-from-mbox-sep-width)
359 "The offset from the `mh-cmd-note' to find the start of the subject.")
361 (defun mh-folder-font-lock-subject (limit)
362 "Return MH-E scan subject strings to font-lock between point and LIMIT."
363 (if (not (re-search-forward mh-scan-subject-regexp limit t))
365 (if (match-beginning 1)
366 (set-match-data (list (match-beginning 1) (match-end 3)
367 (match-beginning 1) (match-end 3) nil nil))
368 (set-match-data (list (match-beginning 3) (match-end 3)
369 nil nil (match-beginning 3) (match-end 3))))
374 ;; Fontifify unseen mesages in bold.
376 (defmacro mh-generate-sequence-font-lock (seq prefix face)
377 "Generate the appropriate code to fontify messages in SEQ.
378 PREFIX is used to generate unique names for the variables and functions
379 defined by the macro. So a different prefix should be provided for every
381 FACE is the font-lock face used to display the matching scan lines."
382 (let ((cache (intern (format "mh-folder-%s-seq-cache" prefix)))
383 (func (intern (format "mh-folder-font-lock-%s" prefix))))
386 "Internal cache variable used for font-lock in MH-E.
387 Should only be non-nil through font-lock stepping, and nil once font-lock
388 is done highlighting.")
389 (make-variable-buffer-local ',cache)
392 "Return unseen message lines to font-lock between point and LIMIT."
393 (if (not ,cache) (setq ,cache (mh-seq-msgs (mh-find-seq ,seq))))
394 (let ((cur-msg (mh-get-msg-num nil)))
397 ((>= (point) limit) ;Presumably at end of buffer
400 ((member cur-msg ,cache)
401 (let ((bpoint (progn (beginning-of-line)(point)))
402 (epoint (progn (forward-line 1)(point))))
403 (if (<= limit (point)) (setq ,cache nil))
404 (set-match-data (list bpoint epoint bpoint epoint))
407 ;; move forward one line at a time, checking each message
408 (while (and (= 0 (forward-line 1))
410 (not (member (mh-get-msg-num nil) ,cache))))
411 ;; Examine how we must have exited the loop...
412 (let ((cur-msg (mh-get-msg-num nil)))
413 (cond ((or (<= limit (point))
414 (not (member cur-msg ,cache)))
417 ((member cur-msg ,cache)
418 (let ((bpoint (progn (beginning-of-line) (point)))
419 (epoint (progn (forward-line 1) (point))))
420 (if (<= limit (point)) (setq ,cache nil))
422 (list bpoint epoint bpoint epoint))
425 (setq mh-folder-font-lock-keywords
426 (append mh-folder-font-lock-keywords
427 (list (list ',func (list 1 '',face 'prepend t))))))))
429 (mh-generate-sequence-font-lock mh-unseen-seq unseen bold)
430 (mh-generate-sequence-font-lock mh-tick-seq tick mh-folder-tick)
434 ;;; Internal variables:
436 (defvar mh-last-destination nil) ;Destination of last refile or write
438 (defvar mh-last-destination-folder nil) ;Destination of last refile command.
439 (defvar mh-last-destination-write nil) ;Destination of last write command.
441 (defvar mh-folder-mode-map (make-keymap)
442 "Keymap for MH folders.")
444 (defvar mh-arrow-marker nil) ;Marker for arrow display in fringe.
446 (defvar mh-delete-list nil) ;List of msg numbers to delete.
448 (defvar mh-refile-list nil) ;List of folder names in mh-seq-list.
450 (defvar mh-next-direction 'forward) ;Direction to move to next message.
452 (defvar mh-view-ops ()) ;Stack of ops that change the folder
453 ;view (such as narrowing or threading).
454 (defvar mh-folder-view-stack ()) ;Stack of previous folder views.
456 (defvar mh-index-data nil) ;Info about index search results
457 (defvar mh-index-previous-search nil)
458 (defvar mh-index-msg-checksum-map nil)
459 (defvar mh-index-checksum-origin-map nil)
460 (defvar mh-index-sequence-search-flag nil)
462 (defvar mh-first-msg-num nil) ;Number of first msg in buffer.
464 (defvar mh-last-msg-num nil) ;Number of last msg in buffer.
466 (defvar mh-mode-line-annotation nil) ;Message range displayed in buffer.
468 (defvar mh-sequence-notation-history nil)
469 ;Rememeber original notation that
470 ;is overwritten by `mh-note-seq'.
472 (defvar mh-colors-available-flag nil) ;Are colors available?
474 ;;; Macros and generic functions:
476 (defun mh-mapc (function list)
477 "Apply FUNCTION to each element of LIST for side effects only."
479 (funcall function (car list))
480 (setq list (cdr list))))
482 (defun mh-scan-format ()
483 "Return the output format argument for the scan program."
484 (if (equal mh-scan-format-file t)
485 (list "-format" (if (mh-variant-p 'nmh 'mu-mh)
486 (list (mh-update-scan-format
487 mh-scan-format-nmh mh-cmd-note))
488 (list (mh-update-scan-format
489 mh-scan-format-mh mh-cmd-note))))
490 (if (not (equal mh-scan-format-file nil))
491 (list "-form" mh-scan-format-file))))
498 (defun mh-rmail (&optional arg)
499 "Inc(orporate) new mail with MH.
500 Scan an MH folder if ARG is non-nil. This function is an entry point to MH-E,
501 the Emacs interface to the MH mail system."
505 (call-interactively 'mh-visit-folder)
506 (unless (get-buffer mh-inbox)
507 (mh-visit-folder mh-inbox (symbol-name mh-unseen-seq)))
511 (defun mh-nmail (&optional arg)
512 "Check for new mail in inbox folder.
513 Scan an MH folder if ARG is non-nil. This function is an entry point to MH-E,
514 the Emacs interface to the MH mail system."
516 (mh-find-path) ; init mh-inbox
518 (call-interactively 'mh-visit-folder)
519 (mh-visit-folder mh-inbox)))
523 ;;; User executable MH-E commands:
525 (defun mh-delete-msg (range)
526 "Mark the specified RANGE for subsequent deletion and move to the next.
527 Default is the displayed message.
529 Check the documentation of `mh-interactive-range' to see how RANGE is read in
531 (interactive (list (mh-interactive-range "Delete")))
532 (mh-delete-msg-no-motion range)
533 (if (looking-at mh-scan-deleted-msg-regexp) (mh-next-msg)))
535 (defun mh-delete-msg-no-motion (range)
536 "Mark the specified RANGE for subsequent deletion.
538 Check the documentation of `mh-interactive-range' to see how RANGE is read in
540 (interactive (list (mh-interactive-range "Delete")))
541 (mh-iterate-on-range () range
542 (mh-delete-a-msg nil)))
544 (defun mh-execute-commands ()
545 "Process outstanding delete and refile requests."
547 (if mh-folder-view-stack (mh-widen t))
548 (mh-process-commands mh-current-folder)
550 (mh-goto-cur-msg) ; after mh-set-scan-mode for efficiency
551 (mh-make-folder-mode-line)
552 t) ; return t for write-file-functions
554 (defun mh-first-msg ()
555 "Move to the first message."
557 (goto-char (point-min))
558 (while (and (not (eobp)) (not (looking-at mh-scan-valid-regexp)))
561 (defun mh-header-display ()
562 "Show the current message with all its headers.
563 Displays headers that might have been suppressed by setting the
564 variables `mh-clean-message-header-flag' or `mhl-formfile', or by the fallback
565 behavior of scrolling uninteresting headers off the top of the window.
566 Type \"\\[mh-show]\" to show the message normally again."
568 (and (not mh-showing-with-headers)
569 (or mhl-formfile mh-clean-message-header-flag)
570 (mh-invalidate-show-buffer))
571 (let ((mh-decode-mime-flag nil)
573 (mh-clean-message-header-flag nil))
575 (mh-in-show-buffer (mh-show-buffer)
576 (goto-char (point-min))
578 (setq mh-showing-with-headers t)))
580 (defun mh-inc-folder (&optional maildrop-name folder)
581 "Inc(orporate)s new mail into the Inbox folder.
582 Optional argument MAILDROP-NAME specifies an alternate maildrop from the
583 default. The optional argument FOLDER specifies where to incorporate mail
584 instead of the default named by `mh-inbox'.
585 The value of `mh-inc-folder-hook' is a list of functions to be called, with no
586 arguments, after incorporating new mail.
587 Do not call this function from outside MH-E; use \\[mh-rmail] instead."
588 (interactive (list (if current-prefix-arg
590 (read-file-name "inc mail from file: "
592 (if current-prefix-arg
593 (mh-prompt-for-folder "inc mail into" mh-inbox t))))
595 (setq folder mh-inbox))
596 (let ((threading-needed-flag nil))
597 (let ((config (current-window-configuration)))
598 (when (and mh-show-buffer (get-buffer mh-show-buffer))
599 (delete-windows-on mh-show-buffer))
600 (cond ((not (get-buffer folder))
601 (mh-make-folder folder)
602 (setq threading-needed-flag mh-show-threads-flag)
603 (setq mh-previous-window-config config))
604 ((not (eq (current-buffer) (get-buffer folder)))
605 (switch-to-buffer folder)
606 (setq mh-previous-window-config config))))
607 (mh-get-new-mail maildrop-name)
608 (when (and threading-needed-flag
610 (goto-char (point-min))
611 (or (null mh-large-folder)
612 (not (equal (forward-line (1+ mh-large-folder)) 0))
613 (and (message "Not threading since the number of messages exceeds `mh-large-folder'")
617 (if (and mh-showing-mode (looking-at mh-scan-valid-regexp)) (mh-show))
618 (run-hooks 'mh-inc-folder-hook)))
620 (defun mh-last-msg ()
621 "Move to the last message."
623 (goto-char (point-max))
624 (while (and (not (bobp)) (not (looking-at mh-scan-valid-regexp)))
628 (defun mh-next-undeleted-msg (&optional arg wait-after-complaining-flag)
629 "Move to the next undeleted message ARG in window.
630 If optional argument WAIT-AFTER-COMPLAINING-FLAG is non-nil and we are at the
631 last undeleted message then pause for a second after printing message."
633 (setq mh-next-direction 'forward)
635 (cond ((re-search-forward mh-scan-good-msg-regexp nil t arg)
639 (message "No more undeleted messages")
640 (if wait-after-complaining-flag (sit-for 1)))))
642 (defun mh-folder-from-address ()
643 "Derive folder name from sender.
645 The name of the folder is derived as follows:
647 a) The folder name associated with the first address found in the list
648 `mh-default-folder-list' is used. Each element in this list contains a
649 `Check Recipient' item. If this item is turned on, then the address is
650 checked against the recipient instead of the sender. This is useful for
653 b) An alias prefixed by `mh-default-folder-prefix' corresponding to the
654 address is used. The prefix is used to prevent clutter in your mail
657 Return nil if a folder name was not derived, or if the variable
658 `mh-default-folder-must-exist-flag' is t and the folder does not exist."
659 ;; Loop for all entries in mh-default-folder-list
661 (goto-char (point-min))
662 (re-search-forward "\n\n" nil 'limit)
663 (narrow-to-region (point-min) (point))
664 (let ((to/cc (concat (or (message-fetch-field "to") "") ", "
665 (or (message-fetch-field "cc") "")))
666 (from (or (message-fetch-field "from") ""))
669 (loop for list in mh-default-folder-list
670 when (string-match (nth 0 list) (if (nth 2 list) to/cc from))
674 ;; Make sure a result from `mh-default-folder-list' begins with "+"
675 ;; since 'mh-expand-file-name below depends on it
676 (when (and folder-name (not (eq (aref folder-name 0) ?+)))
677 (setq folder-name (concat "+" folder-name)))
679 ;; If not, is there an alias for the address?
680 (when (not folder-name)
681 (let* ((from-header (mh-extract-from-header-value))
682 (address (and from-header
683 (nth 1 (mail-extract-address-components
685 (alias (and address (mh-alias-address-to-alias address))))
688 (and alias (concat "+" mh-default-folder-prefix alias))))))
690 ;; If mh-default-folder-must-exist-flag set, check that folder exists.
692 (or (not mh-default-folder-must-exist-flag)
693 (file-exists-p (mh-expand-file-name folder-name))))
696 (defun mh-prompt-for-refile-folder ()
697 "Prompt the user for a folder in which the message should be filed.
698 The folder is returned as a string.
700 The default folder name is generated by the option
701 `mh-default-folder-for-message-function' if it is non-nil or
702 `mh-folder-from-address'."
703 (mh-prompt-for-folder
705 (let ((refile-file (ignore-errors (mh-msg-filename (mh-get-msg-num t)))))
706 (if (null refile-file) ""
708 (set-buffer (get-buffer-create mh-temp-buffer))
710 (insert-file-contents refile-file)
711 (or (and mh-default-folder-for-message-function
712 (let ((buffer-file-name refile-file))
713 (funcall mh-default-folder-for-message-function)))
714 (mh-folder-from-address)
715 (and (eq 'refile (car mh-last-destination-folder))
716 (symbol-name (cdr mh-last-destination-folder)))
720 (defun mh-refile-msg (range folder &optional dont-update-last-destination-flag)
721 "Refile RANGE into FOLDER.
723 Check the documentation of `mh-interactive-range' to see how RANGE is read in
726 If optional argument DONT-UPDATE-LAST-DESTINATION-FLAG is non-nil then the
727 variables `mh-last-destination' and `mh-last-destination-folder' are not
729 (interactive (list (mh-interactive-range "Refile")
730 (intern (mh-prompt-for-refile-folder))))
731 (unless dont-update-last-destination-flag
732 (setq mh-last-destination (cons 'refile folder)
733 mh-last-destination-folder mh-last-destination))
734 (mh-iterate-on-range () range
735 (mh-refile-a-msg nil folder))
736 (when (looking-at mh-scan-refiled-msg-regexp) (mh-next-msg)))
738 (defun mh-refile-or-write-again (range &optional interactive-flag)
739 "Re-execute the last refile or write command on the given RANGE.
740 Default is the displayed message. Use the same folder or file as the previous
741 refile or write command.
742 If INTERACTIVE-FLAG is non-nil then the function was called interactively."
743 (interactive (list (mh-interactive-range "Redo") t))
744 (if (null mh-last-destination)
745 (error "No previous refile or write"))
748 (cond ((eq (car mh-last-destination) 'refile)
749 (mh-refile-msg range (cdr mh-last-destination))
750 (format "Destination folder: %s" (cdr mh-last-destination)))
752 (mh-iterate-on-range msg range
753 (apply 'mh-write-msg-to-file msg (cdr mh-last-destination)))
754 (mh-next-msg interactive-flag)
755 (format "Destination: %s" (cdr mh-last-destination)))))
756 (message "%s" output)))
759 "Quit the current MH-E folder.
760 Restore the previous window configuration, if one exists.
761 The value of `mh-before-quit-hook' is a list of functions to be called, with
762 no arguments, immediately upon entry to this function.
763 The value of `mh-quit-hook' is a list of functions to be called, with no
764 arguments, upon exit of this function.
765 MH-E working buffers (whose name begins with \" *mh-\" or \"*MH-E \") are
768 (run-hooks 'mh-before-quit-hook)
769 (let ((show-buffer (get-buffer mh-show-buffer)))
771 (kill-buffer show-buffer)))
772 (mh-update-sequences)
773 (mh-destroy-postponed-handles)
774 (bury-buffer (current-buffer))
776 ;; Delete all MH-E temporary and working buffers.
777 (dolist (buffer (buffer-list))
778 (when (or (string-match "^ \\*mh-" (buffer-name buffer))
779 (string-match "^\\*MH-E " (buffer-name buffer)))
780 (kill-buffer buffer)))
782 (if mh-previous-window-config
783 (set-window-configuration mh-previous-window-config))
784 (run-hooks 'mh-quit-hook))
786 (defun mh-page-msg (&optional arg)
787 "Page the displayed message forwards.
788 Scrolls ARG lines or a full screen if no argument is supplied. Show buffer
789 first if not displayed. Show the next undeleted message if looking at the
790 bottom of the current message."
793 (if mh-page-to-next-msg-flag
794 (if (equal mh-next-direction 'backward)
795 (mh-previous-undeleted-msg)
796 (mh-next-undeleted-msg))
797 (if (mh-in-show-buffer (mh-show-buffer)
798 (pos-visible-in-window-p (point-max)))
801 "End of message (Type %s to read %s undeleted message)"
802 (single-key-description last-input-event)
803 (if (equal mh-next-direction 'backward)
806 (setq mh-page-to-next-msg-flag t))
807 (scroll-other-window arg)))
810 (defun mh-previous-page (&optional arg)
811 "Page the displayed message backwards.
812 Scrolls ARG lines or a full screen if no argument is supplied."
814 (mh-in-show-buffer (mh-show-buffer)
817 (defun mh-previous-undeleted-msg (&optional arg wait-after-complaining-flag)
818 "Move to the previous undeleted message ARG in window.
819 If optional argument WAIT-AFTER-COMPLAINING-FLAG is non-nil and we are at the
820 first undeleted message then pause for a second after printing message."
822 (setq mh-next-direction 'backward)
824 (cond ((re-search-backward mh-scan-good-msg-regexp nil t arg)
826 (t (message "No previous undeleted message")
827 (if wait-after-complaining-flag (sit-for 1)))))
829 (defun mh-previous-unread-msg (&optional count)
830 "Move to previous unread message.
831 With optional argument COUNT, COUNT-1 unread messages before current message
835 (error "The function mh-previous-unread-msg expects positive argument"))
836 (setq count (1- count))
837 (let ((unread-sequence (cdr (assoc mh-unseen-seq mh-seq-list)))
838 (cur-msg (mh-get-msg-num nil)))
839 (cond ((and (not cur-msg) (not (bobp))
840 ;; If we are at the end of the buffer back up one line and go
841 ;; to unread message after that.
844 (setq cur-msg (mh-get-msg-num nil)))
846 ((or (null unread-sequence) (not cur-msg))
847 ;; No unread message or there aren't any messages in buffer...
848 (message "No more unread messages"))
850 ;; Skip count messages...
851 (while (and unread-sequence (>= (car unread-sequence) cur-msg))
852 (setq unread-sequence (cdr unread-sequence)))
854 (setq unread-sequence (cdr unread-sequence))
855 (setq count (1- count)))
856 (not (car unread-sequence)))
857 (message "No more unread messages"))
858 (t (loop for msg in unread-sequence
859 when (mh-goto-msg msg t) return nil
860 finally (message "No more unread messages"))))))
862 (defun mh-goto-next-button (backward-flag &optional criterion)
863 "Search for next button satisfying criterion.
864 If BACKWARD-FLAG is non-nil search backward in the buffer for a mime button. If
865 CRITERION is a function or a symbol which has a function binding then that
866 function must return non-nil at the button we stop."
867 (unless (or (and (symbolp criterion) (fboundp criterion))
868 (functionp criterion))
869 (setq criterion (lambda (x) t)))
870 ;; Move to the next button in the buffer satisfying criterion
871 (goto-char (or (save-excursion
873 ;; Find point before current button
874 (let ((point-before-current-button
876 (while (get-text-property (point) 'mh-data)
877 (unless (= (forward-line
878 (if backward-flag 1 -1))
881 (goto-char (point-min))
882 (goto-char (point-max)))))
884 ;; Skip over current button
885 (while (and (get-text-property (point) 'mh-data)
886 (not (if backward-flag (bobp) (eobp))))
887 (forward-line (if backward-flag -1 1)))
888 ;; Stop at next MIME button if any exists.
891 (unless (= (forward-line
892 (if backward-flag -1 1))
895 (goto-char (point-max))
896 (goto-char (point-min)))
899 point-before-current-button)
900 (when (and (get-text-property (point) 'mh-data)
901 (funcall criterion (point)))
902 (return-from loop (point))))
906 (defun mh-next-button (&optional backward-flag)
907 "Go to the next MIME button.
908 Advance point to the next MIME button in the show buffer. If the end
909 of buffer is reached then the search wraps over to the start of the
910 buffer. With prefix argument, BACKWARD-FLAG the point will move to the
911 previous MIME button."
912 (interactive (list current-prefix-arg))
913 (unless mh-showing-mode
915 (mh-in-show-buffer (mh-show-buffer)
916 (mh-goto-next-button backward-flag)))
918 (defun mh-prev-button ()
919 "Go to the prev MIME button.
920 Move point to the previous MIME button in the show buffer. If the beginning
921 of the buffer is reached then the search wraps over to the end of the
926 (defun mh-folder-mime-action (part-index action include-security-flag)
927 "Go to PART-INDEX and carry out ACTION.
928 If PART-INDEX is nil then go to the next part in the buffer. The search for
929 the next buffer wraps around if end of buffer is reached. If argument
930 INCLUDE-SECURITY-FLAG is non-nil then include security info buttons when
931 searching for a suitable parts."
932 (unless mh-showing-mode
934 (mh-in-show-buffer (mh-show-buffer)
938 (let ((part (get-text-property p 'mh-part)))
939 (and (integerp part) (= part part-index)))))
941 (if include-security-flag
942 (get-text-property p 'mh-data)
943 (integerp (get-text-property p 'mh-part)))))))
945 (cond ((and (get-text-property point 'mh-part)
946 (or (null part-index)
947 (= (get-text-property point 'mh-part) part-index)))
949 ((and (get-text-property point 'mh-data)
950 include-security-flag
954 (mh-goto-next-button nil criterion)
955 (if (= (point) point)
956 (message "No matching MIME part found")
957 (funcall action)))))))
959 (defun mh-folder-toggle-mime-part (part-index)
960 "Toggle display of button.
961 If point in show buffer is at a button then that part is toggled.
962 If not at a button and PART-INDEX is non-nil point is moved to that part.
963 With nil PART-INDEX find the first button after point (search wraps around if
964 end of buffer is reached) and toggle it."
966 (when (consp part-index) (setq part-index (car part-index)))
967 (mh-folder-mime-action part-index #'mh-press-button t))
969 (defun mh-folder-inline-mime-part (part-index)
970 "Show the raw bytes of MIME part inline.
971 If point in show buffer is at a mime part then that part is inlined.
972 If not at a mime-part and PART-INDEX is non-nil point is moved to that part.
973 With nil PART-INDEX find the first button after point (search wraps around if
974 end of buffer is reached) and inline it."
976 (when (consp part-index) (setq part-index (car part-index)))
977 (mh-folder-mime-action part-index #'mh-mime-inline-part nil))
979 (defun mh-folder-save-mime-part (part-index)
981 If point in show buffer is at a mime part then that part is saved.
982 If not at a mime-part and PART-INDEX is non-nil point is moved to that part.
983 With nil PART-INDEX find the first button after point (search wraps around if
984 end of buffer is reached) and save it."
986 (when (consp part-index) (setq part-index (car part-index)))
987 (mh-folder-mime-action part-index #'mh-mime-save-part nil))
989 (defvar mh-thread-scan-line-map-stack)
991 (defun mh-reset-threads-and-narrowing ()
992 "Reset all variables pertaining to threads and narrowing.
993 Also removes all content from the folder buffer."
994 (setq mh-view-ops ())
995 (setq mh-folder-view-stack ())
996 (setq mh-thread-scan-line-map-stack ())
997 (let ((buffer-read-only nil)) (erase-buffer)))
999 (defun mh-rescan-folder (&optional range dont-exec-pending)
1000 "Rescan a folder after optionally processing the outstanding commands.
1001 If optional prefix argument RANGE is provided, prompt for the range of
1002 messages to display. Otherwise show the entire folder.
1003 If optional argument DONT-EXEC-PENDING is non-nil then pending deletes and
1004 refiles aren't carried out."
1005 (interactive (list (if current-prefix-arg
1006 (mh-read-range "Rescan" mh-current-folder t nil t
1007 mh-interpret-number-as-range-flag)
1009 (setq mh-next-direction 'forward)
1010 (let ((threaded-flag (memq 'unthread mh-view-ops)))
1011 (mh-scan-folder mh-current-folder (or range "all") dont-exec-pending)
1012 (cond (threaded-flag (mh-toggle-threads))
1013 (mh-index-data (mh-index-insert-folder-headers)))))
1015 (defun mh-write-msg-to-file (msg file no-headers)
1016 "Append MSG to the end of a FILE.
1017 If prefix argument NO-HEADERS is provided, write only the message body.
1018 Otherwise send the entire message including the headers."
1020 (list (mh-get-msg-num t)
1021 (let ((default-dir (if (eq 'write (car mh-last-destination-write))
1022 (file-name-directory
1023 (car (cdr mh-last-destination-write)))
1024 default-directory)))
1025 (read-file-name (format "Save message%s in file: "
1026 (if current-prefix-arg " body" ""))
1028 (if (eq 'write (car mh-last-destination-write))
1029 (car (cdr mh-last-destination-write))
1030 (expand-file-name "mail.out" default-dir))))
1031 current-prefix-arg))
1032 (let ((msg-file-to-output (mh-msg-filename msg))
1033 (output-file (mh-expand-file-name file)))
1034 (setq mh-last-destination (list 'write file (if no-headers 'no-headers))
1035 mh-last-destination-write mh-last-destination)
1037 (set-buffer (get-buffer-create mh-temp-buffer))
1039 (insert-file-contents msg-file-to-output)
1040 (goto-char (point-min))
1041 (if no-headers (search-forward "\n\n"))
1042 (append-to-file (point) (point-max) output-file))))
1044 (defun mh-toggle-showing ()
1045 "Toggle the scanning mode/showing mode of displaying messages."
1051 (defun mh-undo (range)
1052 "Undo the pending deletion or refile of the specified RANGE.
1054 Check the documentation of `mh-interactive-range' to see how RANGE is read in
1056 (interactive (list (mh-interactive-range "Undo")))
1057 (cond ((numberp range)
1058 (let ((original-position (point)))
1060 (while (not (or (looking-at mh-scan-deleted-msg-regexp)
1061 (looking-at mh-scan-refiled-msg-regexp)
1062 (and (eq mh-next-direction 'forward) (bobp))
1063 (and (eq mh-next-direction 'backward)
1064 (save-excursion (forward-line) (eobp)))))
1065 (forward-line (if (eq mh-next-direction 'forward) -1 1)))
1066 (if (or (looking-at mh-scan-deleted-msg-regexp)
1067 (looking-at mh-scan-refiled-msg-regexp))
1069 (mh-undo-msg (mh-get-msg-num t))
1071 (goto-char original-position)
1072 (error "Nothing to undo"))))
1073 (t (mh-iterate-on-range () range
1074 (mh-undo-msg nil))))
1075 (if (not (mh-outstanding-commands-p))
1076 (mh-set-folder-modified-p nil)))
1079 (defun mh-folder-line-matches-show-buffer-p ()
1080 "Return t if the message under point in folder-mode is in the show buffer.
1081 Return nil in any other circumstance (no message under point, no show buffer,
1082 the message in the show buffer doesn't match."
1083 (and (eq major-mode 'mh-folder-mode)
1084 (mh-get-msg-num nil)
1086 (get-buffer mh-show-buffer)
1087 (buffer-file-name (get-buffer mh-show-buffer))
1088 (string-match ".*/\\([0-9]+\\)$"
1089 (buffer-file-name (get-buffer mh-show-buffer)))
1091 (match-string 1 (buffer-file-name (get-buffer mh-show-buffer)))
1092 (int-to-string (mh-get-msg-num nil)))))
1094 (eval-when-compile (require 'gnus))
1096 (defmacro mh-macro-expansion-time-gnus-version ()
1097 "Return Gnus version available at macro expansion time.
1098 The macro evaluates the Gnus version at macro expansion time. If MH-E was
1099 compiled then macro expansion happens at compile time."
1102 (defun mh-run-time-gnus-version ()
1103 "Return Gnus version available at run time."
1108 (defun mh-version ()
1109 "Display version information about MH-E and the MH mail handling system."
1111 (set-buffer (get-buffer-create mh-info-buffer))
1114 (insert "MH-E " mh-version "\n\n")
1115 ;; MH-E compilation details.
1116 (insert "MH-E compilation details:\n")
1117 (let* ((compiled-mhe (byte-code-function-p (symbol-function 'mh-version)))
1118 (gnus-compiled-version (if compiled-mhe
1119 (mh-macro-expansion-time-gnus-version)
1121 (insert " Byte compiled:\t\t" (if compiled-mhe "yes" "no") "\n"
1122 " Gnus (compile-time):\t" gnus-compiled-version "\n"
1123 " Gnus (run-time):\t" (mh-run-time-gnus-version) "\n\n"))
1125 (insert (emacs-version) "\n\n")
1127 (if mh-variant-in-use
1128 (insert mh-variant-in-use "\n"
1129 " mh-progs:\t" mh-progs "\n"
1130 " mh-lib:\t" mh-lib "\n"
1131 " mh-lib-progs:\t" mh-lib-progs "\n\n")
1132 (insert "No MH variant detected\n"))
1135 (call-process "uname" nil t nil "-a")
1137 (goto-char (point-min))
1138 (display-buffer mh-info-buffer))
1140 (defun mh-parse-flist-output-line (line &optional current-folder)
1141 "Parse LINE to generate folder name, unseen messages and total messages.
1142 If CURRENT-FOLDER is non-nil then it contains the current folder name and it is
1143 used to avoid problems in corner cases involving folders whose names end with a
1147 (goto-char (point-max))
1148 (let (folder unseen total p)
1149 (when (search-backward " out of " (point-min) t)
1150 (setq total (read-from-string
1151 (buffer-substring-no-properties
1152 (match-end 0) (line-end-position))))
1153 (when (search-backward " in sequence " (point-min) t)
1155 (when (search-backward " has " (point-min) t)
1156 (setq unseen (read-from-string (buffer-substring-no-properties
1158 (while (eq (char-after) ? )
1160 (setq folder (buffer-substring-no-properties
1161 (point-min) (1+ (point))))
1162 (when (and (equal (aref folder (1- (length folder))) ?+)
1163 (equal current-folder folder))
1164 (setq folder (substring folder 0 (1- (length folder)))))
1165 (values (format "+%s" folder) (car unseen) (car total))))))))
1167 (defun mh-folder-size-folder (folder)
1168 "Find size of FOLDER using `folder'."
1170 (let ((u (length (cdr (assoc mh-unseen-seq
1171 (mh-read-folder-sequences folder nil))))))
1172 (call-process (expand-file-name "folder" mh-progs) nil t nil
1173 "-norecurse" folder)
1174 (goto-char (point-min))
1175 (if (re-search-forward " has \\([0-9]+\\) " nil t)
1176 (values (car (read-from-string (match-string 1))) u folder)
1177 (values 0 u folder)))))
1179 (defun mh-folder-size-flist (folder)
1180 "Find size of FOLDER using `flist'."
1182 (call-process (expand-file-name "flist" mh-progs) nil t nil "-showzero"
1183 "-norecurse" folder "-sequence" (symbol-name mh-unseen-seq))
1184 (goto-char (point-min))
1185 (multiple-value-bind (folder unseen total)
1186 (mh-parse-flist-output-line
1187 (buffer-substring (point) (line-end-position)))
1188 (values total unseen folder))))
1190 (defun mh-folder-size (folder)
1191 "Find size of FOLDER."
1192 (if mh-flists-present-flag
1193 (mh-folder-size-flist folder)
1194 (mh-folder-size-folder folder)))
1196 (defun mh-visit-folder (folder &optional range index-data)
1197 "Visit FOLDER and display RANGE of messages.
1198 Do not call this function from outside MH-E; see \\[mh-rmail] instead.
1200 If RANGE is nil (the default if it is omitted when called non-interactively),
1201 then all messages in FOLDER are displayed.
1203 If an index buffer is being created then INDEX-DATA is used to initialize the
1204 index buffer specific data structures.
1206 A prefix argument will cause a prompt for the RANGE of messages
1207 regardless of the size of the `mh-large-folder' variable."
1208 (interactive (let ((folder-name (mh-prompt-for-folder "Visit" mh-inbox t)))
1210 (mh-read-range "Scan" folder-name t nil
1212 mh-interpret-number-as-range-flag))))
1213 (let ((config (current-window-configuration))
1214 (current-buffer (current-buffer))
1215 (threaded-view-flag mh-show-threads-flag))
1216 (delete-other-windows)
1218 (when (get-buffer folder)
1220 (setq threaded-view-flag (memq 'unthread mh-view-ops))))
1222 (mh-make-folder folder)
1223 (setq mh-index-data (car index-data)
1224 mh-index-msg-checksum-map (make-hash-table :test #'equal)
1225 mh-index-checksum-origin-map (make-hash-table :test #'equal))
1226 (mh-index-update-maps folder (cadr index-data))
1227 (mh-index-create-sequences))
1228 (mh-scan-folder folder (or range "all"))
1229 (cond ((and threaded-view-flag
1231 (goto-char (point-min))
1232 (or (null mh-large-folder)
1233 (not (equal (forward-line (1+ mh-large-folder)) 0))
1234 (and (message "Not threading since the number of messages exceeds `mh-large-folder'")
1236 (mh-toggle-threads))
1238 (mh-index-insert-folder-headers)))
1239 (unless (eq current-buffer (current-buffer))
1240 (setq mh-previous-window-config config)))
1244 (defun mh-update-sequences ()
1245 "Update MH's Unseen-Sequence and current folder and message.
1246 Flush MH-E's state out to MH. The message at the cursor becomes current."
1248 ;; mh-update-sequences is the opposite of mh-read-folder-sequences,
1249 ;; which updates MH-E's state from MH.
1250 (let ((folder-set (mh-update-unseen))
1251 (new-cur (mh-get-msg-num nil)))
1253 (let ((seq-entry (mh-find-seq 'cur)))
1254 (mh-remove-cur-notation)
1256 (list new-cur)) ;delete-seq-locally, add-msgs-to-seq
1257 (mh-define-sequence 'cur (list new-cur))
1259 (if (looking-at mh-scan-good-msg-regexp)
1263 ;; psg - mh-current-folder is nil if mh-summary-height < 4 !
1264 ;; So I added this sanity check.
1265 (if (stringp mh-current-folder)
1266 (mh-exec-cmd-quiet t "folder" mh-current-folder "-fast")
1267 (mh-exec-cmd-quiet t "folder" "-fast")))))))
1271 ;;; Support routines.
1273 (defun mh-delete-a-msg (msg)
1275 If MSG is nil then the message at point is deleted.
1277 The value of `mh-delete-msg-hook' is a list of functions to be called, with no
1278 arguments, after the message has been deleted."
1281 (mh-goto-msg msg nil t)
1283 (setq msg (mh-get-msg-num t)))
1284 (if (looking-at mh-scan-refiled-msg-regexp)
1285 (error "Message %d is refiled. Undo refile before deleting" msg))
1286 (if (looking-at mh-scan-deleted-msg-regexp)
1288 (mh-set-folder-modified-p t)
1289 (setq mh-delete-list (cons msg mh-delete-list))
1290 (mh-notate nil mh-note-deleted mh-cmd-note)
1291 (run-hooks 'mh-delete-msg-hook))))
1293 (defun mh-refile-a-msg (msg folder)
1294 "Refile MSG in FOLDER.
1295 If MSG is nil then the message at point is refiled.
1297 Folder is a symbol, not a string.
1298 The value of `mh-refile-msg-hook' is a list of functions to be called, with no
1299 arguments, after the message has been refiled."
1302 (mh-goto-msg msg nil t)
1304 (setq msg (mh-get-msg-num t)))
1305 (cond ((looking-at mh-scan-deleted-msg-regexp)
1306 (error "Message %d is deleted. Undo delete before moving" msg))
1307 ((looking-at mh-scan-refiled-msg-regexp)
1309 (format "Message %d already refiled. Copy to %s as well? "
1311 (mh-exec-cmd "refile" (mh-get-msg-num t) "-link"
1312 "-src" mh-current-folder
1313 (symbol-name folder))
1314 (message "Message not copied")))
1316 (mh-set-folder-modified-p t)
1317 (cond ((null (assoc folder mh-refile-list))
1318 (push (list folder msg) mh-refile-list))
1319 ((not (member msg (cdr (assoc folder mh-refile-list))))
1320 (push msg (cdr (assoc folder mh-refile-list)))))
1321 (mh-notate nil mh-note-refiled mh-cmd-note)
1322 (run-hooks 'mh-refile-msg-hook)))))
1324 (defun mh-next-msg (&optional wait-after-complaining-flag)
1325 "Move backward or forward to the next undeleted message in the buffer.
1326 If optional argument WAIT-AFTER-COMPLAINING-FLAG is non-nil and we are at the
1327 last message, then wait for a second after telling the user that there aren't
1328 any more unread messages."
1329 (if (eq mh-next-direction 'forward)
1330 (mh-next-undeleted-msg 1 wait-after-complaining-flag)
1331 (mh-previous-undeleted-msg 1 wait-after-complaining-flag)))
1333 (defun mh-next-unread-msg (&optional count)
1334 "Move to next unread message.
1335 With optional argument COUNT, COUNT-1 unread messages are skipped."
1338 (error "The function mh-next-unread-msg expects positive argument"))
1339 (setq count (1- count))
1340 (let ((unread-sequence (reverse (cdr (assoc mh-unseen-seq mh-seq-list))))
1341 (cur-msg (mh-get-msg-num nil)))
1342 (cond ((and (not cur-msg) (not (bobp))
1343 ;; If we are at the end of the buffer back up one line and go
1344 ;; to unread message after that.
1347 (setq cur-msg (mh-get-msg-num nil)))
1349 ((or (null unread-sequence) (not cur-msg))
1350 ;; No unread message or there aren't any messages in buffer...
1351 (message "No more unread messages"))
1354 (while (and unread-sequence (>= cur-msg (car unread-sequence)))
1355 (setq unread-sequence (cdr unread-sequence)))
1357 (setq unread-sequence (cdr unread-sequence))
1358 (setq count (1- count)))
1359 (not (car unread-sequence)))
1360 (message "No more unread messages"))
1361 (t (loop for msg in unread-sequence
1362 when (mh-goto-msg msg t) return nil
1363 finally (message "No more unread messages"))))))
1365 (defun mh-set-scan-mode ()
1366 "Display the scan listing buffer, but do not show a message."
1367 (if (get-buffer mh-show-buffer)
1368 (delete-windows-on mh-show-buffer))
1370 (force-mode-line-update)
1371 (if mh-recenter-summary-flag
1374 (defun mh-undo-msg (msg)
1375 "Undo the deletion or refile of one MSG.
1376 If MSG is nil then act on the message at point"
1379 (mh-goto-msg msg t t)
1381 (setq msg (mh-get-msg-num t)))
1382 (cond ((memq msg mh-delete-list)
1383 (setq mh-delete-list (delq msg mh-delete-list)))
1385 (dolist (folder-msg-list mh-refile-list)
1386 (setf (cdr folder-msg-list) (remove msg (cdr folder-msg-list))))
1387 (setq mh-refile-list (loop for x in mh-refile-list
1388 unless (null (cdr x)) collect x))))
1389 (mh-notate nil ? mh-cmd-note)))
1393 ;;; The folder data abstraction.
1395 (defvar mh-index-data-file ".mhe_index"
1396 "MH-E specific file where index seach info is stored.")
1398 (defun mh-make-folder (name)
1399 "Create a new mail folder called NAME.
1400 Make it the current folder."
1401 (switch-to-buffer name)
1402 (setq buffer-read-only nil)
1404 (if mh-adaptive-cmd-note-flag
1405 (mh-set-cmd-note (mh-message-number-width name)))
1406 (setq buffer-read-only t)
1408 (mh-set-folder-modified-p nil)
1409 (setq buffer-file-name mh-folder-filename)
1410 (when (and (not mh-index-data)
1411 (file-exists-p (concat buffer-file-name mh-index-data-file)))
1412 (mh-index-read-data))
1413 (mh-make-folder-mode-line))
1415 ;;; Ensure new buffers won't get this mode if default-major-mode is nil.
1416 (put 'mh-folder-mode 'mode-class 'special)
1420 ;;; Menu extracted from mh-menubar.el V1.1 (31 July 2001)
1421 ;;; Menus for folder mode: folder, message, sequence (in that order)
1422 ;;; folder-mode "Sequence" menu
1424 mh-folder-sequence-menu mh-folder-mode-map "Menu for MH-E folder-sequence."
1426 ["Add Message to Sequence..." mh-put-msg-in-seq (mh-get-msg-num nil)]
1427 ["List Sequences for Message" mh-msg-is-in-seq (mh-get-msg-num nil)]
1428 ["Delete Message from Sequence..." mh-delete-msg-from-seq
1429 (mh-get-msg-num nil)]
1430 ["List Sequences in Folder..." mh-list-sequences t]
1431 ["Delete Sequence..." mh-delete-seq t]
1432 ["Narrow to Sequence..." mh-narrow-to-seq t]
1433 ["Widen from Sequence" mh-widen mh-folder-view-stack]
1435 ["Narrow to Subject Sequence" mh-narrow-to-subject t]
1436 ["Narrow to Tick Sequence" mh-narrow-to-tick
1437 (and mh-tick-seq (mh-seq-msgs (mh-find-seq mh-tick-seq)))]
1438 ["Delete Rest of Same Subject" mh-delete-subject t]
1439 ["Toggle Tick Mark" mh-toggle-tick t]
1441 ["Push State Out to MH" mh-update-sequences t]))
1443 ;;; folder-mode "Message" menu
1445 mh-folder-message-menu mh-folder-mode-map "Menu for MH-E folder-message."
1447 ["Show Message" mh-show (mh-get-msg-num nil)]
1448 ["Show Message with Header" mh-header-display (mh-get-msg-num nil)]
1449 ["Next Message" mh-next-undeleted-msg t]
1450 ["Previous Message" mh-previous-undeleted-msg t]
1451 ["Go to First Message" mh-first-msg t]
1452 ["Go to Last Message" mh-last-msg t]
1453 ["Go to Message by Number..." mh-goto-msg t]
1454 ["Modify Message" mh-modify t]
1455 ["Delete Message" mh-delete-msg (mh-get-msg-num nil)]
1456 ["Refile Message" mh-refile-msg (mh-get-msg-num nil)]
1457 ["Undo Delete/Refile" mh-undo (mh-outstanding-commands-p)]
1458 ["Execute Delete/Refile" mh-execute-commands
1459 (mh-outstanding-commands-p)]
1461 ["Compose a New Message" mh-send t]
1462 ["Reply to Message..." mh-reply (mh-get-msg-num nil)]
1463 ["Forward Message..." mh-forward (mh-get-msg-num nil)]
1464 ["Redistribute Message..." mh-redistribute (mh-get-msg-num nil)]
1465 ["Edit Message Again" mh-edit-again (mh-get-msg-num nil)]
1466 ["Re-edit a Bounced Message" mh-extract-rejected-mail t]
1468 ["Copy Message to Folder..." mh-copy-msg (mh-get-msg-num nil)]
1469 ["Print Message" mh-print-msg (mh-get-msg-num nil)]
1470 ["Write Message to File..." mh-write-msg-to-file
1471 (mh-get-msg-num nil)]
1472 ["Pipe Message to Command..." mh-pipe-msg (mh-get-msg-num nil)]
1473 ["Unpack Uuencoded Message..." mh-store-msg (mh-get-msg-num nil)]
1474 ["Burst Digest Message" mh-burst-digest (mh-get-msg-num nil)]))
1476 ;;; folder-mode "Folder" menu
1478 mh-folder-folder-menu mh-folder-mode-map "Menu for MH-E folder."
1480 ["Incorporate New Mail" mh-inc-folder t]
1481 ["Toggle Show/Folder" mh-toggle-showing t]
1482 ["Execute Delete/Refile" mh-execute-commands
1483 (mh-outstanding-commands-p)]
1484 ["Rescan Folder" mh-rescan-folder t]
1485 ["Thread Folder" mh-toggle-threads
1486 (not (memq 'unthread mh-view-ops))]
1487 ["Pack Folder" mh-pack-folder t]
1488 ["Sort Folder" mh-sort-folder t]
1490 ["List Folders" mh-list-folders t]
1491 ["Visit a Folder..." mh-visit-folder t]
1492 ["View New Messages" mh-index-new-messages t]
1493 ["Search a Folder..." mh-search-folder t]
1494 ["Indexed Search..." mh-index-search t]
1496 ["Quit MH-E" mh-quit t]))
1500 (defmacro mh-remove-xemacs-horizontal-scrollbar ()
1501 "Get rid of the horizontal scrollbar that XEmacs insists on putting in."
1502 (when mh-xemacs-flag
1503 `(if (and (featurep 'scrollbar)
1504 (fboundp 'set-specifier))
1505 (set-specifier horizontal-scrollbar-visible-p nil
1506 (cons (current-buffer) nil)))))
1508 (defmacro mh-write-file-functions-compat ()
1509 "Return `write-file-functions' if it exists.
1510 Otherwise return `local-write-file-hooks'. This macro exists purely for
1511 compatibility. The former symbol is used in Emacs 21.4 onward while the latter
1512 is used in previous versions and XEmacs."
1513 (if (boundp 'write-file-functions)
1514 ''write-file-functions ;Emacs 21.4
1515 ''local-write-file-hooks)) ;<Emacs 21.4, XEmacs
1517 ;; Avoid compiler warnings in non-bleeding edge versions of Emacs.
1519 (defvar tool-bar-mode)
1520 (defvar tool-bar-map)
1521 (defvar desktop-save-buffer)) ;Emacs 21.4
1523 ;; Register mh-folder-mode as supporting which-function-mode...
1524 (load "which-func" t t)
1525 (when (and (boundp 'which-func-modes)
1526 (not (member 'mh-folder-mode which-func-modes)))
1527 (push 'mh-folder-mode which-func-modes))
1529 (defvar mh-folder-buttons-init-flag nil)
1531 ;; Autoload cookie needed by desktop.el
1533 (define-derived-mode mh-folder-mode fundamental-mode "MH-Folder"
1534 "Major MH-E mode for \"editing\" an MH folder scan listing.\\<mh-folder-mode-map>
1536 You can show the message the cursor is pointing to, and step through the
1537 messages. Messages can be marked for deletion or refiling into another
1538 folder; these commands are executed all at once with a separate command.
1540 Options that control this mode can be changed with \\[customize-group];
1541 specify the \"mh\" group. In particular, please see the `mh-scan-format-file'
1542 option if you wish to modify scan's format.
1544 When a folder is visited, the hook `mh-folder-mode-hook' is run.
1548 Many commands that operate on individual messages, such as `mh-forward' or
1549 `mh-refile-msg' take a RANGE argument. This argument can be used in several
1552 If you provide the prefix argument (\\[universal-argument]) to these commands,
1553 then you will be prompted for the message range. This can be any valid MH
1554 range which can include messages, sequences, and the abbreviations (described
1555 in the mh(1) man page):
1558 Indicates all messages in the range <num1> to <num2>, inclusive. The range
1564 Up to N messages beginning with (or ending with) message num. Num may be
1565 any of the pre-defined symbols: first, prev, cur, next or last.
1571 The first, previous, next or last messages, if they exist.
1574 All of the messages.
1576 For example, a range that shows all of these things is `1 2 3 5-10 last:5
1579 If the option `transient-mark-mode' is set to t and you set a region in the
1580 MH-Folder buffer, then the MH-E command will perform the operation on all
1581 messages in that region.
1583 \\{mh-folder-mode-map}"
1585 (unless mh-folder-buttons-init-flag
1586 (mh-tool-bar-folder-buttons-init)
1587 (setq mh-folder-buttons-init-flag t)))
1588 (make-local-variable 'font-lock-defaults)
1589 (setq font-lock-defaults '(mh-folder-font-lock-keywords t))
1590 (make-local-variable 'desktop-save-buffer)
1591 (setq desktop-save-buffer t)
1593 'mh-colors-available-flag (mh-colors-available-p)
1594 ; Do we have colors available
1595 'mh-current-folder (buffer-name) ; Name of folder, a string
1596 'mh-show-buffer (format "show-%s" (buffer-name)) ; Buffer that displays msgs
1597 'mh-folder-filename ; e.g. "/usr/foobar/Mail/inbox/"
1598 (file-name-as-directory (mh-expand-file-name (buffer-name)))
1599 'mh-display-buttons-for-inline-parts-flag
1600 mh-display-buttons-for-inline-parts-flag ; Allow for display of buttons to
1602 'mh-arrow-marker (make-marker) ; Marker where arrow is displayed
1603 'overlay-arrow-position nil ; Allow for simultaneous display in
1604 'overlay-arrow-string ">" ; different MH-E buffers.
1605 'mh-showing-mode nil ; Show message also?
1606 'mh-delete-list nil ; List of msgs nums to delete
1607 'mh-refile-list nil ; List of folder names in mh-seq-list
1608 'mh-seq-list nil ; Alist of (seq . msgs) nums
1609 'mh-seen-list nil ; List of displayed messages
1610 'mh-next-direction 'forward ; Direction to move to next message
1611 'mh-view-ops () ; Stack that keeps track of the order
1612 ; in which narrowing/threading has been
1614 'mh-folder-view-stack () ; Stack of previous views of the
1616 'mh-index-data nil ; If the folder was created by a call
1617 ; to mh-index-search this contains info
1618 ; about the search results.
1619 'mh-index-previous-search nil ; Previous folder and search-regexp
1620 'mh-index-msg-checksum-map nil ; msg -> checksum map
1621 'mh-index-checksum-origin-map nil ; checksum -> ( orig-folder, orig-msg )
1622 'mh-index-sequence-search-flag nil ; folder resulted from sequence search
1623 'mh-first-msg-num nil ; Number of first msg in buffer
1624 'mh-last-msg-num nil ; Number of last msg in buffer
1625 'mh-msg-count nil ; Number of msgs in buffer
1626 'mh-mode-line-annotation nil ; Indicates message range
1627 'mh-sequence-notation-history (make-hash-table)
1628 ; Remember what is overwritten by
1630 'imenu-create-index-function 'mh-index-create-imenu-index
1631 ; Setup imenu support
1632 'mh-previous-window-config nil) ; Previous window configuration
1633 (mh-remove-xemacs-horizontal-scrollbar)
1634 (setq truncate-lines t)
1636 (setq buffer-offer-save t)
1637 (mh-make-local-hook (mh-write-file-functions-compat))
1638 (add-hook (mh-write-file-functions-compat) 'mh-execute-commands nil t)
1639 (make-local-variable 'revert-buffer-function)
1640 (make-local-variable 'hl-line-mode) ; avoid pollution
1641 (mh-funcall-if-exists hl-line-mode 1)
1642 (setq revert-buffer-function 'mh-undo-folder)
1643 (or (assq 'mh-showing-mode minor-mode-alist)
1644 (setq minor-mode-alist
1645 (cons '(mh-showing-mode " Show") minor-mode-alist)))
1646 (easy-menu-add mh-folder-sequence-menu)
1647 (easy-menu-add mh-folder-message-menu)
1648 (easy-menu-add mh-folder-folder-menu)
1649 (set (make-local-variable 'tool-bar-map) mh-folder-tool-bar-map)
1650 (mh-funcall-if-exists mh-toolbar-init :folder)
1651 (if (and mh-xemacs-flag
1652 font-lock-auto-fontify)
1653 (turn-on-font-lock))) ; Force font-lock in XEmacs.
1655 (defun mh-toggle-mime-buttons ()
1656 "Toggle display of buttons for inline MIME parts."
1658 (setq mh-display-buttons-for-inline-parts-flag
1659 (not mh-display-buttons-for-inline-parts-flag))
1662 (defun mh-colors-available-p ()
1663 "Check if colors are available in the Emacs being used."
1666 (or (ignore-errors (mh-funcall-if-exists display-color-cells))
1667 (ignore-errors (mh-funcall-if-exists
1668 x-display-color-cells)))))
1669 (and (numberp color-cells) (>= color-cells 8)))))
1671 (defun mh-colors-in-use-p ()
1672 "Check if colors are being used in the folder buffer."
1673 (and mh-colors-available-flag font-lock-mode))
1675 (defun mh-make-local-vars (&rest pairs)
1676 "Initialize local variables according to the variable-value PAIRS."
1679 (set (make-local-variable (car pairs)) (car (cdr pairs)))
1680 (setq pairs (cdr (cdr pairs)))))
1682 (defun mh-restore-desktop-buffer (desktop-buffer-file-name
1684 desktop-buffer-misc)
1685 "Restore an MH folder buffer specified in a desktop file.
1686 When desktop creates a buffer, DESKTOP-BUFFER-FILE-NAME holds the file name to
1687 visit, DESKTOP-BUFFER-NAME holds the desired buffer name, and
1688 DESKTOP-BUFFER-MISC holds a list of miscellaneous info used by the
1689 `desktop-buffer-handlers' functions."
1691 (mh-visit-folder desktop-buffer-name)
1694 ;;; desktop-buffer-mode-handlers appeared in Emacs 22.
1695 (if (fboundp 'desktop-buffer-mode-handlers)
1696 (add-to-list 'desktop-buffer-mode-handlers
1697 '(mh-folder-mode . mh-restore-desktop-buffer)))
1699 (defun mh-scan-folder (folder range &optional dont-exec-pending)
1700 "Scan the FOLDER over the RANGE.
1701 If the optional argument DONT-EXEC-PENDING is non-nil then pending deletes and
1702 refiles aren't carried out.
1703 Return in the folder's buffer."
1704 (when (stringp range)
1705 (setq range (delete "" (split-string range "[ \t\n]"))))
1706 (cond ((null (get-buffer folder))
1707 (mh-make-folder folder))
1709 (unless dont-exec-pending
1710 (mh-process-or-undo-commands folder)
1711 (mh-reset-threads-and-narrowing))
1712 (switch-to-buffer folder)))
1713 (mh-regenerate-headers range)
1714 (if (zerop (buffer-size))
1715 (if (equal range "all")
1716 (message "Folder %s is empty" folder)
1717 (message "No messages in %s, range %s" folder range))
1719 (when (mh-outstanding-commands-p)
1720 (mh-notate-deleted-and-refiled)))
1722 (defun mh-set-cmd-note (width)
1723 "Set `mh-cmd-note' to WIDTH (minimum of 2).
1725 If `mh-scan-format-file' is set to \"Use Default scan Format\" or \"Specify a
1726 scan Format File\", then this function will NOT update `mh-cmd-note'. In these
1727 cases, the user should change `mh-cmd-note' with `setq' if necessary.
1729 Note that columns in Emacs start with 0."
1730 ;; Add one to the width to always have whitespace in column zero.
1731 (setq width (max (1+ width) 2))
1732 (if (and (equal mh-scan-format-file t)
1733 (not (eq mh-cmd-note width)))
1734 (setq mh-cmd-note width))
1737 (defun mh-regenerate-headers (range &optional update)
1738 "Scan folder over range RANGE.
1739 If UPDATE, append the scan lines, otherwise replace."
1740 (let ((folder mh-current-folder)
1741 (range (if (and range (atom range)) (list range) range))
1743 (message "Scanning %s..." folder)
1744 (mh-remove-all-notation)
1745 (with-mh-folder-updating (nil)
1747 (goto-char (point-max))
1748 (delete-region (point-min) (point-max))
1749 (if mh-adaptive-cmd-note-flag
1750 (mh-set-cmd-note (mh-message-number-width folder))))
1751 (setq scan-start (point))
1752 (apply #'mh-exec-cmd-output
1755 "-noclear" "-noheader"
1756 "-width" (window-width)
1758 (goto-char scan-start)
1759 (cond ((looking-at "scan: no messages in")
1760 (keep-lines mh-scan-valid-regexp)) ; Flush random scan lines
1761 ((looking-at (if (mh-variant-p 'mu-mh)
1762 "scan: message set .* does not exist"
1763 "scan: bad message list "))
1764 (keep-lines mh-scan-valid-regexp))
1765 ((looking-at "scan: ")) ; Keep error messages
1767 (keep-lines mh-scan-valid-regexp))) ; Flush random scan lines
1768 (setq mh-seq-list (mh-read-folder-sequences folder nil))
1769 (mh-notate-user-sequences)
1771 (setq mh-mode-line-annotation
1772 (if (equal range '("all"))
1774 mh-partial-folder-mode-line-annotation)))
1775 (mh-make-folder-mode-line))
1776 (message "Scanning %s...done" folder)))
1778 (defun mh-generate-new-cmd-note (folder)
1779 "Fix the `mh-cmd-note' value for this FOLDER.
1781 After doing an `mh-get-new-mail' operation in this FOLDER, at least
1782 one line that looks like a truncated message number was found.
1784 Remove the text added by the last `mh-inc' command. It should be the
1785 messages cur-last. Call `mh-set-cmd-note' with the widest message number
1788 Reformat the message number width on each line in the buffer and trim
1789 the line length to fit in the window.
1791 Rescan the FOLDER in the range cur-last in order to display the
1792 messages that were removed earlier. They should all fit in the scan
1793 line now with no message truncation."
1795 (let ((maxcol (1- (window-width)))
1796 (old-cmd-note mh-cmd-note)
1799 ;; Nuke all of the lines just added by the last inc
1800 (delete-char (- (point-max) (point)))
1801 ;; Update the current buffer to reflect the new mh-cmd-note
1802 ;; value needed to display messages.
1803 (mh-set-cmd-note (mh-message-number-width folder))
1804 (setq mh-cmd-note-fmt (concat "%" (format "%d" mh-cmd-note) "d"))
1805 ;; Cleanup the messages that are in the buffer right now
1806 (goto-char (point-min))
1807 (cond ((memq 'unthread mh-view-ops)
1808 (mh-thread-add-spaces (- mh-cmd-note old-cmd-note)))
1809 (t (while (re-search-forward mh-scan-msg-number-regexp nil 0 1)
1810 ;; reformat the number to fix in mh-cmd-note columns
1811 (setq msgnum (string-to-number
1813 (match-beginning 1) (match-end 1))))
1814 (replace-match (format mh-cmd-note-fmt msgnum))
1815 ;; trim the line to fix in the window
1817 (let ((eol (point)))
1818 (move-to-column maxcol)
1819 (if (<= (point) eol)
1820 (delete-char (- eol (point))))))))
1821 ;; now re-read the lost messages
1822 (goto-char (point-max))
1824 (mh-regenerate-headers "cur-last" t)))))
1826 (defun mh-get-new-mail (maildrop-name)
1827 "Read new mail from MAILDROP-NAME into the current buffer.
1828 Return in the current buffer."
1829 (let ((point-before-inc (point))
1830 (folder mh-current-folder)
1831 (new-mail-flag nil))
1832 (with-mh-folder-updating (t)
1834 (message "inc %s -file %s..." folder maildrop-name)
1835 (message "inc %s..." folder))
1836 (setq mh-next-direction 'forward)
1837 (goto-char (point-max))
1838 (mh-remove-cur-notation)
1839 (let ((start-of-inc (point)))
1841 ;; I think MH 5 used "-ms-file" instead of "-file",
1842 ;; which would make inc'ing from maildrops fail.
1843 (mh-exec-cmd-output mh-inc-prog nil folder
1845 "-file" (expand-file-name maildrop-name)
1846 "-width" (window-width)
1848 (mh-exec-cmd-output mh-inc-prog nil
1850 "-width" (window-width)))
1852 (message "inc %s -file %s...done" folder maildrop-name)
1853 (message "inc %s...done" folder))
1854 (goto-char start-of-inc)
1855 (cond ((save-excursion
1856 (re-search-forward "^inc: no mail" nil t))
1857 (message "No new mail%s%s" (if maildrop-name " in " "")
1858 (if maildrop-name maildrop-name "")))
1859 ((and (when mh-folder-view-stack
1860 (let ((saved-text (buffer-substring-no-properties
1861 start-of-inc (point-max))))
1862 (delete-region start-of-inc (point-max))
1863 (unwind-protect (mh-widen t)
1864 (mh-remove-cur-notation)
1865 (goto-char (point-max))
1866 (setq start-of-inc (point))
1868 (goto-char start-of-inc))))
1870 ((re-search-forward "^inc:" nil t) ; Error messages
1871 (error "Error incorporating mail"))
1873 (equal mh-scan-format-file t)
1874 mh-adaptive-cmd-note-flag
1875 ;; Have we reached an edge condition?
1877 (re-search-forward mh-scan-msg-overflow-regexp nil 0 1))
1878 (setq start-of-inc (mh-generate-new-cmd-note folder))
1881 (setq new-mail-flag t)))
1882 (keep-lines mh-scan-valid-regexp) ; Flush random scan lines
1883 (let* ((sequences (mh-read-folder-sequences folder t))
1884 (new-cur (assoc 'cur sequences))
1885 (new-unseen (assoc mh-unseen-seq sequences)))
1886 (unless (assoc 'cur mh-seq-list)
1887 (push (list 'cur) mh-seq-list))
1888 (unless (assoc mh-unseen-seq mh-seq-list)
1889 (push (list mh-unseen-seq) mh-seq-list))
1890 (setcdr (assoc 'cur mh-seq-list) (cdr new-cur))
1891 (setcdr (assoc mh-unseen-seq mh-seq-list) (cdr new-unseen)))
1892 (when (equal (point-max) start-of-inc)
1896 (mh-make-folder-mode-line)
1897 (when (mh-speed-flists-active-p)
1898 (mh-speed-flists t mh-current-folder))
1899 (when (memq 'unthread mh-view-ops)
1900 (mh-thread-inc folder start-of-inc))
1902 (goto-char point-before-inc))
1903 (mh-notate-user-sequences (cons start-of-inc (point-max)))))))
1905 (defun mh-make-folder-mode-line (&optional ignored)
1906 "Set the fields of the mode line for a folder buffer.
1907 The optional argument is now obsolete and IGNORED. It used to be used to pass
1908 in what is now stored in the buffer-local variable `mh-mode-line-annotation'."
1910 (save-window-excursion
1912 (let ((new-first-msg-num (mh-get-msg-num nil)))
1913 (when (or (not (memq 'unthread mh-view-ops))
1914 (null mh-first-msg-num)
1915 (null new-first-msg-num)
1916 (< new-first-msg-num mh-first-msg-num))
1917 (setq mh-first-msg-num new-first-msg-num)))
1919 (let ((new-last-msg-num (mh-get-msg-num nil)))
1920 (when (or (not (memq 'unthread mh-view-ops))
1921 (null mh-last-msg-num)
1922 (null new-last-msg-num)
1923 (> new-last-msg-num mh-last-msg-num))
1924 (setq mh-last-msg-num new-last-msg-num)))
1925 (setq mh-msg-count (if mh-first-msg-num
1926 (count-lines (point-min) (point-max))
1928 (setq mode-line-buffer-identification
1929 (list (format " {%%b%s} %s msg%s"
1930 (if mh-mode-line-annotation
1931 (format "/%s" mh-mode-line-annotation)
1933 (if (zerop mh-msg-count)
1935 (format "%d" mh-msg-count))
1936 (if (zerop mh-msg-count)
1938 (cond ((> mh-msg-count 1)
1939 (format "s (%d-%d)" mh-first-msg-num
1942 (format " (%d)" mh-first-msg-num))
1944 (mh-logo-display))))
1946 (defun mh-add-sequence-notation (msg internal-seq-flag)
1947 "Add sequence notation to the MSG on the current line.
1948 If INTERNAL-SEQ-FLAG is non-nil, then refontify the scan line if font-lock is
1950 (with-mh-folder-updating (t)
1953 (if internal-seq-flag
1955 ;; Change the buffer so that if transient-mark-mode is active
1956 ;; and there is an active region it will get deactivated as in
1957 ;; the case of user sequences.
1958 (mh-notate nil nil mh-cmd-note)
1959 (when font-lock-mode
1960 (font-lock-fontify-region (point) (line-end-position))))
1961 (forward-char (1+ mh-cmd-note))
1962 (let ((stack (gethash msg mh-sequence-notation-history)))
1963 (setf (gethash msg mh-sequence-notation-history)
1964 (cons (char-after) stack)))
1965 (mh-notate nil mh-note-seq (1+ mh-cmd-note))))))
1967 (defun mh-remove-sequence-notation (msg internal-seq-flag &optional all)
1968 "Remove sequence notation from the MSG on the current line.
1969 If INTERNAL-SEQ-FLAG is non-nil, then `font-lock' was used to highlight the
1970 sequence. In that case, no notation needs to be removed. Otherwise the effect
1971 of inserting `mh-note-seq' needs to be reversed.
1972 If ALL is non-nil, then all sequence marks on the scan line are removed."
1973 (with-mh-folder-updating (t)
1974 ;; This takes care of internal sequences...
1975 (mh-notate nil nil mh-cmd-note)
1976 (unless internal-seq-flag
1977 ;; ... and this takes care of user sequences.
1978 (let ((stack (gethash msg mh-sequence-notation-history)))
1979 (while (and all (cdr stack))
1980 (setq stack (cdr stack)))
1984 (forward-char (1+ mh-cmd-note))
1986 (insert (car stack))))
1987 (setf (gethash msg mh-sequence-notation-history) (cdr stack))))))
1989 (defun mh-remove-cur-notation ()
1990 "Remove old cur notation."
1991 (let ((cur-msg (car (mh-seq-to-msgs 'cur))))
1994 (mh-goto-msg cur-msg t t)
1995 (looking-at mh-scan-cur-msg-number-regexp))
1996 (mh-notate nil ? mh-cmd-note)
1997 (setq overlay-arrow-position nil)))))
1999 (defun mh-remove-all-notation ()
2000 "Remove all notations on all scan lines that MH-E introduces."
2002 (setq overlay-arrow-position nil)
2003 (goto-char (point-min))
2004 (mh-iterate-on-range msg (cons (point-min) (point-max))
2005 (mh-notate nil ? mh-cmd-note)
2006 (mh-remove-sequence-notation msg nil t))
2007 (clrhash mh-sequence-notation-history)))
2010 (defun mh-goto-cur-msg (&optional minimal-changes-flag)
2011 "Position the cursor at the current message.
2012 When optional argument MINIMAL-CHANGES-FLAG is non-nil, the function doesn't
2013 recenter the folder buffer."
2014 (let ((cur-msg (car (mh-seq-to-msgs 'cur))))
2016 (mh-goto-msg cur-msg t t))
2017 (unless minimal-changes-flag
2020 (mh-maybe-show cur-msg)))
2022 (setq overlay-arrow-position nil)
2023 (message "No current message")))))
2025 (defun mh-process-or-undo-commands (folder)
2026 "If FOLDER has outstanding commands, then either process or discard them.
2027 Called by functions like `mh-sort-folder', so also invalidate show buffer."
2029 (if (mh-outstanding-commands-p)
2030 (if (or mh-do-not-confirm-flag
2032 "Process outstanding deletes and refiles? "))
2033 (mh-process-commands folder)
2037 (mh-invalidate-show-buffer))
2039 (defun mh-process-commands (folder)
2040 "Process outstanding commands for FOLDER.
2041 The value of `mh-folder-updated-hook' is a list of functions to be called,
2042 with no arguments, before the commands are processed."
2043 (message "Processing deletes and refiles for %s..." folder)
2045 (with-mh-folder-updating (nil)
2046 ;; Run the hook while the lists are still valid
2047 (run-hooks 'mh-folder-updated-hook)
2049 ;; Update the unseen sequence if it exists
2052 (let ((redraw-needed-flag mh-index-data)
2053 (folders-changed (list mh-current-folder))
2054 (seq-map (and mh-refile-list mh-refile-preserves-sequences-flag
2055 (mh-create-sequence-map mh-seq-list)))
2056 (dest-map (and mh-refile-list mh-refile-preserves-sequences-flag
2057 (make-hash-table))))
2058 ;; Remove invalid scan lines if we are in an index folder and then remove
2059 ;; the real messages
2061 (mh-index-delete-folder-headers)
2062 (setq folders-changed
2063 (append folders-changed (mh-index-execute-commands))))
2065 ;; Then refile messages
2066 (mh-mapc #'(lambda (folder-msg-list)
2067 (let* ((dest-folder (symbol-name (car folder-msg-list)))
2068 (last (car (mh-translate-range dest-folder "last")))
2069 (msgs (cdr folder-msg-list)))
2070 (push dest-folder folders-changed)
2071 (setq redraw-needed-flag t)
2072 (apply #'mh-exec-cmd
2073 "refile" "-src" folder dest-folder
2074 (mh-coalesce-msg-list msgs))
2075 (mh-delete-scan-msgs msgs)
2076 ;; Preserve sequences in destination folder...
2077 (when mh-refile-preserves-sequences-flag
2079 (loop for i from (1+ (or last 0))
2080 for msg in (sort (copy-sequence msgs) #'<)
2081 do (loop for seq-name in (gethash msg seq-map)
2082 do (push i (gethash seq-name dest-map))))
2084 #'(lambda (seq msgs)
2085 ;; Can't be run in the background, since the
2086 ;; current folder is changed by mark this could
2087 ;; lead to a race condition with the next refile.
2088 (apply #'mh-exec-cmd "mark"
2089 "-sequence" (symbol-name seq) dest-folder
2090 "-add" (mapcar #'(lambda (x) (format "%s" x))
2091 (mh-coalesce-msg-list msgs))))
2094 (setq mh-refile-list ())
2096 ;; Now delete messages
2097 (cond (mh-delete-list
2098 (setq redraw-needed-flag t)
2099 (apply 'mh-exec-cmd "rmm" folder
2100 (mh-coalesce-msg-list mh-delete-list))
2101 (mh-delete-scan-msgs mh-delete-list)
2102 (setq mh-delete-list nil)))
2104 ;; Don't need to remove sequences since delete and refile do so.
2106 (if (> (buffer-size) 0)
2107 (mh-define-sequence 'cur (list (or (mh-get-msg-num nil) "last"))))
2109 ;; Redraw folder buffer if needed
2110 (when (and redraw-needed-flag)
2111 (when (mh-speed-flists-active-p)
2112 (apply #'mh-speed-flists t folders-changed))
2113 (cond ((memq 'unthread mh-view-ops) (mh-thread-inc folder (point-max)))
2114 (mh-index-data (mh-index-insert-folder-headers)))))
2116 (and (buffer-file-name (get-buffer mh-show-buffer))
2117 (not (file-exists-p (buffer-file-name (get-buffer mh-show-buffer))))
2118 ;; If "inc" were to put a new msg in this file,
2119 ;; we would not notice, so mark it invalid now.
2120 (mh-invalidate-show-buffer))
2122 (setq mh-seq-list (mh-read-folder-sequences mh-current-folder nil))
2123 (mh-remove-all-notation)
2124 (mh-notate-user-sequences)
2125 (message "Processing deletes and refiles for %s...done" folder)))
2127 (defun mh-update-unseen ()
2128 "Synchronize the unseen sequence with MH.
2129 Return non-nil iff the MH folder was set.
2130 The value of `mh-unseen-updated-hook' is a list of functions to be called,
2131 with no arguments, after the unseen sequence is updated."
2133 (let* ((unseen-seq (mh-find-seq mh-unseen-seq))
2134 (unseen-msgs (mh-seq-msgs unseen-seq)))
2137 (mh-undefine-sequence mh-unseen-seq mh-seen-list)
2138 (run-hooks 'mh-unseen-updated-hook)
2140 (setq unseen-msgs (delq (car mh-seen-list) unseen-msgs))
2141 (setq mh-seen-list (cdr mh-seen-list)))
2142 (setcdr unseen-seq unseen-msgs)
2143 t) ;since we set the folder
2144 (setq mh-seen-list nil)))))
2146 (defun mh-delete-scan-msgs (msgs)
2147 "Delete the scan listing lines for MSGS."
2150 (when (mh-goto-msg (car msgs) t t)
2151 (when (memq 'unthread mh-view-ops)
2152 (mh-thread-forget-message (car msgs)))
2154 (setq msgs (cdr msgs)))))
2156 (defun mh-outstanding-commands-p ()
2157 "Return non-nil if there are outstanding deletes or refiles."
2159 (when (eq major-mode 'mh-show-mode)
2160 (set-buffer mh-show-folder-buffer))
2161 (or mh-delete-list mh-refile-list)))
2163 (defun mh-coalesce-msg-list (messages)
2164 "Given a list of MESSAGES, return a list of message number ranges.
2165 This is the inverse of `mh-read-msg-list', which expands ranges.
2166 Message lists passed to MH programs should be processed by this function
2167 to avoid exceeding system command line argument limits."
2168 (let ((msgs (sort (copy-sequence messages) 'mh-greaterp))
2174 (if (or (not (numberp prev))
2175 (not (equal (car msgs) (1- prev))))
2176 (progn ;non-sequential, flush old range
2177 (if (eq prev range-high)
2178 (setq ranges (cons range-high ranges))
2179 (setq ranges (cons (format "%s-%s" prev range-high) ranges)))
2180 (setq range-high nil))))
2182 (setq range-high (car msgs))) ;start new or first range
2183 (setq prev (car msgs))
2184 (setq msgs (cdr msgs)))
2187 (defun mh-greaterp (msg1 msg2)
2188 "Return the greater of two message indicators MSG1 and MSG2.
2189 Strings are \"smaller\" than numbers.
2190 Valid values are things like \"cur\", \"last\", 1, and 1820."
2197 (string-lessp msg2 msg1))))
2199 (defun mh-lessp (msg1 msg2)
2200 "Return the lesser of two message indicators MSG1 and MSG2.
2201 Strings are \"smaller\" than numbers.
2202 Valid values are things like \"cur\", \"last\", 1, and 1820."
2203 (not (mh-greaterp msg1 msg2)))
2207 ;;; Basic sequence handling
2209 (defun mh-delete-seq-locally (seq)
2210 "Remove MH-E's record of SEQ."
2211 (let ((entry (mh-find-seq seq)))
2212 (setq mh-seq-list (delq entry mh-seq-list))))
2214 (defun mh-read-folder-sequences (folder save-refiles)
2215 "Read and return the predefined sequences for a FOLDER.
2216 If SAVE-REFILES is non-nil, then keep the sequences
2217 that note messages to be refiled."
2220 (mh-mapc (function (lambda (seq) ; Save the refiling sequences
2221 (if (mh-folder-name-p (mh-seq-name seq))
2222 (setq seqs (cons seq seqs)))))
2225 (if (eq 0 (mh-exec-cmd-quiet nil "mark" folder "-list"))
2227 ;; look for name in line of form "cur: 4" or "myseq (private): 23"
2228 (while (re-search-forward "^[^: ]+" nil t)
2229 (setq seqs (cons (mh-make-seq (intern (buffer-substring
2234 (delete-region (point-min) (point))))) ; avoid race with
2238 (defun mh-read-msg-list ()
2239 "Return a list of message numbers from point to the end of the line.
2240 Expands ranges into set of individual numbers."
2242 (end-of-line (save-excursion (end-of-line) (point)))
2244 (while (re-search-forward "[0-9]+" end-of-line t)
2245 (setq num (string-to-number (buffer-substring (match-beginning 0)
2247 (cond ((looking-at "-") ; Message range
2249 (re-search-forward "[0-9]+" end-of-line t)
2250 (let ((num2 (string-to-number
2251 (buffer-substring (match-beginning 0)
2254 (error "Bad message range: %d-%d" num num2))
2255 (while (<= num num2)
2256 (setq msgs (cons num msgs))
2257 (setq num (1+ num)))))
2258 ((not (zerop num)) ;"pick" outputs "0" to mean no match
2259 (setq msgs (cons num msgs)))))
2262 (defun mh-notate-user-sequences (&optional range)
2263 "Mark user-defined sequences in the messages specified by RANGE.
2264 The optional argument RANGE can be a message number, a list of message
2265 numbers, a sequence, a region in a cons cell. If nil all messages are notated."
2267 (setq range (cons (point-min) (point-max))))
2268 (let ((seqs mh-seq-list)
2269 (msg-hash (make-hash-table)))
2271 (dolist (msg (mh-seq-msgs seq))
2272 (push (car seq) (gethash msg msg-hash))))
2273 (mh-iterate-on-range msg range
2274 (loop for seq in (gethash msg msg-hash)
2275 do (mh-add-sequence-notation msg (mh-internal-seq seq))))))
2277 (defvar mh-internal-seqs '(answered cur deleted forwarded printed))
2279 (defun mh-internal-seq (name)
2280 "Return non-nil if NAME is the name of an internal MH-E sequence."
2281 (or (memq name mh-internal-seqs)
2282 (eq name mh-unseen-seq)
2283 (and (mh-colors-in-use-p) mh-tick-seq (eq name mh-tick-seq))
2284 (eq name mh-previous-seq)
2285 (mh-folder-name-p name)))
2287 (defun mh-valid-seq-p (name)
2288 "Return non-nil if NAME is a valid MH sequence name."
2290 (string-match "^[a-zA-Z][a-zA-Z0-9]*$" (symbol-name name))))
2292 (defun mh-delete-msg-from-seq (range sequence &optional internal-flag)
2293 "Delete RANGE from SEQUENCE.
2295 Check the documentation of `mh-interactive-range' to see how RANGE is read in
2298 Optional third arg INTERNAL-FLAG non-nil means do not inform MH of the
2300 (interactive (list (mh-interactive-range "Delete")
2301 (mh-read-seq-default "Delete from" t)
2303 (let ((entry (mh-find-seq sequence))
2304 (user-sequence-flag (not (mh-internal-seq sequence)))
2305 (folders-changed (list mh-current-folder))
2308 (mh-iterate-on-range msg range
2310 ;; Calling "mark" repeatedly takes too long. So we will pretend here
2311 ;; that we are just modifying an internal sequence...
2312 (when (memq msg (cdr entry))
2313 (mh-remove-sequence-notation msg (not user-sequence-flag)))
2314 (mh-delete-a-msg-from-seq msg sequence t))
2315 ;; ... and here we will "mark" all the messages at one go.
2316 (unless internal-flag (mh-undefine-sequence sequence msg-list))
2317 (when (and mh-index-data (not internal-flag))
2318 (setq folders-changed
2319 (append folders-changed
2320 (mh-index-delete-from-sequence sequence msg-list))))
2321 (when (and (eq sequence mh-unseen-seq) (mh-speed-flists-active-p))
2322 (apply #'mh-speed-flists t folders-changed)))))
2324 (defun mh-catchup (range)
2325 "Delete RANGE from the `mh-unseen-seq' sequence.
2327 Check the document of `mh-interactive-range' to see how RANGE is read in
2329 (interactive (list (mh-interactive-range "Catchup"
2330 (cons (point-min) (point-max)))))
2331 (mh-delete-msg-from-seq range mh-unseen-seq))
2333 (defun mh-delete-a-msg-from-seq (msg sequence internal-flag)
2334 "Delete MSG from SEQUENCE.
2335 If INTERNAL-FLAG is non-nil, then do not inform MH of the change."
2336 (let ((entry (mh-find-seq sequence)))
2337 (when (and entry (memq msg (mh-seq-msgs entry)))
2338 (if (not internal-flag)
2339 (mh-undefine-sequence sequence (list msg)))
2340 (setcdr entry (delq msg (mh-seq-msgs entry))))))
2342 (defun mh-undefine-sequence (seq msgs)
2343 "Remove from the SEQ the list of MSGS."
2344 (when (and (mh-valid-seq-p seq) msgs)
2345 (apply #'mh-exec-cmd "mark" mh-current-folder "-delete"
2346 "-sequence" (symbol-name seq) (mh-coalesce-msg-list msgs))))
2348 (defun mh-define-sequence (seq msgs)
2349 "Define the SEQ to contain the list of MSGS.
2350 Do not mark pseudo-sequences or empty sequences.
2351 Signals an error if SEQ is an invalid name."
2353 (mh-valid-seq-p seq)
2354 (not (mh-folder-name-p seq)))
2356 (mh-exec-cmd-error nil "mark" mh-current-folder "-add" "-zero"
2357 "-sequence" (symbol-name seq)
2358 (mh-coalesce-msg-list msgs)))))
2360 (defun mh-seq-containing-msg (msg &optional include-internal-flag)
2361 "Return a list of the sequences containing MSG.
2362 If INCLUDE-INTERNAL-FLAG non-nil, include MH-E internal sequences in list."
2363 (let ((l mh-seq-list)
2366 (and (memq msg (mh-seq-msgs (car l)))
2367 (or include-internal-flag
2368 (not (mh-internal-seq (mh-seq-name (car l)))))
2369 (setq seqs (cons (mh-seq-name (car l)) seqs)))
2375 ;;; Build the folder-mode keymap:
2377 (suppress-keymap mh-folder-mode-map)
2379 ;; Use defalias to make sure the documented primary key bindings
2380 ;; appear in menu lists.
2381 (defalias 'mh-alt-show 'mh-show)
2382 (defalias 'mh-alt-refile-msg 'mh-refile-msg)
2383 (defalias 'mh-alt-send 'mh-send)
2384 (defalias 'mh-alt-visit-folder 'mh-visit-folder)
2386 ;; Save the `b' binding for a future `back'. Maybe?
2387 (gnus-define-keys mh-folder-mode-map
2389 "!" mh-refile-or-write-again
2391 "," mh-header-display
2393 ";" mh-toggle-mh-decode-mime-flag
2394 ">" mh-write-msg-to-file
2396 "E" mh-extract-rejected-mail
2398 "\177" mh-previous-page
2399 "\C-d" mh-delete-msg-no-motion
2400 "\t" mh-index-next-folder
2401 [backtab] mh-index-previous-folder
2402 "\M-\t" mh-index-previous-folder
2405 "\ed" mh-redistribute
2407 "^" mh-alt-refile-msg
2414 "k" mh-delete-subject-or-thread
2416 "n" mh-next-undeleted-msg
2417 "\M-n" mh-next-unread-msg
2419 "p" mh-previous-undeleted-msg
2420 "\M-p" mh-previous-unread-msg
2424 "t" mh-toggle-showing
2426 "v" mh-index-visit-folder
2427 "x" mh-execute-commands
2430 (gnus-define-keys (mh-folder-map "F" mh-folder-mode-map)
2432 "'" mh-index-ticked-messages
2435 "f" mh-alt-visit-folder
2439 "n" mh-index-new-messages
2440 "o" mh-alt-visit-folder
2442 "q" mh-index-sequenced-messages
2443 "r" mh-rescan-folder
2444 "s" mh-search-folder
2446 "v" mh-visit-folder)
2448 (define-key mh-folder-mode-map "I" mh-inc-spool-map)
2450 (gnus-define-keys (mh-junk-map "J" mh-folder-mode-map)
2452 "b" mh-junk-blacklist
2453 "w" mh-junk-whitelist)
2455 (gnus-define-keys (mh-ps-print-map "P" mh-folder-mode-map)
2457 "A" mh-ps-print-toggle-mime
2458 "C" mh-ps-print-toggle-color
2459 "F" mh-ps-print-toggle-faces
2460 "M" mh-ps-print-toggle-mime
2461 "f" mh-ps-print-msg-file
2464 "s" mh-ps-print-msg-show)
2466 (gnus-define-keys (mh-sequence-map "S" mh-folder-mode-map)
2467 "'" mh-narrow-to-tick
2469 "d" mh-delete-msg-from-seq
2471 "l" mh-list-sequences
2472 "n" mh-narrow-to-seq
2473 "p" mh-put-msg-in-seq
2474 "s" mh-msg-is-in-seq
2477 (gnus-define-keys (mh-thread-map "T" mh-folder-mode-map)
2479 "u" mh-thread-ancestor
2480 "p" mh-thread-previous-sibling
2481 "n" mh-thread-next-sibling
2482 "t" mh-toggle-threads
2483 "d" mh-thread-delete
2484 "o" mh-thread-refile)
2486 (gnus-define-keys (mh-limit-map "/" mh-folder-mode-map)
2487 "'" mh-narrow-to-tick
2490 "f" mh-narrow-to-from
2491 "r" mh-narrow-to-range
2492 "s" mh-narrow-to-subject
2496 (gnus-define-keys (mh-extract-map "X" mh-folder-mode-map)
2498 "s" mh-store-msg ;shar
2499 "u" mh-store-msg) ;uuencode
2501 (gnus-define-keys (mh-digest-map "D" mh-folder-mode-map)
2504 "\177" mh-page-digest-backwards
2505 "b" mh-burst-digest)
2507 (gnus-define-keys (mh-mime-map "K" mh-folder-mode-map)
2509 "a" mh-mime-save-parts
2510 "e" mh-display-with-external-viewer
2511 "i" mh-folder-inline-mime-part
2512 "o" mh-folder-save-mime-part
2513 "t" mh-toggle-mime-buttons
2514 "v" mh-folder-toggle-mime-part
2516 [backtab] mh-prev-button
2517 "\M-\t" mh-prev-button)
2521 (define-key mh-folder-mode-map [button2] 'mh-show-mouse))
2523 (define-key mh-folder-mode-map [mouse-2] 'mh-show-mouse)))
2525 ;; "C-c /" prefix is used in mh-folder-mode by pgp.el and mailcrypt
2531 ;;; If you add a new prefix, add appropriate text to the nil key.
2533 ;;; In general, messages are grouped logically. Taking the main commands for
2534 ;;; example, the first line is "ways to view messages," the second line is
2535 ;;; "things you can do with messages", and the third is "composing" messages.
2537 ;;; When adding a new prefix, ensure that the help message contains "what" the
2538 ;;; prefix is for. For example, if the word "folder" were not present in the
2539 ;;; `F' entry, it would not be clear what these commands operated upon.
2540 (defvar mh-help-messages
2541 '((nil "[i]nc, [.]show, [,]show all, [n]ext, [p]revious,\n"
2542 "[d]elete, [o]refile, e[x]ecute,\n"
2543 "[s]end, [r]eply,\n"
2544 "[;]toggle MIME decoding.\n"
2545 "Prefix characters:\n [F]older, [S]equence, [J]unk, MIME [K]eys,"
2546 "\n [T]hread, [/]limit, e[X]tract, [D]igest, [I]nc spools.")
2548 (?F "[l]ist; [v]isit folder;\n"
2549 "[n]ew messages; [']ticked messages; [s]earch; [i]ndexed search;\n"
2550 "[p]ack; [S]ort; [r]escan; [k]ill")
2551 (?P "PS [p]rint message; [l]non-PS print;\n"
2552 "PS Print [s]how window, message to [f]ile;\n"
2553 "Toggle printing of [M]IME parts, [C]olor, [F]aces")
2554 (?S "[p]ut message in sequence, [n]arrow, [']narrow to ticked, [w]iden,\n"
2555 "[s]equences, [l]ist,\n"
2556 "[d]elete message from sequence, [k]ill sequence")
2557 (?T "[t]oggle, [d]elete, [o]refile thread")
2558 (?/ "Limit to [c]c, [f]rom, [r]ange, [s]ubject, [t]o; [w]iden")
2559 (?X "un[s]har, [u]udecode message")
2560 (?D "[b]urst digest")
2561 (?K "[v]iew, [i]nline, [o]utput/save MIME part; save [a]ll parts; \n"
2562 "[TAB] next; [SHIFT-TAB] previous")
2563 (?J "[b]lacklist, [w]hitelist message"))
2564 "Key binding cheat sheet.
2566 This is an associative array which is used to show the most common commands.
2567 The key is a prefix char. The value is one or more strings which are
2568 concatenated together and displayed in the minibuffer if ? is pressed after
2569 the prefix character. The special key nil is used to display the
2570 non-prefixed commands.
2572 The substitutions described in `substitute-command-keys' are performed as
2577 (dolist (mess '("^Cursor not pointing to message$"
2578 "^There is no other window$"))
2579 (add-to-list 'debug-ignored-errors mess))
2583 ;;; Local Variables:
2584 ;;; indent-tabs-mode: nil
2585 ;;; sentence-end-double-space: nil
2588 ;;; arch-tag: cce884de-bd37-4104-9963-e4439d5ed22b
2589 ;;; mh-e.el ends here