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-post-prepare-hook nil
42 "*Hook that is run after a post buffer has been prepared.
43 If you want to insert the signature, you might put
44 `gnus-inews-insert-signature' in this hook.")
46 (defvar gnus-use-followup-to 'use
47 "*Specifies what to do with Followup-To header.
48 If nil, ignore the header. If it is t, use its value, but ignore
49 `poster'. If it is neither nil nor t, which is the default, always use
52 (defvar gnus-followup-to-function nil
53 "*A variable that contains a function that returns a followup address.
54 The function will be called in the buffer of the article that is being
55 followed up. The buffer will be narrowed to the headers of the
56 article. To pick header headers, one might use `mail-fetch-field'. The
57 function will be called with the name of the current newsgroup as the
60 Here's an example `gnus-followup-to-function':
62 (setq gnus-followup-to-function
64 (cond ((string= group \"mail.list\")
65 (or (mail-fetch-field \"sender\")
66 (mail-fetch-field \"from\")))
68 (or (mail-fetch-field \"reply-to\")
69 (mail-fetch-field \"from\"))))))")
71 (defvar gnus-reply-to-function nil
72 "*A variable that contains a function that returns a reply address.
73 See the `gnus-followup-to-function' variable for an explanation of how
74 this variable is used.
76 This function should return a string that will be used to fill in the
77 header. This function may also return a list. In that case, every
78 list element should be a cons where the first car should be a string
79 with the header name, and the cdr should be a string with the header
82 (defvar gnus-author-copy (getenv "AUTHORCOPY")
83 "*Save outgoing articles in this file.
84 Initialized from the AUTHORCOPY environment variable.
86 If this variable begins with the character \"|\", outgoing articles
87 will be piped to the named program. It is possible to save an article
88 in an MH folder as follows:
90 \(setq gnus-author-copy \"|/usr/local/lib/mh/rcvstore +Article\")
92 If the first character is not a pipe, articles are saved using the
93 function specified by the `gnus-author-copy-saver' variable.")
95 (defvar gnus-mail-self-blind nil
96 "*Non-nil means insert a BCC header in all outgoing articles.
97 This will result in having a copy of the article mailed to yourself.
98 The BCC header is inserted when the post buffer is initialized, so you
99 can remove or alter the BCC header to override the default.")
101 (defvar gnus-author-copy-saver (function rmail-output)
102 "*A function called to save outgoing articles.
103 This function will be called with the same of the file to store the
104 article in. The default function is `rmail-output' which saves in Unix
107 (defvar gnus-user-login-name nil
108 "*The login name of the user.
109 Got from the function `user-login-name' if undefined.")
111 (defvar gnus-user-full-name nil
112 "*The full name of the user.
113 Got from the NAME environment variable if undefined.")
115 (defvar gnus-user-from-line nil
116 "*Your full, complete e-mail address.
117 Overrides the other Gnus variables if it is non-nil.
119 Here are two example values of this variable:
121 \"Lars Magne Ingebrigtsen <larsi@ifi.uio.no>\"
125 \"larsi@ifi.uio.no (Lars Magne Ingebrigtsen)\"
127 The first version is recommended, but the name has to be quoted if it
128 contains non-alphanumerical characters.")
130 (defvar gnus-signature-file "~/.signature"
131 "*Your signature file.
132 If the variable is a string that doesn't correspond to a file, the
133 string itself is inserted.")
135 (defvar gnus-signature-function nil
136 "*A function that should return a signature file name.
137 The function will be called with the name of the newsgroup being
139 If the function returns a string that doesn't correspond to a file, the
140 string itself is inserted.
141 If the function returns nil, the `gnus-signature-file' variable will
144 (defvar gnus-required-headers
145 '(From Date Newsgroups Subject Message-ID Organization Lines X-Newsreader)
146 "*Headers to be generated or prompted for when posting an article.
147 RFC977 and RFC1036 require From, Date, Newsgroups, Subject,
148 Message-ID. Organization, Lines and X-Newsreader are optional. If
149 you want Gnus not to insert some header, remove it from this list.")
151 (defvar gnus-check-before-posting
152 '(subject-cmsg multiple-headers sendsys message-id from
153 long-lines control-chars size new-text
155 "In non-nil, Gnus will attempt to run some checks on outgoing posts.
156 If this variable is t, Gnus will check everything it can. If it is a
157 list, then those elements in that list will be checked.")
159 (defvar gnus-auto-mail-to-author nil
160 "*If non-nil, mail the authors of articles a copy of your follow-ups.
161 If this variable is `ask', the user will be prompted for whether to
162 mail a copy. The string given by `gnus-mail-courtesy-message' will be
163 inserted at the beginning of the mail copy.
165 Mail is sent using the function specified by the
166 `gnus-mail-send-method' variable.")
168 ;; Added by Ethan Bradford <ethanb@ptolemy.astro.washington.edu>.
169 (defvar gnus-mail-courtesy-message
170 "The following message is a courtesy copy of an article\nthat has been posted as well.\n\n"
171 "*This is inserted at the start of a mailed copy of a posted message.
172 If this variable is nil, no such courtesy message will be added.")
174 (defvar gnus-mail-reply-method (function gnus-mail-reply-using-mail)
175 "*Function to compose a reply.
176 Three pre-made functions are `gnus-mail-reply-using-mail' (sendmail);
177 `gnus-mail-reply-using-mhe' (MH-E); and `gnus-mail-reply-using-vm'.")
179 (defvar gnus-mail-forward-method (function gnus-mail-forward-using-mail)
180 "*Function to forward the current message to another user.
181 Three pre-made functions are `gnus-mail-forward-using-mail' (sendmail);
182 `gnus-mail-forward-using-mhe' (MH-E); and `gnus-mail-forward-using-vm'.")
184 (defvar gnus-mail-other-window-method 'gnus-mail-other-window-using-mail
185 "*Function to compose mail in the other window.
186 Three pre-made functions are `gnus-mail-other-window-using-mail'
187 (sendmail); `gnus-mail-other-window-using-mhe' (MH-E); and
188 `gnus-mail-other-window-using-vm'.")
190 (defvar gnus-mail-send-method send-mail-function
191 "*Function to mail a message which is also being posted as an article.
192 The message must have To or Cc header. The default is copied from
193 the variable `send-mail-function'.")
195 (defvar gnus-inews-article-hook (list 'gnus-inews-do-fcc)
196 "*A hook called before finally posting an article.
197 The default hook (`gnus-inews-do-fcc') does FCC processing (ie. saves
198 the article to a file).")
200 (defvar gnus-inews-article-header-hook nil
201 "*A hook called after inserting the headers in an article to be posted.
202 The hook is called from the *post-news* buffer, narrowed to the
205 (defvar gnus-mail-hook nil
206 "*A hook called as the last thing after setting up a mail buffer.")
208 ;;; Internal variables.
210 (defvar gnus-post-news-buffer "*post-news*")
211 (defvar gnus-summary-send-map nil)
212 (defvar gnus-article-copy nil)
213 (defvar gnus-reply-subject nil)
217 ;;; Gnus Posting Functions
220 (define-prefix-command 'gnus-summary-send-map)
221 (define-key gnus-summary-mode-map "S" 'gnus-summary-send-map)
222 (define-key gnus-summary-send-map "p" 'gnus-summary-post-news)
223 (define-key gnus-summary-send-map "f" 'gnus-summary-followup)
224 (define-key gnus-summary-send-map "F" 'gnus-summary-followup-with-original)
225 (define-key gnus-summary-send-map "b" 'gnus-summary-followup-and-reply)
226 (define-key gnus-summary-send-map "B" 'gnus-summary-followup-and-reply-with-original)
227 (define-key gnus-summary-send-map "c" 'gnus-summary-cancel-article)
228 (define-key gnus-summary-send-map "s" 'gnus-summary-supersede-article)
229 (define-key gnus-summary-send-map "r" 'gnus-summary-reply)
230 (define-key gnus-summary-send-map "R" 'gnus-summary-reply-with-original)
231 (define-key gnus-summary-send-map "m" 'gnus-summary-mail-other-window)
232 (define-key gnus-summary-send-map "u" 'gnus-uu-post-news)
233 (define-key gnus-summary-send-map "om" 'gnus-summary-mail-forward)
234 (define-key gnus-summary-send-map "op" 'gnus-summary-post-forward)
235 (define-key gnus-summary-send-map "Om" 'gnus-uu-digest-mail-forward)
236 (define-key gnus-summary-send-map "Op" 'gnus-uu-digest-post-forward)
238 ;;; Internal functions.
240 (defun gnus-number-base36 (num len)
241 (if (if (< len 0) (<= num 0) (= len 0))
243 (concat (gnus-number-base36 (/ num 36) (1- len))
244 (char-to-string (aref "zyxwvutsrqponmlkjihgfedcba9876543210"
247 ;;; Post news commands of Gnus group mode and summary mode
249 (defun gnus-group-mail ()
250 "Start composing a mail."
252 (funcall gnus-mail-other-window-method)
253 (gnus-configure-windows 'group-mail)
254 (run-hooks 'gnus-mail-hook))
256 (defun gnus-group-post-news ()
259 (let ((gnus-newsgroup-name nil))
260 (gnus-post-news 'post nil nil gnus-article-buffer)))
262 (defun gnus-summary-post-news ()
265 (gnus-set-global-variables)
266 (gnus-post-news 'post gnus-newsgroup-name))
268 (defun gnus-summary-followup (yank &optional yank-articles)
269 "Compose a followup to an article.
270 If prefix argument YANK is non-nil, original article is yanked automatically."
272 (gnus-set-global-variables)
273 (if yank-articles (gnus-summary-goto-subject (car yank-articles)))
274 (save-window-excursion
275 (gnus-summary-select-article t))
276 (let ((headers gnus-current-headers)
277 (gnus-newsgroup-name gnus-newsgroup-name))
278 ;; Check Followup-To: poster.
279 (set-buffer gnus-article-buffer)
280 (if (and gnus-use-followup-to
281 (string-equal "poster" (gnus-fetch-field "followup-to"))
282 (or (not (eq gnus-use-followup-to t))
284 "Do you want to ignore `Followup-To: poster'? "))))
285 ;; Mail to the poster. Gnus is now RFC1036 compliant.
286 (gnus-summary-reply yank)
287 (gnus-post-news nil gnus-newsgroup-name
288 headers gnus-article-buffer
289 (or yank-articles (not (not yank))))))
290 (gnus-article-hide-headers-if-wanted))
292 (defun gnus-summary-followup-with-original (n)
293 "Compose a followup to an article and include the original article."
295 (gnus-summary-followup t (gnus-summary-work-articles n)))
297 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
298 (defun gnus-summary-followup-and-reply (yank &optional yank-articles)
299 "Compose a followup and do an auto mail to author."
301 (gnus-set-global-variables)
302 (let ((gnus-auto-mail-to-author t))
303 (gnus-summary-followup yank yank-articles)))
305 (defun gnus-summary-followup-and-reply-with-original (n)
306 "Compose a followup, include the original, and do an auto mail to author."
308 (gnus-summary-followup-and-reply t (gnus-summary-work-articles n)))
310 (defun gnus-summary-cancel-article (n)
311 "Cancel an article you posted."
313 (gnus-set-global-variables)
314 (let ((articles (gnus-summary-work-articles n)))
316 (gnus-summary-select-article t nil nil (car articles))
317 (gnus-eval-in-buffer-window gnus-article-buffer (gnus-cancel-news))
318 (gnus-summary-remove-process-mark (car articles))
319 (gnus-summary-mark-as-read (car articles) gnus-canceled-mark)
320 (gnus-article-hide-headers-if-wanted)
321 (setq articles (cdr articles)))))
323 (defun gnus-summary-supersede-article ()
324 "Compose an article that will supersede a previous article.
325 This is done simply by taking the old article and adding a Supersedes
326 header line with the old Message-ID."
328 (gnus-set-global-variables)
331 (downcase (mail-strip-quoted-names
332 (header-from gnus-current-headers)))
333 (downcase (mail-strip-quoted-names (gnus-inews-user-name)))))
334 (error "This article is not yours."))
335 (gnus-summary-select-article t)
337 (set-buffer gnus-article-buffer)
338 (let ((buffer-read-only nil))
339 (goto-char (point-min))
340 (search-forward "\n\n" nil t)
341 (if (not (re-search-backward "^Message-ID: " nil t))
342 (error "No Message-ID in this article"))))
343 (if (gnus-post-news 'post gnus-newsgroup-name)
346 (insert-buffer gnus-article-buffer)
347 (goto-char (point-min))
348 (search-forward "\n\n" nil t)
349 (if (not (re-search-backward "^Message-ID: " nil t))
350 (error "No Message-ID in this article")
351 (replace-match "Supersedes: " t t))
352 (search-forward "\n\n")
354 (insert mail-header-separator))))
358 (defalias 'sendnews 'gnus-post-news)
361 (defalias 'postnews 'gnus-post-news)
363 (defun gnus-copy-article-buffer (&optional article-buffer)
364 ;; make a copy of the article buffer with all text properties removed
365 ;; this copy is in the buffer gnus-article-copy.
366 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
367 ;; this buffer should be passed to all mail/news reply/post routines.
368 (setq gnus-article-copy (get-buffer-create " *gnus article copy*"))
369 (buffer-disable-undo gnus-article-copy)
370 (or (memq gnus-article-copy gnus-buffer-list)
371 (setq gnus-buffer-list (cons gnus-article-copy gnus-buffer-list)))
372 (let ((article-buffer (or article-buffer gnus-article-buffer)))
373 (if (and (get-buffer article-buffer)
374 (buffer-name (get-buffer article-buffer)))
376 (set-buffer article-buffer)
377 (copy-to-buffer gnus-article-copy (point-min) (point-max))
378 (set-text-properties (point-min) (point-max)
379 nil gnus-article-copy)))))
381 (defun gnus-post-news (post &optional group header article-buffer yank subject)
382 "Begin editing a new USENET news article to be posted.
383 Type \\[describe-mode] in the buffer to get a list of commands."
384 (interactive (list t))
385 (gnus-copy-article-buffer article-buffer)
386 (if (or (not gnus-novice-user)
390 (format "%s" (car (gnus-find-method-for-group
391 gnus-newsgroup-name)))
392 gnus-valid-select-methods))))
395 (nth 5 (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))))
396 (gnus-y-or-n-p "Are you sure you want to post to all of USENET? "))
397 (let ((sumart (if (not post)
399 (set-buffer gnus-summary-buffer)
400 (cons (current-buffer) gnus-current-article))))
401 (from (and header (header-from header)))
402 (winconf (current-window-configuration))
403 follow-to real-group)
404 (and gnus-interactive-post
405 (not gnus-expert-user)
409 (completing-read "Group: " gnus-active-hashtb))
411 (setq subject (read-string "Subject: ")))))
412 (setq mail-reply-buffer gnus-article-copy)
414 (let ((newsgroup-name (or group gnus-newsgroup-name "")))
415 (setq real-group (and group (gnus-group-real-name group)))
416 (setq gnus-post-news-buffer
417 (gnus-request-post-buffer
418 post real-group subject header gnus-article-copy
419 (nth 2 (and group (gnus-gethash group gnus-newsrc-hashtb)))
420 (or (cdr (assq 'to-group
421 (nth 5 (nth 2 (gnus-gethash
423 gnus-newsrc-hashtb)))))
424 (if (and (boundp 'gnus-followup-to-function)
425 gnus-followup-to-function
429 (set-buffer gnus-article-copy)
430 (funcall gnus-followup-to-function group)))))
431 gnus-use-followup-to))
433 (gnus-configure-windows 'post)
435 (gnus-configure-windows 'followup-yank)
436 (gnus-configure-windows 'followup)))
437 (gnus-overload-functions)
438 (make-local-variable 'gnus-article-reply)
439 (make-local-variable 'gnus-article-check-size)
440 (make-local-variable 'gnus-reply-subject)
441 (setq gnus-reply-subject (and header (header-subject header)))
442 (setq gnus-article-reply sumart)
443 ;; Handle `gnus-auto-mail-to-author'.
444 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
445 (let ((to (if (eq gnus-auto-mail-to-author 'ask)
446 (and (y-or-n-p "Also send mail to author? ") from)
447 (and gnus-auto-mail-to-author from))))
450 (if (mail-fetch-field "To")
453 (insert "Cc: " to "\n"))
454 (mail-position-on-field "To")
456 ;; Handle author copy using BCC field.
457 (if (and gnus-mail-self-blind
458 (not (mail-fetch-field "bcc")))
460 (mail-position-on-field "Bcc")
461 (insert (if (stringp gnus-mail-self-blind)
463 (user-login-name)))))
464 ;; Handle author copy using FCC field.
467 (mail-position-on-field "Fcc")
468 (insert gnus-author-copy)))
469 (goto-char (point-min))
472 (re-search-forward "^Newsgroup:" nil t)
475 (re-search-forward "^Subject:" nil t)
479 (concat "^" (regexp-quote mail-header-separator) "$"))
482 (concat "^" (regexp-quote mail-header-separator) "$"))
487 (if (not (listp yank))
488 (news-reply-yank-original nil)
490 (save-window-excursion
491 (set-buffer gnus-summary-buffer)
492 (gnus-summary-select-article nil nil nil (car yank))
493 (gnus-summary-remove-process-mark (car yank)))
494 (let ((mail-reply-buffer gnus-article-copy))
495 (news-reply-yank-original nil))
496 (setq yank (cdr yank)))))))
497 (if gnus-post-prepare-function
498 (funcall gnus-post-prepare-function group))
499 (run-hooks 'gnus-post-prepare-hook)
500 (make-local-variable 'gnus-prev-winconf)
501 (setq gnus-prev-winconf winconf))))
502 (setq gnus-article-check-size (cons (buffer-size) (gnus-article-checksum)))
506 (defun gnus-inews-news (&optional use-group-method)
507 "Send a news message.
508 If given a prefix, and the group is a foreign group, this function
509 will attempt to use the foreign server to post the article."
511 (let* ((case-fold-search nil)
512 (server-running (gnus-server-opened gnus-select-method))
513 (reply gnus-article-reply))
515 ;; Connect to default NNTP server if necessary.
516 ;; Suggested by yuki@flab.fujitsu.junet.
517 (gnus-start-news-server) ;Use default server.
518 ;; NNTP server must be opened before current buffer is modified.
520 (goto-char (point-min))
521 (run-hooks 'news-inews-hook)
526 (goto-char (point-min))
528 (concat "^" (regexp-quote mail-header-separator) "$"))
529 (match-beginning 0)))
531 ;; Correct newsgroups field: change sequence of spaces to comma and
532 ;; eliminate spaces around commas. Eliminate imbedded line breaks.
533 (goto-char (point-min))
534 (if (search-forward-regexp "^Newsgroups: +" nil t)
538 (if (re-search-forward "^[^ \t]" nil 'end)
541 (goto-char (point-min))
542 (replace-regexp "\n[ \t]+" " ") ;No line breaks (too confusing)
543 (goto-char (point-min))
544 (replace-regexp "[ \t\n]*,[ \t\n]*\\|[ \t]+" ",")))
546 ;; Added by Per Abrahamsen <abraham@iesd.auc.dk>.
547 ;; Help save the the world!
550 (let ((newsgroups (mail-fetch-field "newsgroups"))
551 (followup-to (mail-fetch-field "followup-to"))
553 (if (and (string-match "," newsgroups) (not followup-to))
555 (while (string-match "," newsgroups)
557 (cons (list (substring newsgroups
558 0 (match-beginning 0)))
560 (setq newsgroups (substring newsgroups (match-end 0))))
561 (setq groups (nreverse (cons (list newsgroups) groups)))
564 (completing-read "Followups to: (default all groups) "
566 (if (> (length to) 0)
568 (goto-char (point-min))
569 (insert "Followup-To: " to "\n")))))))
571 ;; Cleanup Followup-To.
572 (goto-char (point-min))
573 (if (search-forward-regexp "^Followup-To: +" nil t)
577 (if (re-search-forward "^[^ \t]" nil 'end)
580 (goto-char (point-min))
581 (replace-regexp "\n[ \t]+" " ") ;No line breaks (too confusing)
582 (goto-char (point-min))
583 (replace-regexp "[ \t\n]*,[ \t\n]*\\|[ \t]+" ",")))
585 ;; Mail the message too if To:, Bcc:. or Cc: exists.
586 (let* ((types '("to" "bcc" "cc"))
590 (or (mail-fetch-field (car ty) nil t)
591 (setq types (delete (car ty) types)))
595 ;; We do not want to send mail.
597 (if (not gnus-mail-send-method)
601 1 "No mailer defined. To: and/or Cc: fields ignored.")
604 ;; We want to remove Fcc, because we want to handle
605 ;; that one ourselves...
607 (goto-char (point-min))
608 (if (re-search-forward "^Fcc: " nil t)
612 (progn (beginning-of-line) (point))
613 (progn (forward-line 1) (point))))
619 (gnus-message 5 "Sending via mail...")
621 (if (and gnus-mail-courtesy-message
622 (or (member "to" types)
623 (member "cc" types)))
624 ;; We only want to insert the courtesy mail
625 ;; message if we use to or cc; bcc should not
626 ;; have one. Well, if both bcc and to are
627 ;; present, it will get one anyway.
629 ;; Insert "courtesy" mail message.
630 (goto-char (point-min))
632 (concat "^" (regexp-quote
633 mail-header-separator) "$"))
635 (insert gnus-mail-courtesy-message)
636 (funcall gnus-mail-send-method)
637 (goto-char (point-min))
638 (search-forward gnus-mail-courtesy-message)
639 (replace-match "" t t))
640 (funcall gnus-mail-send-method))
642 (gnus-message 5 "Sending via mail...done")
644 (goto-char (point-min))
648 (concat "^" (regexp-quote mail-header-separator) "$")))
649 (goto-char (point-min))
650 (delete-matching-lines "^BCC:"))
653 (goto-char (point-max))
654 (insert fcc-line))))))))
656 ;; Send to NNTP server.
657 (gnus-message 5 "Posting to USENET...")
658 (if (gnus-inews-article use-group-method)
660 (gnus-message 5 "Posting to USENET...done")
661 (if (gnus-buffer-exists-p (car-safe reply))
664 (set-buffer gnus-summary-buffer)
665 (gnus-summary-mark-article-as-replied
667 ;; We cannot signal an error.
668 (ding) (gnus-message 1 "Article rejected: %s"
669 (gnus-status-message gnus-select-method)))
670 (set-buffer-modified-p nil))
671 ;; If NNTP server is opened by gnus-inews-news, close it by myself.
673 (gnus-close-server (gnus-find-method-for-group gnus-newsgroup-name)))
674 (let ((conf gnus-prev-winconf))
676 ;; Restore last window configuration.
677 (and conf (set-window-configuration conf)))))
679 (defun gnus-inews-check-post ()
680 "Check whether the post looks ok."
682 (not gnus-check-before-posting)
684 ;; We narrow to the headers and check them first.
687 (goto-char (point-min))
691 (concat "^" (regexp-quote mail-header-separator) "$")))
692 (goto-char (point-min))
694 ;; Check for commands in Subject.
695 (or (gnus-check-before-posting 'subject-cmsg)
697 (if (string-match "^cmsg " (mail-fetch-field "subject"))
699 "The control code \"cmsg \" is in the subject. Really post? ")
701 ;; Check for multiple identical headers.
702 (or (gnus-check-before-posting 'multiple-headers)
705 (while (and (not found) (re-search-forward "^[^ \t:]+: " nil t))
707 (or (re-search-forward
708 (concat "^" (setq found
711 (- (match-end 0) 2))))
716 (format "Multiple %s headers. Really post? " found))
718 ;; Check for version and sendsys.
719 (or (gnus-check-before-posting 'sendsys)
721 (if (re-search-forward "^Sendsys:\\|^Version:" nil t)
723 (format "The article contains a %s command. Really post? "
724 (buffer-substring (match-beginning 0)
725 (1- (match-end 0)))))
727 ;; Check the Message-Id header.
728 (or (gnus-check-before-posting 'message-id)
730 (let* ((case-fold-search t)
731 (message-id (mail-fetch-field "message-id")))
733 (and (string-match "@" message-id)
734 (string-match "@[^\\.]*\\." message-id))
737 "The Message-ID looks strange: \"%s\". Really post? "
739 ;; Check the From header.
740 (or (gnus-check-before-posting 'from)
742 (let* ((case-fold-search t)
743 (from (mail-fetch-field "from")))
745 (and (string-match "@" from)
746 (string-match "@[^\\.]*\\." from))
748 (format "The From looks strange: \"%s\". Really post? "
750 ;; Check for long lines.
751 (or (gnus-check-before-posting 'long-lines)
753 (goto-char (point-min))
755 (concat "^" (regexp-quote mail-header-separator) "$"))
759 (< (current-column) 80))
760 (zerop (forward-line 1))))
765 "You have lines longer than 79 characters. Really post? ")))))
766 ;; Check for control characters.
767 (or (gnus-check-before-posting 'control-chars)
769 (if (re-search-forward "[\000-\007\013\015-\037\200-\237]" nil t)
771 "The article contains control characters. Really post? ")
773 ;; Check excessive size.
774 (or (gnus-check-before-posting 'size)
775 (if (> (buffer-size) 60000)
777 (format "The article is %d octets long. Really post? "
780 ;; Use the (size . checksum) variable to see whether the
781 ;; article is empty or has only quoted text.
782 (or (gnus-check-before-posting 'new-text)
783 (if (and (= (buffer-size) (car gnus-article-check-size))
784 (= (gnus-article-checksum) (cdr gnus-article-check-size)))
786 "It looks like there's no new text in your article. Really post? ")
788 ;; Check the length of the signature.
789 (or (gnus-check-before-posting 'signature)
791 (goto-char (point-max))
792 (if (not (re-search-backward gnus-signature-separator nil t))
794 (if (> (count-lines (point) (point-max)) 4)
797 "Your .sig is %d lines; it should be max 4. Really post? "))
800 (defun gnus-article-checksum ()
804 (setq sum (logxor sum (following-char)))
808 ;; Returns non-nil if this type is not to be checked.
809 (defun gnus-check-before-posting (type)
810 (or (not gnus-check-before-posting)
811 (if (listp gnus-check-before-posting)
812 (memq type gnus-check-before-posting)
815 (defun gnus-cancel-news ()
816 "Cancel an article you posted."
818 (if (or gnus-expert-user
819 (gnus-yes-or-no-p "Do you really want to cancel this article? "))
824 (or (gnus-member-of-valid 'post gnus-newsgroup-name)
825 (error "This backend does not support cancelling"))
827 ;; Get header info. from original article.
829 (gnus-article-show-all-headers)
830 (goto-char (point-min))
831 (search-forward "\n\n" nil 'move)
832 (narrow-to-region (point-min) (point))
833 (setq from (mail-fetch-field "from"))
834 (setq newsgroups (mail-fetch-field "newsgroups"))
835 (setq message-id (mail-fetch-field "message-id"))
836 (setq distribution (mail-fetch-field "distribution")))
837 ;; Verify if the article is absolutely user's by comparing
838 ;; user id with value of its From: field.
841 (downcase (mail-strip-quoted-names from))
842 (downcase (mail-strip-quoted-names (gnus-inews-user-name)))))
844 (ding) (gnus-message 3 "This article is not yours."))
845 ;; Make control article.
846 (set-buffer (get-buffer-create " *Gnus-canceling*"))
847 (buffer-disable-undo (current-buffer))
849 (insert "Newsgroups: " newsgroups "\n"
850 "Subject: cancel " message-id "\n"
851 "Control: cancel " message-id "\n"
852 mail-header-separator "\n"
853 "This is a cancel message from " from ".\n")
854 ;; Send the control article to NNTP server.
855 (gnus-message 5 "Canceling your article...")
856 (if (gnus-inews-article)
857 (gnus-message 5 "Canceling your article...done")
859 (gnus-message 1 "Cancel failed; %s"
860 (gnus-status-message gnus-newsgroup-name)))
861 ;; Kill the article buffer.
862 (kill-buffer (current-buffer)))))))
865 ;;; Lowlevel inews interface
867 (defun gnus-inews-article (&optional use-group-method)
868 "Post an article in current buffer using NNTP protocol."
869 ;; Check whether the article is a good Net Citizen.
870 (if (and gnus-article-check-size (not (gnus-inews-check-post)))
873 ;; Looks ok, so we do the nasty.
874 (let ((artbuf (current-buffer))
875 (tmpbuf (get-buffer-create " *Gnus-posting*")))
877 (goto-char (point-max))
878 ;; require a newline at the end for inews to append .signature to
879 (or (= (preceding-char) ?\n)
881 ;; Prepare article headers. All message body such as signature
882 ;; must be inserted before Lines: field is prepared.
884 (goto-char (point-min))
889 (concat "^" (regexp-quote mail-header-separator) "$"))
890 (match-beginning 0)))
891 (gnus-inews-remove-headers)
892 (gnus-inews-insert-headers)
893 (run-hooks gnus-inews-article-header-hook)
897 (buffer-disable-undo (current-buffer))
899 (insert-buffer-substring artbuf)
900 ;; Remove the header separator.
901 (goto-char (point-min))
903 (concat "^" (regexp-quote mail-header-separator) "$"))
904 (replace-match "" t t)
905 ;; This hook may insert a signature.
906 (run-hooks 'gnus-prepare-article-hook)
907 ;; Run final inews hooks. This hook may do FCC.
908 ;; The article must be saved before being posted because
909 ;; `gnus-request-post' modifies the buffer.
910 (run-hooks 'gnus-inews-article-hook)
911 ;; Post an article to NNTP server.
912 ;; Return NIL if post failed.
916 (gnus-find-method-for-group gnus-newsgroup-name)
917 gnus-select-method) use-group-method)
918 (kill-buffer (current-buffer)))))))
920 (defun gnus-inews-remove-headers ()
921 (let ((case-fold-search t))
922 ;; Remove NNTP-posting-host.
923 (goto-char (point-min))
924 (and (re-search-forward "^nntp-posting-host:" nil t)
925 (delete-region (progn (beginning-of-line) (point))
926 (progn (forward-line 1) (point))))
928 (goto-char (point-min))
929 (and (re-search-forward "^bcc:" nil t)
930 (delete-region (progn (beginning-of-line) (point))
931 (progn (forward-line 1) (point))))))
933 (defun gnus-inews-insert-headers ()
934 "Prepare article headers.
935 Headers already prepared in the buffer are not modified.
936 Headers in `gnus-required-headers' will be generated."
937 (let ((Date (gnus-inews-date))
938 (Message-ID (gnus-inews-message-id))
939 (Organization (gnus-inews-organization))
940 (From (gnus-inews-user-name))
941 (Path (gnus-inews-path))
945 (Lines (gnus-inews-lines))
946 (X-Newsreader gnus-version)
947 (headers gnus-required-headers)
950 ;; First we remove any old Message-IDs. This might be slightly
951 ;; fascist, but if the user really wants to generate Message-IDs
952 ;; by herself, she should remove it from the `gnus-required-list'.
953 (goto-char (point-min))
954 (and (memq 'Message-ID headers)
955 (re-search-forward "^Message-ID:" nil t)
956 (delete-region (progn (beginning-of-line) (point))
957 (progn (forward-line 1) (point))))
958 ;; Insert new Sender if the From is strange.
959 (let ((from (mail-fetch-field "from")))
960 (if (and from (not (string= (downcase from) (downcase From))))
962 (goto-char (point-min))
963 (and (re-search-forward "^Sender:" nil t)
964 (delete-region (progn (beginning-of-line) (point))
965 (progn (forward-line 1) (point))))
966 (insert "Sender: " From "\n"))))
967 ;; If there are References, and no "Re: ", then the thread has
968 ;; changed name. See Son-of-1036.
969 (if (and (mail-fetch-field "references")
970 (get-buffer gnus-article-buffer))
971 (let ((psubject (gnus-simplify-subject-re
972 (mail-fetch-field "subject"))))
973 (or (and psubject gnus-reply-subject
974 (string= (gnus-simplify-subject-re gnus-reply-subject)
977 (string-match "@" Message-ID)
979 (concat (substring Message-ID 0 (match-beginning 0))
981 (substring Message-ID (match-beginning 0))))))))
982 ;; Go through all the required headers and see if they are in the
983 ;; articles already. If they are not, or are empty, they are
984 ;; inserted automatically - except for Subject, Newsgroups and
987 (goto-char (point-min))
988 (setq elem (car headers))
990 (setq header (car elem))
992 (if (or (not (re-search-forward
993 (concat "^" (downcase (symbol-name header)) ":") nil t))
995 (if (= (following-char) ? ) (forward-char 1) (insert " "))
996 (looking-at "[ \t]*$")))
1000 ;; The element is a cons. Either the cdr is
1001 ;; a string to be inserted verbatim, or it
1002 ;; is a function, and we insert the value
1003 ;; returned from this function.
1004 (or (and (stringp (cdr elem)) (cdr elem))
1005 (and (fboundp (cdr elem)) (funcall (cdr elem))))
1006 ;; The element is a symbol. We insert the
1007 ;; value of this symbol, if any.
1008 (and (boundp header) (symbol-value header)))
1009 ;; We couldn't generate a value for this header,
1010 ;; so we just ask the user.
1011 (read-from-minibuffer
1012 (format "Empty header for %s; enter value: " header))))
1015 (goto-char (point-max))
1016 (insert (symbol-name header) ": " value "\n"))
1017 (replace-match value t t))))
1018 (setq headers (cdr headers)))))
1020 (defun gnus-inews-insert-signature ()
1021 "Insert a signature file.
1022 If `gnus-signature-function' is bound and returns a string, this
1023 string is used instead of the variable `gnus-signature-file'.
1024 In either case, if the string is a file name, this file is
1025 inserted. If the string is not a file name, the string itself is
1027 If you never want any signature inserted, set both those variables to
1031 (or (and gnus-signature-function
1032 (fboundp gnus-signature-function)
1033 (funcall gnus-signature-function gnus-newsgroup-name))
1034 gnus-signature-file))
1037 (or (file-exists-p signature)
1038 (string-match " " signature)
1040 "^/[^/]+/" (expand-file-name signature)))))
1042 (goto-char (point-max))
1043 (if (and mail-signature (search-backward "\n-- \n" nil t))
1045 ;; Delete any previous signatures.
1046 (if (search-backward "\n-- \n" nil t)
1047 (delete-region (1+ (point)) (point-max)))
1049 (if (file-exists-p signature)
1050 (insert-file-contents signature)
1052 (goto-char (point-max))
1053 (or (bolp) (insert "\n"))))))))
1055 (defun gnus-inews-do-fcc ()
1056 "Process FCC: fields in current article buffer.
1057 Unless the first character of the field is `|', the article is saved
1058 to the specified file using the function specified by the variable
1059 gnus-author-copy-saver. The default function rmail-output saves in
1060 Unix mailbox format.
1061 If the first character is `|', the contents of the article is send to
1062 a program specified by the rest of the value."
1063 (let ((fcc-list nil)
1065 (case-fold-search t)) ;Should ignore case.
1068 (goto-char (point-min))
1069 (search-forward "\n\n")
1070 (narrow-to-region (point-min) (point))
1071 (goto-char (point-min))
1072 (while (re-search-forward "^FCC:[ \t]*" nil t)
1074 (cons (buffer-substring
1078 (skip-chars-backward " \t")
1081 (delete-region (match-beginning 0)
1082 (progn (forward-line 1) (point))))
1083 ;; Process FCC operations.
1086 (setq fcc-file (car fcc-list))
1087 (setq fcc-list (cdr fcc-list))
1088 (cond ((string-match "^[ \t]*|[ \t]*\\(.*\\)[ \t]*$" fcc-file)
1089 (let ((program (substring fcc-file
1090 (match-beginning 1) (match-end 1))))
1091 ;; Suggested by yuki@flab.fujitsu.junet.
1092 ;; Send article to named program.
1093 (call-process-region (point-min) (point-max) shell-file-name
1094 nil nil nil "-c" program)))
1096 ;; Suggested by hyoko@flab.fujitsu.junet.
1097 ;; Save article in Unix mail format by default.
1098 (gnus-make-directory (file-name-directory fcc-file))
1099 (if (and gnus-author-copy-saver
1100 (not (eq gnus-author-copy-saver 'rmail-output)))
1101 (funcall gnus-author-copy-saver fcc-file)
1102 (if (and (file-readable-p fcc-file) (rmail-file-p fcc-file))
1103 (gnus-output-to-rmail fcc-file)
1104 (rmail-output fcc-file 1 t t))))))))))
1106 (defun gnus-inews-path ()
1108 (let ((login-name (gnus-inews-login-name)))
1109 (cond ((null gnus-use-generic-path)
1110 (concat (nth 1 gnus-select-method) "!" login-name))
1111 ((stringp gnus-use-generic-path)
1112 ;; Support GENERICPATH. Suggested by vixie@decwrl.dec.com.
1113 (concat gnus-use-generic-path "!" login-name))
1116 (defun gnus-inews-user-name ()
1117 "Return user's network address as \"NAME@DOMAIN (FULL-NAME)\"."
1118 (let ((full-name (gnus-inews-full-name)))
1119 (or gnus-user-from-line
1120 (concat (if (or gnus-user-login-name gnus-use-generic-from
1121 gnus-local-domain (getenv "DOMAINNAME"))
1122 (concat (gnus-inews-login-name) "@"
1123 (gnus-inews-domain-name gnus-use-generic-from))
1125 ;; User's full name.
1126 (cond ((string-equal full-name "") "")
1127 ((string-equal full-name "&") ;Unix hack.
1128 (concat " (" (user-login-name) ")"))
1130 (concat " (" full-name ")")))))))
1132 (defun gnus-inews-login-name ()
1133 "Return login name."
1134 (or gnus-user-login-name (getenv "LOGNAME") (user-login-name)))
1136 (defun gnus-inews-full-name ()
1137 "Return full user name."
1138 (or gnus-user-full-name (getenv "NAME") (user-full-name)))
1140 (defun gnus-inews-domain-name (&optional genericfrom)
1141 "Return user's domain name.
1142 If optional argument GENERICFROM is a string, use it as the domain
1143 name; if it is non-nil, strip off local host name from the domain name.
1144 If the function `system-name' returns full internet name and the
1145 domain is undefined, the domain name is got from it."
1146 (if (or genericfrom gnus-local-domain (getenv "DOMAINNAME"))
1147 (let* ((system-name (system-name))
1149 (or (if (stringp genericfrom) genericfrom)
1150 (getenv "DOMAINNAME")
1152 ;; Function `system-name' may return full internet name.
1153 ;; Suggested by Mike DeCorte <mrd@sun.soe.clarkson.edu>.
1154 (if (string-match "\\." system-name)
1155 (substring system-name (match-end 0)))
1156 (read-string "Domain name (no host): ")))
1157 (host (or (if (string-match "\\." system-name)
1158 (substring system-name 0 (match-beginning 0)))
1160 (if (string-equal "." (substring domain 0 1))
1161 (setq domain (substring domain 1)))
1162 ;; Support GENERICFROM as same as standard Bnews system.
1163 ;; Suggested by ohm@kaba.junet and vixie@decwrl.dec.com.
1164 (cond ((null genericfrom)
1165 (concat host "." domain))
1166 ;;((stringp genericfrom) genericfrom)
1168 (if (string-match "\\." (system-name))
1170 (substring user-mail-address
1171 (1+ (string-match "@" user-mail-address))))))
1173 (defun gnus-inews-full-address ()
1174 (let ((domain (gnus-inews-domain-name))
1175 (system (system-name))
1176 (case-fold-search t))
1177 (if (string-match "\\." system) system
1178 (if (string-match (concat "^" (regexp-quote system)) domain) domain
1179 (concat system "." domain)))))
1181 (defun gnus-inews-message-id ()
1182 "Generate unique Message-ID for user."
1183 ;; Message-ID should not contain a slash and should be terminated by
1184 ;; a number. I don't know the reason why it is so.
1185 (concat "<" (gnus-inews-unique-id) "@" (gnus-inews-full-address) ">"))
1187 (defvar gnus-unique-id-char nil)
1189 ;; If you ever change this function, make sure the new version
1190 ;; cannot generate IDs that the old version could.
1191 ;; You might for example insert a "." somewhere (not next to another dot
1192 ;; or string boundary), or modify the newsreader name to "Ding".
1193 (defun gnus-inews-unique-id ()
1194 ;; Dont use microseconds from (current-time), they may be unsupported.
1195 ;; Instead we use this randomly inited counter.
1196 (setq gnus-unique-id-char
1197 (% (1+ (or gnus-unique-id-char (logand (random t) (1- (lsh 1 20)))))
1198 ;; (current-time) returns 16-bit ints,
1199 ;; and 2^16*25 just fits into 4 digits i base 36.
1201 (let ((tm (if (fboundp 'current-time)
1202 (current-time) '(12191 46742 287898))))
1204 (if (memq system-type '(ms-dos emx vax-vms))
1205 (let ((user (downcase (gnus-inews-login-name))))
1206 (while (string-match "[^a-z0-9_]" user)
1207 (aset user (match-beginning 0) ?_))
1209 (gnus-number-base36 (user-uid) -1))
1210 (gnus-number-base36 (+ (car tm) (lsh (% gnus-unique-id-char 25) 16)) 4)
1211 (gnus-number-base36 (+ (nth 1 tm) (lsh (/ gnus-unique-id-char 25) 16)) 4)
1212 ;; Append the newsreader name, because while the generated
1213 ;; ID is unique to this newsreader, other newsreaders might
1214 ;; otherwise generate the same ID via another algorithm.
1218 (defun gnus-inews-date ()
1219 "Current time string."
1220 (timezone-make-date-arpa-standard
1221 (current-time-string) (current-time-zone)))
1223 (defun gnus-inews-organization ()
1224 "Return user's organization.
1225 The ORGANIZATION environment variable is used if defined.
1226 If not, the variable `gnus-local-organization' is used instead.
1227 If it is a function, the function will be called with the current
1228 newsgroup name as the argument.
1229 If this is a file name, the contents of this file will be used as the
1231 (let* ((organization
1232 (or (getenv "ORGANIZATION")
1233 (if gnus-local-organization
1234 (if (and (symbolp gnus-local-organization)
1235 (fboundp gnus-local-organization))
1236 (funcall gnus-local-organization gnus-newsgroup-name)
1237 gnus-local-organization))
1238 gnus-organization-file
1239 "~/.organization")))
1240 (and (stringp organization)
1241 (> (length organization) 0)
1243 (gnus-set-work-buffer)
1244 (if (file-exists-p organization)
1245 (insert-file-contents organization)
1246 (insert organization))
1247 (goto-char (point-min))
1248 (while (re-search-forward " *\n *" nil t)
1249 (replace-match " " t t))
1250 (buffer-substring (point-min) (point-max))))))
1252 (defun gnus-inews-lines ()
1253 "Count the number of lines and return numeric string."
1257 (goto-char (point-min))
1259 (concat "^" (regexp-quote mail-header-separator) "$"))
1261 (int-to-string (count-lines (point) (point-max))))))
1265 ;;; Gnus Mail Functions
1268 ;;; Mail reply commands of Gnus summary mode
1270 (defun gnus-summary-reply (yank &optional yank-articles)
1271 "Reply mail to news author.
1272 If prefix argument YANK is non-nil, original article is yanked automatically.
1273 Customize the variable gnus-mail-reply-method to use another mailer."
1275 ;; Bug fix by jbw@bigbird.bu.edu (Joe Wells)
1276 ;; Stripping headers should be specified with mail-yank-ignored-headers.
1277 (gnus-set-global-variables)
1278 (if yank-articles (gnus-summary-goto-subject (car yank-articles)))
1279 (gnus-summary-select-article t)
1280 (let ((gnus-newsgroup-name gnus-newsgroup-name))
1281 (bury-buffer gnus-article-buffer)
1282 (funcall gnus-mail-reply-method (or yank-articles (not (not yank)))))
1283 (gnus-article-hide-headers-if-wanted))
1285 (defun gnus-summary-reply-with-original (n)
1286 "Reply mail to news author with original article.
1287 Customize the variable gnus-mail-reply-method to use another mailer."
1289 (gnus-summary-reply t (gnus-summary-work-articles n)))
1291 (defun gnus-summary-mail-forward (post)
1292 "Forward the current message to another user.
1293 Customize the variable gnus-mail-forward-method to use another mailer."
1295 (gnus-set-global-variables)
1296 (gnus-summary-select-article t)
1297 (gnus-copy-article-buffer)
1298 (let ((gnus-newsgroup-name gnus-newsgroup-name))
1300 (gnus-forward-using-post gnus-article-copy)
1301 (funcall gnus-mail-forward-method gnus-article-copy)))
1302 (gnus-article-hide-headers-if-wanted))
1304 (defun gnus-summary-post-forward ()
1305 "Forward the current article to a newsgroup."
1307 (gnus-summary-mail-forward t))
1309 (defun gnus-summary-mail-other-window ()
1310 "Compose mail in other window.
1311 Customize the variable `gnus-mail-other-window-method' to use another
1314 (gnus-set-global-variables)
1315 (let ((gnus-newsgroup-name gnus-newsgroup-name))
1316 (funcall gnus-mail-other-window-method)))
1318 (defun gnus-mail-reply-using-mail (&optional yank to-address)
1320 (set-buffer gnus-summary-buffer)
1321 (let ((info (nth 2 (gnus-gethash gnus-newsgroup-name gnus-newsrc-hashtb)))
1322 (group (gnus-group-real-name gnus-newsgroup-name))
1323 (cur (cons (current-buffer) (cdr gnus-article-current)))
1324 (winconf (current-window-configuration))
1325 from subject date to reply-to message-of
1326 references message-id sender follow-to cc sendto elt)
1327 (set-buffer (get-buffer-create "*mail*"))
1329 (make-local-variable 'gnus-article-reply)
1330 (setq gnus-article-reply cur)
1331 (make-local-variable 'gnus-prev-winconf)
1332 (setq gnus-prev-winconf winconf)
1333 (use-local-map (copy-keymap mail-mode-map))
1334 (local-set-key "\C-c\C-c" 'gnus-mail-send-and-exit)
1335 (if (and (buffer-modified-p)
1338 "Unsent article being composed; erase it? ")))
1342 (gnus-copy-article-buffer)
1344 (set-buffer gnus-article-copy)
1345 (gnus-narrow-to-headers)
1346 (if (and (boundp 'gnus-reply-to-function)
1347 gnus-reply-to-function)
1348 (setq follow-to (funcall gnus-reply-to-function group)))
1349 (setq from (mail-fetch-field "from"))
1350 (setq date (or (mail-fetch-field "date")
1351 (header-date gnus-current-headers)))
1354 (string-match " *at \\| *@ \\| *(\\| *<" from)))
1356 (concat (if stop-pos (substring from 0 stop-pos) from)
1357 "'s message of " date))))
1358 (setq sender (mail-fetch-field "sender"))
1359 (setq subject (or (mail-fetch-field "subject")
1361 (or (string-match "^[Rr][Ee]:" subject)
1362 (setq subject (concat "Re: " subject)))
1363 (setq cc (mail-fetch-field "cc"))
1364 (setq reply-to (mail-fetch-field "reply-to"))
1365 (setq references (mail-fetch-field "references"))
1366 (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 (or mail-yank-hooks mail-citation-hook
1417 (run-hooks 'news-reply-header-hook)))
1419 (save-window-excursion
1420 (set-buffer gnus-summary-buffer)
1421 (gnus-summary-select-article nil nil nil (car yank))
1422 (gnus-summary-remove-process-mark (car yank)))
1424 (gnus-copy-article-buffer)
1425 (mail-yank-original nil)
1427 (or mail-yank-hooks mail-citation-hook
1428 (run-hooks 'news-reply-header-hook))
1430 (setq yank (cdr yank))))
1432 (gnus-configure-windows 'reply-yank))
1433 (run-hooks 'gnus-mail-hook)))))
1435 (defun gnus-mail-yank-original ()
1438 (mail-yank-original nil))
1439 (or mail-yank-hooks mail-citation-hook
1440 (run-hooks 'news-reply-header-hook)))
1442 (defun gnus-mail-send-and-exit ()
1444 (let ((reply gnus-article-reply)
1445 (winconf gnus-prev-winconf))
1446 (mail-send-and-exit nil)
1447 (if (get-buffer gnus-group-buffer)
1449 (if (gnus-buffer-exists-p (car-safe reply))
1451 (set-buffer (car reply))
1453 (gnus-summary-mark-article-as-replied
1455 (and winconf (set-window-configuration winconf))))))
1457 (defun gnus-forward-make-subject (buffer)
1460 (concat "[" (if (memq 'mail (assoc (symbol-name
1461 (car (gnus-find-method-for-group
1462 gnus-newsgroup-name)))
1463 gnus-valid-select-methods))
1464 (gnus-fetch-field "From")
1465 gnus-newsgroup-name)
1466 "] " (or (gnus-fetch-field "Subject") ""))))
1468 (defun gnus-forward-insert-buffer (buffer)
1469 (let ((beg (goto-char (point-max))))
1470 (insert "------- Start of forwarded message -------\n")
1471 (insert-buffer buffer)
1472 (goto-char (point-max))
1473 (insert "------- End of forwarded message -------\n")
1474 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
1476 (while (setq beg (next-single-property-change (point) 'invisible))
1478 (delete-region beg (or (next-single-property-change
1482 (defun gnus-mail-forward-using-mail (&optional buffer)
1483 "Forward the current message to another user using mail."
1484 ;; This is almost a carbon copy of rmail-forward in rmail.el.
1485 (let* ((forward-buffer (or buffer (current-buffer)))
1486 (winconf (current-window-configuration))
1487 (subject (gnus-forward-make-subject forward-buffer)))
1488 (set-buffer forward-buffer)
1489 (mail nil nil subject)
1490 (use-local-map (copy-keymap (current-local-map)))
1491 (local-set-key "\C-c\C-c" 'gnus-mail-send-and-exit)
1492 (make-local-variable 'gnus-prev-winconf)
1493 (setq gnus-prev-winconf winconf)
1494 (gnus-forward-insert-buffer forward-buffer)
1495 (goto-char (point-min))
1496 (re-search-forward "^To: " nil t)
1497 (gnus-configure-windows 'mail-forward)
1498 ;; You have a chance to arrange the message.
1499 (run-hooks 'gnus-mail-forward-hook)
1500 (run-hooks 'gnus-mail-hook)))
1502 (defun gnus-forward-using-post (&optional buffer)
1503 (let* ((forward-buffer (or buffer (current-buffer)))
1504 (subject (gnus-forward-make-subject forward-buffer)))
1505 (gnus-post-news 'post nil nil nil nil subject)
1507 (gnus-forward-insert-buffer forward-buffer)
1508 ;; You have a chance to arrange the message.
1509 (run-hooks 'gnus-mail-forward-hook))))
1511 (defun gnus-mail-other-window-using-mail ()
1512 "Compose mail other window using mail."
1513 (let ((winconf (current-window-configuration)))
1514 (mail-other-window nil nil nil nil nil (get-buffer gnus-article-buffer))
1515 (use-local-map (copy-keymap (current-local-map)))
1516 (local-set-key "\C-c\C-c" 'gnus-mail-send-and-exit)
1517 (make-local-variable 'gnus-prev-winconf)
1518 (setq gnus-prev-winconf winconf)
1519 (run-hooks 'gnus-mail-hook)))
1521 (defun gnus-article-mail (yank)
1522 "Send a reply to the address near point.
1523 If YANK is non-nil, include the original article."
1527 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
1528 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
1531 (switch-to-buffer gnus-summary-buffer)
1532 (funcall gnus-mail-reply-method yank address)))))
1534 (defun gnus-article-mail-with-original ()
1535 "Send a reply to the address near point and include the original article."
1537 (gnus-article-mail 'yank))
1541 ;;; gnus-msg.el ends here