1 ;;; gnus-msg.el --- mail and post interface for Gnus
2 ;; Copyright (C) 1995 Free Software Foundation, Inc.
4 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
5 ;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
8 ;; This file is part of GNU Emacs.
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)
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.
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.
31 (defvar gnus-organization-file "/usr/lib/news/organization"
32 "*Local news organization file.")
34 (defvar gnus-post-prepare-function nil
35 "*Function that is run after a post buffer has been prepared.
36 It is called with the name of the newsgroup that is posted to. It
37 might be used, for instance, for inserting signatures based on the
38 newsgroup name. (In that case, `gnus-signature-file' and
39 `mail-signature' should both be set to nil).")
41 (defvar gnus-use-followup-to 'use
42 "*Specifies what to do with Followup-To header.
43 If nil, ignore the header. If it is t, use its value, but ignore
44 `poster'. If it is neither nil nor t, which is the default, always use
47 (defvar gnus-followup-to-function nil
48 "*A variable that contains a function that returns a followup address.
49 The function will be called in the buffer of the article that is being
50 followed up. The buffer will be narrowed to the headers of the
51 article. To pick header headers, one might use `mail-fetch-field'. The
52 function will be called with the name of the current newsgroup as the
55 Here's an example `gnus-followup-to-function':
57 (setq gnus-followup-to-function
59 (cond ((string= group \"mail.list\")
60 (or (mail-fetch-field \"sender\")
61 (mail-fetch-field \"from\")))
63 (or (mail-fetch-field \"reply-to\")
64 (mail-fetch-field \"from\"))))))")
66 (defvar gnus-reply-to-function nil
67 "*A variable that contains a function that returns a reply address.
68 See the `gnus-followup-to-function' variable for an explanation of how
69 this variable is used.
71 This function should return a string that will be used to fill in the
72 header. This function may also return a list. In that case, every
73 list element should be a cons where the first car should be a string
74 with the header name, and the cdr should be a string with the header
77 (defvar gnus-author-copy (getenv "AUTHORCOPY")
78 "*Save outgoing articles in this file.
79 Initialized from the AUTHORCOPY environment variable.
81 If this variable begins with the character \"|\", outgoing articles
82 will be piped to the named program. It is possible to save an article
83 in an MH folder as follows:
85 \(setq gnus-author-copy \"|/usr/local/lib/mh/rcvstore +Article\")
87 If the first character is not a pipe, articles are saved using the
88 function specified by the `gnus-author-copy-saver' variable.")
90 (defvar gnus-mail-self-blind nil
91 "*Non-nil means insert a BCC header in all outgoing articles.
92 This will result in having a copy of the article mailed to yourself.
93 The BCC header is inserted when the post buffer is initialized, so you
94 can remove or alter the BCC header to override the default.")
96 (defvar gnus-author-copy-saver (function rmail-output)
97 "*A function called to save outgoing articles.
98 This function will be called with the same of the file to store the
99 article in. The default function is `rmail-output' which saves in Unix
102 (defvar gnus-user-login-name nil
103 "*The login name of the user.
104 Got from the function `user-login-name' if undefined.")
106 (defvar gnus-user-full-name nil
107 "*The full name of the user.
108 Got from the NAME environment variable if undefined.")
110 (defvar gnus-user-from-line nil
111 "*Your full, complete e-mail address.
112 Overrides the other Gnus variables if it is non-nil.
114 Here are two example values of this variable:
116 \"Lars Magne Ingebrigtsen <larsi@ifi.uio.no>\"
120 \"larsi@ifi.uio.no (Lars Magne Ingebrigtsen)\"
122 The first version is recommended, but the name has to be quoted if it
123 contains non-alphanumerical characters.")
125 (defvar gnus-signature-file "~/.signature"
126 "*Your signature file.
127 If the variable is a string that doesn't correspond to a file, the
128 string itself is inserted.")
130 (defvar gnus-signature-function nil
131 "*A function that should return a signature file name.
132 The function will be called with the name of the newsgroup being
134 If the function returns a string that doesn't correspond to a file, the
135 string itself is inserted.
136 If the function returns nil, the `gnus-signature-file' variable will
139 (defvar gnus-required-headers
140 '(From Date Newsgroups Subject Message-ID Organization Lines X-Newsreader)
141 "*Headers to be generated or prompted for when posting an article.
142 RFC977 and RFC1036 require From, Date, Newsgroups, Subject,
143 Message-ID. Organization, Lines and X-Newsreader are optional. If
144 you want Gnus not to insert some header, remove it from this list.")
146 (defvar gnus-check-before-posting
147 '(subject-cmsg multiple-headers sendsys message-id from
148 long-lines control-chars size new-text
150 "In non-nil, Gnus will attempt to run some checks on outgoing posts.
151 If this variable is t, Gnus will check everything it can. If it is a
152 list, then those elements in that list will be checked.")
154 (defvar gnus-auto-mail-to-author nil
155 "*If non-nil, mail the authors of articles a copy of your follow-ups.
156 If this variable is `ask', the user will be prompted for whether to
157 mail a copy. The string given by `gnus-mail-courtesy-message' will be
158 inserted at the beginning of the mail copy.
160 Mail is sent using the function specified by the
161 `gnus-mail-send-method' variable.")
163 ;; Added by Ethan Bradford <ethanb@ptolemy.astro.washington.edu>.
164 (defvar gnus-mail-courtesy-message
165 "The following message is a courtesy copy of an article\nthat has been posted as well.\n\n"
166 "*This is inserted at the start of a mailed copy of a posted message.
167 If this variable is nil, no such courtesy message will be added.")
169 (defvar gnus-mail-reply-method (function gnus-mail-reply-using-mail)
170 "*Function to compose a reply.
171 Three pre-made functions are `gnus-mail-reply-using-mail' (sendmail);
172 `gnus-mail-reply-using-mhe' (MH-E); and `gnus-mail-reply-using-vm'.")
174 (defvar gnus-mail-forward-method (function gnus-mail-forward-using-mail)
175 "*Function to forward the current message to another user.
176 Three pre-made functions are `gnus-mail-forward-using-mail' (sendmail);
177 `gnus-mail-forward-using-mhe' (MH-E); and `gnus-mail-forward-using-vm'.")
179 (defvar gnus-mail-other-window-method 'gnus-mail-other-window-using-mail
180 "*Function to compose mail in the other window.
181 Three pre-made functions are `gnus-mail-other-window-using-mail'
182 (sendmail); `gnus-mail-other-window-using-mhe' (MH-E); and
183 `gnus-mail-other-window-using-vm'.")
185 (defvar gnus-mail-send-method send-mail-function
186 "*Function to mail a message which is also being posted as an article.
187 The message must have To or Cc header. The default is copied from
188 the variable `send-mail-function'.")
190 (defvar gnus-inews-article-hook (list 'gnus-inews-do-fcc)
191 "*A hook called before finally posting an article.
192 The default hook (`gnus-inews-do-fcc') does FCC processing (ie. saves
193 the article to a file).")
195 (defvar gnus-inews-article-header-hook nil
196 "*A hook called after inserting the headers in an article to be posted.
197 The hook is called from the *post-news* buffer, narrowed to the
200 (defvar gnus-mail-hook nil
201 "*A hook called as the last thing after setting up a mail buffer.")
203 ;;; Internal variables.
205 (defvar gnus-post-news-buffer "*post-news*")
206 (defvar gnus-summary-send-map nil)
207 (defvar gnus-article-copy nil)
211 ;;; Gnus Posting Functions
214 (define-prefix-command 'gnus-summary-send-map)
215 (define-key gnus-summary-mode-map "S" 'gnus-summary-send-map)
216 (define-key gnus-summary-send-map "p" 'gnus-summary-post-news)
217 (define-key gnus-summary-send-map "f" 'gnus-summary-followup)
218 (define-key gnus-summary-send-map "F" 'gnus-summary-followup-with-original)
219 (define-key gnus-summary-send-map "b" 'gnus-summary-followup-and-reply)
220 (define-key gnus-summary-send-map "B" 'gnus-summary-followup-and-reply-with-original)
221 (define-key gnus-summary-send-map "c" 'gnus-summary-cancel-article)
222 (define-key gnus-summary-send-map "s" 'gnus-summary-supersede-article)
223 (define-key gnus-summary-send-map "r" 'gnus-summary-reply)
224 (define-key gnus-summary-send-map "R" 'gnus-summary-reply-with-original)
225 (define-key gnus-summary-send-map "m" 'gnus-summary-mail-other-window)
226 (define-key gnus-summary-send-map "u" 'gnus-uu-post-news)
227 (define-key gnus-summary-send-map "om" 'gnus-summary-mail-forward)
228 (define-key gnus-summary-send-map "op" 'gnus-summary-post-forward)
229 (define-key gnus-summary-send-map "Om" 'gnus-uu-digest-mail-forward)
230 (define-key gnus-summary-send-map "Op" 'gnus-uu-digest-post-forward)
232 ;;; Internal functions.
234 (defun gnus-number-base36 (num len)
235 (if (if (< len 0) (<= num 0) (= len 0))
237 (concat (gnus-number-base36 (/ num 36) (1- len))
238 (char-to-string (aref "zyxwvutsrqponmlkjihgfedcba9876543210"
241 ;;; Post news commands of Gnus group mode and summary mode
243 (defun gnus-group-mail ()
244 "Start composing a mail."
246 (funcall gnus-mail-other-window-method)
247 (gnus-configure-windows 'group-mail)
248 (run-hooks 'gnus-mail-hook))
250 (defun gnus-group-post-news ()
253 (let ((gnus-newsgroup-name nil))
254 (gnus-post-news 'post nil nil gnus-article-buffer)))
256 (defun gnus-summary-post-news ()
259 (gnus-set-global-variables)
260 (gnus-post-news 'post gnus-newsgroup-name))
262 (defun gnus-summary-followup (yank &optional yank-articles)
263 "Compose a followup to an article.
264 If prefix argument YANK is non-nil, original article is yanked automatically."
266 (gnus-set-global-variables)
267 (if yank-articles (gnus-summary-goto-subject (car yank-articles)))
268 (save-window-excursion
269 (gnus-summary-select-article t))
270 (let ((headers gnus-current-headers)
271 (gnus-newsgroup-name gnus-newsgroup-name))
272 ;; Check Followup-To: poster.
273 (set-buffer gnus-article-buffer)
274 (if (and gnus-use-followup-to
275 (string-equal "poster" (gnus-fetch-field "followup-to"))
276 (or (not (eq gnus-use-followup-to t))
278 "Do you want to ignore `Followup-To: poster'? "))))
279 ;; Mail to the poster. Gnus is now RFC1036 compliant.
280 (gnus-summary-reply yank)
281 (gnus-post-news nil gnus-newsgroup-name
282 headers gnus-article-buffer
283 (or yank-articles (not (not yank))))))
284 (gnus-article-hide-headers-if-wanted))
286 (defun gnus-summary-followup-with-original (n)
287 "Compose a followup to an article and include the original article."
289 (gnus-summary-followup t (gnus-summary-work-articles n)))
291 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
292 (defun gnus-summary-followup-and-reply (yank &optional yank-articles)
293 "Compose a followup and do an auto mail to author."
295 (gnus-set-global-variables)
296 (let ((gnus-auto-mail-to-author t))
297 (gnus-summary-followup yank yank-articles)))
299 (defun gnus-summary-followup-and-reply-with-original (n)
300 "Compose a followup, include the original, and do an auto mail to author."
302 (gnus-summary-followup-and-reply t (gnus-summary-work-articles n)))
304 (defun gnus-summary-cancel-article (n)
305 "Cancel an article you posted."
307 (gnus-set-global-variables)
308 (let ((articles (gnus-summary-work-articles n)))
310 (gnus-summary-select-article t nil nil (car articles))
311 (gnus-eval-in-buffer-window gnus-article-buffer (gnus-cancel-news))
312 (gnus-summary-remove-process-mark (car articles))
313 (gnus-summary-mark-as-read (car articles) gnus-canceled-mark)
314 (gnus-article-hide-headers-if-wanted)
315 (setq articles (cdr articles)))))
317 (defun gnus-summary-supersede-article ()
318 "Compose an article that will supersede a previous article.
319 This is done simply by taking the old article and adding a Supersedes
320 header line with the old Message-ID."
322 (gnus-set-global-variables)
325 (downcase (mail-strip-quoted-names
326 (header-from gnus-current-headers)))
327 (downcase (mail-strip-quoted-names (gnus-inews-user-name)))))
328 (error "This article is not yours."))
329 (gnus-summary-select-article t)
331 (set-buffer gnus-article-buffer)
332 (let ((buffer-read-only nil))
333 (goto-char (point-min))
334 (search-forward "\n\n" nil t)
335 (if (not (re-search-backward "^Message-ID: " nil t))
336 (error "No Message-ID in this article"))))
337 (if (gnus-post-news 'post gnus-newsgroup-name)
340 (insert-buffer gnus-article-buffer)
341 (goto-char (point-min))
342 (search-forward "\n\n" nil t)
343 (if (not (re-search-backward "^Message-ID: " nil t))
344 (error "No Message-ID in this article")
345 (replace-match "Supersedes: " t t))
346 (search-forward "\n\n")
348 (insert mail-header-separator))))
352 (defalias 'sendnews 'gnus-post-news)
355 (defalias 'postnews 'gnus-post-news)
357 (defun gnus-copy-article-buffer (&optional article-buffer)
358 ;; make a copy of the article buffer with all text properties removed
359 ;; this copy is in the buffer gnus-article-copy.
360 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
361 ;; this buffer should be passed to all mail/news reply/post routines.
362 (setq gnus-article-copy (get-buffer-create " *gnus article copy*"))
363 (buffer-disable-undo gnus-article-copy)
364 (or (memq gnus-article-copy gnus-buffer-list)
365 (setq gnus-buffer-list (cons gnus-article-copy gnus-buffer-list)))
366 (let ((article-buffer (or article-buffer gnus-article-buffer)))
367 (if (and (get-buffer article-buffer)
368 (buffer-name (get-buffer article-buffer)))
370 (set-buffer article-buffer)
371 (copy-to-buffer gnus-article-copy (point-min) (point-max))
372 (set-text-properties (point-min) (point-max)
373 nil gnus-article-copy)))))
375 (defun gnus-post-news (post &optional group header article-buffer yank subject)
376 "Begin editing a new USENET news article to be posted.
377 Type \\[describe-mode] in the buffer to get a list of commands."
378 (interactive (list t))
379 (gnus-copy-article-buffer article-buffer)
380 (if (or (not gnus-novice-user)
384 (format "%s" (car (gnus-find-method-for-group
385 gnus-newsgroup-name)))
386 gnus-valid-select-methods))))
389 (nth 5 (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))))
390 (gnus-y-or-n-p "Are you sure you want to post to all of USENET? "))
391 (let ((sumart (if (not post)
393 (set-buffer gnus-summary-buffer)
394 (cons (current-buffer) gnus-current-article))))
395 (from (and header (header-from header)))
396 (winconf (current-window-configuration))
397 follow-to real-group)
398 (and gnus-interactive-post
399 (not gnus-expert-user)
403 (completing-read "Group: " gnus-active-hashtb))
405 (setq subject (read-string "Subject: ")))))
406 (setq mail-reply-buffer gnus-article-copy)
408 (let ((gnus-newsgroup-name (or group gnus-newsgroup-name "")))
409 (setq real-group (and group (gnus-group-real-name group)))
410 (setq gnus-post-news-buffer
411 (gnus-request-post-buffer
412 post real-group subject header gnus-article-copy
413 (nth 2 (and group (gnus-gethash group gnus-newsrc-hashtb)))
414 (or (cdr (assq 'to-group
415 (nth 5 (nth 2 (gnus-gethash
417 gnus-newsrc-hashtb)))))
418 (if (and (boundp 'gnus-followup-to-function)
419 gnus-followup-to-function
423 (set-buffer gnus-article-copy)
424 (funcall gnus-followup-to-function group)))))
425 gnus-use-followup-to))
427 (gnus-configure-windows 'post)
429 (gnus-configure-windows 'followup-yank)
430 (gnus-configure-windows 'followup)))
431 (gnus-overload-functions)
432 (make-local-variable 'gnus-article-reply)
433 (make-local-variable 'gnus-article-check-size)
434 (setq gnus-article-reply sumart)
435 ;; Handle `gnus-auto-mail-to-author'.
436 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
437 (let ((to (if (eq gnus-auto-mail-to-author 'ask)
438 (and (y-or-n-p "Also send mail to author? ") from)
439 (and gnus-auto-mail-to-author from))))
442 (if (mail-fetch-field "To")
445 (insert "Cc: " to "\n"))
446 (mail-position-on-field "To")
448 ;; Handle author copy using BCC field.
449 (if (and gnus-mail-self-blind
450 (not (mail-fetch-field "bcc")))
452 (mail-position-on-field "Bcc")
453 (insert (if (stringp gnus-mail-self-blind)
455 (user-login-name)))))
456 ;; Handle author copy using FCC field.
459 (mail-position-on-field "Fcc")
460 (insert gnus-author-copy)))
461 (goto-char (point-min))
464 (re-search-forward "^Newsgroup:" nil t)
467 (re-search-forward "^Subject:" nil t)
471 (concat "^" (regexp-quote mail-header-separator) "$"))
474 (concat "^" (regexp-quote mail-header-separator) "$"))
479 (if (not (listp yank))
480 (news-reply-yank-original nil)
482 (save-window-excursion
483 (set-buffer gnus-summary-buffer)
484 (gnus-summary-select-article nil nil nil (car yank))
485 (gnus-summary-remove-process-mark (car yank)))
486 (let ((mail-reply-buffer gnus-article-copy))
487 (news-reply-yank-original nil))
488 (setq yank (cdr yank))))))
489 (if gnus-post-prepare-function
490 (funcall gnus-post-prepare-function group)))
491 (make-local-variable 'gnus-prev-winconf)
492 (setq gnus-prev-winconf winconf))))
493 (setq gnus-article-check-size (cons (buffer-size) (gnus-article-checksum)))
497 (defun gnus-inews-news (&optional use-group-method)
498 "Send a news message.
499 If given a prefix, and the group is a foreign group, this function
500 will attempt to use the foreign server to post the article."
502 (let* ((case-fold-search nil)
503 (server-running (gnus-server-opened gnus-select-method))
504 (reply gnus-article-reply))
506 ;; Connect to default NNTP server if necessary.
507 ;; Suggested by yuki@flab.fujitsu.junet.
508 (gnus-start-news-server) ;Use default server.
509 ;; NNTP server must be opened before current buffer is modified.
511 (goto-char (point-min))
512 (run-hooks 'news-inews-hook)
517 (goto-char (point-min))
519 (concat "^" (regexp-quote mail-header-separator) "$"))
520 (match-beginning 0)))
522 ;; Correct newsgroups field: change sequence of spaces to comma and
523 ;; eliminate spaces around commas. Eliminate imbedded line breaks.
524 (goto-char (point-min))
525 (if (search-forward-regexp "^Newsgroups: +" nil t)
529 (if (re-search-forward "^[^ \t]" nil 'end)
532 (goto-char (point-min))
533 (replace-regexp "\n[ \t]+" " ") ;No line breaks (too confusing)
534 (goto-char (point-min))
535 (replace-regexp "[ \t\n]*,[ \t\n]*\\|[ \t]+" ",")))
537 ;; Added by Per Abrahamsen <abraham@iesd.auc.dk>.
538 ;; Help save the the world!
541 (let ((newsgroups (mail-fetch-field "newsgroups"))
542 (followup-to (mail-fetch-field "followup-to"))
544 (if (and (string-match "," newsgroups) (not followup-to))
546 (while (string-match "," newsgroups)
548 (cons (list (substring newsgroups
549 0 (match-beginning 0)))
551 (setq newsgroups (substring newsgroups (match-end 0))))
552 (setq groups (nreverse (cons (list newsgroups) groups)))
555 (completing-read "Followups to: (default all groups) "
557 (if (> (length to) 0)
559 (goto-char (point-min))
560 (insert "Followup-To: " to "\n")))))))
562 ;; Cleanup Followup-To.
563 (goto-char (point-min))
564 (if (search-forward-regexp "^Followup-To: +" nil t)
568 (if (re-search-forward "^[^ \t]" nil 'end)
571 (goto-char (point-min))
572 (replace-regexp "\n[ \t]+" " ") ;No line breaks (too confusing)
573 (goto-char (point-min))
574 (replace-regexp "[ \t\n]*,[ \t\n]*\\|[ \t]+" ",")))
576 ;; Mail the message too if To:, Bcc:. or Cc: exists.
577 (let* ((types '("to" "bcc" "cc"))
581 (or (mail-fetch-field (car ty) nil t)
582 (setq types (delete (car ty) types)))
586 ;; We do not want to send mail.
588 (if (not gnus-mail-send-method)
592 1 "No mailer defined. To: and/or Cc: fields ignored.")
595 ;; We want to remove Fcc, because we want to handle
596 ;; that one ourselves...
598 (goto-char (point-min))
599 (if (re-search-forward "^Fcc: " nil t)
603 (progn (beginning-of-line) (point))
604 (progn (forward-line 1) (point))))
610 (gnus-message 5 "Sending via mail...")
612 (if (and gnus-mail-courtesy-message
613 (or (member "to" types)
614 (member "cc" types)))
615 ;; We only want to insert the courtesy mail
616 ;; message if we use to or cc; bcc should not
617 ;; have one. Well, if both bcc and to are
618 ;; present, it will get one anyway.
620 ;; Insert "courtesy" mail message.
621 (goto-char (point-min))
623 (concat "^" (regexp-quote
624 mail-header-separator) "$"))
626 (insert gnus-mail-courtesy-message)
627 (funcall gnus-mail-send-method)
628 (goto-char (point-min))
629 (search-forward gnus-mail-courtesy-message)
630 (replace-match "" t t))
631 (funcall gnus-mail-send-method))
633 (gnus-message 5 "Sending via mail... done")
635 (goto-char (point-min))
639 (concat "^" (regexp-quote mail-header-separator) "$")))
640 (goto-char (point-min))
641 (delete-matching-lines "^BCC:"))
644 (goto-char (point-max))
645 (insert fcc-line))))))))
647 ;; Send to NNTP server.
648 (gnus-message 5 "Posting to USENET...")
649 (if (gnus-inews-article use-group-method)
651 (gnus-message 5 "Posting to USENET... done")
652 (if (gnus-buffer-exists-p (car-safe reply))
655 (set-buffer gnus-summary-buffer)
656 (gnus-summary-mark-article-as-replied
658 ;; We cannot signal an error.
659 (ding) (gnus-message 1 "Article rejected: %s"
660 (gnus-status-message gnus-select-method)))
661 (set-buffer-modified-p nil))
662 ;; If NNTP server is opened by gnus-inews-news, close it by myself.
664 (gnus-close-server (gnus-find-method-for-group gnus-newsgroup-name)))
665 (let ((conf gnus-prev-winconf))
667 ;; Restore last window configuration.
668 (and conf (set-window-configuration conf)))))
670 (defun gnus-inews-check-post ()
671 "Check whether the post looks ok."
673 (not gnus-check-before-posting)
675 ;; We narrow to the headers and check them first.
678 (goto-char (point-min))
682 (concat "^" (regexp-quote mail-header-separator) "$")))
683 (goto-char (point-min))
685 ;; Check for commands in Subject.
686 (or (gnus-check-before-posting 'subject-cmsg)
688 (if (string-match "^cmsg " (mail-fetch-field "subject"))
690 "The control code \"cmsg \" is in the subject. Really post? ")
692 ;; Check for multiple identical headers.
693 (or (gnus-check-before-posting 'multiple-headers)
696 (while (and (not found) (re-search-forward "^[^ \t:]+: " nil t))
698 (or (re-search-forward
699 (concat "^" (setq found
702 (- (match-end 0) 2))))
707 (format "Multiple %s headers. Really post? " found))
709 ;; Check for version and sendsys.
710 (or (gnus-check-before-posting 'sendsys)
712 (if (re-search-forward "^Sendsys:\\|^Version:" nil t)
714 (format "The article contains a %s command. Really post? "
715 (buffer-substring (match-beginning 0)
716 (1- (match-end 0)))))
718 ;; Check the Message-Id header.
719 (or (gnus-check-before-posting 'message-id)
721 (let* ((case-fold-search t)
722 (message-id (mail-fetch-field "message-id")))
724 (and (string-match "@" message-id)
725 (string-match "@[^\\.]*\\." message-id))
728 "The Message-ID looks strange: \"%s\". Really post? "
730 ;; Check the From header.
731 (or (gnus-check-before-posting 'from)
733 (let* ((case-fold-search t)
734 (from (mail-fetch-field "from")))
736 (and (string-match "@" from)
737 (string-match "@[^\\.]*\\." from))
739 (format "The From looks strange: \"%s\". Really post? "
741 ;; Check for long lines.
742 (or (gnus-check-before-posting 'long-lines)
744 (goto-char (point-min))
746 (concat "^" (regexp-quote mail-header-separator) "$"))
750 (< (current-column) 80))
751 (zerop (forward-line 1))))
756 "You have lines longer than 79 characters. Really post? ")))))
757 ;; Check for control characters.
758 (or (gnus-check-before-posting 'control-chars)
760 (if (re-search-forward "[\000-\007\013\015-\037\200-\237]" nil t)
762 "The article contains control characters. Really post? ")
764 ;; Check excessive size.
765 (or (gnus-check-before-posting 'size)
766 (if (> (buffer-size) 60000)
768 (format "The article is %d octets long. Really post? "
771 ;; Use the (size . checksum) variable to see whether the
772 ;; article is empty or has only quoted text.
773 (or (gnus-check-before-posting 'new-text)
774 (if (and (= (buffer-size) (car gnus-article-check-size))
775 (= (gnus-article-checksum) (cdr gnus-article-check-size)))
777 "It looks like there's no new text in your article. Really post? ")
779 ;; Check the length of the signature.
780 (or (gnus-check-before-posting 'signature)
782 (goto-char (point-max))
783 (if (not (re-search-backward gnus-signature-separator nil t))
785 (if (> (count-lines (point) (point-max)) 4)
788 "Your .sig is %d lines; it should be max 4. Really post? "))
791 (defun gnus-article-checksum ()
795 (setq sum (logxor sum (following-char)))
799 ;; Returns non-nil if this type is not to be checked.
800 (defun gnus-check-before-posting (type)
801 (or (not gnus-check-before-posting)
802 (if (listp gnus-check-before-posting)
803 (memq type gnus-check-before-posting)
806 (defun gnus-cancel-news ()
807 "Cancel an article you posted."
809 (if (or gnus-expert-user
810 (gnus-yes-or-no-p "Do you really want to cancel this article? "))
815 (or (gnus-member-of-valid 'post gnus-newsgroup-name)
816 (error "This backend does not support cancelling"))
818 ;; Get header info. from original article.
820 (gnus-article-show-all-headers)
821 (goto-char (point-min))
822 (search-forward "\n\n" nil 'move)
823 (narrow-to-region (point-min) (point))
824 (setq from (mail-fetch-field "from"))
825 (setq newsgroups (mail-fetch-field "newsgroups"))
826 (setq message-id (mail-fetch-field "message-id"))
827 (setq distribution (mail-fetch-field "distribution")))
828 ;; Verify if the article is absolutely user's by comparing
829 ;; user id with value of its From: field.
832 (downcase (mail-strip-quoted-names from))
833 (downcase (mail-strip-quoted-names (gnus-inews-user-name)))))
835 (ding) (gnus-message 3 "This article is not yours."))
836 ;; Make control article.
837 (set-buffer (get-buffer-create " *Gnus-canceling*"))
838 (buffer-disable-undo (current-buffer))
840 (insert "Newsgroups: " newsgroups "\n"
841 "Subject: cancel " message-id "\n"
842 "Control: cancel " message-id "\n"
843 mail-header-separator "\n"
844 "This is a cancel message from " from ".\n")
845 ;; Send the control article to NNTP server.
846 (gnus-message 5 "Canceling your article...")
847 (if (gnus-inews-article)
848 (gnus-message 5 "Canceling your article... done")
850 (gnus-message 1 "Cancel failed; %s"
851 (gnus-status-message gnus-newsgroup-name)))
852 ;; Kill the article buffer.
853 (kill-buffer (current-buffer)))))))
856 ;;; Lowlevel inews interface
858 (defun gnus-inews-article (&optional use-group-method)
859 "Post an article in current buffer using NNTP protocol."
860 ;; Check whether the article is a good Net Citizen.
861 (if (and gnus-article-check-size (not (gnus-inews-check-post)))
864 ;; Looks ok, so we do the nasty.
865 (let ((artbuf (current-buffer))
866 (tmpbuf (get-buffer-create " *Gnus-posting*")))
868 (goto-char (point-max))
869 ;; require a newline at the end for inews to append .signature to
870 (or (= (preceding-char) ?\n)
872 ;; Prepare article headers. All message body such as signature
873 ;; must be inserted before Lines: field is prepared.
875 (goto-char (point-min))
880 (concat "^" (regexp-quote mail-header-separator) "$"))
881 (match-beginning 0)))
882 (gnus-inews-remove-headers)
883 (gnus-inews-insert-headers)
884 (run-hooks gnus-inews-article-header-hook)
888 (buffer-disable-undo (current-buffer))
890 (insert-buffer-substring artbuf)
891 ;; Remove the header separator.
892 (goto-char (point-min))
894 (concat "^" (regexp-quote mail-header-separator) "$"))
895 (replace-match "" t t)
896 ;; This hook may insert a signature.
897 (run-hooks 'gnus-prepare-article-hook)
898 ;; Run final inews hooks. This hook may do FCC.
899 ;; The article must be saved before being posted because
900 ;; `gnus-request-post' modifies the buffer.
901 (run-hooks 'gnus-inews-article-hook)
902 ;; Post an article to NNTP server.
903 ;; Return NIL if post failed.
907 (gnus-find-method-for-group gnus-newsgroup-name)
908 gnus-select-method) use-group-method)
909 (kill-buffer (current-buffer)))))))
911 (defun gnus-inews-remove-headers ()
912 (let ((case-fold-search t))
913 ;; Remove NNTP-posting-host.
914 (goto-char (point-min))
915 (and (re-search-forward "^nntp-posting-host:" nil t)
916 (delete-region (progn (beginning-of-line) (point))
917 (progn (forward-line 1) (point))))
919 (goto-char (point-min))
920 (and (re-search-forward "^bcc:" nil t)
921 (delete-region (progn (beginning-of-line) (point))
922 (progn (forward-line 1) (point))))))
924 (defun gnus-inews-insert-headers ()
925 "Prepare article headers.
926 Headers already prepared in the buffer are not modified.
927 Headers in `gnus-required-headers' will be generated."
928 (let ((Date (gnus-inews-date))
929 (Message-ID (gnus-inews-message-id))
930 (Organization (gnus-inews-organization))
931 (From (gnus-inews-user-name))
932 (Path (gnus-inews-path))
936 (Lines (gnus-inews-lines))
937 (X-Newsreader gnus-version)
938 (headers gnus-required-headers)
941 ;; First we remove any old Message-IDs. This might be slightly
942 ;; fascist, but if the user really wants to generate Message-IDs
943 ;; by herself, she should remove it from the `gnus-required-list'.
944 (goto-char (point-min))
945 (and (memq 'Message-ID headers)
946 (re-search-forward "^Message-ID:" nil t)
947 (delete-region (progn (beginning-of-line) (point))
948 (progn (forward-line 1) (point))))
949 ;; Insert new Sender if the From is strange.
950 (let ((from (mail-fetch-field "from")))
951 (if (and from (not (string= (downcase from) (downcase From))))
953 (goto-char (point-min))
954 (and (re-search-forward "^Sender:" nil t)
955 (delete-region (progn (beginning-of-line) (point))
956 (progn (forward-line 1) (point))))
957 (insert "Sender: " From "\n"))))
958 ;; If there are References, and no "Re: ", then the thread has
959 ;; changed name. See Son-of-1036.
960 (if (and (mail-fetch-field "references")
961 (get-buffer gnus-article-buffer))
962 (let ((psubject (gnus-simplify-subject-re
963 (mail-fetch-field "subject")))
966 (set-buffer gnus-article-buffer)
968 (gnus-narrow-to-headers)
969 (if (setq subject (mail-fetch-field "subject"))
971 (and gnus-summary-gather-subject-limit
972 (numberp gnus-summary-gather-subject-limit)
973 (> (length subject) gnus-summary-gather-subject-limit)
976 gnus-summary-gather-subject-limit)))
977 (setq subject (gnus-simplify-subject-re subject))))))
978 (or (and psubject subject (string= subject psubject))
980 (string-match "@" Message-ID)
982 (concat (substring Message-ID 0 (match-beginning 0))
984 (substring Message-ID (match-beginning 0))))))))
985 ;; Go through all the required headers and see if they are in the
986 ;; articles already. If they are not, or are empty, they are
987 ;; inserted automatically - except for Subject, Newsgroups and
990 (goto-char (point-min))
991 (setq elem (car headers))
993 (setq header (car elem))
995 (if (or (not (re-search-forward
996 (concat "^" (downcase (symbol-name header)) ":") nil t))
998 (if (= (following-char) ? ) (forward-char 1) (insert " "))
999 (looking-at "[ \t]*$")))
1002 (or (if (consp elem)
1003 ;; The element is a cons. Either the cdr is
1004 ;; a string to be inserted verbatim, or it
1005 ;; is a function, and we insert the value
1006 ;; returned from this function.
1007 (or (and (stringp (cdr elem)) (cdr elem))
1008 (and (fboundp (cdr elem)) (funcall (cdr elem))))
1009 ;; The element is a symbol. We insert the
1010 ;; value of this symbol, if any.
1011 (and (boundp header) (symbol-value header)))
1012 ;; We couldn't generate a value for this header,
1013 ;; so we just ask the user.
1014 (read-from-minibuffer
1015 (format "Empty header for %s; enter value: " header))))
1018 (goto-char (point-max))
1019 (insert (symbol-name header) ": " value "\n"))
1020 (replace-match value t t))))
1021 (setq headers (cdr headers)))))
1023 (defun gnus-inews-insert-signature ()
1024 "Insert a signature file.
1025 If `gnus-signature-function' is bound and returns a string, this
1026 string is used instead of the variable `gnus-signature-file'.
1027 In either case, if the string is a file name, this file is
1028 inserted. If the string is not a file name, the string itself is
1030 If you never want any signature inserted, set both those variables to
1034 (or (and gnus-signature-function
1035 (fboundp gnus-signature-function)
1036 (funcall gnus-signature-function gnus-newsgroup-name))
1037 gnus-signature-file))
1040 (or (file-exists-p signature)
1041 (string-match " " signature)
1043 "^/[^/]+/" (expand-file-name signature)))))
1045 (goto-char (point-max))
1046 ;; Delete any previous signatures.
1047 (if (and mail-signature (search-backward "\n-- \n" nil t))
1048 (delete-region (1+ (point)) (point-max)))
1050 (if (file-exists-p signature)
1051 (insert-file-contents signature)
1053 (goto-char (point-max))
1054 (or (bolp) (insert "\n")))))))
1056 (defun gnus-inews-do-fcc ()
1057 "Process FCC: fields in current article buffer.
1058 Unless the first character of the field is `|', the article is saved
1059 to the specified file using the function specified by the variable
1060 gnus-author-copy-saver. The default function rmail-output saves in
1061 Unix mailbox format.
1062 If the first character is `|', the contents of the article is send to
1063 a program specified by the rest of the value."
1064 (let ((fcc-list nil)
1066 (case-fold-search t)) ;Should ignore case.
1069 (goto-char (point-min))
1070 (search-forward "\n\n")
1071 (narrow-to-region (point-min) (point))
1072 (goto-char (point-min))
1073 (while (re-search-forward "^FCC:[ \t]*" nil t)
1075 (cons (buffer-substring
1079 (skip-chars-backward " \t")
1082 (delete-region (match-beginning 0)
1083 (progn (forward-line 1) (point))))
1084 ;; Process FCC operations.
1087 (setq fcc-file (car fcc-list))
1088 (setq fcc-list (cdr fcc-list))
1089 (cond ((string-match "^[ \t]*|[ \t]*\\(.*\\)[ \t]*$" fcc-file)
1090 (let ((program (substring fcc-file
1091 (match-beginning 1) (match-end 1))))
1092 ;; Suggested by yuki@flab.fujitsu.junet.
1093 ;; Send article to named program.
1094 (call-process-region (point-min) (point-max) shell-file-name
1095 nil nil nil "-c" program)))
1097 ;; Suggested by hyoko@flab.fujitsu.junet.
1098 ;; Save article in Unix mail format by default.
1099 (gnus-make-directory (file-name-directory fcc-file))
1100 (if (and gnus-author-copy-saver
1101 (not (eq gnus-author-copy-saver 'rmail-output)))
1102 (funcall gnus-author-copy-saver fcc-file)
1103 (if (and (file-readable-p fcc-file) (rmail-file-p fcc-file))
1104 (gnus-output-to-rmail fcc-file)
1105 (rmail-output fcc-file 1 t t))))))))))
1107 (defun gnus-inews-path ()
1109 (let ((login-name (gnus-inews-login-name)))
1110 (cond ((null gnus-use-generic-path)
1111 (concat (nth 1 gnus-select-method) "!" login-name))
1112 ((stringp gnus-use-generic-path)
1113 ;; Support GENERICPATH. Suggested by vixie@decwrl.dec.com.
1114 (concat gnus-use-generic-path "!" login-name))
1117 (defun gnus-inews-user-name ()
1118 "Return user's network address as \"NAME@DOMAIN (FULL-NAME)\"."
1119 (let ((full-name (gnus-inews-full-name)))
1120 (or gnus-user-from-line
1121 (concat (if (or gnus-user-login-name gnus-use-generic-from
1122 gnus-local-domain (getenv "DOMAINNAME"))
1123 (concat (gnus-inews-login-name) "@"
1124 (gnus-inews-domain-name gnus-use-generic-from))
1126 ;; User's full name.
1127 (cond ((string-equal full-name "") "")
1128 ((string-equal full-name "&") ;Unix hack.
1129 (concat " (" (user-login-name) ")"))
1131 (concat " (" full-name ")")))))))
1133 (defun gnus-inews-login-name ()
1134 "Return login name."
1135 (or gnus-user-login-name (getenv "LOGNAME") (user-login-name)))
1137 (defun gnus-inews-full-name ()
1138 "Return full user name."
1139 (or gnus-user-full-name (getenv "NAME") (user-full-name)))
1141 (defun gnus-inews-domain-name (&optional genericfrom)
1142 "Return user's domain name.
1143 If optional argument GENERICFROM is a string, use it as the domain
1144 name; if it is non-nil, strip off local host name from the domain name.
1145 If the function `system-name' returns full internet name and the
1146 domain is undefined, the domain name is got from it."
1147 (if (or genericfrom gnus-local-domain (getenv "DOMAINNAME"))
1148 (let* ((system-name (system-name))
1150 (or (if (stringp genericfrom) genericfrom)
1151 (getenv "DOMAINNAME")
1153 ;; Function `system-name' may return full internet name.
1154 ;; Suggested by Mike DeCorte <mrd@sun.soe.clarkson.edu>.
1155 (if (string-match "\\." system-name)
1156 (substring system-name (match-end 0)))
1157 (read-string "Domain name (no host): ")))
1158 (host (or (if (string-match "\\." system-name)
1159 (substring system-name 0 (match-beginning 0)))
1161 (if (string-equal "." (substring domain 0 1))
1162 (setq domain (substring domain 1)))
1163 ;; Support GENERICFROM as same as standard Bnews system.
1164 ;; Suggested by ohm@kaba.junet and vixie@decwrl.dec.com.
1165 (cond ((null genericfrom)
1166 (concat host "." domain))
1167 ;;((stringp genericfrom) genericfrom)
1169 (if (string-match "\\." (system-name))
1171 (substring user-mail-address
1172 (1+ (string-match "@" user-mail-address))))))
1174 (defun gnus-inews-full-address ()
1175 (let ((domain (gnus-inews-domain-name))
1176 (system (system-name))
1177 (case-fold-search t))
1178 (if (string-match "\\." system) system
1179 (if (string-match (concat "^" (regexp-quote system)) domain) domain
1180 (concat system "." domain)))))
1182 (defun gnus-inews-message-id ()
1183 "Generate unique Message-ID for user."
1184 ;; Message-ID should not contain a slash and should be terminated by
1185 ;; a number. I don't know the reason why it is so.
1186 (concat "<" (gnus-inews-unique-id) "@" (gnus-inews-full-address) ">"))
1188 (defvar gnus-unique-id-char nil)
1190 ;; If you ever change this function, make sure the new version
1191 ;; cannot generate IDs that the old version could.
1192 ;; You might for example insert a "." somewhere (not next to another dot
1193 ;; or string boundary), or modify the newsreader name to "Ding".
1194 (defun gnus-inews-unique-id ()
1195 ;; Dont use microseconds from (current-time), they may be unsupported.
1196 ;; Instead we use this randomly inited counter.
1197 (setq gnus-unique-id-char
1198 (% (1+ (or gnus-unique-id-char (logand (random t) (1- (lsh 1 20)))))
1199 ;; (current-time) returns 16-bit ints,
1200 ;; and 2^16*25 just fits into 4 digits i base 36.
1202 (let ((tm (if (fboundp 'current-time)
1203 (current-time) '(12191 46742 287898))))
1205 (if (memq system-type '(ms-dos emx vax-vms))
1206 (let ((user (downcase (gnus-inews-login-name))))
1207 (while (string-match "[^a-z0-9_]" user)
1208 (aset user (match-beginning 0) ?_))
1210 (gnus-number-base36 (user-uid) -1))
1211 (gnus-number-base36 (+ (car tm) (lsh (% gnus-unique-id-char 25) 16)) 4)
1212 (gnus-number-base36 (+ (nth 1 tm) (lsh (/ gnus-unique-id-char 25) 16)) 4)
1213 ;; Append the newsreader name, because while the generated
1214 ;; ID is unique to this newsreader, other newsreaders might
1215 ;; otherwise generate the same ID via another algorithm.
1219 (defun gnus-inews-date ()
1220 "Current time string."
1221 (timezone-make-date-arpa-standard
1222 (current-time-string) (current-time-zone)))
1224 (defun gnus-inews-organization ()
1225 "Return user's organization.
1226 The ORGANIZATION environment variable is used if defined.
1227 If not, the variable `gnus-local-organization' is used instead.
1228 If it is a function, the function will be called with the current
1229 newsgroup name as the argument.
1230 If this is a file name, the contents of this file will be used as the
1232 (let* ((organization
1233 (or (getenv "ORGANIZATION")
1234 (if gnus-local-organization
1235 (if (and (symbolp gnus-local-organization)
1236 (fboundp gnus-local-organization))
1237 (funcall gnus-local-organization gnus-newsgroup-name)
1238 gnus-local-organization))
1239 gnus-organization-file
1240 "~/.organization")))
1241 (and (stringp organization)
1242 (> (length organization) 0)
1244 (gnus-set-work-buffer)
1245 (if (file-exists-p organization)
1246 (insert-file-contents organization)
1247 (insert organization))
1248 (goto-char (point-min))
1249 (while (re-search-forward " *\n *" nil t)
1250 (replace-match " " t t))
1251 (buffer-substring (point-min) (point-max))))))
1253 (defun gnus-inews-lines ()
1254 "Count the number of lines and return numeric string."
1258 (goto-char (point-min))
1260 (concat "^" (regexp-quote mail-header-separator) "$"))
1262 (int-to-string (count-lines (point) (point-max))))))
1266 ;;; Gnus Mail Functions
1269 ;;; Mail reply commands of Gnus summary mode
1271 (defun gnus-summary-reply (yank &optional yank-articles)
1272 "Reply mail to news author.
1273 If prefix argument YANK is non-nil, original article is yanked automatically.
1274 Customize the variable gnus-mail-reply-method to use another mailer."
1276 ;; Bug fix by jbw@bigbird.bu.edu (Joe Wells)
1277 ;; Stripping headers should be specified with mail-yank-ignored-headers.
1278 (gnus-set-global-variables)
1279 (if yank-articles (gnus-summary-goto-subject (car yank-articles)))
1280 (gnus-summary-select-article t)
1281 (let ((gnus-newsgroup-name gnus-newsgroup-name))
1282 (bury-buffer gnus-article-buffer)
1283 (funcall gnus-mail-reply-method (or yank-articles (not (not yank)))))
1284 (gnus-article-hide-headers-if-wanted))
1286 (defun gnus-summary-reply-with-original (n)
1287 "Reply mail to news author with original article.
1288 Customize the variable gnus-mail-reply-method to use another mailer."
1290 (gnus-summary-reply t (gnus-summary-work-articles n)))
1292 (defun gnus-summary-mail-forward (post)
1293 "Forward the current message to another user.
1294 Customize the variable gnus-mail-forward-method to use another mailer."
1296 (gnus-set-global-variables)
1297 (gnus-summary-select-article t)
1298 (gnus-copy-article-buffer)
1299 (let ((gnus-newsgroup-name gnus-newsgroup-name))
1301 (gnus-forward-using-post gnus-article-copy)
1302 (funcall gnus-mail-forward-method gnus-article-copy)))
1303 (gnus-article-hide-headers-if-wanted))
1305 (defun gnus-summary-post-forward ()
1306 "Forward the current article to a newsgroup."
1308 (gnus-summary-mail-forward t))
1310 (defun gnus-summary-mail-other-window ()
1311 "Compose mail in other window.
1312 Customize the variable `gnus-mail-other-window-method' to use another
1315 (gnus-set-global-variables)
1316 (let ((gnus-newsgroup-name gnus-newsgroup-name))
1317 (funcall gnus-mail-other-window-method)))
1319 (defun gnus-mail-reply-using-mail (&optional yank to-address)
1321 (set-buffer gnus-summary-buffer)
1322 (let ((info (nth 2 (gnus-gethash gnus-newsgroup-name gnus-newsrc-hashtb)))
1323 (group (gnus-group-real-name gnus-newsgroup-name))
1324 (cur (cons (current-buffer) (cdr gnus-article-current)))
1325 (winconf (current-window-configuration))
1326 from subject date to reply-to message-of
1327 references message-id sender follow-to cc sendto elt)
1328 (set-buffer (get-buffer-create "*mail*"))
1330 (make-local-variable 'gnus-article-reply)
1331 (setq gnus-article-reply cur)
1332 (make-local-variable 'gnus-prev-winconf)
1333 (setq gnus-prev-winconf winconf)
1334 (use-local-map (copy-keymap mail-mode-map))
1335 (local-set-key "\C-c\C-c" 'gnus-mail-send-and-exit)
1336 (if (and (buffer-modified-p)
1339 "Unsent article being composed; erase it? ")))
1343 (gnus-copy-article-buffer)
1345 (set-buffer gnus-article-copy)
1346 (gnus-narrow-to-headers)
1347 (if (and (boundp 'gnus-reply-to-function)
1348 gnus-reply-to-function)
1349 (setq follow-to (funcall gnus-reply-to-function group)))
1350 (setq from (mail-fetch-field "from"))
1351 (setq date (or (mail-fetch-field "date")
1352 (header-date gnus-current-headers)))
1355 (string-match " *at \\| *@ \\| *(\\| *<" from)))
1357 (concat (if stop-pos (substring from 0 stop-pos) from)
1358 "'s message of " date))))
1359 (setq sender (mail-fetch-field "sender"))
1360 (setq subject (or (mail-fetch-field "subject")
1362 (or (string-match "^[Rr][Ee]:" subject)
1363 (setq subject (concat "Re: " subject)))
1364 (setq cc (mail-fetch-field "cc"))
1365 (setq reply-to (mail-fetch-field "reply-to"))
1366 (setq references (mail-fetch-field "references"))
1367 (setq message-id (mail-fetch-field "message-id")))
1368 (setq news-reply-yank-from (or from "(nobody)")))
1369 (setq news-reply-yank-message-id
1370 (or message-id "(unknown Message-ID)"))
1372 ;; Gather the "to" addresses out of the follow-to list and remove
1374 (if (and follow-to (listp follow-to))
1375 (while (setq elt (assoc "To" follow-to))
1376 (setq sendto (concat sendto (and sendto ", ") (cdr elt)))
1377 (setq follow-to (delq elt follow-to))))
1379 (mail-setup (or to-address
1380 (if (and follow-to (not (stringp follow-to))) sendto
1381 (or follow-to reply-to from sender "")))
1382 subject message-of nil gnus-article-copy nil)
1384 (if (and follow-to (listp follow-to))
1386 (goto-char (point-min))
1387 (re-search-forward "^To:" nil t)
1391 (insert (car (car follow-to)) ": " (cdr (car follow-to)) "\n")
1392 (setq follow-to (cdr follow-to)))))
1393 ;; Fold long references line to follow RFC1036.
1394 (mail-position-on-field "References")
1395 (let ((begin (- (point) (length "References: ")))
1398 (if references (insert references))
1399 (if (and references message-id) (insert " "))
1400 (if message-id (insert message-id))
1401 ;; The region must end with a newline to fill the region
1402 ;; without inserting extra newline.
1403 (fill-region-as-paragraph begin (1+ (point))))
1404 (goto-char (point-min))
1406 (concat "^" (regexp-quote mail-header-separator) "$"))
1409 (gnus-configure-windows 'reply)
1410 (let ((last (point))
1412 (if (not (listp yank))
1415 (mail-yank-original nil))
1416 (run-hooks 'news-reply-header-hook))
1418 (save-window-excursion
1419 (set-buffer gnus-summary-buffer)
1420 (gnus-summary-select-article nil nil nil (car yank))
1421 (gnus-summary-remove-process-mark (car yank)))
1423 (gnus-copy-article-buffer)
1424 (mail-yank-original nil)
1426 (run-hooks 'news-reply-header-hook)
1428 (setq yank (cdr yank))))
1430 (gnus-configure-windows 'reply-yank))
1431 (run-hooks 'gnus-mail-hook)))))
1433 (defun gnus-mail-yank-original ()
1436 (mail-yank-original nil))
1437 (run-hooks 'news-reply-header-hook))
1439 (defun gnus-mail-send-and-exit ()
1441 (let ((reply gnus-article-reply)
1442 (winconf gnus-prev-winconf))
1443 (mail-send-and-exit nil)
1444 (if (get-buffer gnus-group-buffer)
1446 (if (gnus-buffer-exists-p (car-safe reply))
1448 (set-buffer (car reply))
1450 (gnus-summary-mark-article-as-replied
1452 (and winconf (set-window-configuration winconf))))))
1454 (defun gnus-forward-make-subject (buffer)
1457 (concat "[" (if (memq 'mail (assoc (symbol-name
1458 (car (gnus-find-method-for-group
1459 gnus-newsgroup-name)))
1460 gnus-valid-select-methods))
1461 (gnus-fetch-field "From")
1462 gnus-newsgroup-name)
1463 "] " (or (gnus-fetch-field "Subject") ""))))
1465 (defun gnus-forward-insert-buffer (buffer)
1466 (let ((beg (goto-char (point-max))))
1467 (insert "------- Start of forwarded message -------\n")
1468 (insert-buffer buffer)
1469 (goto-char (point-max))
1470 (insert "------- End of forwarded message -------\n")
1471 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
1473 (while (setq beg (next-single-property-change (point) 'invisible))
1475 (delete-region beg (or (next-single-property-change
1479 (defun gnus-mail-forward-using-mail (&optional buffer)
1480 "Forward the current message to another user using mail."
1481 ;; This is almost a carbon copy of rmail-forward in rmail.el.
1482 (let* ((forward-buffer (or buffer (current-buffer)))
1483 (winconf (current-window-configuration))
1484 (subject (gnus-forward-make-subject forward-buffer)))
1485 (set-buffer forward-buffer)
1486 (mail nil nil subject)
1487 (use-local-map (copy-keymap (current-local-map)))
1488 (local-set-key "\C-c\C-c" 'gnus-mail-send-and-exit)
1489 (make-local-variable 'gnus-prev-winconf)
1490 (setq gnus-prev-winconf winconf)
1491 (gnus-forward-insert-buffer forward-buffer)
1492 (goto-char (point-min))
1493 (re-search-forward "^To: " nil t)
1494 (gnus-configure-windows 'mail-forward)
1495 ;; You have a chance to arrange the message.
1496 (run-hooks 'gnus-mail-forward-hook)
1497 (run-hooks 'gnus-mail-hook)))
1499 (defun gnus-forward-using-post (&optional buffer)
1500 (let* ((forward-buffer (or buffer (current-buffer)))
1501 (subject (gnus-forward-make-subject forward-buffer)))
1502 (gnus-post-news 'post nil nil nil nil subject)
1504 (gnus-forward-insert-buffer forward-buffer)
1505 ;; You have a chance to arrange the message.
1506 (run-hooks 'gnus-mail-forward-hook))))
1508 (defun gnus-mail-other-window-using-mail ()
1509 "Compose mail other window using mail."
1510 (let ((winconf (current-window-configuration)))
1511 (mail-other-window nil nil nil nil nil (get-buffer gnus-article-buffer))
1512 (use-local-map (copy-keymap (current-local-map)))
1513 (local-set-key "\C-c\C-c" 'gnus-mail-send-and-exit)
1514 (make-local-variable 'gnus-prev-winconf)
1515 (setq gnus-prev-winconf winconf)
1516 (run-hooks 'gnus-mail-hook)))
1518 (defun gnus-article-mail (yank)
1519 "Send a reply to the address near point.
1520 If YANK is non-nil, include the original article."
1524 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
1525 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
1528 (switch-to-buffer gnus-summary-buffer)
1529 (funcall gnus-mail-reply-method yank address)))))
1531 (defun gnus-article-mail-with-original ()
1532 "Send a reply to the address near point and include the original article."
1534 (gnus-article-mail 'yank))
1538 ;;; gnus-msg.el ends here