Sync to HEAD
[bpt/emacs.git] / lisp / mh-e / mh-e.el
CommitLineData
c26cf6c8
RS
1;;; mh-e.el --- GNU Emacs interface to the MH mail system
2
924df208
BW
3;; Copyright (C) 1985, 86, 87, 88, 90, 92, 93, 94, 95, 97, 1999,
4;; 2000, 01, 02, 2003 Free Software Foundation, Inc.
c26cf6c8 5
a1b4049d 6;; Author: Bill Wohler <wohler@newt.com>
6e65a812 7;; Maintainer: Bill Wohler <wohler@newt.com>
8aa2fe77 8;; Version: 7.3
c26cf6c8
RS
9;; Keywords: mail
10
60370d40 11;; This file is part of GNU Emacs.
9b7bc076
KH
12
13;; GNU Emacs is free software; you can redistribute it and/or modify
c26cf6c8
RS
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)
16;; any later version.
17
9b7bc076 18;; GNU Emacs is distributed in the hope that it will be useful,
c26cf6c8
RS
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.
22
23;; You should have received a copy of the GNU General Public License
b578f267
EN
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.
c26cf6c8
RS
27
28;;; Commentary:
29
a1b4049d
BW
30;; How to Use:
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.
b578f267 34
a1b4049d
BW
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)
b578f267 39
a1b4049d 40;; MH (Message Handler) is a powerful mail reader.
b578f267 41
a1b4049d
BW
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
bdcfe844 44;; Questions posting there for information on getting MH and MH-E:
a1b4049d 45;; http://www.faqs.org/faqs/mail/mh-faq/part1/preamble.html
b578f267 46
a1b4049d 47;; N.B. MH must have been compiled with the MHE compiler flag or several
bdcfe844 48;; features necessary for MH-E will be missing from MH commands, specifically
b578f267
EN
49;; the -build switch to repl and forw.
50
bdcfe844 51;; MH-E is an Emacs interface to the MH mail system.
a1b4049d 52
bdcfe844 53;; MH-E is supported in GNU Emacs 20 and 21, with MH 6.8.4 and nmh 1.0.4.
a1b4049d
BW
54
55;; Mailing Lists:
56;; mh-e-users@lists.sourceforge.net
57;; mh-e-announce@lists.sourceforge.net
58;; mh-e-devel@lists.sourceforge.net
59;;
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
63
64;; Bug Reports:
65;; https://sourceforge.net/tracker/?group_id=13357&atid=113357
66;; Include the output of M-x mh-version in any bug report.
67
68;; Feature Requests:
69;; https://sourceforge.net/tracker/?atid=363357&group_id=13357&func=browse
70
71;; Support:
72;; https://sourceforge.net/tracker/?group_id=13357&atid=213357
b578f267 73
717e06e5 74;;; Change Log:
b578f267
EN
75
76;; Original version for Gosling emacs by Brian Reid, Stanford, 1982.
77;; Modified by James Larus, BBN, July 1984 and UCB, 1984 & 1985.
78;; Rewritten for GNU Emacs, James Larus 1985. larus@ginger.berkeley.edu
a1b4049d
BW
79;; Modified by Stephen Gildea 1988. gildea@lcs.mit.edu
80;; Maintenance picked up by Bill Wohler <wohler@newt.com> and the
81;; SourceForge Crew <http://mh-e.sourceforge.net/>. 2001.
82
c26cf6c8
RS
83;;; Code:
84
bdcfe844 85(require 'cl)
c3d9274a
BW
86
87(defvar recursive-load-depth-limit)
88(eval-when (compile load eval)
89 (if (and (boundp 'recursive-load-depth-limit)
90 (integerp recursive-load-depth-limit)
91 (> 50 recursive-load-depth-limit))
92 (setq recursive-load-depth-limit 50)))
93
924df208 94(require 'mh-inc)
c26cf6c8 95(require 'mh-utils)
a1b4049d
BW
96(require 'gnus-util)
97(require 'easymenu)
bdcfe844 98(if mh-xemacs-flag
a1b4049d 99 (require 'mh-xemacs-compat))
a1b4049d 100
bdcfe844
BW
101;; Shush the byte-compiler
102(defvar font-lock-auto-fontify)
103(defvar font-lock-defaults)
a1b4049d 104
8aa2fe77 105(defconst mh-version "7.3" "Version number of MH-E.")
c3d9274a
BW
106
107;;; Autoloads
a1b4049d 108(autoload 'Info-goto-node "info")
c26cf6c8
RS
109
110\f
bdcfe844 111
847b8219
KH
112(defvar mh-note-deleted "D"
113 "String whose first character is used to notate deleted messages.")
114
115(defvar mh-note-refiled "^"
116 "String whose first character is used to notate refiled messages.")
117
118(defvar mh-note-cur "+"
119 "String whose first character is used to notate the current message.")
c26cf6c8
RS
120
121(defvar mh-partial-folder-mode-line-annotation "select"
122 "Annotation when displaying part of a folder.
bdcfe844 123The string is displayed after the folder's name. nil for no annotation.")
a1b4049d 124
bdcfe844 125;;; Parameterize MH-E to work with different scan formats. The defaults work
a1b4049d
BW
126;;; with the standard MH scan listings, in which the first 4 characters on
127;;; the line are the message number, followed by two places for notations.
128
a1b4049d
BW
129;; The following scan formats are passed to the scan program if the
130;; setting of `mh-scan-format-file' above is nil. They are identical
131;; except the later one makes use of the nmh `decode' function to
bdcfe844
BW
132;; decode RFC 2047 encodings. If you just want to change the width of
133;; the msg number, use the `mh-set-cmd-note' function.
a1b4049d
BW
134
135(defvar mh-scan-format-mh
136 (concat
137 "%4(msg)"
138 "%<(cur)+%| %>"
139 "%<{replied}-"
140 "%?(nonnull(comp{to}))%<(mymbox{to})t%>"
141 "%?(nonnull(comp{cc}))%<(mymbox{cc})c%>"
142 "%?(nonnull(comp{bcc}))%<(mymbox{bcc})b%>"
143 "%?(nonnull(comp{newsgroups}))n%>"
144 "%<(zero) %>"
145 "%02(mon{date})/%02(mday{date})%<{date} %|*%>"
146 "%<(mymbox{from})%<{to}To:%14(friendly{to})%>%>"
147 "%<(zero)%17(friendly{from})%> "
148 "%{subject}%<{body}<<%{body}%>")
149 "*Scan format string for MH, provided to the scan program via the -format arg.
150This format is identical to the default except that additional hints for
bdcfe844
BW
151fontification have been added to the fifth column (remember that in Emacs, the
152first column is 0).
a1b4049d 153
bdcfe844 154The values of the fifth column, in priority order, are: `-' if the
a1b4049d
BW
155message has been replied to, t if an address on the To: line matches
156one of the mailboxes of the current user, `c' if the Cc: line matches,
157`b' if the Bcc: line matches, and `n' if a non-empty Newsgroups: header
158is present.")
159
160(defvar mh-scan-format-nmh
161 (concat
162 "%4(msg)"
163 "%<(cur)+%| %>"
164 "%<{replied}-"
165 "%?(nonnull(comp{to}))%<(mymbox{to})t%>"
166 "%?(nonnull(comp{cc}))%<(mymbox{cc})c%>"
167 "%?(nonnull(comp{bcc}))%<(mymbox{bcc})b%>"
168 "%?(nonnull(comp{newsgroups}))n%>"
169 "%<(zero) %>"
170 "%02(mon{date})/%02(mday{date})%<{date} %|*%>"
171 "%<(mymbox{from})%<{to}To:%14(decode(friendly{to}))%>%>"
172 "%<(zero)%17(decode(friendly{from}))%> "
173 "%(decode{subject})%<{body}<<%{body}%>")
bdcfe844
BW
174 "*Scan format string for nmh.
175This string is passed to the scan program via the -format arg.
a1b4049d 176This format is identical to the default except that additional hints for
bdcfe844
BW
177fontification have been added to the fifth column (remember that in Emacs, the
178first column is 0).
a1b4049d 179
bdcfe844 180The values of the fifth column, in priority order, are: `-' if the
a1b4049d
BW
181message has been replied to, t if an address on the To: line matches
182one of the mailboxes of the current user, `c' if the Cc: line matches,
183`b' if the Bcc: line matches, and `n' if a non-empty Newsgroups: header
184is present.")
185
bdcfe844 186(defvar mh-scan-good-msg-regexp "^\\( *[0-9]+\\)[^D^0-9]"
a1b4049d
BW
187 "Regexp specifying the scan lines that are 'good' messages.
188The default `mh-folder-font-lock-keywords' expects this expression to contain
189at least one parenthesized expression which matches the message number.")
190
bdcfe844 191(defvar mh-scan-deleted-msg-regexp "^\\( *[0-9]+\\)D"
a1b4049d
BW
192 "Regexp matching scan lines of deleted messages.
193The default `mh-folder-font-lock-keywords' expects this expression to contain
194at least one parenthesized expression which matches the message number.")
195
bdcfe844 196(defvar mh-scan-refiled-msg-regexp "^\\( *[0-9]+\\)\\^"
a1b4049d
BW
197 "Regexp matching scan lines of refiled messages.
198The default `mh-folder-font-lock-keywords' expects this expression to contain
199at least one parenthesized expression which matches the message number.")
200
201(defvar mh-scan-valid-regexp "^ *[0-9]"
202 "Regexp matching scan lines for messages (not error messages).")
203
bdcfe844 204(defvar mh-scan-cur-msg-number-regexp "^\\( *[0-9]+\\+\\).*"
a1b4049d
BW
205 "Regexp matching scan line for the current message.
206The default `mh-folder-font-lock-keywords' expects this expression to contain
207at least one parenthesized expression which matches the message number.
208Don't disable this regexp as it's needed by non fontifying functions.")
209
bdcfe844 210(defvar mh-scan-cur-msg-regexp "^\\( *[0-9]+\\+DISABLED.*\\)"
a1b4049d
BW
211 "Regexp matching scan line for the current message.
212The default `mh-folder-font-lock-keywords' expects this expression to contain
213at least one parenthesized expression which matches the whole line.
214To enable this feature, remove the string DISABLED from the regexp.")
215
216(defvar mh-scan-date-regexp "\\([0-9][0-9]/[0-9][0-9]\\)"
217 "Regexp matching a valid date in scan lines.
218The default `mh-folder-font-lock-keywords' expects this expression to contain
219only one parenthesized expression which matches the date field
220\(see `mh-scan-format-regexp').")
221
222(defvar mh-scan-rcpt-regexp "\\(To:\\)\\(..............\\)"
223 "Regexp specifying the recipient in scan lines for messages we sent.
224The default `mh-folder-font-lock-keywords' expects this expression to contain
225two parenthesized expressions. The first is expected to match the To:
226that the default scan format file generates. The second is expected to match
227the recipient's name.")
228
229(defvar mh-scan-body-regexp "\\(<<\\([^\n]+\\)?\\)"
230 "Regexp matching the message body beginning displayed in scan lines.
231The default `mh-folder-font-lock-keywords' expects this expression to contain
232at least one parenthesized expression which matches the body text.")
233
234(defvar mh-scan-subject-regexp
c3d9274a 235 ;;"^ *[0-9]+........[ ]*...................\\([Rr][Ee]:\\s-*\\)*\\([^<\n]*\\)"
bdcfe844 236 "^ *[0-9]+........[ ]*...................\\([Rr][Ee]\\(\\[[0-9]+\\]\\)?:\\s-*\\)*\\([^<\n]*\\)"
a1b4049d
BW
237 "*Regexp matching the subject string in MH folder mode.
238The default `mh-folder-font-lock-keywords' expects this expression to contain
bdcfe844
BW
239at least tree parenthesized expressions. The first is expected to match the Re:
240string, if any. The second matches an optional bracketed number after Re,
241such as in Re[2]: and the third is expected to match the subject line itself.")
a1b4049d
BW
242
243(defvar mh-scan-format-regexp
bdcfe844
BW
244 (concat "\\([bct]\\)" mh-scan-date-regexp " *\\(..................\\)")
245 "Regexp matching the output of scan.
246The default value is based upon the default values of either
247`mh-scan-format-mh' or `mh-scan-format-nmh'.
a1b4049d
BW
248The default `mh-folder-font-lock-keywords' expects this expression to contain
249at least three parenthesized expressions. The first should match the
250fontification hint, the second is found in `mh-scan-date-regexp', and the
251third should match the user name.")
252
c3d9274a
BW
253\f
254
bdcfe844
BW
255(defvar mh-folder-font-lock-keywords
256 (list
c3d9274a
BW
257 ;; Folders when displaying index buffer
258 (list "^\\+.*"
259 '(0 mh-index-folder-face))
bdcfe844
BW
260 ;; Marked for deletion
261 (list (concat mh-scan-deleted-msg-regexp ".*")
262 '(0 mh-folder-deleted-face))
263 ;; Marked for refile
264 (list (concat mh-scan-refiled-msg-regexp ".*")
265 '(0 mh-folder-refiled-face))
266 ;;after subj
267 (list mh-scan-body-regexp '(1 mh-folder-body-face nil t))
268 '(mh-folder-font-lock-subject
269 (1 mh-folder-followup-face append t)
270 (2 mh-folder-subject-face append t))
271 ;;current msg
272 (list mh-scan-cur-msg-number-regexp
273 '(1 mh-folder-cur-msg-number-face))
274 (list mh-scan-good-msg-regexp
c3d9274a
BW
275 '(1 mh-folder-msg-number-face)) ;; Msg number
276 (list mh-scan-date-regexp '(1 mh-folder-date-face)) ;; Date
bdcfe844 277 (list mh-scan-rcpt-regexp
c3d9274a
BW
278 '(1 mh-folder-to-face) ;; To:
279 '(2 mh-folder-address-face)) ;; address
bdcfe844
BW
280 ;; scan font-lock name
281 (list mh-scan-format-regexp
282 '(1 mh-folder-date-face)
283 '(3 mh-folder-scan-format-face))
284 ;; Current message line
285 (list mh-scan-cur-msg-regexp
286 '(1 mh-folder-cur-msg-face prepend t))
287 ;; Unseen messages in bold
c3d9274a 288 '(mh-folder-font-lock-unseen (1 'bold append t)))
bdcfe844
BW
289 "Regexp keywords used to fontify the MH-Folder buffer.")
290
291(defvar mh-scan-cmd-note-width 1
292 "Number of columns consumed by the cmd-note field in `mh-scan-format'.
293This column will have one of the values: ` ', `D', `^', `+' and where
294` ' is the default value,
295`D' is the `mh-note-deleted' character,
296`^' is the `mh-note-refiled' character, and
297`+' is the `mh-note-cur' character.")
298
299(defvar mh-scan-destination-width 1
300 "Number of columns consumed by the destination field in `mh-scan-format'.
301This column will have one of ' ', '%', '-', 't', 'c', 'b', or `n' in it.
302A ' ' blank space is the default character.
303A '%' indicates that the message in in a named MH sequence.
304A '-' indicates that the message has been annotated with a replied field.
305A 't' indicates that the message contains mymbox in the To: field.
306A 'c' indicates that the message contains mymbox in the Cc: field.
307A 'b' indicates that the message contains mymbox in the Bcc: field.
308A 'n' indicates that the message contains a Newsgroups: field.")
309
310(defvar mh-scan-date-width 5
311 "Number of columns consumed by the date field in `mh-scan-format'.
312This column will typically be of the form mm/dd.")
313
314(defvar mh-scan-date-flag-width 1
315 "Number of columns consumed to flag (in)valid dates in `mh-scan-format'.
316This column will have ` ' for valid and `*' for invalid or missing dates.")
317
318(defvar mh-scan-from-mbox-width 17
319 "Number of columns consumed with the \"From:\" line in `mh-scan-format'.
320This column will have a friendly name or e-mail address of the
321originator, or a \"To: address\" for outgoing e-mail messages.")
322
323(defvar mh-scan-from-mbox-sep-width 2
324 "Number of columns consumed by whitespace after from-mbox in `mh-scan-format'.
325This column will only ever have spaces in it.")
326
327(defvar mh-scan-field-from-start-offset
c3d9274a
BW
328 (+ mh-scan-cmd-note-width
329 mh-scan-destination-width
330 mh-scan-date-width
331 mh-scan-date-flag-width)
332 "The offset from the `mh-cmd-note' to find the start of \"From:\" address.")
bdcfe844
BW
333
334(defvar mh-scan-field-from-end-offset
c3d9274a
BW
335 (+ mh-scan-field-from-start-offset mh-scan-from-mbox-width)
336 "The offset from the `mh-cmd-note' to find the end of \"From:\" address.")
bdcfe844
BW
337
338(defvar mh-scan-field-subject-start-offset
339 (+ mh-scan-cmd-note-width
340 mh-scan-destination-width
341 mh-scan-date-width
342 mh-scan-date-flag-width
343 mh-scan-from-mbox-width
344 mh-scan-from-mbox-sep-width)
345 "The offset from the `mh-cmd-note' to find the start of the subject.")
a1b4049d
BW
346
347(defun mh-folder-font-lock-subject (limit)
bdcfe844 348 "Return MH-E scan subject strings to font-lock between point and LIMIT."
a1b4049d
BW
349 (if (not (re-search-forward mh-scan-subject-regexp limit t))
350 nil
351 (if (match-beginning 1)
bdcfe844
BW
352 (set-match-data (list (match-beginning 1) (match-end 3)
353 (match-beginning 1) (match-end 3) nil nil))
354 (set-match-data (list (match-beginning 3) (match-end 3)
355 nil nil (match-beginning 3) (match-end 3))))
a1b4049d
BW
356 t))
357
bdcfe844
BW
358\f
359
360;; Fontifify unseen mesages in bold.
361
a1b4049d
BW
362(defvar mh-folder-unseen-seq-name nil
363 "Name of unseen sequence.
364The default for this is provided by the function `mh-folder-unseen-seq-name'
365On nmh systems.")
366
367(defun mh-folder-unseen-seq-name ()
368 "Provide name of unseen sequence from mhparam."
369 (or mh-progs (mh-find-path))
370 (save-excursion
bdcfe844
BW
371 (let ((unseen-seq-name "unseen"))
372 (with-temp-buffer
c3d9274a
BW
373 (unwind-protect
374 (progn
375 (call-process (expand-file-name "mhparam" mh-progs)
376 nil '(t t) nil "-component" "Unseen-Sequence")
377 (goto-char (point-min))
378 (if (re-search-forward "Unseen-Sequence: \\(.*\\)$" nil t)
379 (setq unseen-seq-name (match-string 1))))))
a1b4049d
BW
380 unseen-seq-name)))
381
382(defun mh-folder-unseen-seq-list ()
383 "Return a list of unseen message numbers for current folder."
384 (if (not mh-folder-unseen-seq-name)
385 (setq mh-folder-unseen-seq-name (mh-folder-unseen-seq-name)))
386 (cond
387 ((not mh-folder-unseen-seq-name)
388 nil)
389 (t
390 (let ((folder mh-current-folder))
391 (save-excursion
c3d9274a
BW
392 (with-temp-buffer
393 (unwind-protect
394 (progn
395 (call-process (expand-file-name "mark" mh-progs)
bdcfe844 396 nil '(t t) nil
a1b4049d 397 folder "-seq" mh-folder-unseen-seq-name
c3d9274a
BW
398 "-list")
399 (goto-char (point-min))
400 (sort (mh-read-msg-list) '<)))))))))
a1b4049d
BW
401
402(defvar mh-folder-unseen-seq-cache nil
bdcfe844 403 "Internal cache variable used for font-lock in MH-E.
a1b4049d
BW
404Should only be non-nil through font-lock stepping, and nil once font-lock
405is done highlighting.")
406(make-variable-buffer-local 'mh-folder-unseen-seq-cache)
407
408(defun mh-folder-font-lock-unseen (limit)
409 "Return unseen message lines to font-lock between point and LIMIT."
410 (if (not mh-folder-unseen-seq-cache)
411 (setq mh-folder-unseen-seq-cache (mh-folder-unseen-seq-list)))
412 (let ((cur-msg (mh-get-msg-num nil)))
413 (cond
414 ((not mh-folder-unseen-seq-cache)
415 nil)
924df208 416 ((>= (point) limit) ;Presumably at end of buffer
a1b4049d
BW
417 (setq mh-folder-unseen-seq-cache nil)
418 nil)
419 ((member cur-msg mh-folder-unseen-seq-cache)
420 (let ((bpoint (progn (beginning-of-line)(point)))
421 (epoint (progn (forward-line 1)(point))))
422 (if (<= limit (point))
423 (setq mh-folder-unseen-seq-cache nil))
424 (set-match-data (list bpoint epoint bpoint epoint))
425 t))
426 (t
427 ;; move forward one line at a time, checking each message number.
428 (while (and
429 (= 0 (forward-line 1))
430 (> limit (point))
431 (not (member (mh-get-msg-num nil) mh-folder-unseen-seq-cache))))
432 ;; Examine how we must have exited the loop...
433 (let ((cur-msg (mh-get-msg-num nil)))
434 (cond
924df208 435 ((or (<= limit (point))
a1b4049d
BW
436 (not (member cur-msg mh-folder-unseen-seq-cache)))
437 (setq mh-folder-unseen-seq-cache nil)
438 nil)
439 ((member cur-msg mh-folder-unseen-seq-cache)
440 (let ((bpoint (progn (beginning-of-line)(point)))
441 (epoint (progn (forward-line 1)(point))))
442 (if (<= limit (point))
443 (setq mh-folder-unseen-seq-cache nil))
444 (set-match-data (list bpoint epoint bpoint epoint))
445 t))))))))
bdcfe844
BW
446
447\f
c26cf6c8
RS
448
449;;; Internal variables:
450
c3d9274a
BW
451(defvar mh-last-destination nil) ;Destination of last refile or write
452 ;command.
bdcfe844
BW
453(defvar mh-last-destination-folder nil) ;Destination of last refile command.
454(defvar mh-last-destination-write nil) ;Destination of last write command.
c26cf6c8
RS
455
456(defvar mh-folder-mode-map (make-keymap)
457 "Keymap for MH folders.")
458
3d7ca223
BW
459(defvar mh-arrow-marker nil) ;Marker for arrow display in fringe.
460
c3d9274a 461(defvar mh-delete-list nil) ;List of msg numbers to delete.
c26cf6c8 462
c3d9274a 463(defvar mh-refile-list nil) ;List of folder names in mh-seq-list.
c26cf6c8 464
c3d9274a 465(defvar mh-next-direction 'forward) ;Direction to move to next message.
c26cf6c8 466
c3d9274a
BW
467(defvar mh-narrowed-to-seq nil) ;Sequence display is narrowed to or
468 ;nil if not narrowed.
bdcfe844 469
924df208
BW
470(defvar mh-tick-seq-changed-when-narrowed-flag nil)
471 ;Has tick sequence changed while the
472 ;folder was narrowed to it?
473
bdcfe844
BW
474(defvar mh-view-ops ()) ;Stack of ops that change the folder
475 ;view (such as narrowing or threading).
c26cf6c8 476
c3d9274a
BW
477(defvar mh-index-data nil) ;Info about index search results
478(defvar mh-index-previous-search nil)
479(defvar mh-index-msg-checksum-map nil)
480(defvar mh-index-checksum-origin-map nil)
481
482(defvar mh-first-msg-num nil) ;Number of first msg in buffer.
c26cf6c8 483
c3d9274a 484(defvar mh-last-msg-num nil) ;Number of last msg in buffer.
c26cf6c8 485
c3d9274a 486(defvar mh-mode-line-annotation nil) ;Message range displayed in buffer.
c26cf6c8
RS
487
488;;; Macros and generic functions:
489
bdcfe844
BW
490(defun mh-mapc (function list)
491 "Apply FUNCTION to each element of LIST for side effects only."
c26cf6c8 492 (while list
bdcfe844 493 (funcall function (car list))
c26cf6c8
RS
494 (setq list (cdr list))))
495
a1b4049d 496(defun mh-scan-format ()
bdcfe844 497 "Return \"-format\" argument for the scan program."
a1b4049d 498 (if (equal mh-scan-format-file t)
bdcfe844 499 (list "-format" (if mh-nmh-flag
c3d9274a
BW
500 (list (mh-update-scan-format
501 mh-scan-format-nmh mh-cmd-note))
502 (list (mh-update-scan-format
503 mh-scan-format-mh mh-cmd-note))))
a1b4049d 504 (if (not (equal mh-scan-format-file nil))
c3d9274a 505 (list "-format" mh-scan-format-file))))
a1b4049d 506
c26cf6c8
RS
507\f
508
509;;; Entry points:
510
511;;;###autoload
512(defun mh-rmail (&optional arg)
a1b4049d 513 "Inc(orporate) new mail with MH.
bdcfe844 514Scan an MH folder if ARG is non-nil. This function is an entry point to MH-E,
a1b4049d 515the Emacs front end to the MH mail system."
c26cf6c8
RS
516 (interactive "P")
517 (mh-find-path)
518 (if arg
519 (call-interactively 'mh-visit-folder)
3d7ca223
BW
520 (unless (get-buffer mh-inbox)
521 (mh-visit-folder mh-inbox (symbol-name mh-unseen-seq)))
c3d9274a 522 (mh-inc-folder)))
c26cf6c8 523
a1b4049d
BW
524;;;###autoload
525(defun mh-nmail (&optional arg)
526 "Check for new mail in inbox folder.
bdcfe844 527Scan an MH folder if ARG is non-nil. This function is an entry point to MH-E,
a1b4049d
BW
528the Emacs front end to the MH mail system."
529 (interactive "P")
c3d9274a 530 (mh-find-path) ; init mh-inbox
a1b4049d
BW
531 (if arg
532 (call-interactively 'mh-visit-folder)
533 (mh-visit-folder mh-inbox)))
c26cf6c8
RS
534
535\f
536
bdcfe844 537;;; User executable MH-E commands:
c26cf6c8 538
c26cf6c8 539(defun mh-delete-msg (msg-or-seq)
a1b4049d 540 "Mark the specified MSG-OR-SEQ for subsequent deletion and move to the next.
924df208
BW
541Default is the displayed message.
542If optional prefix argument is provided, then prompt for the message sequence.
543If variable `transient-mark-mode' is non-nil and the mark is active, then the
544selected region is marked for deletion.
545In a program, MSG-OR-SEQ can be a message number, a list of message numbers, a
546region in a cons cell, or a sequence."
547 (interactive (list (mh-interactive-msg-or-seq "Delete")))
c26cf6c8
RS
548 (mh-delete-msg-no-motion msg-or-seq)
549 (mh-next-msg))
550
c26cf6c8 551(defun mh-delete-msg-no-motion (msg-or-seq)
a1b4049d 552 "Mark the specified MSG-OR-SEQ for subsequent deletion.
924df208
BW
553Default is the displayed message.
554If optional prefix argument is provided, then prompt for the message sequence.
555If variable `transient-mark-mode' is non-nil and the mark is active, then the
556selected region is marked for deletion.
557In a program, MSG-OR-SEQ can be a message number, a list of message numbers, a
558region in a cons cell, or a sequence."
559 (interactive (list (mh-interactive-msg-or-seq "Delete")))
560 (mh-iterate-on-msg-or-seq () msg-or-seq
561 (mh-delete-a-msg nil)))
c26cf6c8 562
c26cf6c8
RS
563(defun mh-execute-commands ()
564 "Process outstanding delete and refile requests."
565 (interactive)
566 (if mh-narrowed-to-seq (mh-widen))
567 (mh-process-commands mh-current-folder)
568 (mh-set-scan-mode)
c3d9274a 569 (mh-goto-cur-msg) ; after mh-set-scan-mode for efficiency
c26cf6c8 570 (mh-make-folder-mode-line)
c3d9274a 571 t) ; return t for write-file-functions
c26cf6c8
RS
572
573(defun mh-first-msg ()
574 "Move to the first message."
575 (interactive)
847b8219 576 (goto-char (point-min))
a1b4049d 577 (while (and (not (eobp)) (not (looking-at mh-scan-valid-regexp)))
847b8219 578 (forward-line 1)))
c26cf6c8 579
c26cf6c8
RS
580(defun mh-header-display ()
581 "Show the current message with all its headers.
86a32538 582Displays headers that might have been suppressed by setting the
bdcfe844 583variables `mh-clean-message-header-flag' or `mhl-formfile', or by the fallback
86a32538
RS
584behavior of scrolling uninteresting headers off the top of the window.
585Type \"\\[mh-show]\" to show the message normally again."
c26cf6c8
RS
586 (interactive)
587 (and (not mh-showing-with-headers)
bdcfe844 588 (or mhl-formfile mh-clean-message-header-flag)
c26cf6c8 589 (mh-invalidate-show-buffer))
bdcfe844
BW
590 (let ((mh-decode-mime-flag nil)
591 (mhl-formfile nil)
c3d9274a 592 (mh-clean-message-header-flag nil))
c26cf6c8
RS
593 (mh-show-msg nil)
594 (mh-in-show-buffer (mh-show-buffer)
595 (goto-char (point-min))
596 (mh-recenter 0))
597 (setq mh-showing-with-headers t)))
598
924df208 599(defun mh-inc-folder (&optional maildrop-name folder)
847b8219 600 "Inc(orporate)s new mail into the Inbox folder.
a1b4049d 601Optional argument MAILDROP-NAME specifies an alternate maildrop from the
924df208
BW
602default. The optional argument FOLDER specifies where to incorporate mail
603instead of the default named by `mh-inbox'.
bdcfe844
BW
604The value of `mh-inc-folder-hook' is a list of functions to be called, with no
605arguments, after incorporating new mail.
606Do not call this function from outside MH-E; use \\[mh-rmail] instead."
c26cf6c8 607 (interactive (list (if current-prefix-arg
c3d9274a
BW
608 (expand-file-name
609 (read-file-name "inc mail from file: "
924df208
BW
610 mh-user-path)))
611 (if current-prefix-arg
612 (mh-prompt-for-folder "inc mail into" mh-inbox t))))
613 (if (not folder)
614 (setq folder mh-inbox))
c3d9274a
BW
615 (let ((threading-needed-flag nil))
616 (let ((config (current-window-configuration)))
924df208
BW
617 (cond ((not (get-buffer folder))
618 (mh-make-folder folder)
619 (setq threading-needed-flag mh-show-threads-flag)
620 (setq mh-previous-window-config config))
621 ((not (eq (current-buffer) (get-buffer folder)))
622 (switch-to-buffer folder)
623 (setq mh-previous-window-config config))))
c3d9274a
BW
624 (mh-get-new-mail maildrop-name)
625 (when (and threading-needed-flag
626 (save-excursion
627 (goto-char (point-min))
628 (or (null mh-large-folder)
629 (not (equal (forward-line mh-large-folder) 0))
630 (and (message "Not threading since the number of messages exceeds `mh-large-folder'")
631 nil))))
632 (mh-toggle-threads))
924df208
BW
633 (beginning-of-line)
634 (if (and mh-showing-mode (looking-at mh-scan-valid-regexp)) (mh-show))
c3d9274a 635 (run-hooks 'mh-inc-folder-hook)))
c26cf6c8 636
c26cf6c8
RS
637(defun mh-last-msg ()
638 "Move to the last message."
639 (interactive)
640 (goto-char (point-max))
c3d9274a 641 (while (and (not (bobp)) (not (looking-at mh-scan-valid-regexp)))
bdcfe844
BW
642 (forward-line -1))
643 (mh-recenter nil))
c26cf6c8 644
924df208
BW
645(defun mh-next-undeleted-msg (&optional arg wait-after-complaining-flag)
646 "Move to the next undeleted message ARG in window.
647If optional argument WAIT-AFTER-COMPLAINING-FLAG is non-nil and we are at the
648last undeleted message then pause for a second after printing message."
847b8219 649 (interactive "p")
c26cf6c8 650 (setq mh-next-direction 'forward)
847b8219 651 (forward-line 1)
bdcfe844 652 (cond ((re-search-forward mh-scan-good-msg-regexp nil t arg)
c3d9274a
BW
653 (beginning-of-line)
654 (mh-maybe-show))
655 (t (forward-line -1)
924df208
BW
656 (message "No more undeleted messages")
657 (if wait-after-complaining-flag (sit-for 1)))))
c26cf6c8 658
3d7ca223
BW
659(defun mh-folder-from-address ()
660 "Determine folder name from address in From field.
661Takes the address in the From: header field, and returns one of:
662
663 a) The folder name associated with the address in the alist
924df208
BW
664 `mh-default-folder-list'. If the `Check Recipient' boolean
665 is set, then the `mh-default-folder-list' addresses are
666 checked against the recipient instead of the originator
667 (making possible to use this feature for mailing lists).
668 The first match found in `mh-default-folder-list' is used.
3d7ca223
BW
669
670 b) The address' corresponding alias from the user's personal
671 aliases file prefixed by `mh-default-folder-prefix'.
672
673Returns nil if the address was not found in either place or if the variable
674`mh-default-folder-must-exist-flag' is nil and the folder does not exist."
924df208
BW
675 ;; Loop for all entries in mh-default-folder-list
676 (save-excursion
677 (let ((folder-name
678 (car
679 (delq nil
680 (mapcar
681 (lambda (list)
682 (let ((address-regexp (nth 0 list))
683 (folder (nth 1 list))
684 (to-flag (nth 2 list)))
685 (when (or
686 (mh-goto-header-field (if to-flag "To:" "From:"))
687 ; if the To: field is missing, try Cc:
688 (and to-flag (mh-goto-header-field "cc:")))
689 (let ((endfield (save-excursion
690 (mh-header-field-end)(point))))
691 (if (re-search-forward address-regexp endfield t)
692 folder
693 (when to-flag ;Try Cc: as well
694 (mh-goto-header-field "cc:")
695 (let ((endfield (save-excursion
696 (mh-header-field-end)(point))))
697 (when (re-search-forward
698 address-regexp endfield t)
699 folder))))))))
700 mh-default-folder-list)))))
701
702 ;; Make sure a result from `mh-default-folder-list' begins with "+"
703 ;; since 'mh-expand-file-name below depends on it
704 (when (and folder-name (not (eq (aref folder-name 0) ?+)))
705 (setq folder-name (concat "+" folder-name)))
706
707 ;; If not, is there an alias for the address?
708 (when (not folder-name)
709 (let* ((from-header (mh-extract-from-header-value))
710 (address (and from-header
711 (nth 1 (mail-extract-address-components
712 from-header))))
713 (alias (and address (mh-alias-address-to-alias address))))
714 (when alias
715 (setq folder-name
716 (and alias (concat "+" mh-default-folder-prefix alias))))))
717
718 ;; If mh-default-folder-must-exist-flag set, check that folder exists.
719 (if (and folder-name
720 (or (not mh-default-folder-must-exist-flag)
721 (file-exists-p (mh-expand-file-name folder-name))))
722 folder-name))))
3d7ca223
BW
723
724(defun mh-prompt-for-refile-folder ()
725 "Prompt the user for a folder in which the message should be filed.
726The folder is returned as a string.
727
728If `mh-default-folder-for-message-function' is a function then the message
729being refiled is yanked into a temporary buffer and the function is called to
730intelligently guess where the message is to be refiled.
731
732Otherwise, a default folder name is generated by `mh-folder-from-address'."
733 (mh-prompt-for-folder
734 "Destination"
735 (let ((refile-file (mh-msg-filename (mh-get-msg-num t))))
736 (save-excursion
737 (set-buffer (get-buffer-create mh-temp-buffer))
738 (erase-buffer)
739 (insert-file-contents refile-file)
740 (or (and mh-default-folder-for-message-function
741 (let ((buffer-file-name refile-file))
742 (funcall mh-default-folder-for-message-function)))
743 (mh-folder-from-address)
744 (and (eq 'refile (car mh-last-destination-folder))
745 (symbol-name (cdr mh-last-destination-folder)))
746 "")))
747 t))
748
924df208
BW
749(defun mh-refile-msg (msg-or-seq folder
750 &optional dont-update-last-destination-flag)
751 "Refile MSG-OR-SEQ into FOLDER.
752Default is the displayed message.
753If optional prefix argument is provided, then prompt for the message sequence.
a1b4049d 754If variable `transient-mark-mode' is non-nil and the mark is active, then the
924df208
BW
755selected region is marked for refiling.
756In a program, MSG-OR-SEQ can be a message number, a list of message numbers, a
757region in a cons cell, or a sequence.
758
759If optional argument DONT-UPDATE-LAST-DESTINATION-FLAG is non-nil then the
760variables `mh-last-destination' and `mh-last-destination-folder' are not
761updated."
762 (interactive (list (mh-interactive-msg-or-seq "Refile")
763 (intern (mh-prompt-for-refile-folder))))
764 (unless dont-update-last-destination-flag
765 (setq mh-last-destination (cons 'refile folder)
766 mh-last-destination-folder mh-last-destination))
767 (mh-iterate-on-msg-or-seq () msg-or-seq
768 (mh-refile-a-msg nil folder))
c26cf6c8
RS
769 (mh-next-msg))
770
847b8219 771(defun mh-refile-or-write-again (message)
c26cf6c8 772 "Re-execute the last refile or write command on the given MESSAGE.
bdcfe844
BW
773Default is the displayed message. Use the same folder or file as the previous
774refile or write command."
c26cf6c8
RS
775 (interactive (list (mh-get-msg-num t)))
776 (if (null mh-last-destination)
777 (error "No previous refile or write"))
924df208
BW
778 (let (output)
779 (setq output
780 (cond ((eq (car mh-last-destination) 'refile)
781 (mh-refile-a-msg message (cdr mh-last-destination))
782 (format "Destination folder: %s" (cdr mh-last-destination)))
783 (t
784 (apply 'mh-write-msg-to-file message (cdr mh-last-destination))
785 (format "Destination: %s" (cdr mh-last-destination)))))
786 (mh-next-msg (interactive-p))
787 (message output)))
c26cf6c8 788
c26cf6c8 789(defun mh-quit ()
bdcfe844
BW
790 "Quit the current MH-E folder.
791Restore the previous window configuration, if one exists.
792The value of `mh-before-quit-hook' is a list of functions to be called, with
793no arguments, immediately upon entry to this function.
794The value of `mh-quit-hook' is a list of functions to be called, with no
3d7ca223
BW
795arguments, upon exit of this function.
796MH-E working buffers (whose name begins with \" *mh-\" or \"*MH-E \") are
797killed."
c26cf6c8 798 (interactive)
a1b4049d 799 (run-hooks 'mh-before-quit-hook)
bdcfe844
BW
800 (let ((show-buffer (get-buffer mh-show-buffer)))
801 (when show-buffer
802 (kill-buffer show-buffer)))
847b8219 803 (mh-update-sequences)
bdcfe844 804 (mh-destroy-postponed-handles)
6d4de1a7 805 (bury-buffer (current-buffer))
3d7ca223
BW
806
807 ;; Delete all MH-E temporary and working buffers.
808 (dolist (buffer (buffer-list))
809 (when (or (string-match "^ \\*mh-" (buffer-name buffer))
810 (string-match "^\\*MH-E " (buffer-name buffer)))
811 (kill-buffer buffer)))
812
c26cf6c8
RS
813 (if mh-previous-window-config
814 (set-window-configuration mh-previous-window-config))
815 (run-hooks 'mh-quit-hook))
816
817(defun mh-page-msg (&optional arg)
818 "Page the displayed message forwards.
a1b4049d
BW
819Scrolls ARG lines or a full screen if no argument is supplied. Show buffer
820first if not displayed. Show the next undeleted message if looking at the
821bottom of the current message."
c26cf6c8 822 (interactive "P")
a1b4049d 823 (if mh-showing-mode
bdcfe844 824 (if mh-page-to-next-msg-flag
c3d9274a
BW
825 (if (equal mh-next-direction 'backward)
826 (mh-previous-undeleted-msg)
827 (mh-next-undeleted-msg))
828 (if (mh-in-show-buffer (mh-show-buffer)
829 (pos-visible-in-window-p (point-max)))
830 (progn
831 (message (format
832 "End of message (Type %s to read %s undeleted message)"
833 (single-key-description last-input-event)
834 (if (equal mh-next-direction 'backward)
835 "previous"
836 "next")))
837 (setq mh-page-to-next-msg-flag t))
838 (scroll-other-window arg)))
a1b4049d 839 (mh-show)))
c26cf6c8 840
c26cf6c8
RS
841(defun mh-previous-page (&optional arg)
842 "Page the displayed message backwards.
843Scrolls ARG lines or a full screen if no argument is supplied."
844 (interactive "P")
845 (mh-in-show-buffer (mh-show-buffer)
846 (scroll-down arg)))
847
924df208
BW
848(defun mh-previous-undeleted-msg (&optional arg wait-after-complaining-flag)
849 "Move to the previous undeleted message ARG in window.
850If optional argument WAIT-AFTER-COMPLAINING-FLAG is non-nil and we are at the
851first undeleted message then pause for a second after printing message."
c26cf6c8
RS
852 (interactive "p")
853 (setq mh-next-direction 'backward)
854 (beginning-of-line)
bdcfe844 855 (cond ((re-search-backward mh-scan-good-msg-regexp nil t arg)
c3d9274a 856 (mh-maybe-show))
924df208
BW
857 (t (message "No previous undeleted message")
858 (if wait-after-complaining-flag (sit-for 1)))))
c3d9274a
BW
859
860(defun mh-previous-unread-msg (&optional count)
861 "Move to previous unread message.
862With optional argument COUNT, COUNT-1 unread messages before current message
863are skipped."
864 (interactive "p")
865 (unless (> count 0)
866 (error "The function mh-previous-unread-msg expects positive argument"))
867 (setq count (1- count))
868 (let ((unread-sequence (cdr (assoc mh-unseen-seq mh-seq-list)))
869 (cur-msg (mh-get-msg-num nil)))
870 (cond ((and (not cur-msg) (not (bobp))
871 ;; If we are at the end of the buffer back up one line and go
872 ;; to unread message after that.
873 (progn
874 (forward-line -1)
875 (setq cur-msg (mh-get-msg-num nil)))
876 nil))
877 ((or (null unread-sequence) (not cur-msg))
878 ;; No unread message or there aren't any messages in buffer...
879 (message "No more unread messages"))
880 ((progn
881 ;; Skip count messages...
882 (while (and unread-sequence (>= (car unread-sequence) cur-msg))
883 (setq unread-sequence (cdr unread-sequence)))
884 (while (> count 0)
885 (setq unread-sequence (cdr unread-sequence))
886 (setq count (1- count)))
887 (not (car unread-sequence)))
888 (message "No more unread messages"))
889 (t (mh-goto-msg (car unread-sequence))))))
bdcfe844
BW
890
891(defun mh-goto-next-button (backward-flag &optional criterion)
892 "Search for next button satisfying criterion.
893If BACKWARD-FLAG is non-nil search backward in the buffer for a mime button. If
894CRITERION is a function or a symbol which has a function binding then that
895function must return non-nil at the button we stop."
896 (unless (or (and (symbolp criterion) (fboundp criterion))
897 (functionp criterion))
898 (setq criterion (lambda (x) t)))
899 ;; Move to the next button in the buffer satisfying criterion
900 (goto-char (or (save-excursion
901 (beginning-of-line)
902 ;; Find point before current button
903 (let ((point-before-current-button
c3d9274a
BW
904 (save-excursion
905 (while (get-text-property (point) 'mh-data)
906 (unless (= (forward-line
907 (if backward-flag 1 -1))
908 0)
909 (if backward-flag
910 (goto-char (point-min))
911 (goto-char (point-max)))))
912 (point))))
913 ;; Skip over current button
914 (while (and (get-text-property (point) 'mh-data)
915 (not (if backward-flag (bobp) (eobp))))
916 (forward-line (if backward-flag -1 1)))
917 ;; Stop at next MIME button if any exists.
918 (block loop
919 (while (/= (progn
920 (unless (= (forward-line
921 (if backward-flag -1 1))
922 0)
923 (if backward-flag
924 (goto-char (point-max))
925 (goto-char (point-min)))
926 (beginning-of-line))
927 (point))
928 point-before-current-button)
929 (when (and (get-text-property (point) 'mh-data)
930 (funcall criterion (point)))
931 (return-from loop (point))))
932 nil)))
bdcfe844
BW
933 (point))))
934
935(defun mh-next-button (&optional backward-flag)
936 "Go to the next MIME button.
937Advance point to the next MIME button in the show buffer. If the end
938of buffer is reached then the search wraps over to the start of the
939buffer. With prefix argument, BACKWARD-FLAG the point will move to the
940previous MIME button."
941 (interactive (list current-prefix-arg))
942 (unless mh-showing-mode
943 (mh-show))
944 (mh-in-show-buffer (mh-show-buffer)
945 (mh-goto-next-button backward-flag)))
c26cf6c8 946
bdcfe844
BW
947(defun mh-prev-button ()
948 "Go to the prev MIME button.
949Move point to the previous MIME button in the show buffer. If the beginning
950of the buffer is reached then the search wraps over to the end of the
951buffer."
952 (interactive)
953 (mh-next-button t))
954
955(defun mh-folder-mime-action (part-index action include-security-flag)
956 "Go to PART-INDEX and carry out ACTION.
957If PART-INDEX is nil then go to the next part in the buffer. The search for
958the next buffer wraps around if end of buffer is reached. If argument
959INCLUDE-SECURITY-FLAG is non-nil then include security info buttons when
960searching for a suitable parts."
961 (unless mh-showing-mode
962 (mh-show))
963 (mh-in-show-buffer (mh-show-buffer)
964 (let ((criterion
c3d9274a
BW
965 (cond (part-index
966 (lambda (p)
967 (let ((part (get-text-property p 'mh-part)))
968 (and (integerp part) (= part part-index)))))
969 (t (lambda (p)
970 (if include-security-flag
971 (get-text-property p 'mh-data)
972 (integerp (get-text-property p 'mh-part)))))))
bdcfe844
BW
973 (point (point)))
974 (cond ((and (get-text-property point 'mh-part)
975 (or (null part-index)
976 (= (get-text-property point 'mh-part) part-index)))
977 (funcall action))
978 ((and (get-text-property point 'mh-data)
979 include-security-flag
980 (null part-index))
981 (funcall action))
982 (t
983 (mh-goto-next-button nil criterion)
984 (if (= (point) point)
985 (message "No matching MIME part found")
986 (funcall action)))))))
987
988(defun mh-folder-toggle-mime-part (part-index)
989 "Toggle display of button.
990If point in show buffer is at a button then that part is toggled.
991If not at a button and PART-INDEX is non-nil point is moved to that part.
992With nil PART-INDEX find the first button after point (search wraps around if
993end of buffer is reached) and toggle it."
994 (interactive "P")
995 (when (consp part-index) (setq part-index (car part-index)))
996 (mh-folder-mime-action part-index #'mh-press-button t))
997
998(defun mh-folder-inline-mime-part (part-index)
999 "Show the raw bytes of MIME part inline.
1000If point in show buffer is at a mime part then that part is inlined.
1001If not at a mime-part and PART-INDEX is non-nil point is moved to that part.
1002With nil PART-INDEX find the first button after point (search wraps around if
1003end of buffer is reached) and inline it."
1004 (interactive "P")
1005 (when (consp part-index) (setq part-index (car part-index)))
1006 (mh-folder-mime-action part-index #'mh-mime-inline-part nil))
1007
1008(defun mh-folder-save-mime-part (part-index)
1009 "Save MIME part.
1010If point in show buffer is at a mime part then that part is saved.
1011If not at a mime-part and PART-INDEX is non-nil point is moved to that part.
1012With nil PART-INDEX find the first button after point (search wraps around if
1013end of buffer is reached) and save it."
1014 (interactive "P")
1015 (when (consp part-index) (setq part-index (car part-index)))
1016 (mh-folder-mime-action part-index #'mh-mime-save-part nil))
1017
1018(defun mh-reset-threads-and-narrowing ()
1019 "Reset all variables pertaining to threads and narrowing.
1020Also removes all content from the folder buffer."
1021 (setq mh-view-ops ())
1022 (setq mh-narrowed-to-seq nil)
1023 (let ((buffer-read-only nil)) (erase-buffer)))
c26cf6c8 1024
bdcfe844 1025(defun mh-rescan-folder (&optional range dont-exec-pending)
c26cf6c8 1026 "Rescan a folder after optionally processing the outstanding commands.
a1b4049d 1027If optional prefix argument RANGE is provided, prompt for the range of
bdcfe844
BW
1028messages to display. Otherwise show the entire folder.
1029If optional argument DONT-EXEC-PENDING is non-nil then pending deletes and
1030refiles aren't carried out."
c26cf6c8 1031 (interactive (list (if current-prefix-arg
c3d9274a
BW
1032 (mh-read-msg-range mh-current-folder t)
1033 nil)))
c26cf6c8 1034 (setq mh-next-direction 'forward)
c3d9274a 1035 (let ((threaded-flag (memq 'unthread mh-view-ops)))
c3d9274a
BW
1036 (mh-scan-folder mh-current-folder (or range "all") dont-exec-pending)
1037 (cond (threaded-flag (mh-toggle-threads))
1038 (mh-index-data (mh-index-insert-folder-headers)))))
c26cf6c8
RS
1039
1040(defun mh-write-msg-to-file (msg file no-headers)
a1b4049d
BW
1041 "Append MSG to the end of a FILE.
1042If prefix argument NO-HEADERS is provided, write only the message body.
c26cf6c8
RS
1043Otherwise send the entire message including the headers."
1044 (interactive
1045 (list (mh-get-msg-num t)
c3d9274a
BW
1046 (let ((default-dir (if (eq 'write (car mh-last-destination-write))
1047 (file-name-directory
1048 (car (cdr mh-last-destination-write)))
1049 default-directory)))
1050 (read-file-name (format "Save message%s in file: "
1051 (if current-prefix-arg " body" ""))
1052 default-dir
1053 (if (eq 'write (car mh-last-destination-write))
1054 (car (cdr mh-last-destination-write))
1055 (expand-file-name "mail.out" default-dir))))
1056 current-prefix-arg))
847b8219 1057 (let ((msg-file-to-output (mh-msg-filename msg))
c3d9274a 1058 (output-file (mh-expand-file-name file)))
bdcfe844 1059 (setq mh-last-destination (list 'write file (if no-headers 'no-headers))
c3d9274a 1060 mh-last-destination-write mh-last-destination)
c26cf6c8 1061 (save-excursion
847b8219 1062 (set-buffer (get-buffer-create mh-temp-buffer))
c26cf6c8 1063 (erase-buffer)
847b8219 1064 (insert-file-contents msg-file-to-output)
c26cf6c8
RS
1065 (goto-char (point-min))
1066 (if no-headers (search-forward "\n\n"))
1067 (append-to-file (point) (point-max) output-file))))
1068
c26cf6c8
RS
1069(defun mh-toggle-showing ()
1070 "Toggle the scanning mode/showing mode of displaying messages."
1071 (interactive)
a1b4049d 1072 (if mh-showing-mode
c26cf6c8 1073 (mh-set-scan-mode)
a1b4049d 1074 (mh-show)))
c26cf6c8 1075
c26cf6c8 1076(defun mh-undo (msg-or-seq)
a1b4049d 1077 "Undo the pending deletion or refile of the specified MSG-OR-SEQ.
bdcfe844
BW
1078Default is the displayed message.
1079If optional prefix argument is provided, then prompt for the message sequence.
a1b4049d 1080If variable `transient-mark-mode' is non-nil and the mark is active, then the
924df208
BW
1081selected region is unmarked.
1082In a program, MSG-OR-SEQ can be a message number, a list of message numbers, a
1083region in a cons cell, or a sequence."
1084 (interactive (list (mh-interactive-msg-or-seq "Undo")))
c26cf6c8 1085 (cond ((numberp msg-or-seq)
c3d9274a
BW
1086 (let ((original-position (point)))
1087 (beginning-of-line)
1088 (while (not (or (looking-at mh-scan-deleted-msg-regexp)
1089 (looking-at mh-scan-refiled-msg-regexp)
1090 (and (eq mh-next-direction 'forward) (bobp))
1091 (and (eq mh-next-direction 'backward)
1092 (save-excursion (forward-line) (eobp)))))
1093 (forward-line (if (eq mh-next-direction 'forward) -1 1)))
1094 (if (or (looking-at mh-scan-deleted-msg-regexp)
1095 (looking-at mh-scan-refiled-msg-regexp))
1096 (progn
1097 (mh-undo-msg (mh-get-msg-num t))
1098 (mh-maybe-show))
1099 (goto-char original-position)
1100 (error "Nothing to undo"))))
924df208
BW
1101 (t (mh-iterate-on-msg-or-seq () msg-or-seq
1102 (mh-undo-msg nil))))
c26cf6c8
RS
1103 (if (not (mh-outstanding-commands-p))
1104 (mh-set-folder-modified-p nil)))
1105
c3d9274a
BW
1106;;;###mh-autoload
1107(defun mh-folder-line-matches-show-buffer-p ()
1108 "Return t if the message under point in folder-mode is in the show buffer.
1109Return nil in any other circumstance (no message under point, no show buffer,
1110the message in the show buffer doesn't match."
1111 (and (eq major-mode 'mh-folder-mode)
1112 (mh-get-msg-num nil)
1113 mh-show-buffer
1114 (get-buffer mh-show-buffer)
1115 (buffer-file-name (get-buffer mh-show-buffer))
1116 (string-match ".*/\\([0-9]+\\)$"
1117 (buffer-file-name (get-buffer mh-show-buffer)))
1118 (string-equal
1119 (match-string 1 (buffer-file-name (get-buffer mh-show-buffer)))
1120 (int-to-string (mh-get-msg-num nil)))))
1121
1122(eval-when-compile (require 'gnus))
1123
1124(defmacro mh-macro-expansion-time-gnus-version ()
1125 "Return Gnus version available at macro expansion time.
1126The macro evaluates the Gnus version at macro expansion time. If MH-E was
1127compiled then macro expansion happens at compile time."
1128 gnus-version)
1129
1130(defun mh-run-time-gnus-version ()
1131 "Return Gnus version available at run time."
1132 (require 'gnus)
1133 gnus-version)
1134
847b8219 1135;;;###autoload
c26cf6c8 1136(defun mh-version ()
bdcfe844 1137 "Display version information about MH-E and the MH mail handling system."
c26cf6c8
RS
1138 (interactive)
1139 (mh-find-progs)
3d7ca223 1140 (set-buffer (get-buffer-create mh-info-buffer))
c26cf6c8 1141 (erase-buffer)
c3d9274a
BW
1142 ;; MH-E version.
1143 (insert "MH-E " mh-version "\n\n")
1144 ;; MH-E compilation details.
1145 (insert "MH-E compilation details:\n")
1146 (let* ((compiled-mhe (byte-code-function-p (symbol-function 'mh-version)))
1147 (gnus-compiled-version (if compiled-mhe
1148 (mh-macro-expansion-time-gnus-version)
1149 "N/A")))
1150 (insert " Byte compiled:\t\t" (if compiled-mhe "yes" "no") "\n"
1151 " Gnus (compile-time):\t" gnus-compiled-version "\n"
1152 " Gnus (run-time):\t" (mh-run-time-gnus-version) "\n\n"))
1153 ;; Emacs version.
1154 (insert (emacs-version) "\n\n")
a1b4049d 1155 ;; MH version.
c26cf6c8
RS
1156 (let ((help-start (point)))
1157 (condition-case err-data
c3d9274a 1158 (mh-exec-cmd-output "inc" nil (if mh-nmh-flag "-version" "-help"))
a1b4049d 1159 (file-error (insert (mapconcat 'concat (cdr err-data) ": ") "\n")))
c26cf6c8 1160 (goto-char help-start)
bdcfe844 1161 (if mh-nmh-flag
c3d9274a 1162 (search-forward "inc -- " nil t)
a1b4049d
BW
1163 (search-forward "version: " nil t))
1164 (delete-region help-start (point)))
1165 (goto-char (point-max))
c3d9274a
BW
1166 (insert " mh-progs:\t" mh-progs "\n"
1167 " mh-lib:\t" mh-lib "\n"
1168 " mh-lib-progs:\t" mh-lib-progs "\n\n")
a1b4049d
BW
1169 ;; Linux version.
1170 (condition-case ()
1171 (call-process "uname" nil t nil "-a")
1172 (file-error))
1173 (goto-char (point-min))
3d7ca223 1174 (display-buffer mh-info-buffer))
c26cf6c8 1175
3d7ca223
BW
1176(defun mh-parse-flist-output-line (line &optional current-folder)
1177 "Parse LINE to generate folder name, unseen messages and total messages.
1178If CURRENT-FOLDER is non-nil then it contains the current folder name and it is
1179used to avoid problems in corner cases involving folders whose names end with a
1180'+' character."
c3d9274a
BW
1181 (with-temp-buffer
1182 (insert line)
1183 (goto-char (point-max))
1184 (let (folder unseen total p)
1185 (when (search-backward " out of " (point-min) t)
1186 (setq total (read-from-string
1187 (buffer-substring-no-properties
1188 (match-end 0) (line-end-position))))
1189 (when (search-backward " in sequence " (point-min) t)
1190 (setq p (point))
1191 (when (search-backward " has " (point-min) t)
1192 (setq unseen (read-from-string (buffer-substring-no-properties
1193 (match-end 0) p)))
3d7ca223 1194 (while (eq (char-after) ? )
c3d9274a
BW
1195 (backward-char))
1196 (setq folder (buffer-substring-no-properties
1197 (point-min) (1+ (point))))
3d7ca223
BW
1198 (when (and (equal (aref folder (1- (length folder))) ?+)
1199 (equal current-folder folder))
1200 (setq folder (substring folder 0 (1- (length folder)))))
c3d9274a
BW
1201 (values (format "+%s" folder) (car unseen) (car total))))))))
1202
1203(defun mh-folder-size (folder)
1204 "Find size of FOLDER."
1205 (with-temp-buffer
1206 (call-process (expand-file-name "flist" mh-progs) nil t nil
3d7ca223 1207 "-norecurse" folder "-sequence" (symbol-name mh-unseen-seq))
c3d9274a 1208 (goto-char (point-min))
924df208 1209 (multiple-value-bind (folder unseen total)
c3d9274a
BW
1210 (mh-parse-flist-output-line
1211 (buffer-substring (point) (line-end-position)))
924df208 1212 (values total unseen folder))))
c3d9274a
BW
1213
1214(defun mh-visit-folder (folder &optional range index-data)
847b8219 1215 "Visit FOLDER and display RANGE of messages.
c3d9274a
BW
1216Do not call this function from outside MH-E; see \\[mh-rmail] instead.
1217
1218If RANGE is nil (the default if it is omitted when called non-interactively),
1219then all messages in FOLDER are displayed.
1220
1221If an index buffer is being created then INDEX-DATA is used to initialize the
3d7ca223
BW
1222index buffer specific data structures.
1223
1224A prefix argument will cause a prompt for the RANGE of messages
1225regardless of the size of the `mh-large-folder' variable."
c3d9274a 1226 (interactive (let ((folder-name (mh-prompt-for-folder "Visit" mh-inbox t)))
3d7ca223
BW
1227 (list folder-name
1228 (mh-read-msg-range folder-name current-prefix-arg))))
c3d9274a 1229 (let ((config (current-window-configuration))
924df208 1230 (current-buffer (current-buffer))
c3d9274a
BW
1231 (threaded-view-flag mh-show-threads-flag))
1232 (save-excursion
1233 (when (get-buffer folder)
1234 (set-buffer folder)
924df208 1235 (setq threaded-view-flag (memq 'unthread mh-view-ops))))
c3d9274a
BW
1236 (when index-data
1237 (mh-make-folder folder)
1238 (setq mh-index-data (car index-data)
1239 mh-index-msg-checksum-map (make-hash-table :test #'equal)
1240 mh-index-checksum-origin-map (make-hash-table :test #'equal))
1241 (mh-index-update-maps folder (cadr index-data)))
c26cf6c8 1242 (mh-scan-folder folder (or range "all"))
c3d9274a
BW
1243 (cond ((and threaded-view-flag
1244 (save-excursion
1245 (goto-char (point-min))
1246 (or (null mh-large-folder)
1247 (not (equal (forward-line mh-large-folder) 0))
1248 (and (message "Not threading since the number of messages exceeds `mh-large-folder'")
1249 nil))))
1250 (mh-toggle-threads))
1251 (mh-index-data
1252 (mh-index-insert-folder-headers)))
1253 (unless mh-showing-mode (delete-other-windows))
924df208
BW
1254 (unless (eq current-buffer (current-buffer))
1255 (setq mh-previous-window-config config)))
c26cf6c8
RS
1256 nil)
1257
c3d9274a 1258;;;###mh-autoload
847b8219 1259(defun mh-update-sequences ()
bdcfe844
BW
1260 "Update MH's Unseen-Sequence and current folder and message.
1261Flush MH-E's state out to MH. The message at the cursor becomes current."
847b8219
KH
1262 (interactive)
1263 ;; mh-update-sequences is the opposite of mh-read-folder-sequences,
bdcfe844 1264 ;; which updates MH-E's state from MH.
847b8219 1265 (let ((folder-set (mh-update-unseen))
c3d9274a 1266 (new-cur (mh-get-msg-num nil)))
847b8219 1267 (if new-cur
c3d9274a
BW
1268 (let ((seq-entry (mh-find-seq 'cur)))
1269 (mh-remove-cur-notation)
1270 (setcdr seq-entry
1271 (list new-cur)) ;delete-seq-locally, add-msgs-to-seq
1272 (mh-define-sequence 'cur (list new-cur))
1273 (beginning-of-line)
1274 (if (looking-at mh-scan-good-msg-regexp)
3d7ca223 1275 (mh-notate-cur)))
847b8219 1276 (or folder-set
c3d9274a 1277 (save-excursion
a1b4049d
BW
1278 ;; psg - mh-current-folder is nil if mh-summary-height < 4 !
1279 ;; So I added this sanity check.
1280 (if (stringp mh-current-folder)
1281 (mh-exec-cmd-quiet t "folder" mh-current-folder "-fast")
1282 (mh-exec-cmd-quiet t "folder" "-fast")))))))
847b8219 1283
c26cf6c8
RS
1284\f
1285
1286;;; Support routines.
1287
1288(defun mh-delete-a-msg (msg)
bdcfe844 1289 "Delete the MSG.
3d7ca223
BW
1290If MSG is nil then the message at point is deleted.
1291
bdcfe844
BW
1292The value of `mh-delete-msg-hook' is a list of functions to be called, with no
1293arguments, after the message has been deleted."
c26cf6c8 1294 (save-excursion
3d7ca223
BW
1295 (if (numberp msg)
1296 (mh-goto-msg msg nil t)
1297 (beginning-of-line)
1298 (setq msg (mh-get-msg-num t)))
a1b4049d 1299 (if (looking-at mh-scan-refiled-msg-regexp)
c3d9274a 1300 (error "Message %d is refiled. Undo refile before deleting" msg))
a1b4049d 1301 (if (looking-at mh-scan-deleted-msg-regexp)
c3d9274a
BW
1302 nil
1303 (mh-set-folder-modified-p t)
1304 (setq mh-delete-list (cons msg mh-delete-list))
3d7ca223 1305 (mh-notate nil mh-note-deleted mh-cmd-note)
c3d9274a 1306 (run-hooks 'mh-delete-msg-hook))))
c26cf6c8 1307
bdcfe844
BW
1308(defun mh-refile-a-msg (msg folder)
1309 "Refile MSG in FOLDER.
3d7ca223
BW
1310If MSG is nil then the message at point is refiled.
1311
bdcfe844
BW
1312Folder is a symbol, not a string.
1313The value of `mh-refile-msg-hook' is a list of functions to be called, with no
1314arguments, after the message has been refiled."
c26cf6c8 1315 (save-excursion
3d7ca223
BW
1316 (if (numberp msg)
1317 (mh-goto-msg msg nil t)
1318 (beginning-of-line)
1319 (setq msg (mh-get-msg-num t)))
a1b4049d 1320 (cond ((looking-at mh-scan-deleted-msg-regexp)
c3d9274a
BW
1321 (error "Message %d is deleted. Undo delete before moving" msg))
1322 ((looking-at mh-scan-refiled-msg-regexp)
1323 (if (y-or-n-p
1324 (format "Message %d already refiled. Copy to %s as well? "
1325 msg folder))
1326 (mh-exec-cmd "refile" (mh-get-msg-num t) "-link"
1327 "-src" mh-current-folder
1328 (symbol-name folder))
1329 (message "Message not copied.")))
1330 (t
1331 (mh-set-folder-modified-p t)
1332 (cond ((null (assoc folder mh-refile-list))
1333 (push (list folder msg) mh-refile-list))
1334 ((not (member msg (cdr (assoc folder mh-refile-list))))
1335 (push msg (cdr (assoc folder mh-refile-list)))))
3d7ca223 1336 (mh-notate nil mh-note-refiled mh-cmd-note)
c3d9274a 1337 (run-hooks 'mh-refile-msg-hook)))))
c26cf6c8 1338
924df208
BW
1339(defun mh-next-msg (&optional wait-after-complaining-flag)
1340 "Move backward or forward to the next undeleted message in the buffer.
1341If optional argument WAIT-AFTER-COMPLAINING-FLAG is non-nil and we are at the
1342last message, then wait for a second after telling the user that there aren't
1343any more unread messages."
c26cf6c8 1344 (if (eq mh-next-direction 'forward)
924df208
BW
1345 (mh-next-undeleted-msg 1 wait-after-complaining-flag)
1346 (mh-previous-undeleted-msg 1 wait-after-complaining-flag)))
c3d9274a
BW
1347
1348(defun mh-next-unread-msg (&optional count)
1349 "Move to next unread message.
1350With optional argument COUNT, COUNT-1 unread messages are skipped."
1351 (interactive "p")
1352 (unless (> count 0)
1353 (error "The function mh-next-unread-msg expects positive argument"))
1354 (setq count (1- count))
1355 (let ((unread-sequence (reverse (cdr (assoc mh-unseen-seq mh-seq-list))))
1356 (cur-msg (mh-get-msg-num nil)))
1357 (cond ((and (not cur-msg) (not (bobp))
1358 ;; If we are at the end of the buffer back up one line and go
1359 ;; to unread message after that.
1360 (progn
1361 (forward-line -1)
1362 (setq cur-msg (mh-get-msg-num nil)))
1363 nil))
1364 ((or (null unread-sequence) (not cur-msg))
1365 ;; No unread message or there aren't any messages in buffer...
1366 (message "No more unread messages"))
1367 ((progn
1368 ;; Skip messages
1369 (while (and unread-sequence (>= cur-msg (car unread-sequence)))
1370 (setq unread-sequence (cdr unread-sequence)))
1371 (while (> count 0)
1372 (setq unread-sequence (cdr unread-sequence))
1373 (setq count (1- count)))
1374 (not (car unread-sequence)))
1375 (message "No more unread messages"))
1376 (t (mh-goto-msg (car unread-sequence))))))
c26cf6c8 1377
c26cf6c8 1378(defun mh-set-scan-mode ()
bdcfe844 1379 "Display the scan listing buffer, but do not show a message."
c26cf6c8
RS
1380 (if (get-buffer mh-show-buffer)
1381 (delete-windows-on mh-show-buffer))
a1b4049d 1382 (mh-showing-mode 0)
dc9bdc98 1383 (force-mode-line-update)
bdcfe844 1384 (if mh-recenter-summary-flag
c26cf6c8
RS
1385 (mh-recenter nil)))
1386
c26cf6c8 1387(defun mh-undo-msg (msg)
3d7ca223
BW
1388 "Undo the deletion or refile of one MSG.
1389If MSG is nil then act on the message at point"
1390 (save-excursion
1391 (if (numberp msg)
1392 (mh-goto-msg msg t t)
1393 (beginning-of-line)
1394 (setq msg (mh-get-msg-num t)))
1395 (cond ((memq msg mh-delete-list)
1396 (setq mh-delete-list (delq msg mh-delete-list)))
1397 (t
1398 (dolist (folder-msg-list mh-refile-list)
1399 (setf (cdr folder-msg-list) (remove msg (cdr folder-msg-list))))
1400 (setq mh-refile-list (loop for x in mh-refile-list
1401 unless (null (cdr x)) collect x))))
1402 (mh-notate nil ? mh-cmd-note)))
c26cf6c8 1403
c26cf6c8
RS
1404\f
1405
1406;;; The folder data abstraction.
1407
1408(defun mh-make-folder (name)
bdcfe844
BW
1409 "Create a new mail folder called NAME.
1410Make it the current folder."
c26cf6c8
RS
1411 (switch-to-buffer name)
1412 (setq buffer-read-only nil)
1413 (erase-buffer)
bdcfe844
BW
1414 (if mh-adaptive-cmd-note-flag
1415 (mh-set-cmd-note (mh-message-number-width name)))
c26cf6c8
RS
1416 (setq buffer-read-only t)
1417 (mh-folder-mode)
1418 (mh-set-folder-modified-p nil)
847b8219
KH
1419 (setq buffer-file-name mh-folder-filename)
1420 (mh-make-folder-mode-line))
c26cf6c8 1421
c26cf6c8
RS
1422;;; Ensure new buffers won't get this mode if default-major-mode is nil.
1423(put 'mh-folder-mode 'mode-class 'special)
1424
bdcfe844
BW
1425\f
1426
1427;;; Menu extracted from mh-menubar.el V1.1 (31 July 2001)
1428;;; Menus for folder mode: folder, message, sequence (in that order)
1429;;; folder-mode "Sequence" menu
1430(easy-menu-define
1431 mh-folder-sequence-menu mh-folder-mode-map "Menu for MH-E folder-sequence."
1432 '("Sequence"
1433 ["Add Message to Sequence..." mh-put-msg-in-seq (mh-get-msg-num nil)]
1434 ["List Sequences for Message" mh-msg-is-in-seq (mh-get-msg-num nil)]
1435 ["Delete Message from Sequence..." mh-delete-msg-from-seq
1436 (mh-get-msg-num nil)]
1437 ["List Sequences in Folder..." mh-list-sequences t]
1438 ["Delete Sequence..." mh-delete-seq t]
1439 ["Narrow to Sequence..." mh-narrow-to-seq t]
1440 ["Widen from Sequence" mh-widen mh-narrowed-to-seq]
1441 "--"
1442 ["Narrow to Subject Sequence" mh-narrow-to-subject t]
924df208
BW
1443 ["Narrow to Tick Sequence" mh-narrow-to-tick
1444 (and mh-tick-seq (mh-seq-msgs (mh-find-seq mh-tick-seq)))]
bdcfe844 1445 ["Delete Rest of Same Subject" mh-delete-subject t]
924df208 1446 ["Toggle Tick Mark" mh-toggle-tick t]
bdcfe844
BW
1447 "--"
1448 ["Push State Out to MH" mh-update-sequences t]))
1449
1450;;; folder-mode "Message" menu
1451(easy-menu-define
1452 mh-folder-message-menu mh-folder-mode-map "Menu for MH-E folder-message."
1453 '("Message"
1454 ["Show Message" mh-show (mh-get-msg-num nil)]
1455 ["Show Message with Header" mh-header-display (mh-get-msg-num nil)]
1456 ["Next Message" mh-next-undeleted-msg t]
1457 ["Previous Message" mh-previous-undeleted-msg t]
1458 ["Go to First Message" mh-first-msg t]
1459 ["Go to Last Message" mh-last-msg t]
1460 ["Go to Message by Number..." mh-goto-msg t]
1461 ["Modify Message" mh-modify]
1462 ["Delete Message" mh-delete-msg (mh-get-msg-num nil)]
1463 ["Refile Message" mh-refile-msg (mh-get-msg-num nil)]
1464 ["Undo Delete/Refile" mh-undo t]
1465 ["Process Delete/Refile" mh-execute-commands
1466 (or mh-refile-list mh-delete-list)]
1467 "--"
1468 ["Compose a New Message" mh-send t]
1469 ["Reply to Message..." mh-reply (mh-get-msg-num nil)]
1470 ["Forward Message..." mh-forward (mh-get-msg-num nil)]
1471 ["Redistribute Message..." mh-redistribute (mh-get-msg-num nil)]
1472 ["Edit Message Again" mh-edit-again (mh-get-msg-num nil)]
1473 ["Re-edit a Bounced Message" mh-extract-rejected-mail t]
1474 "--"
1475 ["Copy Message to Folder..." mh-copy-msg (mh-get-msg-num nil)]
1476 ["Print Message" mh-print-msg (mh-get-msg-num nil)]
1477 ["Write Message to File..." mh-write-msg-to-file
1478 (mh-get-msg-num nil)]
1479 ["Pipe Message to Command..." mh-pipe-msg (mh-get-msg-num nil)]
1480 ["Unpack Uuencoded Message..." mh-store-msg (mh-get-msg-num nil)]
1481 ["Burst Digest Message" mh-burst-digest (mh-get-msg-num nil)]))
1482
1483;;; folder-mode "Folder" menu
1484(easy-menu-define
1485 mh-folder-folder-menu mh-folder-mode-map "Menu for MH-E folder."
1486 '("Folder"
1487 ["Incorporate New Mail" mh-inc-folder t]
1488 ["Toggle Show/Folder" mh-toggle-showing t]
1489 ["Execute Delete/Refile" mh-execute-commands
1490 (or mh-refile-list mh-delete-list)]
1491 ["Rescan Folder" mh-rescan-folder t]
1492 ["Thread Folder" mh-toggle-threads
1493 (not (memq 'unthread mh-view-ops))]
1494 ["Pack Folder" mh-pack-folder t]
1495 ["Sort Folder" mh-sort-folder t]
1496 "--"
1497 ["List Folders" mh-list-folders t]
1498 ["Visit a Folder..." mh-visit-folder t]
924df208 1499 ["View New Messages" mh-index-new-messages t]
bdcfe844
BW
1500 ["Search a Folder..." mh-search-folder t]
1501 ["Indexed Search..." mh-index-search t]
1502 "--"
1503 ["Quit MH-E" mh-quit t]))
1504
1505\f
1506
bdcfe844
BW
1507(defmacro mh-remove-xemacs-horizontal-scrollbar ()
1508 "Get rid of the horizontal scrollbar that XEmacs insists on putting in."
1509 (when mh-xemacs-flag
1510 `(if (and (featurep 'scrollbar)
1511 (fboundp 'set-specifier))
1512 (set-specifier horizontal-scrollbar-visible-p nil
1513 (cons (current-buffer) nil)))))
1514
924df208
BW
1515;; Avoid compiler warnings in XEmacs and GNU Emacs 20
1516(eval-when-compile (defvar tool-bar-mode))
1517
bdcfe844
BW
1518(defmacro mh-write-file-functions-compat ()
1519 "Return `write-file-functions' if it exists.
1520Otherwise return `local-write-file-hooks'. This macro exists purely for
1521compatibility. The former symbol is used in Emacs 21.4 onward while the latter
1522is used in previous versions and XEmacs."
1523 (if (boundp 'write-file-functions)
c3d9274a
BW
1524 ''write-file-functions ;Emacs 21.4
1525 ''local-write-file-hooks)) ;<Emacs 21.4, XEmacs
bdcfe844 1526
924df208
BW
1527;; Avoid compiler warning
1528(defvar tool-bar-map)
1529
a1b4049d 1530(define-derived-mode mh-folder-mode fundamental-mode "MH-Folder"
bdcfe844 1531 "Major MH-E mode for \"editing\" an MH folder scan listing.\\<mh-folder-mode-map>
a1b4049d 1532
c26cf6c8
RS
1533You can show the message the cursor is pointing to, and step through the
1534messages. Messages can be marked for deletion or refiling into another
1535folder; these commands are executed all at once with a separate command.
1536
1537A prefix argument (\\[universal-argument]) to delete, refile, list, or undo
a1b4049d
BW
1538applies the action to a message sequence. If `transient-mark-mode',
1539is non-nil, the action is applied to the region.
c26cf6c8 1540
a1b4049d
BW
1541Options that control this mode can be changed with \\[customize-group];
1542specify the \"mh\" group. In particular, please see the `mh-scan-format-file'
1543option if you wish to modify scan's format.
c26cf6c8 1544
a1b4049d 1545When a folder is visited, the hook `mh-folder-mode-hook' is run.
c26cf6c8 1546
a1b4049d 1547\\{mh-folder-mode-map}"
c26cf6c8 1548
a1b4049d 1549 (make-local-variable 'font-lock-defaults)
c3d9274a 1550 (setq font-lock-defaults '(mh-folder-font-lock-keywords t))
847b8219 1551 (mh-make-local-vars
c3d9274a 1552 'mh-current-folder (buffer-name) ; Name of folder, a string
c26cf6c8 1553 'mh-show-buffer (format "show-%s" (buffer-name)) ; Buffer that displays msgs
c3d9274a 1554 'mh-folder-filename ; e.g. "/usr/foobar/Mail/inbox/"
c26cf6c8 1555 (file-name-as-directory (mh-expand-file-name (buffer-name)))
3d7ca223
BW
1556 'mh-arrow-marker (make-marker) ; Marker where arrow is displayed
1557 'overlay-arrow-position nil ; Allow for simultaneous display in
1558 'overlay-arrow-string ">" ; different MH-E buffers.
c3d9274a
BW
1559 'mh-showing-mode nil ; Show message also?
1560 'mh-delete-list nil ; List of msgs nums to delete
1561 'mh-refile-list nil ; List of folder names in mh-seq-list
1562 'mh-seq-list nil ; Alist of (seq . msgs) nums
1563 'mh-seen-list nil ; List of displayed messages
1564 'mh-next-direction 'forward ; Direction to move to next message
1565 'mh-narrowed-to-seq nil ; Sequence display is narrowed to
924df208
BW
1566 'mh-tick-seq-changed-when-narrowed-flag nil
1567 ; Tick seq changed while narrowed
bdcfe844
BW
1568 'mh-view-ops () ; Stack that keeps track of the order
1569 ; in which narrowing/threading has been
1570 ; carried out.
c3d9274a
BW
1571 'mh-index-data nil ; If the folder was created by a call
1572 ; to mh-index-search this contains info
1573 ; about the search results.
1574 'mh-index-previous-search nil ; Previous folder and search-regexp
1575 'mh-index-msg-checksum-map nil ; msg -> checksum map
1576 'mh-index-checksum-origin-map nil ; checksum -> ( orig-folder, orig-msg )
1577 'mh-first-msg-num nil ; Number of first msg in buffer
1578 'mh-last-msg-num nil ; Number of last msg in buffer
1579 'mh-msg-count nil ; Number of msgs in buffer
1580 'mh-mode-line-annotation nil ; Indicates message range
1581 'mh-previous-window-config nil) ; Previous window configuration
bdcfe844 1582 (mh-remove-xemacs-horizontal-scrollbar)
c26cf6c8
RS
1583 (setq truncate-lines t)
1584 (auto-save-mode -1)
1585 (setq buffer-offer-save t)
924df208 1586 (mh-make-local-hook (mh-write-file-functions-compat))
bdcfe844 1587 (add-hook (mh-write-file-functions-compat) 'mh-execute-commands nil t)
c26cf6c8 1588 (make-local-variable 'revert-buffer-function)
c3d9274a 1589 (make-local-variable 'hl-line-mode) ; avoid pollution
924df208 1590 (mh-funcall-if-exists hl-line-mode 1)
c26cf6c8 1591 (setq revert-buffer-function 'mh-undo-folder)
a1b4049d 1592 (or (assq 'mh-showing-mode minor-mode-alist)
c26cf6c8 1593 (setq minor-mode-alist
c3d9274a 1594 (cons '(mh-showing-mode " Show") minor-mode-alist)))
a1b4049d
BW
1595 (easy-menu-add mh-folder-sequence-menu)
1596 (easy-menu-add mh-folder-message-menu)
1597 (easy-menu-add mh-folder-folder-menu)
1598 (if (and (boundp 'tool-bar-mode) tool-bar-mode)
bdcfe844 1599 (set (make-local-variable 'tool-bar-map) mh-folder-tool-bar-map))
924df208 1600 (mh-funcall-if-exists mh-toolbar-init :folder)
bdcfe844 1601 (if (and mh-xemacs-flag
c3d9274a
BW
1602 font-lock-auto-fontify)
1603 (turn-on-font-lock))) ; Force font-lock in XEmacs.
c26cf6c8 1604
847b8219 1605(defun mh-make-local-vars (&rest pairs)
bdcfe844
BW
1606 "Initialize local variables according to the variable-value PAIRS."
1607
c26cf6c8 1608 (while pairs
1e495fc7 1609 (set (make-local-variable (car pairs)) (car (cdr pairs)))
c26cf6c8
RS
1610 (setq pairs (cdr (cdr pairs)))))
1611
bdcfe844
BW
1612(defun mh-scan-folder (folder range &optional dont-exec-pending)
1613 "Scan the FOLDER over the RANGE.
1614If the optional argument DONT-EXEC-PENDING is non-nil then pending deletes and
1615refiles aren't carried out.
1616Return in the folder's buffer."
c26cf6c8 1617 (cond ((null (get-buffer folder))
c3d9274a
BW
1618 (mh-make-folder folder))
1619 (t
924df208
BW
1620 (unless dont-exec-pending
1621 (mh-process-or-undo-commands folder)
1622 (mh-reset-threads-and-narrowing))
c3d9274a 1623 (switch-to-buffer folder)))
c26cf6c8 1624 (mh-regenerate-headers range)
a1b4049d 1625 (if (zerop (buffer-size))
bdcfe844 1626 (if (equal range "all")
c3d9274a
BW
1627 (message "Folder %s is empty" folder)
1628 (message "No messages in %s, range %s" folder range))
bdcfe844 1629 (mh-goto-cur-msg))
924df208 1630 (when (mh-outstanding-commands-p)
3d7ca223 1631 (mh-notate-deleted-and-refiled)))
c26cf6c8 1632
c3d9274a
BW
1633(defun mh-set-cmd-note (width)
1634 "Set `mh-cmd-note' to WIDTH characters (minimum of 2).
1635
1636If `mh-scan-format-file' specifies nil or a filename, then this function
1637will NOT update `mh-cmd-note'."
1638 ;; Add one to the width to always have whitespace in column zero.
1639 (setq width (max (1+ width) 2))
1640 (if (and (equal mh-scan-format-file t)
1641 (not (eq mh-cmd-note width)))
1642 (setq mh-cmd-note width))
1643 mh-cmd-note)
1644
847b8219 1645(defun mh-regenerate-headers (range &optional update)
bdcfe844
BW
1646 "Scan folder over range RANGE.
1647If UPDATE, append the scan lines, otherwise replace."
847b8219 1648 (let ((folder mh-current-folder)
bdcfe844 1649 (range (if (and range (atom range)) (list range) range))
c3d9274a 1650 scan-start)
c26cf6c8
RS
1651 (message "Scanning %s..." folder)
1652 (with-mh-folder-updating (nil)
847b8219 1653 (if update
c3d9274a
BW
1654 (goto-char (point-max))
1655 (delete-region (point-min) (point-max))
1656 (if mh-adaptive-cmd-note-flag
1657 (mh-set-cmd-note (mh-message-number-width folder))))
847b8219 1658 (setq scan-start (point))
bdcfe844
BW
1659 (apply #'mh-exec-cmd-output
1660 mh-scan-prog nil
1661 (mh-scan-format)
1662 "-noclear" "-noheader"
1663 "-width" (window-width)
1664 folder range)
847b8219 1665 (goto-char scan-start)
c26cf6c8 1666 (cond ((looking-at "scan: no messages in")
c3d9274a
BW
1667 (keep-lines mh-scan-valid-regexp)) ; Flush random scan lines
1668 ((looking-at "scan: bad message list ")
1669 (keep-lines mh-scan-valid-regexp))
1670 ((looking-at "scan: ")) ; Keep error messages
1671 (t
1672 (keep-lines mh-scan-valid-regexp))) ; Flush random scan lines
c26cf6c8
RS
1673 (setq mh-seq-list (mh-read-folder-sequences folder nil))
1674 (mh-notate-user-sequences)
847b8219 1675 (or update
c3d9274a
BW
1676 (setq mh-mode-line-annotation
1677 (if (equal range '("all"))
1678 nil
1679 mh-partial-folder-mode-line-annotation)))
847b8219 1680 (mh-make-folder-mode-line))
c26cf6c8
RS
1681 (message "Scanning %s...done" folder)))
1682
bdcfe844
BW
1683(defun mh-generate-new-cmd-note (folder)
1684 "Fix the `mh-cmd-note' value for this FOLDER.
1685
1686After doing an `mh-get-new-mail' operation in this FOLDER, at least
1687one line that looks like a truncated message number was found.
1688
1689Remove the text added by the last `mh-inc' command. It should be the
1690messages cur-last. Call `mh-set-cmd-note' with the widest message number
1691in FOLDER.
1692
1693Reformat the message number width on each line in the buffer and trim
1694the line length to fit in the window.
1695
1696Rescan the FOLDER in the range cur-last in order to display the
1697messages that were removed earlier. They should all fit in the scan
1698line now with no message truncation."
1699 (save-excursion
1700 (let ((maxcol (1- (window-width)))
1701 (old-cmd-note mh-cmd-note)
c3d9274a
BW
1702 mh-cmd-note-fmt
1703 msgnum)
bdcfe844
BW
1704 ;; Nuke all of the lines just added by the last inc
1705 (delete-char (- (point-max) (point)))
1706 ;; Update the current buffer to reflect the new mh-cmd-note
1707 ;; value needed to display messages.
1708 (mh-set-cmd-note (mh-message-number-width folder))
1709 (setq mh-cmd-note-fmt (concat "%" (format "%d" mh-cmd-note) "d"))
1710 ;; Cleanup the messages that are in the buffer right now
1711 (goto-char (point-min))
1712 (cond ((memq 'unthread mh-view-ops)
1713 (mh-thread-add-spaces (- mh-cmd-note old-cmd-note)))
1714 (t (while (re-search-forward mh-scan-msg-number-regexp nil 0 1)
1715 ;; reformat the number to fix in mh-cmd-note columns
1716 (setq msgnum (string-to-number
1717 (buffer-substring
1718 (match-beginning 1) (match-end 1))))
1719 (replace-match (format mh-cmd-note-fmt msgnum))
1720 ;; trim the line to fix in the window
1721 (end-of-line)
1722 (let ((eol (point)))
1723 (move-to-column maxcol)
1724 (if (<= (point) eol)
c3d9274a 1725 (delete-char (- eol (point))))))))
bdcfe844
BW
1726 ;; now re-read the lost messages
1727 (goto-char (point-max))
1728 (prog1 (point)
1729 (mh-regenerate-headers "cur-last" t)))))
c26cf6c8
RS
1730
1731(defun mh-get-new-mail (maildrop-name)
bdcfe844
BW
1732 "Read new mail from MAILDROP-NAME into the current buffer.
1733Return in the current buffer."
c26cf6c8 1734 (let ((point-before-inc (point))
c3d9274a
BW
1735 (folder mh-current-folder)
1736 (new-mail-flag nil))
c26cf6c8 1737 (with-mh-folder-updating (t)
f965c3d7 1738 (if maildrop-name
c3d9274a
BW
1739 (message "inc %s -file %s..." folder maildrop-name)
1740 (message "inc %s..." folder))
c26cf6c8
RS
1741 (setq mh-next-direction 'forward)
1742 (goto-char (point-max))
1743 (let ((start-of-inc (point)))
bdcfe844 1744 (mh-remove-cur-notation)
c3d9274a
BW
1745 (if maildrop-name
1746 ;; I think MH 5 used "-ms-file" instead of "-file",
1747 ;; which would make inc'ing from maildrops fail.
1748 (mh-exec-cmd-output mh-inc-prog nil folder
1749 (mh-scan-format)
1750 "-file" (expand-file-name maildrop-name)
1751 "-width" (window-width)
1752 "-truncate")
bdcfe844
BW
1753 (mh-exec-cmd-output mh-inc-prog nil
1754 (mh-scan-format)
1755 "-width" (window-width)))
c3d9274a
BW
1756 (if maildrop-name
1757 (message "inc %s -file %s...done" folder maildrop-name)
1758 (message "inc %s...done" folder))
1759 (goto-char start-of-inc)
1760 (cond ((save-excursion
1761 (re-search-forward "^inc: no mail" nil t))
1762 (message "No new mail%s%s" (if maildrop-name " in " "")
1763 (if maildrop-name maildrop-name "")))
1764 ((and (when mh-narrowed-to-seq
bdcfe844
BW
1765 (let ((saved-text (buffer-substring-no-properties
1766 start-of-inc (point-max))))
1767 (delete-region start-of-inc (point-max))
1768 (unwind-protect (mh-widen)
1769 (goto-char (point-max))
1770 (setq start-of-inc (point))
1771 (insert saved-text)
1772 (goto-char start-of-inc))))
1773 nil))
1774 ((re-search-forward "^inc:" nil t) ; Error messages
c3d9274a
BW
1775 (error "Error incorporating mail"))
1776 ((and
1777 (equal mh-scan-format-file t)
1778 mh-adaptive-cmd-note-flag
1779 ;; Have we reached an edge condition?
1780 (save-excursion
1781 (re-search-forward mh-scan-msg-overflow-regexp nil 0 1))
1782 (setq start-of-inc (mh-generate-new-cmd-note folder))
1783 nil))
1784 (t
1785 (setq new-mail-flag t)))
1786 (keep-lines mh-scan-valid-regexp) ; Flush random scan lines
bdcfe844 1787 (setq mh-seq-list (mh-read-folder-sequences folder t))
c3d9274a 1788 (when (equal (point-max) start-of-inc)
3d7ca223 1789 (mh-notate-cur))
c3d9274a
BW
1790 (mh-notate-user-sequences)
1791 (if new-mail-flag
1792 (progn
1793 (mh-make-folder-mode-line)
924df208
BW
1794 (when (mh-speed-flists-active-p)
1795 (mh-speed-flists t mh-current-folder))
bdcfe844
BW
1796 (when (memq 'unthread mh-view-ops)
1797 (mh-thread-inc folder start-of-inc))
c3d9274a
BW
1798 (mh-goto-cur-msg))
1799 (goto-char point-before-inc))))))
c26cf6c8 1800
847b8219 1801(defun mh-make-folder-mode-line (&optional ignored)
bdcfe844
BW
1802 "Set the fields of the mode line for a folder buffer.
1803The optional argument is now obsolete and IGNORED. It used to be used to pass
1804in what is now stored in the buffer-local variable `mh-mode-line-annotation'."
c26cf6c8 1805 (save-excursion
bdcfe844
BW
1806 (save-window-excursion
1807 (mh-first-msg)
1808 (let ((new-first-msg-num (mh-get-msg-num nil)))
c3d9274a
BW
1809 (when (or (not (memq 'unthread mh-view-ops))
1810 (null mh-first-msg-num)
1811 (null new-first-msg-num)
1812 (< new-first-msg-num mh-first-msg-num))
1813 (setq mh-first-msg-num new-first-msg-num)))
bdcfe844
BW
1814 (mh-last-msg)
1815 (let ((new-last-msg-num (mh-get-msg-num nil)))
c3d9274a
BW
1816 (when (or (not (memq 'unthread mh-view-ops))
1817 (null mh-last-msg-num)
1818 (null new-last-msg-num)
1819 (> new-last-msg-num mh-last-msg-num))
1820 (setq mh-last-msg-num new-last-msg-num)))
bdcfe844 1821 (setq mh-msg-count (if mh-first-msg-num
c3d9274a
BW
1822 (count-lines (point-min) (point-max))
1823 0))
bdcfe844 1824 (setq mode-line-buffer-identification
3d7ca223 1825 (list (format " {%%b%s} %s msg%s"
c3d9274a
BW
1826 (if mh-mode-line-annotation
1827 (format "/%s" mh-mode-line-annotation)
1828 "")
1829 (if (zerop mh-msg-count)
1830 "no"
1831 (format "%d" mh-msg-count))
1832 (if (zerop mh-msg-count)
1833 "s"
1834 (cond ((> mh-msg-count 1)
1835 (format "s (%d-%d)" mh-first-msg-num
1836 mh-last-msg-num))
1837 (mh-first-msg-num
1838 (format " (%d)" mh-first-msg-num))
3d7ca223
BW
1839 (""))))))
1840 (mh-logo-display))))
c26cf6c8
RS
1841
1842(defun mh-unmark-all-headers (remove-all-flags)
bdcfe844
BW
1843 "Remove all '+' flags from the folder listing.
1844With non-nil argument REMOVE-ALL-FLAGS, remove all 'D', '^' and '%' flags too.
1845Optimized for speed (i.e., no regular expressions)."
c26cf6c8
RS
1846 (save-excursion
1847 (let ((case-fold-search nil)
c3d9274a
BW
1848 (last-line (1- (point-max)))
1849 char)
c26cf6c8
RS
1850 (mh-first-msg)
1851 (while (<= (point) last-line)
c3d9274a
BW
1852 (forward-char mh-cmd-note)
1853 (setq char (following-char))
1854 (if (or (and remove-all-flags
1855 (or (= char (aref mh-note-deleted 0))
1856 (= char (aref mh-note-refiled 0))))
1857 (= char (aref mh-note-cur 0)))
1858 (progn
1859 (delete-char 1)
1860 (insert " ")))
1861 (if remove-all-flags
1862 (progn
1863 (forward-char 1)
1864 (if (= (following-char) (aref mh-note-seq 0))
1865 (progn
1866 (delete-char 1)
1867 (insert " ")))))
1868 (forward-line)))))
c26cf6c8 1869
847b8219 1870(defun mh-remove-cur-notation ()
bdcfe844 1871 "Remove old cur notation."
847b8219
KH
1872 (let ((cur-msg (car (mh-seq-to-msgs 'cur))))
1873 (save-excursion
3d7ca223
BW
1874 (when (and cur-msg
1875 (mh-goto-msg cur-msg t t)
1876 (looking-at mh-scan-cur-msg-number-regexp))
1877 (mh-notate nil ? mh-cmd-note)
1878 (setq overlay-arrow-position nil)))))
847b8219 1879
bdcfe844
BW
1880(defun mh-remove-all-notation ()
1881 "Remove all notations on all scan lines that MH-E introduces."
1882 (save-excursion
3d7ca223 1883 (setq overlay-arrow-position nil)
bdcfe844
BW
1884 (goto-char (point-min))
1885 (while (not (eobp))
c3d9274a
BW
1886 (unless (or (equal (char-after) ?+) (eolp))
1887 (mh-notate nil ? mh-cmd-note)
1888 (when (eq (char-after (+ (point) mh-cmd-note 1)) (elt mh-note-seq 0))
1889 (mh-notate nil ? (1+ mh-cmd-note))))
bdcfe844
BW
1890 (forward-line))))
1891
c3d9274a 1892;;;###mh-autoload
bdcfe844
BW
1893(defun mh-goto-cur-msg (&optional minimal-changes-flag)
1894 "Position the cursor at the current message.
1895When optional argument MINIMAL-CHANGES-FLAG is non-nil, the function doesn't
1896recenter the folder buffer."
c26cf6c8
RS
1897 (let ((cur-msg (car (mh-seq-to-msgs 'cur))))
1898 (cond ((and cur-msg
c3d9274a
BW
1899 (mh-goto-msg cur-msg t t))
1900 (unless minimal-changes-flag
3d7ca223 1901 (mh-notate-cur)
bdcfe844
BW
1902 (mh-recenter 0)
1903 (mh-maybe-show cur-msg)))
c3d9274a 1904 (t
3d7ca223 1905 (setq overlay-arrow-position nil)
c3d9274a 1906 (message "No current message")))))
c26cf6c8 1907
c26cf6c8 1908(defun mh-process-or-undo-commands (folder)
bdcfe844
BW
1909 "If FOLDER has outstanding commands, then either process or discard them.
1910Called by functions like `mh-sort-folder', so also invalidate show buffer."
c26cf6c8
RS
1911 (set-buffer folder)
1912 (if (mh-outstanding-commands-p)
bdcfe844 1913 (if (or mh-do-not-confirm-flag
c3d9274a 1914 (y-or-n-p
924df208 1915 "Process outstanding deletes and refiles? "))
c3d9274a 1916 (mh-process-commands folder)
924df208 1917 (set-buffer folder)
c3d9274a 1918 (mh-undo-folder)))
c26cf6c8
RS
1919 (mh-update-unseen)
1920 (mh-invalidate-show-buffer))
1921
c26cf6c8 1922(defun mh-process-commands (folder)
bdcfe844
BW
1923 "Process outstanding commands for FOLDER.
1924The value of `mh-folder-updated-hook' is a list of functions to be called,
1925with no arguments, before the commands are processed."
c26cf6c8
RS
1926 (message "Processing deletes and refiles for %s..." folder)
1927 (set-buffer folder)
1928 (with-mh-folder-updating (nil)
a1b4049d
BW
1929 ;; Run the hook while the lists are still valid
1930 (run-hooks 'mh-folder-updated-hook)
1931
c26cf6c8
RS
1932 ;; Update the unseen sequence if it exists
1933 (mh-update-unseen)
1934
c3d9274a
BW
1935 (let ((redraw-needed-flag mh-index-data))
1936 ;; Remove invalid scan lines if we are in an index folder and then remove
1937 ;; the real messages
1938 (when mh-index-data
1939 (mh-index-delete-folder-headers)
1940 (mh-index-execute-commands))
1941
bdcfe844
BW
1942 ;; Then refile messages
1943 (mh-mapc #'(lambda (folder-msg-list)
1944 (let ((dest-folder (symbol-name (car folder-msg-list)))
1945 (msgs (cdr folder-msg-list)))
1946 (setq redraw-needed-flag t)
1947 (apply #'mh-exec-cmd
1948 "refile" "-src" folder dest-folder
1949 (mh-coalesce-msg-list msgs))
1950 (mh-delete-scan-msgs msgs)))
1951 mh-refile-list)
1952 (setq mh-refile-list ())
1953
1954 ;; Now delete messages
1955 (cond (mh-delete-list
1956 (setq redraw-needed-flag t)
1957 (apply 'mh-exec-cmd "rmm" folder
1958 (mh-coalesce-msg-list mh-delete-list))
1959 (mh-delete-scan-msgs mh-delete-list)
1960 (setq mh-delete-list nil)))
1961
1962 ;; Don't need to remove sequences since delete and refile do so.
1963 ;; Mark cur message
1964 (if (> (buffer-size) 0)
c3d9274a 1965 (mh-define-sequence 'cur (list (or (mh-get-msg-num nil) "last"))))
bdcfe844 1966
c3d9274a
BW
1967 ;; Redraw folder buffer if needed
1968 (when (and redraw-needed-flag)
924df208
BW
1969 (when (mh-speed-flists-active-p)
1970 (mh-speed-flists t mh-current-folder))
c3d9274a
BW
1971 (cond ((memq 'unthread mh-view-ops) (mh-thread-inc folder (point-max)))
1972 (mh-index-data (mh-index-insert-folder-headers)))))
c26cf6c8
RS
1973
1974 (and (buffer-file-name (get-buffer mh-show-buffer))
c3d9274a
BW
1975 (not (file-exists-p (buffer-file-name (get-buffer mh-show-buffer))))
1976 ;; If "inc" were to put a new msg in this file,
1977 ;; we would not notice, so mark it invalid now.
1978 (mh-invalidate-show-buffer))
c26cf6c8
RS
1979
1980 (setq mh-seq-list (mh-read-folder-sequences mh-current-folder nil))
1981 (mh-unmark-all-headers t)
1982 (mh-notate-user-sequences)
1983 (message "Processing deletes and refiles for %s...done" folder)))
1984
c26cf6c8 1985(defun mh-update-unseen ()
bdcfe844
BW
1986 "Synchronize the unseen sequence with MH.
1987Return non-nil iff the MH folder was set.
1988The value of `mh-unseen-updated-hook' is a list of functions to be called,
1989with no arguments, after the unseen sequence is updated."
c26cf6c8 1990 (if mh-seen-list
847b8219 1991 (let* ((unseen-seq (mh-find-seq mh-unseen-seq))
c3d9274a
BW
1992 (unseen-msgs (mh-seq-msgs unseen-seq)))
1993 (if unseen-msgs
1994 (progn
1995 (mh-undefine-sequence mh-unseen-seq mh-seen-list)
1996 (run-hooks 'mh-unseen-updated-hook)
1997 (while mh-seen-list
1998 (setq unseen-msgs (delq (car mh-seen-list) unseen-msgs))
1999 (setq mh-seen-list (cdr mh-seen-list)))
2000 (setcdr unseen-seq unseen-msgs)
2001 t) ;since we set the folder
2002 (setq mh-seen-list nil)))))
c26cf6c8 2003
c26cf6c8 2004(defun mh-delete-scan-msgs (msgs)
bdcfe844 2005 "Delete the scan listing lines for MSGS."
c26cf6c8 2006 (save-excursion
942fc772 2007 (while msgs
bdcfe844
BW
2008 (when (mh-goto-msg (car msgs) t t)
2009 (when (memq 'unthread mh-view-ops)
2010 (mh-thread-forget-message (car msgs)))
2011 (mh-delete-line 1))
942fc772 2012 (setq msgs (cdr msgs)))))
c26cf6c8 2013
c26cf6c8 2014(defun mh-outstanding-commands-p ()
bdcfe844 2015 "Return non-nil if there are outstanding deletes or refiles."
c26cf6c8
RS
2016 (or mh-delete-list mh-refile-list))
2017
847b8219 2018(defun mh-coalesce-msg-list (messages)
924df208
BW
2019 "Given a list of MESSAGES, return a list of message number ranges.
2020This is the inverse of `mh-read-msg-list', which expands ranges.
2021Message lists passed to MH programs should be processed by this function
2022to avoid exceeding system command line argument limits."
847b8219 2023 (let ((msgs (sort (copy-sequence messages) 'mh-greaterp))
c3d9274a
BW
2024 (range-high nil)
2025 (prev -1)
2026 (ranges nil))
847b8219
KH
2027 (while prev
2028 (if range-high
c3d9274a
BW
2029 (if (or (not (numberp prev))
2030 (not (equal (car msgs) (1- prev))))
2031 (progn ;non-sequential, flush old range
2032 (if (eq prev range-high)
2033 (setq ranges (cons range-high ranges))
2034 (setq ranges (cons (format "%s-%s" prev range-high) ranges)))
2035 (setq range-high nil))))
847b8219 2036 (or range-high
c3d9274a 2037 (setq range-high (car msgs))) ;start new or first range
847b8219
KH
2038 (setq prev (car msgs))
2039 (setq msgs (cdr msgs)))
2040 ranges))
2041
2042(defun mh-greaterp (msg1 msg2)
bdcfe844
BW
2043 "Return the greater of two message indicators MSG1 and MSG2.
2044Strings are \"smaller\" than numbers.
2045Legal values are things like \"cur\", \"last\", 1, and 1820."
847b8219 2046 (if (numberp msg1)
c3d9274a
BW
2047 (if (numberp msg2)
2048 (> msg1 msg2)
2049 t)
847b8219 2050 (if (numberp msg2)
c3d9274a 2051 nil
847b8219
KH
2052 (string-lessp msg2 msg1))))
2053
a1b4049d 2054(defun mh-lessp (msg1 msg2)
bdcfe844
BW
2055 "Return the lesser of two message indicators MSG1 and MSG2.
2056Strings are \"smaller\" than numbers.
2057Legal values are things like \"cur\", \"last\", 1, and 1820."
a1b4049d 2058 (not (mh-greaterp msg1 msg2)))
bdcfe844 2059
c26cf6c8
RS
2060\f
2061
2062;;; Basic sequence handling
2063
2064(defun mh-delete-seq-locally (seq)
bdcfe844 2065 "Remove MH-E's record of SEQ."
c26cf6c8
RS
2066 (let ((entry (mh-find-seq seq)))
2067 (setq mh-seq-list (delq entry mh-seq-list))))
2068
2069(defun mh-read-folder-sequences (folder save-refiles)
bdcfe844
BW
2070 "Read and return the predefined sequences for a FOLDER.
2071If SAVE-REFILES is non-nil, then keep the sequences
2072that note messages to be refiled."
c26cf6c8
RS
2073 (let ((seqs ()))
2074 (cond (save-refiles
c3d9274a
BW
2075 (mh-mapc (function (lambda (seq) ; Save the refiling sequences
2076 (if (mh-folder-name-p (mh-seq-name seq))
2077 (setq seqs (cons seq seqs)))))
2078 mh-seq-list)))
c26cf6c8
RS
2079 (save-excursion
2080 (if (eq 0 (mh-exec-cmd-quiet nil "mark" folder "-list"))
c3d9274a
BW
2081 (progn
2082 ;; look for name in line of form "cur: 4" or "myseq (private): 23"
2083 (while (re-search-forward "^[^: ]+" nil t)
2084 (setq seqs (cons (mh-make-seq (intern (buffer-substring
2085 (match-beginning 0)
2086 (match-end 0)))
2087 (mh-read-msg-list))
2088 seqs)))
2089 (delete-region (point-min) (point))))) ; avoid race with
2090 ; mh-process-daemon
c26cf6c8
RS
2091 seqs))
2092
2093(defun mh-read-msg-list ()
bdcfe844
BW
2094 "Return a list of message numbers from point to the end of the line.
2095Expands ranges into set of individual numbers."
c26cf6c8 2096 (let ((msgs ())
c3d9274a
BW
2097 (end-of-line (save-excursion (end-of-line) (point)))
2098 num)
c26cf6c8
RS
2099 (while (re-search-forward "[0-9]+" end-of-line t)
2100 (setq num (string-to-int (buffer-substring (match-beginning 0)
c3d9274a
BW
2101 (match-end 0))))
2102 (cond ((looking-at "-") ; Message range
2103 (forward-char 1)
2104 (re-search-forward "[0-9]+" end-of-line t)
2105 (let ((num2 (string-to-int (buffer-substring (match-beginning 0)
2106 (match-end 0)))))
2107 (if (< num2 num)
2108 (error "Bad message range: %d-%d" num num2))
2109 (while (<= num num2)
2110 (setq msgs (cons num msgs))
2111 (setq num (1+ num)))))
2112 ((not (zerop num)) ;"pick" outputs "0" to mean no match
2113 (setq msgs (cons num msgs)))))
c26cf6c8
RS
2114 msgs))
2115
924df208
BW
2116(defun mh-notate-user-sequences (&optional msg-or-seq)
2117 "Mark user-defined sequences in the messages specified by MSG-OR-SEQ.
2118The optional argument MSG-OR-SEQ can be a message number, a list of message
2119numbers, a sequence, a region in a cons cell, or nil in which case all
2120messages in the folder buffer are notated."
2121 (unless msg-or-seq
2122 (setq msg-or-seq (cons (point-min) (point-max))))
c26cf6c8 2123 (let ((seqs mh-seq-list)
924df208
BW
2124 (msg-hash (make-hash-table))
2125 (tick-msgs (and mh-tick-seq (mh-seq-msgs (mh-find-seq mh-tick-seq)))))
3d7ca223
BW
2126 (dolist (seq seqs)
2127 (unless (mh-internal-seq (mh-seq-name seq))
2128 (dolist (msg (mh-seq-msgs seq))
2129 (setf (gethash msg msg-hash) t))))
924df208 2130 (mh-iterate-on-msg-or-seq msg msg-or-seq
3d7ca223 2131 (when (gethash msg msg-hash)
924df208
BW
2132 (mh-notate nil mh-note-seq (1+ mh-cmd-note)))
2133 (mh-notate-tick msg tick-msgs))))
c26cf6c8 2134
c26cf6c8 2135(defun mh-internal-seq (name)
bdcfe844 2136 "Return non-nil if NAME is the name of an internal MH-E sequence."
c26cf6c8
RS
2137 (or (memq name '(answered cur deleted forwarded printed))
2138 (eq name mh-unseen-seq)
924df208 2139 (and mh-tick-seq (eq name mh-tick-seq))
c26cf6c8
RS
2140 (eq name mh-previous-seq)
2141 (mh-folder-name-p name)))
2142
924df208
BW
2143(defun mh-delete-msg-from-seq (msg-or-seq sequence &optional internal-flag)
2144 "Delete MSG-OR-SEQ from SEQUENCE.
2145Default value of MSG-OR-SEQ is the displayed message.
2146If optional prefix argument is provided, then prompt for the message sequence.
2147If variable `transient-mark-mode' is non-nil and the mark is active, then the
2148selected region is deleted from SEQUENCE..
2149In a program, MSG-OR-SEQ can be a message number, a list of message numbers, a
2150region in a cons cell, or a sequence; optional third arg INTERNAL-FLAG non-nil
2151means do not inform MH of the change."
2152 (interactive (list (mh-interactive-msg-or-seq "Delete")
c3d9274a
BW
2153 (mh-read-seq-default "Delete from" t)
2154 nil))
847b8219 2155 (let ((entry (mh-find-seq sequence)))
924df208
BW
2156 (when entry
2157 (mh-iterate-on-msg-or-seq msg msg-or-seq
2158 (when (memq msg (mh-seq-msgs entry))
2159 (mh-notate nil ? (1+ mh-cmd-note)))
2160 (mh-delete-a-msg-from-seq msg sequence internal-flag)
2161 (mh-clear-text-properties nil))
2162 (mh-notate-user-sequences msg-or-seq)
2163 (when (and (eq sequence mh-unseen-seq) (mh-speed-flists-active-p))
2164 (mh-speed-flists t mh-current-folder)))))
2165
2166(defun mh-delete-a-msg-from-seq (msg sequence internal-flag)
2167 "Delete MSG from SEQUENCE.
2168If INTERNAL-FLAG is non-nil, then do not inform MH of the change."
2169 (let ((entry (mh-find-seq sequence)))
2170 (when (and entry (memq msg (mh-seq-msgs entry)))
2171 (if (not internal-flag)
2172 (mh-undefine-sequence sequence (list msg)))
2173 (setcdr entry (delq msg (mh-seq-msgs entry))))))
2174
2175(defun mh-clear-text-properties (message)
2176 "Clear all text properties (except mh-tick) from the scan line for MESSAGE."
2177 (save-excursion
2178 (with-mh-folder-updating (t)
2179 (when (or (not message) (mh-goto-msg message t t))
2180 (beginning-of-line)
2181 (let ((tick-property (get-text-property (point) 'mh-tick)))
2182 (set-text-properties (point) (line-end-position) nil)
2183 (when tick-property
2184 (add-text-properties (point) (line-end-position)
2185 `(mh-tick ,tick-property))))))))
c26cf6c8 2186
c26cf6c8 2187(defun mh-undefine-sequence (seq msgs)
bdcfe844 2188 "Remove from the SEQ the list of MSGS."
924df208
BW
2189 (prog1 (mh-exec-cmd "mark" mh-current-folder "-delete"
2190 "-sequence" (symbol-name seq)
2191 (mh-coalesce-msg-list msgs))
2192 (when (and (eq seq mh-unseen-seq) (mh-speed-flists-active-p))
2193 (mh-speed-flists t mh-current-folder))))
c26cf6c8 2194
c26cf6c8 2195(defun mh-define-sequence (seq msgs)
bdcfe844
BW
2196 "Define the SEQ to contain the list of MSGS.
2197Do not mark pseudo-sequences or empty sequences.
2198Signals an error if SEQ is an illegal name."
c26cf6c8 2199 (if (and msgs
c3d9274a 2200 (not (mh-folder-name-p seq)))
c26cf6c8 2201 (save-excursion
c3d9274a
BW
2202 (mh-exec-cmd-error nil "mark" mh-current-folder "-add" "-zero"
2203 "-sequence" (symbol-name seq)
2204 (mh-coalesce-msg-list msgs)))))
c26cf6c8 2205
bdcfe844
BW
2206(defun mh-map-over-seqs (function seq-list)
2207 "Apply FUNCTION to each sequence in SEQ-LIST.
2208The sequence name and the list of messages are passed as arguments."
c26cf6c8 2209 (while seq-list
bdcfe844 2210 (funcall function
c3d9274a
BW
2211 (mh-seq-name (car seq-list))
2212 (mh-seq-msgs (car seq-list)))
c26cf6c8
RS
2213 (setq seq-list (cdr seq-list))))
2214
bdcfe844
BW
2215(defun mh-notate-if-in-one-seq (msg character offset seq)
2216 "Notate MSG.
2217The CHARACTER is placed at the given OFFSET from the beginning of the listing.
2218The notation is performed if the MSG is only in SEQ."
847b8219 2219 (let ((in-seqs (mh-seq-containing-msg msg nil)))
c26cf6c8 2220 (if (and (eq seq (car in-seqs)) (null (cdr in-seqs)))
c3d9274a 2221 (mh-notate msg character offset))))
c26cf6c8 2222
bdcfe844
BW
2223(defun mh-seq-containing-msg (msg &optional include-internal-flag)
2224 "Return a list of the sequences containing MSG.
2225If INCLUDE-INTERNAL-FLAG non-nil, include MH-E internal sequences in list."
c26cf6c8 2226 (let ((l mh-seq-list)
c3d9274a 2227 (seqs ()))
c26cf6c8 2228 (while l
847b8219 2229 (and (memq msg (mh-seq-msgs (car l)))
c3d9274a
BW
2230 (or include-internal-flag
2231 (not (mh-internal-seq (mh-seq-name (car l)))))
2232 (setq seqs (cons (mh-seq-name (car l)) seqs)))
c26cf6c8
RS
2233 (setq l (cdr l)))
2234 seqs))
2235
c26cf6c8
RS
2236\f
2237
2238;;; User prompting commands.
2239
c3d9274a
BW
2240(defun mh-read-msg-range (folder &optional always-prompt-flag)
2241 "Prompt for message range from FOLDER.
2242If optional second argument ALWAYS-PROMPT-FLAG is non-nil then always ask for
2243range."
2244 (multiple-value-bind (total unseen) (mh-folder-size folder)
2245 (cond
2246 ((and (not always-prompt-flag) (numberp unseen) (> unseen 0))
2247 (list (symbol-name mh-unseen-seq)))
2248 ((or (null mh-large-folder) (not (numberp total)))
2249 (list "all"))
2250 ((and (numberp total) (or always-prompt-flag (> total mh-large-folder)))
2251 (let* ((prompt
2252 (format "Range or number of messages to read (default: %s): "
2253 total))
2254 (in (read-string prompt nil nil (number-to-string total))))
2255 (cond ((string-match "^[ \f\t\n\r\v]*[0-9]+[ \f\t\n\r\v]*$" in)
2256 (list (format "last:%s" (car (read-from-string in)))))
2257 ((equal in "") (list "all"))
2258 (t (split-string in)))))
2259 (t (list "all")))))
c26cf6c8
RS
2260
2261\f
2262
2263;;; Build the folder-mode keymap:
2264
2265(suppress-keymap mh-folder-mode-map)
a1b4049d 2266
bdcfe844
BW
2267;; Use defalias to make sure the documented primary key bindings
2268;; appear in menu lists.
2269(defalias 'mh-alt-show 'mh-show)
2270(defalias 'mh-alt-refile-msg 'mh-refile-msg)
2271(defalias 'mh-alt-send 'mh-send)
2272(defalias 'mh-alt-visit-folder 'mh-visit-folder)
2273
a1b4049d
BW
2274;; Save the `b' binding for a future `back'. Maybe?
2275(gnus-define-keys mh-folder-mode-map
c3d9274a
BW
2276 " " mh-page-msg
2277 "!" mh-refile-or-write-again
924df208 2278 "'" mh-toggle-tick
c3d9274a
BW
2279 "," mh-header-display
2280 "." mh-alt-show
2281 ">" mh-write-msg-to-file
2282 "?" mh-help
2283 "E" mh-extract-rejected-mail
bdcfe844 2284 "M" mh-modify
c3d9274a
BW
2285 "\177" mh-previous-page
2286 "\C-d" mh-delete-msg-no-motion
2287 "\t" mh-index-next-folder
2288 [backtab] mh-index-previous-folder
2289 "\M-\t" mh-index-previous-folder
2290 "\e<" mh-first-msg
2291 "\e>" mh-last-msg
2292 "\ed" mh-redistribute
2293 "\r" mh-show
2294 "^" mh-alt-refile-msg
2295 "c" mh-copy-msg
2296 "d" mh-delete-msg
2297 "e" mh-edit-again
2298 "f" mh-forward
2299 "g" mh-goto-msg
2300 "i" mh-inc-folder
2301 "k" mh-delete-subject-or-thread
2302 "l" mh-print-msg
2303 "m" mh-alt-send
2304 "n" mh-next-undeleted-msg
2305 "\M-n" mh-next-unread-msg
2306 "o" mh-refile-msg
2307 "p" mh-previous-undeleted-msg
2308 "\M-p" mh-previous-unread-msg
2309 "q" mh-quit
2310 "r" mh-reply
2311 "s" mh-send
2312 "t" mh-toggle-showing
2313 "u" mh-undo
2314 "v" mh-index-visit-folder
2315 "x" mh-execute-commands
2316 "|" mh-pipe-msg)
a1b4049d
BW
2317
2318(gnus-define-keys (mh-folder-map "F" mh-folder-mode-map)
c3d9274a
BW
2319 "?" mh-prefix-help
2320 "S" mh-sort-folder
2321 "f" mh-alt-visit-folder
bdcfe844 2322 "i" mh-index-search
c3d9274a
BW
2323 "k" mh-kill-folder
2324 "l" mh-list-folders
924df208 2325 "n" mh-index-new-messages
c3d9274a
BW
2326 "o" mh-alt-visit-folder
2327 "p" mh-pack-folder
2328 "r" mh-rescan-folder
2329 "s" mh-search-folder
2330 "u" mh-undo-folder
2331 "v" mh-visit-folder)
a1b4049d 2332
924df208
BW
2333(define-key mh-folder-mode-map "I" mh-inc-spool-map)
2334
2335(gnus-define-keys (mh-junk-map "J" mh-folder-mode-map)
2336 "?" mh-prefix-help
2337 "b" mh-junk-blacklist
2338 "w" mh-junk-whitelist)
2339
a1b4049d 2340(gnus-define-keys (mh-sequence-map "S" mh-folder-mode-map)
c3d9274a
BW
2341 "?" mh-prefix-help
2342 "d" mh-delete-msg-from-seq
2343 "k" mh-delete-seq
2344 "l" mh-list-sequences
2345 "n" mh-narrow-to-seq
2346 "p" mh-put-msg-in-seq
2347 "s" mh-msg-is-in-seq
2348 "w" mh-widen)
a1b4049d
BW
2349
2350(gnus-define-keys (mh-thread-map "T" mh-folder-mode-map)
c3d9274a
BW
2351 "?" mh-prefix-help
2352 "u" mh-thread-ancestor
2353 "p" mh-thread-previous-sibling
2354 "n" mh-thread-next-sibling
2355 "t" mh-toggle-threads
2356 "d" mh-thread-delete
2357 "o" mh-thread-refile)
bdcfe844
BW
2358
2359(gnus-define-keys (mh-limit-map "/" mh-folder-mode-map)
924df208 2360 "'" mh-narrow-to-tick
c3d9274a
BW
2361 "?" mh-prefix-help
2362 "s" mh-narrow-to-subject
2363 "w" mh-widen)
a1b4049d
BW
2364
2365(gnus-define-keys (mh-extract-map "X" mh-folder-mode-map)
c3d9274a
BW
2366 "?" mh-prefix-help
2367 "s" mh-store-msg ;shar
2368 "u" mh-store-msg) ;uuencode
a1b4049d
BW
2369
2370(gnus-define-keys (mh-digest-map "D" mh-folder-mode-map)
c3d9274a
BW
2371 " " mh-page-digest
2372 "?" mh-prefix-help
2373 "\177" mh-page-digest-backwards
2374 "b" mh-burst-digest)
a1b4049d 2375
bdcfe844 2376(gnus-define-keys (mh-mime-map "K" mh-folder-mode-map)
c3d9274a
BW
2377 "?" mh-prefix-help
2378 "a" mh-mime-save-parts
bdcfe844
BW
2379 "i" mh-folder-inline-mime-part
2380 "o" mh-folder-save-mime-part
2381 "v" mh-folder-toggle-mime-part
2382 "\t" mh-next-button
2383 [backtab] mh-prev-button
2384 "\M-\t" mh-prev-button)
2385
a1b4049d 2386(cond
bdcfe844 2387 (mh-xemacs-flag
a1b4049d
BW
2388 (define-key mh-folder-mode-map [button2] 'mh-show-mouse))
2389 (t
2390 (define-key mh-folder-mode-map [mouse-2] 'mh-show-mouse)))
c26cf6c8 2391
942fc772
KH
2392;; "C-c /" prefix is used in mh-folder-mode by pgp.el and mailcrypt
2393
c26cf6c8
RS
2394\f
2395
bdcfe844
BW
2396;;; Help Messages
2397
2398;;; If you add a new prefix, add appropriate text to the nil key.
2399;;;
2400;;; In general, messages are grouped logically. Taking the main commands for
2401;;; example, the first line is "ways to view messages," the second line is
2402;;; "things you can do with messages", and the third is "composing" messages.
2403;;;
2404;;; When adding a new prefix, ensure that the help message contains "what" the
2405;;; prefix is for. For example, if the word "folder" were not present in the
2406;;; `F' entry, it would not be clear what these commands operated upon.
2407(defvar mh-help-messages
2408 '((nil "[i]nc, [.]show, [,]show all, [n]ext, [p]revious,\n"
c3d9274a
BW
2409 "[d]elete, [o]refile, e[x]ecute,\n"
2410 "[s]end, [r]eply.\n"
924df208
BW
2411 "Prefix characters:\n [F]older, [S]equence, [J]unk, MIME [K]eys,"
2412 "\n [T]hread, / Limit, e[X]tract, [D]igest, [I]nc spools.")
bdcfe844
BW
2413
2414 (?F "[l]ist, [v]isit folder;\n"
c3d9274a
BW
2415 "[t]hread; [s]earch; [i]ndexed search;\n"
2416 "[p]ack; [S]ort; [r]escan; [k]ill")
bdcfe844 2417 (?S "[p]ut message in sequence, [n]arrow, [w]iden,\n"
c3d9274a
BW
2418 "[s]equences, [l]ist,\n"
2419 "[d]elete message from sequence, [k]ill sequence")
2420 (?T "[t]oggle, [d]elete, [o]refile thread")
bdcfe844
BW
2421 (?/ "Limit to [s]ubject; [w]iden")
2422 (?X "un[s]har, [u]udecode message")
2423 (?D "[b]urst digest")
2424 (?K "[v]iew, [i]nline, [o]utput/save MIME part; save [a]ll parts; \n"
924df208
BW
2425 "[TAB] next; [SHIFT-TAB] previous")
2426 (?J "[b]lacklist, [w]hitelist message"))
bdcfe844
BW
2427 "Key binding cheat sheet.
2428
2429This is an associative array which is used to show the most common commands.
2430The key is a prefix char. The value is one or more strings which are
2431concatenated together and displayed in the minibuffer if ? is pressed after
2432the prefix character. The special key nil is used to display the
2433non-prefixed commands.
2434
2435The substitutions described in `substitute-command-keys' are performed as
2436well.")
a1b4049d 2437
bdcfe844 2438\f
a1b4049d 2439
f1ed9461 2440(dolist (mess '("^Cursor not pointing to message$"
c3d9274a 2441 "^There is no other window$"))
f1ed9461
DL
2442 (add-to-list 'debug-ignored-errors mess))
2443
bdcfe844
BW
2444(provide 'mh-e)
2445
2446;;; Local Variables:
c3d9274a 2447;;; indent-tabs-mode: nil
bdcfe844
BW
2448;;; sentence-end-double-space: nil
2449;;; End:
2450
6b61353c 2451;;; arch-tag: cce884de-bd37-4104-9963-e4439d5ed22b
c26cf6c8 2452;;; mh-e.el ends here