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