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