]> code.delx.au - gnu-emacs/blob - lisp/mail/mh-e.el
(mail-font-lock-keywords): New variable.
[gnu-emacs] / lisp / mail / mh-e.el
1 ;;; mh-e.el --- GNU Emacs interface to the MH mail system
2
3 ;;; Copyright 1985,86,87,88,90,92,93,94 Free Software Foundation, Inc.
4
5 (defconst mh-e-time-stamp "Time-stamp: <94/04/13 11:30:48 gildea>")
6 (defconst mh-e-version "4.1"
7 "Version numbers of this version of mh-e.")
8
9 ;; Maintainer: Stephen Gildea <gildea@lcs.mit.edu>
10 ;; Version: 4.1
11 ;; Keywords: mail
12
13 ;; mh-e is free software; you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; any later version.
17
18 ;; mh-e is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
22
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with mh-e; see the file COPYING. If not, write to
25 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26
27 ;;; Commentary:
28
29 ;;; HOW TO USE:
30 ;;; M-x mh-rmail to read mail. Type C-h m there for a list of commands.
31 ;;; C-u M-x mh-rmail to visit any folder.
32 ;;; M-x mh-smail to send mail. From within the mail reader, "m" works, too.
33 ;;; Your .emacs might benefit from these bindings:
34 ;;; (global-set-key "\C-cr" 'mh-rmail)
35 ;;; (global-set-key "\C-xm" 'mh-smail)
36 ;;; (global-set-key "\C-x4m" 'mh-smail-other-window)
37
38 ;;; MH (Message Handler) is a powerful mail reader. The MH newsgroup
39 ;;; is comp.mail.mh; the mailing list is mh-users@ics.uci.edu (send to
40 ;;; mh-users-request to be added). See the monthly Frequently Asked
41 ;;; Questions posting there for information on getting MH.
42
43 ;;; mh-e works with Emacs 18 or 19, and MH 5 or 6.
44
45 ;;; NB. MH must have been compiled with the MHE compiler flag or several
46 ;;; features necessary mh-e will be missing from MH commands, specifically
47 ;;; the -build switch to repl and forw.
48
49 ;;; Change Log:
50
51 ;;; Original version for Gosling emacs by Brian Reid, Stanford, 1982.
52 ;;; Modified by James Larus, BBN, July 1984 and UCB, 1984 & 1985.
53 ;;; Rewritten for GNU Emacs, James Larus 1985. larus@ginger.berkeley.edu
54 ;;; Modified by Stephen Gildea 1988. gildea@lcs.mit.edu
55 (defconst mh-e-RCS-id "$Header: /home/fsf/rms/e19/lisp/RCS/mh-e.el,v 1.3 1994/07/18 18:04:45 rms Exp rms $")
56
57 ;;; Code:
58
59 (provide 'mh-e)
60 (require 'mh-utils)
61
62 \f
63 ;;; Site customization (see also mh-utils.el):
64
65 (defvar mh-redist-full-contents nil
66 "Non-nil if the `dist' command needs whole letter for redistribution.
67 This is the case only when `send' is compiled with the BERK option.
68 If MH will not allow you to redist a previously redist'd msg, set to nil.")
69
70 ;;; Hooks:
71
72 (defvar mh-folder-mode-hook nil
73 "Invoked in MH-Folder mode on a new folder.")
74
75 (defvar mh-inc-folder-hook nil
76 "Invoked by \\<mh-folder-mode-map>`\\[mh-inc-folder]' after incorporating mail into a folder.")
77
78 (defvar mh-show-hook nil
79 "Invoked after \\<mh-folder-mode-map>`\\[mh-show]' shows a message.")
80
81 (defvar mh-show-mode-hook nil
82 "Invoked in MH-Show mode on each message.")
83
84 (defvar mh-delete-msg-hook nil
85 "Invoked after marking each message for deletion.")
86
87 (defvar mh-refile-msg-hook nil
88 "Invoked after marking each message for refiling.")
89
90 (defvar mh-before-quit-hook nil
91 "Invoked by \\<mh-folder-mode-map>`\\[mh-quit]' before quitting mh-e. See also mh-quit-hook.")
92
93 (defvar mh-quit-hook nil
94 "Invoked after \\<mh-folder-mode-map>`\\[mh-quit]' quits mh-e. See also mh-before-quit-hook.")
95
96
97
98 ;;; Personal preferences:
99
100 (defvar mh-lpr-command-format "lpr -p -J '%s'"
101 "*Format for Unix command that prints a message.
102 The string should be a Unix command line, with the string '%s' where
103 the job's name (folder and message number) should appear. The formatted
104 message text is piped to this command when you type \\<mh-folder-mode-map>`\\[mh-print-msg]'.")
105
106 (defvar mh-scan-prog "scan"
107 "*Program to run to generate one-line-per-message listing of a folder.
108 Normally \"scan\" or a file name linked to scan. This file is searched
109 for relative to the mh-progs directory unless it is an absolute pathname.
110 Automatically becomes buffer-local when set in any fashion.")
111 (make-variable-buffer-local 'mh-scan-prog)
112
113 (defvar mh-inc-prog "inc"
114 "*Program to run to incorporate new mail into a folder.
115 Normally \"inc\". This file is searched for relative to
116 the mh-progs directory unless it is an absolute pathname.")
117
118 (defvar mh-print-background nil
119 "*Print messages in the background if non-nil.
120 WARNING: do not delete the messages until printing is finished;
121 otherwise, your output may be truncated.")
122
123 (defvar mh-recenter-summary-p nil
124 "*Recenter summary window when the show window is toggled off if non-nil.")
125
126 (defvar mh-ins-buf-prefix "> "
127 "*String to put before each non-blank line of a yanked or inserted message.
128 \\<mh-letter-mode-map>Used when the message is inserted into an outgoing letter
129 by \\[mh-insert-letter] or \\[mh-yank-cur-msg].")
130
131 (defvar mh-do-not-confirm nil
132 "*Non-nil means do not prompt for confirmation before some mh-e commands.
133 Affects non-recoverable commands such as mh-kill-folder and mh-undo-folder.")
134
135 (defvar mh-store-default-directory nil
136 "*Last directory used by \\[mh-store-msg]; default for next store.
137 A directory name string, or nil to use current directory.")
138
139 ;;; Parameterize mh-e to work with different scan formats. The defaults work
140 ;;; with the standard MH scan listings, in which the first 4 characters on
141 ;;; the line are the message number, followed by two places for notations.
142
143 (defvar mh-good-msg-regexp "^....[^D^]"
144 "Regexp specifiying the scan lines that are 'good' messages.")
145
146 (defvar mh-deleted-msg-regexp "^....D"
147 "Regexp matching scan lines of deleted messages.")
148
149 (defvar mh-refiled-msg-regexp "^....\\^"
150 "Regexp matching scan lines of refiled messages.")
151
152 (defvar mh-valid-scan-line "^ *[0-9]"
153 "Regexp matching scan lines for messages (not error messages).")
154
155 (defvar mh-flagged-scan-msg-regexp "^....\\D\\|^....\\^\\|^....\\+\\|^.....%"
156 "Regexp matching flagged scan lines.
157 Matches lines marked as deleted, refiled, in a sequence, or the cur message.")
158
159 (defvar mh-cur-scan-msg-regexp "^....\\+"
160 "Regexp matching scan line for the cur message.")
161
162 (defvar mh-show-buffer-mode-line-buffer-id "{show-%s} %d"
163 "Format string to produce `mode-line-buffer-identification' for show buffers.
164 First argument is folder name. Second is message number.")
165
166 (defvar mh-partial-folder-mode-line-annotation "select"
167 "Annotation when displaying part of a folder.
168 The string is displayed after the folder's name. NIL for no annotation.")
169
170
171 ;;; Internal variables:
172
173 (defvar mh-last-destination nil
174 "Destination of last refile or write command.")
175
176 (defvar mh-folder-mode-map (make-keymap)
177 "Keymap for MH folders.")
178
179 (defvar mh-next-seq-num nil
180 "Index of free sequence id.")
181
182 (defvar mh-delete-list nil
183 "List of msg numbers to delete.")
184
185 (defvar mh-refile-list nil
186 "List of folder names in mh-seq-list.")
187
188 (defvar mh-next-direction 'forward
189 "Direction to move to next message.")
190
191 (defvar mh-narrowed-to-seq nil
192 "Sequence display is narrowed to.")
193
194 (defvar mh-first-msg-num nil
195 "Number of first msg in buffer.")
196
197 (defvar mh-last-msg-num nil
198 "Number of last msg in buffer.")
199
200
201 ;;; Macros and generic functions:
202
203 (defun mh-mapc (func list)
204 (while list
205 (funcall func (car list))
206 (setq list (cdr list))))
207
208 \f
209
210 ;;; Entry points:
211
212 ;;;###autoload
213 (defun mh-rmail (&optional arg)
214 "Inc(orporate) new mail with MH, or, with arg, scan an MH mail folder.
215 This function is an entry point to mh-e, the Emacs front end
216 to the MH mail system."
217 (interactive "P")
218 (mh-find-path)
219 (if arg
220 (call-interactively 'mh-visit-folder)
221 (mh-inc-folder)))
222
223
224 ;;; mh-smail and mh-smail-other-window have been moved to the new file
225 ;;; mh-comp.el, but Emacs 18 still looks for them here, so provide a
226 ;;; definition here, too, for a while.
227
228 (defun mh-smail ()
229 "Compose and send mail with the MH mail system.
230 This function is an entry point to mh-e, the Emacs front end
231 to the MH mail system."
232 (interactive)
233 (mh-find-path)
234 (require 'mh-comp)
235 (call-interactively 'mh-send))
236
237
238 (defun mh-smail-other-window ()
239 "Compose and send mail in other window with the MH mail system.
240 This function is an entry point to mh-e, the Emacs front end
241 to the MH mail system."
242 (interactive)
243 (mh-find-path)
244 (require 'mh-comp)
245 (call-interactively 'mh-send-other-window))
246
247 \f
248
249 ;;; User executable mh-e commands:
250
251
252 (defun mh-delete-msg (msg-or-seq)
253 "Mark the specified MESSAGE(s) for subsequent deletion and move to the next.
254 Default is the displayed message. If optional prefix argument is
255 given then prompt for the message sequence."
256 (interactive (list (if current-prefix-arg
257 (mh-read-seq-default "Delete" t)
258 (mh-get-msg-num t))))
259 (mh-delete-msg-no-motion msg-or-seq)
260 (mh-next-msg))
261
262
263 (defun mh-delete-msg-no-motion (msg-or-seq)
264 "Mark the specified MESSAGE(s) for subsequent deletion.
265 Default is the displayed message. If optional prefix argument is
266 provided, then prompt for the message sequence."
267 (interactive (list (if current-prefix-arg
268 (mh-read-seq-default "Delete" t)
269 (mh-get-msg-num t))))
270 (if (numberp msg-or-seq)
271 (mh-delete-a-msg msg-or-seq)
272 (mh-map-to-seq-msgs 'mh-delete-a-msg msg-or-seq)))
273
274
275 (defun mh-execute-commands ()
276 "Process outstanding delete and refile requests."
277 (interactive)
278 (if mh-narrowed-to-seq (mh-widen))
279 (mh-process-commands mh-current-folder)
280 (mh-set-scan-mode)
281 (mh-goto-cur-msg) ; after mh-set-scan-mode for efficiency
282 (mh-make-folder-mode-line)
283 t) ; return t for local-write-file-hooks
284
285
286 (defun mh-first-msg ()
287 "Move to the first message."
288 (interactive)
289 (goto-char (point-min)))
290
291
292 (defun mh-header-display ()
293 "Show the current message with all its headers.
294 Displays headers that might have been suppressed by setting the
295 variables `mh-clean-message-header' or `mhl-formfile', or by the fallback
296 behavior of scrolling uninteresting headers off the top of the window.
297 Type \"\\[mh-show]\" to show the message normally again."
298 (interactive)
299 (and (not mh-showing-with-headers)
300 (or mhl-formfile mh-clean-message-header)
301 (mh-invalidate-show-buffer))
302 (let ((mhl-formfile nil)
303 (mh-clean-message-header nil))
304 (mh-show-msg nil)
305 (mh-in-show-buffer (mh-show-buffer)
306 (goto-char (point-min))
307 (mh-recenter 0))
308 (setq mh-showing-with-headers t)))
309
310
311 (defun mh-inc-folder (&optional maildrop-name)
312 "Inc(orporate)s new mail into +inbox.
313 Optional prefix argument specifies an alternate maildrop from the default.
314 If this is given, incorporates mail into the current folder, rather
315 than +inbox. Runs `mh-inc-folder-hook' after incorporating new mail.
316 Do not call this function from outside mh-e; use \\[mh-rmail] instead."
317 (interactive (list (if current-prefix-arg
318 (expand-file-name
319 (read-file-name "inc mail from file: "
320 mh-user-path)))))
321 (let ((config (current-window-configuration)))
322 (if (not maildrop-name)
323 (cond ((not (get-buffer "+inbox"))
324 (mh-make-folder "+inbox")
325 (setq mh-previous-window-config config))
326 ((not (eq (current-buffer) (get-buffer "+inbox")))
327 (switch-to-buffer "+inbox")
328 (setq mh-previous-window-config config)))))
329 (mh-get-new-mail maildrop-name)
330 (run-hooks 'mh-inc-folder-hook))
331
332
333 (defun mh-last-msg ()
334 "Move to the last message."
335 (interactive)
336 (goto-char (point-max))
337 (while (and (not (bobp)) (looking-at "^$"))
338 (forward-line -1)))
339
340
341 (defun mh-next-undeleted-msg (&optional arg)
342 "Move to next undeleted message in window."
343 (interactive "P")
344 (forward-line (prefix-numeric-value arg))
345 (setq mh-next-direction 'forward)
346 (cond ((re-search-forward mh-good-msg-regexp nil 0 arg)
347 (beginning-of-line)
348 (mh-maybe-show))
349 (t
350 (forward-line -1)
351 (if (get-buffer mh-show-buffer)
352 (delete-windows-on mh-show-buffer)))))
353
354
355 (defun mh-refile-msg (msg-or-seq dest)
356 "Refile MESSAGE(s) (default: displayed message) in FOLDER.
357 If optional prefix argument provided, then prompt for message sequence."
358 (interactive
359 (list (if current-prefix-arg
360 (mh-read-seq-default "Refile" t)
361 (mh-get-msg-num t))
362 (intern
363 (mh-prompt-for-folder
364 "Destination"
365 (or (and mh-msg-folder-hook
366 (let ((file-name (mh-msg-filename (mh-get-msg-num t))))
367 (save-excursion
368 (set-buffer (get-buffer-create " *mh-temp*"))
369 (erase-buffer)
370 (insert-file-contents file-name)
371 (let ((buffer-file-name file-name))
372 (funcall mh-msg-folder-hook)))))
373 (and (eq 'refile (car mh-last-destination))
374 (symbol-name (cdr mh-last-destination)))
375 "")
376 t))))
377 (setq mh-last-destination (cons 'refile dest))
378 (if (numberp msg-or-seq)
379 (mh-refile-a-msg msg-or-seq dest)
380 (mh-map-to-seq-msgs 'mh-refile-a-msg msg-or-seq dest))
381 (mh-next-msg))
382
383
384 (defun mh-refile-or-write-again (msg)
385 "Re-execute the last refile or write command on the given MESSAGE.
386 Default is the displayed message. Use the same folder or file as the
387 previous refile or write command."
388 (interactive (list (mh-get-msg-num t)))
389 (if (null mh-last-destination)
390 (error "No previous refile or write"))
391 (cond ((eq (car mh-last-destination) 'refile)
392 (mh-refile-a-msg msg (cdr mh-last-destination))
393 (message "Destination folder: %s" (cdr mh-last-destination)))
394 (t
395 (apply 'mh-write-msg-to-file msg (cdr mh-last-destination))
396 (message "Destination: %s" (cdr mh-last-destination))))
397 (mh-next-msg))
398
399
400 (defun mh-quit ()
401 "Quit mh-e.
402 Start by running mh-before-quit-hook. Restore the previous window
403 configuration, if one exists. Finish by running mh-quit-hook."
404 (interactive)
405 (run-hooks 'mh-before-quit-hook)
406 (mh-update-unseen)
407 (mh-invalidate-show-buffer)
408 (bury-buffer (current-buffer))
409 (if (get-buffer mh-show-buffer)
410 (bury-buffer mh-show-buffer))
411 (if mh-previous-window-config
412 (set-window-configuration mh-previous-window-config))
413 (run-hooks 'mh-quit-hook))
414
415 (defun mh-page-msg (&optional arg)
416 "Page the displayed message forwards.
417 Scrolls ARG lines or a full screen if no argument is supplied."
418 (interactive "P")
419 (scroll-other-window arg))
420
421
422 (defun mh-previous-page (&optional arg)
423 "Page the displayed message backwards.
424 Scrolls ARG lines or a full screen if no argument is supplied."
425 (interactive "P")
426 (mh-in-show-buffer (mh-show-buffer)
427 (scroll-down arg)))
428
429
430 (defun mh-previous-undeleted-msg (&optional arg)
431 "Move to previous undeleted message in window."
432 (interactive "p")
433 (setq mh-next-direction 'backward)
434 (beginning-of-line)
435 (cond ((re-search-backward mh-good-msg-regexp nil 0 arg)
436 (mh-maybe-show))
437 (t
438 (if (get-buffer mh-show-buffer)
439 (delete-windows-on mh-show-buffer)))))
440
441
442 (defun mh-rescan-folder (&optional range)
443 "Rescan a folder after optionally processing the outstanding commands.
444 If optional prefix argument is provided, prompt for the range of
445 messages to display. Otherwise show the entire folder."
446 (interactive (list (if current-prefix-arg
447 (mh-read-msg-range "Range to scan [all]? ")
448 nil)))
449 (setq mh-next-direction 'forward)
450 (mh-scan-folder mh-current-folder (or range "all")))
451
452
453 (defun mh-write-msg-to-file (msg file no-headers)
454 "Append MESSAGE to the end of a FILE.
455 If NO-HEADERS (prefix argument) is provided, write only the message body.
456 Otherwise send the entire message including the headers."
457 (interactive
458 (list (mh-get-msg-num t)
459 (let ((default-dir (if (eq 'write (car mh-last-destination))
460 (file-name-directory (car (cdr mh-last-destination)))
461 default-directory)))
462 (read-file-name "Save message in file: " default-dir
463 (expand-file-name "mail.out" default-dir)))
464 current-prefix-arg))
465 (let ((file-name (mh-msg-filename msg))
466 (output-file (mh-expand-file-name file)))
467 (setq mh-last-destination (list 'write file no-headers))
468 (save-excursion
469 (set-buffer (get-buffer-create " *mh-temp*"))
470 (erase-buffer)
471 (insert-file-contents file-name)
472 (goto-char (point-min))
473 (if no-headers (search-forward "\n\n"))
474 (append-to-file (point) (point-max) output-file))))
475
476
477 (defun mh-toggle-showing ()
478 "Toggle the scanning mode/showing mode of displaying messages."
479 (interactive)
480 (if mh-showing
481 (mh-set-scan-mode)
482 (mh-show)))
483
484
485 (defun mh-undo (msg-or-seq)
486 "Undo the deletion or refile of the specified MESSAGE(s).
487 Default is the displayed message. If optional prefix argument is
488 provided, then prompt for the message sequence."
489 (interactive (list (if current-prefix-arg
490 (mh-read-seq-default "Undo" t)
491 (mh-get-msg-num t))))
492 (cond ((numberp msg-or-seq)
493 (let ((original-position (point)))
494 (beginning-of-line)
495 (while (not (or (looking-at mh-deleted-msg-regexp)
496 (looking-at mh-refiled-msg-regexp)
497 (and (eq mh-next-direction 'forward) (bobp))
498 (and (eq mh-next-direction 'backward)
499 (save-excursion (forward-line) (eobp)))))
500 (forward-line (if (eq mh-next-direction 'forward) -1 1)))
501 (if (or (looking-at mh-deleted-msg-regexp)
502 (looking-at mh-refiled-msg-regexp))
503 (progn
504 (mh-undo-msg (mh-get-msg-num t))
505 (mh-maybe-show))
506 (goto-char original-position)
507 (error "Nothing to undo"))))
508 (t
509 (mh-mapc (function mh-undo-msg) (mh-seq-to-msgs msg-or-seq))))
510 ;; update the mh-refile-list so mh-outstanding-commands-p will work
511 (mh-mapc (function
512 (lambda (elt)
513 (if (not (mh-seq-to-msgs elt))
514 (setq mh-refile-list (delq elt mh-refile-list)))))
515 mh-refile-list)
516 (if (not (mh-outstanding-commands-p))
517 (mh-set-folder-modified-p nil)))
518
519
520 (defun mh-version ()
521 "Display version information about mh-e and MH."
522 (interactive)
523 (mh-find-progs)
524 (set-buffer (get-buffer-create " *mh-temp*"))
525 (erase-buffer)
526 (insert " mh-e info:\n\nversion: " mh-e-version "\n" mh-e-time-stamp
527 "\nEmacs: " emacs-version " on " (symbol-name system-type) " ")
528 (condition-case ()
529 (call-process "uname" nil t nil "-a")
530 (file-error))
531 (insert "\n\n MH info:\n\n" (expand-file-name "inc" mh-progs) ":\n")
532 (let ((help-start (point)))
533 (condition-case err-data
534 (mh-exec-cmd-output "inc" nil "-help")
535 (file-error (insert (mapconcat 'concat (cdr err-data) ": "))))
536 (goto-char help-start)
537 (search-forward "version: " nil t)
538 (beginning-of-line)
539 (delete-region help-start (point))
540 (goto-char (point-min)))
541 (display-buffer " *mh-temp*"))
542
543
544 (defun mh-visit-folder (folder &optional range)
545 "Visits FOLDER and displays RANGE of messages.
546 Assumes mh-e has already been initialized.
547 Do not call this function from outside mh-e; see \\[mh-rmail] instead."
548 (interactive (list (mh-prompt-for-folder "Visit" "+inbox" t)
549 (mh-read-msg-range "Range [all]? ")))
550 (let ((config (current-window-configuration)))
551 (mh-scan-folder folder (or range "all"))
552 (setq mh-previous-window-config config))
553 nil)
554
555
556 (defun mh-compat-quit ()
557 "\"b\" reserved for future use as mh-burst-digest; will assume you want \"\\[mh-quit]\" ..."
558 ;; This is a temporary compatibility function
559 (interactive)
560 (message "%s" (documentation this-command))
561 (sit-for 1)
562 (call-interactively 'mh-quit))
563
564 \f
565
566 ;;; Support routines.
567
568 (defun mh-delete-a-msg (msg)
569 ;; Delete the MESSAGE.
570 (save-excursion
571 (mh-goto-msg msg nil t)
572 (if (looking-at mh-refiled-msg-regexp)
573 (error "Message %d is refiled. Undo refile before deleting." msg))
574 (if (looking-at mh-deleted-msg-regexp)
575 nil
576 (mh-set-folder-modified-p t)
577 (setq mh-delete-list (cons msg mh-delete-list))
578 (mh-add-msgs-to-seq msg 'deleted t)
579 (mh-notate msg ?D mh-cmd-note)
580 (run-hooks 'mh-delete-msg-hook))))
581
582 (defun mh-refile-a-msg (msg destination)
583 ;; Refile MESSAGE in FOLDER. FOLDER is a symbol, not a string.
584 (save-excursion
585 (mh-goto-msg msg nil t)
586 (cond ((looking-at mh-deleted-msg-regexp)
587 (error "Message %d is deleted. Undo delete before moving." msg))
588 ((looking-at mh-refiled-msg-regexp)
589 (if (y-or-n-p
590 (format "Message %d already refiled. Copy to %s as well? "
591 msg destination))
592 (mh-exec-cmd "refile" (mh-get-msg-num t) "-link"
593 "-src" mh-current-folder
594 (symbol-name destination))
595 (message "Message not copied.")))
596 (t
597 (mh-set-folder-modified-p t)
598 (if (not (memq destination mh-refile-list))
599 (setq mh-refile-list (cons destination mh-refile-list)))
600 (if (not (memq msg (mh-seq-to-msgs destination)))
601 (mh-add-msgs-to-seq msg destination t))
602 (mh-notate msg ?^ mh-cmd-note)
603 (run-hooks 'mh-refile-msg-hook)))))
604
605
606 (defun mh-next-msg ()
607 ;; Move backward or forward to the next undeleted message in the buffer.
608 (if (eq mh-next-direction 'forward)
609 (mh-next-undeleted-msg 1)
610 (mh-previous-undeleted-msg 1)))
611
612
613 (defun mh-set-scan-mode ()
614 ;; Display the scan listing buffer, but do not show a message.
615 (if (get-buffer mh-show-buffer)
616 (delete-windows-on mh-show-buffer))
617 (setq mh-showing nil)
618 (set-buffer-modified-p (buffer-modified-p)) ;force mode line update
619 (if mh-recenter-summary-p
620 (mh-recenter nil)))
621
622
623 (defun mh-undo-msg (msg)
624 ;; Undo the deletion or refile of one MESSAGE.
625 (cond ((memq msg mh-delete-list)
626 (setq mh-delete-list (delq msg mh-delete-list))
627 (mh-delete-msg-from-seq msg 'deleted t))
628 (t
629 (mh-mapc (function (lambda (dest)
630 (mh-delete-msg-from-seq msg dest t)))
631 mh-refile-list)))
632 (mh-notate msg ? mh-cmd-note))
633
634
635 \f
636
637 ;;; The folder data abstraction.
638
639 (defun mh-make-folder (name)
640 ;; Create and initialize a new mail folder called NAME and make it the
641 ;; current folder.
642 (switch-to-buffer name)
643 (setq buffer-read-only nil)
644 (erase-buffer)
645 (setq buffer-read-only t)
646 (mh-folder-mode)
647 (mh-set-folder-modified-p nil)
648 (setq buffer-file-name mh-folder-filename))
649
650
651 ;;; Ensure new buffers won't get this mode if default-major-mode is nil.
652 (put 'mh-folder-mode 'mode-class 'special)
653
654 (defun mh-folder-mode ()
655 "Major mh-e mode for \"editing\" an MH folder scan listing.\\<mh-folder-mode-map>
656 You can show the message the cursor is pointing to, and step through the
657 messages. Messages can be marked for deletion or refiling into another
658 folder; these commands are executed all at once with a separate command.
659
660 A prefix argument (\\[universal-argument]) to delete, refile, list, or undo
661 applies the action to a message sequence.
662
663 Here is a list of the standard keys for mh-e commands, grouped by function.
664 This list is purposefully not customized; mh-e has a long history, and many
665 alternate key bindings as a result. This list is to encourage users to use
666 standard keys so the other keys can perhaps someday be put to new uses.
667
668 t toggle show or scan-only mode
669 . show message, or back to top if already showing
670
671 SPC page forward
672 DEL page back
673
674 n next message
675 p previous message
676 j jump to message by number
677
678 d mark for deletion
679 o, ^ mark for output (refile) to another folder
680 ? show folder of pending refile
681 u undo delete or refile marking
682
683 x execute marked deletes and refiles
684 i incorporate new mail
685
686 m mail a new message
687 r reply to a message
688 f forward a message
689
690 q quit mh-e
691
692 M-f visit new folder
693 M-r rescan this folder
694
695 Here are all the commands with their current binding, listed in key order:
696 \\{mh-folder-mode-map}
697
698 Variables controlling mh-e operation are (defaults in parentheses):
699
700 mh-recursive-folders (nil)
701 Non-nil means commands which operate on folders do so recursively.
702
703 mh-bury-show-buffer (t)
704 Non-nil means that the buffer used to display message is buried.
705 It will never be offered as the default other buffer.
706
707 mh-clean-message-header (nil)
708 Non-nil means remove header lines matching the regular expression
709 specified in mh-invisible-headers from messages.
710
711 mh-visible-headers (nil)
712 If non-nil, it contains a regexp specifying the headers that are shown in
713 a message if mh-clean-message-header is non-nil. Setting this variable
714 overrides mh-invisible-headers.
715
716 mh-do-not-confirm (nil)
717 Non-nil means do not prompt for confirmation before executing some
718 non-recoverable commands such as mh-kill-folder and mh-undo-folder.
719
720 mhl-formfile (nil)
721 Name of format file to be used by mhl to show messages.
722 A value of T means use the default format file.
723 Nil means don't use mhl to format messages.
724
725 mh-lpr-command-format (\"lpr -p -J '%s'\")
726 Format for command used to print a message on a system printer.
727
728 mh-scan-prog (\"scan\")
729 Program to run to generate one-line-per-message listing of a folder.
730 Normally \"scan\" or a file name linked to scan. This file is searched
731 for relative to the mh-progs directory unless it is an absolute pathname.
732 Automatically becomes buffer-local when set in any fashion.
733
734 mh-print-background (nil)
735 Print messages in the background if non-nil.
736 WARNING: do not delete the messages until printing is finished;
737 otherwise, your output may be truncated.
738
739 mh-recenter-summary-p (nil)
740 If non-nil, then the scan listing is recentered when the window displaying
741 a messages is toggled off.
742
743 mh-summary-height (4)
744 Number of lines in the summary window including the mode line.
745
746 mh-ins-buf-prefix (\"> \")
747 String to insert before each non-blank line of a message as it is
748 inserted in a draft letter.
749
750 The value of mh-folder-mode-hook is called when a new folder is set up."
751
752 (kill-all-local-variables)
753 (use-local-map mh-folder-mode-map)
754 (setq major-mode 'mh-folder-mode)
755 (mh-set-mode-name "MH-Folder")
756 (make-local-vars
757 'mh-current-folder (buffer-name) ; Name of folder, a string
758 'mh-show-buffer (format "show-%s" (buffer-name)) ; Buffer that displays msgs
759 'mh-folder-filename ; e.g. "/usr/foobar/Mail/inbox/"
760 (file-name-as-directory (mh-expand-file-name (buffer-name)))
761 'mh-showing nil ; Show message also?
762 'mh-next-seq-num 0 ; Index of free sequence id
763 'mh-delete-list nil ; List of msgs nums to delete
764 'mh-refile-list nil ; List of folder names in mh-seq-list
765 'mh-seq-list nil ; Alist of (seq . msgs) nums
766 'mh-seen-list nil ; List of displayed messages
767 'mh-next-direction 'forward ; Direction to move to next message
768 'mh-narrowed-to-seq nil ; Sequence display is narrowed to
769 'mh-first-msg-num nil ; Number of first msg in buffer
770 'mh-last-msg-num nil ; Number of last msg in buffer
771 'mh-previous-window-config nil) ; Previous window configuration
772 (setq truncate-lines t)
773 (auto-save-mode -1)
774 (setq buffer-offer-save t)
775 (make-local-variable 'local-write-file-hooks)
776 (setq local-write-file-hooks '(mh-execute-commands))
777 (make-local-variable 'revert-buffer-function)
778 (setq revert-buffer-function 'mh-undo-folder)
779 (or (assq 'mh-showing minor-mode-alist)
780 (setq minor-mode-alist
781 (cons '(mh-showing " Show") minor-mode-alist)))
782 (run-hooks 'mh-folder-mode-hook))
783
784
785 (defun make-local-vars (&rest pairs)
786 ;; Take VARIABLE-VALUE pairs and makes local variables initialized to the
787 ;; value.
788 (while pairs
789 (make-variable-buffer-local (car pairs))
790 (set (car pairs) (car (cdr pairs)))
791 (setq pairs (cdr (cdr pairs)))))
792
793
794 (defun mh-scan-folder (folder range)
795 ;; Scan the FOLDER over the RANGE. Return in the folder's buffer.
796 (cond ((null (get-buffer folder))
797 (mh-make-folder folder))
798 (t
799 (mh-process-or-undo-commands folder)
800 (switch-to-buffer folder)))
801 (mh-regenerate-headers range)
802 (cond ((zerop (buffer-size))
803 (if (equal range "all")
804 (message "Folder %s is empty" folder)
805 (message "No messages in %s, range %s" folder range))
806 (sit-for 5)))
807 (mh-goto-cur-msg))
808
809
810 (defun mh-regenerate-headers (range)
811 ;; Replace buffer with scan of its contents over range RANGE.
812 (let ((folder mh-current-folder))
813 (message "Scanning %s..." folder)
814 (with-mh-folder-updating (nil)
815 (erase-buffer)
816 (mh-exec-cmd-output mh-scan-prog nil
817 "-noclear" "-noheader"
818 "-width" (window-width)
819 folder range)
820 (goto-char (point-min))
821 (cond ((looking-at "scan: no messages in")
822 (keep-lines mh-valid-scan-line)) ; Flush random scan lines
823 ((looking-at "scan: ")) ; Keep error messages
824 (t
825 (keep-lines mh-valid-scan-line))) ; Flush random scan lines
826 (mh-delete-seq-locally 'cur) ; To pick up new one
827 (setq mh-seq-list (mh-read-folder-sequences folder nil))
828 (mh-notate-user-sequences)
829 (mh-make-folder-mode-line (if (equal range "all")
830 nil
831 mh-partial-folder-mode-line-annotation)))
832 (message "Scanning %s...done" folder)))
833
834
835 (defun mh-get-new-mail (maildrop-name)
836 ;; Read new mail from a maildrop into the current buffer.
837 ;; Return in the current buffer.
838 (let ((point-before-inc (point))
839 (folder mh-current-folder)
840 (new-mail-p nil))
841 (with-mh-folder-updating (t)
842 (message (if maildrop-name
843 (format "inc %s -file %s..." folder maildrop-name)
844 (format "inc %s..." folder)))
845 (setq mh-next-direction 'forward)
846 (goto-char (point-max))
847 (let ((start-of-inc (point)))
848 (if maildrop-name
849 (mh-exec-cmd-output mh-inc-prog nil folder
850 "-file" (expand-file-name maildrop-name)
851 "-width" (window-width)
852 "-truncate")
853 (mh-exec-cmd-output mh-inc-prog nil
854 "-width" (window-width)))
855 (message
856 (if maildrop-name
857 (format "inc %s -file %s...done" folder maildrop-name)
858 (format "inc %s...done" folder)))
859 (goto-char start-of-inc)
860 (cond ((looking-at "inc: no mail")
861 (message "No new mail%s%s" (if maildrop-name " in " "")
862 (if maildrop-name maildrop-name "")))
863 ((re-search-forward "^inc:" nil t) ; Error messages
864 (error "inc error"))
865 (t
866 ;; remove old cur notation (cf mh-goto-cur-msg code)
867 (let ((cur-msg (car (mh-seq-to-msgs 'cur))))
868 (save-excursion
869 (and cur-msg
870 (mh-goto-msg cur-msg t nil)
871 (looking-at mh-cur-scan-msg-regexp)
872 (mh-notate nil ? mh-cmd-note))))
873 (setq new-mail-p t)))
874 (keep-lines mh-valid-scan-line) ; Flush random scan lines
875 (mh-delete-seq-locally 'cur) ; To pick up new one
876 (setq mh-seq-list (mh-read-folder-sequences folder t))
877 (mh-notate-user-sequences)
878 (if new-mail-p
879 (progn
880 (mh-goto-cur-msg)
881 (mh-make-folder-mode-line))
882 (goto-char point-before-inc))))))
883
884
885 (defun mh-make-folder-mode-line (&optional annotation)
886 ;; Set the fields of the mode line for a folder buffer.
887 ;; The optional ANNOTATION string is displayed after the folder's name.
888 (save-excursion
889 (mh-first-msg)
890 (setq mh-first-msg-num (mh-get-msg-num nil))
891 (mh-last-msg)
892 (setq mh-last-msg-num (mh-get-msg-num nil))
893 (let ((lines (count-lines (point-min) (point-max))))
894 (setq mode-line-buffer-identification
895 (list (format "{%%b%s} %d msg%s"
896 (if annotation (format "/%s" annotation) "")
897 lines
898 (if (zerop lines)
899 "s"
900 (if (> lines 1)
901 (format "s (%d-%d)" mh-first-msg-num
902 mh-last-msg-num)
903 (format " (%d)" mh-first-msg-num)))))))))
904
905
906 (defun mh-unmark-all-headers (remove-all-flags)
907 ;; Remove all '+' flags from the headers, and if called with a non-nil
908 ;; argument, remove all 'D', '^' and '%' flags too.
909 ;; Optimized for speed (i.e., no regular expressions).
910 (save-excursion
911 (let ((case-fold-search nil)
912 (last-line (- (point-max) mh-cmd-note))
913 char)
914 (mh-first-msg)
915 (while (<= (point) last-line)
916 (forward-char mh-cmd-note)
917 (setq char (following-char))
918 (if (or (and remove-all-flags
919 (or (eql char ?D)
920 (eql char ?^)
921 (eql char ?%)))
922 (eql char ?+))
923 (progn
924 (delete-char 1)
925 (insert " ")))
926 (forward-line)))))
927
928
929 (defun mh-goto-cur-msg ()
930 ;; Position the cursor at the current message.
931 (let ((cur-msg (car (mh-seq-to-msgs 'cur))))
932 (cond ((and cur-msg
933 (mh-goto-msg cur-msg t nil))
934 (mh-notate nil ?+ mh-cmd-note)
935 (mh-recenter 0)
936 (mh-maybe-show cur-msg))
937 (t
938 (mh-last-msg)
939 (message "No current message")))))
940
941
942 (defun mh-process-or-undo-commands (folder)
943 ;; If FOLDER has outstanding commands, then either process or discard them.
944 ;; Called by functions like mh-sort-folder, so also invalidate show buffer.
945 (set-buffer folder)
946 (if (mh-outstanding-commands-p)
947 (if (or mh-do-not-confirm
948 (y-or-n-p
949 "Process outstanding deletes and refiles (or lose them)? "))
950 (mh-process-commands folder)
951 (mh-undo-folder)))
952 (mh-update-unseen)
953 (mh-invalidate-show-buffer))
954
955
956 (defun mh-process-commands (folder)
957 ;; Process outstanding commands for the folder FOLDER.
958 (message "Processing deletes and refiles for %s..." folder)
959 (set-buffer folder)
960 (with-mh-folder-updating (nil)
961 ;; Update the unseen sequence if it exists
962 (mh-update-unseen)
963
964 ;; Then refile messages
965 (mh-mapc
966 (function
967 (lambda (dest)
968 (let ((msgs (mh-seq-to-msgs dest)))
969 (cond (msgs
970 (apply 'mh-exec-cmd "refile"
971 "-src" folder (symbol-name dest) msgs)
972 (mh-delete-scan-msgs msgs))))))
973 mh-refile-list)
974 (setq mh-refile-list nil)
975
976 ;; Now delete messages
977 (cond (mh-delete-list
978 (apply 'mh-exec-cmd "rmm" folder mh-delete-list)
979 (mh-delete-scan-msgs mh-delete-list)
980 (setq mh-delete-list nil)))
981
982 ;; Don't need to remove sequences since delete and refile do so.
983
984 ;; Mark cur message
985 (if (> (buffer-size) 0)
986 (mh-define-sequence 'cur (or (mh-get-msg-num nil) "last")))
987
988 (and (buffer-file-name (get-buffer mh-show-buffer))
989 (not (file-exists-p (buffer-file-name (get-buffer mh-show-buffer))))
990 ;; If "inc" were to put a new msg in this file,
991 ;; we would not notice, so mark it invalid now.
992 (mh-invalidate-show-buffer))
993
994 (setq mh-seq-list (mh-read-folder-sequences mh-current-folder nil))
995 (mh-unmark-all-headers t)
996 (mh-notate-user-sequences)
997 (message "Processing deletes and refiles for %s...done" folder)))
998
999
1000 (defun mh-update-unseen ()
1001 ;; Push updates to the Unseen sequence out to MH.
1002 (if mh-seen-list
1003 (progn
1004 (if (mh-seq-to-msgs mh-unseen-seq)
1005 (mh-undefine-sequence mh-unseen-seq mh-seen-list))
1006 (setq mh-seen-list nil))))
1007
1008
1009 (defun mh-delete-scan-msgs (msgs)
1010 ;; Delete the scan listing lines for each of the msgs in the LIST.
1011 ;; Optimized for speed (i.e., no regular expressions).
1012 (setq msgs (sort msgs (function <))) ;okay to clobber msgs
1013 (save-excursion
1014 (mh-first-msg)
1015 (while (and msgs (< (point) (point-max)))
1016 (cond ((equal (mh-get-msg-num nil) (car msgs))
1017 (delete-region (point) (save-excursion (forward-line) (point)))
1018 (setq msgs (cdr msgs)))
1019 (t
1020 (forward-line))))))
1021
1022
1023 (defun mh-outstanding-commands-p ()
1024 ;; Returns non-nil if there are outstanding deletes or refiles.
1025 (or mh-delete-list mh-refile-list))
1026
1027 \f
1028
1029 ;;; Basic sequence handling
1030
1031 (defun mh-delete-seq-locally (seq)
1032 ;; Remove mh-e's record of SEQUENCE.
1033 (let ((entry (mh-find-seq seq)))
1034 (setq mh-seq-list (delq entry mh-seq-list))))
1035
1036 (defun mh-read-folder-sequences (folder save-refiles)
1037 ;; Read and return the predefined sequences for a FOLDER.
1038 ;; If SAVE-REFILES is non-nil, then keep the sequences
1039 ;; that note messages to be refiled.
1040 (let ((seqs ()))
1041 (cond (save-refiles
1042 (mh-mapc (function (lambda (seq) ; Save the refiling sequences
1043 (if (mh-folder-name-p (mh-seq-name seq))
1044 (setq seqs (cons seq seqs)))))
1045 mh-seq-list)))
1046 (save-excursion
1047 (if (eq 0 (mh-exec-cmd-quiet nil "mark" folder "-list"))
1048 (progn
1049 ;; look for name in line of form "cur: 4" or "myseq (private): 23"
1050 (while (re-search-forward "^[^: ]+" nil t)
1051 (setq seqs (cons (mh-make-seq (intern (buffer-substring
1052 (match-beginning 0)
1053 (match-end 0)))
1054 (mh-read-msg-list))
1055 seqs)))
1056 (delete-region (point-min) (point))))) ; avoid race with mh-process-daemon
1057 seqs))
1058
1059 (defun mh-read-msg-list ()
1060 ;; Return a list of message numbers from the current point to the end of
1061 ;; the line.
1062 (let ((msgs ())
1063 (end-of-line (save-excursion (end-of-line) (point)))
1064 num)
1065 (while (re-search-forward "[0-9]+" end-of-line t)
1066 (setq num (string-to-int (buffer-substring (match-beginning 0)
1067 (match-end 0))))
1068 (cond ((looking-at "-") ; Message range
1069 (forward-char 1)
1070 (re-search-forward "[0-9]+" end-of-line t)
1071 (let ((num2 (string-to-int (buffer-substring (match-beginning 0)
1072 (match-end 0)))))
1073 (if (< num2 num)
1074 (error "Bad message range: %d-%d" num num2))
1075 (while (<= num num2)
1076 (setq msgs (cons num msgs))
1077 (setq num (1+ num)))))
1078 ((not (zerop num)) (setq msgs (cons num msgs)))))
1079 msgs))
1080
1081 (defun mh-notate-user-sequences ()
1082 ;; Mark the scan listing of all messages in user-defined sequences.
1083 (let ((seqs mh-seq-list)
1084 name)
1085 (while seqs
1086 (setq name (mh-seq-name (car seqs)))
1087 (if (not (mh-internal-seq name))
1088 (mh-notate-seq name ?% (1+ mh-cmd-note)))
1089 (setq seqs (cdr seqs)))))
1090
1091
1092 (defun mh-internal-seq (name)
1093 ;; Return non-NIL if NAME is the name of an internal mh-e sequence.
1094 (or (memq name '(answered cur deleted forwarded printed))
1095 (eq name mh-unseen-seq)
1096 (eq name mh-previous-seq)
1097 (mh-folder-name-p name)))
1098
1099
1100 (defun mh-delete-msg-from-seq (msg seq &optional internal-flag)
1101 "Delete MESSAGE from SEQUENCE. MESSAGE defaults to displayed message.
1102 From Lisp, optional third arg INTERNAL non-nil means do not
1103 inform MH of the change."
1104 (interactive (list (mh-get-msg-num t)
1105 (mh-read-seq-default "Delete from" t)
1106 nil))
1107 (let ((entry (mh-find-seq seq)))
1108 (cond (entry
1109 (mh-notate-if-in-one-seq msg ? (1+ mh-cmd-note) (mh-seq-name entry))
1110 (if (not internal-flag)
1111 (mh-undefine-sequence seq msg))
1112 (setcdr entry (delq msg (mh-seq-msgs entry)))))))
1113
1114
1115 (defun mh-undefine-sequence (seq msgs)
1116 ;; Remove from the SEQUENCE the MSGS, which may be a list or single msg.
1117 (mh-exec-cmd "mark" mh-current-folder "-delete"
1118 "-sequence" (symbol-name seq)
1119 msgs))
1120
1121
1122 (defun mh-define-sequence (seq msgs)
1123 ;; Define the SEQUENCE to contain the list of MSGS.
1124 ;; Do not mark pseudo-sequences or empty sequences.
1125 ;; Signals an error if SEQUENCE is an illegal name.
1126 (if (and msgs
1127 (not (mh-folder-name-p seq)))
1128 (save-excursion
1129 (mh-exec-cmd-error nil "mark" mh-current-folder "-add" "-zero"
1130 "-sequence" (symbol-name seq)
1131 msgs))))
1132
1133
1134 (defun mh-define-sequences (seq-list)
1135 ;; Define the sequences in SEQ-LIST.
1136 (mh-map-over-seqs 'mh-define-sequence seq-list))
1137
1138
1139 (defun mh-map-over-seqs (func seq-list)
1140 ;; Apply the FUNCTION to each element in the list of SEQUENCES,
1141 ;; passing the sequence name and the list of messages as arguments.
1142 (while seq-list
1143 (funcall func (mh-seq-name (car seq-list)) (mh-seq-msgs (car seq-list)))
1144 (setq seq-list (cdr seq-list))))
1145
1146
1147 (defun mh-notate-if-in-one-seq (msg notation offset seq)
1148 ;; If the MESSAGE is in only the SEQUENCE, then mark the scan listing of the
1149 ;; message with the CHARACTER at the given OFFSET from the beginning of the
1150 ;; listing line.
1151 (let ((in-seqs (mh-seq-containing-msg msg)))
1152 (if (and (eq seq (car in-seqs)) (null (cdr in-seqs)))
1153 (mh-notate msg notation offset))))
1154
1155
1156 (defun mh-seq-containing-msg (msg)
1157 ;; Return a list of the sequences containing MESSAGE.
1158 (let ((l mh-seq-list)
1159 (seqs ()))
1160 (while l
1161 (if (memq msg (mh-seq-msgs (car l)))
1162 (setq seqs (cons (mh-seq-name (car l)) seqs)))
1163 (setq l (cdr l)))
1164 seqs))
1165
1166
1167 \f
1168
1169 ;;; User prompting commands.
1170
1171
1172 (defun mh-read-msg-range (prompt)
1173 ;; Read a list of blank-separated items.
1174 (let* ((buf (read-string prompt))
1175 (buf-size (length buf))
1176 (start 0)
1177 (input ()))
1178 (while (< start buf-size)
1179 (let ((next (read-from-string buf start buf-size)))
1180 (setq input (cons (car next) input))
1181 (setq start (cdr next))))
1182 (nreverse input)))
1183
1184 \f
1185
1186 ;;; Build the folder-mode keymap:
1187
1188 (suppress-keymap mh-folder-mode-map)
1189 (define-key mh-folder-mode-map "q" 'mh-quit)
1190 (define-key mh-folder-mode-map "b" 'mh-compat-quit)
1191 (define-key mh-folder-mode-map "?" 'mh-msg-is-in-seq)
1192 (define-key mh-folder-mode-map "%" 'mh-put-msg-in-seq)
1193 (define-key mh-folder-mode-map "|" 'mh-pipe-msg)
1194 (define-key mh-folder-mode-map "\ea" 'mh-edit-again)
1195 (define-key mh-folder-mode-map "\e%" 'mh-delete-msg-from-seq)
1196 (define-key mh-folder-mode-map "\e#" 'mh-delete-seq)
1197 (define-key mh-folder-mode-map "\C-xn" 'mh-narrow-to-seq)
1198 (define-key mh-folder-mode-map "\C-xw" 'mh-widen)
1199 (define-key mh-folder-mode-map "\eb" 'mh-burst-digest)
1200 (define-key mh-folder-mode-map "\eu" 'mh-undo-folder)
1201 (define-key mh-folder-mode-map "\e " 'mh-page-digest)
1202 (define-key mh-folder-mode-map "\e\177" 'mh-page-digest-backwards)
1203 (define-key mh-folder-mode-map "\ed" 'mh-redistribute)
1204 (define-key mh-folder-mode-map "\ee" 'mh-extract-rejected-mail)
1205 (define-key mh-folder-mode-map "\ef" 'mh-visit-folder)
1206 (define-key mh-folder-mode-map "\ek" 'mh-kill-folder)
1207 (define-key mh-folder-mode-map "\el" 'mh-list-folders)
1208 (define-key mh-folder-mode-map "\en" 'mh-store-msg)
1209 (define-key mh-folder-mode-map "\ep" 'mh-pack-folder)
1210 (define-key mh-folder-mode-map "\eq" 'mh-list-sequences)
1211 (define-key mh-folder-mode-map "\es" 'mh-search-folder)
1212 (define-key mh-folder-mode-map "\er" 'mh-rescan-folder)
1213 (define-key mh-folder-mode-map "l" 'mh-print-msg)
1214 (define-key mh-folder-mode-map "t" 'mh-toggle-showing)
1215 (define-key mh-folder-mode-map "c" 'mh-copy-msg)
1216 (define-key mh-folder-mode-map "i" 'mh-inc-folder)
1217 (define-key mh-folder-mode-map "x" 'mh-execute-commands)
1218 (define-key mh-folder-mode-map "e" 'mh-execute-commands)
1219 (define-key mh-folder-mode-map "f" 'mh-forward)
1220 (define-key mh-folder-mode-map "m" 'mh-send)
1221 (define-key mh-folder-mode-map "s" 'mh-send)
1222 (define-key mh-folder-mode-map "r" 'mh-reply)
1223 (define-key mh-folder-mode-map "a" 'mh-reply)
1224 (define-key mh-folder-mode-map "j" 'mh-goto-msg)
1225 (define-key mh-folder-mode-map "g" 'mh-goto-msg)
1226 (define-key mh-folder-mode-map "\e>" 'mh-last-msg)
1227 (define-key mh-folder-mode-map "\177" 'mh-previous-page)
1228 (define-key mh-folder-mode-map " " 'mh-page-msg)
1229 (define-key mh-folder-mode-map "." 'mh-show)
1230 (define-key mh-folder-mode-map "," 'mh-header-display)
1231 (define-key mh-folder-mode-map "u" 'mh-undo)
1232 (define-key mh-folder-mode-map "d" 'mh-delete-msg)
1233 (define-key mh-folder-mode-map "\C-d" 'mh-delete-msg-no-motion)
1234 (define-key mh-folder-mode-map "p" 'mh-previous-undeleted-msg)
1235 (define-key mh-folder-mode-map "n" 'mh-next-undeleted-msg)
1236 (define-key mh-folder-mode-map "o" 'mh-refile-msg)
1237 (define-key mh-folder-mode-map "^" 'mh-refile-msg)
1238 (define-key mh-folder-mode-map "\C-o" 'mh-write-msg-to-file)
1239 (define-key mh-folder-mode-map ">" 'mh-write-msg-to-file)
1240 (define-key mh-folder-mode-map "!" 'mh-refile-or-write-again)
1241
1242 \f
1243
1244 ;;;autoload the other mh-e parts
1245
1246 ;;; mh-comp
1247
1248 (autoload 'mh-smail "mh-comp"
1249 "Compose and send mail with the MH mail system." t)
1250 (autoload 'mh-smail-other-window "mh-comp"
1251 "Compose and send mail in other window with the MH mail system." t)
1252 (autoload 'mh-edit-again "mh-comp"
1253 "Clean-up a draft or a message previously sent and make it resendable." t)
1254 (autoload 'mh-extract-rejected-mail "mh-comp"
1255 "Extract a letter returned by the mail system and make it resendable." t)
1256 (autoload 'mh-forward "mh-comp"
1257 "Forward MESSAGE(s) (default: displayed message)." t)
1258 (autoload 'mh-redistribute "mh-comp"
1259 "Redistribute a letter." t)
1260 (autoload 'mh-reply "mh-comp"
1261 "Reply to a MESSAGE (default: displayed message)." t)
1262 (autoload 'mh-send "mh-comp"
1263 "Compose and send a letter." t)
1264 (autoload 'mh-send-other-window "mh-comp"
1265 "Compose and send a letter in another window." t)
1266 (autoload 'mh-letter-mode "mh-comp"
1267 "Mode for composing letters in mh-e." t)
1268
1269
1270 ;;; mh-funcs
1271
1272 (autoload 'mh-burst-digest "mh-funcs"
1273 "Burst apart the current message, which should be a digest." t)
1274 (autoload 'mh-copy-msg "mh-funcs"
1275 "Copy specified MESSAGE(s) to another FOLDER without deleting them." t)
1276 (autoload 'mh-kill-folder "mh-funcs"
1277 "Remove the current folder." t)
1278 (autoload 'mh-list-folders "mh-funcs"
1279 "List mail folders." t)
1280 (autoload 'mh-pack-folder "mh-funcs"
1281 "Renumber the messages of a folder to be 1..n." t)
1282 (autoload 'mh-pipe-msg "mh-funcs"
1283 "Pipe the current message through the given shell COMMAND." t)
1284 (autoload 'mh-page-digest "mh-funcs"
1285 "Advance displayed message to next digested message." t)
1286 (autoload 'mh-page-digest-backwards "mh-funcs"
1287 "Back up displayed message to previous digested message." t)
1288 (autoload 'mh-print-msg "mh-funcs"
1289 "Print MESSAGE(s) (default: displayed message) on a line printer." t)
1290 (autoload 'mh-sort-folder "mh-funcs"
1291 "Sort the messages in the current folder by date." t)
1292 (autoload 'mh-undo-folder "mh-funcs"
1293 "Undo all commands in current folder." t)
1294 (autoload 'mh-store-msg "mh-funcs"
1295 "Store the file(s) contained in the current message into DIRECTORY.
1296 The message can contain a shar file or uuencoded file." t)
1297 (autoload 'mh-store-buffer "mh-funcs"
1298 "Store the file(s) contained in the current buffer into DIRECTORY.
1299 The buffer can contain a shar file or uuencoded file." t)
1300
1301
1302 ;;; mh-pick
1303
1304 (autoload 'mh-search-folder "mh-pick"
1305 "Search FOLDER for messages matching a pattern." t)
1306
1307 ;;; mh-seq
1308
1309 (autoload 'mh-put-msg-in-seq "mh-seq"
1310 "Add MESSAGE(s) (default: displayed message) to SEQUENCE." t)
1311 (autoload 'mh-delete-seq "mh-seq"
1312 "Delete the SEQUENCE." t)
1313 (autoload 'mh-list-sequences "mh-seq"
1314 "List the sequences defined in FOLDER." t)
1315 (autoload 'mh-msg-is-in-seq "mh-seq"
1316 "Display the sequences that contain MESSAGE (default: displayed message)." t)
1317 (autoload 'mh-narrow-to-seq "mh-seq"
1318 "Restrict display of this folder to just messages in a sequence." t)
1319 (autoload 'mh-widen "mh-seq"
1320 "Remove restrictions from current folder, thereby showing all messages." t)
1321 (autoload 'mh-rename-seq "mh-seq"
1322 "Rename a SEQUENCE to have a new NAME." t)
1323
1324 ;;; mh-e.el ends here