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