annotate lisp/=mh-e.el @ 7653:ff5fcf65ceaa

(LD_SWITCH_SYSTEM): Add conditionals for HPUX_USE_SHLIBS. Delete explicit -Xlinker in GCC case.
author Richard M. Stallman <rms@gnu.org>
date Mon, 23 May 1994 07:14:38 +0000
parents 8e8321e76af5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1 ;;; mh-e.el --- GNU Emacs interface to the MH mail system
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
2
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
3 ;;; Copyright (C) 1985, 86, 87, 88, 90, 92, 93 Free Software Foundation
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
4
3327
e533aed58919 (mh-signature-file-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 3220
diff changeset
5 (defconst mh-e-time-stamp "Time-stamp: <93/05/30 18:37:43 gildea>")
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
6
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
7 ;; Maintainer: Stephen Gildea <gildea@lcs.mit.edu>
3327
e533aed58919 (mh-signature-file-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 3220
diff changeset
8 ;; Version: 3.8.2
811
e694e0879463 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 804
diff changeset
9 ;; Keywords: mail
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 ;; GNU Emacs is distributed in the hope that it will be useful,
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 ;; but without any warranty. No author or distributor
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 ;; accepts responsibility to anyone for the consequences of using it
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 ;; or for whether it serves any particular purpose or works at all,
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15 ;; unless he says so in writing.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 ;; Everyone is granted permission to copy, modify and redistribute
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 ;; GNU Emacs, but only under the conditions described in the
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19 ;; document "GNU Emacs copying permission notice". An exact copy
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20 ;; of the document is supposed to have been given to you along with
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21 ;; GNU Emacs so that you can know how you may redistribute it all.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 ;; It should be in a file named COPYING. Among other things, the
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23 ;; copyright notice and this notice must be preserved on all copies.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24
790
47ec7c4c42bc *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 731
diff changeset
25 ;;; Commentary:
47ec7c4c42bc *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 731
diff changeset
26
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
27 ;;; mh-e works with Emacs 18 or 19, and MH 5 or 6.
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
28
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
29 ;;; HOW TO USE:
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
30 ;;; M-x mh-rmail to read mail. Type C-h m there for a list of commands.
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
31 ;;; C-u M-x mh-rmail to visit any folder.
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
32 ;;; M-x mh-smail to send mail. From within the mail reader, "m" works, too.
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
33 ;;; Your .emacs might benefit from these bindings:
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
34 ;;; (global-set-key "\C-xm" 'mh-smail)
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
35 ;;; (global-set-key "\C-x4m" 'mh-smail-other-window)
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
36 ;;; (global-set-key "\C-cr" 'mh-rmail)
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
37
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
38 ;;; MH (Message Handler) is a powerful mail reader. The MH newsgroup
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
39 ;;; is comp.mail.mh; the mailing list is mh-users@ics.uci.edu (send to
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
40 ;;; mh-users-request to be added). See the monthly Frequently Asked
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
41 ;;; Questions posting there for information on getting MH.
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
42
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
43 ;;; NB. MH must have been compiled with the MHE compiler flag or several
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
44 ;;; features necessary mh-e will be missing from MH commands, specifically
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
45 ;;; the -build switch to repl and forw.
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
46
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
47 ;;; Original version for Gosling emacs by Brian Reid, Stanford, 1982.
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
48 ;;; Modified by James Larus, BBN, July 1984 and UCB, 1984 & 1985.
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
49 ;;; Rewritten for GNU Emacs, James Larus 1985. larus@ginger.berkeley.edu
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
50 ;;; Modified by Stephen Gildea 1988. gildea@bbn.com
4495
8e8321e76af5 (mh-read-msg-list): Undo previous change.
Richard M. Stallman <rms@gnu.org>
parents: 4174
diff changeset
51 (defconst mh-e-RCS-id "$Header: /home/fsf/rms/e19/lisp/RCS/mh-e.el,v 1.15 1993/07/20 04:35:00 rms Exp rms $")
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52
790
47ec7c4c42bc *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 731
diff changeset
53 ;;; Code:
47ec7c4c42bc *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 731
diff changeset
54
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57 ;;; Constants:
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
58
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 ;;; Set for local environment:
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 ;;;* These are now in paths.el.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 ;;;(defvar mh-progs "/usr/new/mh/" "Directory containing MH commands.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62 ;;;(defvar mh-lib "/usr/new/lib/mh/" "Directory of MH library.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
64 (defvar mh-redist-full-contents nil
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65 "Non-nil if the `dist' command needs whole letter for redistribution.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66 This is the case when `send' is compiled with the BERK option.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69 ;;; Hooks:
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71 (defvar mh-folder-mode-hook nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72 "Invoked in `mh-folder mode' on a new folder.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74 (defvar mh-letter-mode-hook nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75 "Invoked in `mh-letter-mode' on a new letter.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
77 (defvar mh-compose-letter-function nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
78 "Invoked in `mh-compose-and-send-mail' on a draft letter.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79 It is passed three arguments: TO recipients, SUBJECT, and CC recipients.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
80
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81 (defvar mh-before-send-letter-hook nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82 "Invoked at the beginning of the \\[mh-send-letter] command.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
83
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84 (defvar mh-inc-folder-hook nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85 "Invoked after incorporating mail into a folder with \\[mh-inc-folder].")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
87 (defvar mh-before-quit-hook nil
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
88 "Invoked by \\[mh-quit] before quitting mh-e. See also mh-quit-hook")
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
89
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90 (defvar mh-quit-hook nil
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
91 "Invoked after quitting mh-e by \\[mh-quit]. See also mh-before-quit-hook")
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
92
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
93
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 (defvar mh-ins-string nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95 "Temporarily set by `mh-insert-prefix' prior to running `mh-yank-hooks'.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97 (defvar mh-yank-hooks
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98 '(lambda ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99 (save-excursion
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100 (goto-char (point))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
101 (or (bolp) (forward-line 1))
4113
93d42767e2ec (mh-yank-hooks): Use (mark t).
Richard M. Stallman <rms@gnu.org>
parents: 3850
diff changeset
102 (while (< (point) (mark t))
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
103 (insert mh-ins-string)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104 (forward-line 1))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
105 "Hook to run citation function.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
106 Expects POINT and MARK to be set to the region to cite.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
108
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
109 ;;; Personal preferences:
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111 (defvar mh-clean-message-header nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
112 "*Non-nil means clean headers of messages that are displayed or inserted.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113 The variables `mh-visible-headers' and `mh-invisible-headers' control what
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114 is removed.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
115
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116 (defvar mh-visible-headers nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
117 "*If non-nil, contains a regexp specifying the headers to keep when cleaning.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
118 Only used if `mh-clean-message-header' is non-nil. Setting this variable
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
119 overrides `mh-invisible-headers'.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
120
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
121 (defvar mhl-formfile nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
122 "*Name of format file to be used by mhl to show messages.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
123 A value of T means use the default format file.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
124 Nil means don't use mhl to format messages.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
125
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
126 (defvar mh-lpr-command-format "lpr -p -J '%s'"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
127 "*Format for Unix command that prints a message.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128 The string should be a Unix command line, with the string '%s' where
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
129 the job's name (folder and message number) should appear. The message text
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
130 is piped to this command.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
131
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
132 (defvar mh-print-background nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133 "*Print messages in the background if non-nil.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134 WARNING: do not delete the messages until printing is finished;
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 otherwise, your output may be truncated.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
136
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
137 (defvar mh-summary-height 4
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
138 "*Number of lines in summary window (including the mode line).")
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
139
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
140 (defvar mh-recenter-summary-p nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
141 "*Recenter summary window when the show window is toggled off if non-nil.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
142
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
143 (defvar mh-ins-buf-prefix "> "
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
144 "*String to put before each non-blank line of a yanked or inserted message.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145 Used when the message is inserted in an outgoing letter.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
146
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
147 (defvar mh-do-not-confirm nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
148 "*Non-nil means do not prompt for confirmation before some commands.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
149 Only affects certain innocuous commands.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
150
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
151 (defvar mh-bury-show-buffer t
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
152 "*Non-nil means that the displayed show buffer for a folder is buried.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
153
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154 (defvar mh-delete-yanked-msg-window nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155 "*Controls window display when a message is yanked by \\[mh-yank-cur-msg].
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
156 If non-nil, yanking the current message into a draft letter deletes any
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
157 windows displaying the message.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
158
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
159 (defvar mh-yank-from-start-of-msg t
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
160 "*Controls which part of a message is yanked by \\[mh-yank-cur-msg].
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
161 If non-nil, include the entire message. If the symbol `body', then yank the
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
162 message minus the header. If nil, yank only the portion of the message
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
163 following the point. If the show buffer has a region, this variable is
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
164 ignored.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
165
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
166 (defvar mh-reply-default-reply-to nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
167 "*Sets the person or persons to whom a reply will be sent.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
168 If nil, prompt for recipient. If non-nil, then \\[mh-reply] will use this
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
169 value and it should be one of \"from\", \"to\", or \"cc\".")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
170
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
171 (defvar mh-recursive-folders nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
172 "*If non-nil, then commands which operate on folders do so recursively.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
173
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
174 (defvar mh-unshar-default-directory ""
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
175 "*Default for directory name prompted for by mh-unshar-msg.")
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
176
3327
e533aed58919 (mh-signature-file-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 3220
diff changeset
177 (defvar mh-signature-file-name "~/.signature"
e533aed58919 (mh-signature-file-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 3220
diff changeset
178 "*Name of file containing the user's signature.
e533aed58919 (mh-signature-file-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 3220
diff changeset
179 Inserted into message by \\<mh-letter-mode-map>\\[mh-insert-signature].")
e533aed58919 (mh-signature-file-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 3220
diff changeset
180
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
181
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
182 ;;; Parameterize mh-e to work with different scan formats. The defaults work
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
183 ;;; with the standard MH scan listings.
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
184
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
185 (defvar mh-cmd-note 4
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
186 "Offset to insert notation.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
187
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
188 (defvar mh-note-repl "-"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
189 "String whose first character is used to notate replied to messages.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
190
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
191 (defvar mh-note-forw "F"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
192 "String whose first character is used to notate forwarded messages.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
193
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
194 (defvar mh-note-dist "R"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
195 "String whose first character is used to notate redistributed messages.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
196
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
197 (defvar mh-good-msg-regexp "^....[^D^]"
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 3488
diff changeset
198 "Regexp specifying the scan lines that are 'good' messages.")
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
200 (defvar mh-deleted-msg-regexp "^....D"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
201 "Regexp matching scan lines of deleted messages.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
202
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
203 (defvar mh-refiled-msg-regexp "^....\\^"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
204 "Regexp matching scan lines of refiled messages.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
205
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
206 (defvar mh-valid-scan-line "^ *[0-9]"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207 "Regexp matching scan lines for messages (not error messages).")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
208
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
209 (defvar mh-msg-number-regexp "^ *\\([0-9]+\\)"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
210 "Regexp to find the number of a message in a scan line.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
211 The message's number must be surrounded with \\( \\)")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
212
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213 (defvar mh-msg-search-regexp "^[^0-9]*%d[^0-9]"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
214 "Format string containing a regexp matching the scan listing for a message.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215 The desired message's number will be an argument to format.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 (defvar mh-flagged-scan-msg-regexp "^....\\D\\|^....\\^\\|^....\\+\\|^.....%"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218 "Regexp matching flagged scan lines.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
219 Matches lines marked as deleted, refiled, in a sequence, or the cur message.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
221 (defvar mh-cur-scan-msg-regexp "^....\\+"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
222 "Regexp matching scan line for the cur message.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224 (defvar mh-show-buffer-mode-line-buffer-id "{%%b} %s/%d"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
225 "Format string to produce `mode-line-buffer-id' for show buffers.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
226 First argument is folder name. Second is message number.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
227
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228 (defvar mh-partial-folder-mode-line-annotation "select"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229 "Annotation when displaying part of a folder.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230 The string is displayed after the folder's name. NIL for no annotation.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
231
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
232
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
233 ;;; Real constants:
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
234
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
235 (defvar mh-invisible-headers
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
236 "^Received: \\|^Message-Id: \\|^Remailed-\\|^Via: \\|^Mail-from: \\|^Return-Path: \\|^In-Reply-To: \\|^Resent-"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
237 "Regexp matching lines in a message header that are not to be shown.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
238 If `mh-visible-headers' is non-nil, it is used instead to specify what
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
239 to keep.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
240
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
241 (defvar mh-rejected-letter-start
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
242 (concat "^ ----- Unsent message follows -----$" ;from mail system
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
243 "\\|^------- Unsent Draft$" ;from MH itself
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
244 "\\|^ --- The unsent message follows ---$") ;from AIX mail system
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
245 "Regexp specifying the beginning of the wrapper around a returned letter.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
246 This wrapper is generated by the mail system when rejecting a letter.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
247
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
248 (defvar mh-to-field-choices '((?t . "To:") (?s . "Subject:") (?c . "Cc:")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
249 (?b . "Bcc:") (?f . "Fcc:"))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
250 "A-list of (character . field name) strings for mh-to-field.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
251
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
252
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
253 ;;; Global variables:
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
254
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
255 (defvar mh-user-path ""
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
256 "User's mail folder.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
257
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
258 (defvar mh-last-destination nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
259 "Destination of last refile or write command.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
260
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
261 (defvar mh-folder-mode-map (make-keymap)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
262 "Keymap for MH folders.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
263
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
264 (defvar mh-letter-mode-map (copy-keymap text-mode-map)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
265 "Keymap for composing mail.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
266
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
267 (defvar mh-pick-mode-map (make-sparse-keymap)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
268 "Keymap for searching folder.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
269
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
270 (defvar mh-searching-folder nil
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
271 "Folder this pick is searching.")
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
272
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
273 (defvar mh-letter-mode-syntax-table nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
274 "Syntax table used while in mh-e letter mode.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
275
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
276 (if mh-letter-mode-syntax-table
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
277 ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
278 (setq mh-letter-mode-syntax-table
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
279 (make-syntax-table text-mode-syntax-table))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
280 (set-syntax-table mh-letter-mode-syntax-table)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
281 (modify-syntax-entry ?% "." mh-letter-mode-syntax-table))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
282
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
283 (defvar mh-folder-list nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
284 "List of folder names for completion.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
285
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
286 (defvar mh-draft-folder nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
287 "Name of folder containing draft messages.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
288 NIL means do not use draft folder.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
289
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
290 (defvar mh-unseen-seq nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
291 "Name of the unseen sequence.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
292
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
293 (defvar mh-previous-window-config nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
294 "Window configuration before mh-e command.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
295
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
296 (defvar mh-previous-seq nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
297 "Name of the sequence to which a message was last added.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
298
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
299
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
300 ;;; Macros and generic functions:
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
301
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
302 (defmacro mh-push (v l)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
303 (list 'setq l (list 'cons v l)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
304
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
305
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
306 (defmacro mh-when (pred &rest body)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
307 (list 'cond (cons pred body)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
308
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
309
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
310 (defmacro with-mh-folder-updating (save-modification-flag-p &rest body)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
311 ;; Format is (with-mh-folder-updating (SAVE-MODIFICATION-FLAG-P) &body BODY).
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
312 ;; Execute BODY, which can modify the folder buffer without having to
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
313 ;; worry about file locking or the read-only flag, and return its result.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
314 ;; If SAVE-MODIFICATION-FLAG-P is non-nil, the buffer's modification
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
315 ;; flag is unchanged, otherwise it is cleared.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
316 (setq save-modification-flag-p (car save-modification-flag-p)) ; CL style
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
317 (` (let ((folder-updating-mod-flag (buffer-modified-p)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
318 (prog1
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
319 (let ((buffer-read-only nil)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
320 (buffer-file-name nil)) ; don't let the buffer get locked
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
321 (,@ body))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
322 (, (if save-modification-flag-p
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
323 '(mh-set-folder-modified-p folder-updating-mod-flag)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
324 '(mh-set-folder-modified-p nil)))))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
325
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
326
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
327 (defun mh-mapc (func list)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
328 (while list
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
329 (funcall func (car list))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
330 (setq list (cdr list))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
331
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
332
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
333
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
334 ;;; Entry points:
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
335
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
336 ;;;###autoload
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
337 (defun mh-rmail (&optional arg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
338 "Inc(orporate) new mail (no arg) or scan a MH mail box (arg given).
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
339 This front end uses the MH mail system, which uses different conventions
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
340 from the usual mail system."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
341 (interactive "P")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
342 (mh-find-path)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
343 (if arg
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
344 (call-interactively 'mh-visit-folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
345 (mh-inc-folder)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
346
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
347
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
348 ;;;###autoload
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
349 (defun mh-smail ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
350 "Compose and send mail with the MH mail system."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
351 (interactive)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
352 (mh-find-path)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
353 (call-interactively 'mh-send))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
354
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
355
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
356 (defun mh-smail-other-window ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
357 "Compose and send mail in other window with the MH mail system."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
358 (interactive)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
359 (mh-find-path)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
360 (call-interactively 'mh-send-other-window))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
361
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
362
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
363
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
364 ;;; User executable mh-e commands:
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
365
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
366 (defun mh-burst-digest ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
367 "Burst apart the current message, which should be a digest.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
368 The message is replaced by its table of contents and the letters from the
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
369 digest are inserted into the folder after that message."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
370 (interactive)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
371 (let ((digest (mh-get-msg-num t)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
372 (mh-process-or-undo-commands mh-current-folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
373 (mh-set-folder-modified-p t) ; lock folder while bursting
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
374 (message "Bursting digest...")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
375 (mh-exec-cmd "burst" mh-current-folder digest "-inplace")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
376 (mh-scan-folder mh-current-folder (format "%d-last" mh-first-msg-num))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
377 (message "Bursting digest...done")))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
378
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
379
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
380 (defun mh-copy-msg (prefix-provided msg-or-seq dest)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
381 "Copy specified MESSAGE(s) to another FOLDER without deleting them.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
382 Default is the displayed message. If optional prefix argument is
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
383 provided, then prompt for the message sequence."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
384 (interactive (list current-prefix-arg
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
385 (if current-prefix-arg
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
386 (mh-read-seq-default "Copy" t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
387 (mh-get-msg-num t))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
388 (mh-prompt-for-folder "Copy to" "" t)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
389 (mh-exec-cmd "refile" msg-or-seq "-link" "-src" mh-current-folder dest)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
390 (if prefix-provided
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
391 (mh-notate-seq msg-or-seq ?C mh-cmd-note)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
392 (mh-notate msg-or-seq ?C mh-cmd-note)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
393
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
394
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
395 (defun mh-delete-msg (msg-or-seq)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
396 "Mark the specified MESSAGE(s) for subsequent deletion and move to the next.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
397 Default is the displayed message. If optional prefix argument is
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
398 given then prompt for the message sequence."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
399 (interactive (list (if current-prefix-arg
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
400 (mh-read-seq-default "Delete" t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
401 (mh-get-msg-num t))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
402 (if (numberp msg-or-seq)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
403 (mh-delete-a-msg msg-or-seq)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
404 (mh-map-to-seq-msgs 'mh-delete-a-msg msg-or-seq))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
405 (mh-next-msg))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
406
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
407
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
408 (defun mh-delete-msg-no-motion (msg-or-seq)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
409 "Mark the specified MESSAGE(s) for subsequent deletion.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
410 Default is the displayed message. If optional prefix argument is
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
411 provided, then prompt for the message sequence."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
412 (interactive (list (if current-prefix-arg
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
413 (mh-read-seq-default "Delete" t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
414 (mh-get-msg-num t))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
415 (if (numberp msg-or-seq)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
416 (mh-delete-a-msg msg-or-seq)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
417 (mh-map-to-seq-msgs 'mh-delete-a-msg msg-or-seq)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
418
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
419
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
420 (defun mh-delete-msg-from-seq (prefix-provided msg-or-seq &optional from-seq)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
421 "Delete MESSAGE (default: displayed message) from SEQUENCE.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
422 If optional prefix argument provided, then delete all messages
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
423 from a sequence."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
424 (interactive (let ((argp current-prefix-arg))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
425 (list argp
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
426 (if argp
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
427 (mh-read-seq-default "Delete" t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
428 (mh-get-msg-num t))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
429 (if (not argp)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
430 (mh-read-seq-default "Delete from" t)))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
431 (if prefix-provided
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
432 (mh-remove-seq msg-or-seq)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
433 (mh-remove-msg-from-seq msg-or-seq from-seq)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
434
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
435
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
436 (defun mh-edit-again (msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
437 "Clean-up a draft or a message previously sent and make it resendable."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
438 (interactive (list (mh-get-msg-num t)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
439 (let* ((from-folder mh-current-folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
440 (config (current-window-configuration))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
441 (draft
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
442 (cond ((and mh-draft-folder (equal from-folder mh-draft-folder))
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
443 (pop-to-buffer (find-file-noselect (mh-msg-filename msg)) t)
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
444 (rename-buffer (format "draft-%d" msg))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
445 (buffer-name))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
446 (t
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
447 (mh-read-draft "clean-up" (mh-msg-filename msg) nil)))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
448 (mh-clean-msg-header (point-min)
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
449 "^Date:\\|^Received:\\|^Message-Id:\\|^From:\\|^Delivery-Date:"
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
450 nil)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
451 (goto-char (point-min))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
452 (set-buffer-modified-p nil)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
453 (mh-compose-and-send-mail draft "" from-folder nil nil nil nil nil nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
454 config)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
455
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
456
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
457 (defun mh-execute-commands ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
458 "Process outstanding delete and refile requests."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
459 (interactive)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
460 (if mh-narrowed-to-seq (mh-widen))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
461 (mh-process-commands mh-current-folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
462 (mh-set-scan-mode)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
463 (mh-goto-cur-msg) ; after mh-set-scan-mode for efficiency
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
464 (mh-make-folder-mode-line)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
465 t) ; return t for write-file-hooks
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
466
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
467
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
468 (defun mh-extract-rejected-mail (msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
469 "Extract a letter returned by the mail system and make it resendable.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
470 Default is the displayed message."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
471 (interactive (list (mh-get-msg-num t)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
472 (let ((from-folder mh-current-folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
473 (config (current-window-configuration))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
474 (draft (mh-read-draft "extraction" (mh-msg-filename msg) nil)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
475 (goto-char (point-min))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
476 (cond ((re-search-forward mh-rejected-letter-start nil t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
477 (forward-char 1)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
478 (delete-region (point-min) (point))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
479 (mh-clean-msg-header (point-min)
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
480 "^Date:\\|^Received:\\|^Message-Id:\\|^From:\\|^Sender:\\|^Return-Path:"
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
481 nil))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
482 (t
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
483 (message "Does not appear to be a rejected letter.")))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
484 (goto-char (point-min))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
485 (set-buffer-modified-p nil)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
486 (mh-compose-and-send-mail draft "" from-folder msg (mh-get-field "To")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
487 (mh-get-field "From") (mh-get-field "cc")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
488 nil nil config)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
489
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
490
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
491 (defun mh-first-msg ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
492 "Move to the first message."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
493 (interactive)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
494 (goto-char (point-min)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
495
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
496
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
497 (defun mh-forward (prefix-provided msg-or-seq to cc)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
498 "Forward MESSAGE(s) (default: displayed message).
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
499 If optional prefix argument provided, then prompt for the message sequence."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
500 (interactive (list current-prefix-arg
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
501 (if current-prefix-arg
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
502 (mh-read-seq-default "Forward" t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
503 (mh-get-msg-num t))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
504 (read-string "To: ")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
505 (read-string "Cc: ")))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
506 (let* ((folder mh-current-folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
507 (config (current-window-configuration))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
508 ;; forw always leaves file in "draft" since it doesn't have -draft
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
509 (draft-name (expand-file-name "draft" mh-user-path))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
510 (draft (cond ((or (not (file-exists-p draft-name))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
511 (y-or-n-p "The file 'draft' exists. Discard it? "))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
512 (mh-exec-cmd "forw"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
513 "-build" mh-current-folder msg-or-seq)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
514 (prog1
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
515 (mh-read-draft "" draft-name t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
516 (mh-insert-fields "To:" to "Cc:" cc)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
517 (set-buffer-modified-p nil)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
518 (t
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
519 (mh-read-draft "" draft-name nil)))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
520 (goto-char (point-min))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
521 (re-search-forward "^------- Forwarded Message")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
522 (forward-line -1)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
523 (narrow-to-region (point) (point-max))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
524 (let* ((subject (save-excursion (mh-get-field "From:")))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
525 (trim (string-match "<" subject))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
526 (forw-subject (save-excursion (mh-get-field "Subject:"))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
527 (if trim
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
528 (setq subject (substring subject 0 (1- trim))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
529 (widen)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
530 (save-excursion
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
531 (mh-insert-fields "Subject:" (format "[%s: %s]" subject forw-subject)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
532 (delete-other-windows)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
533 (if prefix-provided
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
534 (mh-add-msgs-to-seq (mh-seq-to-msgs msg-or-seq) 'forwarded t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
535 (mh-add-msgs-to-seq msg-or-seq 'forwarded t))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
536 (mh-compose-and-send-mail draft "" folder msg-or-seq
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
537 to subject cc
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
538 mh-note-forw "Forwarded:"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
539 config))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
540
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
541
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
542 (defun mh-goto-msg (number &optional no-error-if-no-message dont-show)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
543 "Position the cursor at message NUMBER.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
544 Non-nil second argument means do not signal an error if message does not exist.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
545 Non-nil third argument means not to show the message.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
546 Return non-nil if cursor is at message."
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
547 (interactive "NGoto message: ")
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
548 (let ((cur-msg (mh-get-msg-num nil))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
549 (starting-place (point))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
550 (msg-pattern (mh-msg-search-pat number)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
551 (cond ((cond ((and cur-msg (= cur-msg number)) t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
552 ((and cur-msg
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
553 (< cur-msg number)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
554 (re-search-forward msg-pattern nil t)) t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
555 ((and cur-msg
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
556 (> cur-msg number)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
557 (re-search-backward msg-pattern nil t)) t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
558 (t ; Do thorough search of buffer
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
559 (goto-char (point-max))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
560 (re-search-backward msg-pattern nil t)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
561 (beginning-of-line)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
562 (if (not dont-show) (mh-maybe-show number))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
563 t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
564 (t
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
565 (goto-char starting-place)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
566 (if (not no-error-if-no-message)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
567 (error "No message %d" number))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
568 nil))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
569
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
570
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
571 (defun mh-inc-folder (&optional maildrop-name)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
572 "Inc(orporate) new mail into +inbox.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
573 Optional prefix argument specifies an alternate maildrop from the default.
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
574 If this is given, incorporate mail into the current folder, rather
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
575 than +inbox. Run `mh-inc-folder-hook' after incorporating new mail."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
576 (interactive (list (if current-prefix-arg
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
577 (expand-file-name
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
578 (read-file-name "inc mail from file: "
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
579 mh-user-path)))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
580 (let ((config (current-window-configuration)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
581 (if (not maildrop-name)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
582 (cond ((not (get-buffer "+inbox"))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
583 (mh-make-folder "+inbox")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
584 (setq mh-previous-window-config config))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
585 ((not (eq (current-buffer) (get-buffer "+inbox")))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
586 (switch-to-buffer "+inbox")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
587 (setq mh-previous-window-config config)))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
588 (mh-get-new-mail maildrop-name)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
589 (run-hooks 'mh-inc-folder-hook))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
590
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
591
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
592 (defun mh-kill-folder ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
593 "Remove the current folder."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
594 (interactive)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
595 (if (or mh-do-not-confirm
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
596 (yes-or-no-p (format "Remove folder %s? " mh-current-folder)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
597 (let ((folder mh-current-folder))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
598 (mh-set-folder-modified-p t) ; lock folder to kill it
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
599 (mh-exec-cmd-daemon "rmf" folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
600 (mh-remove-folder-from-folder-list folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
601 (message "Folder %s removed" folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
602 (mh-set-folder-modified-p nil) ; so kill-buffer doesn't complain
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
603 (if (get-buffer mh-show-buffer)
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
604 (kill-buffer mh-show-buffer))
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
605 (kill-buffer folder))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
606 (message "Folder not removed")))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
607
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
608
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
609 (defun mh-last-msg ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
610 "Move to the last message."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
611 (interactive)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
612 (goto-char (point-max))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
613 (while (and (not (bobp)) (looking-at "^$"))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
614 (forward-line -1)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
615
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
616
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
617 (defun mh-list-folders ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
618 "List mail folders."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
619 (interactive)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
620 (with-output-to-temp-buffer " *mh-temp*"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
621 (save-excursion
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
622 (switch-to-buffer " *mh-temp*")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
623 (erase-buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
624 (message "Listing folders...")
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
625 (mh-exec-cmd-output "folders" t (if mh-recursive-folders
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
626 "-recurse"
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
627 "-norecurse"))
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
628 (goto-char (point-min))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
629 (message "Listing folders...done"))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
630
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
631
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
632 (defun mh-msg-is-in-seq (msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
633 "Display the sequences that contain MESSAGE (default: displayed message)."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
634 (interactive (list (mh-get-msg-num t)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
635 (message "Message %d is in sequences: %s"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
636 msg
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
637 (mapconcat 'concat
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
638 (mh-list-to-string (mh-seq-containing-msg msg))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
639 " ")))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
640
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
641
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
642 (defun mh-narrow-to-seq (seq)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
643 "Restrict display of this folder to just messages in a sequence.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
644 Reads which sequence. Use \\[mh-widen] to undo this command."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
645 (interactive (list (mh-read-seq "Narrow to" t)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
646 (let ((eob (point-max)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
647 (with-mh-folder-updating (t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
648 (cond ((mh-seq-to-msgs seq)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
649 (mh-copy-seq-to-point seq eob)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
650 (narrow-to-region eob (point-max))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
651 (mh-make-folder-mode-line (symbol-name seq))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
652 (mh-recenter nil)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
653 (setq mh-narrowed-to-seq seq))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
654 (t
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
655 (error "No messages in sequence `%s'" (symbol-name seq)))))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
656
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
657
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
658 (defun mh-next-undeleted-msg (&optional arg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
659 "Move to next undeleted message in window."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
660 (interactive "P")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
661 (forward-line (prefix-numeric-value arg))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
662 (setq mh-next-direction 'forward)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
663 (cond ((re-search-forward mh-good-msg-regexp nil 0 arg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
664 (beginning-of-line)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
665 (mh-maybe-show))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
666 (t
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
667 (forward-line -1)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
668 (if (get-buffer mh-show-buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
669 (delete-windows-on mh-show-buffer)))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
670
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
671
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
672 (defun mh-pack-folder (range)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
673 "Renumber the messages of a folder to be 1..n.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
674 First, offer to execute any outstanding commands for the current folder.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
675 If optional prefix argument provided, prompt for the range of messages
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
676 to display after packing. Otherwise, show the entire folder."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
677 (interactive (list (if current-prefix-arg
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
678 (mh-read-msg-range
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
679 "Range to scan after packing [all]? ")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
680 "all")))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
681 (mh-pack-folder-1 range)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
682 (mh-goto-cur-msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
683 (message "Packing folder...done"))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
684
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
685
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
686 (defun mh-pipe-msg (prefix-provided command)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
687 "Pipe the current message through the given shell COMMAND.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
688 If optional prefix argument is provided, send the entire message.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
689 Otherwise just send the message's body."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
690 (interactive
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
691 (list current-prefix-arg (read-string "Shell command on message: ")))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
692 (save-excursion
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
693 (mh-display-msg (mh-get-msg-num t) mh-current-folder) ;update show buffer
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
694 (goto-char (point-min))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
695 (if (not prefix-provided) (search-forward "\n\n"))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
696 (shell-command-on-region (point) (point-max) command nil)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
697
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
698
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
699 (defun mh-refile-msg (prefix-provided msg-or-seq dest)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
700 "Refile MESSAGE(s) (default: displayed message) in FOLDER.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
701 If optional prefix argument provided, then prompt for message sequence."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
702 (interactive
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
703 (list current-prefix-arg
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
704 (if current-prefix-arg
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
705 (mh-read-seq-default "Refile" t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
706 (mh-get-msg-num t))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
707 (intern
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
708 (mh-prompt-for-folder "Destination"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
709 (if (eq 'refile (car mh-last-destination))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
710 (symbol-name (cdr mh-last-destination))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
711 "")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
712 t))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
713 (setq mh-last-destination (cons 'refile dest))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
714 (if prefix-provided
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
715 (mh-map-to-seq-msgs 'mh-refile-a-msg msg-or-seq dest)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
716 (mh-refile-a-msg msg-or-seq dest))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
717 (mh-next-msg))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
718
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
719
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
720 (defun mh-refile-or-write-again (msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
721 "Re-execute the last refile or write command on the given MESSAGE.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
722 Default is the displayed message. Use the same folder or file as the
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
723 previous refile or write command."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
724 (interactive (list (mh-get-msg-num t)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
725 (if (null mh-last-destination)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
726 (error "No previous refile or write"))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
727 (cond ((eq (car mh-last-destination) 'refile)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
728 (mh-refile-a-msg msg (cdr mh-last-destination))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
729 (message "Destination folder: %s" (cdr mh-last-destination)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
730 (t
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
731 (mh-write-msg-to-file msg (cdr mh-last-destination))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
732 (message "Destination: %s" (cdr mh-last-destination))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
733 (mh-next-msg))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
734
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
735
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
736 (defun mh-reply (prefix-provided msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
737 "Reply to a MESSAGE (default: displayed message).
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
738 If optional prefix argument provided, then include the message in the reply
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
739 using filter mhl.reply in your MH directory."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
740 (interactive (list current-prefix-arg (mh-get-msg-num t)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
741 (let ((minibuffer-help-form
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
742 "from => Sender only\nto => Sender and primary recipients\ncc or all => Sender and all recipients"))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
743 (let ((reply-to (or mh-reply-default-reply-to
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
744 (completing-read "Reply to whom: "
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
745 '(("from") ("to") ("cc") ("all"))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
746 nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
747 t)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
748 (folder mh-current-folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
749 (show-buffer mh-show-buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
750 (config (current-window-configuration)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
751 (message "Composing a reply...")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
752 (cond ((or (equal reply-to "from") (equal reply-to ""))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
753 (apply 'mh-exec-cmd
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
754 "repl" "-build" "-noquery"
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
755 "-nodraftfolder" mh-current-folder
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
756 msg
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
757 "-nocc" "all"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
758 (if prefix-provided
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
759 (list "-filter" "mhl.reply"))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
760 ((equal reply-to "to")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
761 (apply 'mh-exec-cmd
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
762 "repl" "-build" "-noquery"
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
763 "-nodraftfolder" mh-current-folder
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
764 msg
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
765 "-cc" "to"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
766 (if prefix-provided
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
767 (list "-filter" "mhl.reply"))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
768 ((or (equal reply-to "cc") (equal reply-to "all"))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
769 (apply 'mh-exec-cmd
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
770 "repl" "-build" "-noquery"
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
771 "-nodraftfolder" mh-current-folder
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
772 msg
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
773 "-cc" "all" "-nocc" "me"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
774 (if prefix-provided
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
775 (list "-filter" "mhl.reply")))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
776
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
777 (let ((draft (mh-read-draft "reply"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
778 (expand-file-name "reply" mh-user-path)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
779 t)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
780 (delete-other-windows)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
781 (set-buffer-modified-p nil)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
782
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
783 (let ((to (mh-get-field "To:"))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
784 (subject (mh-get-field "Subject:"))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
785 (cc (mh-get-field "Cc:")))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
786 (goto-char (point-min))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
787 (mh-goto-header-end 1)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
788 (if (not prefix-provided)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
789 (mh-display-msg msg folder))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
790 (mh-add-msgs-to-seq msg 'answered t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
791 (message "Composing a reply...done")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
792 (mh-compose-and-send-mail draft "" folder msg to subject cc
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
793 mh-note-repl "Replied:" config))))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
794
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
795
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
796 (defun mh-quit ()
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
797 "Quit mh-e.
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
798 Start by running mh-before-quit-hook. Restore the previous window
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
799 configuration, if one exists. Finish by running mh-quit-hook."
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
800 (interactive)
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
801 (run-hooks 'mh-before-quit-hook)
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
802 (if mh-previous-window-config
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
803 (set-window-configuration mh-previous-window-config))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
804 (run-hooks 'mh-quit-hook))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
805
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
806
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
807 (defun mh-page-digest ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
808 "Advance displayed message to next digested message."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
809 (interactive)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
810 (save-excursion
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
811 (mh-show-message-in-other-window)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
812 ;; Go to top of screen (in case user moved point).
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
813 (move-to-window-line 0)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
814 (let ((case-fold-search nil))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
815 ;; Search for blank line and then for From:
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
816 (mh-when (not (and (search-forward "\n\n" nil t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
817 (search-forward "From:" nil t)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
818 (other-window -1)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
819 (error "No more messages")))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
820 ;; Go back to previous blank line, then forward to the first non-blank.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
821 (search-backward "\n\n" nil t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
822 (forward-line 2)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
823 (mh-recenter 0)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
824 (other-window -1)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
825
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
826
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
827 (defun mh-page-digest-backwards ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
828 "Back up displayed message to previous digested message."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
829 (interactive)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
830 (save-excursion
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
831 (mh-show-message-in-other-window)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
832 ;; Go to top of screen (in case user moved point).
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
833 (move-to-window-line 0)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
834 (let ((case-fold-search nil))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
835 (beginning-of-line)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
836 (mh-when (not (and (search-backward "\n\n" nil t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
837 (search-backward "From:" nil t)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
838 (other-window -1)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
839 (error "No more messages")))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
840 ;; Go back to previous blank line, then forward to the first non-blank.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
841 (search-backward "\n\n" nil t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
842 (forward-line 2)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
843 (mh-recenter 0)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
844 (other-window -1)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
845
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
846
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
847 (defun mh-page-msg (&optional arg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
848 "Page the displayed message forwards.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
849 Scrolls ARG lines or a full screen if no argument is supplied."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
850 (interactive "P")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
851 (scroll-other-window arg))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
852
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
853
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
854 (defun mh-previous-page (&optional arg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
855 "Page the displayed message backwards.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
856 Scrolls ARG lines or a full screen if no argument is supplied."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
857 (interactive "P")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
858 (save-excursion
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
859 (mh-show-message-in-other-window)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
860 (unwind-protect
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
861 (scroll-down arg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
862 (other-window -1))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
863
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
864
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
865 (defun mh-previous-undeleted-msg (&optional arg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
866 "Move to previous undeleted message in window."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
867 (interactive "p")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
868 (setq mh-next-direction 'backward)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
869 (beginning-of-line)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
870 (cond ((re-search-backward mh-good-msg-regexp nil 0 arg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
871 (mh-maybe-show))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
872 (t
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
873 (if (get-buffer mh-show-buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
874 (delete-windows-on mh-show-buffer)))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
875
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
876
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
877 (defun mh-print-msg (prefix-provided msg-or-seq)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
878 "Print MESSAGE(s) (default: displayed message) on a line printer.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
879 If optional prefix argument provided, then prompt for the message sequence."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
880 (interactive (list current-prefix-arg
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
881 (if current-prefix-arg
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
882 (reverse (mh-seq-to-msgs
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
883 (mh-read-seq-default "Print" t)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
884 (mh-get-msg-num t))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
885 (if prefix-provided
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
886 (message "Printing sequence...")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
887 (message "Printing message..."))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
888 (let ((print-command
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
889 (if prefix-provided
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
890 (format "(scan -clear %s ; %s -nobell -clear %s %s) | %s"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
891 (mapconcat (function (lambda (msg) msg)) msg-or-seq " ")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
892 (expand-file-name "mhl" mh-lib)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
893 (if (stringp mhl-formfile)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
894 (format "-form %s" mhl-formfile)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
895 "")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
896 (mh-msg-filenames msg-or-seq)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
897 (format mh-lpr-command-format
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
898 (if prefix-provided
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
899 (format "Sequence from %s" mh-current-folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
900 (format "%s/%d" mh-current-folder
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
901 msg-or-seq))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
902 (format "%s -nobell -clear %s %s | %s"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
903 (expand-file-name "mhl" mh-lib)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
904 (mh-msg-filename msg-or-seq)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
905 (if (stringp mhl-formfile)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
906 (format "-form %s" mhl-formfile)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
907 "")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
908 (format mh-lpr-command-format
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
909 (if prefix-provided
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
910 (format "Sequence from %s" mh-current-folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
911 (format "%s/%d" mh-current-folder
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
912 msg-or-seq)))))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
913 (if mh-print-background
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
914 (mh-exec-cmd-daemon shell-file-name "-c" print-command)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
915 (call-process shell-file-name nil nil nil "-c" print-command))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
916 (if prefix-provided
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
917 (mh-notate-seq msg-or-seq ?P mh-cmd-note)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
918 (mh-notate msg-or-seq ?P mh-cmd-note))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
919 (mh-add-msgs-to-seq msg-or-seq 'printed t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
920 (if prefix-provided
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
921 (message "Printing sequence...done")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
922 (message "Printing message...done"))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
923
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
924
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
925 (defun mh-put-msg-in-seq (prefix-provided from to)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
926 "Add MESSAGE(s) (default: displayed message) to SEQUENCE.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
927 If optional prefix argument provided, then prompt for the message sequence."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
928 (interactive (list current-prefix-arg
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
929 (if current-prefix-arg
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
930 (mh-seq-to-msgs
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
931 (mh-read-seq-default "Add messages from" t))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
932 (mh-get-msg-num t))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
933 (mh-read-seq-default "Add to" nil)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
934 (setq mh-previous-seq to)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
935 (mh-add-msgs-to-seq from to))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
936
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
937
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
938 (defun mh-rescan-folder (&optional range)
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
939 "Rescan a folder after optionally processing the outstanding commands.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
940 If optional prefix argument is provided, prompt for the range of
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
941 messages to display. Otherwise show the entire folder."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
942 (interactive (list (if current-prefix-arg
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
943 (mh-read-msg-range "Range to scan [all]? ")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
944 nil)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
945 (setq mh-next-direction 'forward)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
946 (mh-scan-folder mh-current-folder (or range "all")))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
947
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
948
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
949 (defun mh-redistribute (to cc msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
950 "Redistribute a letter.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
951 Depending on how your copy of MH was compiled, you may need to change the
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
952 setting of the variable mh-redist-full-contents. See its documentation."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
953 (interactive (list (read-string "Redist-To: ")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
954 (read-string "Redist-Cc: ")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
955 (mh-get-msg-num t)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
956 (save-window-excursion
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
957 (let ((folder mh-current-folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
958 (draft (mh-read-draft "redistribution"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
959 (if mh-redist-full-contents
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
960 (mh-msg-filename msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
961 nil)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
962 nil)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
963 (mh-goto-header-end 0)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
964 (insert "Resent-To: " to "\n")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
965 (if (not (equal cc "")) (insert "Resent-cc: " cc "\n"))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
966 (mh-clean-msg-header (point-min)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
967 "^Message-Id:\\|^Received:\\|^Return-Path:\\|^Sender:\\|^Date:\\|^From:"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
968 nil)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
969 (save-buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
970 (message "Redistributing...")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
971 (if mh-redist-full-contents
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
972 (call-process "/bin/sh" nil 0 nil "-c"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
973 (format "mhdist=1 mhaltmsg=%s %s -push %s"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
974 (buffer-file-name)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
975 (expand-file-name "send" mh-progs)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
976 (buffer-file-name)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
977 (call-process "/bin/sh" nil 0 nil "-c"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
978 (format "mhdist=1 mhaltmsg=%s mhannotate=1 %s -push %s"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
979 (mh-msg-filename msg folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
980 (expand-file-name "send" mh-progs)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
981 (buffer-file-name))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
982 (mh-annotate-msg msg folder mh-note-dist
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
983 "-component" "Resent:"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
984 "-text" (format "\"%s %s\"" to cc))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
985 (kill-buffer draft)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
986 (message "Redistributing...done"))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
987
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
988
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
989 (defun mh-write-msg-to-file (msg file)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
990 "Append MESSAGE to the end of a FILE."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
991 (interactive
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
992 (list (mh-get-msg-num t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
993 (let ((default-dir (if (eq 'write (car mh-last-destination))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
994 (file-name-directory (cdr mh-last-destination))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
995 default-directory)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
996 (read-file-name "Save message in file: " default-dir
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
997 (expand-file-name "mail.out" default-dir)))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
998 (let ((file-name (mh-msg-filename msg))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
999 (output-file (mh-expand-file-name file)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1000 (setq mh-last-destination (cons 'write file))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1001 (save-excursion
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1002 (set-buffer (get-buffer-create " *mh-temp*"))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1003 (erase-buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1004 (insert-file-contents file-name)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1005 (append-to-file (point-min) (point-max) output-file))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1006
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1007
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1008 (defun mh-search-folder (folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1009 "Search FOLDER for messages matching a pattern."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1010 (interactive (list (mh-prompt-for-folder "Search"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1011 mh-current-folder
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1012 t)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1013 (switch-to-buffer-other-window "pick-pattern")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1014 (if (or (zerop (buffer-size))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1015 (not (y-or-n-p "Reuse pattern? ")))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1016 (mh-make-pick-template)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1017 (message ""))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1018 (setq mh-searching-folder folder))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1019
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1020
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1021 (defun mh-send (to cc subject)
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1022 "Compose and send a letter.
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1023 The letter is composed in mh-letter-mode; see its documentation for more
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1024 details. If `mh-compose-letter-function' is defined, it is called on the
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1025 draft and passed three arguments: to, subject, and cc."
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1026 (interactive "sTo: \nsCc: \nsSubject: ")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1027 (let ((config (current-window-configuration)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1028 (delete-other-windows)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1029 (mh-send-sub to cc subject config)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1030
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1031
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1032 (defun mh-send-other-window (to cc subject)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1033 "Compose and send a letter in another window.."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1034 (interactive "sTo: \nsCc: \nsSubject: ")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1035 (let ((pop-up-windows t))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1036 (mh-send-sub to cc subject (current-window-configuration))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1037
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1038
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1039 (defun mh-send-sub (to cc subject config)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1040 "Do the real work of composing and sending a letter.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1041 Expects the TO, CC, and SUBJECT fields as arguments.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1042 CONFIG is the window configuration before sending mail."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1043 (let ((folder mh-current-folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1044 (msg-num (mh-get-msg-num nil)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1045 (message "Composing a message...")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1046 (let ((draft (mh-read-draft
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1047 "message"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1048 (if (file-exists-p
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1049 (expand-file-name "components" mh-user-path))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1050 (expand-file-name "components" mh-user-path)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1051 (if (file-exists-p
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1052 (expand-file-name "components" mh-lib))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1053 (expand-file-name "components" mh-lib)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1054 (error "Can't find components file")))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1055 nil)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1056 (mh-insert-fields "To:" to "Subject:" subject "Cc:" cc)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1057 (set-buffer-modified-p nil)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1058 (goto-char (point-max))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1059 (message "Composing a message...done")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1060 (mh-compose-and-send-mail draft "" folder msg-num
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1061 to subject cc
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1062 nil nil config))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1063
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1064
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1065 (defun mh-show (&optional msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1066 "Show MESSAGE (default: displayed message).
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1067 Forces a two-window display with the folder window on top (size
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1068 mh-summary-height) and the show buffer below it."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1069 (interactive)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1070 (if (not msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1071 (setq msg (mh-get-msg-num t)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1072 (setq mh-showing t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1073 (mh-set-mode-name "mh-e show")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1074 (if (not (eql (next-window (minibuffer-window)) (selected-window)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1075 (delete-other-windows)) ; force ourself to the top window
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1076 (let ((folder mh-current-folder))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1077 (mh-show-message-in-other-window)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1078 (mh-display-msg msg folder))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1079 (other-window -1)
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1080 (if (not (= (1+ (window-height)) (screen-height))) ;not horizontally split
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1081 (shrink-window (- (window-height) mh-summary-height)))
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1082 (mh-recenter nil)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1083 (if (not (memq msg mh-seen-list)) (mh-push msg mh-seen-list)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1084
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1085
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1086 (defun mh-sort-folder ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1087 "Sort the messages in the current folder by date."
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1088 (interactive)
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1089 (mh-process-or-undo-commands mh-current-folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1090 (setq mh-next-direction 'forward)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1091 (mh-set-folder-modified-p t) ; lock folder while sorting
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1092 (message "Sorting folder...")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1093 (mh-exec-cmd "sortm" mh-current-folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1094 (message "Sorting folder...done")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1095 (mh-scan-folder mh-current-folder "all"))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1096
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1097
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1098 (defun mh-toggle-showing ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1099 "Toggle the scanning mode/showing mode of displaying messages."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1100 (interactive)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1101 (if mh-showing
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1102 (mh-set-scan-mode)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1103 (mh-show)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1104
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1105
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1106 (defun mh-undo (prefix-provided msg-or-seq)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1107 "Undo the deletion or refile of the specified MESSAGE(s).
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1108 Default is the displayed message. If optional prefix argument is
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1109 provided, then prompt for the message sequence."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1110 (interactive (list current-prefix-arg
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1111 (if current-prefix-arg
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1112 (mh-read-seq-default "Undo" t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1113 (mh-get-msg-num t))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1114 (cond (prefix-provided
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1115 (mh-mapc (function mh-undo-msg) (mh-seq-to-msgs msg-or-seq)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1116 (t
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1117 (let ((original-position (point)))
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1118 (beginning-of-line)
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1119 (while (not (or (looking-at mh-deleted-msg-regexp)
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1120 (looking-at mh-refiled-msg-regexp)
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1121 (and (eq mh-next-direction 'forward) (bobp))
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1122 (and (eq mh-next-direction 'backward)
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1123 (save-excursion (forward-line) (eobp)))))
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1124 (forward-line (if (eq mh-next-direction 'forward) -1 1)))
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1125 (if (or (looking-at mh-deleted-msg-regexp)
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1126 (looking-at mh-refiled-msg-regexp))
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1127 (progn
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1128 (mh-undo-msg (mh-get-msg-num t))
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1129 (mh-maybe-show))
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1130 (goto-char original-position)
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1131 (error "Nothing to undo")))))
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1132 ;; update the mh-refile-list so mh-outstanding-commands-p will work
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1133 (mh-mapc (function
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1134 (lambda (elt)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1135 (if (not (mh-seq-to-msgs elt))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1136 (setq mh-refile-list (delq elt mh-refile-list)))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1137 mh-refile-list)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1138 (if (not (mh-outstanding-commands-p))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1139 (mh-set-folder-modified-p nil)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1140
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1141
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1142 (defun mh-undo-msg (msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1143 ;; Undo the deletion or refile of one MESSAGE.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1144 (cond ((memq msg mh-delete-list)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1145 (setq mh-delete-list (delq msg mh-delete-list))
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1146 (mh-remove-msg-from-seq msg 'deleted t))
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1147 (t
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1148 (mh-mapc (function (lambda (dest)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1149 (mh-remove-msg-from-seq msg dest t)))
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1150 mh-refile-list)))
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1151 (mh-notate msg ? mh-cmd-note))
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1152
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1153
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1154 (defun mh-undo-folder (&rest ignore)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1155 "Undo all commands in current folder."
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1156 (interactive)
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1157 (cond ((or mh-do-not-confirm
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1158 (yes-or-no-p "Undo all commands in folder? "))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1159 (setq mh-delete-list nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1160 mh-refile-list nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1161 mh-seq-list nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1162 mh-next-direction 'forward)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1163 (with-mh-folder-updating (nil)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1164 (mh-unmark-all-headers t)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1165 (t
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1166 (message "Commands not undone.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1167 (sit-for 2))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1168
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1169
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1170 (defun mh-unshar-msg (dir)
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1171 "Unpack the shar file contained in the current message into directory DIR."
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1172 (interactive (list (read-file-name "Unshar message in directory: "
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1173 mh-unshar-default-directory
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1174 mh-unshar-default-directory nil)))
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1175 (mh-display-msg (mh-get-msg-num t) mh-current-folder) ;update show buffer
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1176 (mh-unshar-buffer dir))
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1177
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1178 (defun mh-unshar-buffer (dir)
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1179 ;; Unpack the shar file contained in the current buffer into directory DIR.
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1180 (goto-char (point-min))
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1181 (if (or (re-search-forward "^#![ \t]*/bin/sh" nil t)
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1182 (and (re-search-forward "^[^a-z0-9\"]*cut here\b" nil t)
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1183 (forward-line 1))
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1184 (re-search-forward "^#" nil t)
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1185 (re-search-forward "^: " nil t))
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1186 (let ((default-directory (expand-file-name dir))
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1187 (start (progn (beginning-of-line) (point)))
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1188 (log-buffer (get-buffer-create "*Unshar Output*")))
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1189 (save-excursion
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1190 (set-buffer log-buffer)
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1191 (setq default-directory (expand-file-name dir))
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1192 (erase-buffer)
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1193 (if (file-directory-p default-directory)
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1194 (insert "cd " dir "\n")
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1195 (insert "mkdir " dir "\n")
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1196 (call-process "mkdir" nil log-buffer t default-directory)))
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1197 (set-window-start (display-buffer log-buffer) 0) ;so can watch progress
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1198 (call-process-region start (point-max) "sh" nil log-buffer t))
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1199 (error "Cannot find start of shar.")))
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1200
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1201
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1202 (defun mh-visit-folder (folder &optional range)
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1203 "Visit FOLDER and display RANGE of messages.
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1204 Assumes mh-e has already been initialized."
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1205 (interactive (list (mh-prompt-for-folder "Visit" "+inbox" t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1206 (mh-read-msg-range "Range [all]? ")))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1207 (let ((config (current-window-configuration)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1208 (mh-scan-folder folder (or range "all"))
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1209 (setq mh-previous-window-config config))
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1210 nil)
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1211
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1212
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1213 (defun mh-widen ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1214 "Remove restrictions from the current folder, thereby showing all messages."
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1215 (interactive)
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1216 (if mh-narrowed-to-seq
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1217 (with-mh-folder-updating (t)
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1218 (delete-region (point-min) (point-max))
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1219 (widen)
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1220 (mh-make-folder-mode-line)))
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1221 (setq mh-narrowed-to-seq nil))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1222
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1223
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1224
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1225 ;;; Support routines.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1226
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1227 (defun mh-delete-a-msg (msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1228 ;; Delete the MESSAGE.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1229 (save-excursion
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1230 (mh-goto-msg msg nil t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1231 (if (looking-at mh-refiled-msg-regexp)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1232 (error "Message %d is refiled. Undo refile before deleting." msg))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1233 (if (looking-at mh-deleted-msg-regexp)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1234 nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1235 (mh-set-folder-modified-p t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1236 (mh-push msg mh-delete-list)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1237 (mh-add-msgs-to-seq msg 'deleted t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1238 (mh-notate msg ?D mh-cmd-note))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1239
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1240
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1241 (defun mh-refile-a-msg (msg destination)
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1242 ;; Refile MESSAGE in FOLDER. FOLDER is a symbol, not a string.
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1243 (save-excursion
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1244 (mh-goto-msg msg nil t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1245 (cond ((looking-at mh-deleted-msg-regexp)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1246 (error "Message %d is deleted. Undo delete before moving." msg))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1247 ((looking-at mh-refiled-msg-regexp)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1248 (if (y-or-n-p
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1249 (format "Message %d already refiled. Copy to %s as well? "
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1250 msg destination))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1251 (mh-exec-cmd "refile" (mh-get-msg-num t) "-link"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1252 "-src" mh-current-folder
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1253 (symbol-name destination))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1254 (message "Message not copied.")))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1255 (t
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1256 (mh-set-folder-modified-p t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1257 (if (not (memq destination mh-refile-list))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1258 (mh-push destination mh-refile-list))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1259 (if (not (memq msg (mh-seq-to-msgs destination)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1260 (mh-add-msgs-to-seq msg destination t))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1261 (mh-notate msg ?^ mh-cmd-note)))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1262
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1263
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1264 (defun mh-display-msg (msg-num folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1265 ;; Display message NUMBER of FOLDER.
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1266 ;; Sets the current buffer to the show buffer.
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1267 (set-buffer folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1268 ;; Bind variables in folder buffer in case they are local
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1269 (let ((formfile mhl-formfile)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1270 (clean-message-header mh-clean-message-header)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1271 (invisible-headers mh-invisible-headers)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1272 (visible-headers mh-visible-headers)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1273 (msg-filename (mh-msg-filename msg-num))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1274 (show-buffer mh-show-buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1275 (folder mh-current-folder))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1276 (if (not (file-exists-p msg-filename))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1277 (error "Message %d does not exist" msg-num))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1278 (switch-to-buffer show-buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1279 (if mh-bury-show-buffer (bury-buffer (current-buffer)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1280 (mh-when (not (equal msg-filename buffer-file-name))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1281 ;; Buffer does not yet contain message.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1282 (clear-visited-file-modtime)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1283 (unlock-buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1284 (setq buffer-file-name nil) ; no locking during setup
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1285 (erase-buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1286 (if formfile
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1287 (if (stringp formfile)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1288 (mh-exec-lib-cmd-output "mhl" "-nobell" "-noclear"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1289 "-form" formfile msg-filename)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1290 (mh-exec-lib-cmd-output "mhl" "-nobell" "-noclear"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1291 msg-filename))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1292 (insert-file-contents msg-filename))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1293 (goto-char (point-min))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1294 (cond (clean-message-header
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1295 (mh-clean-msg-header (point-min)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1296 invisible-headers
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1297 visible-headers)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1298 (goto-char (point-min)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1299 (t
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1300 (let ((case-fold-search t))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1301 (re-search-forward
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1302 "^To:\\|^From:\\|^Subject:\\|^Date:" nil t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1303 (beginning-of-line)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1304 (mh-recenter 0))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1305 (set-buffer-modified-p nil)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1306 (setq buffer-file-name msg-filename)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1307 (set-mark nil)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1308 (setq mode-line-buffer-identification
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1309 (list (format mh-show-buffer-mode-line-buffer-id
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1310 folder msg-num))))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1311
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1312
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1313 (defun mh-invalidate-show-buffer ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1314 ;; Invalidate the show buffer so we must update it to use it.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1315 (if (get-buffer mh-show-buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1316 (save-excursion
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1317 (set-buffer mh-show-buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1318 (setq buffer-file-name nil))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1319
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1320
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1321 (defun mh-show-message-in-other-window ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1322 (switch-to-buffer-other-window mh-show-buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1323 (if mh-bury-show-buffer (bury-buffer (current-buffer))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1324
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1325
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1326 (defun mh-clean-msg-header (start invisible-headers visible-headers)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1327 ;; Flush extraneous lines in a message header, from the given POINT to the
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1328 ;; end of the message header. If VISIBLE-HEADERS is non-nil, it contains a
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1329 ;; regular expression specifying the lines to display, otherwise
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1330 ;; INVISIBLE-HEADERS contains a regular expression specifying lines to
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1331 ;; delete from the header.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1332 (let ((case-fold-search t))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1333 (save-restriction
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1334 (goto-char start)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1335 (if (search-forward "\n\n" nil t)
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1336 (backward-char 1))
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1337 (narrow-to-region start (point))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1338 (goto-char (point-min))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1339 (if visible-headers
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1340 (while (< (point) (point-max))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1341 (beginning-of-line)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1342 (cond ((looking-at visible-headers)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1343 (forward-line 1)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1344 (while (looking-at "^[ \t]+") (forward-line 1)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1345 (t
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1346 (mh-delete-line 1)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1347 (while (looking-at "^[ \t]+")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1348 (beginning-of-line)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1349 (mh-delete-line 1)))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1350 (while (re-search-forward invisible-headers nil t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1351 (beginning-of-line)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1352 (mh-delete-line 1)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1353 (while (looking-at "^[ \t]+")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1354 (beginning-of-line)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1355 (mh-delete-line 1))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1356 (unlock-buffer))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1357
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1358
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1359 (defun mh-delete-line (lines)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1360 ;; Delete version of kill-line.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1361 (delete-region (point) (save-excursion (forward-line lines) (point))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1362
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1363
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1364 (defun mh-read-draft (use initial-contents delete-contents-file)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1365 ;; Read draft file into a draft buffer and make that buffer the current one.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1366 ;; USE is a message used for prompting about the intended use of the message.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1367 ;; INITIAL-CONTENTS is filename that is read into an empty buffer, or NIL
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1368 ;; if buffer should not be modified. Delete the initial-contents file if
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1369 ;; DELETE-CONTENTS-FILE flag is set.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1370 ;; Returns the draft folder's name.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1371 ;; If the draft folder facility is enabled in ~/.mh_profile, a new buffer is
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1372 ;; used each time and saved in the draft folder. The draft file can then be
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1373 ;; reused.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1374 (cond (mh-draft-folder
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1375 (let ((orig-default-dir default-directory))
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1376 (pop-to-buffer (find-file-noselect (mh-new-draft-name)) t)
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1377 (rename-buffer (format "draft-%s" (buffer-name)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1378 (setq default-directory orig-default-dir)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1379 (t
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1380 (let ((draft-name (expand-file-name "draft" mh-user-path)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1381 (pop-to-buffer "draft") ; Create if necessary
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1382 (if (buffer-modified-p)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1383 (if (y-or-n-p "Draft has been modified; kill anyway? ")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1384 (set-buffer-modified-p nil)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1385 (error "Draft preserved")))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1386 (setq buffer-file-name draft-name)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1387 (clear-visited-file-modtime)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1388 (unlock-buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1389 (mh-when (and (file-exists-p draft-name)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1390 (not (equal draft-name initial-contents)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1391 (insert-file-contents draft-name)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1392 (delete-file draft-name)))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1393 (mh-when (and initial-contents
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1394 (or (zerop (buffer-size))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1395 (not (y-or-n-p
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1396 (format "A draft exists. Use for %s? " use)))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1397 (erase-buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1398 (insert-file-contents initial-contents)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1399 (if delete-contents-file (delete-file initial-contents)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1400 (auto-save-mode 1)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1401 (if mh-draft-folder
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1402 (save-buffer)) ; Do not reuse draft name
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1403 (buffer-name))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1404
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1405
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1406 (defun mh-new-draft-name ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1407 ;; Returns the pathname of folder for draft messages.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1408 (save-excursion
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1409 (set-buffer (get-buffer-create " *mh-temp*"))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1410 (erase-buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1411 (mh-exec-cmd-output "mhpath" nil mh-draft-folder "new")
4113
93d42767e2ec (mh-yank-hooks): Use (mark t).
Richard M. Stallman <rms@gnu.org>
parents: 3850
diff changeset
1412 (buffer-substring (point) (1- (mark t)))))
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1413
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1414
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1415 (defun mh-next-msg ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1416 ;; Move backward or forward to the next undeleted message in the buffer.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1417 (if (eq mh-next-direction 'forward)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1418 (mh-next-undeleted-msg 1)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1419 (mh-previous-undeleted-msg 1)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1420
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1421
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1422 (defun mh-set-scan-mode ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1423 ;; Display the scan listing buffer, but do not show a message.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1424 (if (get-buffer mh-show-buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1425 (delete-windows-on mh-show-buffer))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1426 (mh-set-mode-name "mh-e scan")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1427 (setq mh-showing nil)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1428 (if mh-recenter-summary-p
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1429 (mh-recenter nil)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1430
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1431
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1432 (defun mh-maybe-show (&optional msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1433 ;; If in showing mode, then display the message pointed to by the cursor.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1434 (if mh-showing (mh-show msg)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1435
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1436
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1437 (defun mh-set-mode-name (mode-name-string)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1438 ;; Set the mode-name and ensure that the mode line is updated.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1439 (setq mode-name mode-name-string)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1440 ;; Force redisplay of all buffers' mode lines to be considered.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1441 (save-excursion (set-buffer (other-buffer)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1442 (set-buffer-modified-p (buffer-modified-p)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1443
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1444
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1445
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1446 ;;; The folder data abstraction.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1447
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1448 (defvar mh-current-folder nil "Name of current folder, a string.")
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 3488
diff changeset
1449 (defvar mh-show-buffer nil "Buffer that displays message for this folder.")
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1450 (defvar mh-folder-filename nil "Full path of directory for this folder.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1451 (defvar mh-showing nil "If non-nil, show the message in a separate window.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1452 (defvar mh-next-seq-num nil "Index of free sequence id.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1453 (defvar mh-delete-list nil "List of msg numbers to delete.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1454 (defvar mh-refile-list nil "List of folder names in mh-seq-list.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1455 (defvar mh-seq-list nil "Alist of (seq . msgs) numbers.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1456 (defvar mh-seen-list nil "List of displayed messages.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1457 (defvar mh-next-direction 'forward "Direction to move to next message.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1458 (defvar mh-narrowed-to-seq nil "Sequence display is narrowed to.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1459 (defvar mh-first-msg-num nil "Number of first msg in buffer.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1460 (defvar mh-last-msg-num nil "Number of last msg in buffer.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1461
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1462
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1463 (defun mh-make-folder (name)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1464 ;; Create and initialize a new mail folder called NAME and make it the
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1465 ;; current folder.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1466 (switch-to-buffer name)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1467 (setq buffer-read-only nil)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1468 (erase-buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1469 (setq buffer-read-only t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1470 (mh-folder-mode)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1471 (mh-set-folder-modified-p nil)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1472 (setq buffer-file-name mh-folder-filename)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1473 (mh-set-mode-name "mh-e scan"))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1474
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1475
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1476 ;;; Don't use this mode when creating buffers if default-major-mode is nil.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1477 (put 'mh-folder-mode 'mode-class 'special)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1478
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1479 (defun mh-folder-mode ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1480 "Major mode for \"editing\" an MH folder scan listing.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1481 Messages can be marked for refiling and deletion. However, both actions
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1482 are deferred until you request execution with \\[mh-execute-commands].
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1483 \\{mh-folder-mode-map}
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1484 A prefix argument (\\[universal-argument]) to delete, refile, list, or undo
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1485 applies the action to a message sequence.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1486
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1487 Variables controlling mh-e operation are (defaults in parentheses):
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1488
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1489 mh-bury-show-buffer (t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1490 Non-nil means that the buffer used to display message is buried.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1491 It will never be offered as the default other buffer.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1492
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1493 mh-clean-message-header (nil)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1494 Non-nil means remove header lines matching the regular expression
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1495 specified in mh-invisible-headers from messages.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1496
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1497 mh-visible-headers (nil)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1498 If non-nil, it contains a regexp specifying the headers that are shown in
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1499 a message if mh-clean-message-header is non-nil. Setting this variable
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1500 overrides mh-invisible-headers.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1501
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1502 mh-do-not-confirm (nil)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1503 Non-nil means do not prompt for confirmation before executing some
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1504 non-recoverable commands such as mh-kill-folder and mh-undo-folder.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1505
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1506 mhl-formfile (nil)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1507 Name of format file to be used by mhl to show messages.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1508 A value of T means use the default format file.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1509 Nil means don't use mhl to format messages.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1510
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1511 mh-lpr-command-format (\"lpr -p -J '%s'\")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1512 Format for command used to print a message on a system printer.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1513
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1514 mh-recenter-summary-p (nil)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1515 If non-nil, then the scan listing is recentered when the window displaying
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1516 a messages is toggled off.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1517
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1518 mh-summary-height (4)
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1519 Number of lines in the summary window including the mode line.
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1520
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1521 mh-ins-buf-prefix (\"> \")
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1522 String to insert before each non-blank line of a message as it is
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1523 inserted in a draft letter.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1524
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1525 The value of mh-folder-mode-hook is called when a new folder is set up."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1526
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1527 (kill-all-local-variables)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1528 (use-local-map mh-folder-mode-map)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1529 (setq major-mode 'mh-folder-mode)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1530 (mh-set-mode-name "mh-e folder")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1531 (make-local-vars
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1532 'mh-current-folder (buffer-name) ; Name of folder, a string
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1533 'mh-show-buffer (format "show-%s" (buffer-name)) ; Buffer that displays msgs
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1534 'mh-folder-filename ; e.g. "/usr/foobar/Mail/inbox/"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1535 (file-name-as-directory (mh-expand-file-name (buffer-name)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1536 'mh-showing nil ; Show message also?
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1537 'mh-next-seq-num 0 ; Index of free sequence id
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1538 'mh-delete-list nil ; List of msgs nums to delete
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1539 'mh-refile-list nil ; List of folder names in mh-seq-list
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1540 'mh-seq-list nil ; Alist of (seq . msgs) nums
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1541 'mh-seen-list nil ; List of displayed messages
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1542 'mh-next-direction 'forward ; Direction to move to next message
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1543 'mh-narrowed-to-seq nil ; Sequence display is narrowed to
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1544 'mh-first-msg-num nil ; Number of first msg in buffer
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1545 'mh-last-msg-num nil ; Number of last msg in buffer
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1546 'mh-previous-window-config nil) ; Previous window configuration
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1547 (setq truncate-lines t)
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1548 (auto-save-mode -1)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1549 (setq buffer-offer-save t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1550 (make-local-variable 'write-file-hooks)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1551 (setq write-file-hooks '(mh-execute-commands))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1552 (make-local-variable 'revert-buffer-function)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1553 (setq revert-buffer-function 'mh-undo-folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1554 (run-hooks 'mh-folder-mode-hook))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1555
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1556
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1557 (defun make-local-vars (&rest pairs)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1558 ;; Take VARIABLE-VALUE pairs and makes local variables initialized to the
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1559 ;; value.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1560 (while pairs
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1561 (make-variable-buffer-local (car pairs))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1562 (set (car pairs) (car (cdr pairs)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1563 (setq pairs (cdr (cdr pairs)))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1564
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1565
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1566 (defun mh-scan-folder (folder range)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1567 ;; Scan the FOLDER over the RANGE. Return in the folder's buffer.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1568 (cond ((null (get-buffer folder))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1569 (mh-make-folder folder))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1570 (t
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1571 (mh-process-or-undo-commands folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1572 (switch-to-buffer folder)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1573 (mh-regenerate-headers range)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1574 (mh-when (zerop (buffer-size))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1575 (if (equal range "all")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1576 (message "Folder %s is empty" folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1577 (message "No messages in %s, range %s" folder range))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1578 (sit-for 5))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1579 (mh-goto-cur-msg))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1580
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1581
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1582 (defun mh-regenerate-headers (range)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1583 ;; Replace buffer with scan of its contents over range RANGE.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1584 (let ((folder mh-current-folder))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1585 (message "Scanning %s..." folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1586 (with-mh-folder-updating (nil)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1587 (erase-buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1588 (mh-exec-cmd-output "scan" nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1589 "-noclear" "-noheader"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1590 "-width" (window-width)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1591 folder range)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1592 (goto-char (point-min))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1593 (cond ((looking-at "scan: no messages in")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1594 (keep-lines mh-valid-scan-line)) ; Flush random scan lines
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1595 ((looking-at "scan: ")) ; Keep error messages
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1596 (t
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1597 (keep-lines mh-valid-scan-line))) ; Flush random scan lines
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1598 (mh-delete-seq-locally 'cur) ; To pick up new one
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1599 (setq mh-seq-list (mh-read-folder-sequences folder nil))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1600 (mh-notate-user-sequences)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1601 (mh-make-folder-mode-line (if (equal range "all")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1602 nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1603 mh-partial-folder-mode-line-annotation)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1604 (message "Scanning %s...done" folder)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1605
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1606
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1607 (defun mh-get-new-mail (maildrop-name)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1608 ;; Read new mail from a maildrop into the current buffer.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1609 ;; Return T if there was new mail, NIL otherwise. Return in the current
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1610 ;; buffer.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1611 (let ((point-before-inc (point))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1612 (folder mh-current-folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1613 (return-value t))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1614 (with-mh-folder-updating (t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1615 (message (if maildrop-name
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1616 (format "inc %s -file %s..." folder maildrop-name)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1617 (format "inc %s..." folder)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1618 (mh-unmark-all-headers nil)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1619 (setq mh-next-direction 'forward)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1620 (goto-char (point-max))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1621 (let ((start-of-inc (point)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1622 (if maildrop-name
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1623 (mh-exec-cmd-output "inc" nil folder
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1624 "-file" (expand-file-name maildrop-name)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1625 "-width" (window-width)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1626 "-truncate")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1627 (mh-exec-cmd-output "inc" nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1628 "-width" (window-width)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1629 (message
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1630 (if maildrop-name
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1631 (format "inc %s -file %s...done" folder maildrop-name)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1632 (format "inc %s...done" folder)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1633 (goto-char start-of-inc)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1634 (cond ((looking-at "inc: no mail")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1635 (keep-lines mh-valid-scan-line) ; Flush random scan lines
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1636 (goto-char point-before-inc)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1637 (message "No new mail%s%s" (if maildrop-name " in " "")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1638 (if maildrop-name maildrop-name "")))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1639 ((re-search-forward "^inc:" nil t) ; Error messages
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1640 (error "inc error"))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1641 (t
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1642 (mh-delete-seq-locally 'cur) ; To pick up new one
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1643 (setq mh-seq-list (mh-read-folder-sequences folder t))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1644 (mh-notate-user-sequences)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1645 (keep-lines mh-valid-scan-line)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1646 (mh-make-folder-mode-line)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1647 (mh-goto-cur-msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1648 (setq return-value t))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1649 return-value)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1650
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1651
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1652 (defun mh-make-folder-mode-line (&optional annotation)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1653 ;; Set the fields of the mode line for a folder buffer.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1654 ;; The optional ANNOTATION string is displayed after the folder's name.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1655 (save-excursion
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1656 (mh-first-msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1657 (setq mh-first-msg-num (mh-get-msg-num nil))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1658 (mh-last-msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1659 (setq mh-last-msg-num (mh-get-msg-num nil))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1660 (let ((lines (count-lines (point-min) (point-max))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1661 (setq mode-line-buffer-identification
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1662 (list (format "{%%b%s} %d msg%s"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1663 (if annotation (format "/%s" annotation) "")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1664 lines
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1665 (if (zerop lines)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1666 "s"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1667 (if (> lines 1)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1668 (format "s (%d-%d)" mh-first-msg-num
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1669 mh-last-msg-num)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1670 (format " (%d)" mh-first-msg-num)))))))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1671
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1672
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1673 (defun mh-unmark-all-headers (remove-all-flags)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1674 ;; Remove all '+' flags from the headers, and if called with a non-nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1675 ;; argument, remove all 'D', '^' and '%' flags too.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1676 ;; Optimized for speed (i.e., no regular expressions).
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1677 (save-excursion
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1678 (let ((case-fold-search nil)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1679 (last-line (- (point-max) mh-cmd-note))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1680 char)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1681 (mh-first-msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1682 (while (<= (point) last-line)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1683 (forward-char mh-cmd-note)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1684 (setq char (following-char))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1685 (if (or (and remove-all-flags
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1686 (or (eql char ?D)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1687 (eql char ?^)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1688 (eql char ?%)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1689 (eql char ?+))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1690 (progn
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1691 (delete-char 1)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1692 (insert " ")))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1693 (forward-line)))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1694
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1695
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1696 (defun mh-goto-cur-msg ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1697 ;; Position the cursor at the current message.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1698 (let ((cur-msg (car (mh-seq-to-msgs 'cur))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1699 (cond ((and cur-msg
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1700 (mh-goto-msg cur-msg t nil))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1701 (mh-notate nil ?+ mh-cmd-note)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1702 (mh-recenter 0)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1703 (mh-maybe-show cur-msg))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1704 (t
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1705 (mh-last-msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1706 (message "No current message")))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1707
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1708
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1709 (defun mh-pack-folder-1 (range)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1710 ;; Close and pack the current folder.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1711 (mh-process-or-undo-commands mh-current-folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1712 (message "Packing folder...")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1713 (mh-set-folder-modified-p t) ; lock folder while packing
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1714 (save-excursion
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1715 (mh-exec-cmd-quiet " *mh-temp*" "folder" mh-current-folder "-pack"))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1716 (mh-regenerate-headers range))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1717
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1718
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1719 (defun mh-process-or-undo-commands (folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1720 ;; If FOLDER has outstanding commands, then either process or discard them.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1721 (set-buffer folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1722 (if (mh-outstanding-commands-p)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1723 (if (or mh-do-not-confirm
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1724 (y-or-n-p
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1725 "Process outstanding deletes and refiles (or lose them)? "))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1726 (mh-process-commands folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1727 (mh-undo-folder))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1728 (mh-invalidate-show-buffer)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1729
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1730
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1731 (defun mh-process-commands (folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1732 ;; Process outstanding commands for the folder FOLDER.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1733 (message "Processing deletes and refiles for %s..." folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1734 (set-buffer folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1735 (with-mh-folder-updating (nil)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1736 ;; Update the unseen sequence if it exists
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1737 (if (and mh-seen-list (mh-seq-to-msgs mh-unseen-seq))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1738 (mh-undefine-sequence mh-unseen-seq mh-seen-list))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1739
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1740 ;; Then refile messages
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1741 (mh-mapc
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1742 (function
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1743 (lambda (dest)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1744 (let ((msgs (mh-seq-to-msgs dest)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1745 (mh-when msgs
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1746 (apply 'mh-exec-cmd "refile"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1747 "-src" folder (symbol-name dest) msgs)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1748 (mh-delete-scan-msgs msgs)))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1749 mh-refile-list)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1750
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1751 ;; Now delete messages
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1752 (mh-when mh-delete-list
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1753 (apply 'mh-exec-cmd "rmm" folder mh-delete-list)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1754 (mh-delete-scan-msgs mh-delete-list))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1755
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1756 ;; Don't need to remove sequences since delete and refile do so.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1757
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1758 ;; Mark cur message
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1759 (if (> (buffer-size) 0)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1760 (mh-define-sequence 'cur (list (or (mh-get-msg-num nil) "last"))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1761
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1762 (mh-invalidate-show-buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1763
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1764 (setq mh-delete-list nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1765 mh-refile-list nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1766 mh-seq-list (mh-read-folder-sequences mh-current-folder nil)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1767 mh-seen-list nil)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1768 (mh-unmark-all-headers t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1769 (mh-notate-user-sequences)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1770 (message "Processing deletes and refiles for %s...done" folder)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1771
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1772
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1773 (defun mh-delete-scan-msgs (msgs)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1774 ;; Delete the scan listing lines for each of the msgs in the LIST.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1775 ;; Optimized for speed (i.e., no regular expressions).
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1776 (setq msgs (sort msgs (function <))) ;okay to clobber msgs
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1777 (save-excursion
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1778 (mh-first-msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1779 (while (and msgs (< (point) (point-max)))
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1780 (cond ((equal (mh-get-msg-num nil) (car msgs))
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1781 (delete-region (point) (save-excursion (forward-line) (point)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1782 (setq msgs (cdr msgs)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1783 (t
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1784 (forward-line))))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1785
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1786
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1787 (defun mh-set-folder-modified-p (flag)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1788 "Mark current folder as modified or unmodified according to FLAG."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1789 (set-buffer-modified-p flag))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1790
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1791
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1792 (defun mh-outstanding-commands-p ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1793 ;; Returns non-nil if there are outstanding deletes or refiles.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1794 (or mh-delete-list mh-refile-list))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1795
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1796
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1797
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1798 ;;; Mode for composing and sending a draft message.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1799
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1800 (defvar mh-sent-from-folder nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1801 "Folder of msg associated with this letter.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1802
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1803 (defvar mh-sent-from-msg nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1804 "Number of msg associated with this letter.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1805
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1806 (defvar mh-send-args nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1807 "Extra arguments to pass to \"send\" command.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1808
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1809 (defvar mh-annotate-char nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1810 "Character to use to annotate mh-sent-from-msg.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1811
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1812 (defvar mh-annotate-field nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1813 "Field name for message annotation.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1814
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1815 (defun mh-letter-mode ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1816 "Mode for composing letters in mh-e.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1817 When you have finished composing, type \\[mh-send-letter] to send the letter.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1818
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1819 Variables controlling this mode (defaults in parentheses):
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1820
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1821 mh-delete-yanked-msg-window (nil)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1822 If non-nil, \\[mh-yank-cur-msg] will delete any windows displaying
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1823 the yanked message.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1824
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1825 mh-yank-from-start-of-msg (t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1826 If non-nil, \\[mh-yank-cur-msg] will include the entire message.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1827 If `body', just yank the body (no header).
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1828 If nil, only the portion of the message following the point will be yanked.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1829 If there is a region, this variable is ignored.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1830
3327
e533aed58919 (mh-signature-file-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 3220
diff changeset
1831 mh-signature-file-name (\"~/.signature\")
e533aed58919 (mh-signature-file-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 3220
diff changeset
1832 File to be inserted into message by \\[mh-insert-signature].
e533aed58919 (mh-signature-file-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 3220
diff changeset
1833
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1834 Upon invoking mh-letter-mode, text-mode-hook and mh-letter-mode-hook are
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1835 invoked with no args, if those values are non-nil.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1836
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1837 \\{mh-letter-mode-map}"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1838 (interactive)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1839 (kill-all-local-variables)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1840 (make-local-variable 'paragraph-start)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1841 (setq paragraph-start (concat "^[ \t]*[-_][-_][-_]+$\\|" paragraph-start))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1842 (make-local-variable 'paragraph-separate)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1843 (setq paragraph-separate
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1844 (concat "^[ \t]*[-_][-_][-_]+$\\|" paragraph-separate))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1845 (make-local-variable 'mh-send-args)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1846 (make-local-variable 'mh-annotate-char)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1847 (make-local-variable 'mh-annotate-field)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1848 (make-local-variable 'mh-previous-window-config)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1849 (make-local-variable 'mh-sent-from-folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1850 (make-local-variable 'mh-sent-from-msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1851 (use-local-map mh-letter-mode-map)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1852 (setq major-mode 'mh-letter-mode)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1853 (mh-set-mode-name "mh-e letter")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1854 (set-syntax-table mh-letter-mode-syntax-table)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1855 (run-hooks 'text-mode-hook 'mh-letter-mode-hook)
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1856 (mh-when (and (boundp 'auto-fill-hook) auto-fill-hook) ;emacs 18
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1857 (make-local-variable 'auto-fill-hook)
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1858 (setq auto-fill-hook 'mh-auto-fill-for-letter))
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1859 (mh-when (and (boundp 'auto-fill-function) auto-fill-function) ;emacs 19
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1860 (make-local-variable 'auto-fill-function)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1861 (setq auto-fill-function 'mh-auto-fill-for-letter)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1862
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1863
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1864 (defun mh-auto-fill-for-letter ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1865 ;; Auto-fill in letters treats the header specially by inserting a tab
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1866 ;; before continuation line.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1867 (do-auto-fill)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1868 (if (mh-in-header-p)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1869 (save-excursion
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1870 (beginning-of-line nil)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1871 (insert-char ?\t 1))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1872
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1873
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1874 (defun mh-in-header-p ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1875 ;; Return non-nil if the point is in the header of a draft message.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1876 (save-excursion
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1877 (let ((cur-point (point)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1878 (goto-char (point-min))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1879 (re-search-forward "^--------" nil t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1880 (< cur-point (point)))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1881
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1882
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1883 (defun mh-to-field ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1884 "Move point to the end of a specified header field.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1885 The field is indicated by the previous keystroke. Create the field if
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1886 it does not exist. Set the mark to point before moving."
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1887 (interactive)
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1888 (expand-abbrev)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1889 (let ((target (cdr (assoc (logior last-input-char ?`) mh-to-field-choices)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1890 (case-fold-search t))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1891 (cond ((mh-position-on-field target t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1892 (let ((eol (point)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1893 (skip-chars-backward " \t")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1894 (delete-region (point) eol))
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1895 (if (and (not (eq (logior last-input-char ?`) ?s))
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1896 (save-excursion
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1897 (backward-char 1)
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1898 (not (looking-at "[:,]"))))
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1899 (insert ", ")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1900 (insert " ")))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1901 (t
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1902 (goto-char (point-min))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1903 (re-search-forward "^To:")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1904 (forward-line 1)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1905 (while (looking-at "^[ \t]") (forward-line 1))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1906 (insert (format "%s \n" target))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1907 (backward-char 1)))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1908
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1909
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1910 (defun mh-to-fcc ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1911 "Insert an Fcc: field in the current message.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1912 Prompt for the field name with a completion list of the current folders."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1913 (interactive)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1914 (let ((last-input-char ?\C-f)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1915 (folder (mh-prompt-for-folder "Fcc" "" t)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1916 (expand-abbrev)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1917 (save-excursion
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1918 (mh-to-field)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1919 (insert (substring folder 1 nil)))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1920
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1921
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1922 (defun mh-insert-signature ()
3327
e533aed58919 (mh-signature-file-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 3220
diff changeset
1923 "Insert the file named by mh-signature-file-name at the current point."
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1924 (interactive)
3327
e533aed58919 (mh-signature-file-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 3220
diff changeset
1925 (insert-file-contents mh-signature-file-name)
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1926 (set-buffer-modified-p (buffer-modified-p))) ; force mode line update
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1927
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1928
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1929 (defun mh-check-whom ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1930 "Verify recipients of the current letter."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1931 (interactive)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1932 (let ((file-name (buffer-file-name)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1933 (set-buffer-modified-p t) ; Force writing of contents
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1934 (save-buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1935 (message "Checking recipients...")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1936 (switch-to-buffer-other-window "*Mail Recipients*")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1937 (bury-buffer (current-buffer))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1938 (erase-buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1939 (mh-exec-cmd-output "whom" t file-name)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1940 (other-window -1)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1941 (message "Checking recipients...done")))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1942
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1943
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1944
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1945 ;;; Routines to make a search pattern and search for a message.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1946
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1947 (defvar mh-searching-folder nil "Folder this pick is searching.")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1948
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1949
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1950 (defun mh-make-pick-template ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1951 ;; Initialize the current buffer with a template for a pick pattern.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1952 (erase-buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1953 (kill-all-local-variables)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1954 (make-local-variable 'mh-searching-folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1955 (insert "From: \n"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1956 "To: \n"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1957 "Cc: \n"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1958 "Date: \n"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1959 "Subject: \n"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1960 "---------\n")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1961 (mh-letter-mode)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1962 (use-local-map mh-pick-mode-map)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1963 (goto-char (point-min))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1964 (end-of-line))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1965
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1966
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1967 (defun mh-do-pick-search ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1968 "Find messages that match the qualifications in the current pattern buffer.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1969 Messages are searched for in the folder named in mh-searching-folder.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1970 Put messages found in a sequence named `search'."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1971 (interactive)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1972 (let ((pattern-buffer (buffer-name))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1973 (searching-buffer mh-searching-folder)
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
1974 range msgs
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1975 (pattern nil)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1976 (new-buffer nil))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1977 (save-excursion
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1978 (cond ((get-buffer searching-buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1979 (set-buffer searching-buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1980 (setq range (format "%d-%d" mh-first-msg-num mh-last-msg-num)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1981 (t
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1982 (mh-make-folder searching-buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1983 (setq range "all")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1984 (setq new-buffer t))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1985 (message "Searching...")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1986 (goto-char (point-min))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1987 (while (setq pattern (mh-next-pick-field pattern-buffer))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1988 (setq msgs (mh-seq-from-command searching-buffer
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1989 'search
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1990 (nconc (cons "pick" pattern)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1991 (list searching-buffer
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1992 range
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1993 "-sequence" "search"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1994 "-list"))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1995 (setq range "search"))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1996 (message "Searching...done")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1997 (if new-buffer
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1998 (mh-scan-folder searching-buffer msgs)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1999 (switch-to-buffer searching-buffer))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2000 (delete-other-windows)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2001 (mh-notate-seq 'search ?% (1+ mh-cmd-note))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2002
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2003
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2004 (defun mh-next-pick-field (buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2005 ;; Return the next piece of a pick argument that can be extracted from the
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2006 ;; BUFFER. Returns nil if no pieces remain.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2007 (set-buffer buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2008 (let ((case-fold-search t))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2009 (cond ((eobp)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2010 nil)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2011 ((re-search-forward "^\\([a-z].*\\):[ \t]*\\([a-z0-9].*\\)$" nil t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2012 (let* ((component
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2013 (format "--%s"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2014 (downcase (buffer-substring (match-beginning 1)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2015 (match-end 1)))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2016 (pat (buffer-substring (match-beginning 2) (match-end 2))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2017 (forward-line 1)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2018 (list component pat)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2019 ((re-search-forward "^-*$" nil t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2020 (forward-char 1)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2021 (let ((body (buffer-substring (point) (point-max))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2022 (if (and (> (length body) 0) (not (equal body "\n")))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2023 (list "-search" body)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2024 nil)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2025 (t
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2026 nil))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2027
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2028
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2029
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2030 ;;; Routines to compose and send a letter.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2031
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2032 (defun mh-compose-and-send-mail (draft send-args
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2033 sent-from-folder sent-from-msg
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2034 to subject cc
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2035 annotate-char annotate-field
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2036 config)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2037 ;; Edit and compose a draft message in buffer DRAFT and send or save it.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2038 ;; SENT-FROM-FOLDER is buffer containing scan listing of current folder, or
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2039 ;; nil if none exists.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2040 ;; SENT-FROM-MSG is the message number or sequence name or nil.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2041 ;; SEND-ARGS is an optional argument passed to the send command.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2042 ;; The TO, SUBJECT, and CC fields are passed to the
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2043 ;; mh-compose-letter-function.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2044 ;; If ANNOTATE-CHAR is non-null, it is used to notate the scan listing of the
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2045 ;; message. In that case, the ANNOTATE-FIELD is used to build a string
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2046 ;; for mh-annotate-msg.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2047 ;; CONFIG is the window configuration to restore after sending the letter.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2048 (pop-to-buffer draft)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2049 (mh-letter-mode)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2050 (setq mh-sent-from-folder sent-from-folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2051 (setq mh-sent-from-msg sent-from-msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2052 (setq mh-send-args send-args)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2053 (setq mh-annotate-char annotate-char)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2054 (setq mh-annotate-field annotate-field)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2055 (setq mh-previous-window-config config)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2056 (setq mode-line-buffer-identification (list "{%b}"))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2057 (if (and (boundp 'mh-compose-letter-function)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2058 (symbol-value 'mh-compose-letter-function))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2059 ;; run-hooks will not pass arguments.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2060 (let ((value (symbol-value 'mh-compose-letter-function)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2061 (if (and (listp value) (not (eq (car value) 'lambda)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2062 (while value
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2063 (funcall (car value) to subject cc)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2064 (setq value (cdr value)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2065 (funcall mh-compose-letter-function to subject cc)))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2066
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2067
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2068 (defun mh-send-letter (&optional arg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2069 "Send the draft letter in the current buffer.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2070 If optional prefix argument is provided, monitor delivery.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2071 Run mh-before-send-letter-hook before doing anything."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2072 (interactive "P")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2073 (run-hooks 'mh-before-send-letter-hook)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2074 (set-buffer-modified-p t) ; Make sure buffer is written
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2075 (save-buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2076 (message "Sending...")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2077 (let ((draft-buffer (current-buffer))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2078 (file-name (buffer-file-name))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2079 (config mh-previous-window-config))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2080 (cond (arg
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2081 (pop-to-buffer "MH mail delivery")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2082 (erase-buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2083 (if mh-send-args
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2084 (mh-exec-cmd-output "send" t "-watch" "-nopush"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2085 "-nodraftfolder" mh-send-args file-name)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2086 (mh-exec-cmd-output "send" t "-watch" "-nopush"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2087 "-nodraftfolder" file-name))
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
2088 (goto-char (point-max)) ; show the interesting part
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2089 (recenter -1)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2090 (set-buffer draft-buffer)) ; for annotation below
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2091 (mh-send-args
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2092 (mh-exec-cmd-daemon "send" "-nodraftfolder" "-noverbose"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2093 mh-send-args file-name))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2094 (t
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2095 (mh-exec-cmd-daemon "send" "-nodraftfolder" "-noverbose"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2096 file-name)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2097
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2098 (if mh-annotate-char
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2099 (mh-annotate-msg mh-sent-from-msg
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2100 mh-sent-from-folder
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2101 mh-annotate-char
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2102 "-component" mh-annotate-field
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2103 "-text" (format "\"%s %s\""
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2104 (mh-get-field "To:")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2105 (mh-get-field "Cc:"))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2106
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2107 (mh-when (or (not arg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2108 (y-or-n-p "Kill draft buffer? "))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2109 (kill-buffer draft-buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2110 (if config
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2111 (set-window-configuration config)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2112 (message "Sending...done")))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2113
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2114
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2115 (defun mh-insert-letter (prefix-provided folder msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2116 "Insert a message from any folder into the current letter.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2117 Removes the message's headers using mh-invisible-headers.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2118 Prefixes each non-blank line with mh-ins-buf-prefix (default \">> \").
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2119 If optional prefix argument provided, do not indent and do not delete
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2120 headers. Leaves the mark before the letter and point after it."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2121 (interactive
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2122 (list current-prefix-arg
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2123 (mh-prompt-for-folder "Message from" mh-sent-from-folder nil)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2124 (read-input (format "Message number%s: "
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2125 (if mh-sent-from-msg
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2126 (format " [%d]" mh-sent-from-msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2127 "")))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2128 (save-restriction
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2129 (narrow-to-region (point) (point))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2130 (let ((start (point-min)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2131 (if (equal msg "") (setq msg (int-to-string mh-sent-from-msg)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2132 (mh-exec-lib-cmd-output "mhl" "-nobell" "-noclear"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2133 (expand-file-name msg
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2134 (mh-expand-file-name folder)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2135 (mh-when (not prefix-provided)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2136 (mh-clean-msg-header start mh-invisible-headers mh-visible-headers)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2137 (set-mark start) ; since mh-clean-msg-header moves it
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2138 (mh-insert-prefix-string mh-ins-buf-prefix)))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2139
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2140
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2141 (defun mh-yank-cur-msg ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2142 "Insert the current message into the draft buffer.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2143 Prefix each non-blank line in the message with the string in
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2144 `mh-ins-buf-prefix'. If a region is set in the message's buffer, then
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2145 only the region will be inserted. Otherwise, the entire message will
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2146 be inserted if `mh-yank-from-start-of-msg' is non-nil. If this variable
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2147 is nil, the portion of the message following the point will be yanked.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2148 If `mh-delete-yanked-msg-window' is non-nil, any window displaying the
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2149 yanked message will be deleted."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2150 (interactive)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2151 (if (and mh-sent-from-folder mh-sent-from-msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2152 (let ((to-point (point))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2153 (to-buffer (current-buffer)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2154 (set-buffer mh-sent-from-folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2155 (if mh-delete-yanked-msg-window
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2156 (delete-windows-on mh-show-buffer))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2157 (set-buffer mh-show-buffer) ; Find displayed message
3850
1c084fa7c501 (mh-yank-cur-msg): Test mark-active.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
2158 (let ((mh-ins-str (cond (mark-active
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
2159 (buffer-substring (region-beginning)
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
2160 (region-end)))
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2161 ((eq 'body mh-yank-from-start-of-msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2162 (buffer-substring
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2163 (save-excursion
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2164 (goto-char (point-min))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2165 (mh-goto-header-end 1)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2166 (point))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2167 (point-max)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2168 (mh-yank-from-start-of-msg
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2169 (buffer-substring (point-min) (point-max)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2170 (t
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2171 (buffer-substring (point) (point-max))))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2172 (set-buffer to-buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2173 (narrow-to-region to-point to-point)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2174 (push-mark)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2175 (insert mh-ins-str)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2176 (mh-insert-prefix-string mh-ins-buf-prefix)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2177 (insert "\n")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2178 (widen)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2179 (error "There is no current message")))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2180
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2181
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2182 (defun mh-insert-prefix-string (mh-ins-string)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2183 ;; Run MH-YANK-HOOK to insert a prefix string before each line in the buffer.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2184 ;; Generality for supercite users.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2185 (save-excursion
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2186 (set-mark (point-max))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2187 (goto-char (point-min))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2188 (run-hooks 'mh-yank-hooks)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2189
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2190
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2191 (defun mh-fully-kill-draft ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2192 "Kill the draft message file and the draft message buffer.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2193 Use \\[kill-buffer] if you don't want to delete the draft message file."
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
2194 (interactive)
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2195 (if (y-or-n-p "Kill draft message? ")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2196 (let ((config mh-previous-window-config))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2197 (if (file-exists-p (buffer-file-name))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2198 (delete-file (buffer-file-name)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2199 (set-buffer-modified-p nil)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2200 (kill-buffer (buffer-name))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2201 (message "")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2202 (if config
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2203 (set-window-configuration config)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2204 (error "Message not killed")))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2205
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2206
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2207 (defun mh-recenter (arg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2208 ;; Like recenter but with two improvements: nil arg means recenter,
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2209 ;; and only does anything if the current buffer is in the selected
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2210 ;; window. (Commands like save-some-buffers can make this false.)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2211 (if (eql (get-buffer-window (current-buffer))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2212 (selected-window))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2213 (recenter (if arg arg '(t)))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2214
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2215
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2216
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2217 ;;; Commands to manipulate sequences. Sequences are stored in an alist
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2218 ;;; of the form:
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2219 ;;; ((seq-name msgs ...) (seq-name msgs ...) ...)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2220
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2221 (defun mh-make-seq (name msgs) (cons name msgs))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2222
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2223 (defmacro mh-seq-name (pair) (list 'car pair))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2224
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2225 (defmacro mh-seq-msgs (pair) (list 'cdr pair))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2226
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2227 (defun mh-find-seq (name) (assoc name mh-seq-list))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2228
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2229
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2230 (defun mh-seq-to-msgs (seq)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2231 "Return a list of the messages in SEQUENCE."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2232 (mh-seq-msgs (mh-find-seq seq)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2233
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2234
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2235 (defun mh-seq-containing-msg (msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2236 ;; Return a list of the sequences containing MESSAGE.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2237 (let ((l mh-seq-list)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2238 (seqs ()))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2239 (while l
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2240 (if (memq msg (mh-seq-msgs (car l)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2241 (mh-push (mh-seq-name (car l)) seqs))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2242 (setq l (cdr l)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2243 seqs))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2244
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2245
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2246 (defun mh-msg-to-seq (msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2247 ;; Given a MESSAGE number, return the first sequence in which it occurs.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2248 (car (mh-seq-containing-msg msg)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2249
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2250
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2251 (defun mh-read-seq-default (prompt not-empty)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2252 ;; Read and return sequence name with default narrowed or previous sequence.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2253 (mh-read-seq prompt not-empty (or mh-narrowed-to-seq mh-previous-seq)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2254
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2255
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2256 (defun mh-read-seq (prompt not-empty &optional default)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2257 ;; Read and return a sequence name. Prompt with PROMPT, raise an error
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2258 ;; if the sequence is empty and the NOT-EMPTY flag is non-nil, and supply
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2259 ;; an optional DEFAULT sequence.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2260 ;; A reply of '%' defaults to the first sequence containing the current
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2261 ;; message.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2262 (let* ((input (completing-read (format "%s %s %s" prompt "sequence:"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2263 (if default
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2264 (format "[%s] " default)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2265 ""))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2266 (mh-seq-names mh-seq-list)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2267 (seq (cond ((equal input "%") (mh-msg-to-seq (mh-get-msg-num t)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2268 ((equal input "") default)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2269 (t (intern input))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2270 (msgs (mh-seq-to-msgs seq)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2271 (if (and (null msgs) not-empty)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2272 (error (format "No messages in sequence `%s'" seq)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2273 seq))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2274
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2275
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2276 (defun mh-read-folder-sequences (folder define-sequences)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2277 ;; Read and return the predefined sequences for a FOLDER. If
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2278 ;; DEFINE-SEQUENCES is non-nil, then define mh-e's sequences before
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2279 ;; reading MH's sequences.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2280 (let ((seqs ()))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2281 (mh-when define-sequences
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2282 (mh-define-sequences mh-seq-list)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2283 (mh-mapc (function (lambda (seq) ; Save the internal sequences
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2284 (if (mh-folder-name-p (mh-seq-name seq))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2285 (mh-push seq seqs))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2286 mh-seq-list))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2287 (save-excursion
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2288 (mh-exec-cmd-quiet " *mh-temp*" "mark" folder "-list")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2289 (goto-char (point-min))
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
2290 ;; look for name in line of form "cur: 4" or "myseq (private): 23"
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
2291 (while (re-search-forward "^[^: ]+" nil t)
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2292 (mh-push (mh-make-seq (intern (buffer-substring (match-beginning 0)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2293 (match-end 0)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2294 (mh-read-msg-list))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2295 seqs))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2296 (delete-region (point-min) (point))) ; avoid race with mh-process-daemon
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2297 seqs))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2298
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2299
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2300 (defun mh-seq-names (seq-list)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2301 ;; Return an alist containing the names of the SEQUENCES.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2302 (mapcar (function (lambda (entry) (list (symbol-name (mh-seq-name entry)))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2303 seq-list))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2304
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2305
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2306 (defun mh-seq-from-command (folder seq seq-command)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2307 ;; In FOLDER, make a sequence named SEQ by executing COMMAND.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2308 ;; COMMAND is a list. The first element is a program name
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2309 ;; and the subsequent elements are its arguments, all strings.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2310 (let ((msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2311 (msgs ())
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2312 (case-fold-search t))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2313 (save-excursion
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2314 (save-window-excursion
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2315 (apply 'mh-exec-cmd-quiet " *mh-temp*" seq-command)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2316 (goto-char (point-min))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2317 (while (setq msg (car (mh-read-msg-list)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2318 (mh-push msg msgs)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2319 (forward-line 1)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2320 (set-buffer folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2321 (setq msgs (nreverse msgs)) ; Put in ascending order
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2322 (mh-push (mh-make-seq seq msgs) mh-seq-list)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2323 msgs)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2324
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2325
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2326 (defun mh-read-msg-list ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2327 ;; Return a list of message numbers from the current point to the end of
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2328 ;; the line.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2329 (let ((msgs ())
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2330 (end-of-line (save-excursion (end-of-line) (point)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2331 num)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2332 (while (re-search-forward "[0-9]+" end-of-line t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2333 (setq num (string-to-int (buffer-substring (match-beginning 0)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2334 (match-end 0))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2335 (cond ((looking-at "-") ; Message range
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2336 (forward-char 1)
4495
8e8321e76af5 (mh-read-msg-list): Undo previous change.
Richard M. Stallman <rms@gnu.org>
parents: 4174
diff changeset
2337 (re-search-forward "[0-9]+" end-of-line t)
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2338 (let ((num2 (string-to-int (buffer-substring (match-beginning 0)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2339 (match-end 0)))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2340 (if (< num2 num)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2341 (error "Bad message range: %d-%d" num num2))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2342 (while (<= num num2)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2343 (mh-push num msgs)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2344 (setq num (1+ num)))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2345 ((not (zerop num)) (mh-push num msgs))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2346 msgs))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2347
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2348
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2349 (defun mh-remove-seq (seq)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2350 ;; Delete the SEQUENCE.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2351 (mh-map-to-seq-msgs 'mh-notate-if-in-one-seq seq ? (1+ mh-cmd-note) seq)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2352 (mh-undefine-sequence seq (list "all"))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2353 (mh-delete-seq-locally seq))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2354
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2355
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2356 (defun mh-delete-seq-locally (seq)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2357 ;; Remove mh-e's record of SEQUENCE.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2358 (let ((entry (mh-find-seq seq)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2359 (setq mh-seq-list (delq entry mh-seq-list))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2360
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2361
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2362 (defun mh-remove-msg-from-seq (msg seq &optional internal-flag)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2363 ;; Remove MESSAGE from the SEQUENCE. If optional FLAG is non-nil, do not
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2364 ;; inform MH of the change.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2365 (let ((entry (mh-find-seq seq)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2366 (mh-when entry
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2367 (mh-notate-if-in-one-seq msg ? (1+ mh-cmd-note) (mh-seq-name entry))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2368 (if (not internal-flag)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2369 (mh-undefine-sequence seq (list msg)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2370 (setcdr entry (delq msg (mh-seq-msgs entry))))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2371
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2372
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2373 (defun mh-add-msgs-to-seq (msgs seq &optional internal-flag)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2374 ;; Add MESSAGE(s) to the SEQUENCE. If optional FLAG is non-nil, do not mark
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2375 ;; the message in the scan listing or inform MH of the addition.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2376 (let ((entry (mh-find-seq seq)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2377 (if (and msgs (atom msgs)) (setq msgs (list msgs)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2378 (if (null entry)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2379 (mh-push (mh-make-seq seq msgs) mh-seq-list)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2380 (if msgs (setcdr entry (append msgs (cdr entry)))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2381 (mh-when (not internal-flag)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2382 (mh-add-to-sequence seq msgs)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2383 (mh-notate-seq seq ?% (1+ mh-cmd-note)))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2384
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2385
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2386 (defun mh-rename-seq (seq new-name)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2387 "Rename a SEQUENCE to have a new NAME."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2388 (interactive "SOld sequence name: \nSNew name: ")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2389 (let ((old-seq (mh-find-seq seq)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2390 (if old-seq
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2391 (rplaca old-seq new-name)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2392 (error "Sequence %s does not exists" seq))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2393 (mh-undefine-sequence seq (mh-seq-msgs old-seq))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2394 (mh-define-sequence new-name (mh-seq-msgs old-seq))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2395
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2396
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2397 (defun mh-notate-user-sequences ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2398 ;; Mark the scan listing of all messages in user-defined sequences.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2399 (let ((seqs mh-seq-list)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2400 name)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2401 (while seqs
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2402 (setq name (mh-seq-name (car seqs)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2403 (if (not (mh-internal-seq name))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2404 (mh-notate-seq name ?% (1+ mh-cmd-note)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2405 (setq seqs (cdr seqs)))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2406
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2407
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2408 (defun mh-internal-seq (name)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2409 ;; Return non-NIL if NAME is the name of an internal mh-e sequence.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2410 (or (memq name '(answered cur deleted forwarded printed))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2411 (eq name mh-unseen-seq)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2412 (mh-folder-name-p name)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2413
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2414
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2415 (defun mh-folder-name-p (name)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2416 ;; Return non-NIL if NAME is possibly the name of a folder.
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
2417 ;; A name (a string or symbol) can be a folder name if it begins with "+".
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2418 (if (symbolp name)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2419 (eql (aref (symbol-name name) 0) ?+)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2420 (eql (aref name 0) ?+)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2421
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2422
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2423 (defun mh-notate-seq (seq notation offset)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2424 ;; Mark the scan listing of all messages in the SEQUENCE with the CHARACTER
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2425 ;; at the given OFFSET from the beginning of the listing line.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2426 (mh-map-to-seq-msgs 'mh-notate seq notation offset))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2427
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2428
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2429 (defun mh-notate-if-in-one-seq (msg notation offset seq)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2430 ;; If the MESSAGE is in only the SEQUENCE, then mark the scan listing of the
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2431 ;; message with the CHARACTER at the given OFFSET from the beginning of the
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2432 ;; listing line.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2433 (let ((in-seqs (mh-seq-containing-msg msg)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2434 (if (and (eq seq (car in-seqs)) (null (cdr in-seqs)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2435 (mh-notate msg notation offset))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2436
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2437
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2438 (defun mh-map-to-seq-msgs (func seq &rest args)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2439 ;; Invoke the FUNCTION at each message in the SEQUENCE, passing the
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2440 ;; remaining ARGS as arguments.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2441 (save-excursion
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2442 (let ((msgs (mh-seq-to-msgs seq)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2443 (while msgs
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2444 (if (mh-goto-msg (car msgs) t t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2445 (apply func (car msgs) args))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2446 (setq msgs (cdr msgs))))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2447
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2448
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2449 (defun mh-map-over-seqs (func seq-list)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2450 ;; Apply the FUNCTION to each element in the list of SEQUENCES,
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2451 ;; passing the sequence name and the list of messages as arguments.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2452 (while seq-list
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2453 (funcall func (mh-seq-name (car seq-list)) (mh-seq-msgs (car seq-list)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2454 (setq seq-list (cdr seq-list))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2455
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2456
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2457 (defun mh-define-sequences (seq-list)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2458 ;; Define the sequences in SEQ-LIST.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2459 (mh-map-over-seqs 'mh-define-sequence seq-list))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2460
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2461
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2462 (defun mh-add-to-sequence (seq msgs)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2463 ;; Add to a SEQUENCE each message the list of MSGS.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2464 (if (not (mh-folder-name-p seq))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2465 (if msgs
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2466 (apply 'mh-exec-cmd "mark" mh-current-folder
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2467 "-sequence" (symbol-name seq)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2468 "-add" msgs))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2469
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2470
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2471 (defun mh-define-sequence (seq msgs)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2472 ;; Define the SEQUENCE to contain the list of MSGS. Do not mark
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2473 ;; pseudo-sequences or empty sequences.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2474 (if (and msgs
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2475 (not (mh-folder-name-p seq)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2476 (save-excursion
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2477 (apply 'mh-exec-cmd "mark" mh-current-folder
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2478 "-sequence" (symbol-name seq)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2479 "-add" "-zero" (mh-list-to-string msgs)))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2480
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2481
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2482 (defun mh-undefine-sequence (seq msgs)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2483 ;; Remove from the SEQUENCE the list of MSGS.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2484 (apply 'mh-exec-cmd "mark" mh-current-folder
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2485 "-sequence" (symbol-name seq)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2486 "-delete" msgs))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2487
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2488
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2489 (defun mh-copy-seq-to-point (seq location)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2490 ;; Copy the scan listing of the messages in SEQUENCE to after the point
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2491 ;; LOCATION in the current buffer.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2492 (mh-map-to-seq-msgs 'mh-copy-line-to-point seq location))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2493
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2494
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2495 (defun mh-copy-line-to-point (msg location)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2496 ;; Copy the current line to the LOCATION in the current buffer.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2497 (beginning-of-line)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2498 (let ((beginning-of-line (point)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2499 (forward-line 1)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2500 (copy-region-as-kill beginning-of-line (point))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2501 (goto-char location)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2502 (yank)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2503 (goto-char beginning-of-line)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2504
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2505
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2506
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2507 ;;; Issue commands to MH.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2508
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2509 (defun mh-exec-cmd (command &rest args)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2510 ;; Execute MH command COMMAND with ARGS.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2511 ;; Any output is assumed to be an error and is shown to the user.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2512 (save-excursion
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2513 (set-buffer " *mh-temp*")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2514 (erase-buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2515 (apply 'call-process
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2516 (expand-file-name command mh-progs) nil t nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2517 (mh-list-to-string args))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2518 (if (> (buffer-size) 0)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2519 (save-window-excursion
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2520 (switch-to-buffer-other-window " *mh-temp*")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2521 (sit-for 5)))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2522
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2523
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2524 (defun mh-exec-cmd-quiet (buffer command &rest args)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2525 ;; In BUFFER, execute MH command COMMAND with ARGS.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2526 ;; ARGS is a list of strings. Return in BUFFER, if one exists.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2527 (mh-when (stringp buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2528 (set-buffer buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2529 (erase-buffer))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2530 (apply 'call-process
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2531 (expand-file-name command mh-progs) nil buffer nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2532 args))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2533
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2534
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2535 (defun mh-exec-cmd-output (command display &rest args)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2536 ;; Execute MH command COMMAND with DISPLAY flag and ARGS putting the output
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2537 ;; into buffer after point. Set mark after inserted text.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2538 (push-mark (point) t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2539 (apply 'call-process
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2540 (expand-file-name command mh-progs) nil t display
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2541 (mh-list-to-string args))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2542 (exchange-point-and-mark))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2543
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2544
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2545 (defun mh-exec-cmd-daemon (command &rest args)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2546 ;; Execute MH command COMMAND with ARGS. Any output from command is
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2547 ;; displayed in an asynchronous pop-up window.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2548 (save-excursion
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2549 (set-buffer (get-buffer-create " *mh-temp*"))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2550 (erase-buffer))
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
2551 (let* ((process-connection-type nil)
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
2552 (process (apply 'start-process
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
2553 command nil
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
2554 (expand-file-name command mh-progs)
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
2555 (mh-list-to-string args))))
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2556 (set-process-filter process 'mh-process-daemon)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2557
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2558
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2559 (defun mh-process-daemon (process output)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2560 ;; Process daemon that puts output into a temporary buffer.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2561 (set-buffer (get-buffer-create " *mh-temp*"))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2562 (insert-before-markers output)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2563 (display-buffer " *mh-temp*"))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2564
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2565
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2566 (defun mh-exec-lib-cmd-output (command &rest args)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2567 ;; Execute MH library command COMMAND with ARGS.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2568 ;; Put the output into buffer after point. Set mark after inserted text.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2569 (push-mark (point) t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2570 (apply 'call-process
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2571 (expand-file-name command mh-lib) nil t nil
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2572 (mh-list-to-string args))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2573 (exchange-point-and-mark))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2574
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2575
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2576 (defun mh-list-to-string (l)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2577 ;; Flattens the list L and makes every element of the new list into a string.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2578 (let ((new-list nil))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2579 (while l
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2580 (cond ((null (car l)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2581 ((symbolp (car l)) (mh-push (symbol-name (car l)) new-list))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2582 ((numberp (car l)) (mh-push (int-to-string (car l)) new-list))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2583 ((equal (car l) ""))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2584 ((stringp (car l)) (mh-push (car l) new-list))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2585 ((listp (car l))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2586 (setq new-list (nconc (nreverse (mh-list-to-string (car l)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2587 new-list)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2588 (t (error "Bad element in mh-list-to-string: %s" (car l))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2589 (setq l (cdr l)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2590 (nreverse new-list)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2591
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2592
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2593
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2594 ;;; Commands to annotate a message.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2595
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2596 (defun mh-annotate-msg (msg buffer note &rest args)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2597 ;; Mark the MESSAGE in BUFFER listing with the character NOTE and annotate
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2598 ;; the saved message with ARGS.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2599 (apply 'mh-exec-cmd "anno" buffer msg args)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2600 (save-excursion
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2601 (cond ((get-buffer buffer) ; Buffer may be deleted
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2602 (set-buffer buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2603 (if (symbolp msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2604 (mh-notate-seq msg note (1+ mh-cmd-note))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2605 (mh-notate msg note (1+ mh-cmd-note)))))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2606
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2607
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2608 (defun mh-notate (msg notation offset)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2609 ;; Marks MESSAGE with the character NOTATION at position OFFSET.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2610 ;; Null MESSAGE means the message that the cursor points to.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2611 (save-excursion
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2612 (if (or (null msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2613 (mh-goto-msg msg t t))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2614 (with-mh-folder-updating (t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2615 (beginning-of-line)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2616 (forward-char offset)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2617 (delete-char 1)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2618 (insert notation)))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2619
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2620
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2621
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2622 ;;; User prompting commands.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2623
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2624 (defun mh-prompt-for-folder (prompt default can-create)
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
2625 ;; Prompt for a folder name with PROMPT. Returns the folder's name as a
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
2626 ;; string. DEFAULT is used if the folder exists and the user types return.
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
2627 ;; If the CAN-CREATE flag is t, then a non-existent folder is made.
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2628 (let* ((prompt (format "%s folder%s" prompt
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2629 (if (equal "" default)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2630 "? "
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2631 (format " [%s]? " default))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2632 name)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2633 (if (null mh-folder-list)
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
2634 (mh-set-folder-list))
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2635 (while (and (setq name (completing-read prompt mh-folder-list
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2636 nil nil "+"))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2637 (equal name "")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2638 (equal default "")))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2639 (cond ((or (equal name "") (equal name "+"))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2640 (setq name default))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2641 ((not (mh-folder-name-p name))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2642 (setq name (format "+%s" name))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2643 (let ((new-file-p (not (file-exists-p (mh-expand-file-name name)))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2644 (cond ((and new-file-p
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2645 (y-or-n-p
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2646 (format "Folder %s does not exist. Create it? " name)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2647 (message "Creating %s" name)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2648 (call-process "mkdir" nil nil nil (mh-expand-file-name name))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2649 (message "Creating %s...done" name)
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
2650 (mh-push (list name) mh-folder-list))
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2651 (new-file-p
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2652 (error "Folder %s is not created" name))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2653 (t
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2654 (mh-when (null (assoc name mh-folder-list))
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
2655 (mh-push (list name) mh-folder-list)))))
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2656 name))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2657
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2658
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
2659 (defun mh-set-folder-list ()
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
2660 "Sets mh-folder-list correctly.
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
2661 A useful function for the command line or for when you need to sync by hand."
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
2662 (setq mh-folder-list (mh-make-folder-list)))
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
2663
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
2664
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2665 (defun mh-make-folder-list ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2666 "Return a list of the user's folders.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2667 Result is in a form suitable for completing read."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2668 (interactive)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2669 (message "Collecting folder names...")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2670 (save-window-excursion
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2671 (mh-exec-cmd-quiet " *mh-temp*" "folders" "-fast"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2672 (if mh-recursive-folders
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2673 "-recurse"
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2674 "-norecurse"))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2675 (goto-char (point-min))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2676 (let ((list nil)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2677 start)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2678 (while (not (eobp))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2679 (setq start (point))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2680 (forward-line 1)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2681 (mh-push (list (format "+%s" (buffer-substring start (1- (point)))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2682 list))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2683 (message "Collecting folder names...done")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2684 list)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2685
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2686
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2687 (defun mh-remove-folder-from-folder-list (folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2688 ;; Remove FOLDER from the list of folders.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2689 (setq mh-folder-list
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2690 (delq (assoc folder mh-folder-list) mh-folder-list)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2691
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2692
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2693 (defun mh-read-msg-range (prompt)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2694 ;; Read a list of blank-separated items.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2695 (let* ((buf (read-string prompt))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2696 (buf-size (length buf))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2697 (start 0)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2698 (input ()))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2699 (while (< start buf-size)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2700 (let ((next (read-from-string buf start buf-size)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2701 (mh-push (car next) input)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2702 (setq start (cdr next))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2703 (nreverse input)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2704
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2705
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2706
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2707 ;;; Misc. functions.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2708
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2709 (defun mh-get-msg-num (error-if-no-message)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2710 ;; Return the message number of the displayed message. If the argument
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2711 ;; ERROR-IF-NO-MESSAGE is non-nil, then complain if the cursor is not
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2712 ;; pointing to a message.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2713 (save-excursion
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2714 (beginning-of-line)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2715 (cond ((looking-at mh-msg-number-regexp)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2716 (string-to-int (buffer-substring (match-beginning 1)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2717 (match-end 1))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2718 (error-if-no-message
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2719 (error "Cursor not pointing to message"))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2720 (t nil))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2721
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2722
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2723 (defun mh-msg-search-pat (n)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2724 ;; Return a search pattern for message N in the scan listing.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2725 (format mh-msg-search-regexp n))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2726
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2727
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2728 (defun mh-msg-filename (msg &optional folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2729 ;; Return the file name of MESSAGE in FOLDER (default current folder).
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2730 (expand-file-name (int-to-string msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2731 (if folder
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2732 (mh-expand-file-name folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2733 mh-folder-filename)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2734
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2735
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2736 (defun mh-msg-filenames (msgs &optional folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2737 ;; Return a list of file names for MSGS in FOLDER (default current folder).
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2738 (mapconcat (function (lambda (msg) (mh-msg-filename msg folder))) msgs " "))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2739
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2740
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2741 (defun mh-expand-file-name (filename &optional default)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2742 "Just like `expand-file-name', but also handles MH folder names.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2743 Assumes that any filename that starts with '+' is a folder name."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2744 (if (mh-folder-name-p filename)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2745 (expand-file-name (substring filename 1) mh-user-path)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2746 (expand-file-name filename default)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2747
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2748
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2749 (defun mh-find-path ()
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2750 ;; Set mh-user-path, mh-draft-folder, and mh-unseen-seq from profile file.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2751 (save-excursion
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2752 ;; Be sure profile is fully expanded before switching buffers
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2753 (let ((profile (expand-file-name (or (getenv "MH") "~/.mh_profile"))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2754 (if (not (file-exists-p profile))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2755 (error "Cannot find MH profile %s" profile))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2756 (set-buffer (get-buffer-create " *mh-temp*"))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2757 (erase-buffer)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2758 (insert-file-contents profile)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2759 (setq mh-draft-folder (mh-get-field "Draft-Folder:"))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2760 (cond ((equal mh-draft-folder "")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2761 (setq mh-draft-folder nil))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2762 ((not (mh-folder-name-p mh-draft-folder))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2763 (setq mh-draft-folder (format "+%s" mh-draft-folder))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2764 (setq mh-user-path (mh-get-field "Path:"))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2765 (if (equal mh-user-path "")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2766 (setq mh-user-path "Mail"))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2767 (setq mh-user-path
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2768 (file-name-as-directory
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2769 (expand-file-name mh-user-path (expand-file-name "~"))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2770 (if (and mh-draft-folder
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2771 (not (file-exists-p (mh-expand-file-name mh-draft-folder))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2772 (error "Draft folder %s does not exist. Create it and try again."
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2773 mh-draft-folder))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2774 (setq mh-unseen-seq (mh-get-field "Unseen-Sequence:"))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2775 (if (equal mh-unseen-seq "")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2776 (setq mh-unseen-seq 'unseen)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2777 (setq mh-unseen-seq (intern mh-unseen-seq))))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2778
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2779
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2780 (defun mh-get-field (field)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2781 ;; Find and return the value of field FIELD in the current buffer.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2782 ;; Returns the empty string if the field is not in the message.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2783 (let ((case-fold-search t))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2784 (goto-char (point-min))
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
2785 (cond ((not (re-search-forward (format "^%s" field) nil t)) "")
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2786 ((looking-at "[\t ]*$") "")
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2787 (t
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2788 (re-search-forward "[\t ]*\\([^\t \n].*\\)$" nil t)
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
2789 (let ((start (match-beginning 1)))
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
2790 (forward-line 1)
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
2791 (while (looking-at "[ \t]")
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
2792 (forward-line 1))
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
2793 (buffer-substring start (1- (point))))))))
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2794
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2795
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2796 (defun mh-insert-fields (&rest name-values)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2797 ;; Insert the NAME-VALUE pairs in the current buffer.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2798 ;; Do not insert any pairs whose value is the empty string.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2799 (let ((case-fold-search t))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2800 (while name-values
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2801 (let ((field-name (car name-values))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2802 (value (car (cdr name-values))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2803 (mh-when (not (equal value ""))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2804 (goto-char (point-min))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2805 (cond ((not (re-search-forward (format "^%s" field-name) nil t))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2806 (mh-goto-header-end 0)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2807 (insert field-name " " value "\n"))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2808 (t
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2809 (end-of-line)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2810 (insert " " value))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2811 (setq name-values (cdr (cdr name-values)))))))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2812
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2813
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2814 (defun mh-position-on-field (field set-mark)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2815 ;; Set point to the end of the line beginning with FIELD.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2816 ;; Set the mark to the old value of point, if SET-MARK is non-nil.
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
2817 ;; Returns non-nil iff the field was found.
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2818 (let ((case-fold-search t))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2819 (if set-mark (push-mark))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2820 (goto-char (point-min))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2821 (mh-goto-header-end 0)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2822 (if (re-search-backward (format "^%s" field) nil t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2823 (progn (end-of-line) t)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2824 nil)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2825
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2826
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2827 (defun mh-goto-header-end (arg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2828 ;; Find the end of the message header in the current buffer and position
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2829 ;; the cursor at the ARG'th newline after the header.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2830 (if (re-search-forward "^$\\|^-+$" nil nil)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2831 (forward-line arg)))
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2832
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2833
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2834
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2835 ;;; Build the folder-mode keymap:
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2836
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2837 (suppress-keymap mh-folder-mode-map)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2838 (define-key mh-folder-mode-map "q" 'mh-quit)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2839 (define-key mh-folder-mode-map "b" 'mh-quit)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2840 (define-key mh-folder-mode-map "?" 'mh-msg-is-in-seq)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2841 (define-key mh-folder-mode-map "%" 'mh-put-msg-in-seq)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2842 (define-key mh-folder-mode-map "|" 'mh-pipe-msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2843 (define-key mh-folder-mode-map "\ea" 'mh-edit-again)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2844 (define-key mh-folder-mode-map "\e%" 'mh-delete-msg-from-seq)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2845 (define-key mh-folder-mode-map "\C-xn" 'mh-narrow-to-seq)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2846 (define-key mh-folder-mode-map "\C-xw" 'mh-widen)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2847 (define-key mh-folder-mode-map "\eb" 'mh-burst-digest)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2848 (define-key mh-folder-mode-map "\eu" 'mh-undo-folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2849 (define-key mh-folder-mode-map "\e " 'mh-page-digest)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2850 (define-key mh-folder-mode-map "\e\177" 'mh-page-digest-backwards)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2851 (define-key mh-folder-mode-map "\ee" 'mh-extract-rejected-mail)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2852 (define-key mh-folder-mode-map "\ef" 'mh-visit-folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2853 (define-key mh-folder-mode-map "\ek" 'mh-kill-folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2854 (define-key mh-folder-mode-map "\el" 'mh-list-folders)
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
2855 (define-key mh-folder-mode-map "\en" 'mh-unshar-msg)
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2856 (define-key mh-folder-mode-map "\eo" 'mh-write-msg-to-file)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2857 (define-key mh-folder-mode-map "\ep" 'mh-pack-folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2858 (define-key mh-folder-mode-map "\es" 'mh-search-folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2859 (define-key mh-folder-mode-map "\er" 'mh-rescan-folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2860 (define-key mh-folder-mode-map "l" 'mh-print-msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2861 (define-key mh-folder-mode-map "t" 'mh-toggle-showing)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2862 (define-key mh-folder-mode-map "c" 'mh-copy-msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2863 (define-key mh-folder-mode-map ">" 'mh-write-msg-to-file)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2864 (define-key mh-folder-mode-map "i" 'mh-inc-folder)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2865 (define-key mh-folder-mode-map "x" 'mh-execute-commands)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2866 (define-key mh-folder-mode-map "e" 'mh-execute-commands)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2867 (define-key mh-folder-mode-map "r" 'mh-redistribute)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2868 (define-key mh-folder-mode-map "f" 'mh-forward)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2869 (define-key mh-folder-mode-map "s" 'mh-send)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2870 (define-key mh-folder-mode-map "m" 'mh-send)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2871 (define-key mh-folder-mode-map "a" 'mh-reply)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2872 (define-key mh-folder-mode-map "j" 'mh-goto-msg)
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
2873 (define-key mh-folder-mode-map "<" 'mh-first-msg)
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2874 (define-key mh-folder-mode-map "g" 'mh-goto-msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2875 (define-key mh-folder-mode-map "\177" 'mh-previous-page)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2876 (define-key mh-folder-mode-map " " 'mh-page-msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2877 (define-key mh-folder-mode-map "." 'mh-show)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2878 (define-key mh-folder-mode-map "u" 'mh-undo)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2879 (define-key mh-folder-mode-map "!" 'mh-refile-or-write-again)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2880 (define-key mh-folder-mode-map "^" 'mh-refile-msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2881 (define-key mh-folder-mode-map "d" 'mh-delete-msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2882 (define-key mh-folder-mode-map "\C-d" 'mh-delete-msg-no-motion)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2883 (define-key mh-folder-mode-map "p" 'mh-previous-undeleted-msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2884 (define-key mh-folder-mode-map "n" 'mh-next-undeleted-msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2885 (define-key mh-folder-mode-map "o" 'mh-refile-msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2886
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2887
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2888 ;;; Build the letter-mode keymap:
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2889
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2890 (define-key mh-letter-mode-map "\C-c\C-f\C-b" 'mh-to-field)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2891 (define-key mh-letter-mode-map "\C-c\C-f\C-c" 'mh-to-field)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2892 (define-key mh-letter-mode-map "\C-c\C-f\C-f" 'mh-to-fcc)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2893 (define-key mh-letter-mode-map "\C-c\C-f\C-s" 'mh-to-field)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2894 (define-key mh-letter-mode-map "\C-c\C-f\C-t" 'mh-to-field)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2895 (define-key mh-letter-mode-map "\C-c\C-fb" 'mh-to-field)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2896 (define-key mh-letter-mode-map "\C-c\C-fc" 'mh-to-field)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2897 (define-key mh-letter-mode-map "\C-c\C-ff" 'mh-to-fcc)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2898 (define-key mh-letter-mode-map "\C-c\C-fs" 'mh-to-field)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2899 (define-key mh-letter-mode-map "\C-c\C-ft" 'mh-to-field)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2900 (define-key mh-letter-mode-map "\C-c\C-q" 'mh-fully-kill-draft)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2901 (define-key mh-letter-mode-map "\C-c\C-w" 'mh-check-whom)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2902 (define-key mh-letter-mode-map "\C-c\C-i" 'mh-insert-letter)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2903 (define-key mh-letter-mode-map "\C-c\C-y" 'mh-yank-cur-msg)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2904 (define-key mh-letter-mode-map "\C-c\C-s" 'mh-insert-signature)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2905 (define-key mh-letter-mode-map "\C-c\C-c" 'mh-send-letter)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2906
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2907
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2908 ;;; Build the pick-mode keymap:
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2909
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2910 (define-key mh-pick-mode-map "\C-c\C-c" 'mh-do-pick-search)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2911 (define-key mh-pick-mode-map "\C-c\C-f\C-b" 'mh-to-field)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2912 (define-key mh-pick-mode-map "\C-c\C-f\C-c" 'mh-to-field)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2913 (define-key mh-pick-mode-map "\C-c\C-f\C-f" 'mh-to-field)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2914 (define-key mh-pick-mode-map "\C-c\C-f\C-s" 'mh-to-field)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2915 (define-key mh-pick-mode-map "\C-c\C-f\C-t" 'mh-to-field)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2916 (define-key mh-pick-mode-map "\C-c\C-fb" 'mh-to-field)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2917 (define-key mh-pick-mode-map "\C-c\C-fc" 'mh-to-field)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2918 (define-key mh-pick-mode-map "\C-c\C-ff" 'mh-to-field)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2919 (define-key mh-pick-mode-map "\C-c\C-fs" 'mh-to-field)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2920 (define-key mh-pick-mode-map "\C-c\C-ft" 'mh-to-field)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2921 (define-key mh-pick-mode-map "\C-c\C-w" 'mh-check-whom)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2922
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2923
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2924
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2925 ;;; For Gnu Emacs.
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2926 ;;; Local Variables: ***
3220
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
2927 ;;; eval: (put 'mh-when 'lisp-indent-hook 1) ***
77a302be84da Version 3.8.1 from Gildea.
Richard M. Stallman <rms@gnu.org>
parents: 2349
diff changeset
2928 ;;; eval: (put 'with-mh-folder-updating 'lisp-indent-hook 1) ***
731
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2929 ;;; End: ***
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2930
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2931 (provide 'mh-e)
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2932
5c6db33a9ef6 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2933 ;;; mh-e.el ends here