annotate lisp/=mh-e.el @ 1176:60e0dc538df3

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