annotate lisp/=mh-e.el @ 748:4714ad36583c

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