1 ;;; mh-e.el --- GNU Emacs interface to the MH mail system
3 ;; Copyright (C) 1985, 86, 87, 88, 90, 92, 93, 94, 95, 97, 1999,
4 ;; 2000, 01, 02, 03, 2004 Free Software Foundation, Inc.
6 ;; Author: Bill Wohler <wohler@newt.com>
7 ;; Maintainer: Bill Wohler <wohler@newt.com>
11 ;; This file is part of GNU Emacs.
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation; either version 2, or (at your option)
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26 ;; Boston, MA 02111-1307, USA.
31 ;; M-x mh-rmail to read mail. Type C-h m there for a list of commands.
32 ;; C-u M-x mh-rmail to visit any folder.
33 ;; M-x mh-smail to send mail. From within the mail reader, "m" works, too.
35 ;; Your .emacs might benefit from these bindings:
36 ;; (global-set-key "\C-cr" 'mh-rmail)
37 ;; (global-set-key "\C-xm" 'mh-smail)
38 ;; (global-set-key "\C-x4m" 'mh-smail-other-window)
40 ;; MH (Message Handler) is a powerful mail reader.
42 ;; The MH newsgroup is comp.mail.mh; the mailing list is mh-users@ics.uci.edu
43 ;; (send to mh-users-request to be added). See the monthly Frequently Asked
44 ;; Questions posting there for information on getting MH and MH-E:
45 ;; http://www.faqs.org/faqs/mail/mh-faq/part1/preamble.html
47 ;; N.B. MH must have been compiled with the MHE compiler flag or several
48 ;; features necessary for MH-E will be missing from MH commands, specifically
49 ;; the -build switch to repl and forw.
51 ;; MH-E is an Emacs interface to the MH mail system.
53 ;; MH-E is supported in GNU Emacs 20 and 21, with MH 6.8.4 and nmh 1.0.4.
56 ;; mh-e-users@lists.sourceforge.net
57 ;; mh-e-announce@lists.sourceforge.net
58 ;; mh-e-devel@lists.sourceforge.net
60 ;; Subscribe by sending a "subscribe" message to
61 ;; <list>-request@lists.sourceforge.net, or by using the web interface at
62 ;; https://sourceforge.net/mail/?group_id=13357
65 ;; https://sourceforge.net/tracker/?group_id=13357&atid=113357
66 ;; Include the output of M-x mh-version in any bug report.
69 ;; https://sourceforge.net/tracker/?atid=363357&group_id=13357&func=browse
72 ;; https://sourceforge.net/tracker/?group_id=13357&atid=213357
76 ;; Original version for Gosling emacs by Brian Reid, Stanford, 1982.
77 ;; Modified by James Larus, BBN, July 1984 and UCB, 1984 & 1985.
78 ;; Rewritten for GNU Emacs, James Larus, 1985.
79 ;; Modified by Stephen Gildea, 1988.
80 ;; Maintenance picked up by Bill Wohler and the
81 ;; SourceForge Crew <http://mh-e.sourceforge.net/>, 2001.
87 (eval-when-compile (require 'mh-acros
))
96 ;; Shush the byte-compiler
97 (defvar font-lock-auto-fontify
)
98 (defvar font-lock-defaults
)
100 (defconst mh-version
"7.82" "Version number of MH-E.")
103 (autoload 'Info-goto-node
"info")
105 (defvar mh-partial-folder-mode-line-annotation
"select"
106 "Annotation when displaying part of a folder.
107 The string is displayed after the folder's name. nil for no annotation.")
110 ;;; Scan Line Formats
112 ;;; Parameterize MH-E to work with different scan formats. The defaults work
113 ;;; with the standard MH scan listings, in which the first 4 characters on
114 ;;; the line are the message number, followed by two places for notations.
116 ;; The following scan formats are passed to the scan program if the setting of
117 ;; `mh-scan-format-file' is t. They are identical except the later one makes
118 ;; use of the nmh `decode' function to decode RFC 2047 encodings. If you just
119 ;; want to change the width of the msg number, use the `mh-set-cmd-note'
122 (defvar mh-scan-format-mh
127 "%?(nonnull(comp{to}))%<(mymbox{to})t%>"
128 "%?(nonnull(comp{cc}))%<(mymbox{cc})c%>"
129 "%?(nonnull(comp{bcc}))%<(mymbox{bcc})b%>"
130 "%?(nonnull(comp{newsgroups}))n%>"
132 "%02(mon{date})/%02(mday{date})%<{date} %|*%>"
133 "%<(mymbox{from})%<{to}To:%14(friendly{to})%>%>"
134 "%<(zero)%17(friendly{from})%> "
135 "%{subject}%<{body}<<%{body}%>")
136 "*Scan format string for MH, provided to the scan program via the -format arg.
137 This format is identical to the default except that additional hints for
138 fontification have been added to the fifth column (remember that in Emacs, the
141 The values of the fifth column, in priority order, are: `-' if the message has
142 been replied to, t if an address on the To: line matches one of the
143 mailboxes of the current user, `c' if the Cc: line matches, `b' if the Bcc:
144 line matches, and `n' if a non-empty Newsgroups: header is present.")
146 (defvar mh-scan-format-nmh
151 "%?(nonnull(comp{to}))%<(mymbox{to})t%>"
152 "%?(nonnull(comp{cc}))%<(mymbox{cc})c%>"
153 "%?(nonnull(comp{bcc}))%<(mymbox{bcc})b%>"
154 "%?(nonnull(comp{newsgroups}))n%>"
156 "%02(mon{date})/%02(mday{date})%<{date} %|*%>"
157 "%<(mymbox{from})%<{to}To:%14(decode(friendly{to}))%>%>"
158 "%<(zero)%17(decode(friendly{from}))%> "
159 "%(decode{subject})%<{body}<<%{body}%>")
160 "*Scan format string for nmh.
161 This string is passed to the scan program via the -format arg.
162 This format is identical to the default except that additional hints for
163 fontification have been added to the fifth column (remember that in Emacs, the
166 The values of the fifth column, in priority order, are: `-' if the message has
167 been replied to, t if an address on the To: field matches one of the
168 mailboxes of the current user, `c' if the Cc: field matches, `b' if the Bcc:
169 field matches, and `n' if a non-empty Newsgroups: field is present.")
171 (defvar mh-note-deleted ?D
172 "Deleted messages are marked by this character.
173 See also `mh-scan-deleted-msg-regexp'.")
175 (defvar mh-note-refiled ?^
176 "Refiled messages are marked by this character.
177 See also `mh-scan-refiled-msg-regexp'.")
179 (defvar mh-note-cur ?
+
180 "The current message (in MH) is marked by this character.
181 See also `mh-scan-cur-msg-number-regexp'.")
183 (defvar mh-scan-good-msg-regexp
"^\\( *[0-9]+\\)[^D^0-9]"
184 "This regexp specifies the scan lines that are 'good' messages.
185 Note that the default setting of `mh-folder-font-lock-keywords' expects this
186 expression to contain at least one parenthesized expression which matches the
187 message number as in the default of \"^\\\\( *[0-9]+\\\\)[^D^0-9]\".")
189 (defvar mh-scan-deleted-msg-regexp
"^\\( *[0-9]+\\)D"
190 "This regexp matches deleted messages.
191 Note that the default setting of `mh-folder-font-lock-keywords' expects this
192 expression to contain at least one parenthesized expression which matches the
193 message number as in the default of \"^\\\\( *[0-9]+\\\\)D\".
194 See also `mh-note-deleted'.")
196 (defvar mh-scan-refiled-msg-regexp
"^\\( *[0-9]+\\)\\^"
197 "This regexp matches refiled messages.
198 Note that the default setting of `mh-folder-font-lock-keywords' expects this
199 expression to contain at least one parenthesized expression which matches the
200 message number as in the default of \"^\\\\( *[0-9]+\\\\)\\\\^\".
201 See also `mh-note-refiled'.")
203 (defvar mh-scan-valid-regexp
"^ *[0-9]"
204 "This regexp matches scan lines for messages (not error messages).")
206 (defvar mh-scan-cur-msg-number-regexp
"^\\( *[0-9]+\\+\\).*"
207 "This regexp matches the current message.
208 Note that the default setting of `mh-folder-font-lock-keywords' expects this
209 expression to contain at least one parenthesized expression which matches the
210 message number as in the default of \"^\\\\( *[0-9]+\\\\+\\\\).*\". Don't
211 disable this regexp as it's needed by non-fontifying functions.
212 See also `mh-note-cur'.")
214 (defvar mh-scan-date-regexp
"\\([0-9][0-9]/[0-9][0-9]\\)"
215 "This regexp matches a valid date.
216 Note that the default setting of `mh-folder-font-lock-keywords' expects this
217 expression to contain only one parenthesized expression which matches the date
218 field as in the default of \"\\\\([0-9][0-9]/[0-9][0-9]\\\\)\"}.
219 See also `mh-scan-format-regexp'.")
221 (defvar mh-scan-rcpt-regexp
"\\(To:\\)\\(..............\\)"
222 "This regexp specifies the recipient in messages you sent.
223 Note that the default setting of `mh-folder-font-lock-keywords'
224 expects this expression to contain two parenthesized expressions. The
225 first is expected to match the `To:' that the default scan format
226 file generates. The second is expected to match the recipient's name
227 as in the default of \"\\\\(To:\\\\)\\\\(..............\\\\)\".")
229 (defvar mh-scan-body-regexp
"\\(<<\\([^\n]+\\)?\\)"
230 "This regexp matches the message body fragment displayed in scan lines.
231 Note that the default setting of `mh-folder-font-lock-keywords' expects this
232 expression to contain at least one parenthesized expression which matches the
233 body text as in the default of \"\\\\(<<\\\\([^\\n]+\\\\)?\\\\)\".")
235 (defvar mh-scan-subject-regexp
236 "^ *[0-9]+........[ ]*...................\\([Rr][Ee]\\(\\[[0-9]+\\]\\)?:\\s-*\\)*\\([^<\n]*\\)"
237 "This regexp matches the subject.
238 Note that the default setting of `mh-folder-font-lock-keywords' expects this
239 expression to contain at least three parenthesized expressions. The first is
240 expected to match the `Re:' string, if any. The second matches an optional
241 bracketed number after `Re:', such as in `Re[2]:' (and is thus a
242 sub-expression of the first expression) and the third is expected to match
243 the subject line itself as in the default of \"^ *[0-9]+........[ ]*...................\\\\([Rr][Ee]\\\\(\\\\\\=[[0-9]+\\\\]\\\\)?:\\\\s-*\\\\)*\\\\([^<\\n]*\\\\)\".")
245 (defvar mh-scan-format-regexp
246 (concat "\\([bct]\\)" mh-scan-date-regexp
" *\\(..................\\)")
247 "This regexp matches the output of scan.
248 Note that the default setting of `mh-folder-font-lock-keywords' expects this
249 expression to contain at least three parenthesized expressions. The first
250 should match the fontification hint, the second is found in
251 `mh-scan-date-regexp', and the third should match the user name as in the
252 default of \"(concat \"\\\\([bct]\\\\)\" mh-scan-date-regexp
253 \"*\\\\(..................\\\\)\")\".")
257 (defvar mh-folder-font-lock-keywords
259 ;; Folders when displaying index buffer
261 '(0 mh-index-folder-face
))
262 ;; Marked for deletion
263 (list (concat mh-scan-deleted-msg-regexp
".*")
264 '(0 mh-folder-deleted-face
))
266 (list (concat mh-scan-refiled-msg-regexp
".*")
267 '(0 mh-folder-refiled-face
))
269 (list mh-scan-body-regexp
'(1 mh-folder-body-face nil t
))
270 '(mh-folder-font-lock-subject
271 (1 mh-folder-followup-face append t
)
272 (2 mh-folder-subject-face append t
))
274 (list mh-scan-cur-msg-number-regexp
275 '(1 mh-folder-cur-msg-number-face
))
276 (list mh-scan-good-msg-regexp
277 '(1 mh-folder-msg-number-face
)) ;; Msg number
278 (list mh-scan-date-regexp
'(1 mh-folder-date-face
)) ;; Date
279 (list mh-scan-rcpt-regexp
280 '(1 mh-folder-to-face
) ;; To:
281 '(2 mh-folder-address-face
)) ;; address
282 ;; scan font-lock name
283 (list mh-scan-format-regexp
284 '(1 mh-folder-date-face
)
285 '(3 mh-folder-scan-format-face
)))
286 "Regexp keywords used to fontify the MH-Folder buffer.")
288 (defvar mh-scan-cmd-note-width
1
289 "Number of columns consumed by the cmd-note field in `mh-scan-format'.
290 This column will have one of the values: ` ', `D', `^', `+' and where
291 ` ' is the default value,
292 `D' is the `mh-note-deleted' character,
293 `^' is the `mh-note-refiled' character, and
294 `+' is the `mh-note-cur' character.")
296 (defvar mh-scan-destination-width
1
297 "Number of columns consumed by the destination field in `mh-scan-format'.
298 This column will have one of ' ', '%', '-', 't', 'c', 'b', or `n' in it.
299 A ' ' blank space is the default character.
300 A '%' indicates that the message in in a named MH sequence.
301 A '-' indicates that the message has been annotated with a replied field.
302 A 't' indicates that the message contains mymbox in the To: field.
303 A 'c' indicates that the message contains mymbox in the Cc: field.
304 A 'b' indicates that the message contains mymbox in the Bcc: field.
305 A 'n' indicates that the message contains a Newsgroups: field.")
307 (defvar mh-scan-date-width
5
308 "Number of columns consumed by the date field in `mh-scan-format'.
309 This column will typically be of the form mm/dd.")
311 (defvar mh-scan-date-flag-width
1
312 "Number of columns consumed to flag (in)valid dates in `mh-scan-format'.
313 This column will have ` ' for valid and `*' for invalid or missing dates.")
315 (defvar mh-scan-from-mbox-width
17
316 "Number of columns consumed with the \"From:\" line in `mh-scan-format'.
317 This column will have a friendly name or e-mail address of the
318 originator, or a \"To: address\" for outgoing e-mail messages.")
320 (defvar mh-scan-from-mbox-sep-width
2
321 "Number of columns consumed by whitespace after from-mbox in `mh-scan-format'.
322 This column will only ever have spaces in it.")
324 (defvar mh-scan-field-from-start-offset
325 (+ mh-scan-cmd-note-width
326 mh-scan-destination-width
328 mh-scan-date-flag-width
)
329 "The offset from the `mh-cmd-note' to find the start of \"From:\" address.")
331 (defvar mh-scan-field-from-end-offset
332 (+ mh-scan-field-from-start-offset mh-scan-from-mbox-width
)
333 "The offset from the `mh-cmd-note' to find the end of \"From:\" address.")
335 (defvar mh-scan-field-subject-start-offset
336 (+ mh-scan-cmd-note-width
337 mh-scan-destination-width
339 mh-scan-date-flag-width
340 mh-scan-from-mbox-width
341 mh-scan-from-mbox-sep-width
)
342 "The offset from the `mh-cmd-note' to find the start of the subject.")
344 (defun mh-folder-font-lock-subject (limit)
345 "Return MH-E scan subject strings to font-lock between point and LIMIT."
346 (if (not (re-search-forward mh-scan-subject-regexp limit t
))
348 (if (match-beginning 1)
349 (set-match-data (list (match-beginning 1) (match-end 3)
350 (match-beginning 1) (match-end 3) nil nil
))
351 (set-match-data (list (match-beginning 3) (match-end 3)
352 nil nil
(match-beginning 3) (match-end 3))))
357 ;; Fontifify unseen mesages in bold.
359 (defmacro mh-generate-sequence-font-lock
(seq prefix face
)
360 "Generate the appropriate code to fontify messages in SEQ.
361 PREFIX is used to generate unique names for the variables and functions
362 defined by the macro. So a different prefix should be provided for every
364 FACE is the font-lock face used to display the matching scan lines."
365 (let ((cache (intern (format "mh-folder-%s-seq-cache" prefix
)))
366 (func (intern (format "mh-folder-font-lock-%s" prefix
))))
369 "Internal cache variable used for font-lock in MH-E.
370 Should only be non-nil through font-lock stepping, and nil once font-lock
371 is done highlighting.")
372 (make-variable-buffer-local ',cache
)
375 "Return unseen message lines to font-lock between point and LIMIT."
376 (if (not ,cache
) (setq ,cache
(mh-seq-msgs (mh-find-seq ,seq
))))
377 (let ((cur-msg (mh-get-msg-num nil
)))
380 ((>= (point) limit
) ;Presumably at end of buffer
383 ((member cur-msg
,cache
)
384 (let ((bpoint (progn (beginning-of-line)(point)))
385 (epoint (progn (forward-line 1)(point))))
386 (if (<= limit
(point)) (setq ,cache nil
))
387 (set-match-data (list bpoint epoint bpoint epoint
))
390 ;; move forward one line at a time, checking each message
391 (while (and (= 0 (forward-line 1))
393 (not (member (mh-get-msg-num nil
) ,cache
))))
394 ;; Examine how we must have exited the loop...
395 (let ((cur-msg (mh-get-msg-num nil
)))
396 (cond ((or (<= limit
(point))
397 (not (member cur-msg
,cache
)))
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
))
405 (list bpoint epoint bpoint epoint
))
408 (setq mh-folder-font-lock-keywords
409 (append mh-folder-font-lock-keywords
410 (list (list ',func
(list 1 '',face
'prepend t
))))))))
412 (mh-generate-sequence-font-lock mh-unseen-seq unseen bold
)
413 (mh-generate-sequence-font-lock mh-tick-seq tick mh-folder-tick-face
)
417 ;;; Internal variables:
419 (defvar mh-last-destination nil
) ;Destination of last refile or write
421 (defvar mh-last-destination-folder nil
) ;Destination of last refile command.
422 (defvar mh-last-destination-write nil
) ;Destination of last write command.
424 (defvar mh-folder-mode-map
(make-keymap)
425 "Keymap for MH folders.")
427 (defvar mh-arrow-marker nil
) ;Marker for arrow display in fringe.
429 (defvar mh-delete-list nil
) ;List of msg numbers to delete.
431 (defvar mh-refile-list nil
) ;List of folder names in mh-seq-list.
433 (defvar mh-next-direction
'forward
) ;Direction to move to next message.
435 (defvar mh-view-ops
()) ;Stack of ops that change the folder
436 ;view (such as narrowing or threading).
437 (defvar mh-folder-view-stack
()) ;Stack of previous folder views.
439 (defvar mh-index-data nil
) ;Info about index search results
440 (defvar mh-index-previous-search nil
)
441 (defvar mh-index-msg-checksum-map nil
)
442 (defvar mh-index-checksum-origin-map nil
)
443 (defvar mh-index-sequence-search-flag nil
)
445 (defvar mh-first-msg-num nil
) ;Number of first msg in buffer.
447 (defvar mh-last-msg-num nil
) ;Number of last msg in buffer.
449 (defvar mh-mode-line-annotation nil
) ;Message range displayed in buffer.
451 (defvar mh-sequence-notation-history nil
)
452 ;Rememeber original notation that
453 ;is overwritten by `mh-note-seq'.
455 (defvar mh-colors-available-flag nil
) ;Are colors available?
457 ;;; Macros and generic functions:
459 (defun mh-mapc (function list
)
460 "Apply FUNCTION to each element of LIST for side effects only."
462 (funcall function
(car list
))
463 (setq list
(cdr list
))))
465 (defun mh-scan-format ()
466 "Return the output format argument for the scan program."
467 (if (equal mh-scan-format-file t
)
468 (list "-format" (if (mh-variant-p 'nmh
'mu-mh
)
469 (list (mh-update-scan-format
470 mh-scan-format-nmh mh-cmd-note
))
471 (list (mh-update-scan-format
472 mh-scan-format-mh mh-cmd-note
))))
473 (if (not (equal mh-scan-format-file nil
))
474 (list "-form" mh-scan-format-file
))))
481 (defun mh-rmail (&optional arg
)
482 "Inc(orporate) new mail with MH.
483 Scan an MH folder if ARG is non-nil. This function is an entry point to MH-E,
484 the Emacs interface to the MH mail system."
488 (call-interactively 'mh-visit-folder
)
489 (unless (get-buffer mh-inbox
)
490 (mh-visit-folder mh-inbox
(symbol-name mh-unseen-seq
)))
494 (defun mh-nmail (&optional arg
)
495 "Check for new mail in inbox folder.
496 Scan an MH folder if ARG is non-nil. This function is an entry point to MH-E,
497 the Emacs interface to the MH mail system."
499 (mh-find-path) ; init mh-inbox
501 (call-interactively 'mh-visit-folder
)
502 (mh-visit-folder mh-inbox
)))
506 ;;; User executable MH-E commands:
508 (defun mh-delete-msg (range)
509 "Mark the specified RANGE for subsequent deletion and move to the next.
510 Default is the displayed message.
512 Check the documentation of `mh-interactive-range' to see how RANGE is read in
514 (interactive (list (mh-interactive-range "Delete")))
515 (mh-delete-msg-no-motion range
)
516 (if (looking-at mh-scan-deleted-msg-regexp
) (mh-next-msg)))
518 (defun mh-delete-msg-no-motion (range)
519 "Mark the specified RANGE for subsequent deletion.
521 Check the documentation of `mh-interactive-range' to see how RANGE is read in
523 (interactive (list (mh-interactive-range "Delete")))
524 (mh-iterate-on-range () range
525 (mh-delete-a-msg nil
)))
527 (defun mh-execute-commands ()
528 "Process outstanding delete and refile requests."
530 (if mh-folder-view-stack
(mh-widen t
))
531 (mh-process-commands mh-current-folder
)
533 (mh-goto-cur-msg) ; after mh-set-scan-mode for efficiency
534 (mh-make-folder-mode-line)
535 t
) ; return t for write-file-functions
537 (defun mh-first-msg ()
538 "Move to the first message."
540 (goto-char (point-min))
541 (while (and (not (eobp)) (not (looking-at mh-scan-valid-regexp
)))
544 (defun mh-header-display ()
545 "Show the current message with all its headers.
546 Displays headers that might have been suppressed by setting the
547 variables `mh-clean-message-header-flag' or `mhl-formfile', or by the fallback
548 behavior of scrolling uninteresting headers off the top of the window.
549 Type \"\\[mh-show]\" to show the message normally again."
551 (and (not mh-showing-with-headers
)
552 (or mhl-formfile mh-clean-message-header-flag
)
553 (mh-invalidate-show-buffer))
554 (let ((mh-decode-mime-flag nil
)
556 (mh-clean-message-header-flag nil
))
558 (mh-in-show-buffer (mh-show-buffer)
559 (goto-char (point-min))
561 (setq mh-showing-with-headers t
)))
563 (defun mh-inc-folder (&optional maildrop-name folder
)
564 "Inc(orporate)s new mail into the Inbox folder.
565 Optional argument MAILDROP-NAME specifies an alternate maildrop from the
566 default. The optional argument FOLDER specifies where to incorporate mail
567 instead of the default named by `mh-inbox'.
568 The value of `mh-inc-folder-hook' is a list of functions to be called, with no
569 arguments, after incorporating new mail.
570 Do not call this function from outside MH-E; use \\[mh-rmail] instead."
571 (interactive (list (if current-prefix-arg
573 (read-file-name "inc mail from file: "
575 (if current-prefix-arg
576 (mh-prompt-for-folder "inc mail into" mh-inbox t
))))
578 (setq folder mh-inbox
))
579 (let ((threading-needed-flag nil
))
580 (let ((config (current-window-configuration)))
581 (delete-other-windows)
582 (cond ((not (get-buffer folder
))
583 (mh-make-folder folder
)
584 (setq threading-needed-flag mh-show-threads-flag
)
585 (setq mh-previous-window-config config
))
586 ((not (eq (current-buffer) (get-buffer folder
)))
587 (switch-to-buffer folder
)
588 (setq mh-previous-window-config config
))))
589 (mh-get-new-mail maildrop-name
)
590 (when (and threading-needed-flag
592 (goto-char (point-min))
593 (or (null mh-large-folder
)
594 (not (equal (forward-line (1+ mh-large-folder
)) 0))
595 (and (message "Not threading since the number of messages exceeds `mh-large-folder'")
599 (if (and mh-showing-mode
(looking-at mh-scan-valid-regexp
)) (mh-show))
600 (run-hooks 'mh-inc-folder-hook
)))
602 (defun mh-last-msg ()
603 "Move to the last message."
605 (goto-char (point-max))
606 (while (and (not (bobp)) (not (looking-at mh-scan-valid-regexp
)))
610 (defun mh-next-undeleted-msg (&optional arg wait-after-complaining-flag
)
611 "Move to the next undeleted message ARG in window.
612 If optional argument WAIT-AFTER-COMPLAINING-FLAG is non-nil and we are at the
613 last undeleted message then pause for a second after printing message."
615 (setq mh-next-direction
'forward
)
617 (cond ((re-search-forward mh-scan-good-msg-regexp nil t arg
)
621 (message "No more undeleted messages")
622 (if wait-after-complaining-flag
(sit-for 1)))))
624 (defun mh-folder-from-address ()
625 "Derive folder name from sender.
627 The name of the folder is derived as follows:
629 a) The folder name associated with the first address found in the list
630 `mh-default-folder-list' is used. Each element in this list contains a
631 `Check Recipient' item. If this item is turned on, then the address is
632 checked against the recipient instead of the sender. This is useful for
635 b) An alias prefixed by `mh-default-folder-prefix' corresponding to the
636 address is used. The prefix is used to prevent clutter in your mail
639 Return nil if a folder name was not derived, or if the variable
640 `mh-default-folder-must-exist-flag' is t and the folder does not exist."
641 ;; Loop for all entries in mh-default-folder-list
643 (goto-char (point-min))
644 (re-search-forward "\n\n" nil
'limit
)
645 (narrow-to-region (point-min) (point))
646 (let ((to/cc
(concat (or (message-fetch-field "to") "") ", "
647 (or (message-fetch-field "cc") "")))
648 (from (or (message-fetch-field "from") ""))
651 (loop for list in mh-default-folder-list
652 when
(string-match (nth 0 list
) (if (nth 2 list
) to
/cc from
))
656 ;; Make sure a result from `mh-default-folder-list' begins with "+"
657 ;; since 'mh-expand-file-name below depends on it
658 (when (and folder-name
(not (eq (aref folder-name
0) ?
+)))
659 (setq folder-name
(concat "+" folder-name
)))
661 ;; If not, is there an alias for the address?
662 (when (not folder-name
)
663 (let* ((from-header (mh-extract-from-header-value))
664 (address (and from-header
665 (nth 1 (mail-extract-address-components
667 (alias (and address
(mh-alias-address-to-alias address
))))
670 (and alias
(concat "+" mh-default-folder-prefix alias
))))))
672 ;; If mh-default-folder-must-exist-flag set, check that folder exists.
674 (or (not mh-default-folder-must-exist-flag
)
675 (file-exists-p (mh-expand-file-name folder-name
))))
678 (defun mh-prompt-for-refile-folder ()
679 "Prompt the user for a folder in which the message should be filed.
680 The folder is returned as a string.
682 The default folder name is generated by the option
683 `mh-default-folder-for-message-function' if it is non-nil or
684 `mh-folder-from-address'."
685 (mh-prompt-for-folder
687 (let ((refile-file (ignore-errors (mh-msg-filename (mh-get-msg-num t
)))))
688 (if (null refile-file
) ""
690 (set-buffer (get-buffer-create mh-temp-buffer
))
692 (insert-file-contents refile-file
)
693 (or (and mh-default-folder-for-message-function
694 (let ((buffer-file-name refile-file
))
695 (funcall mh-default-folder-for-message-function
)))
696 (mh-folder-from-address)
697 (and (eq 'refile
(car mh-last-destination-folder
))
698 (symbol-name (cdr mh-last-destination-folder
)))
702 (defun mh-refile-msg (range folder
&optional dont-update-last-destination-flag
)
703 "Refile RANGE into FOLDER.
705 Check the documentation of `mh-interactive-range' to see how RANGE is read in
708 If optional argument DONT-UPDATE-LAST-DESTINATION-FLAG is non-nil then the
709 variables `mh-last-destination' and `mh-last-destination-folder' are not
711 (interactive (list (mh-interactive-range "Refile")
712 (intern (mh-prompt-for-refile-folder))))
713 (unless dont-update-last-destination-flag
714 (setq mh-last-destination
(cons 'refile folder
)
715 mh-last-destination-folder mh-last-destination
))
716 (mh-iterate-on-range () range
717 (mh-refile-a-msg nil folder
))
718 (when (looking-at mh-scan-refiled-msg-regexp
) (mh-next-msg)))
720 (defun mh-refile-or-write-again (message)
721 "Re-execute the last refile or write command on the given MESSAGE.
722 Default is the displayed message. Use the same folder or file as the previous
723 refile or write command."
724 (interactive (list (mh-get-msg-num t
)))
725 (if (null mh-last-destination
)
726 (error "No previous refile or write"))
729 (cond ((eq (car mh-last-destination
) 'refile
)
730 (mh-refile-a-msg message
(cdr mh-last-destination
))
731 (format "Destination folder: %s" (cdr mh-last-destination
)))
733 (apply 'mh-write-msg-to-file message
(cdr mh-last-destination
))
734 (format "Destination: %s" (cdr mh-last-destination
)))))
735 (mh-next-msg (interactive-p))
739 "Quit the current MH-E folder.
740 Restore the previous window configuration, if one exists.
741 The value of `mh-before-quit-hook' is a list of functions to be called, with
742 no arguments, immediately upon entry to this function.
743 The value of `mh-quit-hook' is a list of functions to be called, with no
744 arguments, upon exit of this function.
745 MH-E working buffers (whose name begins with \" *mh-\" or \"*MH-E \") are
748 (run-hooks 'mh-before-quit-hook
)
749 (let ((show-buffer (get-buffer mh-show-buffer
)))
751 (kill-buffer show-buffer
)))
752 (mh-update-sequences)
753 (mh-destroy-postponed-handles)
754 (bury-buffer (current-buffer))
756 ;; Delete all MH-E temporary and working buffers.
757 (dolist (buffer (buffer-list))
758 (when (or (string-match "^ \\*mh-" (buffer-name buffer
))
759 (string-match "^\\*MH-E " (buffer-name buffer
)))
760 (kill-buffer buffer
)))
762 (if mh-previous-window-config
763 (set-window-configuration mh-previous-window-config
))
764 (run-hooks 'mh-quit-hook
))
766 (defun mh-page-msg (&optional arg
)
767 "Page the displayed message forwards.
768 Scrolls ARG lines or a full screen if no argument is supplied. Show buffer
769 first if not displayed. Show the next undeleted message if looking at the
770 bottom of the current message."
773 (if mh-page-to-next-msg-flag
774 (if (equal mh-next-direction
'backward
)
775 (mh-previous-undeleted-msg)
776 (mh-next-undeleted-msg))
777 (if (mh-in-show-buffer (mh-show-buffer)
778 (pos-visible-in-window-p (point-max)))
781 "End of message (Type %s to read %s undeleted message)"
782 (single-key-description last-input-event
)
783 (if (equal mh-next-direction
'backward
)
786 (setq mh-page-to-next-msg-flag t
))
787 (scroll-other-window arg
)))
790 (defun mh-previous-page (&optional arg
)
791 "Page the displayed message backwards.
792 Scrolls ARG lines or a full screen if no argument is supplied."
794 (mh-in-show-buffer (mh-show-buffer)
797 (defun mh-previous-undeleted-msg (&optional arg wait-after-complaining-flag
)
798 "Move to the previous undeleted message ARG in window.
799 If optional argument WAIT-AFTER-COMPLAINING-FLAG is non-nil and we are at the
800 first undeleted message then pause for a second after printing message."
802 (setq mh-next-direction
'backward
)
804 (cond ((re-search-backward mh-scan-good-msg-regexp nil t arg
)
806 (t (message "No previous undeleted message")
807 (if wait-after-complaining-flag
(sit-for 1)))))
809 (defun mh-previous-unread-msg (&optional count
)
810 "Move to previous unread message.
811 With optional argument COUNT, COUNT-1 unread messages before current message
815 (error "The function mh-previous-unread-msg expects positive argument"))
816 (setq count
(1- count
))
817 (let ((unread-sequence (cdr (assoc mh-unseen-seq mh-seq-list
)))
818 (cur-msg (mh-get-msg-num nil
)))
819 (cond ((and (not cur-msg
) (not (bobp))
820 ;; If we are at the end of the buffer back up one line and go
821 ;; to unread message after that.
824 (setq cur-msg
(mh-get-msg-num nil
)))
826 ((or (null unread-sequence
) (not cur-msg
))
827 ;; No unread message or there aren't any messages in buffer...
828 (message "No more unread messages"))
830 ;; Skip count messages...
831 (while (and unread-sequence
(>= (car unread-sequence
) cur-msg
))
832 (setq unread-sequence
(cdr unread-sequence
)))
834 (setq unread-sequence
(cdr unread-sequence
))
835 (setq count
(1- count
)))
836 (not (car unread-sequence
)))
837 (message "No more unread messages"))
838 (t (loop for msg in unread-sequence
839 when
(mh-goto-msg msg t
) return nil
840 finally
(message "No more unread messages"))))))
842 (defun mh-goto-next-button (backward-flag &optional criterion
)
843 "Search for next button satisfying criterion.
844 If BACKWARD-FLAG is non-nil search backward in the buffer for a mime button. If
845 CRITERION is a function or a symbol which has a function binding then that
846 function must return non-nil at the button we stop."
847 (unless (or (and (symbolp criterion
) (fboundp criterion
))
848 (functionp criterion
))
849 (setq criterion
(lambda (x) t
)))
850 ;; Move to the next button in the buffer satisfying criterion
851 (goto-char (or (save-excursion
853 ;; Find point before current button
854 (let ((point-before-current-button
856 (while (get-text-property (point) 'mh-data
)
857 (unless (= (forward-line
858 (if backward-flag
1 -
1))
861 (goto-char (point-min))
862 (goto-char (point-max)))))
864 ;; Skip over current button
865 (while (and (get-text-property (point) 'mh-data
)
866 (not (if backward-flag
(bobp) (eobp))))
867 (forward-line (if backward-flag -
1 1)))
868 ;; Stop at next MIME button if any exists.
871 (unless (= (forward-line
872 (if backward-flag -
1 1))
875 (goto-char (point-max))
876 (goto-char (point-min)))
879 point-before-current-button
)
880 (when (and (get-text-property (point) 'mh-data
)
881 (funcall criterion
(point)))
882 (return-from loop
(point))))
886 (defun mh-next-button (&optional backward-flag
)
887 "Go to the next MIME button.
888 Advance point to the next MIME button in the show buffer. If the end
889 of buffer is reached then the search wraps over to the start of the
890 buffer. With prefix argument, BACKWARD-FLAG the point will move to the
891 previous MIME button."
892 (interactive (list current-prefix-arg
))
893 (unless mh-showing-mode
895 (mh-in-show-buffer (mh-show-buffer)
896 (mh-goto-next-button backward-flag
)))
898 (defun mh-prev-button ()
899 "Go to the prev MIME button.
900 Move point to the previous MIME button in the show buffer. If the beginning
901 of the buffer is reached then the search wraps over to the end of the
906 (defun mh-folder-mime-action (part-index action include-security-flag
)
907 "Go to PART-INDEX and carry out ACTION.
908 If PART-INDEX is nil then go to the next part in the buffer. The search for
909 the next buffer wraps around if end of buffer is reached. If argument
910 INCLUDE-SECURITY-FLAG is non-nil then include security info buttons when
911 searching for a suitable parts."
912 (unless mh-showing-mode
914 (mh-in-show-buffer (mh-show-buffer)
918 (let ((part (get-text-property p
'mh-part
)))
919 (and (integerp part
) (= part part-index
)))))
921 (if include-security-flag
922 (get-text-property p
'mh-data
)
923 (integerp (get-text-property p
'mh-part
)))))))
925 (cond ((and (get-text-property point
'mh-part
)
926 (or (null part-index
)
927 (= (get-text-property point
'mh-part
) part-index
)))
929 ((and (get-text-property point
'mh-data
)
930 include-security-flag
934 (mh-goto-next-button nil criterion
)
935 (if (= (point) point
)
936 (message "No matching MIME part found")
937 (funcall action
)))))))
939 (defun mh-folder-toggle-mime-part (part-index)
940 "Toggle display of button.
941 If point in show buffer is at a button then that part is toggled.
942 If not at a button and PART-INDEX is non-nil point is moved to that part.
943 With nil PART-INDEX find the first button after point (search wraps around if
944 end of buffer is reached) and toggle it."
946 (when (consp part-index
) (setq part-index
(car part-index
)))
947 (mh-folder-mime-action part-index
#'mh-press-button t
))
949 (defun mh-folder-inline-mime-part (part-index)
950 "Show the raw bytes of MIME part inline.
951 If point in show buffer is at a mime part then that part is inlined.
952 If not at a mime-part and PART-INDEX is non-nil point is moved to that part.
953 With nil PART-INDEX find the first button after point (search wraps around if
954 end of buffer is reached) and inline it."
956 (when (consp part-index
) (setq part-index
(car part-index
)))
957 (mh-folder-mime-action part-index
#'mh-mime-inline-part nil
))
959 (defun mh-folder-save-mime-part (part-index)
961 If point in show buffer is at a mime part then that part is saved.
962 If not at a mime-part 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 save it."
966 (when (consp part-index
) (setq part-index
(car part-index
)))
967 (mh-folder-mime-action part-index
#'mh-mime-save-part nil
))
969 (defvar mh-thread-scan-line-map-stack
)
971 (defun mh-reset-threads-and-narrowing ()
972 "Reset all variables pertaining to threads and narrowing.
973 Also removes all content from the folder buffer."
974 (setq mh-view-ops
())
975 (setq mh-folder-view-stack
())
976 (setq mh-thread-scan-line-map-stack
())
977 (let ((buffer-read-only nil
)) (erase-buffer)))
979 (defun mh-rescan-folder (&optional range dont-exec-pending
)
980 "Rescan a folder after optionally processing the outstanding commands.
981 If optional prefix argument RANGE is provided, prompt for the range of
982 messages to display. Otherwise show the entire folder.
983 If optional argument DONT-EXEC-PENDING is non-nil then pending deletes and
984 refiles aren't carried out."
985 (interactive (list (if current-prefix-arg
986 (mh-read-range "Rescan" mh-current-folder t nil t
987 mh-interpret-number-as-range-flag
)
989 (setq mh-next-direction
'forward
)
990 (let ((threaded-flag (memq 'unthread mh-view-ops
)))
991 (mh-scan-folder mh-current-folder
(or range
"all") dont-exec-pending
)
992 (cond (threaded-flag (mh-toggle-threads))
993 (mh-index-data (mh-index-insert-folder-headers)))))
995 (defun mh-write-msg-to-file (msg file no-headers
)
996 "Append MSG to the end of a FILE.
997 If prefix argument NO-HEADERS is provided, write only the message body.
998 Otherwise send the entire message including the headers."
1000 (list (mh-get-msg-num t
)
1001 (let ((default-dir (if (eq 'write
(car mh-last-destination-write
))
1002 (file-name-directory
1003 (car (cdr mh-last-destination-write
)))
1004 default-directory
)))
1005 (read-file-name (format "Save message%s in file: "
1006 (if current-prefix-arg
" body" ""))
1008 (if (eq 'write
(car mh-last-destination-write
))
1009 (car (cdr mh-last-destination-write
))
1010 (expand-file-name "mail.out" default-dir
))))
1011 current-prefix-arg
))
1012 (let ((msg-file-to-output (mh-msg-filename msg
))
1013 (output-file (mh-expand-file-name file
)))
1014 (setq mh-last-destination
(list 'write file
(if no-headers
'no-headers
))
1015 mh-last-destination-write mh-last-destination
)
1017 (set-buffer (get-buffer-create mh-temp-buffer
))
1019 (insert-file-contents msg-file-to-output
)
1020 (goto-char (point-min))
1021 (if no-headers
(search-forward "\n\n"))
1022 (append-to-file (point) (point-max) output-file
))))
1024 (defun mh-toggle-showing ()
1025 "Toggle the scanning mode/showing mode of displaying messages."
1031 (defun mh-undo (range)
1032 "Undo the pending deletion or refile of the specified RANGE.
1034 Check the documentation of `mh-interactive-range' to see how RANGE is read in
1036 (interactive (list (mh-interactive-range "Undo")))
1037 (cond ((numberp range
)
1038 (let ((original-position (point)))
1040 (while (not (or (looking-at mh-scan-deleted-msg-regexp
)
1041 (looking-at mh-scan-refiled-msg-regexp
)
1042 (and (eq mh-next-direction
'forward
) (bobp))
1043 (and (eq mh-next-direction
'backward
)
1044 (save-excursion (forward-line) (eobp)))))
1045 (forward-line (if (eq mh-next-direction
'forward
) -
1 1)))
1046 (if (or (looking-at mh-scan-deleted-msg-regexp
)
1047 (looking-at mh-scan-refiled-msg-regexp
))
1049 (mh-undo-msg (mh-get-msg-num t
))
1051 (goto-char original-position
)
1052 (error "Nothing to undo"))))
1053 (t (mh-iterate-on-range () range
1054 (mh-undo-msg nil
))))
1055 (if (not (mh-outstanding-commands-p))
1056 (mh-set-folder-modified-p nil
)))
1059 (defun mh-folder-line-matches-show-buffer-p ()
1060 "Return t if the message under point in folder-mode is in the show buffer.
1061 Return nil in any other circumstance (no message under point, no show buffer,
1062 the message in the show buffer doesn't match."
1063 (and (eq major-mode
'mh-folder-mode
)
1064 (mh-get-msg-num nil
)
1066 (get-buffer mh-show-buffer
)
1067 (buffer-file-name (get-buffer mh-show-buffer
))
1068 (string-match ".*/\\([0-9]+\\)$"
1069 (buffer-file-name (get-buffer mh-show-buffer
)))
1071 (match-string 1 (buffer-file-name (get-buffer mh-show-buffer
)))
1072 (int-to-string (mh-get-msg-num nil
)))))
1074 (eval-when-compile (require 'gnus
))
1076 (defmacro mh-macro-expansion-time-gnus-version
()
1077 "Return Gnus version available at macro expansion time.
1078 The macro evaluates the Gnus version at macro expansion time. If MH-E was
1079 compiled then macro expansion happens at compile time."
1082 (defun mh-run-time-gnus-version ()
1083 "Return Gnus version available at run time."
1088 (defun mh-version ()
1089 "Display version information about MH-E and the MH mail handling system."
1091 (set-buffer (get-buffer-create mh-info-buffer
))
1094 (insert "MH-E " mh-version
"\n\n")
1095 ;; MH-E compilation details.
1096 (insert "MH-E compilation details:\n")
1097 (let* ((compiled-mhe (byte-code-function-p (symbol-function 'mh-version
)))
1098 (gnus-compiled-version (if compiled-mhe
1099 (mh-macro-expansion-time-gnus-version)
1101 (insert " Byte compiled:\t\t" (if compiled-mhe
"yes" "no") "\n"
1102 " Gnus (compile-time):\t" gnus-compiled-version
"\n"
1103 " Gnus (run-time):\t" (mh-run-time-gnus-version) "\n\n"))
1105 (insert (emacs-version) "\n\n")
1107 (if mh-variant-in-use
1108 (insert mh-variant-in-use
"\n"
1109 " mh-progs:\t" mh-progs
"\n"
1110 " mh-lib:\t" mh-lib
"\n"
1111 " mh-lib-progs:\t" mh-lib-progs
"\n\n")
1112 (insert "No MH variant detected\n"))
1115 (call-process "uname" nil t nil
"-a")
1117 (goto-char (point-min))
1118 (display-buffer mh-info-buffer
))
1120 (defun mh-parse-flist-output-line (line &optional current-folder
)
1121 "Parse LINE to generate folder name, unseen messages and total messages.
1122 If CURRENT-FOLDER is non-nil then it contains the current folder name and it is
1123 used to avoid problems in corner cases involving folders whose names end with a
1127 (goto-char (point-max))
1128 (let (folder unseen total p
)
1129 (when (search-backward " out of " (point-min) t
)
1130 (setq total
(read-from-string
1131 (buffer-substring-no-properties
1132 (match-end 0) (line-end-position))))
1133 (when (search-backward " in sequence " (point-min) t
)
1135 (when (search-backward " has " (point-min) t
)
1136 (setq unseen
(read-from-string (buffer-substring-no-properties
1138 (while (eq (char-after) ?
)
1140 (setq folder
(buffer-substring-no-properties
1141 (point-min) (1+ (point))))
1142 (when (and (equal (aref folder
(1- (length folder
))) ?
+)
1143 (equal current-folder folder
))
1144 (setq folder
(substring folder
0 (1- (length folder
)))))
1145 (values (format "+%s" folder
) (car unseen
) (car total
))))))))
1147 (defun mh-folder-size-folder (folder)
1148 "Find size of FOLDER using `folder'."
1150 (let ((u (length (cdr (assoc mh-unseen-seq
1151 (mh-read-folder-sequences folder nil
))))))
1152 (call-process (expand-file-name "folder" mh-progs
) nil t nil
1153 "-norecurse" folder
)
1154 (goto-char (point-min))
1155 (if (re-search-forward " has \\([0-9]+\\) " nil t
)
1156 (values (car (read-from-string (match-string 1))) u folder
)
1157 (values 0 u folder
)))))
1159 (defun mh-folder-size-flist (folder)
1160 "Find size of FOLDER using `flist'."
1162 (call-process (expand-file-name "flist" mh-progs
) nil t nil
"-showzero"
1163 "-norecurse" folder
"-sequence" (symbol-name mh-unseen-seq
))
1164 (goto-char (point-min))
1165 (multiple-value-bind (folder unseen total
)
1166 (mh-parse-flist-output-line
1167 (buffer-substring (point) (line-end-position)))
1168 (values total unseen folder
))))
1170 (defun mh-folder-size (folder)
1171 "Find size of FOLDER."
1172 (if mh-flists-present-flag
1173 (mh-folder-size-flist folder
)
1174 (mh-folder-size-folder folder
)))
1176 (defun mh-visit-folder (folder &optional range index-data
)
1177 "Visit FOLDER and display RANGE of messages.
1178 Do not call this function from outside MH-E; see \\[mh-rmail] instead.
1180 If RANGE is nil (the default if it is omitted when called non-interactively),
1181 then all messages in FOLDER are displayed.
1183 If an index buffer is being created then INDEX-DATA is used to initialize the
1184 index buffer specific data structures.
1186 A prefix argument will cause a prompt for the RANGE of messages
1187 regardless of the size of the `mh-large-folder' variable."
1188 (interactive (let ((folder-name (mh-prompt-for-folder "Visit" mh-inbox t
)))
1190 (mh-read-range "Scan" folder-name t nil
1192 mh-interpret-number-as-range-flag
))))
1193 (let ((config (current-window-configuration))
1194 (current-buffer (current-buffer))
1195 (threaded-view-flag mh-show-threads-flag
))
1196 (delete-other-windows)
1198 (when (get-buffer folder
)
1200 (setq threaded-view-flag
(memq 'unthread mh-view-ops
))))
1202 (mh-make-folder folder
)
1203 (setq mh-index-data
(car index-data
)
1204 mh-index-msg-checksum-map
(make-hash-table :test
#'equal
)
1205 mh-index-checksum-origin-map
(make-hash-table :test
#'equal
))
1206 (mh-index-update-maps folder
(cadr index-data
))
1207 (mh-index-create-sequences))
1208 (mh-scan-folder folder
(or range
"all"))
1209 (cond ((and threaded-view-flag
1211 (goto-char (point-min))
1212 (or (null mh-large-folder
)
1213 (not (equal (forward-line (1+ mh-large-folder
)) 0))
1214 (and (message "Not threading since the number of messages exceeds `mh-large-folder'")
1216 (mh-toggle-threads))
1218 (mh-index-insert-folder-headers)))
1219 (unless (eq current-buffer
(current-buffer))
1220 (setq mh-previous-window-config config
)))
1224 (defun mh-update-sequences ()
1225 "Update MH's Unseen-Sequence and current folder and message.
1226 Flush MH-E's state out to MH. The message at the cursor becomes current."
1228 ;; mh-update-sequences is the opposite of mh-read-folder-sequences,
1229 ;; which updates MH-E's state from MH.
1230 (let ((folder-set (mh-update-unseen))
1231 (new-cur (mh-get-msg-num nil
)))
1233 (let ((seq-entry (mh-find-seq 'cur
)))
1234 (mh-remove-cur-notation)
1236 (list new-cur
)) ;delete-seq-locally, add-msgs-to-seq
1237 (mh-define-sequence 'cur
(list new-cur
))
1239 (if (looking-at mh-scan-good-msg-regexp
)
1243 ;; psg - mh-current-folder is nil if mh-summary-height < 4 !
1244 ;; So I added this sanity check.
1245 (if (stringp mh-current-folder
)
1246 (mh-exec-cmd-quiet t
"folder" mh-current-folder
"-fast")
1247 (mh-exec-cmd-quiet t
"folder" "-fast")))))))
1251 ;;; Support routines.
1253 (defun mh-delete-a-msg (msg)
1255 If MSG is nil then the message at point is deleted.
1257 The value of `mh-delete-msg-hook' is a list of functions to be called, with no
1258 arguments, after the message has been deleted."
1261 (mh-goto-msg msg nil t
)
1263 (setq msg
(mh-get-msg-num t
)))
1264 (if (looking-at mh-scan-refiled-msg-regexp
)
1265 (error "Message %d is refiled. Undo refile before deleting" msg
))
1266 (if (looking-at mh-scan-deleted-msg-regexp
)
1268 (mh-set-folder-modified-p t
)
1269 (setq mh-delete-list
(cons msg mh-delete-list
))
1270 (mh-notate nil mh-note-deleted mh-cmd-note
)
1271 (run-hooks 'mh-delete-msg-hook
))))
1273 (defun mh-refile-a-msg (msg folder
)
1274 "Refile MSG in FOLDER.
1275 If MSG is nil then the message at point is refiled.
1277 Folder is a symbol, not a string.
1278 The value of `mh-refile-msg-hook' is a list of functions to be called, with no
1279 arguments, after the message has been refiled."
1282 (mh-goto-msg msg nil t
)
1284 (setq msg
(mh-get-msg-num t
)))
1285 (cond ((looking-at mh-scan-deleted-msg-regexp
)
1286 (error "Message %d is deleted. Undo delete before moving" msg
))
1287 ((looking-at mh-scan-refiled-msg-regexp
)
1289 (format "Message %d already refiled. Copy to %s as well? "
1291 (mh-exec-cmd "refile" (mh-get-msg-num t
) "-link"
1292 "-src" mh-current-folder
1293 (symbol-name folder
))
1294 (message "Message not copied")))
1296 (mh-set-folder-modified-p t
)
1297 (cond ((null (assoc folder mh-refile-list
))
1298 (push (list folder msg
) mh-refile-list
))
1299 ((not (member msg
(cdr (assoc folder mh-refile-list
))))
1300 (push msg
(cdr (assoc folder mh-refile-list
)))))
1301 (mh-notate nil mh-note-refiled mh-cmd-note
)
1302 (run-hooks 'mh-refile-msg-hook
)))))
1304 (defun mh-next-msg (&optional wait-after-complaining-flag
)
1305 "Move backward or forward to the next undeleted message in the buffer.
1306 If optional argument WAIT-AFTER-COMPLAINING-FLAG is non-nil and we are at the
1307 last message, then wait for a second after telling the user that there aren't
1308 any more unread messages."
1309 (if (eq mh-next-direction
'forward
)
1310 (mh-next-undeleted-msg 1 wait-after-complaining-flag
)
1311 (mh-previous-undeleted-msg 1 wait-after-complaining-flag
)))
1313 (defun mh-next-unread-msg (&optional count
)
1314 "Move to next unread message.
1315 With optional argument COUNT, COUNT-1 unread messages are skipped."
1318 (error "The function mh-next-unread-msg expects positive argument"))
1319 (setq count
(1- count
))
1320 (let ((unread-sequence (reverse (cdr (assoc mh-unseen-seq mh-seq-list
))))
1321 (cur-msg (mh-get-msg-num nil
)))
1322 (cond ((and (not cur-msg
) (not (bobp))
1323 ;; If we are at the end of the buffer back up one line and go
1324 ;; to unread message after that.
1327 (setq cur-msg
(mh-get-msg-num nil
)))
1329 ((or (null unread-sequence
) (not cur-msg
))
1330 ;; No unread message or there aren't any messages in buffer...
1331 (message "No more unread messages"))
1334 (while (and unread-sequence
(>= cur-msg
(car unread-sequence
)))
1335 (setq unread-sequence
(cdr unread-sequence
)))
1337 (setq unread-sequence
(cdr unread-sequence
))
1338 (setq count
(1- count
)))
1339 (not (car unread-sequence
)))
1340 (message "No more unread messages"))
1341 (t (loop for msg in unread-sequence
1342 when
(mh-goto-msg msg t
) return nil
1343 finally
(message "No more unread messages"))))))
1345 (defun mh-set-scan-mode ()
1346 "Display the scan listing buffer, but do not show a message."
1347 (if (get-buffer mh-show-buffer
)
1348 (delete-windows-on mh-show-buffer
))
1350 (force-mode-line-update)
1351 (if mh-recenter-summary-flag
1354 (defun mh-undo-msg (msg)
1355 "Undo the deletion or refile of one MSG.
1356 If MSG is nil then act on the message at point"
1359 (mh-goto-msg msg t t
)
1361 (setq msg
(mh-get-msg-num t
)))
1362 (cond ((memq msg mh-delete-list
)
1363 (setq mh-delete-list
(delq msg mh-delete-list
)))
1365 (dolist (folder-msg-list mh-refile-list
)
1366 (setf (cdr folder-msg-list
) (remove msg
(cdr folder-msg-list
))))
1367 (setq mh-refile-list
(loop for x in mh-refile-list
1368 unless
(null (cdr x
)) collect x
))))
1369 (mh-notate nil ? mh-cmd-note
)))
1373 ;;; The folder data abstraction.
1375 (defvar mh-index-data-file
".mhe_index"
1376 "MH-E specific file where index seach info is stored.")
1378 (defun mh-make-folder (name)
1379 "Create a new mail folder called NAME.
1380 Make it the current folder."
1381 (switch-to-buffer name
)
1382 (setq buffer-read-only nil
)
1384 (if mh-adaptive-cmd-note-flag
1385 (mh-set-cmd-note (mh-message-number-width name
)))
1386 (setq buffer-read-only t
)
1388 (mh-set-folder-modified-p nil
)
1389 (setq buffer-file-name mh-folder-filename
)
1390 (when (and (not mh-index-data
)
1391 (file-exists-p (concat buffer-file-name mh-index-data-file
)))
1392 (mh-index-read-data))
1393 (mh-make-folder-mode-line))
1395 ;;; Ensure new buffers won't get this mode if default-major-mode is nil.
1396 (put 'mh-folder-mode
'mode-class
'special
)
1400 ;;; Menu extracted from mh-menubar.el V1.1 (31 July 2001)
1401 ;;; Menus for folder mode: folder, message, sequence (in that order)
1402 ;;; folder-mode "Sequence" menu
1404 mh-folder-sequence-menu mh-folder-mode-map
"Menu for MH-E folder-sequence."
1406 ["Add Message to Sequence..." mh-put-msg-in-seq
(mh-get-msg-num nil
)]
1407 ["List Sequences for Message" mh-msg-is-in-seq
(mh-get-msg-num nil
)]
1408 ["Delete Message from Sequence..." mh-delete-msg-from-seq
1409 (mh-get-msg-num nil
)]
1410 ["List Sequences in Folder..." mh-list-sequences t
]
1411 ["Delete Sequence..." mh-delete-seq t
]
1412 ["Narrow to Sequence..." mh-narrow-to-seq t
]
1413 ["Widen from Sequence" mh-widen mh-folder-view-stack
]
1415 ["Narrow to Subject Sequence" mh-narrow-to-subject t
]
1416 ["Narrow to Tick Sequence" mh-narrow-to-tick
1417 (and mh-tick-seq
(mh-seq-msgs (mh-find-seq mh-tick-seq
)))]
1418 ["Delete Rest of Same Subject" mh-delete-subject t
]
1419 ["Toggle Tick Mark" mh-toggle-tick t
]
1421 ["Push State Out to MH" mh-update-sequences t
]))
1423 ;;; folder-mode "Message" menu
1425 mh-folder-message-menu mh-folder-mode-map
"Menu for MH-E folder-message."
1427 ["Show Message" mh-show
(mh-get-msg-num nil
)]
1428 ["Show Message with Header" mh-header-display
(mh-get-msg-num nil
)]
1429 ["Next Message" mh-next-undeleted-msg t
]
1430 ["Previous Message" mh-previous-undeleted-msg t
]
1431 ["Go to First Message" mh-first-msg t
]
1432 ["Go to Last Message" mh-last-msg t
]
1433 ["Go to Message by Number..." mh-goto-msg t
]
1434 ["Modify Message" mh-modify t
]
1435 ["Delete Message" mh-delete-msg
(mh-get-msg-num nil
)]
1436 ["Refile Message" mh-refile-msg
(mh-get-msg-num nil
)]
1437 ["Undo Delete/Refile" mh-undo
(mh-outstanding-commands-p)]
1438 ["Execute Delete/Refile" mh-execute-commands
1439 (mh-outstanding-commands-p)]
1441 ["Compose a New Message" mh-send t
]
1442 ["Reply to Message..." mh-reply
(mh-get-msg-num nil
)]
1443 ["Forward Message..." mh-forward
(mh-get-msg-num nil
)]
1444 ["Redistribute Message..." mh-redistribute
(mh-get-msg-num nil
)]
1445 ["Edit Message Again" mh-edit-again
(mh-get-msg-num nil
)]
1446 ["Re-edit a Bounced Message" mh-extract-rejected-mail t
]
1448 ["Copy Message to Folder..." mh-copy-msg
(mh-get-msg-num nil
)]
1449 ["Print Message" mh-print-msg
(mh-get-msg-num nil
)]
1450 ["Write Message to File..." mh-write-msg-to-file
1451 (mh-get-msg-num nil
)]
1452 ["Pipe Message to Command..." mh-pipe-msg
(mh-get-msg-num nil
)]
1453 ["Unpack Uuencoded Message..." mh-store-msg
(mh-get-msg-num nil
)]
1454 ["Burst Digest Message" mh-burst-digest
(mh-get-msg-num nil
)]))
1456 ;;; folder-mode "Folder" menu
1458 mh-folder-folder-menu mh-folder-mode-map
"Menu for MH-E folder."
1460 ["Incorporate New Mail" mh-inc-folder t
]
1461 ["Toggle Show/Folder" mh-toggle-showing t
]
1462 ["Execute Delete/Refile" mh-execute-commands
1463 (mh-outstanding-commands-p)]
1464 ["Rescan Folder" mh-rescan-folder t
]
1465 ["Thread Folder" mh-toggle-threads
1466 (not (memq 'unthread mh-view-ops
))]
1467 ["Pack Folder" mh-pack-folder t
]
1468 ["Sort Folder" mh-sort-folder t
]
1470 ["List Folders" mh-list-folders t
]
1471 ["Visit a Folder..." mh-visit-folder t
]
1472 ["View New Messages" mh-index-new-messages t
]
1473 ["Search a Folder..." mh-search-folder t
]
1474 ["Indexed Search..." mh-index-search t
]
1476 ["Quit MH-E" mh-quit t
]))
1480 (defmacro mh-remove-xemacs-horizontal-scrollbar
()
1481 "Get rid of the horizontal scrollbar that XEmacs insists on putting in."
1482 (when mh-xemacs-flag
1483 `(if (and (featurep 'scrollbar
)
1484 (fboundp 'set-specifier
))
1485 (set-specifier horizontal-scrollbar-visible-p nil
1486 (cons (current-buffer) nil
)))))
1488 (defmacro mh-write-file-functions-compat
()
1489 "Return `write-file-functions' if it exists.
1490 Otherwise return `local-write-file-hooks'. This macro exists purely for
1491 compatibility. The former symbol is used in Emacs 21.4 onward while the latter
1492 is used in previous versions and XEmacs."
1493 (if (boundp 'write-file-functions
)
1494 ''write-file-functions
;Emacs 21.4
1495 ''local-write-file-hooks
)) ;<Emacs 21.4, XEmacs
1497 ;; Avoid compiler warnings in non-bleeding edge versions of Emacs.
1499 (defvar tool-bar-mode
)
1500 (defvar tool-bar-map
)
1501 (defvar desktop-save-buffer
)) ;Emacs 21.4
1503 ;; Register mh-folder-mode as supporting which-function-mode...
1504 (load "which-func" t t
)
1505 (when (and (boundp 'which-func-modes
)
1506 (not (member 'mh-folder-mode which-func-modes
)))
1507 (push 'mh-folder-mode which-func-modes
))
1509 (define-derived-mode mh-folder-mode fundamental-mode
"MH-Folder"
1510 "Major MH-E mode for \"editing\" an MH folder scan listing.\\<mh-folder-mode-map>
1512 You can show the message the cursor is pointing to, and step through the
1513 messages. Messages can be marked for deletion or refiling into another
1514 folder; these commands are executed all at once with a separate command.
1516 Options that control this mode can be changed with \\[customize-group];
1517 specify the \"mh\" group. In particular, please see the `mh-scan-format-file'
1518 option if you wish to modify scan's format.
1520 When a folder is visited, the hook `mh-folder-mode-hook' is run.
1524 Many commands that operate on individual messages, such as `mh-forward' or
1525 `mh-refile-msg' take a RANGE argument. This argument can be used in several
1528 If you provide the prefix argument (\\[universal-argument]) to these commands,
1529 then you will be prompted for the message range. This can be any legal MH
1530 range which can include messages, sequences, and the abbreviations (described
1531 in the mh(1) man page):
1534 Indicates all messages in the range <num1> to <num2>, inclusive. The range
1540 Up to N messages beginning with (or ending with) message num. Num may be
1541 any of the pre-defined symbols: first, prev, cur, next or last.
1547 The first, previous, next or last messages, if they exist.
1550 All of the messages.
1552 For example, a range that shows all of these things is `1 2 3 5-10 last:5
1555 If the option `transient-mark-mode' is set to t and you set a region in the
1556 MH-Folder buffer, then the MH-E command will perform the operation on all
1557 messages in that region.
1559 \\{mh-folder-mode-map}"
1561 (make-local-variable 'font-lock-defaults
)
1562 (setq font-lock-defaults
'(mh-folder-font-lock-keywords t
))
1563 (make-local-variable 'desktop-save-buffer
)
1564 (setq desktop-save-buffer t
)
1566 'mh-colors-available-flag
(mh-colors-available-p)
1567 ; Do we have colors available
1568 'mh-current-folder
(buffer-name) ; Name of folder, a string
1569 'mh-show-buffer
(format "show-%s" (buffer-name)) ; Buffer that displays msgs
1570 'mh-folder-filename
; e.g. "/usr/foobar/Mail/inbox/"
1571 (file-name-as-directory (mh-expand-file-name (buffer-name)))
1572 'mh-display-buttons-for-inline-parts-flag
1573 mh-display-buttons-for-inline-parts-flag
; Allow for display of buttons to
1575 'mh-arrow-marker
(make-marker) ; Marker where arrow is displayed
1576 'overlay-arrow-position nil
; Allow for simultaneous display in
1577 'overlay-arrow-string
">" ; different MH-E buffers.
1578 'mh-showing-mode nil
; Show message also?
1579 'mh-delete-list nil
; List of msgs nums to delete
1580 'mh-refile-list nil
; List of folder names in mh-seq-list
1581 'mh-seq-list nil
; Alist of (seq . msgs) nums
1582 'mh-seen-list nil
; List of displayed messages
1583 'mh-next-direction
'forward
; Direction to move to next message
1584 'mh-view-ops
() ; Stack that keeps track of the order
1585 ; in which narrowing/threading has been
1587 'mh-folder-view-stack
() ; Stack of previous views of the
1589 'mh-index-data nil
; If the folder was created by a call
1590 ; to mh-index-search this contains info
1591 ; about the search results.
1592 'mh-index-previous-search nil
; Previous folder and search-regexp
1593 'mh-index-msg-checksum-map nil
; msg -> checksum map
1594 'mh-index-checksum-origin-map nil
; checksum -> ( orig-folder, orig-msg )
1595 'mh-index-sequence-search-flag nil
; folder resulted from sequence search
1596 'mh-first-msg-num nil
; Number of first msg in buffer
1597 'mh-last-msg-num nil
; Number of last msg in buffer
1598 'mh-msg-count nil
; Number of msgs in buffer
1599 'mh-mode-line-annotation nil
; Indicates message range
1600 'mh-sequence-notation-history
(make-hash-table)
1601 ; Remember what is overwritten by
1603 'imenu-create-index-function
'mh-index-create-imenu-index
1604 ; Setup imenu support
1605 'mh-previous-window-config nil
) ; Previous window configuration
1606 (mh-remove-xemacs-horizontal-scrollbar)
1607 (setq truncate-lines t
)
1609 (setq buffer-offer-save t
)
1610 (mh-make-local-hook (mh-write-file-functions-compat))
1611 (add-hook (mh-write-file-functions-compat) 'mh-execute-commands nil t
)
1612 (make-local-variable 'revert-buffer-function
)
1613 (make-local-variable 'hl-line-mode
) ; avoid pollution
1614 (mh-funcall-if-exists hl-line-mode
1)
1615 (setq revert-buffer-function
'mh-undo-folder
)
1616 (or (assq 'mh-showing-mode minor-mode-alist
)
1617 (setq minor-mode-alist
1618 (cons '(mh-showing-mode " Show") minor-mode-alist
)))
1619 (easy-menu-add mh-folder-sequence-menu
)
1620 (easy-menu-add mh-folder-message-menu
)
1621 (easy-menu-add mh-folder-folder-menu
)
1622 (set (make-local-variable 'tool-bar-map
) mh-folder-tool-bar-map
)
1623 (mh-funcall-if-exists mh-toolbar-init
:folder
)
1624 (if (and mh-xemacs-flag
1625 font-lock-auto-fontify
)
1626 (turn-on-font-lock))) ; Force font-lock in XEmacs.
1628 (defun mh-toggle-mime-buttons ()
1629 "Toggle display of buttons for inline MIME parts."
1631 (setq mh-display-buttons-for-inline-parts-flag
1632 (not mh-display-buttons-for-inline-parts-flag
))
1635 (defun mh-colors-available-p ()
1636 "Check if colors are available in the Emacs being used."
1639 (or (ignore-errors (mh-funcall-if-exists display-color-cells
))
1640 (ignore-errors (mh-funcall-if-exists
1641 x-display-color-cells
)))))
1642 (and (numberp color-cells
) (>= color-cells
8)))))
1644 (defun mh-colors-in-use-p ()
1645 "Check if colors are being used in the folder buffer."
1646 (and mh-colors-available-flag font-lock-mode
))
1648 (defun mh-make-local-vars (&rest pairs
)
1649 "Initialize local variables according to the variable-value PAIRS."
1652 (set (make-local-variable (car pairs
)) (car (cdr pairs
)))
1653 (setq pairs
(cdr (cdr pairs
)))))
1656 (defun mh-restore-desktop-buffer (desktop-buffer-file-name
1658 desktop-buffer-misc
)
1659 "Restore an MH folder buffer specified in a desktop file.
1660 When desktop creates a buffer, DESKTOP-BUFFER-FILE-NAME holds the file name to
1661 visit, DESKTOP-BUFFER-NAME holds the desired buffer name, and
1662 DESKTOP-BUFFER-MISC holds a list of miscellaneous info used by the
1663 `desktop-buffer-handlers' functions."
1665 (mh-visit-folder desktop-buffer-name
)
1668 (defun mh-scan-folder (folder range
&optional dont-exec-pending
)
1669 "Scan the FOLDER over the RANGE.
1670 If the optional argument DONT-EXEC-PENDING is non-nil then pending deletes and
1671 refiles aren't carried out.
1672 Return in the folder's buffer."
1673 (when (stringp range
)
1674 (setq range
(delete "" (split-string range
"[ \t\n]"))))
1675 (cond ((null (get-buffer folder
))
1676 (mh-make-folder folder
))
1678 (unless dont-exec-pending
1679 (mh-process-or-undo-commands folder
)
1680 (mh-reset-threads-and-narrowing))
1681 (switch-to-buffer folder
)))
1682 (mh-regenerate-headers range
)
1683 (if (zerop (buffer-size))
1684 (if (equal range
"all")
1685 (message "Folder %s is empty" folder
)
1686 (message "No messages in %s, range %s" folder range
))
1688 (when (mh-outstanding-commands-p)
1689 (mh-notate-deleted-and-refiled)))
1691 (defun mh-set-cmd-note (width)
1692 "Set `mh-cmd-note' to WIDTH characters (minimum of 2).
1694 If `mh-scan-format-file' specifies nil or a filename, then this function
1695 will NOT update `mh-cmd-note'."
1696 ;; Add one to the width to always have whitespace in column zero.
1697 (setq width
(max (1+ width
) 2))
1698 (if (and (equal mh-scan-format-file t
)
1699 (not (eq mh-cmd-note width
)))
1700 (setq mh-cmd-note width
))
1703 (defun mh-regenerate-headers (range &optional update
)
1704 "Scan folder over range RANGE.
1705 If UPDATE, append the scan lines, otherwise replace."
1706 (let ((folder mh-current-folder
)
1707 (range (if (and range
(atom range
)) (list range
) range
))
1709 (message "Scanning %s..." folder
)
1710 (mh-remove-all-notation)
1711 (with-mh-folder-updating (nil)
1713 (goto-char (point-max))
1714 (delete-region (point-min) (point-max))
1715 (if mh-adaptive-cmd-note-flag
1716 (mh-set-cmd-note (mh-message-number-width folder
))))
1717 (setq scan-start
(point))
1718 (apply #'mh-exec-cmd-output
1721 "-noclear" "-noheader"
1722 "-width" (window-width)
1724 (goto-char scan-start
)
1725 (cond ((looking-at "scan: no messages in")
1726 (keep-lines mh-scan-valid-regexp
)) ; Flush random scan lines
1727 ((looking-at (if (mh-variant-p 'mu-mh
)
1728 "scan: message set .* does not exist"
1729 "scan: bad message list "))
1730 (keep-lines mh-scan-valid-regexp
))
1731 ((looking-at "scan: ")) ; Keep error messages
1733 (keep-lines mh-scan-valid-regexp
))) ; Flush random scan lines
1734 (setq mh-seq-list
(mh-read-folder-sequences folder nil
))
1735 (mh-notate-user-sequences)
1737 (setq mh-mode-line-annotation
1738 (if (equal range
'("all"))
1740 mh-partial-folder-mode-line-annotation
)))
1741 (mh-make-folder-mode-line))
1742 (message "Scanning %s...done" folder
)))
1744 (defun mh-generate-new-cmd-note (folder)
1745 "Fix the `mh-cmd-note' value for this FOLDER.
1747 After doing an `mh-get-new-mail' operation in this FOLDER, at least
1748 one line that looks like a truncated message number was found.
1750 Remove the text added by the last `mh-inc' command. It should be the
1751 messages cur-last. Call `mh-set-cmd-note' with the widest message number
1754 Reformat the message number width on each line in the buffer and trim
1755 the line length to fit in the window.
1757 Rescan the FOLDER in the range cur-last in order to display the
1758 messages that were removed earlier. They should all fit in the scan
1759 line now with no message truncation."
1761 (let ((maxcol (1- (window-width)))
1762 (old-cmd-note mh-cmd-note
)
1765 ;; Nuke all of the lines just added by the last inc
1766 (delete-char (- (point-max) (point)))
1767 ;; Update the current buffer to reflect the new mh-cmd-note
1768 ;; value needed to display messages.
1769 (mh-set-cmd-note (mh-message-number-width folder
))
1770 (setq mh-cmd-note-fmt
(concat "%" (format "%d" mh-cmd-note
) "d"))
1771 ;; Cleanup the messages that are in the buffer right now
1772 (goto-char (point-min))
1773 (cond ((memq 'unthread mh-view-ops
)
1774 (mh-thread-add-spaces (- mh-cmd-note old-cmd-note
)))
1775 (t (while (re-search-forward mh-scan-msg-number-regexp nil
0 1)
1776 ;; reformat the number to fix in mh-cmd-note columns
1777 (setq msgnum
(string-to-number
1779 (match-beginning 1) (match-end 1))))
1780 (replace-match (format mh-cmd-note-fmt msgnum
))
1781 ;; trim the line to fix in the window
1783 (let ((eol (point)))
1784 (move-to-column maxcol
)
1785 (if (<= (point) eol
)
1786 (delete-char (- eol
(point))))))))
1787 ;; now re-read the lost messages
1788 (goto-char (point-max))
1790 (mh-regenerate-headers "cur-last" t
)))))
1792 (defun mh-get-new-mail (maildrop-name)
1793 "Read new mail from MAILDROP-NAME into the current buffer.
1794 Return in the current buffer."
1795 (let ((point-before-inc (point))
1796 (folder mh-current-folder
)
1797 (new-mail-flag nil
))
1798 (with-mh-folder-updating (t)
1800 (message "inc %s -file %s..." folder maildrop-name
)
1801 (message "inc %s..." folder
))
1802 (setq mh-next-direction
'forward
)
1803 (goto-char (point-max))
1804 (mh-remove-all-notation)
1805 (let ((start-of-inc (point)))
1807 ;; I think MH 5 used "-ms-file" instead of "-file",
1808 ;; which would make inc'ing from maildrops fail.
1809 (mh-exec-cmd-output mh-inc-prog nil folder
1811 "-file" (expand-file-name maildrop-name
)
1812 "-width" (window-width)
1814 (mh-exec-cmd-output mh-inc-prog nil
1816 "-width" (window-width)))
1818 (message "inc %s -file %s...done" folder maildrop-name
)
1819 (message "inc %s...done" folder
))
1820 (goto-char start-of-inc
)
1821 (cond ((save-excursion
1822 (re-search-forward "^inc: no mail" nil t
))
1823 (message "No new mail%s%s" (if maildrop-name
" in " "")
1824 (if maildrop-name maildrop-name
"")))
1825 ((and (when mh-folder-view-stack
1826 (let ((saved-text (buffer-substring-no-properties
1827 start-of-inc
(point-max))))
1828 (delete-region start-of-inc
(point-max))
1829 (unwind-protect (mh-widen t
)
1830 (mh-remove-all-notation)
1831 (goto-char (point-max))
1832 (setq start-of-inc
(point))
1834 (goto-char start-of-inc
))))
1836 ((re-search-forward "^inc:" nil t
) ; Error messages
1837 (error "Error incorporating mail"))
1839 (equal mh-scan-format-file t
)
1840 mh-adaptive-cmd-note-flag
1841 ;; Have we reached an edge condition?
1843 (re-search-forward mh-scan-msg-overflow-regexp nil
0 1))
1844 (setq start-of-inc
(mh-generate-new-cmd-note folder
))
1847 (setq new-mail-flag t
)))
1848 (keep-lines mh-scan-valid-regexp
) ; Flush random scan lines
1849 (setq mh-seq-list
(mh-read-folder-sequences folder t
))
1850 (when (equal (point-max) start-of-inc
)
1854 (mh-make-folder-mode-line)
1855 (when (mh-speed-flists-active-p)
1856 (mh-speed-flists t mh-current-folder
))
1857 (when (memq 'unthread mh-view-ops
)
1858 (mh-thread-inc folder start-of-inc
))
1860 (goto-char point-before-inc
))
1861 (mh-notate-user-sequences)
1862 (mh-notate-deleted-and-refiled)))))
1864 (defun mh-make-folder-mode-line (&optional ignored
)
1865 "Set the fields of the mode line for a folder buffer.
1866 The optional argument is now obsolete and IGNORED. It used to be used to pass
1867 in what is now stored in the buffer-local variable `mh-mode-line-annotation'."
1869 (save-window-excursion
1871 (let ((new-first-msg-num (mh-get-msg-num nil
)))
1872 (when (or (not (memq 'unthread mh-view-ops
))
1873 (null mh-first-msg-num
)
1874 (null new-first-msg-num
)
1875 (< new-first-msg-num mh-first-msg-num
))
1876 (setq mh-first-msg-num new-first-msg-num
)))
1878 (let ((new-last-msg-num (mh-get-msg-num nil
)))
1879 (when (or (not (memq 'unthread mh-view-ops
))
1880 (null mh-last-msg-num
)
1881 (null new-last-msg-num
)
1882 (> new-last-msg-num mh-last-msg-num
))
1883 (setq mh-last-msg-num new-last-msg-num
)))
1884 (setq mh-msg-count
(if mh-first-msg-num
1885 (count-lines (point-min) (point-max))
1887 (setq mode-line-buffer-identification
1888 (list (format " {%%b%s} %s msg%s"
1889 (if mh-mode-line-annotation
1890 (format "/%s" mh-mode-line-annotation
)
1892 (if (zerop mh-msg-count
)
1894 (format "%d" mh-msg-count
))
1895 (if (zerop mh-msg-count
)
1897 (cond ((> mh-msg-count
1)
1898 (format "s (%d-%d)" mh-first-msg-num
1901 (format " (%d)" mh-first-msg-num
))
1903 (mh-logo-display))))
1905 (defun mh-add-sequence-notation (msg internal-seq-flag
)
1906 "Add sequence notation to the MSG on the current line.
1907 If INTERNAL-SEQ-FLAG is non-nil, then refontify the scan line if font-lock is
1909 (with-mh-folder-updating (t)
1912 (if internal-seq-flag
1914 ;; Change the buffer so that if transient-mark-mode is active
1915 ;; and there is an active region it will get deactivated as in
1916 ;; the case of user sequences.
1917 (mh-notate nil nil mh-cmd-note
)
1918 (when font-lock-mode
1919 (font-lock-fontify-region (point) (line-end-position))))
1920 (forward-char (1+ mh-cmd-note
))
1921 (let ((stack (gethash msg mh-sequence-notation-history
)))
1922 (setf (gethash msg mh-sequence-notation-history
)
1923 (cons (char-after) stack
)))
1924 (mh-notate nil mh-note-seq
(1+ mh-cmd-note
))))))
1926 (defun mh-remove-sequence-notation (msg internal-seq-flag
&optional all
)
1927 "Remove sequence notation from the MSG on the current line.
1928 If INTERNAL-SEQ-FLAG is non-nil, then `font-lock' was used to highlight the
1929 sequence. In that case, no notation needs to be removed. Otherwise the effect
1930 of inserting `mh-note-seq' needs to be reversed.
1931 If ALL is non-nil, then all sequence marks on the scan line are removed."
1932 (with-mh-folder-updating (t)
1933 ;; This takes care of internal sequences...
1934 (mh-notate nil nil mh-cmd-note
)
1935 (unless internal-seq-flag
1936 ;; ... and this takes care of user sequences.
1937 (let ((stack (gethash msg mh-sequence-notation-history
)))
1938 (while (and all
(cdr stack
))
1939 (setq stack
(cdr stack
)))
1943 (forward-char (1+ mh-cmd-note
))
1945 (insert (car stack
))))
1946 (setf (gethash msg mh-sequence-notation-history
) (cdr stack
))))))
1948 (defun mh-remove-cur-notation ()
1949 "Remove old cur notation."
1950 (let ((cur-msg (car (mh-seq-to-msgs 'cur
))))
1953 (mh-goto-msg cur-msg t t
)
1954 (looking-at mh-scan-cur-msg-number-regexp
))
1955 (mh-notate nil ? mh-cmd-note
)
1956 (setq overlay-arrow-position nil
)))))
1958 (defun mh-remove-all-notation ()
1959 "Remove all notations on all scan lines that MH-E introduces."
1961 (setq overlay-arrow-position nil
)
1962 (goto-char (point-min))
1963 (mh-iterate-on-range msg
(cons (point-min) (point-max))
1964 (mh-notate nil ? mh-cmd-note
)
1965 (mh-remove-sequence-notation msg nil t
))
1966 (clrhash mh-sequence-notation-history
)))
1969 (defun mh-goto-cur-msg (&optional minimal-changes-flag
)
1970 "Position the cursor at the current message.
1971 When optional argument MINIMAL-CHANGES-FLAG is non-nil, the function doesn't
1972 recenter the folder buffer."
1973 (let ((cur-msg (car (mh-seq-to-msgs 'cur
))))
1975 (mh-goto-msg cur-msg t t
))
1976 (unless minimal-changes-flag
1979 (mh-maybe-show cur-msg
)))
1981 (setq overlay-arrow-position nil
)
1982 (message "No current message")))))
1984 (defun mh-process-or-undo-commands (folder)
1985 "If FOLDER has outstanding commands, then either process or discard them.
1986 Called by functions like `mh-sort-folder', so also invalidate show buffer."
1988 (if (mh-outstanding-commands-p)
1989 (if (or mh-do-not-confirm-flag
1991 "Process outstanding deletes and refiles? "))
1992 (mh-process-commands folder
)
1996 (mh-invalidate-show-buffer))
1998 (defun mh-process-commands (folder)
1999 "Process outstanding commands for FOLDER.
2000 The value of `mh-folder-updated-hook' is a list of functions to be called,
2001 with no arguments, before the commands are processed."
2002 (message "Processing deletes and refiles for %s..." folder
)
2004 (with-mh-folder-updating (nil)
2005 ;; Run the hook while the lists are still valid
2006 (run-hooks 'mh-folder-updated-hook
)
2008 ;; Update the unseen sequence if it exists
2011 (let ((redraw-needed-flag mh-index-data
)
2012 (folders-changed (list mh-current-folder
))
2013 (seq-map (and mh-refile-list mh-refile-preserves-sequences-flag
2014 (mh-create-sequence-map mh-seq-list
)))
2015 (dest-map (and mh-refile-list mh-refile-preserves-sequences-flag
2016 (make-hash-table))))
2017 ;; Remove invalid scan lines if we are in an index folder and then remove
2018 ;; the real messages
2020 (mh-index-delete-folder-headers)
2021 (setq folders-changed
2022 (append folders-changed
(mh-index-execute-commands))))
2024 ;; Then refile messages
2025 (mh-mapc #'(lambda (folder-msg-list)
2026 (let* ((dest-folder (symbol-name (car folder-msg-list
)))
2027 (last (car (mh-translate-range dest-folder
"last")))
2028 (msgs (cdr folder-msg-list
)))
2029 (push dest-folder folders-changed
)
2030 (setq redraw-needed-flag t
)
2031 (apply #'mh-exec-cmd
2032 "refile" "-src" folder dest-folder
2033 (mh-coalesce-msg-list msgs
))
2034 (mh-delete-scan-msgs msgs
)
2035 ;; Preserve sequences in destination folder...
2036 (when (and mh-refile-preserves-sequences-flag
2039 (loop for i from
(1+ last
)
2040 for msg in
(sort (copy-sequence msgs
) #'<)
2041 do
(loop for seq-name in
(gethash msg seq-map
)
2042 do
(push i
(gethash seq-name dest-map
))))
2044 #'(lambda (seq msgs
)
2045 ;; Run it in the background, since we don't care
2046 ;; about the results.
2047 (apply #'mh-exec-cmd-daemon
"mark" #'ignore
2048 "-sequence" (symbol-name seq
) dest-folder
2049 "-add" (mapcar #'(lambda (x) (format "%s" x
))
2050 (mh-coalesce-msg-list msgs
))))
2053 (setq mh-refile-list
())
2055 ;; Now delete messages
2056 (cond (mh-delete-list
2057 (setq redraw-needed-flag t
)
2058 (apply 'mh-exec-cmd
"rmm" folder
2059 (mh-coalesce-msg-list mh-delete-list
))
2060 (mh-delete-scan-msgs mh-delete-list
)
2061 (setq mh-delete-list nil
)))
2063 ;; Don't need to remove sequences since delete and refile do so.
2065 (if (> (buffer-size) 0)
2066 (mh-define-sequence 'cur
(list (or (mh-get-msg-num nil
) "last"))))
2068 ;; Redraw folder buffer if needed
2069 (when (and redraw-needed-flag
)
2070 (when (mh-speed-flists-active-p)
2071 (apply #'mh-speed-flists t folders-changed
))
2072 (cond ((memq 'unthread mh-view-ops
) (mh-thread-inc folder
(point-max)))
2073 (mh-index-data (mh-index-insert-folder-headers)))))
2075 (and (buffer-file-name (get-buffer mh-show-buffer
))
2076 (not (file-exists-p (buffer-file-name (get-buffer mh-show-buffer
))))
2077 ;; If "inc" were to put a new msg in this file,
2078 ;; we would not notice, so mark it invalid now.
2079 (mh-invalidate-show-buffer))
2081 (setq mh-seq-list
(mh-read-folder-sequences mh-current-folder nil
))
2082 (mh-remove-all-notation)
2083 (mh-notate-user-sequences)
2084 (message "Processing deletes and refiles for %s...done" folder
)))
2086 (defun mh-update-unseen ()
2087 "Synchronize the unseen sequence with MH.
2088 Return non-nil iff the MH folder was set.
2089 The value of `mh-unseen-updated-hook' is a list of functions to be called,
2090 with no arguments, after the unseen sequence is updated."
2092 (let* ((unseen-seq (mh-find-seq mh-unseen-seq
))
2093 (unseen-msgs (mh-seq-msgs unseen-seq
)))
2096 (mh-undefine-sequence mh-unseen-seq mh-seen-list
)
2097 (run-hooks 'mh-unseen-updated-hook
)
2099 (setq unseen-msgs
(delq (car mh-seen-list
) unseen-msgs
))
2100 (setq mh-seen-list
(cdr mh-seen-list
)))
2101 (setcdr unseen-seq unseen-msgs
)
2102 t
) ;since we set the folder
2103 (setq mh-seen-list nil
)))))
2105 (defun mh-delete-scan-msgs (msgs)
2106 "Delete the scan listing lines for MSGS."
2109 (when (mh-goto-msg (car msgs
) t t
)
2110 (when (memq 'unthread mh-view-ops
)
2111 (mh-thread-forget-message (car msgs
)))
2113 (setq msgs
(cdr msgs
)))))
2115 (defun mh-outstanding-commands-p ()
2116 "Return non-nil if there are outstanding deletes or refiles."
2118 (when (eq major-mode
'mh-show-mode
)
2119 (set-buffer mh-show-folder-buffer
))
2120 (or mh-delete-list mh-refile-list
)))
2122 (defun mh-coalesce-msg-list (messages)
2123 "Given a list of MESSAGES, return a list of message number ranges.
2124 This is the inverse of `mh-read-msg-list', which expands ranges.
2125 Message lists passed to MH programs should be processed by this function
2126 to avoid exceeding system command line argument limits."
2127 (let ((msgs (sort (copy-sequence messages
) 'mh-greaterp
))
2133 (if (or (not (numberp prev
))
2134 (not (equal (car msgs
) (1- prev
))))
2135 (progn ;non-sequential, flush old range
2136 (if (eq prev range-high
)
2137 (setq ranges
(cons range-high ranges
))
2138 (setq ranges
(cons (format "%s-%s" prev range-high
) ranges
)))
2139 (setq range-high nil
))))
2141 (setq range-high
(car msgs
))) ;start new or first range
2142 (setq prev
(car msgs
))
2143 (setq msgs
(cdr msgs
)))
2146 (defun mh-greaterp (msg1 msg2
)
2147 "Return the greater of two message indicators MSG1 and MSG2.
2148 Strings are \"smaller\" than numbers.
2149 Legal values are things like \"cur\", \"last\", 1, and 1820."
2156 (string-lessp msg2 msg1
))))
2158 (defun mh-lessp (msg1 msg2
)
2159 "Return the lesser of two message indicators MSG1 and MSG2.
2160 Strings are \"smaller\" than numbers.
2161 Legal values are things like \"cur\", \"last\", 1, and 1820."
2162 (not (mh-greaterp msg1 msg2
)))
2166 ;;; Basic sequence handling
2168 (defun mh-delete-seq-locally (seq)
2169 "Remove MH-E's record of SEQ."
2170 (let ((entry (mh-find-seq seq
)))
2171 (setq mh-seq-list
(delq entry mh-seq-list
))))
2173 (defun mh-read-folder-sequences (folder save-refiles
)
2174 "Read and return the predefined sequences for a FOLDER.
2175 If SAVE-REFILES is non-nil, then keep the sequences
2176 that note messages to be refiled."
2179 (mh-mapc (function (lambda (seq) ; Save the refiling sequences
2180 (if (mh-folder-name-p (mh-seq-name seq
))
2181 (setq seqs
(cons seq seqs
)))))
2184 (if (eq 0 (mh-exec-cmd-quiet nil
"mark" folder
"-list"))
2186 ;; look for name in line of form "cur: 4" or "myseq (private): 23"
2187 (while (re-search-forward "^[^: ]+" nil t
)
2188 (setq seqs
(cons (mh-make-seq (intern (buffer-substring
2193 (delete-region (point-min) (point))))) ; avoid race with
2197 (defun mh-read-msg-list ()
2198 "Return a list of message numbers from point to the end of the line.
2199 Expands ranges into set of individual numbers."
2201 (end-of-line (save-excursion (end-of-line) (point)))
2203 (while (re-search-forward "[0-9]+" end-of-line t
)
2204 (setq num
(string-to-int (buffer-substring (match-beginning 0)
2206 (cond ((looking-at "-") ; Message range
2208 (re-search-forward "[0-9]+" end-of-line t
)
2209 (let ((num2 (string-to-int (buffer-substring (match-beginning 0)
2212 (error "Bad message range: %d-%d" num num2
))
2213 (while (<= num num2
)
2214 (setq msgs
(cons num msgs
))
2215 (setq num
(1+ num
)))))
2216 ((not (zerop num
)) ;"pick" outputs "0" to mean no match
2217 (setq msgs
(cons num msgs
)))))
2220 (defun mh-notate-user-sequences (&optional range
)
2221 "Mark user-defined sequences in the messages specified by RANGE.
2222 The optional argument RANGE can be a message number, a list of message
2223 numbers, a sequence, a region in a cons cell. If nil all messages are notated."
2225 (setq range
(cons (point-min) (point-max))))
2226 (let ((seqs mh-seq-list
)
2227 (msg-hash (make-hash-table)))
2229 (dolist (msg (mh-seq-msgs seq
))
2230 (push (car seq
) (gethash msg msg-hash
))))
2231 (mh-iterate-on-range msg range
2232 (loop for seq in
(gethash msg msg-hash
)
2233 do
(mh-add-sequence-notation msg
(mh-internal-seq seq
))))))
2235 (defvar mh-internal-seqs
'(answered cur deleted forwarded printed
))
2237 (defun mh-internal-seq (name)
2238 "Return non-nil if NAME is the name of an internal MH-E sequence."
2239 (or (memq name mh-internal-seqs
)
2240 (eq name mh-unseen-seq
)
2241 (and (mh-colors-in-use-p) mh-tick-seq
(eq name mh-tick-seq
))
2242 (eq name mh-previous-seq
)
2243 (mh-folder-name-p name
)))
2245 (defun mh-valid-seq-p (name)
2246 "Return non-nil if NAME is a valid MH sequence name."
2248 (string-match "^[a-zA-Z][a-zA-Z0-9]*$" (symbol-name name
))))
2250 (defun mh-delete-msg-from-seq (range sequence
&optional internal-flag
)
2251 "Delete RANGE from SEQUENCE.
2253 Check the documentation of `mh-interactive-range' to see how RANGE is read in
2256 Optional third arg INTERNAL-FLAG non-nil means do not inform MH of the
2258 (interactive (list (mh-interactive-range "Delete")
2259 (mh-read-seq-default "Delete from" t
)
2261 (let ((entry (mh-find-seq sequence
))
2262 (user-sequence-flag (not (mh-internal-seq sequence
)))
2263 (folders-changed (list mh-current-folder
))
2266 (mh-iterate-on-range msg range
2268 ;; Calling "mark" repeatedly takes too long. So we will pretend here
2269 ;; that we are just modifying an internal sequence...
2270 (when (memq msg
(cdr entry
))
2271 (mh-remove-sequence-notation msg
(not user-sequence-flag
)))
2272 (mh-delete-a-msg-from-seq msg sequence t
))
2273 ;; ... and here we will "mark" all the messages at one go.
2274 (unless internal-flag
(mh-undefine-sequence sequence msg-list
))
2275 (when (and mh-index-data
(not internal-flag
))
2276 (setq folders-changed
2277 (append folders-changed
2278 (mh-index-delete-from-sequence sequence msg-list
))))
2279 (when (and (eq sequence mh-unseen-seq
) (mh-speed-flists-active-p))
2280 (apply #'mh-speed-flists t folders-changed
)))))
2282 (defun mh-catchup (range)
2283 "Delete RANGE from the `mh-unseen-seq' sequence.
2285 Check the document of `mh-interactive-range' to see how RANGE is read in
2287 (interactive (list (mh-interactive-range "Catchup"
2288 (cons (point-min) (point-max)))))
2289 (mh-delete-msg-from-seq range mh-unseen-seq
))
2291 (defun mh-delete-a-msg-from-seq (msg sequence internal-flag
)
2292 "Delete MSG from SEQUENCE.
2293 If INTERNAL-FLAG is non-nil, then do not inform MH of the change."
2294 (let ((entry (mh-find-seq sequence
)))
2295 (when (and entry
(memq msg
(mh-seq-msgs entry
)))
2296 (if (not internal-flag
)
2297 (mh-undefine-sequence sequence
(list msg
)))
2298 (setcdr entry
(delq msg
(mh-seq-msgs entry
))))))
2300 (defun mh-undefine-sequence (seq msgs
)
2301 "Remove from the SEQ the list of MSGS."
2302 (when (and (mh-valid-seq-p seq
) msgs
)
2303 (apply #'mh-exec-cmd
"mark" mh-current-folder
"-delete"
2304 "-sequence" (symbol-name seq
) (mh-coalesce-msg-list msgs
))))
2306 (defun mh-define-sequence (seq msgs
)
2307 "Define the SEQ to contain the list of MSGS.
2308 Do not mark pseudo-sequences or empty sequences.
2309 Signals an error if SEQ is an illegal name."
2311 (mh-valid-seq-p seq
)
2312 (not (mh-folder-name-p seq
)))
2314 (mh-exec-cmd-error nil
"mark" mh-current-folder
"-add" "-zero"
2315 "-sequence" (symbol-name seq
)
2316 (mh-coalesce-msg-list msgs
)))))
2318 (defun mh-seq-containing-msg (msg &optional include-internal-flag
)
2319 "Return a list of the sequences containing MSG.
2320 If INCLUDE-INTERNAL-FLAG non-nil, include MH-E internal sequences in list."
2321 (let ((l mh-seq-list
)
2324 (and (memq msg
(mh-seq-msgs (car l
)))
2325 (or include-internal-flag
2326 (not (mh-internal-seq (mh-seq-name (car l
)))))
2327 (setq seqs
(cons (mh-seq-name (car l
)) seqs
)))
2333 ;;; Build the folder-mode keymap:
2335 (suppress-keymap mh-folder-mode-map
)
2337 ;; Use defalias to make sure the documented primary key bindings
2338 ;; appear in menu lists.
2339 (defalias 'mh-alt-show
'mh-show
)
2340 (defalias 'mh-alt-refile-msg
'mh-refile-msg
)
2341 (defalias 'mh-alt-send
'mh-send
)
2342 (defalias 'mh-alt-visit-folder
'mh-visit-folder
)
2344 ;; Save the `b' binding for a future `back'. Maybe?
2345 (gnus-define-keys mh-folder-mode-map
2347 "!" mh-refile-or-write-again
2349 "," mh-header-display
2351 ";" mh-toggle-mh-decode-mime-flag
2352 ">" mh-write-msg-to-file
2354 "E" mh-extract-rejected-mail
2356 "\177" mh-previous-page
2357 "\C-d" mh-delete-msg-no-motion
2358 "\t" mh-index-next-folder
2359 [backtab] mh-index-previous-folder
2360 "\M-\t" mh-index-previous-folder
2363 "\ed" mh-redistribute
2365 "^" mh-alt-refile-msg
2372 "k" mh-delete-subject-or-thread
2374 "n" mh-next-undeleted-msg
2375 "\M-n" mh-next-unread-msg
2377 "p" mh-previous-undeleted-msg
2378 "\M-p" mh-previous-unread-msg
2382 "t" mh-toggle-showing
2384 "v" mh-index-visit-folder
2385 "x" mh-execute-commands
2388 (gnus-define-keys (mh-folder-map "F" mh-folder-mode-map)
2390 "'" mh-index-ticked-messages
2393 "f" mh-alt-visit-folder
2397 "n" mh-index-new-messages
2398 "o" mh-alt-visit-folder
2400 "q" mh-index-sequenced-messages
2401 "r" mh-rescan-folder
2402 "s" mh-search-folder
2404 "v" mh-visit-folder)
2406 (define-key mh-folder-mode-map "I" mh-inc-spool-map)
2408 (gnus-define-keys (mh-junk-map "J" mh-folder-mode-map)
2410 "b" mh-junk-blacklist
2411 "w" mh-junk-whitelist)
2413 (gnus-define-keys (mh-ps-print-map "P" mh-folder-mode-map)
2415 "A" mh-ps-print-toggle-mime
2416 "C" mh-ps-print-toggle-color
2417 "F" mh-ps-print-toggle-faces
2418 "M" mh-ps-print-toggle-mime
2419 "f" mh-ps-print-msg-file
2422 "s" mh-ps-print-msg-show)
2424 (gnus-define-keys (mh-sequence-map "S" mh-folder-mode-map)
2425 "'" mh-narrow-to-tick
2427 "d" mh-delete-msg-from-seq
2429 "l" mh-list-sequences
2430 "n" mh-narrow-to-seq
2431 "p" mh-put-msg-in-seq
2432 "s" mh-msg-is-in-seq
2435 (gnus-define-keys (mh-thread-map "T" mh-folder-mode-map)
2437 "u" mh-thread-ancestor
2438 "p" mh-thread-previous-sibling
2439 "n" mh-thread-next-sibling
2440 "t" mh-toggle-threads
2441 "d" mh-thread-delete
2442 "o" mh-thread-refile)
2444 (gnus-define-keys (mh-limit-map "/" mh-folder-mode-map)
2445 "'" mh-narrow-to-tick
2448 "f" mh-narrow-to-from
2449 "r" mh-narrow-to-range
2450 "s" mh-narrow-to-subject
2454 (gnus-define-keys (mh-extract-map "X" mh-folder-mode-map)
2456 "s" mh-store-msg ;shar
2457 "u" mh-store-msg) ;uuencode
2459 (gnus-define-keys (mh-digest-map "D" mh-folder-mode-map)
2462 "\177" mh-page-digest-backwards
2463 "b" mh-burst-digest)
2465 (gnus-define-keys (mh-mime-map "K" mh-folder-mode-map)
2467 "a" mh-mime-save-parts
2468 "e" mh-display-with-external-viewer
2469 "i" mh-folder-inline-mime-part
2470 "o" mh-folder-save-mime-part
2471 "t" mh-toggle-mime-buttons
2472 "v" mh-folder-toggle-mime-part
2474 [backtab] mh-prev-button
2475 "\M-\t" mh-prev-button
)
2479 (define-key mh-folder-mode-map
[button2] 'mh-show-mouse))
2481 (define-key mh-folder-mode-map [mouse-2] 'mh-show-mouse)))
2483 ;; "C-c /" prefix is used in mh-folder-mode by pgp.el and mailcrypt
2489 ;;; If you add a new prefix, add appropriate text to the nil key.
2491 ;;; In general, messages are grouped logically. Taking the main commands for
2492 ;;; example, the first line is "ways to view messages," the second line is
2493 ;;; "things you can do with messages", and the third is "composing" messages.
2495 ;;; When adding a new prefix, ensure that the help message contains "what" the
2496 ;;; prefix is for. For example, if the word "folder" were not present in the
2497 ;;; `F' entry, it would not be clear what these commands operated upon.
2498 (defvar mh-help-messages
2499 '((nil "[i]nc, [.]show, [,]show all, [n]ext, [p]revious,\n"
2500 "[d]elete, [o]refile, e[x]ecute,\n"
2501 "[s]end, [r]eply,\n"
2502 "[;]toggle MIME decoding.\n"
2503 "Prefix characters:\n [F]older, [S]equence, [J]unk, MIME [K]eys,"
2504 "\n [T]hread, [/]limit, e[X]tract, [D]igest, [I]nc spools.")
2506 (?F "[l]ist; [v]isit folder;\n"
2507 "[n]ew messages; [']ticked messages; [s]earch; [i]ndexed search;\n"
2508 "[p]ack; [S]ort; [r]escan; [k]ill")
2509 (?P "PS [p]rint message; [l]non-PS print;\n"
2510 "PS Print [s]how window, message to [f]ile;\n"
2511 "Toggle printing of [M]IME parts, [C]olor, [F]aces")
2512 (?S "[p]ut message in sequence, [n]arrow, [']narrow to ticked, [w]iden,\n"
2513 "[s]equences, [l]ist,\n"
2514 "[d]elete message from sequence, [k]ill sequence")
2515 (?T "[t]oggle, [d]elete, [o]refile thread")
2516 (?/ "Limit to [c]c, [f]rom, [r]ange, [s]ubject, [t]o; [w]iden")
2517 (?X "un[s]har, [u]udecode message")
2518 (?D "[b]urst digest")
2519 (?K "[v]iew, [i]nline, [o]utput/save MIME part; save [a]ll parts; \n"
2520 "[TAB] next; [SHIFT-TAB] previous")
2521 (?J "[b]lacklist, [w]hitelist message"))
2522 "Key binding cheat sheet.
2524 This is an associative array which is used to show the most common commands.
2525 The key is a prefix char. The value is one or more strings which are
2526 concatenated together and displayed in the minibuffer if ? is pressed after
2527 the prefix character. The special key nil is used to display the
2528 non-prefixed commands.
2530 The substitutions described in `substitute-command-keys' are performed as
2535 (dolist (mess '("^Cursor not pointing to message$"
2536 "^There is no other window$"))
2537 (add-to-list 'debug-ignored-errors mess))
2541 ;;; Local Variables:
2542 ;;; indent-tabs-mode: nil
2543 ;;; sentence-end-double-space: nil
2546 ;;; arch-tag: cce884de-bd37-4104-9963-e4439d5ed22b
2547 ;;; mh-e.el ends here