annotate lisp/mh-e/mh-comp.el @ 147:e186c2b7192d xemacs-20-2

Added tag r20-2p1 for changeset 2af401a6ecca
author cvs
date Mon, 13 Aug 2007 09:34:48 +0200
parents 34a5b81f86ba
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; mh-comp --- mh-e functions for composing messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; Time-stamp: <95/08/19 17:48:59 gildea>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Copyright (C) 1993, 1995 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; This file is part of mh-e, part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; along with GNU Emacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; Internal support for mh-e package.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; Change Log:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
28 ;; $Id: mh-comp.el,v 1.2 1997/04/19 23:21:00 steve Exp $
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (provide 'mh-comp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (require 'mh-utils)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;; Site customization (see also mh-utils.el):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
37 (defgroup mh-compose nil
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
38 "Mh-e functions for composing messages"
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
39 :prefix "mh-"
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
40 :group 'mh)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
41
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
42
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (defvar mh-send-prog "send"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 "Name of the MH send program.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 Some sites need to change this because of a name conflict.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (defvar mh-redist-full-contents nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 "Non-nil if the `dist' command needs whole letter for redistribution.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 This is the case only when `send' is compiled with the BERK option.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 If MH will not allow you to redist a previously redist'd msg, set to nil.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (defvar mh-note-repl "-"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 "String whose first character is used to notate replied to messages.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (defvar mh-note-forw "F"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 "String whose first character is used to notate forwarded messages.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (defvar mh-note-dist "R"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 "String whose first character is used to notate redistributed messages.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (defvar mh-yank-hooks nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 "Obsolete hook for modifying a citation just inserted in the mail buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 Each hook function can find the citation between point and mark.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 And each hook function should leave point and mark around the citation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 text as modified.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 This is a normal hook, misnamed for historical reasons.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 It is semi-obsolete and is only used if mail-citation-hook is nil.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (defvar mail-citation-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 "*Hook for modifying a citation just inserted in the mail buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 Each hook function can find the citation between point and mark.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 And each hook function should leave point and mark around the citation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 text as modified.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 If this hook is entirely empty (nil), the text of the message is inserted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 with mh-ins-buf-prefix prefixed to each line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 See also the variable mh-yank-from-start-of-msg, which controls how
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 much of the message passed to the hook.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;;; Copied from sendmail.el for Hyperbole
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (defvar mail-header-separator "--------"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 "*Line used by MH to separate headers from text in messages being composed.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;;; Personal preferences:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
89 (defcustom mh-delete-yanked-msg-window nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 "*Controls window display when a message is yanked by \\<mh-letter-mode-map>\\[mh-yank-cur-msg].
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 If non-nil, yanking the current message into a draft letter deletes any
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
92 windows displaying the message."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
93 :type 'boolean
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
94 :group 'mh-compose)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
96 (defcustom mh-yank-from-start-of-msg t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 "*Controls which part of a message is yanked by \\<mh-letter-mode-map>\\[mh-yank-cur-msg].
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 If non-nil, include the entire message. If the symbol `body', then yank the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 message minus the header. If nil, yank only the portion of the message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 following the point. If the show buffer has a region, this variable is
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
101 ignored."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
102 :type '(choice (const t) (const nil) (const body))
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
103 :group 'mh-compose)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
105 (defcustom mh-ins-buf-prefix "> "
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 "*String to put before each non-blank line of a yanked or inserted message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 \\<mh-letter-mode-map>Used when the message is inserted into an outgoing letter
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
108 by \\[mh-insert-letter] or \\[mh-yank-cur-msg]."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
109 :type 'string
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
110 :group 'mh-compose)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
112 (defcustom mh-reply-default-reply-to nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 "*Sets the person or persons to whom a reply will be sent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 If nil, prompt for recipient. If non-nil, then \\<mh-folder-mode-map>`\\[mh-reply]' will use this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 value and it should be one of \"from\", \"to\", \"cc\", or \"all\".
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
116 The values \"cc\" and \"all\" do the same thing."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
117 :type '(choice (const :tag "Prompt" nil)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
118 (const "from") (const "to")
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
119 (const "cc") (const "all"))
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
120 :group 'mh-compose)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
122 (defcustom mh-signature-file-name "~/.signature"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 "*Name of file containing the user's signature.
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
124 Inserted into message by \\<mh-letter-mode-map>\\[mh-insert-signature]."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
125 :type 'file
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
126 :group 'mh-compose)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
128 (defcustom mh-forward-subject-format "%s: %s"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 "*Format to generate the Subject: line contents for a forwarded message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 The two string arguments to the format are the sender of the original
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
131 message and the original subject line."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
132 :type 'string
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
133 :group 'mh-compose)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (defvar mh-comp-formfile "components"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 "Name of file to be used as a skeleton for composing messages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 Default is \"components\". If not a complete path name, the file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 is searched for first in the user's MH directory, then in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 system MH lib directory.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (defvar mh-repl-formfile "replcomps"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 "Name of file to be used as a skeleton for replying to messages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 Default is \"replcomps\". If not a complete path name, the file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 is searched for first in the user's MH directory, then in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 system MH lib directory.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ;;; Hooks:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
149 (defcustom mh-letter-mode-hook nil
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
150 "Invoked in `mh-letter-mode' on a new letter."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
151 :type 'hook
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
152 :group 'mh-compose)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
154 (defcustom mh-compose-letter-function nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 "Invoked when setting up a letter draft.
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
156 It is passed three arguments: TO recipients, SUBJECT, and CC recipients."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
157 :type 'function
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
158 :group 'mh-compose)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
160 (defcustom mh-before-send-letter-hook nil
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
161 "Invoked at the beginning of the \\<mh-letter-mode-map>\\[mh-send-letter] command."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
162 :type 'hook
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 70
diff changeset
163 :group 'mh-compose)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (defvar mh-rejected-letter-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (concat "^ ----- Unsent message follows -----$" ;from sendmail V5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 "\\|^ ----- Original message follows -----$" ;from sendmail V8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 "\\|^------- Unsent Draft$" ;from MH itself
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 "\\|^---------- Original Message ----------$" ;from zmailer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 "\\|^ --- The unsent message follows ---$" ;from AIX mail system
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 "\\|^ Your message follows:$" ;from MMDF-II
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 "\\|^Content-Description: Returned Content$" ;1993 KJ sendmail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 "Regexp specifying the beginning of the wrapper around a returned letter.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 This wrapper is generated by the mail system when rejecting a letter.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (defvar mh-new-draft-cleaned-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 "^Date:\\|^Received:\\|^Message-Id:\\|^From:\\|^Sender:\\|^Errors-To:\\|^Delivery-Date:\\|^Return-Path:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 "Regexp of header lines to remove before offering a message as a new draft.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 Used by the \\<mh-folder-mode-map>`\\[mh-edit-again]' and `\\[mh-extract-rejected-mail]' commands.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (defvar mh-to-field-choices '(("t" . "To:") ("s" . "Subject:") ("c" . "Cc:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ("b" . "Bcc:") ("f" . "Fcc:") ("r" . "From:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ("d" . "Dcc:"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 "Alist of (final-character . field-name) choices for mh-to-field.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (defvar mh-letter-mode-map (copy-keymap text-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 "Keymap for composing mail.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (defvar mh-letter-mode-syntax-table nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 "Syntax table used by mh-e while in MH-Letter mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (if mh-letter-mode-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (setq mh-letter-mode-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (make-syntax-table text-mode-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (modify-syntax-entry ?% "." mh-letter-mode-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (defun mh-smail ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 "Compose and send mail with the MH mail system.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 This function is an entry point to mh-e, the Emacs front end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 to the MH mail system.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 See documentation of `\\[mh-send]' for more details on composing mail."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (mh-find-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (call-interactively 'mh-send))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (defvar mh-error-if-no-draft nil) ;raise error over using old draft
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (defun mh-smail-batch ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 "Set up a mail composition draft with the MH mail system.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 This function is an entry point to mh-e, the Emacs front end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 to the MH mail system. This function does not prompt the user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 for any header fields, and thus is suitable for use by programs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 that want to create a mail buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 Users should use `\\[mh-smail]' to compose mail."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (mh-find-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (let ((mh-error-if-no-draft t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (mh-send "" "" "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (defun mh-edit-again (msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 "Clean-up a draft or a message previously sent and make it resendable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 Default is the current message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 The variable mh-new-draft-cleaned-headers specifies the headers to remove.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 See also documentation for `\\[mh-send]' function."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (interactive (list (mh-get-msg-num t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (let* ((from-folder mh-current-folder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (config (current-window-configuration))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (draft
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (cond ((and mh-draft-folder (equal from-folder mh-draft-folder))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (pop-to-buffer (find-file-noselect (mh-msg-filename msg)) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (rename-buffer (format "draft-%d" msg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (buffer-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (mh-read-draft "clean-up" (mh-msg-filename msg) nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (mh-clean-msg-header (point-min) mh-new-draft-cleaned-headers nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (save-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (mh-compose-and-send-mail draft "" from-folder nil nil nil nil nil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 config)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (defun mh-extract-rejected-mail (msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 "Extract a letter returned by the mail system and make it resendable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 Default is the current message. The variable mh-new-draft-cleaned-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 gives the headers to clean out of the original message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 See also documentation for `\\[mh-send]' function."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (interactive (list (mh-get-msg-num t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (let ((from-folder mh-current-folder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (config (current-window-configuration))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (draft (mh-read-draft "extraction" (mh-msg-filename msg) nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (cond ((re-search-forward mh-rejected-letter-start nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (skip-chars-forward " \t\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (delete-region (point-min) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (mh-clean-msg-header (point-min) mh-new-draft-cleaned-headers nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (message "Does not appear to be a rejected letter.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (save-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (mh-compose-and-send-mail draft "" from-folder msg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (mh-get-header-field "To:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (mh-get-header-field "From:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (mh-get-header-field "Cc:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 nil nil config)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (defun mh-forward (to cc &optional msg-or-seq)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 "Forward a message or message sequence. Defaults to displayed message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 If optional prefix argument provided, then prompt for the message sequence.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 See also documentation for `\\[mh-send]' function."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (interactive (list (mh-read-address "To: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (mh-read-address "Cc: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (if current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (mh-read-seq-default "Forward" t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (mh-get-msg-num t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (or msg-or-seq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (setq msg-or-seq (mh-get-msg-num t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (let* ((folder mh-current-folder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (config (current-window-configuration))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 ;; forw always leaves file in "draft" since it doesn't have -draft
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (draft-name (expand-file-name "draft" mh-user-path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (draft (cond ((or (not (file-exists-p draft-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (y-or-n-p "The file 'draft' exists. Discard it? "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (mh-exec-cmd "forw" "-build"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 mh-current-folder msg-or-seq)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (mh-read-draft "" draft-name t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (mh-insert-fields "To:" to "Cc:" cc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (save-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (mh-read-draft "" draft-name nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (let (orig-from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 orig-subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (re-search-forward "^------- Forwarded Message")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (skip-chars-forward " \t\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (narrow-to-region (point) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (setq orig-from (mh-get-header-field "From:"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (setq orig-subject (mh-get-header-field "Subject:")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (let ((forw-subject
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (mh-forwarded-letter-subject orig-from orig-subject)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (mh-insert-fields "Subject:" forw-subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (re-search-forward "^------- Forwarded Message")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (delete-other-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (if (numberp msg-or-seq)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (mh-add-msgs-to-seq msg-or-seq 'forwarded t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (mh-add-msgs-to-seq (mh-seq-to-msgs msg-or-seq) 'forwarded t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (mh-compose-and-send-mail draft "" folder msg-or-seq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 to forw-subject cc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 mh-note-forw "Forwarded:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 config)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (defun mh-forwarded-letter-subject (from subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 ;; Return a Subject suitable for a forwarded message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 ;; Original message has headers FROM and SUBJECT.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (let ((addr-start (string-match "<" from))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (comment (string-match "(" from)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (cond ((and addr-start (> addr-start 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 ;; Full Name <luser@host>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (setq from (substring from 0 (1- addr-start))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 ;; luser@host (Full Name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (setq from (substring from (1+ comment) (1- (length from)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (format mh-forward-subject-format from subject))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (defun mh-smail-other-window ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 "Compose and send mail in other window with the MH mail system.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 This function is an entry point to mh-e, the Emacs front end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 to the MH mail system.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 See documentation of `\\[mh-send]' for more details on composing mail."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (mh-find-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (call-interactively 'mh-send-other-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (defun mh-redistribute (to cc &optional msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 "Redistribute a letter.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 Depending on how your copy of MH was compiled, you may need to change the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 setting of the variable mh-redist-full-contents. See its documentation."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (interactive (list (mh-read-address "Redist-To: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (mh-read-address "Redist-Cc: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (mh-get-msg-num t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (or msg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (setq msg (mh-get-msg-num t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (let ((folder mh-current-folder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (draft (mh-read-draft "redistribution"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (if mh-redist-full-contents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (mh-msg-filename msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (mh-goto-header-end 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (insert "Resent-To: " to "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (if (not (equal cc "")) (insert "Resent-cc: " cc "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (mh-clean-msg-header (point-min)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 "^Message-Id:\\|^Received:\\|^Return-Path:\\|^Sender:\\|^Date:\\|^From:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (save-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (message "Redistributing...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (if mh-redist-full-contents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (call-process "/bin/sh" nil 0 nil "-c"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (format "mhdist=1 mhaltmsg=%s %s -push %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (expand-file-name mh-send-prog mh-progs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (call-process "/bin/sh" nil 0 nil "-c"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (format "mhdist=1 mhaltmsg=%s mhannotate=1 %s -push %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (mh-msg-filename msg folder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (expand-file-name mh-send-prog mh-progs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (mh-annotate-msg msg folder mh-note-dist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 "-component" "Resent:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 "-text" (format "\"%s %s\"" to cc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (kill-buffer draft)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (message "Redistributing...done"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (defun mh-reply (message &optional includep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 "Reply to MESSAGE (default: current message).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 If optional prefix argument INCLUDEP provided, then include the message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 in the reply using filter mhl.reply in your MH directory.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 Prompts for type of addresses to reply to:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 from sender only,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 to sender and primary recipients,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 cc/all sender and all recipients.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 If the file named by `mh-repl-formfile' exists, it is used as a skeleton
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 for the reply. See also documentation for `\\[mh-send]' function."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (interactive (list (mh-get-msg-num t) current-prefix-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (let ((minibuffer-help-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 "from => Sender only\nto => Sender and primary recipients\ncc or all => Sender and all recipients"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (let ((reply-to (or mh-reply-default-reply-to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (completing-read "Reply to whom: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 '(("from") ("to") ("cc") ("all"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (folder mh-current-folder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (show-buffer mh-show-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (config (current-window-configuration)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (message "Composing a reply...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (mh-exec-cmd "repl" "-build" "-noquery" "-nodraftfolder"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (if (stringp mh-repl-formfile) ;must be string, but we're paranoid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (list "-form" mh-repl-formfile))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 mh-current-folder message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (cond ((or (equal reply-to "from") (equal reply-to ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 '("-nocc" "all"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 ((equal reply-to "to")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 '("-cc" "to"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 ((or (equal reply-to "cc") (equal reply-to "all"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 '("-cc" "all" "-nocc" "me")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (if includep
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 '("-filter" "mhl.reply")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (let ((draft (mh-read-draft "reply"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (expand-file-name "reply" mh-user-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (delete-other-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (save-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (let ((to (mh-get-header-field "To:"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (subject (mh-get-header-field "Subject:"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (cc (mh-get-header-field "Cc:")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (mh-goto-header-end 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (or includep
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (mh-in-show-buffer (show-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (mh-display-msg message folder)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (mh-add-msgs-to-seq message 'answered t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (message "Composing a reply...done")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (mh-compose-and-send-mail draft "" folder message to subject cc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 mh-note-repl "Replied:" config))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (defun mh-send (to cc subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 "Compose and send a letter.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 The file named by `mh-comp-formfile' will be used as the form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 Do not call this function from outside mh-e; use \\[mh-smail] instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 The letter is composed in mh-letter-mode; see its documentation for more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 details. If `mh-compose-letter-function' is defined, it is called on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 draft and passed three arguments: to, subject, and cc."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (interactive (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (mh-read-address "To: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (mh-read-address "Cc: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (read-string "Subject: ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (let ((config (current-window-configuration)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (delete-other-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (mh-send-sub to cc subject config)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (defun mh-send-other-window (to cc subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 "Compose and send a letter in another window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 Do not call this function from outside mh-e;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 use \\[mh-smail-other-window] instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 See also documentation for `\\[mh-send]' function."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (interactive (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (mh-read-address "To: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (mh-read-address "Cc: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (read-string "Subject: ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (let ((pop-up-windows t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (mh-send-sub to cc subject (current-window-configuration))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (defun mh-send-sub (to cc subject config)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 ;; Do the real work of composing and sending a letter.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 ;; Expects the TO, CC, and SUBJECT fields as arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 ;; CONFIG is the window configuration before sending mail.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (let ((folder mh-current-folder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (msg-num (mh-get-msg-num nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (message "Composing a message...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (let ((draft (mh-read-draft
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 "message"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (let (components)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 ((file-exists-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (setq components
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (expand-file-name mh-comp-formfile mh-user-path)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 components)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 ((file-exists-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (setq components
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 (expand-file-name mh-comp-formfile mh-lib)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 components)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (error (format "Can't find components file \"%s\""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 components)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (mh-insert-fields "To:" to "Subject:" subject "Cc:" cc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (message "Composing a message...done")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (mh-compose-and-send-mail draft "" folder msg-num
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 to subject cc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 nil nil config))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (defun mh-read-draft (use initial-contents delete-contents-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 ;; Read draft file into a draft buffer and make that buffer the current one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 ;; USE is a message used for prompting about the intended use of the message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 ;; INITIAL-CONTENTS is filename that is read into an empty buffer, or NIL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 ;; if buffer should not be modified. Delete the initial-contents file if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 ;; DELETE-CONTENTS-FILE flag is set.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 ;; Returns the draft folder's name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 ;; If the draft folder facility is enabled in ~/.mh_profile, a new buffer is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 ;; used each time and saved in the draft folder. The draft file can then be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 ;; reused.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (cond (mh-draft-folder
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (let ((orig-default-dir default-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (draft-file-name (mh-new-draft-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (pop-to-buffer (generate-new-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (format "draft-%s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (file-name-nondirectory draft-file-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (insert-file-contents draft-file-name t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (file-error))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (setq default-directory orig-default-dir)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (let ((draft-name (expand-file-name "draft" mh-user-path)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (pop-to-buffer "draft") ; Create if necessary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (if (buffer-modified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (if (y-or-n-p "Draft has been modified; kill anyway? ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (error "Draft preserved")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (setq buffer-file-name draft-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (clear-visited-file-modtime)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (unlock-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (cond ((and (file-exists-p draft-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (not (equal draft-name initial-contents)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (insert-file-contents draft-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (delete-file draft-name))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (cond ((and initial-contents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (or (zerop (buffer-size))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (if (y-or-n-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (format "A draft exists. Use for %s? " use))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (if mh-error-if-no-draft
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (error "A prior draft exists."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (insert-file-contents initial-contents)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (if delete-contents-file (delete-file initial-contents))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (auto-save-mode 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (if mh-draft-folder
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (save-buffer)) ; Do not reuse draft name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (buffer-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (defun mh-new-draft-name ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 ;; Returns the pathname of folder for draft messages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (mh-exec-cmd-quiet t "mhpath" mh-draft-folder "new")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (buffer-substring (point-min) (1- (point-max)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (defun mh-annotate-msg (msg buffer note &rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 ;; Mark the MESSAGE in BUFFER listing with the character NOTE and annotate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 ;; the saved message with ARGS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (apply 'mh-exec-cmd "anno" buffer msg args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (cond ((get-buffer buffer) ; Buffer may be deleted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (if (symbolp msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (mh-notate-seq msg note (1+ mh-cmd-note))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (mh-notate msg note (1+ mh-cmd-note)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (defun mh-insert-fields (&rest name-values)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 ;; Insert the NAME-VALUE pairs in the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 ;; If field NAME exists, append VALUE to it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 ;; Do not insert any pairs whose value is the empty string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (let ((case-fold-search t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (while name-values
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (let ((field-name (car name-values))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (value (car (cdr name-values))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (cond ((equal value "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 ((mh-position-on-field field-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (insert " " value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (insert field-name " " value "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (setq name-values (cdr (cdr name-values)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (defun mh-position-on-field (field &optional ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 ;; Move to the end of the FIELD in the header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 ;; Move to end of entire header if FIELD not found.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 ;; Returns non-nil iff FIELD was found.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 ;; The optional second arg is for pre-version 4 compatibility.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (if (mh-goto-header-field field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (mh-header-field-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (defun mh-get-header-field (field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 ;; Find and return the body of FIELD in the mail header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 ;; Returns the empty string if the field is not in the header of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 ;; current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (if (mh-goto-header-field field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (skip-chars-forward " \t") ;strip leading white space in body
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (let ((start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (mh-header-field-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (buffer-substring start (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (fset 'mh-get-field 'mh-get-header-field) ;mh-e 4 compatibility
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (defun mh-goto-header-field (field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 ;; Move to FIELD in the message header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 ;; Move to the end of the FIELD name, which should end in a colon.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 ;; Returns T if found, NIL if not.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (let ((case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (headers-end (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (mh-goto-header-end 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (re-search-forward (format "^%s" field) headers-end t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 (defun mh-header-field-end ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 ;; Move to the end of the current header field.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 ;; Handles RFC 822 continuation lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (while (looking-at "^[ \t]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (backward-char 1)) ;to end of previous line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (defun mh-goto-header-end (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 ;; Find the end of the message header in the current buffer and position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 ;; the cursor at the ARG'th newline after the header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (if (re-search-forward "^-*$" nil nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (forward-line arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (defun mh-read-address (prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 ;; Read a To: or Cc: address, prompting in the minibuffer with PROMPT.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 ;; May someday do completion on aliases.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 (read-string prompt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 ;;; Mode for composing and sending a draft message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (defvar mh-sent-from-folder nil) ;Folder of msg assoc with this letter.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 (defvar mh-sent-from-msg nil) ;Number of msg assoc with this letter.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 (defvar mh-send-args nil) ;Extra args to pass to "send" command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (defvar mh-annotate-char nil) ;Character to use to annotate mh-sent-from-msg.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 (defvar mh-annotate-field nil) ;Field name for message annotation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (put 'mh-letter-mode 'mode-class 'special)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (defun mh-letter-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 "Mode for composing letters in mh-e.\\<mh-letter-mode-map>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 When you have finished composing, type \\[mh-send-letter] to send the message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 using the MH mail handling system.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 See the documentation for \\[mh-edit-mhn] for information on composing MIME
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 messages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 \\{mh-letter-mode-map}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 Variables controlling this mode (defaults in parentheses):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 mh-delete-yanked-msg-window (nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 If non-nil, \\[mh-yank-cur-msg] will delete any windows displaying
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 the yanked message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 mh-yank-from-start-of-msg (t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 If non-nil, \\[mh-yank-cur-msg] will include the entire message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 If `body', just yank the body (no header).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 If nil, only the portion of the message following the point will be yanked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 If there is a region, this variable is ignored.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 mh-ins-buf-prefix (\"> \")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 String to insert before each non-blank line of a message as it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 inserted in a draft letter.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 mh-signature-file-name (\"~/.signature\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 File to be inserted into message by \\[mh-insert-signature].
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 Upon invoking mh-letter-mode, text-mode-hook and mh-letter-mode-hook are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 invoked with no args, if those values are non-nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 (or mh-user-path (mh-find-path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 (make-local-variable 'paragraph-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (setq paragraph-start (concat "^[ \t]*[-_][-_][-_]+$\\|" paragraph-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 (make-local-variable 'paragraph-separate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 (setq paragraph-separate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 (concat "^[ \t]*[-_][-_][-_]+$\\|" paragraph-separate))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 (make-local-variable 'mh-send-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 (make-local-variable 'mh-annotate-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 (make-local-variable 'mh-annotate-field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 (make-local-variable 'mh-previous-window-config)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 (make-local-variable 'mh-sent-from-folder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 (make-local-variable 'mh-sent-from-msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 (make-local-variable 'mail-header-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (setq mail-header-separator "--------") ;for Hyperbole
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (use-local-map mh-letter-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (setq major-mode 'mh-letter-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (mh-set-mode-name "MH-Letter")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (set-syntax-table mh-letter-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 (run-hooks 'text-mode-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 ;; if text-mode-hook turned on auto-fill, tune it for messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 (cond ((and (boundp 'auto-fill-hook) auto-fill-hook) ;emacs 18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (make-local-variable 'auto-fill-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (setq auto-fill-hook 'mh-auto-fill-for-letter)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (cond ((and (boundp 'auto-fill-function) auto-fill-function) ;emacs 19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 (make-local-variable 'auto-fill-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 (setq auto-fill-function 'mh-auto-fill-for-letter)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (run-hooks 'mh-letter-mode-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 (defun mh-auto-fill-for-letter ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 ;; Auto-fill in letters treats the header specially by inserting a tab
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 ;; before continuation line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (if (mh-in-header-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 (let ((fill-prefix "\t"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 (do-auto-fill))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 (do-auto-fill)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 (defun mh-in-header-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 ;; Return non-nil if the point is in the header of a draft message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 (let ((cur-point (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 (re-search-forward "^-*$" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 (< cur-point (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 (defun mh-to-field ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 "Move point to the end of a specified header field.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 The field is indicated by the previous keystroke (the last keystroke
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 of the command) according to the list in the variable mh-to-field-choices.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 Create the field if it does not exist. Set the mark to point before moving."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 (expand-abbrev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 (let ((target (cdr (or (assoc (char-to-string (logior last-input-char ?`))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 mh-to-field-choices)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 ;; also look for a char for version 4 compat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 (assoc (logior last-input-char ?`) mh-to-field-choices))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (case-fold-search t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (push-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (cond ((mh-position-on-field target)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (let ((eol (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 (delete-region (point) eol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 (if (and (not (eq (logior last-input-char ?`) ?s))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 (backward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 (not (looking-at "[:,]"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 (insert ", ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 (insert " ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 (if (mh-position-on-field "To:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 (insert (format "%s \n" target))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 (backward-char 1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 (defun mh-to-fcc (&optional folder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 "Insert an Fcc: FOLDER field in the current message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 Prompt for the field name with a completion list of the current folders."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 (or folder
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 (setq folder (mh-prompt-for-folder
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 "Fcc"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 (or (and mh-default-folder-for-message-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (funcall mh-default-folder-for-message-function)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 (let ((last-input-char ?\C-f))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 (expand-abbrev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (mh-to-field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 (insert (if (mh-folder-name-p folder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 (substring folder 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 folder)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 (defun mh-insert-signature ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 "Insert the file named by mh-signature-file-name at the current point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 (insert-file-contents mh-signature-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 (set-buffer-modified-p (buffer-modified-p))) ; force mode line update
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 (defun mh-check-whom ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 "Verify recipients of the current letter, showing expansion of any aliases."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 (let ((file-name buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 (save-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 (message "Checking recipients...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 (mh-in-show-buffer ("*Recipients*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 (bury-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 (mh-exec-cmd-output "whom" t file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 (message "Checking recipients...done")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 ;;; Routines to compose and send a letter.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 (defun mh-compose-and-send-mail (draft send-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 sent-from-folder sent-from-msg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 to subject cc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 annotate-char annotate-field
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 config)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 ;; Edit and compose a draft message in buffer DRAFT and send or save it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 ;; SENT-FROM-FOLDER is buffer containing scan listing of current folder, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 ;; nil if none exists.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 ;; SENT-FROM-MSG is the message number or sequence name or nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 ;; SEND-ARGS is an optional argument passed to the send command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 ;; The TO, SUBJECT, and CC fields are passed to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 ;; mh-compose-letter-function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 ;; If ANNOTATE-CHAR is non-null, it is used to notate the scan listing of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 ;; message. In that case, the ANNOTATE-FIELD is used to build a string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 ;; for mh-annotate-msg.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 ;; CONFIG is the window configuration to restore after sending the letter.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 (pop-to-buffer draft)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (mh-letter-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 (setq mh-sent-from-folder sent-from-folder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 (setq mh-sent-from-msg sent-from-msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 (setq mh-send-args send-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (setq mh-annotate-char annotate-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 (setq mh-annotate-field annotate-field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 (setq mh-previous-window-config config)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 (setq mode-line-buffer-identification (list "{%b}"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 (if (and (boundp 'mh-compose-letter-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 mh-compose-letter-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 ;; run-hooks will not pass arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 (let ((value mh-compose-letter-function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 (if (and (listp value) (not (eq (car value) 'lambda)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 (while value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (funcall (car value) to subject cc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 (setq value (cdr value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 (funcall mh-compose-letter-function to subject cc)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 (defun mh-send-letter (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 "Send the draft letter in the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 If optional prefix argument is provided, monitor delivery.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 Run mh-before-send-letter-hook before doing anything."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 (run-hooks 'mh-before-send-letter-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 (save-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 (message "Sending...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 (let ((draft-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 (file-name buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 (config mh-previous-window-config))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 (cond (arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 (pop-to-buffer "MH mail delivery")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 (mh-exec-cmd-output mh-send-prog t "-watch" "-nopush"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 "-nodraftfolder" mh-send-args file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 (goto-char (point-max)) ; show the interesting part
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 (recenter -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 (set-buffer draft-buffer)) ; for annotation below
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 (mh-exec-cmd-daemon mh-send-prog "-nodraftfolder" "-noverbose"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 mh-send-args file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 (if mh-annotate-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 (mh-annotate-msg mh-sent-from-msg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 mh-sent-from-folder
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 mh-annotate-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 "-component" mh-annotate-field
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 "-text" (format "\"%s %s\""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 (mh-get-header-field "To:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 (mh-get-header-field "Cc:"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 (cond ((or (not arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 (y-or-n-p "Kill draft buffer? "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 (kill-buffer draft-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 (if config
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 (set-window-configuration config))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 (if arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 (message "Sending...done")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 (message "Sending...backgrounded"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 (defun mh-insert-letter (folder message verbatim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 "Insert a message into the current letter.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 Removes the message's headers using mh-invisible-headers. Prefixes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 each non-blank line with mh-ins-buf-prefix. Prompts for FOLDER and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 MESSAGE. If prefix argument VERBATIM provided, do not indent and do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 not delete headers. Leaves the mark before the letter and point after it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 (list (mh-prompt-for-folder "Message from" mh-sent-from-folder nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 (read-input (format "Message number%s: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 (if mh-sent-from-msg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 (format " [%d]" mh-sent-from-msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 current-prefix-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 (narrow-to-region (point) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 (let ((start (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 (if (equal message "") (setq message (int-to-string mh-sent-from-msg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 (mh-exec-lib-cmd-output "mhl" "-nobell" "-noclear"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 (expand-file-name message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 (mh-expand-file-name folder)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 (cond ((not verbatim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 (mh-clean-msg-header start mh-invisible-headers mh-visible-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 (set-mark start) ; since mh-clean-msg-header moves it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 (mh-insert-prefix-string mh-ins-buf-prefix))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 (defun mh-yank-cur-msg ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 "Insert the current message into the draft buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 Prefix each non-blank line in the message with the string in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 `mh-ins-buf-prefix'. If a region is set in the message's buffer, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 only the region will be inserted. Otherwise, the entire message will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 be inserted if `mh-yank-from-start-of-msg' is non-nil. If this variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 is nil, the portion of the message following the point will be yanked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 If `mh-delete-yanked-msg-window' is non-nil, any window displaying the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 yanked message will be deleted."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 (if (and mh-sent-from-folder mh-sent-from-msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 (let ((to-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 (to-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 (set-buffer mh-sent-from-folder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 (if mh-delete-yanked-msg-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 (delete-windows-on mh-show-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 (set-buffer mh-show-buffer) ; Find displayed message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 (let ((mh-ins-str (cond ((if (boundp 'mark-active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 mark-active ;Emacs 19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 (mark)) ;Emacs 18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 (buffer-substring (region-beginning)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 (region-end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 ((eq 'body mh-yank-from-start-of-msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 (mh-goto-header-end 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 (mh-yank-from-start-of-msg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 (buffer-substring (point-min) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 (buffer-substring (point) (point-max))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 (set-buffer to-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 (narrow-to-region to-point to-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 (push-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 (insert mh-ins-str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 (mh-insert-prefix-string mh-ins-buf-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 (insert "\n"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 (error "There is no current message")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 (defun mh-insert-prefix-string (mh-ins-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 ;; Run mail-citation-hook to insert a prefix string before each line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 ;; in the buffer. Generality for supercite users.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 (set-mark (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 (cond (mail-citation-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 (run-hooks 'mail-citation-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 (mh-yank-hooks ;old hook name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 (run-hooks 'mh-yank-hooks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 (or (bolp) (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 (let ((zmacs-regions nil)) ;so "(mark)" works in XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 (while (< (point) (mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 (insert mh-ins-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 (forward-line 1))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 (defun mh-fully-kill-draft ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 "Kill the draft message file and the draft message buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 Use \\[kill-buffer] if you don't want to delete the draft message file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 (if (y-or-n-p "Kill draft message? ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 (let ((config mh-previous-window-config))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 (if (file-exists-p buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 (delete-file buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 (kill-buffer (buffer-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 (message "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 (if config
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 (set-window-configuration config)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 (error "Message not killed")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 ;;; Build the letter-mode keymap:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 (define-key mh-letter-mode-map "\C-c\C-f\C-b" 'mh-to-field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 (define-key mh-letter-mode-map "\C-c\C-f\C-c" 'mh-to-field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 (define-key mh-letter-mode-map "\C-c\C-f\C-d" 'mh-to-field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 (define-key mh-letter-mode-map "\C-c\C-f\C-f" 'mh-to-fcc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 (define-key mh-letter-mode-map "\C-c\C-f\C-r" 'mh-to-field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 (define-key mh-letter-mode-map "\C-c\C-f\C-s" 'mh-to-field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 (define-key mh-letter-mode-map "\C-c\C-f\C-t" 'mh-to-field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 (define-key mh-letter-mode-map "\C-c\C-fb" 'mh-to-field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 (define-key mh-letter-mode-map "\C-c\C-fc" 'mh-to-field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 (define-key mh-letter-mode-map "\C-c\C-fd" 'mh-to-field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 (define-key mh-letter-mode-map "\C-c\C-ff" 'mh-to-fcc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 (define-key mh-letter-mode-map "\C-c\C-fr" 'mh-to-field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 (define-key mh-letter-mode-map "\C-c\C-fs" 'mh-to-field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 (define-key mh-letter-mode-map "\C-c\C-ft" 'mh-to-field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 (define-key mh-letter-mode-map "\C-c\C-i" 'mh-insert-letter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 (define-key mh-letter-mode-map "\C-c\C-q" 'mh-fully-kill-draft)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 (define-key mh-letter-mode-map "\C-c\C-\\" 'mh-fully-kill-draft) ;if no C-q
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 (define-key mh-letter-mode-map "\C-c\C-s" 'mh-insert-signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 (define-key mh-letter-mode-map "\C-c\C-^" 'mh-insert-signature) ;if no C-s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 (define-key mh-letter-mode-map "\C-c\C-w" 'mh-check-whom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 (define-key mh-letter-mode-map "\C-c\C-y" 'mh-yank-cur-msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 (define-key mh-letter-mode-map "\C-c\C-c" 'mh-send-letter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 (define-key mh-letter-mode-map "\C-c\C-m\C-f" 'mh-mhn-compose-forw)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 (define-key mh-letter-mode-map "\C-c\C-m\C-e" 'mh-mhn-compose-anon-ftp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 (define-key mh-letter-mode-map "\C-c\C-m\C-t" 'mh-mhn-compose-external-compressed-tar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 (define-key mh-letter-mode-map "\C-c\C-m\C-i" 'mh-mhn-compose-insertion)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 (define-key mh-letter-mode-map "\C-c\C-e" 'mh-edit-mhn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 (define-key mh-letter-mode-map "\C-c\C-m\C-u" 'mh-revert-mhn-edit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 ;; "C-c /" prefix is used in mh-letter-mode by pgp.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 ;;; autoloads from mh-mime
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 (autoload 'mh-mhn-compose-insertion "mh-mime"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 "Add a directive to insert a MIME message part from a file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 This is the typical way to insert non-text parts in a message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 See also \\[mh-edit-mhn]." t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 (autoload 'mh-mhn-compose-anon-ftp "mh-mime"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 "Add a directive for a MIME anonymous ftp external body part.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 This directive tells MH to include a reference to a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 message/external-body part retrievable by anonymous FTP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 See also \\[mh-edit-mhn]." t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 (autoload 'mh-mhn-compose-external-compressed-tar "mh-mime"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 "Add a directive to include a MIME reference to a compressed tar file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 The file should be available via anonymous ftp. This directive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 tells MH to include a reference to a message/external-body part.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 See also \\[mh-edit-mhn]." t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 (autoload 'mh-mhn-compose-forw "mh-mime"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 "Add a forw directive to this message, to forward a message with MIME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 This directive tells MH to include another message in this one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 See also \\[mh-edit-mhn]." t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 (autoload 'mh-edit-mhn "mh-mime"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 "Format the current draft for MIME, expanding any mhn directives.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 Process the current draft with the mhn program, which,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 using directives already inserted in the draft, fills in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 all the MIME components and header fields.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 This step should be done last just before sending the message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 The mhn program is part of MH version 6.8 or later.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 The `\\[mh-revert-mhn-edit]' command undoes this command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 For assistance with creating mhn directives to insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 various types of components in a message, see
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 \\[mh-mhn-compose-insertion] (generic insertion from a file),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 \\[mh-mhn-compose-anon-ftp] (external reference to file via anonymous ftp),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 \\[mh-mhn-compose-external-compressed-tar] \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 \(reference to compressed tar file via anonymous ftp), and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 \\[mh-mhn-compose-forw] (forward message)." t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 (autoload 'mh-revert-mhn-edit "mh-mime"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 "Undoes the effect of \\[mh-edit-mhn] by reverting to the backup file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 Optional non-nil argument means don't ask for confirmation." t)