annotate lisp/gnus/message.el @ 24:4103f0995bd7 r19-15b95

Import from CVS: tag r19-15b95
author cvs
date Mon, 13 Aug 2007 08:51:03 +0200
parents 8fc7fe29b841
children 1917ad0d78d7
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 ;;; message.el --- composing mail and news messages
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2 ;; Copyright (C) 1996,97 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Keywords: mail, news
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; This file is part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; Boston, MA 02111-1307, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; This mode provides mail-sending facilities from within Emacs. It
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;; consists mainly of large chunks of code from the sendmail.el,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; gnus-msg.el and rnewspost.el files.
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 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (require 'cl))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (require 'mailheader)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (require 'rmail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (require 'nnheader)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (require 'timezone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (require 'easymenu)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
39 (require 'custom)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (if (string-match "XEmacs\\|Lucid" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (require 'mail-abbrevs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (require 'mailabbrev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
44 (defgroup message '((user-mail-address custom-variable)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
45 (user-full-name custom-variable))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
46 "Mail and news message composing."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
47 :link '(custom-manual "(message)Top")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
48 :group 'emacs)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
49
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
50 (put 'user-mail-address 'custom-type 'string)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
51 (put 'user-full-name 'custom-type 'string)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
52
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
53 (defgroup message-various nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
54 "Various Message Variables"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
55 :link '(custom-manual "(message)Various Message Variables")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
56 :group 'message)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
57
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
58 (defgroup message-buffers nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
59 "Message Buffers"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
60 :link '(custom-manual "(message)Message Buffers")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
61 :group 'message)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
62
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
63 (defgroup message-sending nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
64 "Message Sending"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
65 :link '(custom-manual "(message)Sending Variables")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
66 :group 'message)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
67
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
68 (defgroup message-interface nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
69 "Message Interface"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
70 :link '(custom-manual "(message)Interface")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
71 :group 'message)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
72
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
73 (defgroup message-forwarding nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
74 "Message Forwarding"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
75 :link '(custom-manual "(message)Forwarding")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
76 :group 'message-interface)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
77
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
78 (defgroup message-insertion nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
79 "Message Insertion"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
80 :link '(custom-manual "(message)Insertion")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
81 :group 'message)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
82
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
83 (defgroup message-headers nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
84 "Message Headers"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
85 :link '(custom-manual "(message)Message Headers")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
86 :group 'message)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
87
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
88 (defgroup message-news nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
89 "Composing News Messages"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
90 :group 'message)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
91
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
92 (defgroup message-mail nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
93 "Composing Mail Messages"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
94 :group 'message)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
95
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
96 (defcustom message-directory "~/Mail/"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
97 "*Directory from which all other mail file variables are derived."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
98 :group 'message-various
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
99 :type 'directory)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
100
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
101 (defcustom message-max-buffers 10
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
102 "*How many buffers to keep before starting to kill them off."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
103 :group 'message-buffers
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
104 :type 'integer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
105
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
106 (defcustom message-send-rename-function nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
107 "Function called to rename the buffer after sending it."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
108 :group 'message-buffers
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
109 :type 'function)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ;;;###autoload
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
112 (defcustom message-fcc-handler-function 'message-output
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 "*A function called to save outgoing articles.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 This function will be called with the name of the file to store the
18
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents: 16
diff changeset
115 article in. The default function is `message-output' which saves in Unix
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
116 mailbox format."
18
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents: 16
diff changeset
117 :type '(radio (function-item message-output)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
118 (function :tag "Other"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
119 :group 'message-sending)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
120
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
121 (defcustom message-courtesy-message
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
122 "The following message is a courtesy copy of an article\nthat has been posted to %s as well.\n\n"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
123 "*This is inserted at the start of a mailed copy of a posted message.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
124 If the string contains the format spec \"%s\", the Newsgroups
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
125 the article has been posted to will be inserted there.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
126 If this variable is nil, no such courtesy message will be added."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
127 :group 'message-sending
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
128 :type 'string)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
129
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
130 (defcustom message-ignored-bounced-headers "^\\(Received\\|Return-Path\\):"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
131 "*Regexp that matches headers to be removed in resent bounced mail."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
132 :group 'message-interface
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
133 :type 'regexp)
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 ;;;###autoload
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
136 (defcustom message-from-style 'default
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 "*Specifies how \"From\" headers look.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 If `nil', they contain just the return address like:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 king@grassland.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 If `parens', they look like:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 king@grassland.com (Elvis Parsley)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 If `angles', they look like:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 Elvis Parsley <king@grassland.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 Otherwise, most addresses look like `angles', but they look like
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
147 `parens' if `angles' would need quoting and `parens' would not."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
148 :type '(choice (const :tag "simple" nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
149 (const parens)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
150 (const angles)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
151 (const default))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
152 :group 'message-headers)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
153
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
154 (defcustom message-syntax-checks nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
155 ;; Guess this one shouldn't be easy to customize...
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 "Controls what syntax checks should not be performed on outgoing posts.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 To disable checking of long signatures, for instance, add
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 `(signature . disabled)' to this list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 Don't touch this variable unless you really know what you're doing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 Checks include subject-cmsg multiple-headers sendsys message-id from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 long-lines control-chars size new-text redirected-followup signature
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
164 approved sender empty empty-headers message-id from subject
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
165 shorten-followup-to existing-newsgroups."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
166 :group 'message-news)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
167
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
168 (defcustom message-required-news-headers
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 '(From Newsgroups Subject Date Message-ID
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (optional . Organization) Lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (optional . X-Newsreader))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
172 "Headers to be generated or prompted for when posting an article.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 RFC977 and RFC1036 require From, Date, Newsgroups, Subject,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 Message-ID. Organization, Lines, In-Reply-To, Expires, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 X-Newsreader are optional. If don't you want message to insert some
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
176 header, remove it from this list."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
177 :group 'message-news
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
178 :group 'message-headers
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
179 :type '(repeat sexp))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
180
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
181 (defcustom message-required-mail-headers
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 '(From Subject Date (optional . In-Reply-To) Message-ID Lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (optional . X-Mailer))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
184 "Headers to be generated or prompted for when mailing a message.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 RFC822 required that From, Date, To, Subject and Message-ID be
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
186 included. Organization, Lines and X-Mailer are optional."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
187 :group 'message-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
188 :group 'message-headers
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
189 :type '(repeat sexp))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
190
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
191 (defcustom message-deletable-headers '(Message-ID Date Lines)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
192 "Headers to be deleted if they already exist and were generated by message previously."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
193 :group 'message-headers
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
194 :type 'sexp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
195
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
196 (defcustom message-ignored-news-headers
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
197 "^NNTP-Posting-Host:\\|^Xref:\\|^Bcc:\\|^Gcc:\\|^Fcc:\\|^Resent-Fcc:"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
198 "*Regexp of headers to be removed unconditionally before posting."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
199 :group 'message-news
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
200 :group 'message-headers
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
201 :type 'regexp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
202
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
203 (defcustom message-ignored-mail-headers "^Gcc:\\|^Fcc:\\|^Resent-Fcc:"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
204 "*Regexp of headers to be removed unconditionally before mailing."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
205 :group 'message-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
206 :group 'message-headers
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
207 :type 'regexp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
208
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
209 (defcustom message-ignored-supersedes-headers "^Path:\\|^Date\\|^NNTP-Posting-Host:\\|^Xref:\\|^Lines:\\|^Received:\\|^X-From-Line:\\|Return-Path:\\|^Supersedes:"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
210 "*Header lines matching this regexp will be deleted before posting.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
211 It's best to delete old Path and Date headers before posting to avoid
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
212 any confusion."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
213 :group 'message-interface
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
214 :type 'regexp)
0
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
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
217 (defcustom message-signature-separator "^-- *$"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
218 "Regexp matching the signature separator."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
219 :type 'regexp
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
220 :group 'message-various)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
221
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
222 (defcustom message-elide-elipsis "\n[...]\n\n"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
223 "*The string which is inserted for elided text.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
224
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
225 (defcustom message-interactive nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 "Non-nil means when sending a message wait for and display errors.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
227 nil means let mailer mail back a message to report errors."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
228 :group 'message-sending
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
229 :group 'message-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
230 :type 'boolean)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
231
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
232 (defcustom message-generate-new-buffers t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 "*Non-nil means that a new message buffer will be created whenever `mail-setup' is called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 If this is a function, call that function with three parameters: The type,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 the to address and the group name. (Any of these may be nil.) The function
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
236 should return the new buffer name."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
237 :group 'message-buffers
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
238 :type '(choice (const :tag "off" nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
239 (const :tag "on" t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
240 (function fun)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
241
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
242 (defcustom message-kill-buffer-on-exit nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
243 "*Non-nil means that the message buffer will be killed after sending a message."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
244 :group 'message-buffers
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
245 :type 'boolean)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (defvar gnus-local-organization)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
248 (defcustom message-user-organization
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (or (and (boundp 'gnus-local-organization)
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 18
diff changeset
250 (stringp gnus-local-organization)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 gnus-local-organization)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (getenv "ORGANIZATION")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 "*String to be used as an Organization header.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
255 If t, use `message-user-organization-file'."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
256 :group 'message-headers
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
257 :type '(choice string
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
258 (const :tag "consult file" t)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 ;;;###autoload
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
261 (defcustom message-user-organization-file "/usr/lib/news/organization"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
262 "*Local news organization file."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
263 :type 'file
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
264 :group 'message-headers)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
265
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
266 (defcustom message-autosave-directory "~/"
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
267 ; (concat (file-name-as-directory message-directory) "drafts/")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 "*Directory where message autosaves buffers.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
269 If nil, message won't autosave."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
270 :group 'message-buffers
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
271 :type 'directory)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
272
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
273 (defcustom message-forward-start-separator
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 "------- Start of forwarded message -------\n"
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
275 "*Delimiter inserted before forwarded messages."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
276 :group 'message-forwarding
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
277 :type 'string)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
278
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
279 (defcustom message-forward-end-separator
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 "------- End of forwarded message -------\n"
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
281 "*Delimiter inserted after forwarded messages."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
282 :group 'message-forwarding
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
283 :type 'string)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
284
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
285 (defcustom message-signature-before-forwarded-message t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
286 "*If non-nil, put the signature before any included forwarded message."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
287 :group 'message-forwarding
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
288 :type 'boolean)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
289
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
290 (defcustom message-included-forward-headers
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-\\|^Message-ID:\\|^References:"
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
292 "*Regexp matching headers to be included in forwarded messages."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
293 :group 'message-forwarding
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
294 :type 'regexp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
295
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
296 (defcustom message-ignored-resent-headers "^Return-receipt"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
297 "*All headers that match this regexp will be deleted when resending a message."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
298 :group 'message-interface
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
299 :type 'regexp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
300
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
301 (defcustom message-ignored-cited-headers "."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
302 "*Delete these headers from the messages you yank."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
303 :group 'message-insertion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
304 :type 'regexp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
305
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
306 (defcustom message-cancel-message "I am canceling my own article."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
307 "Message to be inserted in the cancel message."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
308 :group 'message-interface
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
309 :type 'string)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 ;; Useful to set in site-init.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 ;;;###autoload
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
313 (defcustom message-send-mail-function 'message-send-mail-with-sendmail
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 "Function to call to send the current buffer as mail.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 The headers should be delimited by a line whose contents match the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 variable `mail-header-separator'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
318 Legal values include `message-send-mail-with-sendmail' (the default),
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
319 `message-send-mail-with-mh' and `message-send-mail-with-qmail'."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
320 :type '(radio (function-item message-send-mail-with-sendmail)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
321 (function-item message-send-mail-with-mh)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
322 (function-item message-send-mail-with-qmail)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
323 (function :tag "Other"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
324 :group 'message-sending
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
325 :group 'message-mail)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
326
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
327 (defcustom message-send-news-function 'message-send-news
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 "Function to call to send the current buffer as news.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 The headers should be delimited by a line whose contents match the
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
330 variable `mail-header-separator'."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
331 :group 'message-sending
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
332 :group 'message-news
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
333 :type 'function)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
334
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
335 (defcustom message-reply-to-function nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
336 "Function that should return a list of headers.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
337 This function should pick out addresses from the To, Cc, and From headers
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
338 and respond with new To and Cc headers."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
339 :group 'message-interface
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
340 :type 'function)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
341
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
342 (defcustom message-wide-reply-to-function nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
343 "Function that should return a list of headers.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
344 This function should pick out addresses from the To, Cc, and From headers
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
345 and respond with new To and Cc headers."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
346 :group 'message-interface
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
347 :type 'function)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
348
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
349 (defcustom message-followup-to-function nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 "Function that should return a list of headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 This function should pick out addresses from the To, Cc, and From headers
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
352 and respond with new To and Cc headers."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
353 :group 'message-interface
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
354 :type 'function)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
355
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
356 (defcustom message-use-followup-to 'ask
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 "*Specifies what to do with Followup-To header.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
358 If nil, always ignore the header. If it is t, use its value, but
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
359 query before using the \"poster\" value. If it is the symbol `ask',
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
360 always query the user whether to use the value. If it is the symbol
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
361 `use', always use the value."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
362 :group 'message-interface
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
363 :type '(choice (const :tag "ignore" nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
364 (const use)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
365 (const ask)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
366
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
367 ;; stuff relating to broken sendmail in MMDF
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
368 (defcustom message-sendmail-f-is-evil nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
369 "*Non-nil means that \"-f username\" should not be added to the sendmail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
370 command line, because it is even more evil than leaving it out."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
371 :group 'message-sending
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
372 :type 'boolean)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
373
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
374 ;; qmail-related stuff
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
375 (defcustom message-qmail-inject-program "/var/qmail/bin/qmail-inject"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
376 "Location of the qmail-inject program."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
377 :group 'message-sending
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
378 :type 'file)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
379
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
380 (defcustom message-qmail-inject-args nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
381 "Arguments passed to qmail-inject programs.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
382 This should be a list of strings, one string for each argument.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
383
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
384 For e.g., if you wish to set the envelope sender address so that bounces
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
385 go to the right place or to deal with listserv's usage of that address, you
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
386 might set this variable to '(\"-f\" \"you@some.where\")."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
387 :group 'message-sending
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
388 :type '(repeat string))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (defvar gnus-post-method)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (defvar gnus-select-method)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
392 (defcustom message-post-method
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (cond ((and (boundp 'gnus-post-method)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 gnus-post-method)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 gnus-post-method)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 ((boundp 'gnus-select-method)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 gnus-select-method)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (t '(nnspool "")))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
399 "Method used to post news."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
400 :group 'message-news
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
401 :group 'mesage-sending
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
402 ;; This should be the `gnus-select-method' widget, but that might
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
403 ;; create a dependence to `gnus.el'.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
404 :type 'sexp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
405
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
406 (defcustom message-generate-headers-first nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
407 "*If non-nil, generate all possible headers before composing."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
408 :group 'message-headers
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
409 :type 'boolean)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
410
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
411 (defcustom message-setup-hook nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 "Normal hook, run each time a new outgoing message is initialized.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
413 The function `message-setup' runs this hook."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
414 :group 'message-various
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
415 :type 'hook)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
416
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
417 (defcustom message-signature-setup-hook nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 "Normal hook, run each time a new outgoing message is initialized.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 It is run after the headers have been inserted and before
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
420 the signature is inserted."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
421 :group 'message-various
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
422 :type 'hook)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
423
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
424 (defcustom message-mode-hook nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
425 "Hook run in message mode buffers."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
426 :group 'message-various
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
427 :type 'hook)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
428
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
429 (defcustom message-header-hook nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
430 "Hook run in a message mode buffer narrowed to the headers."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
431 :group 'message-various
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
432 :type 'hook)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
433
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
434 (defcustom message-header-setup-hook nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
435 "Hook called narrowed to the headers when setting up a message
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
436 buffer."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
437 :group 'message-various
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
438 :type 'hook)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
439
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
440 ;;;###autoload
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
441 (defcustom message-citation-line-function 'message-insert-citation-line
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
442 "*Function called to insert the \"Whomever writes:\" line."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
443 :type 'function
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
444 :group 'message-insertion)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 ;;;###autoload
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
447 (defcustom message-yank-prefix "> "
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
448 "*Prefix inserted on the lines of yanked messages.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
449 nil means use indentation."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
450 :type 'string
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
451 :group 'message-insertion)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
452
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
453 (defcustom message-indentation-spaces 3
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
454 "*Number of spaces to insert at the beginning of each cited line.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
455 Used by `message-yank-original' via `message-yank-cite'."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
456 :group 'message-insertion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
457 :type 'integer)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 ;;;###autoload
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
460 (defcustom message-cite-function
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
461 (if (and (boundp 'mail-citation-hook)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
462 mail-citation-hook)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
463 mail-citation-hook
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
464 'message-cite-original)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
465 "*Function for citing an original message."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
466 :type '(radio (function-item message-cite-original)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
467 (function-item sc-cite-original)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
468 (function :tag "Other"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
469 :group 'message-insertion)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 ;;;###autoload
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
472 (defcustom message-indent-citation-function 'message-indent-citation
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 "*Function for modifying a citation just inserted in the mail buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 This can also be a list of functions. Each function can find the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 citation between (point) and (mark t). And each function should leave
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
476 point and mark around the citation text as modified."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
477 :type 'function
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
478 :group 'message-insertion)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (defvar message-abbrevs-loaded nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 ;;;###autoload
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
483 (defcustom message-signature t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 "*String to be inserted at the end of the message buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 If t, the `message-signature-file' file will be inserted instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 If a function, the result from the function will be used instead.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
487 If a form, the result from the form will be used instead."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
488 :type 'sexp
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
489 :group 'message-insertion)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 ;;;###autoload
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
492 (defcustom message-signature-file "~/.signature"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
493 "*File containing the text inserted at end of message buffer."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
494 :type 'file
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
495 :group 'message-insertion)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
496
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
497 (defcustom message-distribution-function nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
498 "*Function called to return a Distribution header."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
499 :group 'message-news
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
500 :group 'message-headers
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
501 :type 'function)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
502
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
503 (defcustom message-expires 14
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
504 "Number of days before your article expires."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
505 :group 'message-news
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
506 :group 'message-headers
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
507 :link '(custom-manual "(message)News Headers")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
508 :type 'integer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
509
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
510 (defcustom message-user-path nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 "If nil, use the NNTP server name in the Path header.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
512 If stringp, use this; if non-nil, use no host name (user name only)."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
513 :group 'message-news
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
514 :group 'message-headers
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
515 :link '(custom-manual "(message)News Headers")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
516 :type '(choice (const :tag "nntp" nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
517 (string :tag "name")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
518 (sexp :tag "none" :format "%t" t)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (defvar message-reply-buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (defvar message-reply-headers nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (defvar message-newsreader nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (defvar message-mailer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (defvar message-sent-message-via nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (defvar message-checksum nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (defvar message-send-actions nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 "A list of actions to be performed upon successful sending of a message.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (defvar message-exit-actions nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 "A list of actions to be performed upon exiting after sending a message.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (defvar message-kill-actions nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 "A list of actions to be performed before killing a message buffer.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (defvar message-postpone-actions nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 "A list of actions to be performed after postponing a message.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
535 (defcustom message-default-headers ""
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 "*A string containing header lines to be inserted in outgoing messages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 It is inserted before you edit the message, so you can edit or delete
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
538 these lines."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
539 :group 'message-headers
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
540 :type 'string)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
541
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
542 (defcustom message-default-mail-headers ""
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
543 "*A string of header lines to be inserted in outgoing mails."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
544 :group 'message-headers
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
545 :group 'message-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
546 :type 'string)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
547
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
548 (defcustom message-default-news-headers ""
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
549 "*A string of header lines to be inserted in outgoing news
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
550 articles."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
551 :group 'message-headers
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
552 :group 'message-news
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
553 :type 'string)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 ;; Note: could use /usr/ucb/mail instead of sendmail;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 ;; options -t, and -v if not interactive.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
557 (defcustom message-mailer-swallows-blank-line
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (if (and (string-match "sparc-sun-sunos\\(\\'\\|[^5]\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 system-configuration)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (file-readable-p "/etc/sendmail.cf")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (let ((buffer (get-buffer-create " *temp*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (insert-file-contents "/etc/sendmail.cf")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (let ((case-fold-search nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (re-search-forward "^OR\\>" nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (kill-buffer buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 ;; According to RFC822, "The field-name must be composed of printable
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
571 ;; ASCII characters (i. e., characters that have decimal values between
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
572 ;; 33 and 126, except colon)", i. e., any chars except ctl chars,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 ;; space, or colon.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 '(looking-at "[ \t]\\|[][!\"#$%&'()*+,-./0-9;<=>?@A-Z\\\\^_`a-z{|}~]+:"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 "Set this non-nil if the system's mailer runs the header and body together.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 \(This problem exists on Sunos 4 when sendmail is run in remote mode.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 The value should be an expression to test whether the problem will
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
578 actually occur."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
579 :group 'message-sending
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
580 :type 'sexp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
581
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
582 (ignore-errors
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
583 (define-mail-user-agent 'message-user-agent
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
584 'message-mail 'message-send-and-exit
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
585 'message-kill-buffer 'message-send-hook))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
586
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 18
diff changeset
587 (defvar message-mh-deletable-headers '(Message-ID Date Lines Sender)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
588 "If non-nil, delete the deletable headers before feeding to mh.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
589
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
590 ;;; Internal variables.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
591 ;;; Well, not really internal.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (defvar message-mode-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (let ((table (copy-syntax-table text-mode-syntax-table)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (modify-syntax-entry ?% ". " table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 "Syntax table used while in Message mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
599 (defvar message-mode-abbrev-table text-mode-abbrev-table
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
600 "Abbrev table used in Message mode buffers.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
601 Defaults to `text-mode-abbrev-table'.")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
602
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (defvar message-font-lock-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 (let* ((cite-prefix "A-Za-z") (cite-suffix (concat cite-prefix "0-9_.@-")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (list '("^To:" . font-lock-function-name-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 '("^[GBF]?[Cc][Cc]:\\|^Reply-To:" . font-lock-keyword-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 '("^\\(Subject:\\)[ \t]*\\(.+\\)?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (1 font-lock-comment-face) (2 font-lock-type-face nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (list (concat "^\\(" (regexp-quote mail-header-separator) "\\)$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 1 'font-lock-comment-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (cons (concat "^[ \t]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 "\\([" cite-prefix "]+[" cite-suffix "]*\\)?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 "[>|}].*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 'font-lock-reference-face)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
615 '("^\\(X-[A-Za-z0-9-]+\\|In-Reply-To\\):.*"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 . font-lock-string-face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 "Additional expressions to highlight in Message mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (defvar message-face-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 '((bold . bold-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (underline . underline-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (default . (lambda (b e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (unbold-region b e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (ununderline-region b e))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 "Alist of mail and news faces for facemenu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 The cdr of ech entry is a function for applying the face to a region.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
628 (defcustom message-send-hook nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
629 "Hook run before sending messages."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
630 :group 'message-various
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
631 :options '(ispell-message)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
632 :type 'hook)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
633
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
634 (defcustom message-send-mail-hook nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
635 "Hook run before sending mail messages."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
636 :group 'message-various
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
637 :type 'hook)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
638
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
639 (defcustom message-send-news-hook nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
640 "Hook run before sending news messages."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
641 :group 'message-various
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
642 :type 'hook)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
643
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
644 (defcustom message-sent-hook nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
645 "Hook run after sending messages."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
646 :group 'message-various
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
647 :type 'hook)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 ;;; Internal variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (defvar message-buffer-list nil)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
652 (defvar message-this-is-news nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
653 (defvar message-this-is-mail nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
654
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
655 ;; Byte-compiler warning
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
656 (defvar gnus-active-hashtb)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
657 (defvar gnus-read-active-file)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 ;;; Regexp matching the delimiter of messages in UNIX mail format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 ;;; (UNIX From lines), minus the initial ^.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 (defvar message-unix-mail-delimiter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (let ((time-zone-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (concat "\\([A-Z]?[A-Z]?[A-Z][A-Z]\\( DST\\)?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 "\\|[-+]?[0-9][0-9][0-9][0-9]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 "\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 "\\) *")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 "From "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 ;; Username, perhaps with a quoted section that can contain spaces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 "\\("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 "[^ \n]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 "\\(\\|\".*\"[^ \n]*\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 "\\|<[^<>\n]+>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 "\\) ?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 ;; The time the message was sent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 "\\([^ \n]*\\) *" ; day of the week
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 "\\([^ ]*\\) *" ; month
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 "\\([0-9]*\\) *" ; day of month
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 "\\([0-9:]*\\) *" ; time of day
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 ;; Perhaps a time zone, specified by an abbreviation, or by a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 ;; numeric offset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 time-zone-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 ;; The year.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 " [0-9][0-9]\\([0-9]*\\) *"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 ;; On some systems the time zone can appear after the year, too.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 time-zone-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 ;; Old uucp cruft.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 "\\(remote from .*\\)?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 (defvar message-unsent-separator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 (concat "^ *---+ +Unsent message follows +---+ *$\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 "^ *---+ +Returned message +---+ *$\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 "^Start of returned message$\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 "^ *---+ +Original message +---+ *$\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 "^ *--+ +begin message +--+ *$\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 "^ *---+ +Original message follows +---+ *$\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 "^|? *---+ +Message text follows: +---+ *|?$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 "A regexp that matches the separator before the text of a failed message.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 (defvar message-header-format-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 `((Newsgroups)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 (To . message-fill-address)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 (Cc . message-fill-address)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 (Subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 (In-Reply-To)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (Fcc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (Bcc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (Date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (Organization)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (Distribution)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 (Lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 (Expires)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 (Message-ID)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
722 (References)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (X-Mailer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (X-Newsreader))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 "Alist used for formatting headers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (eval-and-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 (autoload 'message-setup-toolbar "messagexmas")
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
729 (autoload 'mh-send-letter "mh-comp")
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
730 (autoload 'gnus-point-at-eol "gnus-util")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
731 (autoload 'gnus-point-at-bol "gnus-util")
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
732 (autoload 'gnus-output-to-mail "gnus-util")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
733 (autoload 'gnus-output-to-rmail "gnus-util"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 ;;; Utility functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
741 (defmacro message-y-or-n-p (question show &rest text)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
742 "Ask QUESTION, displaying the rest of the arguments in a temp. buffer if SHOW"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
743 `(message-talkative-question 'y-or-n-p ,question ,show ,@text))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
744
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 ;; Delete the current line (and the next N lines.);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 (defmacro message-delete-line (&optional n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 `(delete-region (progn (beginning-of-line) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 (progn (forward-line ,(or n 1)) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 (defun message-tokenize-header (header &optional separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 "Split HEADER into a list of header elements.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 \",\" is used as the separator."
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
753 (if (not header)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
754 nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
755 (let ((regexp (format "[%s]+" (or separator ",")))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
756 (beg 1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
757 (first t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
758 quoted elems paren)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
759 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
760 (message-set-work-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
761 (insert header)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
762 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
763 (while (not (eobp))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
764 (if first
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
765 (setq first nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
766 (forward-char 1))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
767 (cond ((and (> (point) beg)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
768 (or (eobp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
769 (and (looking-at regexp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
770 (not quoted)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
771 (not paren))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
772 (push (buffer-substring beg (point)) elems)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
773 (setq beg (match-end 0)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
774 ((= (following-char) ?\")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
775 (setq quoted (not quoted)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
776 ((and (= (following-char) ?\()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
777 (not quoted))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
778 (setq paren t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
779 ((and (= (following-char) ?\))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
780 (not quoted))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
781 (setq paren nil))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
782 (nreverse elems)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 18
diff changeset
784 (defun message-fetch-field (header &optional not-all)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 "The same as `mail-fetch-field', only remove all newlines."
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 18
diff changeset
786 (let ((value (mail-fetch-field header nil (not not-all))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 (when value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (nnheader-replace-chars-in-string value ?\n ? ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 (defun message-fetch-reply-field (header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 "Fetch FIELD from the message we're replying to."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 (when (and message-reply-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 (buffer-name message-reply-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 (set-buffer message-reply-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 (message-fetch-field header))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 (defun message-set-work-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 (if (get-buffer " *message work*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 (set-buffer " *message work*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 (erase-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 (set-buffer (get-buffer-create " *message work*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 (kill-all-local-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 (buffer-disable-undo (current-buffer))))
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 message-functionp (form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 "Return non-nil if FORM is funcallable."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 (or (and (symbolp form) (fboundp form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 (and (listp form) (eq (car form) 'lambda))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 (defun message-strip-subject-re (subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 "Remove \"Re:\" from subject lines."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 (if (string-match "^[Rr][Ee]: *" subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 (substring subject (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 subject))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 (defun message-remove-header (header &optional is-regexp first reverse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 "Remove HEADER in the narrowed buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 If REGEXP, HEADER is a regular expression.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 If FIRST, only remove the first instance of the header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 Return the number of headers removed."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 (let ((regexp (if is-regexp header (concat "^" header ":")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 (number 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 (case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 (while (and (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 (not last))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (if (if reverse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 (not (looking-at regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 (looking-at regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 (incf number)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 (when first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 (setq last t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 (delete-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 ;; There might be a continuation header, so we have to search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 ;; until we find a new non-continuation line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 (if (re-search-forward "^[^ \t]" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (goto-char (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 (point-max)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 (if (re-search-forward "^[^ \t]" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 (goto-char (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 number))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 (defun message-narrow-to-headers ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 "Narrow the buffer to the head of the message."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 (narrow-to-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 (if (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 (concat "^" (regexp-quote mail-header-separator) "\n") nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 (goto-char (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 (defun message-narrow-to-head ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 "Narrow the buffer to the head of the message."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 (narrow-to-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 (if (search-forward "\n\n" nil 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 (1- (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 (goto-char (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 (defun message-news-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 "Say whether the current buffer contains a news message."
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
875 (or message-this-is-news
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
876 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
877 (save-restriction
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
878 (message-narrow-to-headers)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
879 (message-fetch-field "newsgroups")))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 (defun message-mail-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 "Say whether the current buffer contains a mail message."
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
883 (or message-this-is-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
884 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
885 (save-restriction
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
886 (message-narrow-to-headers)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
887 (or (message-fetch-field "to")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
888 (message-fetch-field "cc")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
889 (message-fetch-field "bcc"))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 (defun message-next-header ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 "Go to the beginning of the next header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 (or (eobp) (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 (not (if (re-search-forward "^[^ \t]" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 (goto-char (point-max)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 (defun message-sort-headers-1 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 "Sort the buffer as headers using `message-rank' text props."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 (sort-subr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 nil 'message-next-header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 (message-next-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 (unless (bobp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 (forward-char -1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 (or (get-text-property (point) 'message-rank)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
910 10000))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 (defun message-sort-headers ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 "Sort the headers of the current message according to `message-header-format-alist'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 (let ((max (1+ (length message-header-format-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 rank)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 (message-narrow-to-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 (while (re-search-forward "^[^ \n]+:" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 (put-text-property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 (match-beginning 0) (1+ (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 'message-rank
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 (if (setq rank (length (memq (assq (intern (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 (1- (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 message-header-format-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 message-header-format-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 (- max rank)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 (1+ max)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 (message-sort-headers-1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 ;;; Message mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 ;;; Set up keymap.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 (defvar message-mode-map nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 (unless message-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 (setq message-mode-map (copy-keymap text-mode-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 (define-key message-mode-map "\C-c?" 'describe-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 (define-key message-mode-map "\C-c\C-f\C-t" 'message-goto-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 (define-key message-mode-map "\C-c\C-f\C-b" 'message-goto-bcc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 (define-key message-mode-map "\C-c\C-f\C-w" 'message-goto-fcc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 (define-key message-mode-map "\C-c\C-f\C-c" 'message-goto-cc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 (define-key message-mode-map "\C-c\C-f\C-s" 'message-goto-subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 (define-key message-mode-map "\C-c\C-f\C-r" 'message-goto-reply-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 (define-key message-mode-map "\C-c\C-f\C-n" 'message-goto-newsgroups)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 (define-key message-mode-map "\C-c\C-f\C-d" 'message-goto-distribution)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 (define-key message-mode-map "\C-c\C-f\C-f" 'message-goto-followup-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 (define-key message-mode-map "\C-c\C-f\C-k" 'message-goto-keywords)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 (define-key message-mode-map "\C-c\C-f\C-u" 'message-goto-summary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 (define-key message-mode-map "\C-c\C-b" 'message-goto-body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 (define-key message-mode-map "\C-c\C-i" 'message-goto-signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 (define-key message-mode-map "\C-c\C-t" 'message-insert-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 (define-key message-mode-map "\C-c\C-n" 'message-insert-newsgroups)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 (define-key message-mode-map "\C-c\C-y" 'message-yank-original)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 (define-key message-mode-map "\C-c\C-q" 'message-fill-yanked-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 (define-key message-mode-map "\C-c\C-w" 'message-insert-signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 (define-key message-mode-map "\C-c\C-r" 'message-caesar-buffer-body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 (define-key message-mode-map "\C-c\C-o" 'message-sort-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 (define-key message-mode-map "\C-c\M-r" 'message-rename-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 (define-key message-mode-map "\C-c\C-c" 'message-send-and-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 (define-key message-mode-map "\C-c\C-s" 'message-send)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 (define-key message-mode-map "\C-c\C-k" 'message-kill-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 (define-key message-mode-map "\C-c\C-d" 'message-dont-send)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
976 (define-key message-mode-map "\C-c\C-e" 'message-elide-region)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
977
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 (define-key message-mode-map "\t" 'message-tab))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
980 (easy-menu-define
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
981 message-mode-menu message-mode-map "Message Menu."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
982 '("Message"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
983 ["Sort Headers" message-sort-headers t]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
984 ["Yank Original" message-yank-original t]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
985 ["Fill Yanked Message" message-fill-yanked-message t]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
986 ["Insert Signature" message-insert-signature t]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
987 ["Caesar (rot13) Message" message-caesar-buffer-body t]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
988 ["Caesar (rot13) Region" message-caesar-region (mark t)]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
989 ["Elide Region" message-elide-region (mark t)]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
990 ["Rename buffer" message-rename-buffer t]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
991 ["Spellcheck" ispell-message t]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
992 "----"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
993 ["Send Message" message-send-and-exit t]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
994 ["Abort Message" message-dont-send t]))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
995
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
996 (easy-menu-define
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
997 message-mode-field-menu message-mode-map ""
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
998 '("Field"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
999 ["Fetch To" message-insert-to t]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1000 ["Fetch Newsgroups" message-insert-newsgroups t]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1001 "----"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1002 ["To" message-goto-to t]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1003 ["Subject" message-goto-subject t]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1004 ["Cc" message-goto-cc t]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1005 ["Reply-To" message-goto-reply-to t]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1006 ["Summary" message-goto-summary t]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1007 ["Keywords" message-goto-keywords t]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1008 ["Newsgroups" message-goto-newsgroups t]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1009 ["Followup-To" message-goto-followup-to t]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1010 ["Distribution" message-goto-distribution t]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1011 ["Body" message-goto-body t]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1012 ["Signature" message-goto-signature t]))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 (defvar facemenu-add-face-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 (defvar facemenu-remove-face-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 (defun message-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 "Major mode for editing mail and news to be sent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 Like Text Mode but with these additional commands:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 C-c C-s message-send (send the message) C-c C-c message-send-and-exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 C-c C-f move to a header field (and create it if there isn't):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 C-c C-f C-t move to To C-c C-f C-s move to Subject
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 C-c C-f C-c move to Cc C-c C-f C-b move to Bcc
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1025 C-c C-f C-w move to Fcc C-c C-f C-r move to Reply-To
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 C-c C-f C-u move to Summary C-c C-f C-n move to Newsgroups
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 C-c C-f C-k move to Keywords C-c C-f C-d move to Distribution
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1028 C-c C-f C-f move to Followup-To
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 C-c C-t message-insert-to (add a To header to a news followup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 C-c C-n message-insert-newsgroups (add a Newsgroup header to a news reply)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 C-c C-b message-goto-body (move to beginning of message text).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 C-c C-i message-goto-signature (move to the beginning of the signature).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 C-c C-w message-insert-signature (insert `message-signature-file' file).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 C-c C-y message-yank-original (insert current message, if any).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 C-c C-q message-fill-yanked-message (fill what was yanked).
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1036 C-c C-e message-elide-region (elide the text between point and mark).
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1037 C-c C-r message-caesar-buffer-body (rot13 the message body)."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 (kill-all-local-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 (make-local-variable 'message-reply-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 (setq message-reply-buffer nil)
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 18
diff changeset
1042 (set (make-local-variable 'message-send-actions) nil)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 18
diff changeset
1043 (set (make-local-variable 'message-exit-actions) nil)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 18
diff changeset
1044 (set (make-local-variable 'message-kill-actions) nil)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 18
diff changeset
1045 (set (make-local-variable 'message-postpone-actions) nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 (set-syntax-table message-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 (use-local-map message-mode-map)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1048 (setq local-abbrev-table message-mode-abbrev-table)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 (setq major-mode 'message-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 (setq mode-name "Message")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 (setq buffer-offer-save t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 (make-local-variable 'font-lock-defaults)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 (setq font-lock-defaults '(message-font-lock-keywords t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 (make-local-variable 'facemenu-add-face-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 (make-local-variable 'facemenu-remove-face-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 (setq facemenu-add-face-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 (lambda (face end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 (let ((face-fun (cdr (assq face message-face-alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 (if face-fun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 (funcall face-fun (point) end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 (error "Face %s not configured for %s mode" face mode-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 facemenu-remove-face-function t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 (make-local-variable 'paragraph-separate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 (make-local-variable 'paragraph-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 (setq paragraph-start (concat (regexp-quote mail-header-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 "$\\|[ \t]*[-_][-_][-_]+$\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 "-- $\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 paragraph-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 (setq paragraph-separate (concat (regexp-quote mail-header-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 "$\\|[ \t]*[-_][-_][-_]+$\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 "-- $\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 paragraph-separate))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 (make-local-variable 'message-reply-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 (setq message-reply-headers nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 (make-local-variable 'message-newsreader)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 (make-local-variable 'message-mailer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 (make-local-variable 'message-post-method)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 (make-local-variable 'message-sent-message-via)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 (setq message-sent-message-via nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 (make-local-variable 'message-checksum)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 (setq message-checksum nil)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1083 ;;(when (fboundp 'mail-hist-define-keys)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1084 ;; (mail-hist-define-keys))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 (when (string-match "XEmacs\\|Lucid" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 (message-setup-toolbar))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 (easy-menu-add message-mode-menu message-mode-map)
18
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents: 16
diff changeset
1088 (easy-menu-add message-mode-field-menu message-mode-map)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 ;; Allow mail alias things.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 (if (fboundp 'mail-abbrevs-setup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 (mail-abbrevs-setup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 (funcall (intern "mail-aliases-setup")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 (run-hooks 'text-mode-hook 'message-mode-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 ;;; Message mode commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 ;;; Movement commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 (defun message-goto-to ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 "Move point to the To header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 (message-position-on-field "To"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 (defun message-goto-subject ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 "Move point to the Subject header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 (message-position-on-field "Subject"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 (defun message-goto-cc ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 "Move point to the Cc header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 (message-position-on-field "Cc" "To"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 (defun message-goto-bcc ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 "Move point to the Bcc header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 (message-position-on-field "Bcc" "Cc" "To"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 (defun message-goto-fcc ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 "Move point to the Fcc header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 (message-position-on-field "Fcc" "To" "Newsgroups"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 (defun message-goto-reply-to ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 "Move point to the Reply-To header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 (message-position-on-field "Reply-To" "Subject"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 (defun message-goto-newsgroups ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 "Move point to the Newsgroups header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 (message-position-on-field "Newsgroups"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 (defun message-goto-distribution ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 "Move point to the Distribution header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 (message-position-on-field "Distribution"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 (defun message-goto-followup-to ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 "Move point to the Followup-To header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 (message-position-on-field "Followup-To" "Newsgroups"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 (defun message-goto-keywords ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 "Move point to the Keywords header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 (message-position-on-field "Keywords" "Subject"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 (defun message-goto-summary ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 "Move point to the Summary header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 (message-position-on-field "Summary" "Subject"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 (defun message-goto-body ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 "Move point to the beginning of the message body."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 (if (looking-at "[ \t]*\n") (expand-abbrev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 (search-forward (concat "\n" mail-header-separator "\n") nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 (defun message-goto-signature ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 "Move point to the beginning of the message signature."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 (goto-char (point-min))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1169 (if (re-search-forward message-signature-separator nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1170 (forward-line 1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1171 (goto-char (point-max))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 (defun message-insert-to ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 "Insert a To header that points to the author of the article being replied to."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 (interactive)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1178 (let ((co (message-fetch-field "courtesy-copies-to")))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1179 (when (and co
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1180 (equal (downcase co) "never"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1181 (error "The user has requested not to have copies sent via mail")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 (when (and (message-position-on-field "To")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 (mail-fetch-field "to")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 (not (string-match "\\` *\\'" (mail-fetch-field "to"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 (insert ", "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 (insert (or (message-fetch-reply-field "reply-to")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 (message-fetch-reply-field "from") "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 (defun message-insert-newsgroups ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 "Insert the Newsgroups header from the article being replied to."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 (when (and (message-position-on-field "Newsgroups")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 (mail-fetch-field "newsgroups")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 (not (string-match "\\` *\\'" (mail-fetch-field "newsgroups"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 (insert ","))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 (insert (or (message-fetch-reply-field "newsgroups") "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 ;;; Various commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 (defun message-insert-signature (&optional force)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 "Insert a signature. See documentation for the `message-signature' variable."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 (interactive (list 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 (let* ((signature
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1206 (cond
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1207 ((and (null message-signature)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1208 (eq force 0))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1209 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1210 (goto-char (point-max))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1211 (not (re-search-backward
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1212 message-signature-separator nil t))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1213 ((and (null message-signature)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1214 force)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1215 t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1216 ((message-functionp message-signature)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1217 (funcall message-signature))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1218 ((listp message-signature)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1219 (eval message-signature))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1220 (t message-signature)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 (signature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 (cond ((stringp signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 ((and (eq t signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 message-signature-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 (file-exists-p message-signature-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 signature))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 (when signature
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1229 (goto-char (point-max))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1230 ;; Insert the signature.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 (unless (bolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 (insert "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 (insert "\n-- \n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 (if (eq signature t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 (insert-file-contents message-signature-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 (insert signature))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 (or (bolp) (insert "\n")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1240 (defun message-elide-region (b e)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1241 "Elide the text between point and mark. An ellipsis (from
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1242 message-elide-elipsis) will be inserted where the text was killed."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1243 (interactive "r")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1244 (kill-region b e)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1245 (unless (bolp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1246 (insert "\n"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1247 (insert message-elide-elipsis))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1248
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 (defvar message-caesar-translation-table nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 (defun message-caesar-region (b e &optional n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 "Caesar rotation of region by N, default 13, for decrypting netnews."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 (min (point) (or (mark t) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 (max (point) (or (mark t) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 (when current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 (prefix-numeric-value current-prefix-arg))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 (setq n (if (numberp n) (mod n 26) 13)) ;canonize N
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 (unless (or (zerop n) ; no action needed for a rot of 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 (= b e)) ; no region to rotate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 ;; We build the table, if necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 (when (or (not message-caesar-translation-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 (/= (aref message-caesar-translation-table ?a) (+ ?a n)))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
1266 (setq message-caesar-translation-table
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
1267 (message-make-caesar-translation-table n)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 ;; Then we translate the region. Do it this way to retain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 ;; text properties.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 (while (< b e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 (subst-char-in-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 b (1+ b) (char-after b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 (aref message-caesar-translation-table (char-after b)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 (incf b))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
1276 (defun message-make-caesar-translation-table (n)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
1277 "Create a rot table with offset N."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
1278 (let ((i -1)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
1279 (table (make-string 256 0)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
1280 (while (< (incf i) 256)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
1281 (aset table i i))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
1282 (concat
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
1283 (substring table 0 ?A)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
1284 (substring table (+ ?A n) (+ ?A n (- 26 n)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
1285 (substring table ?A (+ ?A n))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
1286 (substring table (+ ?A 26) ?a)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
1287 (substring table (+ ?a n) (+ ?a n (- 26 n)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
1288 (substring table ?a (+ ?a n))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
1289 (substring table (+ ?a 26) 255))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
1290
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 (defun message-caesar-buffer-body (&optional rotnum)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 "Caesar rotates all letters in the current buffer by 13 places.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 Used to encode/decode possibly offensive messages (commonly in net.jokes).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 With prefix arg, specifies the number of places to rotate each letter forward.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 Mail and USENET news headers are not rotated."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 (interactive (if current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 (list (prefix-numeric-value current-prefix-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 (list nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 (when (message-goto-body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 (narrow-to-region (point) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 (message-caesar-region (point-min) (point-max) rotnum))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1305 (defun message-pipe-buffer-body (program)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1306 "Pipe the message body in the current buffer through PROGRAM."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1307 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1308 (save-restriction
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1309 (when (message-goto-body)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1310 (narrow-to-region (point) (point-max)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1311 (let ((body (buffer-substring (point-min) (point-max))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1312 (unless (equal 0 (call-process-region
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1313 (point-min) (point-max) program t t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1314 (insert body)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1315 (gnus-message 1 "%s failed." program))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1316
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 (defun message-rename-buffer (&optional enter-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 "Rename the *message* buffer to \"*message* RECIPIENT\".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 If the function is run with a prefix, it will ask for a new buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 name, rather than giving an automatic name."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 (interactive "Pbuffer name: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 (narrow-to-region (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 (search-forward mail-header-separator nil 'end))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1327 (let* ((mail-to (or
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1328 (if (message-news-p) (message-fetch-field "Newsgroups")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1329 (message-fetch-field "To"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1330 ""))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 (mail-trimmed-to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 (if (string-match "," mail-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 (concat (substring mail-to 0 (match-beginning 0)) ", ...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 mail-to))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 (name-default (concat "*message* " mail-trimmed-to))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 (name (if enter-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337 (read-string "New buffer name: " name-default)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1338 name-default))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1339 (default-directory
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1340 (file-name-as-directory message-autosave-directory)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1341 (rename-buffer name t)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 (defun message-fill-yanked-message (&optional justifyp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344 "Fill the paragraphs of a message yanked into this one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 Numeric argument means justify as well."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 (search-forward (concat "\n" mail-header-separator "\n") nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 (let ((fill-prefix message-yank-prefix))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 (fill-individual-paragraphs (point) (point-max) justifyp t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 (defun message-indent-citation ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 "Modify text just inserted from a message to be cited.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 The inserted text should be the region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 When this function returns, the region is again around the modified text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 Normally, indent each nonblank line `message-indentation-spaces' spaces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 However, if `message-yank-prefix' is non-nil, insert that prefix on each line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 (let ((start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 ;; Remove unwanted headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 (when message-ignored-cited-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 (narrow-to-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366 (if (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 (1- (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 (point)))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1369 (message-remove-header message-ignored-cited-headers t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1370 (goto-char (point-max))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1371 ;; Delete blank lines at the start of the buffer.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1372 (while (and (point-min)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1373 (eolp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1374 (not (eobp)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1375 (message-delete-line))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1376 ;; Delete blank lines at the end of the buffer.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1377 (goto-char (point-max))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1378 (unless (eolp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1379 (insert "\n"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1380 (while (and (zerop (forward-line -1))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1381 (looking-at "$"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1382 (message-delete-line))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 ;; Do the indentation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 (if (null message-yank-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 (indent-rigidly start (mark t) message-indentation-spaces)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 (while (< (point) (mark t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 (insert message-yank-prefix)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1390 (forward-line 1))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1391 (goto-char start)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 (defun message-yank-original (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 "Insert the message being replied to, if any.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 Puts point before the text and mark after.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 Normally indents each nonblank line ARG spaces (default 3). However,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 if `message-yank-prefix' is non-nil, insert that prefix on each line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1399 This function uses `message-cite-function' to do the actual citing.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1400
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401 Just \\[universal-argument] as argument means don't indent, insert no
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 prefix, and don't delete any headers."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 (let ((modified (buffer-modified-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 (when (and message-reply-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 message-cite-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 (delete-windows-on message-reply-buffer t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 (insert-buffer message-reply-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 (funcall message-cite-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 (message-exchange-point-and-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 (unless (bolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 (insert ?\n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 (unless modified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 (setq message-checksum (cons (message-checksum) (buffer-size)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1416 (defun message-cite-original ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1417 "Cite function in the standard Message manner."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 (let ((start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 (functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 (when message-indent-citation-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421 (if (listp message-indent-citation-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 message-indent-citation-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 (list message-indent-citation-function)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 (while functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 (funcall (pop functions)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427 (when message-citation-line-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 (unless (bolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 (insert "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 (funcall message-citation-line-function))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 (defun message-insert-citation-line ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 "Function that inserts a simple citation line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434 (when message-reply-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 (insert (mail-header-from message-reply-headers) " writes:\n\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 (defun message-position-on-field (header &rest afters)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 (let ((case-fold-search t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440 (narrow-to-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444 (concat "^" (regexp-quote mail-header-separator) "$"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 (if (re-search-forward (concat "^" (regexp-quote header) ":") nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 (re-search-forward "^[^ \t]" nil 'move)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 (skip-chars-backward "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 (while (and afters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 (not (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 (concat "^" (regexp-quote (car afters)) ":")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457 (pop afters))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 (when afters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459 (re-search-forward "^[^ \t]" nil 'move)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 (beginning-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 (insert header ": \n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 (forward-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 (defun message-remove-signature ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 "Remove the signature from the text between point and mark.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 The text will also be indented the normal way."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 (let ((start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 mark)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1471 (if (not (re-search-forward message-signature-separator (mark t) t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1472 ;; No signature here, so we just indent the cited text.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1473 (message-indent-citation)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1474 ;; Find the last non-empty line.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1475 (forward-line -1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1476 (while (looking-at "[ \t]*$")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1477 (forward-line -1))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1478 (forward-line 1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1479 (setq mark (set-marker (make-marker) (point)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1480 (goto-char start)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481 (message-indent-citation)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1482 ;; Enable undoing the deletion.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1483 (undo-boundary)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1484 (delete-region mark (mark t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1485 (set-marker mark nil)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 ;;; Sending messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 (defun message-send-and-exit (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 "Send message like `message-send', then, if no errors, exit from mail buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 (let ((buf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 (actions message-exit-actions))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 (when (and (message-send arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499 (buffer-name buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 (if message-kill-buffer-on-exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501 (kill-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502 (bury-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 (when (eq buf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 (message-bury buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505 (message-do-actions actions))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 (defun message-dont-send ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 "Don't send the message you have been editing."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 (interactive)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1510 (let ((actions message-postpone-actions))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1511 (message-bury (current-buffer))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1512 (message-do-actions actions)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 (defun message-kill-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 "Kill the current buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 (let ((actions message-kill-actions))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 (kill-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 (message-do-actions actions)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 (defun message-bury (buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522 "Bury this mail buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523 (let ((newbuf (other-buffer buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 (bury-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525 (if (and (fboundp 'frame-parameters)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526 (cdr (assq 'dedicated (frame-parameters)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527 (not (null (delq (selected-frame) (visible-frame-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 (delete-frame (selected-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 (switch-to-buffer newbuf))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531 (defun message-send (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532 "Send the message in the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533 If `message-interactive' is non-nil, wait for success indication
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534 or error messages, and inform user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535 Otherwise any failure is reported in a message back to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 the user from the mailer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538 (when (if buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539 (y-or-n-p (format "Send buffer contents as %s message? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540 (if (message-mail-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541 (if (message-news-p) "mail and news" "mail")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 "news")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 (or (buffer-modified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544 (y-or-n-p "No changes in the buffer; really send? ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 ;; Make it possible to undo the coming changes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546 (undo-boundary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547 (let ((inhibit-read-only t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548 (put-text-property (point-min) (point-max) 'read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549 (message-fix-before-sending)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 (run-hooks 'message-send-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 (message "Sending...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 (when (and (or (not (message-news-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 (and (or (not (memq 'news message-sent-message-via))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554 (y-or-n-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 "Already sent message via news; resend? "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 (funcall message-send-news-function arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557 (or (not (message-mail-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 (and (or (not (memq 'mail message-sent-message-via))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559 (y-or-n-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 "Already sent message via mail; resend? "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 (message-send-mail arg))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 (message-do-fcc)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1563 ;;(when (fboundp 'mail-hist-put-headers-into-history)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1564 ;; (mail-hist-put-headers-into-history))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565 (run-hooks 'message-sent-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 (message "Sending...done")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 ;; If buffer has no file, mark it as unmodified and delete autosave.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 (unless buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570 (delete-auto-save-file-if-necessary t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 ;; Delete other mail buffers and stuff.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572 (message-do-send-housekeeping)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 (message-do-actions message-send-actions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 ;; Return success.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 (defun message-fix-before-sending ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 "Do various things to make the message nice before sending it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 ;; Make sure there's a newline at the end of the message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581 (unless (bolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 (insert "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584 (defun message-add-action (action &rest types)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585 "Add ACTION to be performed when doing an exit of type TYPES."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 (let (var)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587 (while types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 (set (setq var (intern (format "message-%s-actions" (pop types))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589 (nconc (symbol-value var) (list action))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 (defun message-do-actions (actions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592 "Perform all actions in ACTIONS."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 ;; Now perform actions on successful sending.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 (while actions
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1595 (ignore-errors
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1596 (cond
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1597 ;; A simple function.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1598 ((message-functionp (car actions))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1599 (funcall (car actions)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1600 ;; Something to be evaled.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1601 (t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1602 (eval (car actions)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 (pop actions)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 (defun message-send-mail (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606 (require 'mail-utils)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1607 (let ((tembuf (message-generate-new-buffer-clone-locals " message temp"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608 (case-fold-search nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609 (news (message-news-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610 (mailbuf (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612 (message-narrow-to-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613 ;; Insert some headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 (let ((message-deletable-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615 (if news nil message-deletable-headers)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1616 (message-generate-headers message-required-mail-headers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617 ;; Let the user do all of the above.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618 (run-hooks 'message-header-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621 (set-buffer tembuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622 (erase-buffer)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1623 ;; Avoid copying text props.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1624 (insert (format
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1625 "%s" (save-excursion
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1626 (set-buffer mailbuf)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1627 (buffer-string))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628 ;; Remove some headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630 (message-narrow-to-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 ;; Remove some headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 (message-remove-header message-ignored-mail-headers t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 ;; require one newline at the end.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 (or (= (preceding-char) ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636 (insert ?\n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637 (when (and news
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 (or (message-fetch-field "cc")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 (message-fetch-field "to")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 (message-insert-courtesy-copy))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 (funcall message-send-mail-function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642 (kill-buffer tembuf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643 (set-buffer mailbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644 (push 'mail message-sent-message-via)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646 (defun message-send-mail-with-sendmail ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1647 "Send off the prepared buffer with sendmail."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648 (let ((errbuf (if message-interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649 (generate-new-buffer " sendmail errors")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651 resend-to-addresses delimline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652 (let ((case-fold-search t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654 (message-narrow-to-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655 (setq resend-to-addresses (message-fetch-field "resent-to")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 ;; Change header-delimiter to be what sendmail expects.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1657 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1658 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659 (concat "^" (regexp-quote mail-header-separator) "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660 (replace-match "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661 (backward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1662 (setq delimline (point-marker))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1663 (run-hooks 'message-send-mail-hook)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664 ;; Insert an extra newline if we need it to work around
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665 ;; Sun's bug that swallows newlines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666 (goto-char (1+ delimline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667 (when (eval message-mailer-swallows-blank-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668 (newline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669 (when message-interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671 (set-buffer errbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672 (erase-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673 (let ((default-directory "/"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 (apply 'call-process-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1675 (append (list (point-min) (point-max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1676 (if (boundp 'sendmail-program)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677 sendmail-program
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678 "/usr/lib/sendmail")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679 nil errbuf nil "-oi")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1680 ;; Always specify who from,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681 ;; since some systems have broken sendmails.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1682 ;; But some systems are more broken with -f, so
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1683 ;; we'll let users override this.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1684 (if (null message-sendmail-f-is-evil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1685 (list "-f" (user-login-name)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1686 ;; These mean "report errors by mail"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687 ;; and "deliver in background".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688 (if (null message-interactive) '("-oem" "-odb"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689 ;; Get the addresses from the message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690 ;; unless this is a resend.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1691 ;; We must not do that for a resend
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692 ;; because we would find the original addresses.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693 ;; For a resend, include the specific addresses.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694 (if resend-to-addresses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695 (list resend-to-addresses)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1696 '("-t")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697 (when message-interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1699 (set-buffer errbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1700 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1701 (while (re-search-forward "\n\n* *" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1702 (replace-match "; "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1703 (if (not (zerop (buffer-size)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1704 (error "Sending...failed to %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1705 (buffer-substring (point-min) (point-max)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1706 (when (bufferp errbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1707 (kill-buffer errbuf)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1709 (defun message-send-mail-with-qmail ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1710 "Pass the prepared message buffer to qmail-inject.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1711 Refer to the documentation for the variable `message-send-mail-function'
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1712 to find out how to use this."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1713 ;; replace the header delimiter with a blank line
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1714 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1715 (re-search-forward
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1716 (concat "^" (regexp-quote mail-header-separator) "\n"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1717 (replace-match "\n")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1718 (run-hooks 'message-send-mail-hook)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1719 ;; send the message
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1720 (case
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1721 (apply
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1722 'call-process-region 1 (point-max) message-qmail-inject-program
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1723 nil nil nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1724 ;; qmail-inject's default behaviour is to look for addresses on the
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1725 ;; command line; if there're none, it scans the headers.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1726 ;; yes, it does The Right Thing w.r.t. Resent-To and it's kin.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1727 ;;
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1728 ;; in general, ALL of qmail-inject's defaults are perfect for simply
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1729 ;; reading a formatted (i. e., at least a To: or Resent-To header)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1730 ;; message from stdin.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1731 ;;
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1732 ;; qmail also has the advantage of not having been raped by
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1733 ;; various vendors, so we don't have to allow for that, either --
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1734 ;; compare this with message-send-mail-with-sendmail and weep
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1735 ;; for sendmail's lost innocence.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1736 ;;
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1737 ;; all this is way cool coz it lets us keep the arguments entirely
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1738 ;; free for -inject-arguments -- a big win for the user and for us
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1739 ;; since we don't have to play that double-guessing game and the user
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1740 ;; gets full control (no gestapo'ish -f's, for instance). --sj
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1741 message-qmail-inject-args)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1742 ;; qmail-inject doesn't say anything on it's stdout/stderr,
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1743 ;; we have to look at the retval instead
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1744 (0 nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1745 (1 (error "qmail-inject reported permanent failure."))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1746 (111 (error "qmail-inject reported transient failure."))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1747 ;; should never happen
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1748 (t (error "qmail-inject reported unknown failure."))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1749
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750 (defun message-send-mail-with-mh ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1751 "Send the prepared message buffer with mh."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1752 (let ((mh-previous-window-config nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1753 (name (make-temp-name
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1754 (concat (file-name-as-directory
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1755 (expand-file-name message-autosave-directory))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756 "msg."))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1757 (setq buffer-file-name name)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1758 ;; MH wants to generate these headers itself.
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 18
diff changeset
1759 (when message-mh-deletable-headers
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 18
diff changeset
1760 (let ((headers message-mh-deletable-headers))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1761 (while headers
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1762 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1763 (and (re-search-forward
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1764 (concat "^" (symbol-name (car headers)) ": *") nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1765 (message-delete-line))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1766 (pop headers))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1767 (run-hooks 'message-send-mail-hook)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1768 ;; Pass it on to mh.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1769 (mh-send-letter)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771 (defun message-send-news (&optional arg)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1772 (let ((tembuf (message-generate-new-buffer-clone-locals " *message temp*"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773 (case-fold-search nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1774 (method (if (message-functionp message-post-method)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775 (funcall message-post-method arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776 message-post-method))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777 (messbuf (current-buffer))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1778 (message-syntax-checks
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1779 (if arg
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1780 (cons '(existing-newsgroups . disabled)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1781 message-syntax-checks)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1782 message-syntax-checks))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1783 result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1785 (message-narrow-to-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1786 ;; Insert some headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1787 (message-generate-headers message-required-news-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1788 ;; Let the user do all of the above.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789 (run-hooks 'message-header-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790 (message-cleanup-headers)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1791 (if (not (message-check-news-syntax))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1792 (progn
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1793 ;;(message "Posting not performed")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1794 nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1795 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1796 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1797 (set-buffer tembuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1798 (buffer-disable-undo (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1799 (erase-buffer)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1800 ;; Avoid copying text props.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1801 (insert (format
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1802 "%s" (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1803 (set-buffer messbuf)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1804 (buffer-string))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1805 ;; Remove some headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1806 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1807 (message-narrow-to-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1808 ;; Remove some headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1809 (message-remove-header message-ignored-news-headers t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1810 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1811 ;; require one newline at the end.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812 (or (= (preceding-char) ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 (insert ?\n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814 (let ((case-fold-search t))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1815 ;; Remove the delimiter.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1816 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1817 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1818 (concat "^" (regexp-quote mail-header-separator) "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1819 (replace-match "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1820 (backward-char 1))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1821 (run-hooks 'message-send-news-hook)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1822 (require (car method))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823 (funcall (intern (format "%s-open-server" (car method)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1824 (cadr method) (cddr method))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1825 (setq result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1826 (funcall (intern (format "%s-request-post" (car method))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827 (kill-buffer tembuf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1828 (set-buffer messbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829 (if result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1830 (push 'news message-sent-message-via)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1831 (message "Couldn't send message via news: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1832 (nnheader-get-report (car method)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1833 nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1836 ;;; Header generation & syntax checking.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1837 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1838
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1839 (defmacro message-check (type &rest forms)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1840 "Eval FORMS if TYPE is to be checked."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1841 `(or (message-check-element ,type)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1842 (save-excursion
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1843 ,@forms)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1844
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1845 (put 'message-check 'lisp-indent-function 1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1846 (put 'message-check 'edebug-form-spec '(form body))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1847
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1848 (defun message-check-element (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1849 "Returns non-nil if this type is not to be checked."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1850 (if (eq message-syntax-checks 'dont-check-for-anything-just-trust-me)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1851 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1852 (let ((able (assq type message-syntax-checks)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1853 (and (consp able)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854 (eq (cdr able) 'disabled)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1856 (defun message-check-news-syntax ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1857 "Check the syntax of the message."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1858 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1859 (save-restriction
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1860 (widen)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1861 (and
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1862 ;; We narrow to the headers and check them first.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1863 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1864 (save-restriction
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1865 (message-narrow-to-headers)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1866 (message-check-news-header-syntax)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1867 ;; Check the body.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1868 (message-check-news-body-syntax)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1869
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1870 (defun message-check-news-header-syntax ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1871 (and
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1872 ;; Check for commands in Subject.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1873 (message-check 'subject-cmsg
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1874 (if (string-match "^cmsg " (message-fetch-field "subject"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1875 (y-or-n-p
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1876 "The control code \"cmsg\" is in the subject. Really post? ")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1877 t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1878 ;; Check for multiple identical headers.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1879 (message-check 'multiple-headers
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1880 (let (found)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1881 (while (and (not found)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1882 (re-search-forward "^[^ \t:]+: " nil t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1883 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1884 (or (re-search-forward
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1885 (concat "^"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1886 (regexp-quote
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1887 (setq found
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1888 (buffer-substring
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1889 (match-beginning 0) (- (match-end 0) 2))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1890 ":")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1891 nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1892 (setq found nil))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1893 (if found
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1894 (y-or-n-p (format "Multiple %s headers. Really post? " found))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1895 t)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1896 ;; Check for Version and Sendsys.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1897 (message-check 'sendsys
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1898 (if (re-search-forward "^Sendsys:\\|^Version:" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1899 (y-or-n-p
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1900 (format "The article contains a %s command. Really post? "
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1901 (buffer-substring (match-beginning 0)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1902 (1- (match-end 0)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1903 t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1904 ;; See whether we can shorten Followup-To.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1905 (message-check 'shorten-followup-to
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1906 (let ((newsgroups (message-fetch-field "newsgroups"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1907 (followup-to (message-fetch-field "followup-to"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1908 to)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1909 (when (and newsgroups
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1910 (string-match "," newsgroups)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1911 (not followup-to)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1912 (not
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1913 (zerop
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1914 (length
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1915 (setq to (completing-read
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1916 "Followups to: (default all groups) "
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1917 (mapcar (lambda (g) (list g))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1918 (cons "poster"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1919 (message-tokenize-header
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1920 newsgroups)))))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1921 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1922 (insert "Followup-To: " to "\n"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1923 t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1924 ;; Check "Shoot me".
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1925 (message-check 'shoot
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1926 (if (re-search-forward
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1927 "Message-ID.*.i-did-not-set--mail-host-address--so-shoot-me" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1928 (y-or-n-p "You appear to have a misconfigured system. Really post? ")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1929 t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1930 ;; Check for Approved.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1931 (message-check 'approved
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1932 (if (re-search-forward "^Approved:" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1933 (y-or-n-p "The article contains an Approved header. Really post? ")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1934 t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1935 ;; Check the Message-ID header.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1936 (message-check 'message-id
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1937 (let* ((case-fold-search t)
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 18
diff changeset
1938 (message-id (message-fetch-field "message-id" t)))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1939 (or (not message-id)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1940 (and (string-match "@" message-id)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1941 (string-match "@[^\\.]*\\." message-id))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1942 (y-or-n-p
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1943 (format "The Message-ID looks strange: \"%s\". Really post? "
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1944 message-id)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1945 ;; Check the Subject header.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1946 (message-check 'subject
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1947 (let* ((case-fold-search t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1948 (subject (message-fetch-field "subject")))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1949 (or
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1950 (and subject
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1951 (not (string-match "\\`[ \t]*\\'" subject)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1952 (ignore
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1953 (message
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1954 "The subject field is empty or missing. Posting is denied.")))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1955 ;; Check the Newsgroups & Followup-To headers.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1956 (message-check 'existing-newsgroups
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1957 (let* ((case-fold-search t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1958 (newsgroups (message-fetch-field "newsgroups"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1959 (followup-to (message-fetch-field "followup-to"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1960 (groups (message-tokenize-header
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1961 (if followup-to
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1962 (concat newsgroups "," followup-to)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1963 newsgroups)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1964 (hashtb (and (boundp 'gnus-active-hashtb)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1965 gnus-active-hashtb))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1966 errors)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1967 (if (or (not hashtb)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1968 (not (boundp 'gnus-read-active-file))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1969 (not gnus-read-active-file)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1970 (eq gnus-read-active-file 'some))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1971 t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1972 (while groups
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1973 (when (and (not (boundp (intern (car groups) hashtb)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1974 (not (equal (car groups) "poster")))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1975 (push (car groups) errors))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1976 (pop groups))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1977 (if (not errors)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1978 t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1979 (y-or-n-p
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1980 (format
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1981 "Really post to %s unknown group%s: %s "
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1982 (if (= (length errors) 1) "this" "these")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1983 (if (= (length errors) 1) "" "s")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1984 (mapconcat 'identity errors ", ")))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1985 ;; Check the Newsgroups & Followup-To headers for syntax errors.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1986 (message-check 'valid-newsgroups
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1987 (let ((case-fold-search t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1988 (headers '("Newsgroups" "Followup-To"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1989 header error)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1990 (while (and headers (not error))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1991 (when (setq header (mail-fetch-field (car headers)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1992 (if (or
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1993 (not
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1994 (string-match
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1995 "\\`\\([-+_&.a-zA-Z0-9]+\\)?\\(,[-+_&.a-zA-Z0-9]+\\)*\\'"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1996 header))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1997 (memq
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1998 nil (mapcar
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1999 (lambda (g)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2000 (not (string-match "\\.\\'\\|\\.\\." g)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2001 (message-tokenize-header header ","))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2002 (setq error t)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2003 (unless error
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2004 (pop headers)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2005 (if (not error)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2006 t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2007 (y-or-n-p
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2008 (format "The %s header looks odd: \"%s\". Really post? "
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2009 (car headers) header)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2010 ;; Check the From header.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2011 (message-check 'from
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2012 (let* ((case-fold-search t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2013 (from (message-fetch-field "from"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2014 (ad (nth 1 (mail-extract-address-components from))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2015 (cond
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2016 ((not from)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2017 (message "There is no From line. Posting is denied.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2018 nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2019 ((or (not (string-match "@[^\\.]*\\." ad)) ;larsi@ifi
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2020 (string-match "\\.\\." ad) ;larsi@ifi..uio
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2021 (string-match "@\\." ad) ;larsi@.ifi.uio
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2022 (string-match "\\.$" ad) ;larsi@ifi.uio.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2023 (not (string-match "^[^@]+@[^@]+$" ad)) ;larsi.ifi.uio
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2024 (string-match "(.*).*(.*)" from)) ;(lars) (lars)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2025 (message
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2026 "Denied posting -- the From looks strange: \"%s\"." from)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2027 nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2028 (t t))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2029
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2030 (defun message-check-news-body-syntax ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2031 (and
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2032 ;; Check for long lines.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2033 (message-check 'long-lines
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2034 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2035 (re-search-forward
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2036 (concat "^" (regexp-quote mail-header-separator) "$"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2037 (while (and
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2038 (progn
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2039 (end-of-line)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2040 (< (current-column) 80))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2041 (zerop (forward-line 1))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2042 (or (bolp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2043 (eobp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2044 (y-or-n-p
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2045 "You have lines longer than 79 characters. Really post? ")))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2046 ;; Check whether the article is empty.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2047 (message-check 'empty
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2048 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2049 (re-search-forward
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2050 (concat "^" (regexp-quote mail-header-separator) "$"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2051 (forward-line 1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2052 (let ((b (point)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2053 (goto-char (point-max))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2054 (re-search-backward message-signature-separator nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2055 (beginning-of-line)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2056 (or (re-search-backward "[^ \n\t]" b t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2057 (y-or-n-p "Empty article. Really post? "))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2058 ;; Check for control characters.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2059 (message-check 'control-chars
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2060 (if (re-search-forward "[\000-\007\013\015-\037\200-\237]" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2061 (y-or-n-p
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2062 "The article contains control characters. Really post? ")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2063 t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2064 ;; Check excessive size.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2065 (message-check 'size
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2066 (if (> (buffer-size) 60000)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2067 (y-or-n-p
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2068 (format "The article is %d octets long. Really post? "
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2069 (buffer-size)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2070 t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2071 ;; Check whether any new text has been added.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2072 (message-check 'new-text
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2073 (or
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2074 (not message-checksum)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2075 (not (and (eq (message-checksum) (car message-checksum))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2076 (eq (buffer-size) (cdr message-checksum))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2077 (y-or-n-p
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2078 "It looks like no new text has been added. Really post? ")))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2079 ;; Check the length of the signature.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2080 (message-check 'signature
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2081 (goto-char (point-max))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2082 (if (or (not (re-search-backward message-signature-separator nil t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2083 (search-forward message-forward-end-separator nil t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2084 t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2085 (if (> (count-lines (point) (point-max)) 5)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2086 (y-or-n-p
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2087 (format
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2088 "Your .sig is %d lines; it should be max 4. Really post? "
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2089 (1- (count-lines (point) (point-max)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2090 t)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2091
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2092 (defun message-checksum ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2093 "Return a \"checksum\" for the current buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2094 (let ((sum 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2095 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2096 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2097 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2098 (concat "^" (regexp-quote mail-header-separator) "$"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2099 (while (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2100 (when (not (looking-at "[ \t\n]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2101 (setq sum (logxor (ash sum 1) (following-char))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2102 (forward-char 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2103 sum))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2105 (defun message-do-fcc ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2106 "Process Fcc headers in the current buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2107 (let ((case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2108 (buf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2109 list file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2110 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2111 (set-buffer (get-buffer-create " *message temp*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2112 (buffer-disable-undo (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2113 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2114 (insert-buffer-substring buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2115 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2116 (message-narrow-to-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2117 (while (setq file (message-fetch-field "fcc"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2118 (push file list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2119 (message-remove-header "fcc" nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2120 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2121 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2122 (replace-match "" t t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2123 ;; Process FCC operations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2124 (while list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2125 (setq file (pop list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2126 (if (string-match "^[ \t]*|[ \t]*\\(.*\\)[ \t]*$" file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2127 ;; Pipe the article to the program in question.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2128 (call-process-region (point-min) (point-max) shell-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2129 nil nil nil shell-command-switch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2130 (match-string 1 file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2131 ;; Save the article.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2132 (setq file (expand-file-name file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2133 (unless (file-exists-p (file-name-directory file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2134 (make-directory (file-name-directory file) t))
18
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents: 16
diff changeset
2135 (if (and message-fcc-handler-function
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents: 16
diff changeset
2136 (not (eq message-fcc-handler-function 'rmail-output)))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents: 16
diff changeset
2137 (funcall message-fcc-handler-function file)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents: 16
diff changeset
2138 (if (and (file-readable-p file) (mail-file-babyl-p file))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents: 16
diff changeset
2139 (rmail-output file 1 nil t)
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents: 16
diff changeset
2140 (let ((mail-use-rfc822 t))
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents: 16
diff changeset
2141 (rmail-output file 1 t t))))))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2142
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2143 (kill-buffer (current-buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2144
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2145 (defun message-output (filename)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2146 "Append this article to Unix/babyl mail file.."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2147 (if (and (file-readable-p filename)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2148 (mail-file-babyl-p filename))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2149 (gnus-output-to-rmail filename t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2150 (gnus-output-to-mail filename t)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2151
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2152 (defun message-cleanup-headers ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2153 "Do various automatic cleanups of the headers."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2154 ;; Remove empty lines in the header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2155 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2156 (message-narrow-to-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2157 (while (re-search-forward "^[ \t]*\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2158 (replace-match "" t t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2160 ;; Correct Newsgroups and Followup-To headers: change sequence of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2161 ;; spaces to comma and eliminate spaces around commas. Eliminate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2162 ;; embedded line breaks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2163 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2164 (while (re-search-forward "^\\(Newsgroups\\|Followup-To\\): +" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2165 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2166 (narrow-to-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2167 (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2168 (if (re-search-forward "^[^ \t]" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2169 (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2170 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2171 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2172 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2173 (while (re-search-forward "\n[ \t]+" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2174 (replace-match " " t t)) ;No line breaks (too confusing)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2175 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2176 (while (re-search-forward "[ \t\n]*,[ \t\n]*\\|[ \t]+" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2177 (replace-match "," t t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2178 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2179 ;; Remove trailing commas.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2180 (when (re-search-forward ",+$" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2181 (replace-match "" t t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2183 (defun message-make-date ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2184 "Make a valid data header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2185 (let ((now (current-time)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2186 (timezone-make-date-arpa-standard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2187 (current-time-string now) (current-time-zone now))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2188
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2189 (defun message-make-message-id ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2190 "Make a unique Message-ID."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2191 (concat "<" (message-unique-id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2192 (let ((psubject (save-excursion (message-fetch-field "subject"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2193 (if (and message-reply-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2194 (mail-header-references message-reply-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2195 (mail-header-subject message-reply-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2196 psubject
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2197 (mail-header-subject message-reply-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2198 (not (string=
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2199 (message-strip-subject-re
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2200 (mail-header-subject message-reply-headers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2201 (message-strip-subject-re psubject))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2202 "_-_" ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2203 "@" (message-make-fqdn) ">"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2205 (defvar message-unique-id-char nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2206
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2207 ;; If you ever change this function, make sure the new version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2208 ;; cannot generate IDs that the old version could.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2209 ;; You might for example insert a "." somewhere (not next to another dot
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2210 ;; or string boundary), or modify the "fsf" string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2211 (defun message-unique-id ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2212 ;; Don't use microseconds from (current-time), they may be unsupported.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2213 ;; Instead we use this randomly inited counter.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2214 (setq message-unique-id-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2215 (% (1+ (or message-unique-id-char (logand (random t) (1- (lsh 1 20)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2216 ;; (current-time) returns 16-bit ints,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2217 ;; and 2^16*25 just fits into 4 digits i base 36.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2218 (* 25 25)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2219 (let ((tm (current-time)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2220 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2221 (if (memq system-type '(ms-dos emx vax-vms))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2222 (let ((user (downcase (user-login-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2223 (while (string-match "[^a-z0-9_]" user)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2224 (aset user (match-beginning 0) ?_))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2225 user)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2226 (message-number-base36 (user-uid) -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2227 (message-number-base36 (+ (car tm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2228 (lsh (% message-unique-id-char 25) 16)) 4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2229 (message-number-base36 (+ (nth 1 tm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2230 (lsh (/ message-unique-id-char 25) 16)) 4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2231 ;; Append the newsreader name, because while the generated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2232 ;; ID is unique to this newsreader, other newsreaders might
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2233 ;; otherwise generate the same ID via another algorithm.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2234 ".fsf")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2236 (defun message-number-base36 (num len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2237 (if (if (< len 0) (<= num 0) (= len 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2238 ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2239 (concat (message-number-base36 (/ num 36) (1- len))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2240 (char-to-string (aref "zyxwvutsrqponmlkjihgfedcba9876543210"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2241 (% num 36))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2242
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2243 (defun message-make-organization ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2244 "Make an Organization header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2245 (let* ((organization
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2246 (or (getenv "ORGANIZATION")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2247 (when message-user-organization
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2248 (if (message-functionp message-user-organization)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2249 (funcall message-user-organization)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2250 message-user-organization)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2251 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2252 (message-set-work-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2253 (cond ((stringp organization)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2254 (insert organization))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2255 ((and (eq t organization)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2256 message-user-organization-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2257 (file-exists-p message-user-organization-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2258 (insert-file-contents message-user-organization-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2259 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2260 (while (re-search-forward "[\t\n]+" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2261 (replace-match "" t t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2262 (unless (zerop (buffer-size))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2263 (buffer-string)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2265 (defun message-make-lines ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2266 "Count the number of lines and return numeric string."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2267 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2268 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2269 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2270 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2271 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2272 (concat "^" (regexp-quote mail-header-separator) "$"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2273 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2274 (int-to-string (count-lines (point) (point-max))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2275
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2276 (defun message-make-in-reply-to ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2277 "Return the In-Reply-To header for this message."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2278 (when message-reply-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2279 (let ((from (mail-header-from message-reply-headers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2280 (date (mail-header-date message-reply-headers)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2281 (when from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2282 (let ((stop-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2283 (string-match " *at \\| *@ \\| *(\\| *<" from)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2284 (concat (if stop-pos (substring from 0 stop-pos) from)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2285 "'s message of "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2286 (if (or (not date) (string= date ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2287 "(unknown date)" date)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2288
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2289 (defun message-make-distribution ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2290 "Make a Distribution header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2291 (let ((orig-distribution (message-fetch-reply-field "distribution")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2292 (cond ((message-functionp message-distribution-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2293 (funcall message-distribution-function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2294 (t orig-distribution))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2295
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2296 (defun message-make-expires ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2297 "Return an Expires header based on `message-expires'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2298 (let ((current (current-time))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2299 (future (* 1.0 message-expires 60 60 24)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2300 ;; Add the future to current.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2301 (setcar current (+ (car current) (round (/ future (expt 2 16)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2302 (setcar (cdr current) (+ (nth 1 current) (% (round future) (expt 2 16))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2303 ;; Return the date in the future in UT.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2304 (timezone-make-date-arpa-standard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2305 (current-time-string current) (current-time-zone current) '(0 "UT"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2306
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2307 (defun message-make-path ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2308 "Return uucp path."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2309 (let ((login-name (user-login-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2310 (cond ((null message-user-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2311 (concat (system-name) "!" login-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2312 ((stringp message-user-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2313 ;; Support GENERICPATH. Suggested by vixie@decwrl.dec.com.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2314 (concat message-user-path "!" login-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2315 (t login-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2316
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2317 (defun message-make-from ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2318 "Make a From header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2319 (let* ((login (message-make-address))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2320 (fullname
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2321 (or (and (boundp 'user-full-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2322 user-full-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2323 (user-full-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2324 (when (string= fullname "&")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2325 (setq fullname (user-login-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2326 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2327 (message-set-work-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2328 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2329 ((or (null message-from-style)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2330 (equal fullname ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2331 (insert login))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2332 ((or (eq message-from-style 'angles)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2333 (and (not (eq message-from-style 'parens))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2334 ;; Use angles if no quoting is needed, or if parens would
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2335 ;; need quoting too.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2336 (or (not (string-match "[^- !#-'*+/-9=?A-Z^-~]" fullname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2337 (let ((tmp (concat fullname nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2338 (while (string-match "([^()]*)" tmp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2339 (aset tmp (match-beginning 0) ?-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2340 (aset tmp (1- (match-end 0)) ?-))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2341 (string-match "[\\()]" tmp)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2342 (insert fullname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2343 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2344 ;; Look for a character that cannot appear unquoted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2345 ;; according to RFC 822.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2346 (when (re-search-forward "[^- !#-'*+/-9=?A-Z^-~]" nil 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2347 ;; Quote fullname, escaping specials.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2348 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2349 (insert "\"")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2350 (while (re-search-forward "[\"\\]" nil 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2351 (replace-match "\\\\\\&" t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2352 (insert "\""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2353 (insert " <" login ">"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2354 (t ; 'parens or default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2355 (insert login " (")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2356 (let ((fullname-start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2357 (insert fullname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2358 (goto-char fullname-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2359 ;; RFC 822 says \ and nonmatching parentheses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2360 ;; must be escaped in comments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2361 ;; Escape every instance of ()\ ...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2362 (while (re-search-forward "[()\\]" nil 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2363 (replace-match "\\\\\\&" t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2364 ;; ... then undo escaping of matching parentheses,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2365 ;; including matching nested parentheses.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2366 (goto-char fullname-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2367 (while (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2368 "\\(\\=\\|[^\\]\\(\\\\\\\\\\)*\\)\\\\(\\(\\([^\\]\\|\\\\\\\\\\)*\\)\\\\)"
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2369 nil 1)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2370 (replace-match "\\1(\\3)" t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2371 (goto-char fullname-start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2372 (insert ")")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2373 (buffer-string))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2374
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2375 (defun message-make-sender ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2376 "Return the \"real\" user address.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2377 This function tries to ignore all user modifications, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2378 give as trustworthy answer as possible."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2379 (concat (user-login-name) "@" (system-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2380
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2381 (defun message-make-address ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2382 "Make the address of the user."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2383 (or (message-user-mail-address)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2384 (concat (user-login-name) "@" (message-make-domain))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2385
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2386 (defun message-user-mail-address ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2387 "Return the pertinent part of `user-mail-address'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2388 (when user-mail-address
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2389 (if (string-match " " user-mail-address)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2390 (nth 1 (mail-extract-address-components user-mail-address))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2391 user-mail-address)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2392
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2393 (defun message-make-fqdn ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2394 "Return user's fully qualified domain name."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2395 (let ((system-name (system-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2396 (user-mail (message-user-mail-address)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2397 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2398 ((string-match "[^.]\\.[^.]" system-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2399 ;; `system-name' returned the right result.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2400 system-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2401 ;; Try `mail-host-address'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2402 ((and (boundp 'mail-host-address)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2403 (stringp mail-host-address)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2404 (string-match "\\." mail-host-address))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2405 mail-host-address)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2406 ;; We try `user-mail-address' as a backup.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2407 ((and (string-match "\\." user-mail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2408 (string-match "@\\(.*\\)\\'" user-mail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2409 (match-string 1 user-mail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2410 ;; Default to this bogus thing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2411 (t
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2412 (concat system-name ".i-did-not-set--mail-host-address--so-shoot-me")))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2413
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2414 (defun message-make-host-name ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2415 "Return the name of the host."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2416 (let ((fqdn (message-make-fqdn)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2417 (string-match "^[^.]+\\." fqdn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2418 (substring fqdn 0 (1- (match-end 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2419
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2420 (defun message-make-domain ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2421 "Return the domain name."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2422 (or mail-host-address
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2423 (message-make-fqdn)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2424
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2425 (defun message-generate-headers (headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2426 "Prepare article HEADERS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2427 Headers already prepared in the buffer are not modified."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2428 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2429 (message-narrow-to-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2430 (let* ((Date (message-make-date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2431 (Message-ID (message-make-message-id))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2432 (Organization (message-make-organization))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2433 (From (message-make-from))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2434 (Path (message-make-path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2435 (Subject nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2436 (Newsgroups nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2437 (In-Reply-To (message-make-in-reply-to))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2438 (To nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2439 (Distribution (message-make-distribution))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2440 (Lines (message-make-lines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2441 (X-Newsreader message-newsreader)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2442 (X-Mailer (and (not (message-fetch-field "X-Newsreader"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2443 message-mailer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2444 (Expires (message-make-expires))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2445 (case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2446 header value elem)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2447 ;; First we remove any old generated headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2448 (let ((headers message-deletable-headers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2449 (while headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2450 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2451 (and (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2452 (concat "^" (symbol-name (car headers)) ": *") nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2453 (get-text-property (1+ (match-beginning 0)) 'message-deletable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2454 (message-delete-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2455 (pop headers)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2456 ;; Go through all the required headers and see if they are in the
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2457 ;; articles already. If they are not, or are empty, they are
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2458 ;; inserted automatically - except for Subject, Newsgroups and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2459 ;; Distribution.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2460 (while headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2461 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2462 (setq elem (pop headers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2463 (if (consp elem)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2464 (if (eq (car elem) 'optional)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2465 (setq header (cdr elem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2466 (setq header (car elem)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2467 (setq header elem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2468 (when (or (not (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2469 (concat "^" (downcase (symbol-name header)) ":")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2470 nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2471 (progn
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2472 ;; The header was found. We insert a space after the
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2473 ;; colon, if there is none.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2474 (if (/= (following-char) ? ) (insert " ") (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2475 ;; Find out whether the header is empty...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2476 (looking-at "[ \t]*$")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2477 ;; So we find out what value we should insert.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2478 (setq value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2479 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2480 ((and (consp elem) (eq (car elem) 'optional))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2481 ;; This is an optional header. If the cdr of this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2482 ;; is something that is nil, then we do not insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2483 ;; this header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2484 (setq header (cdr elem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2485 (or (and (fboundp (cdr elem)) (funcall (cdr elem)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2486 (and (boundp (cdr elem)) (symbol-value (cdr elem)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2487 ((consp elem)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2488 ;; The element is a cons. Either the cdr is a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2489 ;; string to be inserted verbatim, or it is a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2490 ;; function, and we insert the value returned from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2491 ;; this function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2492 (or (and (stringp (cdr elem)) (cdr elem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2493 (and (fboundp (cdr elem)) (funcall (cdr elem)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2494 ((and (boundp header) (symbol-value header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2495 ;; The element is a symbol. We insert the value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2496 ;; of this symbol, if any.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2497 (symbol-value header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2498 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2499 ;; We couldn't generate a value for this header,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2500 ;; so we just ask the user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2501 (read-from-minibuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2502 (format "Empty header for %s; enter value: " header)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2503 ;; Finally insert the header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2504 (when (and value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2505 (not (equal value "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2506 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2507 (if (bolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2508 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2509 ;; This header didn't exist, so we insert it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2510 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2511 (insert (symbol-name header) ": " value "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2512 (forward-line -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2513 ;; The value of this header was empty, so we clear
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2514 ;; totally and insert the new value.
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
2515 (delete-region (point) (gnus-point-at-eol))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2516 (insert value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2517 ;; Add the deletable property to the headers that require it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2518 (and (memq header message-deletable-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2519 (progn (beginning-of-line) (looking-at "[^:]+: "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2520 (add-text-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2521 (point) (match-end 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2522 '(message-deletable t face italic) (current-buffer)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2523 ;; Insert new Sender if the From is strange.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2524 (let ((from (message-fetch-field "from"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2525 (sender (message-fetch-field "sender"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2526 (secure-sender (message-make-sender)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2527 (when (and from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2528 (not (message-check-element 'sender))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2529 (not (string=
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2530 (downcase
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2531 (cadr (mail-extract-address-components from)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2532 (downcase secure-sender)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2533 (or (null sender)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2534 (not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2535 (string=
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2536 (downcase
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2537 (cadr (mail-extract-address-components sender)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2538 (downcase secure-sender)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2539 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2540 ;; Rename any old Sender headers to Original-Sender.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2541 (when (re-search-forward "^\\(Original-\\)*Sender:" nil t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2542 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2543 (insert "Original-")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2544 (beginning-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2545 (insert "Sender: " secure-sender "\n"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2546
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2547 (defun message-insert-courtesy-copy ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2548 "Insert a courtesy message in mail copies of combined messages."
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2549 (let (newsgroups)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2550 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2551 (save-restriction
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2552 (message-narrow-to-headers)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2553 (when (setq newsgroups (message-fetch-field "newsgroups"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2554 (goto-char (point-max))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2555 (insert "Posted-To: " newsgroups "\n")))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2556 (forward-line 1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2557 (when message-courtesy-message
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2558 (cond
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2559 ((string-match "%s" message-courtesy-message)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2560 (insert (format message-courtesy-message newsgroups)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2561 (t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2562 (insert message-courtesy-message)))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2563
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2564 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2565 ;;; Setting up a message buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2566 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2567
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2568 (defun message-fill-address (header value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2569 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2570 (narrow-to-region (point) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2571 (insert (capitalize (symbol-name header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2572 ": "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2573 (if (consp value) (car value) value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2574 "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2575 (narrow-to-region (point-min) (1- (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2576 (let (quoted last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2577 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2578 (while (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2579 (skip-chars-forward "^,\"" (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2580 (if (or (= (following-char) ?,)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2581 (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2582 (when (not quoted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2583 (if (and (> (current-column) 78)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2584 last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2585 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2586 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2587 (goto-char last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2588 (insert "\n\t"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2589 (setq last (1+ (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2590 (setq last (1+ (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2591 (setq quoted (not quoted)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2592 (unless (eobp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2593 (forward-char 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2594 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2595 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2596 (forward-line 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2597
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2598 (defun message-fill-header (header value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2599 (let ((begin (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2600 (fill-column 78)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2601 (fill-prefix "\t"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2602 (insert (capitalize (symbol-name header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2603 ": "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2604 (if (consp value) (car value) value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2605 "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2606 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2607 (narrow-to-region begin (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2608 (fill-region-as-paragraph begin (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2609 ;; Tapdance around looong Message-IDs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2610 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2611 (when (looking-at "[ \t]*$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2612 (message-delete-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2613 (goto-char begin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2614 (re-search-forward ":" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2615 (when (looking-at "\n[ \t]+")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2616 (replace-match " " t t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2617 (goto-char (point-max)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2618
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2619 (defun message-position-point ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2620 "Move point to where the user probably wants to find it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2621 (message-narrow-to-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2622 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2623 ((re-search-forward "^[^:]+:[ \t]*$" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2624 (search-backward ":" )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2625 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2626 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2627 (if (= (following-char) ? )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2628 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2629 (insert " ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2630 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2631 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2632 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2633 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2634 (unless (looking-at "$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2635 (forward-line 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2636 (sit-for 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2637
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2638 (defun message-buffer-name (type &optional to group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2639 "Return a new (unique) buffer name based on TYPE and TO."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2640 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2641 ;; Check whether `message-generate-new-buffers' is a function,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2642 ;; and if so, call it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2643 ((message-functionp message-generate-new-buffers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2644 (funcall message-generate-new-buffers type to group))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2645 ;; Generate a new buffer name The Message Way.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2646 (message-generate-new-buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2647 (generate-new-buffer-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2648 (concat "*" type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2649 (if to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2650 (concat " to "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2651 (or (car (mail-extract-address-components to))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2652 to) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2653 "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2654 (if (and group (not (string= group ""))) (concat " on " group) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2655 "*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2656 ;; Use standard name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2657 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2658 (format "*%s message*" type))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2659
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2660 (defun message-pop-to-buffer (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2661 "Pop to buffer NAME, and warn if it already exists and is modified."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2662 (let ((buffer (get-buffer name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2663 (if (and buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2664 (buffer-name buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2665 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2666 (set-buffer (pop-to-buffer buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2667 (when (and (buffer-modified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2668 (not (y-or-n-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2669 "Message already being composed; erase? ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2670 (error "Message being composed")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2671 (set-buffer (pop-to-buffer name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2672 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2673 (message-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2674
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2675 (defun message-do-send-housekeeping ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2676 "Kill old message buffers."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2677 ;; We might have sent this buffer already. Delete it from the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2678 ;; list of buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2679 (setq message-buffer-list (delq (current-buffer) message-buffer-list))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2680 (while (and message-max-buffers
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2681 message-buffer-list
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2682 (>= (length message-buffer-list) message-max-buffers))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2683 ;; Kill the oldest buffer -- unless it has been changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2684 (let ((buffer (pop message-buffer-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2685 (when (and (buffer-name buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2686 (not (buffer-modified-p buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2687 (kill-buffer buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2688 ;; Rename the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2689 (if message-send-rename-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2690 (funcall message-send-rename-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2691 (when (string-match "\\`\\*" (buffer-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2692 (rename-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2693 (concat "*sent " (substring (buffer-name) (match-end 0))) t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2694 ;; Push the current buffer onto the list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2695 (when message-max-buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2696 (setq message-buffer-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2697 (nconc message-buffer-list (list (current-buffer))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2698
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2699 (defvar mc-modes-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2700 (defun message-setup (headers &optional replybuffer actions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2701 (when (and (boundp 'mc-modes-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2702 (not (assq 'message-mode mc-modes-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2703 (push '(message-mode (encrypt . mc-encrypt-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2704 (sign . mc-sign-message))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2705 mc-modes-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2706 (when actions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2707 (setq message-send-actions actions))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2708 (setq message-reply-buffer replybuffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2709 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2710 ;; Insert all the headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2711 (mail-header-format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2712 (let ((h headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2713 (alist message-header-format-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2714 (while h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2715 (unless (assq (caar h) message-header-format-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2716 (push (list (caar h)) alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2717 (pop h))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2718 alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2719 headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2720 (delete-region (point) (progn (forward-line -1) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2721 (when message-default-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2722 (insert message-default-headers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2723 (put-text-property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2724 (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2725 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2726 (insert mail-header-separator "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2727 (1- (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2728 'read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2729 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2730 (when (message-news-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2731 (when message-default-news-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2732 (insert message-default-news-headers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2733 (when message-generate-headers-first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2734 (message-generate-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2735 (delq 'Lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2736 (delq 'Subject
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2737 (copy-sequence message-required-news-headers))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2738 (when (message-mail-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2739 (when message-default-mail-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2740 (insert message-default-mail-headers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2741 (when message-generate-headers-first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2742 (message-generate-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2743 (delq 'Lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2744 (delq 'Subject
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2745 (copy-sequence message-required-mail-headers))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2746 (run-hooks 'message-signature-setup-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2747 (message-insert-signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2748 (message-set-auto-save-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2749 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2750 (message-narrow-to-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2751 (run-hooks 'message-header-setup-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2752 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2753 (run-hooks 'message-setup-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2754 (message-position-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2755 (undo-boundary))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2756
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2757 (defun message-set-auto-save-file-name ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2758 "Associate the message buffer with a file in the drafts directory."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2759 (when message-autosave-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2760 (unless (file-exists-p message-autosave-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2761 (make-directory message-autosave-directory t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2762 (let ((name (make-temp-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2763 (concat (file-name-as-directory message-autosave-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2764 "msg."))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2765 (setq buffer-auto-save-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2766 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2767 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2768 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2769 (set-buffer (get-buffer-create " *draft tmp*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2770 (setq buffer-file-name name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2771 (make-auto-save-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2772 (kill-buffer (current-buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2773 (clear-visited-file-modtime))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2774
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2775
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2776
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2777 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2778 ;;; Commands for interfacing with message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2779 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2780
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2781 ;;;###autoload
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2782 (defun message-mail (&optional to subject
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2783 other-headers continue switch-function
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2784 yank-action send-actions)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2785 "Start editing a mail message to be sent."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2786 (interactive)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2787 (let ((message-this-is-mail t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2788 (message-pop-to-buffer (message-buffer-name "mail" to))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2789 (message-setup
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2790 (nconc
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2791 `((To . ,(or to "")) (Subject . ,(or subject "")))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2792 (when other-headers (list other-headers))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2793
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2794 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2795 (defun message-news (&optional newsgroups subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2796 "Start editing a news article to be sent."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2797 (interactive)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2798 (let ((message-this-is-news t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2799 (message-pop-to-buffer (message-buffer-name "news" nil newsgroups))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2800 (message-setup `((Newsgroups . ,(or newsgroups ""))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2801 (Subject . ,(or subject ""))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2802
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2803 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2804 (defun message-reply (&optional to-address wide ignore-reply-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2805 "Start editing a reply to the article in the current buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2806 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2807 (let ((cur (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2808 from subject date reply-to to cc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2809 references message-id follow-to
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2810 (inhibit-point-motion-hooks t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2811 mct never-mct gnus-warning)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2812 (save-restriction
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2813 (message-narrow-to-head)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2814 ;; Allow customizations to have their say.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2815 (if (not wide)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2816 ;; This is a regular reply.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2817 (if (message-functionp message-reply-to-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2818 (setq follow-to (funcall message-reply-to-function)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2819 ;; This is a followup.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2820 (if (message-functionp message-wide-reply-to-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2821 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2822 (setq follow-to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2823 (funcall message-wide-reply-to-function)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2824 ;; Find all relevant headers we need.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2825 (setq from (message-fetch-field "from")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2826 date (message-fetch-field "date")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2827 subject (or (message-fetch-field "subject") "none")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2828 to (message-fetch-field "to")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2829 cc (message-fetch-field "cc")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2830 mct (message-fetch-field "mail-copies-to")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2831 reply-to (unless ignore-reply-to (message-fetch-field "reply-to"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2832 references (message-fetch-field "references")
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 18
diff changeset
2833 message-id (message-fetch-field "message-id" t))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2834 ;; Remove any (buggy) Re:'s that are present and make a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2835 ;; proper one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2836 (when (string-match "^[ \t]*[Rr][Ee]:[ \t]*" subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2837 (setq subject (substring subject (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2838 (setq subject (concat "Re: " subject))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2839
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2840 (when (and (setq gnus-warning (message-fetch-field "gnus-warning"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2841 (string-match "<[^>]+>" gnus-warning))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2842 (setq message-id (match-string 0 gnus-warning)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2843
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2844 ;; Handle special values of Mail-Copies-To.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2845 (when mct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2846 (cond ((equal (downcase mct) "never")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2847 (setq never-mct t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2848 (setq mct nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2849 ((equal (downcase mct) "always")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2850 (setq mct (or reply-to from)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2851
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2852 (unless follow-to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2853 (if (or (not wide)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2854 to-address)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2855 (setq follow-to (list (cons 'To (or to-address reply-to from))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2856 (let (ccalist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2857 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2858 (message-set-work-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2859 (unless never-mct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2860 (insert (or reply-to from "")))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2861 (insert (if (bolp) "" ", ") (or to ""))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2862 (insert (if mct (concat (if (bolp) "" ", ") mct) ""))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2863 (insert (if cc (concat (if (bolp) "" ", ") cc) ""))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2864 ;; Remove addresses that match `rmail-dont-reply-to-names'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2865 (insert (prog1 (rmail-dont-reply-to (buffer-string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2866 (erase-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2867 (goto-char (point-min))
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 18
diff changeset
2868 ;; Perhaps Mail-Copies-To: never removed the only address?
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 18
diff changeset
2869 (when (eobp)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 18
diff changeset
2870 (insert (or reply-to from "")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2871 (setq ccalist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2872 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2873 (lambda (addr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2874 (cons (mail-strip-quoted-names addr) addr))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2875 (message-tokenize-header (buffer-string))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2876 (let ((s ccalist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2877 (while s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2878 (setq ccalist (delq (assoc (car (pop s)) s) ccalist)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2879 (setq follow-to (list (cons 'To (cdr (pop ccalist)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2880 (when ccalist
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2881 (let ((ccs (cons 'Cc (mapconcat
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2882 (lambda (addr) (cdr addr)) ccalist ", "))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2883 (when (string-match "^ +" (cdr ccs))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2884 (setcdr ccs (substring (cdr ccs) (match-end 0))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2885 (push ccs follow-to))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2886 (widen))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2887
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2888 (message-pop-to-buffer (message-buffer-name
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2889 (if wide "wide reply" "reply") from
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2890 (if wide to-address nil)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2891
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2892 (setq message-reply-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2893 (vector 0 subject from date message-id references 0 0 ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2894
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2895 (message-setup
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2896 `((Subject . ,subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2897 ,@follow-to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2898 ,@(if (or references message-id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2899 `((References . ,(concat (or references "") (and references " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2900 (or message-id ""))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2901 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2902 cur)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2903
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2904 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2905 (defun message-wide-reply (&optional to-address)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2906 "Make a \"wide\" reply to the message in the current buffer."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2907 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2908 (message-reply to-address t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2909
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2910 ;;;###autoload
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2911 (defun message-followup (&optional to-newsgroups)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2912 "Follow up to the message in the current buffer.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2913 If TO-NEWSGROUPS, use that as the new Newsgroups line."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2914 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2915 (let ((cur (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2916 from subject date reply-to mct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2917 references message-id follow-to
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2918 (inhibit-point-motion-hooks t)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2919 (message-this-is-news t)
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
2920 followup-to distribution newsgroups gnus-warning posted-to)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2921 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2922 (narrow-to-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2923 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2924 (if (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2925 (1- (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2926 (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2927 (when (message-functionp message-followup-to-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2928 (setq follow-to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2929 (funcall message-followup-to-function)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2930 (setq from (message-fetch-field "from")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2931 date (message-fetch-field "date")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2932 subject (or (message-fetch-field "subject") "none")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2933 references (message-fetch-field "references")
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 18
diff changeset
2934 message-id (message-fetch-field "message-id" t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2935 followup-to (message-fetch-field "followup-to")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2936 newsgroups (message-fetch-field "newsgroups")
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
2937 posted-to (message-fetch-field "posted-to")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2938 reply-to (message-fetch-field "reply-to")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2939 distribution (message-fetch-field "distribution")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2940 mct (message-fetch-field "mail-copies-to"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2941 (when (and (setq gnus-warning (message-fetch-field "gnus-warning"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2942 (string-match "<[^>]+>" gnus-warning))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2943 (setq message-id (match-string 0 gnus-warning)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2944 ;; Remove bogus distribution.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2945 (when (and (stringp distribution)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2946 (let ((case-fold-search t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2947 (string-match "world" distribution)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2948 (setq distribution nil))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2949 ;; Remove any (buggy) Re:'s that are present and make a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2950 ;; proper one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2951 (when (string-match "^[ \t]*[Rr][Ee]:[ \t]*" subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2952 (setq subject (substring subject (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2953 (setq subject (concat "Re: " subject))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2954 (widen))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2955
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2956 (message-pop-to-buffer (message-buffer-name "followup" from newsgroups))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2957
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2958 (message-setup
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2959 `((Subject . ,subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2960 ,@(cond
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2961 (to-newsgroups
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2962 (list (cons 'Newsgroups to-newsgroups)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2963 (follow-to follow-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2964 ((and followup-to message-use-followup-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2965 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2966 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2967 ((equal (downcase followup-to) "poster")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2968 (if (or (eq message-use-followup-to 'use)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2969 (message-y-or-n-p "Obey Followup-To: poster? " t "\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2970 You should normally obey the Followup-To: header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2971
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2972 `Followup-To: poster' sends your response via e-mail instead of news.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2973
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2974 A typical situation where `Followup-To: poster' is used is when the poster
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2975 does not read the newsgroup, so he wouldn't see any replies sent to it."))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
2976 (progn
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
2977 (setq message-this-is-news nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
2978 (cons 'To (or reply-to from "")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2979 (cons 'Newsgroups newsgroups)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2980 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2981 (if (or (equal followup-to newsgroups)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2982 (not (eq message-use-followup-to 'ask))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2983 (message-y-or-n-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2984 (concat "Obey Followup-To: " followup-to "? ") t "\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2985 You should normally obey the Followup-To: header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2986
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2987 `Followup-To: " followup-to "'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2988 directs your response to " (if (string-match "," followup-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2989 "the specified newsgroups"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2990 "that newsgroup only") ".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2991
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2992 If a message is posted to several newsgroups, Followup-To is often
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2993 used to direct the following discussion to one newsgroup only,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2994 because discussions that are spread over several newsgroup tend to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2995 be fragmented and very difficult to follow.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2996
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2997 Also, some source/announcement newsgroups are not indented for discussion;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2998 responses here are directed to other newsgroups."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2999 (cons 'Newsgroups followup-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3000 (cons 'Newsgroups newsgroups))))))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
3001 (posted-to
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 22
diff changeset
3002 `((Newsgroups . ,posted-to)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3003 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3004 `((Newsgroups . ,newsgroups))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3005 ,@(and distribution (list (cons 'Distribution distribution)))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3006 ,@(if (or references message-id)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3007 `((References . ,(concat (or references "") (and references " ")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3008 (or message-id "")))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3009 ,@(when (and mct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3010 (not (equal (downcase mct) "never")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3011 (list (cons 'Cc (if (equal (downcase mct) "always")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3012 (or reply-to from "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3013 mct)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3014
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3015 cur)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3016
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3017 (setq message-reply-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3018 (vector 0 subject from date message-id references 0 0 ""))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3019
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3020
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3021 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3022 (defun message-cancel-news ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3023 "Cancel an article you posted."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3024 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3025 (unless (message-news-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3026 (error "This is not a news article; canceling is impossible"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3027 (when (yes-or-no-p "Do you really want to cancel this article? ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3028 (let (from newsgroups message-id distribution buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3029 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3030 ;; Get header info. from original article.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3031 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3032 (message-narrow-to-head)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3033 (setq from (message-fetch-field "from")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3034 newsgroups (message-fetch-field "newsgroups")
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 18
diff changeset
3035 message-id (message-fetch-field "message-id" t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3036 distribution (message-fetch-field "distribution")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3037 ;; Make sure that this article was written by the user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3038 (unless (string-equal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3039 (downcase (cadr (mail-extract-address-components from)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3040 (downcase (message-make-address)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3041 (error "This article is not yours"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3042 ;; Make control message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3043 (setq buf (set-buffer (get-buffer-create " *message cancel*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3044 (buffer-disable-undo (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3045 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3046 (insert "Newsgroups: " newsgroups "\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3047 "From: " (message-make-from) "\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3048 "Subject: cmsg cancel " message-id "\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3049 "Control: cancel " message-id "\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3050 (if distribution
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3051 (concat "Distribution: " distribution "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3052 "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3053 mail-header-separator "\n"
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3054 message-cancel-message)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3055 (message "Canceling your article...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3056 (let ((message-syntax-checks 'dont-check-for-anything-just-trust-me))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3057 (funcall message-send-news-function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3058 (message "Canceling your article...done")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3059 (kill-buffer buf)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3060
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3061 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3062 (defun message-supersede ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3063 "Start composing a message to supersede the current message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3064 This is done simply by taking the old article and adding a Supersedes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3065 header line with the old Message-ID."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3066 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3067 (let ((cur (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3068 ;; Check whether the user owns the article that is to be superseded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3069 (unless (string-equal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3070 (downcase (cadr (mail-extract-address-components
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3071 (message-fetch-field "from"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3072 (downcase (message-make-address)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3073 (error "This article is not yours"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3074 ;; Get a normal message buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3075 (message-pop-to-buffer (message-buffer-name "supersede"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3076 (insert-buffer-substring cur)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3077 (message-narrow-to-head)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3078 ;; Remove unwanted headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3079 (when message-ignored-supersedes-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3080 (message-remove-header message-ignored-supersedes-headers t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3081 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3082 (if (not (re-search-forward "^Message-ID: " nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3083 (error "No Message-ID in this article")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3084 (replace-match "Supersedes: " t t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3085 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3086 (insert mail-header-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3087 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3088 (forward-line 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3089
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3090 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3091 (defun message-recover ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3092 "Reread contents of current buffer from its last auto-save file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3093 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3094 (let ((file-name (make-auto-save-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3095 (cond ((save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3096 (if (not (eq system-type 'vax-vms))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3097 (with-output-to-temp-buffer "*Directory*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3098 (buffer-disable-undo standard-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3099 (let ((default-directory "/"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3100 (call-process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3101 "ls" nil standard-output nil "-l" file-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3102 (yes-or-no-p (format "Recover auto save file %s? " file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3103 (let ((buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3104 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3105 (insert-file-contents file-name nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3106 (t (error "message-recover cancelled")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3108 ;;; Forwarding messages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3110 (defun message-make-forward-subject ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3111 "Return a Subject header suitable for the message in the current buffer."
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3112 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3113 (save-restriction
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3114 (current-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3115 (message-narrow-to-head)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3116 (concat "[" (or (message-fetch-field
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3117 (if (message-news-p) "newsgroups" "from"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3118 "(nowhere)")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3119 "] " (or (message-fetch-field "Subject") "")))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3121 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3122 (defun message-forward (&optional news)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3123 "Forward the current message via mail.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3124 Optional NEWS will use news to forward instead of mail."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3125 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3126 (let ((cur (current-buffer))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3127 (subject (message-make-forward-subject))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3128 art-beg)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3129 (if news (message-news nil subject) (message-mail nil subject))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3130 ;; Put point where we want it before inserting the forwarded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3131 ;; message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3132 (if message-signature-before-forwarded-message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3133 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3134 (message-goto-body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3135 ;; Make sure we're at the start of the line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3136 (unless (eolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3137 (insert "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3138 ;; Narrow to the area we are to insert.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3139 (narrow-to-region (point) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3140 ;; Insert the separators and the forwarded buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3141 (insert message-forward-start-separator)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3142 (setq art-beg (point))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3143 (insert-buffer-substring cur)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3144 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3145 (insert message-forward-end-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3146 (set-text-properties (point-min) (point-max) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3147 ;; Remove all unwanted headers.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3148 (goto-char art-beg)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3149 (narrow-to-region (point) (if (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3150 (1- (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3151 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3152 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3153 (message-remove-header message-included-forward-headers t nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3154 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3155 (message-position-point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3156
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3157 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3158 (defun message-resend (address)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3159 "Resend the current article to ADDRESS."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3160 (interactive "sResend message to: ")
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3161 (message "Resending message to %s..." address)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3162 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3163 (let ((cur (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3164 beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3165 ;; We first set up a normal mail buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3166 (set-buffer (get-buffer-create " *message resend*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3167 (buffer-disable-undo (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3168 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3169 (message-setup `((To . ,address)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3170 ;; Insert our usual headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3171 (message-generate-headers '(From Date To))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3172 (message-narrow-to-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3173 ;; Rename them all to "Resent-*".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3174 (while (re-search-forward "^[A-Za-z]" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3175 (forward-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3176 (insert "Resent-"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3177 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3178 (forward-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3179 (delete-region (point) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3180 (setq beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3181 ;; Insert the message to be resent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3182 (insert-buffer-substring cur)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3183 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3184 (search-forward "\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3185 (forward-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3186 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3187 (narrow-to-region beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3188 (message-remove-header message-ignored-resent-headers t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3189 (goto-char (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3190 (insert mail-header-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3191 ;; Rename all old ("Also-")Resent headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3192 (while (re-search-backward "^\\(Also-\\)?Resent-" beg t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3193 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3194 (insert "Also-"))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3195 ;; Quote any "From " lines at the beginning.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3196 (goto-char beg)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3197 (when (looking-at "From ")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3198 (replace-match "X-From-Line: "))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3199 ;; Send it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3200 (message-send-mail)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3201 (kill-buffer (current-buffer)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3202 (message "Resending message to %s...done" address)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3203
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3204 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3205 (defun message-bounce ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3206 "Re-mail the current message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3207 This only makes sense if the current message is a bounce message than
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3208 contains some mail you have written which has been bounced back to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3209 you."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3210 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3211 (let ((cur (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3212 boundary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3213 (message-pop-to-buffer (message-buffer-name "bounce"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3214 (insert-buffer-substring cur)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3215 (undo-boundary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3216 (message-narrow-to-head)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3217 (if (and (message-fetch-field "Mime-Version")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3218 (setq boundary (message-fetch-field "Content-Type")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3219 (if (string-match "boundary=\"\\([^\"]+\\)\"" boundary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3220 (setq boundary (concat (match-string 1 boundary) " *\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3221 "Content-Type: message/rfc822"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3222 (setq boundary nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3223 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3224 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3225 (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3226 (or (and boundary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3227 (re-search-forward boundary nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3228 (forward-line 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3229 (and (re-search-forward message-unsent-separator nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3230 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3231 (and (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3232 (re-search-forward "^Return-Path:.*\n" nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3233 ;; We remove everything before the bounced mail.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3234 (delete-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3235 (point-min)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3236 (if (re-search-forward "^[^ \n\t]+:" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3237 (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3238 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3239 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3240 (message-narrow-to-head)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3241 (message-remove-header message-ignored-bounced-headers t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3242 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3243 (insert mail-header-separator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3244 (message-position-point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3245
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3246 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3247 ;;; Interactive entry points for new message buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3248 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3250 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3251 (defun message-mail-other-window (&optional to subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3252 "Like `message-mail' command, but display mail buffer in another window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3253 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3254 (let ((pop-up-windows t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3255 (special-display-buffer-names nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3256 (special-display-regexps nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3257 (same-window-buffer-names nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3258 (same-window-regexps nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3259 (message-pop-to-buffer (message-buffer-name "mail" to)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3260 (message-setup `((To . ,(or to "")) (Subject . ,(or subject "")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3261
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3262 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3263 (defun message-mail-other-frame (&optional to subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3264 "Like `message-mail' command, but display mail buffer in another frame."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3265 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3266 (let ((pop-up-frames t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3267 (special-display-buffer-names nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3268 (special-display-regexps nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3269 (same-window-buffer-names nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3270 (same-window-regexps nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3271 (message-pop-to-buffer (message-buffer-name "mail" to)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3272 (message-setup `((To . ,(or to "")) (Subject . ,(or subject "")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3273
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3274 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3275 (defun message-news-other-window (&optional newsgroups subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3276 "Start editing a news article to be sent."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3277 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3278 (let ((pop-up-windows t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3279 (special-display-buffer-names nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3280 (special-display-regexps nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3281 (same-window-buffer-names nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3282 (same-window-regexps nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3283 (message-pop-to-buffer (message-buffer-name "news" nil newsgroups)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3284 (message-setup `((Newsgroups . ,(or newsgroups ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3285 (Subject . ,(or subject "")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3286
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3287 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3288 (defun message-news-other-frame (&optional newsgroups subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3289 "Start editing a news article to be sent."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3290 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3291 (let ((pop-up-frames t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3292 (special-display-buffer-names nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3293 (special-display-regexps nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3294 (same-window-buffer-names nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3295 (same-window-regexps nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3296 (message-pop-to-buffer (message-buffer-name "news" nil newsgroups)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3297 (message-setup `((Newsgroups . ,(or newsgroups ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3298 (Subject . ,(or subject "")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3299
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3300 ;;; underline.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3302 ;; This code should be moved to underline.el (from which it is stolen).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3303
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3304 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3305 (defun bold-region (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3306 "Bold all nonblank characters in the region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3307 Works by overstriking characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3308 Called from program, takes two arguments START and END
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3309 which specify the range to operate on."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3310 (interactive "r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3311 (save-excursion
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3312 (let ((end1 (make-marker)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3313 (move-marker end1 (max start end))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3314 (goto-char (min start end))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3315 (while (< (point) end1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3316 (or (looking-at "[_\^@- ]")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3317 (insert (following-char) "\b"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3318 (forward-char 1)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3319
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3320 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3321 (defun unbold-region (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3322 "Remove all boldness (overstruck characters) in the region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3323 Called from program, takes two arguments START and END
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3324 which specify the range to operate on."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3325 (interactive "r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3326 (save-excursion
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3327 (let ((end1 (make-marker)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3328 (move-marker end1 (max start end))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3329 (goto-char (min start end))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3330 (while (re-search-forward "\b" end1 t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3331 (if (eq (following-char) (char-after (- (point) 2)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3332 (delete-char -2))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3333
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3334 (defalias 'message-exchange-point-and-mark 'exchange-point-and-mark)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3335
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3336 ;; Support for toolbar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3337 (when (string-match "XEmacs\\|Lucid" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3338 (require 'messagexmas))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3339
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3340 ;;; Group name completion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3341
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3342 (defvar message-newgroups-header-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3343 "^\\(Newsgroups\\|Followup-To\\|Posted-To\\):"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3344 "Regexp that match headers that lists groups.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3345
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3346 (defun message-tab ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3347 "Expand group names in Newsgroups and Followup-To headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3348 Do a `tab-to-tab-stop' if not in those headers."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3349 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3350 (if (let ((mail-abbrev-mode-regexp message-newgroups-header-regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3351 (mail-abbrev-in-expansion-header-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3352 (message-expand-group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3353 (tab-to-tab-stop)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3354
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3355 (defvar gnus-active-hashtb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3356 (defun message-expand-group ()
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3357 (let* ((b (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3358 (save-restriction
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3359 (narrow-to-region
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3360 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3361 (beginning-of-line)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3362 (skip-chars-forward "^:")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3363 (1+ (point)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3364 (point))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3365 (skip-chars-backward "^, \t\n") (point))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3366 (completion-ignore-case t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3367 (string (buffer-substring b (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3368 (hashtb (and (boundp 'gnus-active-hashtb) gnus-active-hashtb))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3369 (completions (all-completions string hashtb))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3370 (cur (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3371 comp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3372 (delete-region b (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3373 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3374 ((= (length completions) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3375 (if (string= (car completions) string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3376 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3377 (insert string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3378 (message "Only matching group"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3379 (insert (car completions))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3380 ((and (setq comp (try-completion string hashtb))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3381 (not (string= comp string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3382 (insert comp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3383 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3384 (insert string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3385 (if (not comp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3386 (message "No matching groups")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3387 (pop-to-buffer "*Completions*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3388 (buffer-disable-undo (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3389 (let ((buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3390 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3391 (let ((standard-output (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3392 (display-completion-list (sort completions 'string<)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3393 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3394 (pop-to-buffer cur)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3395
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3396 ;;; Help stuff.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3397
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3398 (defun message-talkative-question (ask question show &rest text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3399 "Call FUNCTION with argument QUESTION, displaying the rest of the arguments in a temporary buffer if SHOW.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3400 The following arguments may contain lists of values."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3401 (if (and show
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3402 (setq text (message-flatten-list text)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3403 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3404 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3405 (with-output-to-temp-buffer " *MESSAGE information message*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3406 (set-buffer " *MESSAGE information message*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3407 (mapcar 'princ text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3408 (goto-char (point-min))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3409 (funcall ask question))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3410 (funcall ask question)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3411
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3412 (defun message-flatten-list (list)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3413 "Return a new, flat list that contains all elements of LIST.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3414
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3415 \(message-flatten-list '(1 (2 3 (4 5 (6))) 7))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3416 => (1 2 3 4 5 6 7)"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3417 (cond ((consp list)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3418 (apply 'append (mapcar 'message-flatten-list list)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3419 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3420 (list list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3421
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3422 (defun message-generate-new-buffer-clone-locals (name &optional varstr)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3423 "Create and return a buffer with a name based on NAME using generate-new-buffer.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3424 Then clone the local variables and values from the old buffer to the
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3425 new one, cloning only the locals having a substring matching the
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3426 regexp varstr."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3427 (let ((oldlocals (buffer-local-variables)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3428 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3429 (set-buffer (generate-new-buffer name))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3430 (mapcar (lambda (dude)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3431 (when (and (car dude)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3432 (or (not varstr)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3433 (string-match varstr (symbol-name (car dude)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3434 (ignore-errors
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3435 (set (make-local-variable (car dude))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3436 (cdr dude)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3437 oldlocals)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3438 (current-buffer))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
3439
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3440 (run-hooks 'message-load-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3441
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3442 (provide 'message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3443
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3444 ;;; message.el ends here