Mercurial > emacs
annotate lisp/gnus-msg.el @ 15424:85a85480fa3c
(tar-mode-revert): Cope if user cancels the revert.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 12 Jun 1996 21:50:08 +0000 |
parents | 7c0be13394a1 |
children | 530d0d516a42 |
rev | line source |
---|---|
13401 | 1 ;;; gnus-msg.el --- mail and post interface for Gnus |
14169 | 2 |
13401 | 3 ;; Copyright (C) 1995 Free Software Foundation, Inc. |
4 | |
5 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet> | |
6 ;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no> | |
7 ;; Keywords: news | |
8 | |
9 ;; This file is part of GNU Emacs. | |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation; either version 2, or (at your option) | |
14 ;; any later version. | |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
14169 | 22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
24 ;; Boston, MA 02111-1307, USA. | |
13401 | 25 |
26 ;;; Commentary: | |
27 | |
28 ;;; Code: | |
29 | |
30 (require 'gnus) | |
31 (require 'sendmail) | |
32 (require 'gnus-ems) | |
33 | |
34 (defvar gnus-organization-file "/usr/lib/news/organization" | |
35 "*Local news organization file.") | |
36 | |
37 (defvar gnus-prepare-article-hook (list 'gnus-inews-insert-signature) | |
38 "*A hook called after preparing body, but before preparing header headers. | |
39 The default hook (`gnus-inews-insert-signature') inserts a signature | |
40 file specified by the variable `gnus-signature-file'.") | |
41 | |
42 (defvar gnus-post-prepare-function nil | |
43 "*Function that is run after a post buffer has been prepared. | |
44 It is called with the name of the newsgroup that is posted to. It | |
45 might be used, for instance, for inserting signatures based on the | |
46 newsgroup name. (In that case, `gnus-signature-file' and | |
47 `mail-signature' should both be set to nil).") | |
48 | |
49 (defvar gnus-post-prepare-hook nil | |
50 "*Hook that is run after a post buffer has been prepared. | |
51 If you want to insert the signature, you might put | |
52 `gnus-inews-insert-signature' in this hook.") | |
53 | |
54 (defvar gnus-use-followup-to t | |
55 "*Specifies what to do with Followup-To header. | |
56 If nil, ignore the header. If it is t, use its value, but ignore | |
57 `poster'. If it is the symbol `ask', query the user before posting. | |
58 If it is the symbol `use', always use the value.") | |
59 | |
60 (defvar gnus-followup-to-function nil | |
61 "*A variable that contains a function that returns a followup address. | |
62 The function will be called in the buffer of the article that is being | |
63 followed up. The buffer will be narrowed to the headers of the | |
64 article. To pick header headers, one might use `mail-fetch-field'. The | |
65 function will be called with the name of the current newsgroup as the | |
66 argument. | |
67 | |
68 Here's an example `gnus-followup-to-function': | |
69 | |
70 (setq gnus-followup-to-function | |
71 (lambda (group) | |
72 (cond ((string= group \"mail.list\") | |
73 (or (mail-fetch-field \"sender\") | |
74 (mail-fetch-field \"from\"))) | |
75 (t | |
76 (or (mail-fetch-field \"reply-to\") | |
77 (mail-fetch-field \"from\"))))))") | |
78 | |
79 (defvar gnus-reply-to-function nil | |
80 "*A variable that contains a function that returns a reply address. | |
81 See the `gnus-followup-to-function' variable for an explanation of how | |
82 this variable is used. | |
83 | |
84 This function should return a string that will be used to fill in the | |
85 header. This function may also return a list. In that case, every | |
86 list element should be a cons where the first car should be a string | |
87 with the header name, and the cdr should be a string with the header | |
88 value.") | |
89 | |
90 (defvar gnus-author-copy (getenv "AUTHORCOPY") | |
91 "*Save outgoing articles in this file. | |
92 Initialized from the AUTHORCOPY environment variable. | |
93 | |
94 If this variable begins with the character \"|\", outgoing articles | |
95 will be piped to the named program. It is possible to save an article | |
96 in an MH folder as follows: | |
97 | |
98 \(setq gnus-author-copy \"|/usr/local/lib/mh/rcvstore +Article\") | |
99 | |
100 If the first character is not a pipe, articles are saved using the | |
101 function specified by the `gnus-author-copy-saver' variable.") | |
102 | |
103 (defvar gnus-mail-self-blind nil | |
104 "*Non-nil means insert a BCC header in all outgoing articles. | |
105 This will result in having a copy of the article mailed to yourself. | |
106 The BCC header is inserted when the post buffer is initialized, so you | |
107 can remove or alter the BCC header to override the default.") | |
108 | |
109 (defvar gnus-author-copy-saver (function rmail-output) | |
110 "*A function called to save outgoing articles. | |
111 This function will be called with the same of the file to store the | |
112 article in. The default function is `rmail-output' which saves in Unix | |
113 mailbox format.") | |
114 | |
115 (defvar gnus-user-login-name nil | |
116 "*The login name of the user. | |
117 Got from the function `user-login-name' if undefined.") | |
118 | |
119 (defvar gnus-user-full-name nil | |
120 "*The full name of the user. | |
121 Got from the NAME environment variable if undefined.") | |
122 | |
123 (defvar gnus-user-from-line nil | |
124 "*Your full, complete e-mail address. | |
125 Overrides the other Gnus variables if it is non-nil. | |
126 | |
127 Here are two example values of this variable: | |
128 | |
129 \"Lars Magne Ingebrigtsen <larsi@ifi.uio.no>\" | |
130 | |
131 and | |
132 | |
133 \"larsi@ifi.uio.no (Lars Magne Ingebrigtsen)\" | |
134 | |
135 The first version is recommended, but the name has to be quoted if it | |
136 contains non-alphanumerical characters.") | |
137 | |
138 (defvar gnus-signature-file "~/.signature" | |
139 "*Your signature file. | |
140 If the variable is a string that doesn't correspond to a file, the | |
141 string itself is inserted.") | |
142 | |
143 (defvar gnus-signature-function nil | |
144 "*A function that should return a signature file name. | |
145 The function will be called with the name of the newsgroup being | |
146 posted to. | |
147 If the function returns a string that doesn't correspond to a file, the | |
148 string itself is inserted. | |
149 If the function returns nil, the `gnus-signature-file' variable will | |
150 be used instead.") | |
151 | |
152 (defvar gnus-required-headers | |
153 '(From Date Newsgroups Subject Message-ID Organization Lines X-Newsreader) | |
154 "*Headers to be generated or prompted for when posting an article. | |
155 RFC977 and RFC1036 require From, Date, Newsgroups, Subject, | |
156 Message-ID. Organization, Lines and X-Newsreader are optional. If | |
157 you want Gnus not to insert some header, remove it from this list.") | |
158 | |
159 (defvar gnus-deletable-headers '(Message-ID Date) | |
160 "*Headers to be deleted if they already exists and were generated by Gnus previously.") | |
161 | |
162 (defvar gnus-removable-headers '(NNTP-Posting-Host Bcc Xref) | |
163 "*Headers to be removed unconditionally before posting.") | |
164 | |
165 (defvar gnus-check-before-posting | |
166 '(subject-cmsg multiple-headers sendsys message-id from | |
167 long-lines control-chars size new-text | |
168 signature) | |
169 "In non-nil, Gnus will attempt to run some checks on outgoing posts. | |
170 If this variable is t, Gnus will check everything it can. If it is a | |
171 list, then those elements in that list will be checked.") | |
172 | |
173 (defvar gnus-delete-supersedes-headers | |
174 "^Path:\\|^Date\\|^NNTP-Posting-Host:\\|^Supersedes:" | |
175 "*Header lines matching this regexp will be deleted before posting. | |
176 It's best to delete old Path and Date headers before posting to avoid | |
177 any confusion.") | |
178 | |
179 (defvar gnus-auto-mail-to-author nil | |
180 "*If non-nil, mail the authors of articles a copy of your follow-ups. | |
181 If this variable is `ask', the user will be prompted for whether to | |
182 mail a copy. The string given by `gnus-mail-courtesy-message' will be | |
183 inserted at the beginning of the mail copy. | |
184 | |
185 Mail is sent using the function specified by the | |
186 `gnus-mail-send-method' variable.") | |
187 | |
188 ;; Added by Ethan Bradford <ethanb@ptolemy.astro.washington.edu>. | |
189 (defvar gnus-mail-courtesy-message | |
190 "The following message is a courtesy copy of an article\nthat has been posted as well.\n\n" | |
191 "*This is inserted at the start of a mailed copy of a posted message. | |
192 If this variable is nil, no such courtesy message will be added.") | |
193 | |
194 (defvar gnus-mail-reply-method (function gnus-mail-reply-using-mail) | |
195 "*Function to compose a reply. | |
196 Three pre-made functions are `gnus-mail-reply-using-mail' (sendmail); | |
197 `gnus-mail-reply-using-mhe' (MH-E); and `gnus-mail-reply-using-vm'.") | |
198 | |
199 (defvar gnus-mail-forward-method (function gnus-mail-forward-using-mail) | |
200 "*Function to forward the current message to another user. | |
201 Three pre-made functions are `gnus-mail-forward-using-mail' (sendmail); | |
202 `gnus-mail-forward-using-mhe' (MH-E); and `gnus-mail-forward-using-vm'.") | |
203 | |
204 (defvar gnus-mail-other-window-method 'gnus-mail-other-window-using-mail | |
205 "*Function to compose mail in the other window. | |
206 Three pre-made functions are `gnus-mail-other-window-using-mail' | |
207 (sendmail); `gnus-mail-other-window-using-mhe' (MH-E); and | |
208 `gnus-mail-other-window-using-vm'.") | |
209 | |
210 (defvar gnus-mail-send-method send-mail-function | |
211 "*Function to mail a message which is also being posted as an article. | |
212 The message must have To or Cc header. The default is copied from | |
213 the variable `send-mail-function'.") | |
214 | |
215 (defvar gnus-inews-article-function 'gnus-inews-article | |
216 "*Function to post an article.") | |
217 | |
218 (defvar gnus-inews-article-hook (list 'gnus-inews-do-fcc) | |
219 "*A hook called before finally posting an article. | |
220 The default hook (`gnus-inews-do-fcc') does FCC processing (ie. saves | |
221 the article to a file).") | |
222 | |
223 (defvar gnus-inews-article-header-hook nil | |
224 "*A hook called after inserting the headers in an article to be posted. | |
225 The hook is called from the *post-news* buffer, narrowed to the | |
226 headers.") | |
227 | |
228 (defvar gnus-mail-hook nil | |
229 "*A hook called as the last thing after setting up a mail buffer.") | |
230 | |
231 ;;; Internal variables. | |
232 | |
233 (defvar gnus-post-news-buffer "*post-news*") | |
234 (defvar gnus-mail-buffer "*mail*") | |
235 (defvar gnus-summary-send-map nil) | |
236 (defvar gnus-article-copy nil) | |
237 (defvar gnus-reply-subject nil) | |
238 | |
239 (eval-and-compile | |
240 (autoload 'gnus-uu-post-news "gnus-uu" nil t) | |
241 (autoload 'rmail-output "rmailout")) | |
242 | |
243 | |
244 ;;; | |
245 ;;; Gnus Posting Functions | |
246 ;;; | |
247 | |
248 (define-prefix-command 'gnus-summary-send-map) | |
249 (define-key gnus-summary-mode-map "S" 'gnus-summary-send-map) | |
250 (define-key gnus-summary-send-map "p" 'gnus-summary-post-news) | |
251 (define-key gnus-summary-send-map "f" 'gnus-summary-followup) | |
252 (define-key gnus-summary-send-map "F" 'gnus-summary-followup-with-original) | |
253 (define-key gnus-summary-send-map "b" 'gnus-summary-followup-and-reply) | |
254 (define-key gnus-summary-send-map "B" 'gnus-summary-followup-and-reply-with-original) | |
255 (define-key gnus-summary-send-map "c" 'gnus-summary-cancel-article) | |
256 (define-key gnus-summary-send-map "s" 'gnus-summary-supersede-article) | |
257 (define-key gnus-summary-send-map "r" 'gnus-summary-reply) | |
258 (define-key gnus-summary-send-map "R" 'gnus-summary-reply-with-original) | |
259 (define-key gnus-summary-send-map "m" 'gnus-summary-mail-other-window) | |
260 (define-key gnus-summary-send-map "u" 'gnus-uu-post-news) | |
261 (define-key gnus-summary-send-map "om" 'gnus-summary-mail-forward) | |
262 (define-key gnus-summary-send-map "op" 'gnus-summary-post-forward) | |
263 (define-key gnus-summary-send-map "Om" 'gnus-uu-digest-mail-forward) | |
264 (define-key gnus-summary-send-map "Op" 'gnus-uu-digest-post-forward) | |
265 | |
266 ;;; Internal functions. | |
267 | |
268 (defun gnus-number-base36 (num len) | |
269 (if (if (< len 0) (<= num 0) (= len 0)) | |
270 "" | |
271 (concat (gnus-number-base36 (/ num 36) (1- len)) | |
272 (char-to-string (aref "zyxwvutsrqponmlkjihgfedcba9876543210" | |
273 (% num 36)))))) | |
274 | |
275 ;;; Post news commands of Gnus group mode and summary mode | |
276 | |
277 (defun gnus-group-mail () | |
278 "Start composing a mail." | |
279 (interactive) | |
280 (funcall gnus-mail-other-window-method)) | |
281 | |
282 (defun gnus-group-post-news () | |
283 "Post an article." | |
284 (interactive) | |
285 (let ((gnus-newsgroup-name nil)) | |
286 (gnus-post-news 'post nil nil gnus-article-buffer))) | |
287 | |
288 (defun gnus-summary-post-news () | |
289 "Post an article." | |
290 (interactive) | |
291 (gnus-set-global-variables) | |
292 (gnus-post-news 'post gnus-newsgroup-name)) | |
293 | |
294 (defun gnus-summary-followup (yank &optional yank-articles) | |
295 "Compose a followup to an article. | |
296 If prefix argument YANK is non-nil, original article is yanked automatically." | |
297 (interactive "P") | |
298 (gnus-set-global-variables) | |
299 (if yank-articles (gnus-summary-goto-subject (car yank-articles))) | |
300 (save-window-excursion | |
301 (gnus-summary-select-article)) | |
302 (let ((headers (gnus-get-header-by-number (gnus-summary-article-number))) | |
303 (gnus-newsgroup-name gnus-newsgroup-name)) | |
304 ;; Check Followup-To: poster. | |
305 (set-buffer gnus-article-buffer) | |
306 (if (and gnus-use-followup-to | |
307 (string-equal "poster" (gnus-fetch-field "followup-to")) | |
308 (or (not (memq gnus-use-followup-to '(t ask))) | |
309 (not (gnus-y-or-n-p | |
310 "Do you want to ignore `Followup-To: poster'? ")))) | |
311 ;; Mail to the poster. | |
312 (gnus-summary-reply yank) | |
313 (gnus-post-news nil gnus-newsgroup-name | |
314 headers gnus-article-buffer | |
315 (or yank-articles (not (not yank))))))) | |
316 | |
317 (defun gnus-summary-followup-with-original (n) | |
318 "Compose a followup to an article and include the original article." | |
319 (interactive "P") | |
320 (gnus-summary-followup t (gnus-summary-work-articles n))) | |
321 | |
322 ;; Suggested by Daniel Quinlan <quinlan@best.com>. | |
323 (defun gnus-summary-followup-and-reply (yank &optional yank-articles) | |
324 "Compose a followup and do an auto mail to author." | |
325 (interactive "P") | |
326 (gnus-set-global-variables) | |
327 (let ((gnus-auto-mail-to-author t)) | |
328 (gnus-summary-followup yank yank-articles))) | |
329 | |
330 (defun gnus-summary-followup-and-reply-with-original (n) | |
331 "Compose a followup, include the original, and do an auto mail to author." | |
332 (interactive "P") | |
333 (gnus-summary-followup-and-reply t (gnus-summary-work-articles n))) | |
334 | |
335 (defun gnus-summary-cancel-article (n) | |
336 "Cancel an article you posted." | |
337 (interactive "P") | |
338 (gnus-set-global-variables) | |
339 (let ((articles (gnus-summary-work-articles n))) | |
340 (while articles | |
341 (gnus-summary-select-article t nil nil (car articles)) | |
342 (and (gnus-eval-in-buffer-window gnus-article-buffer (gnus-cancel-news)) | |
343 (gnus-summary-mark-as-read (car articles) gnus-canceled-mark)) | |
344 (gnus-summary-remove-process-mark (car articles)) | |
345 (gnus-article-hide-headers-if-wanted) | |
346 (setq articles (cdr articles))))) | |
347 | |
348 (defun gnus-summary-supersede-article () | |
349 "Compose an article that will supersede a previous article. | |
350 This is done simply by taking the old article and adding a Supersedes | |
351 header line with the old Message-ID." | |
352 (interactive) | |
353 (gnus-set-global-variables) | |
354 (gnus-summary-select-article t) | |
355 (if (not | |
356 (string-equal | |
357 (downcase (mail-strip-quoted-names | |
358 (mail-header-from gnus-current-headers))) | |
359 (downcase (mail-strip-quoted-names (gnus-inews-user-name))))) | |
360 (error "This article is not yours.")) | |
361 (save-excursion | |
362 (set-buffer gnus-article-buffer) | |
363 (let ((buffer-read-only nil)) | |
364 (goto-char (point-min)) | |
365 (search-forward "\n\n" nil t) | |
366 (if (not (re-search-backward "^Message-ID: " nil t)) | |
367 (error "No Message-ID in this article")))) | |
368 (if (gnus-post-news 'post gnus-newsgroup-name) | |
369 (progn | |
370 (erase-buffer) | |
371 (insert-buffer gnus-article-buffer) | |
372 (if (search-forward "\n\n" nil t) | |
373 (forward-char -1) | |
374 (goto-char (point-max))) | |
375 (narrow-to-region (point-min) (point)) | |
376 (goto-char (point-min)) | |
377 (and gnus-delete-supersedes-headers | |
378 (delete-matching-lines gnus-delete-supersedes-headers)) | |
379 (goto-char (point-min)) | |
380 (if (not (re-search-forward "^Message-ID: " nil t)) | |
381 (error "No Message-ID in this article") | |
382 (replace-match "Supersedes: " t t)) | |
383 (goto-char (point-max)) | |
384 (insert mail-header-separator) | |
385 (widen) | |
386 (forward-line 1)))) | |
387 | |
388 | |
389 ;;;###autoload | |
390 (defalias 'sendnews 'gnus-post-news) | |
391 | |
392 ;;;###autoload | |
393 (defalias 'postnews 'gnus-post-news) | |
394 | |
395 (defun gnus-copy-article-buffer (&optional article-buffer) | |
396 ;; make a copy of the article buffer with all text properties removed | |
397 ;; this copy is in the buffer gnus-article-copy. | |
398 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used | |
399 ;; this buffer should be passed to all mail/news reply/post routines. | |
400 (setq gnus-article-copy (get-buffer-create " *gnus article copy*")) | |
401 (buffer-disable-undo gnus-article-copy) | |
402 (or (memq gnus-article-copy gnus-buffer-list) | |
403 (setq gnus-buffer-list (cons gnus-article-copy gnus-buffer-list))) | |
404 (let ((article-buffer (or article-buffer gnus-article-buffer))) | |
405 (if (and (get-buffer article-buffer) | |
406 (buffer-name (get-buffer article-buffer))) | |
407 (save-excursion | |
408 (set-buffer article-buffer) | |
409 (widen) | |
410 (copy-to-buffer gnus-article-copy (point-min) (point-max)) | |
411 (set-text-properties (point-min) (point-max) | |
412 nil gnus-article-copy))))) | |
413 | |
13679
d4841ac1505f
(gnus-post-news): Add autoload.
Richard M. Stallman <rms@gnu.org>
parents:
13401
diff
changeset
|
414 ;;;###autoload |
13401 | 415 (defun gnus-post-news (post &optional group header article-buffer yank subject) |
416 "Begin editing a new USENET news article to be posted. | |
417 Type \\[describe-mode] in the buffer to get a list of commands." | |
418 (interactive (list t)) | |
419 (gnus-copy-article-buffer article-buffer) | |
420 (if (or (not gnus-novice-user) | |
421 gnus-expert-user | |
422 (not (eq 'post | |
423 (nth 1 (assoc | |
424 (format "%s" (car (gnus-find-method-for-group | |
425 gnus-newsgroup-name))) | |
426 gnus-valid-select-methods)))) | |
427 (and group | |
428 (assq 'to-address | |
429 (nth 5 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))) | |
430 (gnus-y-or-n-p "Are you sure you want to post to all of USENET? ")) | |
431 (let ((sumart (if (not post) | |
432 (save-excursion | |
433 (set-buffer gnus-summary-buffer) | |
434 (cons (current-buffer) gnus-current-article)))) | |
435 (from (and header (mail-header-from header))) | |
436 (winconf (current-window-configuration)) | |
437 real-group) | |
438 (and gnus-interactive-post | |
439 (not gnus-expert-user) | |
440 post (not group) | |
441 (progn | |
442 (setq gnus-newsgroup-name | |
443 (setq group | |
444 (completing-read "Group: " gnus-active-hashtb))) | |
445 (or subject | |
446 (setq subject (read-string "Subject: "))))) | |
447 (setq mail-reply-buffer gnus-article-copy) | |
448 | |
449 (let ((newsgroup-name (or group gnus-newsgroup-name ""))) | |
450 (setq real-group (and group (gnus-group-real-name group))) | |
451 (setq gnus-post-news-buffer | |
452 (gnus-request-post-buffer | |
453 post real-group subject header gnus-article-copy | |
454 (nth 2 (and group (gnus-gethash group gnus-newsrc-hashtb))) | |
455 (or (cdr (assq 'to-group | |
456 (nth 5 (nth 2 (gnus-gethash | |
457 newsgroup-name | |
458 gnus-newsrc-hashtb))))) | |
459 (if (and (boundp 'gnus-followup-to-function) | |
460 gnus-followup-to-function | |
461 gnus-article-copy) | |
462 (save-excursion | |
463 (set-buffer gnus-article-copy) | |
464 (funcall gnus-followup-to-function group)))) | |
465 gnus-use-followup-to)) | |
466 (if post | |
467 (gnus-configure-windows 'post 'force) | |
468 (if yank | |
469 (gnus-configure-windows 'followup-yank 'force) | |
470 (gnus-configure-windows 'followup 'force))) | |
471 (gnus-overload-functions) | |
472 (make-local-variable 'gnus-article-reply) | |
473 (make-local-variable 'gnus-article-check-size) | |
474 (make-local-variable 'gnus-reply-subject) | |
475 (setq gnus-reply-subject (and header (mail-header-subject header))) | |
476 (setq gnus-article-reply sumart) | |
477 ;; Handle `gnus-auto-mail-to-author'. | |
478 ;; Suggested by Daniel Quinlan <quinlan@best.com>. | |
479 ;; Revised to respect Reply-To by Ulrik Dickow <dickow@nbi.dk>. | |
480 (let ((to (and (not post) | |
481 (if (if (eq gnus-auto-mail-to-author 'ask) | |
482 (y-or-n-p "Also send mail to author? ") | |
483 gnus-auto-mail-to-author) | |
484 (or (save-excursion | |
485 (set-buffer gnus-article-copy) | |
486 (gnus-fetch-field "reply-to")) | |
487 from))))) | |
488 (if to | |
489 (if (mail-fetch-field "To") | |
490 (progn | |
491 (beginning-of-line) | |
492 (insert "Cc: " to "\n")) | |
493 (mail-position-on-field "To") | |
494 (insert to)))) | |
495 ;; Handle author copy using BCC field. | |
496 (if (and gnus-mail-self-blind | |
497 (not (mail-fetch-field "bcc"))) | |
498 (progn | |
499 (mail-position-on-field "Bcc") | |
500 (insert (if (stringp gnus-mail-self-blind) | |
501 gnus-mail-self-blind | |
502 (user-login-name))))) | |
503 ;; Handle author copy using FCC field. | |
504 (if gnus-author-copy | |
505 (progn | |
506 (mail-position-on-field "Fcc") | |
507 (insert gnus-author-copy))) | |
508 (goto-char (point-min)) | |
509 (if post | |
510 (cond ((not group) | |
511 (re-search-forward "^Newsgroup:" nil t) | |
512 (end-of-line)) | |
513 ((not subject) | |
514 (re-search-forward "^Subject:" nil t) | |
515 (end-of-line)) | |
516 (t | |
517 (re-search-forward | |
518 (concat "^" (regexp-quote mail-header-separator) "$")) | |
519 (forward-line 1))) | |
520 (re-search-forward | |
521 (concat "^" (regexp-quote mail-header-separator) "$")) | |
522 (forward-line 1) | |
523 (if (not yank) | |
524 () | |
525 (save-excursion | |
526 (if (not (listp yank)) | |
527 (news-reply-yank-original nil) | |
528 (setq yank (reverse yank)) | |
529 (while yank | |
530 (save-excursion | |
531 (save-window-excursion | |
532 (set-buffer gnus-summary-buffer) | |
533 (gnus-summary-select-article nil nil nil (car yank)) | |
534 (gnus-summary-remove-process-mark (car yank))) | |
535 (let ((mail-reply-buffer gnus-article-copy)) | |
536 (gnus-copy-article-buffer) | |
537 (let ((news-reply-yank-message-id | |
538 (save-excursion | |
539 (set-buffer gnus-article-copy) | |
540 (mail-fetch-field "message-id"))) | |
541 (news-reply-yank-from | |
542 (save-excursion | |
543 (set-buffer gnus-article-copy) | |
544 (mail-fetch-field "from")))) | |
545 (news-reply-yank-original nil)) | |
546 (setq yank (cdr yank))))))))) | |
547 (if gnus-post-prepare-function | |
548 (funcall gnus-post-prepare-function group)) | |
549 (run-hooks 'gnus-post-prepare-hook) | |
550 (make-local-variable 'gnus-prev-winconf) | |
551 (setq gnus-prev-winconf winconf)))) | |
552 (setq gnus-article-check-size (cons (buffer-size) (gnus-article-checksum))) | |
553 (message "") | |
554 t) | |
555 | |
556 (defun gnus-inews-news (&optional use-group-method) | |
557 "Send a news message. | |
558 If given a prefix, and the group is a foreign group, this function | |
559 will attempt to use the foreign server to post the article." | |
560 (interactive "P") | |
561 (or gnus-current-select-method | |
562 (setq gnus-current-select-method gnus-select-method)) | |
563 (let* ((case-fold-search nil) | |
564 (server-running (gnus-server-opened gnus-current-select-method)) | |
565 (reply gnus-article-reply) | |
566 error post-result) | |
567 (save-excursion | |
568 ;; Connect to default NNTP server if necessary. | |
569 ;; Suggested by yuki@flab.fujitsu.junet. | |
570 (gnus-start-news-server) ;Use default server. | |
571 ;; NNTP server must be opened before current buffer is modified. | |
572 (widen) | |
573 (goto-char (point-min)) | |
574 (run-hooks 'news-inews-hook) | |
575 (save-restriction | |
576 (narrow-to-region | |
577 (point-min) | |
578 (progn | |
579 (goto-char (point-min)) | |
580 (re-search-forward | |
581 (concat "^" (regexp-quote mail-header-separator) "$")) | |
582 (match-beginning 0))) | |
583 | |
584 ;; Correct newsgroups field: change sequence of spaces to comma and | |
14040 | 585 ;; eliminate spaces around commas. Eliminate embedded line breaks. |
13401 | 586 (goto-char (point-min)) |
587 (if (re-search-forward "^Newsgroups: +" nil t) | |
588 (save-restriction | |
589 (narrow-to-region | |
590 (point) | |
591 (if (re-search-forward "^[^ \t]" nil t) | |
592 (match-beginning 0) | |
593 (forward-line 1) | |
594 (point))) | |
595 (goto-char (point-min)) | |
596 (while (re-search-forward "\n[ \t]+" nil t) | |
597 (replace-match " " t t)) ;No line breaks (too confusing) | |
598 (goto-char (point-min)) | |
599 (while (re-search-forward "[ \t\n]*,[ \t\n]*\\|[ \t]+" nil t) | |
600 (replace-match "," t t)) | |
601 (goto-char (point-min)) | |
602 ;; Remove a trailing comma. | |
603 (if (re-search-forward ",$" nil t) | |
604 (replace-match "" t t)))) | |
605 | |
606 ;; Added by Per Abrahamsen <abraham@iesd.auc.dk>. | |
607 ;; Help save the the world! | |
608 (or | |
609 gnus-expert-user | |
610 (let ((newsgroups (mail-fetch-field "newsgroups")) | |
611 (followup-to (mail-fetch-field "followup-to")) | |
612 groups to) | |
613 (if (and newsgroups | |
614 (string-match "," newsgroups) (not followup-to)) | |
615 (progn | |
616 (while (string-match "," newsgroups) | |
617 (setq groups | |
618 (cons (list (substring newsgroups | |
619 0 (match-beginning 0))) | |
620 groups)) | |
621 (setq newsgroups (substring newsgroups (match-end 0)))) | |
622 (setq groups (nreverse (cons (list newsgroups) groups))) | |
623 | |
624 (setq to | |
625 (completing-read "Followups to: (default all groups) " | |
626 groups)) | |
627 (if (> (length to) 0) | |
628 (progn | |
629 (goto-char (point-min)) | |
630 (insert "Followup-To: " to "\n"))))))) | |
631 | |
632 ;; Cleanup Followup-To. | |
633 (goto-char (point-min)) | |
634 (if (search-forward-regexp "^Followup-To: +" nil t) | |
635 (save-restriction | |
636 (narrow-to-region | |
637 (point) | |
638 (if (re-search-forward "^[^ \t]" nil 'end) | |
639 (match-beginning 0) | |
640 (point-max))) | |
641 (goto-char (point-min)) | |
642 (replace-regexp "\n[ \t]+" " ") ;No line breaks (too confusing) | |
643 (goto-char (point-min)) | |
644 (replace-regexp "[ \t\n]*,[ \t\n]*\\|[ \t]+" ","))) | |
645 | |
646 ;; Mail the message too if To:, Bcc:. or Cc: exists. | |
647 (let* ((types '("to" "bcc" "cc")) | |
648 (ty types) | |
649 fcc-line) | |
650 (while ty | |
651 (or (mail-fetch-field (car ty) nil t) | |
652 (setq types (delete (car ty) types))) | |
653 (setq ty (cdr ty))) | |
654 | |
655 (if (not types) | |
656 ;; We do not want to send mail. | |
657 () | |
658 (if (not gnus-mail-send-method) | |
659 (progn | |
660 (ding) | |
661 (gnus-message | |
662 1 "No mailer defined. To: and/or Cc: fields ignored.") | |
663 (sit-for 1)) | |
664 (save-excursion | |
665 ;; We want to remove Fcc, because we want to handle | |
666 ;; that one ourselves... | |
667 | |
668 (goto-char (point-min)) | |
669 (if (re-search-forward "^Fcc: " nil t) | |
670 (progn | |
671 (setq fcc-line | |
672 (buffer-substring | |
673 (progn (beginning-of-line) (point)) | |
674 (progn (forward-line 1) (point)))) | |
675 (forward-line -1) | |
676 (gnus-delete-line))) | |
677 | |
678 ;; We generate a Message-ID so that the mail and the | |
679 ;; news copy of the message both get the same ID. | |
680 (or (mail-fetch-field "message-id") | |
681 (not (memq 'Message-ID gnus-required-headers)) | |
682 (progn | |
683 (goto-char (point-max)) | |
684 (insert "Message-ID: " (gnus-inews-message-id) "\n"))) | |
685 | |
686 (save-restriction | |
687 (widen) | |
688 (gnus-message 5 "Sending via mail...") | |
689 | |
690 (if (and gnus-mail-courtesy-message | |
691 (or (member "to" types) | |
692 (member "cc" types))) | |
693 ;; We only want to insert the courtesy mail | |
694 ;; message if we use to or cc; bcc should not | |
695 ;; have one. Well, if both bcc and to are | |
696 ;; present, it will get one anyway. | |
697 (progn | |
698 ;; Insert "courtesy" mail message. | |
699 (goto-char (point-min)) | |
700 (re-search-forward | |
701 (concat "^" (regexp-quote | |
702 mail-header-separator) "$")) | |
703 (forward-line 1) | |
704 (insert gnus-mail-courtesy-message) | |
705 (funcall gnus-mail-send-method) | |
706 (goto-char (point-min)) | |
707 (search-forward gnus-mail-courtesy-message) | |
708 (replace-match "" t t)) | |
709 (funcall gnus-mail-send-method)) | |
710 | |
711 (gnus-message 5 "Sending via mail...done") | |
712 | |
713 (goto-char (point-min)) | |
714 (narrow-to-region | |
715 (point) | |
716 (re-search-forward | |
717 (concat "^" (regexp-quote mail-header-separator) "$"))) | |
718 (goto-char (point-min)) | |
719 (while (re-search-forward "^BCC:" nil t) | |
720 (delete-region (match-beginning 0) | |
721 ;; There might be continuation headers. | |
722 (if (re-search-forward "^[^ \t]" nil t) | |
723 (match-beginning 0) | |
724 ;; Uhm... or something like this. | |
725 (forward-line 1) | |
726 (point))))) | |
727 (if fcc-line | |
728 (progn | |
729 (goto-char (point-max)) | |
730 (insert fcc-line)))))))) | |
731 | |
732 ;; Send to server. | |
733 (gnus-message 5 "Posting to USENET...") | |
734 (setq post-result (funcall gnus-inews-article-function use-group-method)) | |
735 (cond ((eq post-result 'illegal) | |
736 (setq error t) | |
737 (ding)) | |
738 (post-result | |
739 (gnus-message 5 "Posting to USENET...done") | |
740 (if (gnus-buffer-exists-p (car-safe reply)) | |
741 (progn | |
742 (save-excursion | |
743 (set-buffer gnus-summary-buffer) | |
744 (gnus-summary-mark-article-as-replied | |
745 (cdr reply))))) | |
746 (set-buffer-modified-p nil)) | |
747 (t | |
748 ;; We cannot signal an error. | |
749 (setq error t) | |
750 (ding) | |
751 (gnus-message 1 "Article rejected: %s" | |
752 (gnus-status-message gnus-select-method))))) | |
753 ;; If NNTP server is opened by gnus-inews-news, close it by myself. | |
754 (or server-running | |
755 (gnus-close-server (gnus-find-method-for-group gnus-newsgroup-name))) | |
756 (let ((conf gnus-prev-winconf)) | |
757 (if (not error) | |
758 (progn | |
759 (bury-buffer) | |
760 ;; Restore last window configuration. | |
761 (and conf (set-window-configuration conf))))))) | |
762 | |
763 (defun gnus-inews-check-post () | |
764 "Check whether the post looks ok." | |
765 (or | |
766 (not gnus-check-before-posting) | |
767 (and | |
768 ;; We narrow to the headers and check them first. | |
769 (save-excursion | |
770 (save-restriction | |
771 (goto-char (point-min)) | |
772 (narrow-to-region | |
773 (point) | |
774 (progn | |
775 (re-search-forward | |
776 (concat "^" (regexp-quote mail-header-separator) "$")) | |
777 (match-beginning 0))) | |
778 (goto-char (point-min)) | |
779 (and | |
780 ;; Check for commands in Subject. | |
781 (or | |
782 (gnus-check-before-posting 'subject-cmsg) | |
783 (save-excursion | |
784 (if (string-match "^cmsg " (mail-fetch-field "subject")) | |
785 (gnus-y-or-n-p | |
786 "The control code \"cmsg \" is in the subject. Really post? ") | |
787 t))) | |
788 ;; Check for multiple identical headers. | |
789 (or (gnus-check-before-posting 'multiple-headers) | |
790 (save-excursion | |
791 (let (found) | |
792 (while (and (not found) (re-search-forward "^[^ \t:]+: " | |
793 nil t)) | |
794 (save-excursion | |
795 (or (re-search-forward | |
796 (concat "^" (setq found | |
797 (buffer-substring | |
798 (match-beginning 0) | |
799 (- (match-end 0) 2)))) | |
800 nil t) | |
801 (setq found nil)))) | |
802 (if found | |
803 (gnus-y-or-n-p | |
804 (format "Multiple %s headers. Really post? " found)) | |
805 t)))) | |
806 ;; Check for version and sendsys. | |
807 (or (gnus-check-before-posting 'sendsys) | |
808 (save-excursion | |
809 (if (re-search-forward "^Sendsys:\\|^Version:" nil t) | |
810 (gnus-y-or-n-p | |
811 (format "The article contains a %s command. Really post? " | |
812 (buffer-substring (match-beginning 0) | |
813 (1- (match-end 0))))) | |
814 t))) | |
815 ;; Check the Message-Id header. | |
816 (or (gnus-check-before-posting 'message-id) | |
817 (save-excursion | |
818 (let* ((case-fold-search t) | |
819 (message-id (mail-fetch-field "message-id"))) | |
820 (or (not message-id) | |
821 (and (string-match "@" message-id) | |
822 (string-match "@[^\\.]*\\." message-id)) | |
823 (gnus-y-or-n-p | |
824 (format | |
825 "The Message-ID looks strange: \"%s\". Really post? " | |
826 message-id)))))) | |
827 ;; Check the From header. | |
828 (or (gnus-check-before-posting 'from) | |
829 (save-excursion | |
830 (let* ((case-fold-search t) | |
831 (from (mail-fetch-field "from"))) | |
832 (cond | |
833 ((not from) | |
834 (gnus-y-or-n-p "There is no From line. Really post? ")) | |
835 ((not (string-match "@[^\\.]*\\." from)) | |
836 (gnus-y-or-n-p | |
837 (format | |
838 "The address looks strange: \"%s\". Really post? " from))) | |
839 ((string-match "(.*).*(.*)" from) | |
840 (gnus-y-or-n-p | |
841 (format | |
842 "The From header looks strange: \"%s\". Really post? " | |
843 from))) | |
844 (t t))))) | |
845 ))) | |
846 ;; Check for long lines. | |
847 (or (gnus-check-before-posting 'long-lines) | |
848 (save-excursion | |
849 (goto-char (point-min)) | |
850 (re-search-forward | |
851 (concat "^" (regexp-quote mail-header-separator) "$")) | |
852 (while (and | |
853 (progn | |
854 (end-of-line) | |
855 (< (current-column) 80)) | |
856 (zerop (forward-line 1)))) | |
857 (or (bolp) | |
858 (eobp) | |
859 (gnus-y-or-n-p | |
860 (format | |
861 "You have lines longer than 79 characters. Really post? "))))) | |
862 ;; Check for control characters. | |
863 (or (gnus-check-before-posting 'control-chars) | |
864 (save-excursion | |
865 (if (re-search-forward "[\000-\007\013\015-\037\200-\237]" nil t) | |
866 (gnus-y-or-n-p | |
867 "The article contains control characters. Really post? ") | |
868 t))) | |
869 ;; Check excessive size. | |
870 (or (gnus-check-before-posting 'size) | |
871 (if (> (buffer-size) 60000) | |
872 (gnus-y-or-n-p | |
873 (format "The article is %d octets long. Really post? " | |
874 (buffer-size))) | |
875 t)) | |
876 ;; Use the (size . checksum) variable to see whether the | |
877 ;; article is empty or has only quoted text. | |
878 (or | |
879 (gnus-check-before-posting 'new-text) | |
880 (if (and (= (buffer-size) (car gnus-article-check-size)) | |
881 (= (gnus-article-checksum) (cdr gnus-article-check-size))) | |
882 (gnus-y-or-n-p | |
883 "It looks like there's no new text in your article. Really post? ") | |
884 t)) | |
885 ;; Check the length of the signature. | |
886 (or (gnus-check-before-posting 'signature) | |
887 (progn | |
888 (goto-char (point-max)) | |
889 (if (not (re-search-backward gnus-signature-separator nil t)) | |
890 t | |
891 (if (> (count-lines (point) (point-max)) 5) | |
892 (gnus-y-or-n-p | |
893 (format | |
894 "Your .sig is %d lines; it should be max 4. Really post? " | |
895 (count-lines (point) (point-max)))) | |
896 t))))))) | |
897 | |
898 (defun gnus-article-checksum () | |
899 (let ((sum 0)) | |
900 (save-excursion | |
901 (while (not (eobp)) | |
902 (setq sum (logxor sum (following-char))) | |
903 (forward-char 1))) | |
904 sum)) | |
905 | |
906 ;; Returns non-nil if this type is not to be checked. | |
907 (defun gnus-check-before-posting (type) | |
908 (not | |
909 (or (not gnus-check-before-posting) | |
910 (if (listp gnus-check-before-posting) | |
911 (memq type gnus-check-before-posting) | |
912 t)))) | |
913 | |
914 (defun gnus-cancel-news () | |
915 "Cancel an article you posted." | |
916 (interactive) | |
917 (if (or gnus-expert-user | |
918 (gnus-yes-or-no-p "Do you really want to cancel this article? ")) | |
919 (let ((from nil) | |
920 (newsgroups nil) | |
921 (message-id nil) | |
922 (distribution nil)) | |
923 (or (gnus-member-of-valid 'post gnus-newsgroup-name) | |
924 (error "This backend does not support canceling")) | |
925 (save-excursion | |
926 ;; Get header info. from original article. | |
927 (save-restriction | |
928 (gnus-article-show-all-headers) | |
929 (goto-char (point-min)) | |
930 (search-forward "\n\n" nil 'move) | |
931 (narrow-to-region (point-min) (point)) | |
932 (setq from (mail-fetch-field "from")) | |
933 (setq newsgroups (mail-fetch-field "newsgroups")) | |
934 (setq message-id (mail-fetch-field "message-id")) | |
935 (setq distribution (mail-fetch-field "distribution"))) | |
936 ;; Verify if the article is absolutely user's by comparing | |
937 ;; user id with value of its From: field. | |
938 (if (not | |
939 (string-equal | |
940 (downcase (mail-strip-quoted-names from)) | |
941 (downcase (mail-strip-quoted-names (gnus-inews-user-name))))) | |
942 (progn | |
943 (ding) (gnus-message 3 "This article is not yours.") | |
944 nil) | |
945 ;; Make control article. | |
946 (set-buffer (get-buffer-create " *Gnus-canceling*")) | |
947 (buffer-disable-undo (current-buffer)) | |
948 (erase-buffer) | |
949 (insert "Newsgroups: " newsgroups "\n" | |
950 "Subject: cancel " message-id "\n" | |
951 "Control: cancel " message-id "\n" | |
952 (if distribution | |
953 (concat "Distribution: " distribution "\n") | |
954 "") | |
955 mail-header-separator "\n" | |
956 "This is a cancel message from " from ".\n") | |
957 ;; Send the control article to NNTP server. | |
958 (gnus-message 5 "Canceling your article...") | |
959 (prog1 | |
960 (if (funcall gnus-inews-article-function) | |
961 (gnus-message 5 "Canceling your article...done") | |
962 (progn | |
963 (ding) | |
964 (gnus-message 1 "Cancel failed; %s" | |
965 (gnus-status-message gnus-newsgroup-name)) | |
966 nil) | |
967 t) | |
968 ;; Kill the article buffer. | |
969 (kill-buffer (current-buffer)))))))) | |
970 | |
971 | |
972 ;;; Lowlevel inews interface | |
973 | |
974 (defun gnus-inews-article (&optional use-group-method) | |
975 "Post an article in current buffer using NNTP protocol." | |
976 (let ((artbuf (current-buffer)) | |
977 (tmpbuf (get-buffer-create " *Gnus-posting*"))) | |
978 (widen) | |
979 (goto-char (point-max)) | |
980 ;; require a newline at the end for inews to append .signature to | |
981 (or (= (preceding-char) ?\n) | |
982 (insert ?\n)) | |
983 ;; Prepare article headers. All message body such as signature | |
984 ;; must be inserted before Lines: field is prepared. | |
985 (save-restriction | |
986 (goto-char (point-min)) | |
987 (narrow-to-region | |
988 (point-min) | |
989 (save-excursion | |
990 (re-search-forward | |
991 (concat "^" (regexp-quote mail-header-separator) "$")) | |
992 (match-beginning 0))) | |
993 (gnus-inews-remove-headers) | |
994 (gnus-inews-insert-headers) | |
995 (run-hooks 'gnus-inews-article-header-hook) | |
996 (widen)) | |
997 ;; Check whether the article is a good Net Citizen. | |
998 (if (and gnus-article-check-size | |
999 (not (gnus-inews-check-post))) | |
1000 ;; Aber nein! | |
1001 'illegal | |
1002 ;; Looks ok, so we do the nasty. | |
1003 (save-excursion | |
1004 (set-buffer tmpbuf) | |
1005 (buffer-disable-undo (current-buffer)) | |
1006 (erase-buffer) | |
1007 (insert-buffer-substring artbuf) | |
1008 ;; Remove the header separator. | |
1009 (goto-char (point-min)) | |
1010 (re-search-forward | |
1011 (concat "^" (regexp-quote mail-header-separator) "$")) | |
1012 (replace-match "" t t) | |
1013 ;; This hook may insert a signature. | |
1014 (save-excursion | |
1015 (goto-char (point-min)) | |
1016 (let ((gnus-newsgroup-name (or (mail-fetch-field "newsgroups") | |
1017 gnus-newsgroup-name))) | |
1018 (run-hooks 'gnus-prepare-article-hook))) | |
1019 ;; Run final inews hooks. This hook may do FCC. | |
1020 ;; The article must be saved before being posted because | |
1021 ;; `gnus-request-post' modifies the buffer. | |
1022 (run-hooks 'gnus-inews-article-hook) | |
1023 ;; Post an article to NNTP server. | |
1024 ;; Return NIL if post failed. | |
1025 (prog1 | |
1026 (gnus-request-post | |
1027 (if use-group-method | |
1028 (gnus-find-method-for-group gnus-newsgroup-name) | |
1029 gnus-select-method) use-group-method) | |
1030 (kill-buffer (current-buffer))))))) | |
1031 | |
1032 (defun gnus-inews-remove-headers () | |
1033 (let ((case-fold-search t) | |
1034 (headers gnus-removable-headers)) | |
1035 ;; Remove toxic headers. | |
1036 (while headers | |
1037 (goto-char (point-min)) | |
1038 (and (re-search-forward | |
1039 (concat "^" (downcase (format "%s" (car headers)))) | |
1040 nil t) | |
1041 (delete-region (progn (beginning-of-line) (point)) | |
1042 (progn (forward-line 1) (point)))) | |
1043 (setq headers (cdr headers))))) | |
1044 | |
1045 (defun gnus-inews-insert-headers () | |
1046 "Prepare article headers. | |
1047 Headers already prepared in the buffer are not modified. | |
1048 Headers in `gnus-required-headers' will be generated." | |
1049 (let ((Date (gnus-inews-date)) | |
1050 (Message-ID (gnus-inews-message-id)) | |
1051 (Organization (gnus-inews-organization)) | |
1052 (From (gnus-inews-user-name)) | |
1053 (Path (gnus-inews-path)) | |
1054 (Subject nil) | |
1055 (Newsgroups nil) | |
1056 (Distribution nil) | |
1057 (Lines (gnus-inews-lines)) | |
1058 (X-Newsreader gnus-version) | |
1059 (headers gnus-required-headers) | |
1060 (case-fold-search t) | |
1061 header value elem) | |
1062 ;; First we remove any old generated headers. | |
1063 (let ((headers gnus-deletable-headers)) | |
1064 (while headers | |
1065 (goto-char (point-min)) | |
1066 (and (re-search-forward | |
1067 (concat "^" (symbol-name (car headers)) ": *") nil t) | |
1068 (get-text-property (1+ (match-beginning 0)) 'gnus-deletable) | |
1069 (gnus-delete-line)) | |
1070 (setq headers (cdr headers)))) | |
1071 ;; If there are References, and no "Re: ", then the thread has | |
1072 ;; changed name. See Son-of-1036. | |
1073 (if (and (mail-fetch-field "references") | |
1074 (get-buffer gnus-article-buffer)) | |
1075 (let ((psubject (gnus-simplify-subject-re | |
1076 (mail-fetch-field "subject")))) | |
1077 (or (and psubject gnus-reply-subject | |
1078 (string= (gnus-simplify-subject-re gnus-reply-subject) | |
1079 psubject)) | |
1080 (progn | |
1081 (string-match "@" Message-ID) | |
1082 (setq Message-ID | |
1083 (concat (substring Message-ID 0 (match-beginning 0)) | |
1084 "_-_" | |
1085 (substring Message-ID (match-beginning 0)))))))) | |
1086 ;; Go through all the required headers and see if they are in the | |
1087 ;; articles already. If they are not, or are empty, they are | |
1088 ;; inserted automatically - except for Subject, Newsgroups and | |
1089 ;; Distribution. | |
1090 (while headers | |
1091 (goto-char (point-min)) | |
1092 (setq elem (car headers)) | |
1093 (if (consp elem) | |
1094 (setq header (car elem)) | |
1095 (setq header elem)) | |
1096 (if (or (not (re-search-forward | |
1097 (concat "^" (downcase (symbol-name header)) ":") nil t)) | |
1098 (progn | |
1099 ;; The header was found. We insert a space after the | |
1100 ;; colon, if there is none. | |
1101 (if (/= (following-char) ? ) (insert " ")) | |
1102 ;; Find out whether the header is empty... | |
1103 (looking-at "[ \t]*$"))) | |
1104 ;; So we find out what value we should insert. | |
1105 (progn | |
1106 (setq value | |
1107 (or (if (consp elem) | |
1108 ;; The element is a cons. Either the cdr is | |
1109 ;; a string to be inserted verbatim, or it | |
1110 ;; is a function, and we insert the value | |
1111 ;; returned from this function. | |
1112 (or (and (stringp (cdr elem)) (cdr elem)) | |
1113 (and (fboundp (cdr elem)) (funcall (cdr elem)))) | |
1114 ;; The element is a symbol. We insert the | |
1115 ;; value of this symbol, if any. | |
1116 (and (boundp header) (symbol-value header))) | |
1117 ;; We couldn't generate a value for this header, | |
1118 ;; so we just ask the user. | |
1119 (read-from-minibuffer | |
1120 (format "Empty header for %s; enter value: " header)))) | |
1121 ;; Finally insert the header. | |
1122 (save-excursion | |
1123 (if (bolp) | |
1124 (progn | |
1125 (goto-char (point-max)) | |
1126 (insert (symbol-name header) ": " value "\n") | |
1127 (forward-line -1)) | |
1128 (replace-match value t t)) | |
1129 ;; Add the deletable property to the headers that require it. | |
1130 (and (memq header gnus-deletable-headers) | |
1131 (progn (beginning-of-line) (looking-at "[^:]+: ")) | |
1132 (add-text-properties | |
1133 (point) (match-end 0) | |
1134 '(gnus-deletable t face italic) (current-buffer)))))) | |
1135 (setq headers (cdr headers))) | |
1136 ;; Insert new Sender if the From is strange. | |
1137 (let ((from (mail-fetch-field "from")) | |
1138 (sender (mail-fetch-field "sender"))) | |
14604
ab3a6813575a
(gnus-inews-insert-headers): Check whether Sender
Karl Heuer <kwzh@gnu.org>
parents:
14478
diff
changeset
|
1139 (if (and from |
13401 | 1140 (not (string= |
14604
ab3a6813575a
(gnus-inews-insert-headers): Check whether Sender
Karl Heuer <kwzh@gnu.org>
parents:
14478
diff
changeset
|
1141 (downcase |
ab3a6813575a
(gnus-inews-insert-headers): Check whether Sender
Karl Heuer <kwzh@gnu.org>
parents:
14478
diff
changeset
|
1142 (car (cdr (gnus-extract-address-components from)))) |
13401 | 1143 (downcase (gnus-inews-real-user-address)))) |
1144 (or (null sender) | |
14604
ab3a6813575a
(gnus-inews-insert-headers): Check whether Sender
Karl Heuer <kwzh@gnu.org>
parents:
14478
diff
changeset
|
1145 (not |
13401 | 1146 (string= |
14604
ab3a6813575a
(gnus-inews-insert-headers): Check whether Sender
Karl Heuer <kwzh@gnu.org>
parents:
14478
diff
changeset
|
1147 (downcase |
ab3a6813575a
(gnus-inews-insert-headers): Check whether Sender
Karl Heuer <kwzh@gnu.org>
parents:
14478
diff
changeset
|
1148 (car (cdr (gnus-extract-address-components sender)))) |
13401 | 1149 (downcase (gnus-inews-real-user-address)))))) |
1150 (progn | |
14604
ab3a6813575a
(gnus-inews-insert-headers): Check whether Sender
Karl Heuer <kwzh@gnu.org>
parents:
14478
diff
changeset
|
1151 (goto-char (point-min)) |
13401 | 1152 (and (re-search-forward "^Sender:" nil t) |
1153 (progn | |
1154 (beginning-of-line) | |
1155 (insert "Original-") | |
1156 (beginning-of-line))) | |
1157 (insert "Sender: " (gnus-inews-real-user-address) "\n")))))) | |
1158 | |
1159 | |
1160 (defun gnus-inews-insert-signature () | |
1161 "Insert a signature file. | |
1162 If `gnus-signature-function' is bound and returns a string, this | |
1163 string is used instead of the variable `gnus-signature-file'. | |
1164 In either case, if the string is a file name, this file is | |
1165 inserted. If the string is not a file name, the string itself is | |
1166 inserted. | |
1167 | |
1168 If you never want any signature inserted, set both of these variables to | |
1169 nil." | |
1170 (save-excursion | |
1171 (let ((signature | |
1172 (or (and gnus-signature-function | |
1173 (funcall gnus-signature-function gnus-newsgroup-name)) | |
1174 gnus-signature-file))) | |
1175 (if (and signature | |
1176 (or (file-exists-p signature) | |
1177 (string-match " " signature) | |
1178 (not (string-match | |
1179 "^/[^/]+/" (expand-file-name signature))))) | |
1180 (progn | |
1181 (goto-char (point-max)) | |
1182 (if (and mail-signature (search-backward "\n-- \n" nil t)) | |
1183 () | |
1184 ;; Delete any previous signatures. | |
1185 (if (search-backward "\n-- \n" nil t) | |
1186 (delete-region (point) (point-max))) | |
1187 (or (eolp) (insert "\n")) | |
1188 (insert "-- \n") | |
1189 (if (file-exists-p signature) | |
1190 (insert-file-contents signature) | |
1191 (insert signature)) | |
1192 (goto-char (point-max)) | |
1193 (or (bolp) (insert "\n")))))))) | |
1194 | |
1195 ;; Written by "Mr. Per Persson" <pp@solace.mh.se>. | |
1196 (defun gnus-inews-insert-mime-headers () | |
1197 (let ((mail-header-separator "")) | |
1198 (or (mail-position-on-field "Mime-Version") | |
1199 (insert "1.0") | |
1200 (cond ((save-excursion | |
1201 (beginning-of-buffer) | |
1202 (re-search-forward "[\200-\377]" nil t)) | |
1203 (or (mail-position-on-field "Content-Type") | |
1204 (insert "text/plain; charset=ISO-8859-1")) | |
1205 (or (mail-position-on-field "Content-Transfer-Encoding") | |
1206 (insert "8bit"))) | |
1207 (t (or (mail-position-on-field "Content-Type") | |
1208 (insert "text/plain; charset=US-ASCII")) | |
1209 (or (mail-position-on-field "Content-Transfer-Encoding") | |
1210 (insert "7bit"))))))) | |
1211 | |
1212 (defun gnus-inews-do-fcc () | |
1213 "Process FCC: fields in current article buffer. | |
1214 Unless the first character of the field is `|', the article is saved | |
1215 to the specified file using the function specified by the variable | |
1216 gnus-author-copy-saver. The default function rmail-output saves in | |
1217 Unix mailbox format. | |
1218 If the first character is `|', the contents of the article is send to | |
1219 a program specified by the rest of the value." | |
1220 (let ((fcc-list nil) | |
1221 (fcc-file nil) | |
1222 (case-fold-search t)) ;Should ignore case. | |
1223 (save-excursion | |
1224 (save-restriction | |
1225 (goto-char (point-min)) | |
1226 (search-forward "\n\n") | |
1227 (narrow-to-region (point-min) (point)) | |
1228 (goto-char (point-min)) | |
1229 (while (re-search-forward "^FCC:[ \t]*" nil t) | |
1230 (setq fcc-list | |
1231 (cons (buffer-substring | |
1232 (point) | |
1233 (progn | |
1234 (end-of-line) | |
1235 (skip-chars-backward " \t") | |
1236 (point))) | |
1237 fcc-list)) | |
1238 (delete-region (match-beginning 0) | |
1239 (progn (forward-line 1) (point)))) | |
1240 ;; Process FCC operations. | |
1241 (widen) | |
1242 (while fcc-list | |
1243 (setq fcc-file (car fcc-list)) | |
1244 (setq fcc-list (cdr fcc-list)) | |
1245 (cond ((string-match "^[ \t]*|[ \t]*\\(.*\\)[ \t]*$" fcc-file) | |
1246 (let ((program (substring fcc-file | |
1247 (match-beginning 1) (match-end 1)))) | |
1248 ;; Suggested by yuki@flab.fujitsu.junet. | |
1249 ;; Send article to named program. | |
1250 (call-process-region (point-min) (point-max) shell-file-name | |
1251 nil nil nil "-c" program))) | |
1252 (t | |
1253 ;; Suggested by hyoko@flab.fujitsu.junet. | |
1254 ;; Save article in Unix mail format by default. | |
1255 (gnus-make-directory (file-name-directory fcc-file)) | |
1256 (if (and gnus-author-copy-saver | |
1257 (not (eq gnus-author-copy-saver 'rmail-output))) | |
1258 (funcall gnus-author-copy-saver fcc-file) | |
1259 (if (and (file-readable-p fcc-file) | |
1260 (mail-file-babyl-p fcc-file)) | |
1261 (gnus-output-to-rmail fcc-file) | |
1262 (rmail-output fcc-file 1 t t)))))))))) | |
1263 | |
1264 (defun gnus-inews-path () | |
1265 "Return uucp path." | |
1266 (let ((login-name (gnus-inews-login-name))) | |
1267 (cond ((null gnus-use-generic-path) | |
1268 (concat (nth 1 gnus-select-method) "!" login-name)) | |
1269 ((stringp gnus-use-generic-path) | |
1270 ;; Support GENERICPATH. Suggested by vixie@decwrl.dec.com. | |
1271 (concat gnus-use-generic-path "!" login-name)) | |
1272 (t login-name)))) | |
1273 | |
1274 (defun gnus-inews-user-name () | |
1275 "Return user's network address as \"NAME@DOMAIN (FULL-NAME)\"." | |
1276 (let ((full-name (gnus-inews-full-name)) | |
1277 (address (if (or gnus-user-login-name gnus-use-generic-from | |
1278 gnus-local-domain (getenv "DOMAINNAME")) | |
1279 (concat (gnus-inews-login-name) "@" | |
1280 (gnus-inews-domain-name gnus-use-generic-from)) | |
1281 user-mail-address))) | |
1282 (or gnus-user-from-line | |
1283 (concat address | |
1284 ;; User's full name. | |
1285 (cond ((string-equal full-name "&") ;Unix hack. | |
1286 (concat " (" (user-login-name) ")")) | |
1287 ((string-match "[^ ]+@[^ ]+ +(.*)" address) | |
1288 "") | |
1289 (t | |
1290 (concat " (" full-name ")"))))))) | |
1291 | |
1292 (defun gnus-inews-real-user-address () | |
1293 "Return the \"real\" user address. | |
1294 This function tries to ignore all user modifications, and | |
1295 give as trustworthy answer as possible." | |
1296 (concat (user-login-name) "@" (gnus-inews-full-address))) | |
1297 | |
1298 (defun gnus-inews-login-name () | |
1299 "Return login name." | |
1300 (or gnus-user-login-name (getenv "LOGNAME") (user-login-name))) | |
1301 | |
1302 (defun gnus-inews-full-name () | |
1303 "Return full user name." | |
1304 (or gnus-user-full-name (getenv "NAME") (user-full-name))) | |
1305 | |
1306 (defun gnus-inews-domain-name (&optional genericfrom) | |
1307 "Return user's domain name. | |
1308 If optional argument GENERICFROM is a string, use it as the domain | |
1309 name; if it is non-nil, strip off local host name from the domain name. | |
1310 If the function `system-name' returns full internet name and the | |
1311 domain is undefined, the domain name is got from it." | |
1312 (if (or genericfrom gnus-local-domain (getenv "DOMAINNAME")) | |
1313 (let* ((system-name (system-name)) | |
1314 (domain | |
1315 (or (if (stringp genericfrom) genericfrom) | |
1316 (getenv "DOMAINNAME") | |
1317 gnus-local-domain | |
1318 ;; Function `system-name' may return full internet name. | |
1319 ;; Suggested by Mike DeCorte <mrd@sun.soe.clarkson.edu>. | |
1320 (if (string-match "\\." system-name) | |
1321 (substring system-name (match-end 0))) | |
1322 (read-string "Domain name (no host): "))) | |
1323 (host (or (if (string-match "\\." system-name) | |
1324 (substring system-name 0 (match-beginning 0))) | |
1325 system-name))) | |
1326 (if (string-equal "." (substring domain 0 1)) | |
1327 (setq domain (substring domain 1))) | |
1328 ;; Support GENERICFROM as same as standard Bnews system. | |
1329 ;; Suggested by ohm@kaba.junet and vixie@decwrl.dec.com. | |
1330 (cond ((null genericfrom) | |
1331 (concat host "." domain)) | |
1332 ;;((stringp genericfrom) genericfrom) | |
1333 (t domain))) | |
1334 (if (string-match "\\." (system-name)) | |
1335 (system-name) | |
1336 (substring user-mail-address | |
1337 (1+ (string-match "@" user-mail-address)))))) | |
1338 | |
1339 (defun gnus-inews-full-address () | |
1340 (let ((domain (gnus-inews-domain-name)) | |
1341 (system (system-name)) | |
1342 (case-fold-search t)) | |
1343 (if (string-match "\\." system) system | |
1344 (if (string-match (concat "^" (regexp-quote system)) domain) domain | |
1345 (concat system "." domain))))) | |
1346 | |
1347 (defun gnus-inews-message-id () | |
1348 "Generate unique Message-ID for user." | |
1349 ;; Message-ID should not contain a slash and should be terminated by | |
1350 ;; a number. I don't know the reason why it is so. | |
1351 (concat "<" (gnus-inews-unique-id) "@" (gnus-inews-full-address) ">")) | |
1352 | |
1353 (defvar gnus-unique-id-char nil) | |
1354 | |
1355 ;; If you ever change this function, make sure the new version | |
1356 ;; cannot generate IDs that the old version could. | |
1357 ;; You might for example insert a "." somewhere (not next to another dot | |
1358 ;; or string boundary), or modify the newsreader name to "Ding". | |
1359 (defun gnus-inews-unique-id () | |
14040 | 1360 ;; Don't use microseconds from (current-time), they may be unsupported. |
13401 | 1361 ;; Instead we use this randomly inited counter. |
1362 (setq gnus-unique-id-char | |
1363 (% (1+ (or gnus-unique-id-char (logand (random t) (1- (lsh 1 20))))) | |
1364 ;; (current-time) returns 16-bit ints, | |
1365 ;; and 2^16*25 just fits into 4 digits i base 36. | |
1366 (* 25 25))) | |
1367 (let ((tm (if (fboundp 'current-time) | |
1368 (current-time) '(12191 46742 287898)))) | |
1369 (concat | |
1370 (if (memq system-type '(ms-dos emx vax-vms)) | |
1371 (let ((user (downcase (gnus-inews-login-name)))) | |
1372 (while (string-match "[^a-z0-9_]" user) | |
1373 (aset user (match-beginning 0) ?_)) | |
1374 user) | |
1375 (gnus-number-base36 (user-uid) -1)) | |
1376 (gnus-number-base36 (+ (car tm) (lsh (% gnus-unique-id-char 25) 16)) 4) | |
1377 (gnus-number-base36 (+ (nth 1 tm) (lsh (/ gnus-unique-id-char 25) 16)) 4) | |
1378 ;; Append the newsreader name, because while the generated | |
1379 ;; ID is unique to this newsreader, other newsreaders might | |
1380 ;; otherwise generate the same ID via another algorithm. | |
1381 ".fsf"))) | |
1382 | |
1383 | |
1384 (defun gnus-inews-date () | |
1385 "Current time string." | |
15298
7c0be13394a1
(gnus-inews-date): Avoid race condition.
Karl Heuer <kwzh@gnu.org>
parents:
14604
diff
changeset
|
1386 ;; We call (current-time) once, rather than letting current-time-string and |
7c0be13394a1
(gnus-inews-date): Avoid race condition.
Karl Heuer <kwzh@gnu.org>
parents:
14604
diff
changeset
|
1387 ;; current-time-zone default to it, because that avoids a rare race |
7c0be13394a1
(gnus-inews-date): Avoid race condition.
Karl Heuer <kwzh@gnu.org>
parents:
14604
diff
changeset
|
1388 ;; condition when the time zone changes between those two calls. |
7c0be13394a1
(gnus-inews-date): Avoid race condition.
Karl Heuer <kwzh@gnu.org>
parents:
14604
diff
changeset
|
1389 (let ((now (current-time))) |
7c0be13394a1
(gnus-inews-date): Avoid race condition.
Karl Heuer <kwzh@gnu.org>
parents:
14604
diff
changeset
|
1390 (timezone-make-date-arpa-standard |
7c0be13394a1
(gnus-inews-date): Avoid race condition.
Karl Heuer <kwzh@gnu.org>
parents:
14604
diff
changeset
|
1391 (current-time-string now) (current-time-zone now)))) |
13401 | 1392 |
1393 (defun gnus-inews-organization () | |
1394 "Return user's organization. | |
1395 The ORGANIZATION environment variable is used if defined. | |
1396 If not, the variable `gnus-local-organization' is used instead. | |
1397 If it is a function, the function will be called with the current | |
1398 newsgroup name as the argument. | |
1399 If this is a file name, the contents of this file will be used as the | |
1400 organization." | |
1401 (let* ((organization | |
1402 (or (getenv "ORGANIZATION") | |
1403 (if gnus-local-organization | |
1404 (if (and (symbolp gnus-local-organization) | |
1405 (fboundp gnus-local-organization)) | |
1406 (funcall gnus-local-organization gnus-newsgroup-name) | |
1407 gnus-local-organization)) | |
1408 gnus-organization-file | |
1409 "~/.organization"))) | |
1410 (and (stringp organization) | |
1411 (> (length organization) 0) | |
1412 (or (file-exists-p organization) | |
1413 (string-match " " organization) | |
1414 (not (string-match "^/usr/lib/" organization))) | |
1415 (save-excursion | |
1416 (gnus-set-work-buffer) | |
1417 (if (file-exists-p organization) | |
1418 (insert-file-contents organization) | |
1419 (insert organization)) | |
1420 (goto-char (point-min)) | |
1421 (while (re-search-forward " *\n *" nil t) | |
1422 (replace-match " " t t)) | |
1423 (buffer-substring (point-min) (point-max)))))) | |
1424 | |
1425 (defun gnus-inews-lines () | |
1426 "Count the number of lines and return numeric string." | |
1427 (save-excursion | |
1428 (save-restriction | |
1429 (widen) | |
1430 (goto-char (point-min)) | |
1431 (re-search-forward | |
1432 (concat "^" (regexp-quote mail-header-separator) "$")) | |
1433 (forward-line 1) | |
1434 (int-to-string (count-lines (point) (point-max)))))) | |
1435 | |
1436 | |
1437 ;;; | |
1438 ;;; Gnus Mail Functions | |
1439 ;;; | |
1440 | |
1441 ;;; Mail reply commands of Gnus summary mode | |
1442 | |
1443 (defun gnus-summary-reply (yank &optional yank-articles) | |
1444 "Reply mail to news author. | |
1445 If prefix argument YANK is non-nil, original article is yanked automatically. | |
1446 Customize the variable gnus-mail-reply-method to use another mailer." | |
1447 (interactive "P") | |
1448 ;; Bug fix by jbw@bigbird.bu.edu (Joe Wells) | |
1449 ;; Stripping headers should be specified with mail-yank-ignored-headers. | |
1450 (gnus-set-global-variables) | |
1451 (if yank-articles (gnus-summary-goto-subject (car yank-articles))) | |
1452 (gnus-summary-select-article) | |
1453 (let ((gnus-newsgroup-name gnus-newsgroup-name)) | |
1454 (bury-buffer gnus-article-buffer) | |
1455 (funcall gnus-mail-reply-method (or yank-articles (not (not yank)))))) | |
1456 | |
1457 (defun gnus-summary-reply-with-original (n) | |
1458 "Reply mail to news author with original article. | |
1459 Customize the variable gnus-mail-reply-method to use another mailer." | |
1460 (interactive "P") | |
1461 (gnus-summary-reply t (gnus-summary-work-articles n))) | |
1462 | |
1463 (defun gnus-summary-mail-forward (post) | |
1464 "Forward the current message to another user. | |
1465 Customize the variable gnus-mail-forward-method to use another mailer." | |
1466 (interactive "P") | |
1467 (gnus-set-global-variables) | |
1468 (gnus-summary-select-article) | |
1469 (gnus-copy-article-buffer) | |
1470 (let ((gnus-newsgroup-name gnus-newsgroup-name)) | |
1471 (if post | |
1472 (gnus-forward-using-post gnus-article-copy) | |
1473 (funcall gnus-mail-forward-method gnus-article-copy)))) | |
1474 | |
1475 (defun gnus-summary-post-forward () | |
1476 "Forward the current article to a newsgroup." | |
1477 (interactive) | |
1478 (gnus-summary-mail-forward t)) | |
1479 | |
1480 (defvar gnus-nastygram-message | |
1481 "The following article was inappropriately posted to %s.\n" | |
1482 "Format string to insert in nastygrams. | |
1483 The current group name will be inserted at \"%s\".") | |
1484 | |
1485 (defun gnus-summary-mail-nastygram (n) | |
1486 "Send a nastygram to the author of the current article." | |
1487 (interactive "P") | |
1488 (if (or gnus-expert-user | |
1489 (gnus-y-or-n-p | |
1490 "Really send a nastygram to the author of the current article? ")) | |
1491 (let ((group gnus-newsgroup-name)) | |
1492 (gnus-summary-reply-with-original n) | |
1493 (set-buffer gnus-mail-buffer) | |
1494 (insert (format gnus-nastygram-message group)) | |
1495 (gnus-mail-send-and-exit)))) | |
1496 | |
1497 (defun gnus-summary-mail-other-window () | |
1498 "Compose mail in other window. | |
1499 Customize the variable `gnus-mail-other-window-method' to use another | |
1500 mailer." | |
1501 (interactive) | |
1502 (gnus-set-global-variables) | |
1503 (let ((gnus-newsgroup-name gnus-newsgroup-name)) | |
1504 (funcall gnus-mail-other-window-method))) | |
1505 | |
1506 (defun gnus-mail-reply-using-mail (&optional yank to-address) | |
1507 (save-excursion | |
1508 (set-buffer gnus-summary-buffer) | |
1509 (let ((group (gnus-group-real-name gnus-newsgroup-name)) | |
1510 (cur (cons (current-buffer) (cdr gnus-article-current))) | |
1511 (winconf (current-window-configuration)) | |
1512 from subject date reply-to message-of | |
1513 references message-id sender follow-to sendto elt) | |
1514 (set-buffer (get-buffer-create gnus-mail-buffer)) | |
1515 (mail-mode) | |
1516 (make-local-variable 'gnus-article-reply) | |
1517 (setq gnus-article-reply cur) | |
1518 (make-local-variable 'gnus-prev-winconf) | |
1519 (setq gnus-prev-winconf winconf) | |
1520 (if (and (buffer-modified-p) | |
1521 (> (buffer-size) 0) | |
1522 (not (gnus-y-or-n-p | |
1523 "Unsent article being composed; erase it? "))) | |
1524 () | |
1525 (erase-buffer) | |
1526 (save-excursion | |
1527 (gnus-copy-article-buffer) | |
1528 (save-restriction | |
1529 (set-buffer gnus-article-copy) | |
1530 (gnus-narrow-to-headers) | |
1531 (if (and (boundp 'gnus-reply-to-function) | |
1532 gnus-reply-to-function) | |
1533 (setq follow-to (funcall gnus-reply-to-function group))) | |
1534 (setq from (mail-fetch-field "from")) | |
1535 (setq date (or (mail-fetch-field "date") | |
1536 (mail-header-date gnus-current-headers))) | |
1537 (and from | |
1538 (let ((stop-pos | |
1539 (string-match " *at \\| *@ \\| *(\\| *<" from))) | |
1540 (setq message-of | |
1541 (concat (if stop-pos (substring from 0 stop-pos) from) | |
1542 "'s message of " date)))) | |
1543 (setq sender (mail-fetch-field "sender")) | |
1544 (setq subject (or (mail-fetch-field "subject") | |
1545 "Re: none")) | |
1546 (or (string-match "^[Rr][Ee]:" subject) | |
1547 (setq subject (concat "Re: " subject))) | |
1548 (setq reply-to (mail-fetch-field "reply-to")) | |
1549 (setq references (mail-fetch-field "references")) | |
1550 (setq message-id (mail-fetch-field "message-id")) | |
1551 (widen)) | |
1552 (setq news-reply-yank-from (or from "(nobody)"))) | |
1553 (setq news-reply-yank-message-id | |
1554 (or message-id "(unknown Message-ID)")) | |
1555 | |
1556 ;; Gather the "to" addresses out of the follow-to list and remove | |
1557 ;; them as we go. | |
1558 (if (and follow-to (listp follow-to)) | |
1559 (while (setq elt (assoc "To" follow-to)) | |
1560 (setq sendto (concat sendto (and sendto ", ") (cdr elt))) | |
1561 (setq follow-to (delq elt follow-to)))) | |
1562 | |
1563 (mail-setup (or to-address | |
1564 (if (and follow-to (not (stringp follow-to))) sendto | |
1565 (or follow-to reply-to from sender ""))) | |
1566 subject message-of nil gnus-article-copy nil) | |
1567 | |
1568 (auto-save-mode auto-save-default) | |
14478
cb600acfe4f6
(gnus-mail-reply-using-mail): Use the local keymap
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1569 (use-local-map (copy-keymap (current-local-map))) |
13401 | 1570 (local-set-key "\C-c\C-c" 'gnus-mail-send-and-exit) |
1571 | |
1572 (if (and follow-to (listp follow-to)) | |
1573 (progn | |
1574 (goto-char (point-min)) | |
1575 (re-search-forward "^To:" nil t) | |
1576 (beginning-of-line) | |
1577 (forward-line 1) | |
1578 (while follow-to | |
1579 (insert (car (car follow-to)) ": " (cdr (car follow-to)) "\n") | |
1580 (setq follow-to (cdr follow-to))))) | |
1581 (nnheader-insert-references references message-id) | |
1582 (goto-char (point-min)) | |
1583 (re-search-forward | |
1584 (concat "^" (regexp-quote mail-header-separator) "$")) | |
1585 (forward-line 1) | |
1586 (if (not yank) | |
1587 (gnus-configure-windows 'reply 'force) | |
1588 (let ((last (point)) | |
1589 end) | |
1590 (if (not (listp yank)) | |
1591 (progn | |
1592 (save-excursion | |
1593 (mail-yank-original nil)) | |
1594 (or mail-yank-hooks mail-citation-hook | |
1595 (run-hooks 'news-reply-header-hook))) | |
1596 (while yank | |
1597 (save-window-excursion | |
1598 (set-buffer gnus-summary-buffer) | |
1599 (gnus-summary-select-article nil nil nil (car yank)) | |
1600 (gnus-summary-remove-process-mark (car yank))) | |
1601 (save-excursion | |
1602 (gnus-copy-article-buffer) | |
1603 (mail-yank-original nil) | |
1604 (setq end (point))) | |
1605 (or mail-yank-hooks mail-citation-hook | |
1606 (run-hooks 'news-reply-header-hook)) | |
1607 (goto-char end) | |
1608 (setq yank (cdr yank)))) | |
1609 (goto-char last)) | |
1610 (gnus-configure-windows 'reply-yank 'force)) | |
1611 (run-hooks 'gnus-mail-hook))))) | |
1612 | |
1613 (defun gnus-mail-yank-original () | |
1614 (interactive) | |
1615 (save-excursion | |
1616 (mail-yank-original nil)) | |
1617 (or mail-yank-hooks mail-citation-hook | |
1618 (run-hooks 'news-reply-header-hook))) | |
1619 | |
1620 (defun gnus-mail-send-and-exit () | |
1621 (interactive) | |
1622 (let ((reply gnus-article-reply) | |
1623 (winconf gnus-prev-winconf)) | |
1624 (mail-send-and-exit nil) | |
1625 (if (get-buffer gnus-group-buffer) | |
1626 (progn | |
1627 (if (gnus-buffer-exists-p (car-safe reply)) | |
1628 (progn | |
1629 (set-buffer (car reply)) | |
1630 (and (cdr reply) | |
1631 (gnus-summary-mark-article-as-replied | |
1632 (cdr reply))))) | |
1633 (and winconf (set-window-configuration winconf)))))) | |
1634 | |
1635 (defun gnus-forward-make-subject (buffer) | |
1636 (save-excursion | |
1637 (set-buffer buffer) | |
1638 (concat "[" (if (memq 'mail (assoc (symbol-name | |
1639 (car (gnus-find-method-for-group | |
1640 gnus-newsgroup-name))) | |
1641 gnus-valid-select-methods)) | |
1642 (gnus-fetch-field "From") | |
1643 gnus-newsgroup-name) | |
1644 "] " (or (gnus-fetch-field "Subject") "")))) | |
1645 | |
1646 (defun gnus-forward-insert-buffer (buffer) | |
1647 (let ((beg (goto-char (point-max)))) | |
1648 (insert "------- Start of forwarded message -------\n") | |
1649 (insert-buffer buffer) | |
1650 (goto-char (point-max)) | |
1651 (insert "------- End of forwarded message -------\n") | |
1652 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>. | |
1653 (goto-char beg) | |
1654 (while (setq beg (next-single-property-change (point) 'invisible)) | |
1655 (goto-char beg) | |
1656 (delete-region beg (or (next-single-property-change | |
1657 (point) 'invisible) | |
1658 (point-max)))))) | |
1659 | |
1660 (defun gnus-mail-forward-using-mail (&optional buffer) | |
1661 "Forward the current message to another user using mail." | |
1662 ;; This is almost a carbon copy of rmail-forward in rmail.el. | |
1663 (let* ((forward-buffer (or buffer (current-buffer))) | |
1664 (winconf (current-window-configuration)) | |
1665 (subject (gnus-forward-make-subject forward-buffer))) | |
1666 (set-buffer forward-buffer) | |
1667 (mail nil nil subject) | |
1668 (use-local-map (copy-keymap (current-local-map))) | |
1669 (local-set-key "\C-c\C-c" 'gnus-mail-send-and-exit) | |
1670 (make-local-variable 'gnus-prev-winconf) | |
1671 (setq gnus-prev-winconf winconf) | |
1672 (gnus-forward-insert-buffer forward-buffer) | |
1673 (goto-char (point-min)) | |
1674 (re-search-forward "^To: " nil t) | |
1675 (gnus-configure-windows 'mail-forward 'force) | |
1676 ;; You have a chance to arrange the message. | |
1677 (run-hooks 'gnus-mail-forward-hook) | |
1678 (run-hooks 'gnus-mail-hook))) | |
1679 | |
1680 (defun gnus-forward-using-post (&optional buffer) | |
1681 (save-excursion | |
1682 (let* ((forward-buffer (or buffer (current-buffer))) | |
1683 (subject (gnus-forward-make-subject forward-buffer)) | |
1684 (gnus-newsgroup-name nil)) | |
1685 (gnus-post-news 'post nil nil nil nil subject) | |
1686 (save-excursion | |
1687 (gnus-forward-insert-buffer forward-buffer) | |
1688 ;; You have a chance to arrange the message. | |
1689 (run-hooks 'gnus-mail-forward-hook))))) | |
1690 | |
1691 (defun gnus-mail-other-window-using-mail () | |
1692 "Compose mail other window using mail." | |
1693 (let ((winconf (current-window-configuration))) | |
1694 (mail-other-window nil nil nil nil nil (get-buffer gnus-article-buffer)) | |
1695 (use-local-map (copy-keymap (current-local-map))) | |
1696 (local-set-key "\C-c\C-c" 'gnus-mail-send-and-exit) | |
1697 (make-local-variable 'gnus-prev-winconf) | |
1698 (setq gnus-prev-winconf winconf) | |
1699 (run-hooks 'gnus-mail-hook) | |
1700 (gnus-configure-windows 'summary-mail 'force))) | |
1701 | |
1702 (defun gnus-article-mail (yank) | |
1703 "Send a reply to the address near point. | |
1704 If YANK is non-nil, include the original article." | |
1705 (interactive "P") | |
1706 (let ((address | |
1707 (buffer-substring | |
1708 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point))) | |
1709 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point)))))) | |
1710 (and address | |
1711 (progn | |
1712 (switch-to-buffer gnus-summary-buffer) | |
1713 (funcall gnus-mail-reply-method yank address))))) | |
1714 | |
1715 (defun gnus-bug () | |
1716 "Send a bug report to the Gnus maintainers." | |
1717 (interactive) | |
1718 (let ((winconf (current-window-configuration))) | |
1719 (delete-other-windows) | |
1720 (switch-to-buffer "*Gnus Help Bug*") | |
1721 (erase-buffer) | |
1722 (insert gnus-bug-message) | |
1723 (goto-char (point-min)) | |
1724 (pop-to-buffer "*Gnus Bug*") | |
1725 (erase-buffer) | |
1726 (mail-mode) | |
1727 (mail-setup gnus-maintainer nil nil nil nil nil) | |
1728 (auto-save-mode auto-save-default) | |
1729 (make-local-variable 'gnus-prev-winconf) | |
1730 (setq gnus-prev-winconf winconf) | |
1731 (use-local-map (copy-keymap mail-mode-map)) | |
1732 (local-set-key "\C-c\C-c" 'gnus-bug-mail-send-and-exit) | |
1733 (goto-char (point-min)) | |
1734 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$")) | |
1735 (forward-line 1) | |
1736 (insert (format "%s\n%s\n\n\n\n\n" (gnus-version) (emacs-version))) | |
1737 (gnus-debug) | |
1738 (goto-char (point-min)) | |
1739 (search-forward "Subject: " nil t) | |
1740 (message ""))) | |
1741 | |
1742 (defun gnus-bug-mail-send-and-exit () | |
1743 "Send the bug message and exit." | |
1744 (interactive) | |
1745 (and (get-buffer "*Gnus Help Bug*") | |
1746 (kill-buffer "*Gnus Help Bug*")) | |
1747 (gnus-mail-send-and-exit)) | |
1748 | |
1749 (defun gnus-debug () | |
1750 "Attemps to go through the Gnus source file and report what variables have been changed. | |
1751 The source file has to be in the Emacs load path." | |
1752 (interactive) | |
1753 (let ((files '("gnus.el" "gnus-msg.el" "gnus-score.el")) | |
1754 file dirs expr olist sym) | |
1755 (message "Please wait while we snoop your variables...") | |
1756 (sit-for 0) | |
1757 (save-excursion | |
1758 (set-buffer (get-buffer-create " *gnus bug info*")) | |
1759 (buffer-disable-undo (current-buffer)) | |
1760 (while files | |
1761 (erase-buffer) | |
1762 (setq dirs load-path) | |
1763 (while dirs | |
1764 (if (or (not (car dirs)) | |
1765 (not (stringp (car dirs))) | |
1766 (not (file-exists-p | |
1767 (setq file (concat (file-name-as-directory | |
1768 (car dirs)) (car files)))))) | |
1769 (setq dirs (cdr dirs)) | |
1770 (setq dirs nil) | |
1771 (insert-file-contents file) | |
1772 (goto-char (point-min)) | |
1773 (or (re-search-forward "^;;* *Internal variables" nil t) | |
1774 (error "Malformed sources in file %s" file)) | |
1775 (narrow-to-region (point-min) (point)) | |
1776 (goto-char (point-min)) | |
1777 (while (setq expr (condition-case () | |
1778 (read (current-buffer)) (error nil))) | |
1779 (condition-case () | |
1780 (and (eq (car expr) 'defvar) | |
1781 (stringp (nth 3 expr)) | |
1782 (or (not (boundp (nth 1 expr))) | |
1783 (not (equal (eval (nth 2 expr)) | |
1784 (symbol-value (nth 1 expr))))) | |
1785 (setq olist (cons (nth 1 expr) olist))) | |
1786 (error nil))))) | |
1787 (setq files (cdr files))) | |
1788 (kill-buffer (current-buffer))) | |
1789 (insert "------------------- Environment follows -------------------\n\n") | |
1790 (while olist | |
1791 (if (boundp (car olist)) | |
1792 (insert "(setq " (symbol-name (car olist)) | |
1793 (if (or (consp (setq sym (symbol-value (car olist)))) | |
1794 (and (symbolp sym) | |
1795 (not (or (eq sym nil) | |
1796 (eq sym t))))) | |
1797 " '" " ") | |
1798 (prin1-to-string (symbol-value (car olist))) ")\n") | |
1799 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n")) | |
1800 (setq olist (cdr olist))) | |
1801 (insert "\n\n") | |
1802 ;; Remove any null chars - they seem to cause trouble for some | |
1803 ;; mailers. (Byte-compiled output from the stuff above.) | |
1804 (goto-char (point-min)) | |
1805 (while (re-search-forward "[\000\200]" nil t) | |
1806 (replace-match "" t t)))) | |
1807 | |
1808 (gnus-ems-redefine) | |
1809 | |
1810 (provide 'gnus-msg) | |
1811 | |
1812 ;;; gnus-msg.el ends here |