1 ;;; gnus-msg.el --- mail and post interface for Gnus
2 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
3 ;; Free Software Foundation, Inc.
5 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
6 ;; Lars Magne Ingebrigtsen <larsi@gnus.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
30 (eval-when-compile (require 'cl))
37 (defcustom gnus-post-method 'current
38 "*Preferred method for posting USENET news.
40 If this variable is `current' (which is the default), Gnus will use
41 the \"current\" select method when posting. If it is `native', Gnus
42 will use the native select method when posting.
44 This method will not be used in mail groups and the like, only in
47 If not `native' nor `current', the value must be a valid method as discussed
48 in the documentation of `gnus-select-method'. It can also be a list of
49 methods. If that is the case, the user will be queried for what select
50 method to use when posting."
51 :group 'gnus-group-foreign
52 :link '(custom-manual "(gnus)Posting Server")
53 :type `(choice (const native)
55 (sexp :tag "Methods" ,gnus-select-method)))
57 (defcustom gnus-outgoing-message-group nil
58 "*All outgoing messages will be put in this group.
59 If you want to store all your outgoing mail and articles in the group
60 \"nnml:archive\", you set this variable to that value. This variable
61 can also be a list of group names.
63 If you want to have greater control over what group to put each
64 message in, you can set this variable to a function that checks the
65 current newsgroup name and then returns a suitable group name (or list
68 :type '(choice (string :tag "Group")
71 (defcustom gnus-mailing-list-groups nil
72 "*Regexp matching groups that are really mailing lists.
73 This is useful when you're reading a mailing list that has been
74 gatewayed to a newsgroup, and you want to followup to an article in
79 (defcustom gnus-add-to-list nil
80 "*If non-nil, add a `to-list' parameter automatically."
84 (defcustom gnus-crosspost-complaint
87 You posted the article below with the following Newsgroups header:
91 The %s group, at least, was an inappropriate recipient
92 of this message. Please trim your Newsgroups header to exclude this
93 group before posting in the future.
98 "Format string to be inserted when complaining about crossposts.
99 The first %s will be replaced by the Newsgroups header;
100 the second with the current group name."
104 (defcustom gnus-message-setup-hook nil
105 "Hook run after setting up a message buffer."
109 (defcustom gnus-bug-create-help-buffer t
110 "*Should we create the *Gnus Help Bug* buffer?"
114 (defcustom gnus-posting-styles nil
115 "*Alist of styles to use when posting.
116 See Info node `(gnus)Posting Styles'."
118 :link '(custom-manual "(gnus)Posting Styles")
119 :type '(repeat (cons (choice (regexp)
122 (string :tag "Header")
123 (regexp :tag "Regexp"))
127 (choice (const signature)
128 (const signature-file)
135 (string :tag "Header"))
141 (defcustom gnus-gcc-mark-as-read nil
142 "If non-nil, automatically mark Gcc articles as read."
147 (defvar gnus-inews-mark-gcc-as-read nil
148 "Obsolete variable. Use `gnus-gcc-mark-as-read' instead.")
150 (make-obsolete-variable 'gnus-inews-mark-gcc-as-read
151 'gnus-gcc-mark-as-read)
153 (defcustom gnus-gcc-externalize-attachments nil
154 "Should local-file attachments be included as external parts in Gcc copies?
155 If it is `all', attach files as external parts;
156 if a regexp and matches the Gcc group name, attach files as external parts;
157 if nil, attach files as normal parts."
160 :type '(choice (const nil :tag "None")
161 (const all :tag "Any")
162 (string :tag "Regexp")))
164 (gnus-define-group-parameter
165 posting-charset-alist
168 "Return the permitted unencoded charsets for posting of GROUP."
169 :variable gnus-group-posting-charset-alist
171 '(("^\\(no\\|fr\\)\\.[^,]*\\(,[ \t\n]*\\(no\\|fr\\)\\.[^,]*\\)*$" iso-8859-1 (iso-8859-1))
172 ("^\\(fido7\\|relcom\\)\\.[^,]*\\(,[ \t\n]*\\(fido7\\|relcom\\)\\.[^,]*\\)*$" koi8-r (koi8-r))
173 (message-this-is-mail nil nil)
174 (message-this-is-news nil t))
176 "Alist of regexps and permitted unencoded charsets for posting.
177 Each element of the alist has the form (TEST HEADER BODY-LIST), where
178 TEST is either a regular expression matching the newsgroup header or a
180 HEADER is the charset which may be left unencoded in the header (nil
181 means encode all charsets),
182 BODY-LIST is a list of charsets which may be encoded using 8bit
183 content-transfer encoding in the body, or one of the special values
184 nil (always encode using quoted-printable) or t (always use 8bit).
186 Note that any value other than nil for HEADER infringes some RFCs, so
187 use this option with care."
188 :variable-group gnus-charset
190 '(repeat (list :tag "Permitted unencoded charsets"
192 (regexp :tag "Group")
193 (const :tag "Mail message" :value message-this-is-mail)
194 (const :tag "News article" :value message-this-is-news))
195 (choice :tag "Header"
196 (const :tag "None" nil)
197 (symbol :tag "Charset"))
199 (const :tag "Any" :value t)
200 (const :tag "None" :value nil)
201 (repeat :tag "Charsets"
202 (symbol :tag "Charset")))))
203 :parameter-type '(choice :tag "Permitted unencoded charsets"
206 :parameter-document "\
207 List of charsets that are permitted to be unencoded.")
209 (defcustom gnus-debug-files
210 '("gnus.el" "gnus-sum.el" "gnus-group.el"
211 "gnus-art.el" "gnus-start.el" "gnus-async.el"
212 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
213 "gnus-agent.el" "gnus-cache.el" "gnus-srvr.el"
214 "mm-util.el" "mm-decode.el" "nnmail.el" "message.el")
215 "Files whose variables will be reported in `gnus-bug'."
218 :type '(repeat (string :tag "File")))
220 (defcustom gnus-debug-exclude-variables
221 '(mm-mime-mule-charset-alist
222 nnmail-split-fancy message-minibuffer-local-map)
223 "Variables that should not be reported in `gnus-bug'."
226 :type '(repeat (symbol :tag "Variable")))
228 (defcustom gnus-discouraged-post-methods
229 '(nndraft nnml nnimap nnmaildir nnmh nnfolder nndir)
230 "A list of back ends that are not used in \"real\" newsgroups.
231 This variable is used only when `gnus-post-method' is `current'."
233 :group 'gnus-group-foreign
234 :type '(repeat (symbol :tag "Back end")))
236 (defcustom gnus-message-replysign
238 "Automatically sign replies to signed messages.
239 See also the `mml-default-sign-method' variable."
243 (defcustom gnus-message-replyencrypt
245 "Automatically encrypt replies to encrypted messages.
246 See also the `mml-default-encrypt-method' variable."
250 (defcustom gnus-message-replysignencrypted
252 "Setting this causes automatically encryped messages to also be signed."
256 (defcustom gnus-confirm-mail-reply-to-news nil
257 "If non-nil, Gnus requests confirmation when replying to news.
258 This is done because new users often reply by mistake when reading
260 This can also be a function receiving the group name as the only
261 parameter which should return non-nil iff a confirmation is needed, or
262 a regexp, in which case a confirmation is asked for iff the group name
265 :type '(choice (const :tag "No" nil)
267 (regexp :tag "Iff group matches regexp")
268 (function :tag "Iff function evaluates to non-nil")))
270 (defcustom gnus-confirm-treat-mail-like-news
272 "If non-nil, Gnus will treat mail like news with regard to confirmation
273 when replying by mail. See the `gnus-confirm-mail-reply-to-news' variable
274 for fine-tuning this.
275 If nil, Gnus will never ask for confirmation if replying to mail."
279 (defcustom gnus-summary-resend-default-address t
280 "If non-nil, Gnus tries to suggest a default address to resend to.
281 If nil, the address field will always be empty after invoking
282 `gnus-summary-resend-message'."
286 (defcustom gnus-user-agent 'emacs-gnus-type
287 "Which information should be exposed in the User-Agent header.
289 It can be one of the symbols `gnus' \(show only Gnus version\) `emacs-gnus'
290 \(show only Emacs and Gnus versions\), `emacs-gnus-config' \(same as
291 `emacs-gnus' plus system configuration\), `emacs-gnus-type' \(same as
292 `emacs-gnus' plus system type\) or a custom string. If you set it to a
293 string, be sure to use a valid format, see RFC 2616."
296 (item :tag "Show Gnus and Emacs versions and system type"
298 (item :tag "Show Gnus and Emacs versions and system configuration"
300 (item :tag "Show Gnus and Emacs versions" emacs-gnus)
301 (item :tag "Show only Gnus version" gnus)
302 (string :tag "Other")))
304 ;;; Internal variables.
306 (defvar gnus-inhibit-posting-styles nil
307 "Inhibit the use of posting styles.")
309 (defvar gnus-article-yanked-articles nil)
310 (defvar gnus-message-buffer "*Mail Gnus*")
311 (defvar gnus-article-copy nil)
312 (defvar gnus-check-before-posting nil)
313 (defvar gnus-last-posting-server nil)
314 (defvar gnus-message-group-art nil)
316 (defvar gnus-msg-force-broken-reply-to nil)
318 (defconst gnus-bug-message
319 "Sending a bug report to the Gnus Towers.
320 ========================================
322 The buffer below is a mail buffer. When you press `C-c C-c', it will
323 be sent to the Gnus Bug Exterminators.
325 The thing near the bottom of the buffer is how the environment
326 settings will be included in the mail. Please do not delete that.
327 They will tell the Bug People what your environment is, so that it
328 will be easier to locate the bugs.
330 If you have found a bug that makes Emacs go \"beep\", set
331 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
332 and include the backtrace in your bug report.
334 Please describe the bug in annoying, painstaking detail.
336 Thank you for your help in stamping out bugs.
340 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
341 (autoload 'news-setup "rnewspost")
342 (autoload 'news-reply-mode "rnewspost")
343 (autoload 'rmail-dont-reply-to "mail-utils")
344 (autoload 'rmail-output "rmailout"))
348 ;;; Gnus Posting Functions
351 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
352 "p" gnus-summary-post-news
353 "i" gnus-summary-news-other-window
354 "f" gnus-summary-followup
355 "F" gnus-summary-followup-with-original
356 "c" gnus-summary-cancel-article
357 "s" gnus-summary-supersede-article
358 "r" gnus-summary-reply
359 "y" gnus-summary-yank-message
360 "R" gnus-summary-reply-with-original
361 "w" gnus-summary-wide-reply
362 "W" gnus-summary-wide-reply-with-original
363 "v" gnus-summary-very-wide-reply
364 "V" gnus-summary-very-wide-reply-with-original
365 "n" gnus-summary-followup-to-mail
366 "N" gnus-summary-followup-to-mail-with-original
367 "m" gnus-summary-mail-other-window
368 "u" gnus-uu-post-news
369 "\M-c" gnus-summary-mail-crosspost-complaint
370 "Br" gnus-summary-reply-broken-reply-to
371 "BR" gnus-summary-reply-broken-reply-to-with-original
372 "om" gnus-summary-mail-forward
373 "op" gnus-summary-post-forward
374 "Om" gnus-uu-digest-mail-forward
375 "Op" gnus-uu-digest-post-forward)
377 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
378 "b" gnus-summary-resend-bounced-mail
379 ;; "c" gnus-summary-send-draft
380 "r" gnus-summary-resend-message
381 "e" gnus-summary-resend-message-edit)
383 ;;; Internal functions.
385 (defun gnus-inews-make-draft ()
387 (gnus-inews-make-draft-meta-information
388 ,gnus-newsgroup-name ',gnus-article-reply)))
390 (defvar gnus-article-reply nil)
391 (defmacro gnus-setup-message (config &rest forms)
392 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
393 (buffer (make-symbol "gnus-setup-message-buffer"))
394 (article (make-symbol "gnus-setup-message-article"))
395 (yanked (make-symbol "gnus-setup-yanked-articles"))
396 (group (make-symbol "gnus-setup-message-group")))
397 `(let ((,winconf (current-window-configuration))
398 (,buffer (buffer-name (current-buffer)))
399 (,article gnus-article-reply)
400 (,yanked gnus-article-yanked-articles)
401 (,group gnus-newsgroup-name)
402 (message-header-setup-hook
403 (copy-sequence message-header-setup-hook))
404 (mbl mml-buffer-list)
405 (message-mode-hook (copy-sequence message-mode-hook)))
406 (setq mml-buffer-list nil)
407 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
408 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
409 ;; #### FIXME: for a reason that I did not manage to identify yet,
410 ;; the variable `gnus-newsgroup-name' does not honor a dynamically
411 ;; scoped or setq'ed value from a caller like `C-u gnus-summary-mail'.
412 ;; After evaluation of @forms below, it gets the value we actually want
413 ;; to override, and the posting styles are used. For that reason, I've
414 ;; added an optional argument to `gnus-configure-posting-styles' to
415 ;; make sure that the correct value for the group name is used. -- drv
416 (add-hook 'message-mode-hook
418 (gnus-configure-posting-styles ,group)))
419 (gnus-pull ',(intern gnus-draft-meta-information-header)
420 message-required-headers)
422 (not (string= ,group "")))
424 (intern gnus-draft-meta-information-header)
425 (gnus-inews-make-draft))
426 message-required-headers))
430 (gnus-inews-add-send-actions ,winconf ,buffer ,article ,config
432 (setq gnus-message-buffer (current-buffer))
433 (set (make-local-variable 'gnus-message-group-art)
434 (cons ,group ,article))
435 (set (make-local-variable 'gnus-newsgroup-name) ,group)
436 (gnus-run-hooks 'gnus-message-setup-hook)
437 (if (eq major-mode 'message-mode)
438 (let ((mbl1 mml-buffer-list))
439 (setq mml-buffer-list mbl) ;; Global value
440 (set (make-local-variable 'mml-buffer-list) mbl1);; Local value
441 ;; LOCAL argument of add-hook differs between GNU Emacs
442 ;; and XEmacs. make-local-hook makes sure they are local.
443 (make-local-hook 'kill-buffer-hook)
444 (make-local-hook 'change-major-mode-hook)
445 (add-hook 'change-major-mode-hook 'mml-destroy-buffers nil t)
446 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))
447 (mml-destroy-buffers)
448 (setq mml-buffer-list mbl)))
450 (gnus-configure-windows ,config t)
451 (run-hooks 'post-command-hook)
452 (set-buffer-modified-p nil))))
454 (defun gnus-inews-make-draft-meta-information (group article)
455 (concat "(\"" group "\" "
456 (if article (number-to-string
463 (defun gnus-msg-mail (&optional to subject other-headers continue
464 switch-action yank-action send-actions)
465 "Start editing a mail message to be sent.
466 Like `message-mail', but with Gnus paraphernalia, particularly the
467 Gcc: header for archiving purposes."
469 (let ((buf (current-buffer))
471 (gnus-setup-message 'message
472 (message-mail to subject other-headers continue
473 nil yank-action send-actions))
475 (setq mail-buf (current-buffer))
476 (switch-to-buffer buf)
477 (apply switch-action mail-buf nil)))
478 ;; COMPOSEFUNC should return t if succeed. Undocumented ???
481 (defvar save-selected-window-window)
484 (defun gnus-button-mailto (address)
486 (set-buffer (gnus-copy-article-buffer))
487 (gnus-setup-message 'message
488 (message-reply address))
489 (and (boundp 'save-selected-window-window)
490 (not (window-live-p save-selected-window-window))
491 (setq save-selected-window-window (selected-window))))
494 (defun gnus-button-reply (&optional to-address wide)
495 "Like `message-reply'."
497 (gnus-setup-message 'message
498 (message-reply to-address wide))
499 (and (boundp 'save-selected-window-window)
500 (not (window-live-p save-selected-window-window))
501 (setq save-selected-window-window (selected-window))))
504 (define-mail-user-agent 'gnus-user-agent
505 'gnus-msg-mail 'message-send-and-exit
506 'message-kill-buffer 'message-send-hook)
508 (defun gnus-setup-posting-charset (group)
509 (let ((alist gnus-group-posting-charset-alist)
510 (group (or group ""))
514 (while (setq elem (pop alist))
515 (when (or (and (stringp (car elem))
516 (string-match (car elem) group))
517 (and (gnus-functionp (car elem))
518 (funcall (car elem) group))
519 (and (symbolp (car elem))
520 (symbol-value (car elem))))
521 (throw 'found (cons (cadr elem) (caddr elem)))))))))
523 (defun gnus-inews-add-send-actions (winconf buffer article
524 &optional config yanked)
525 (make-local-hook 'message-sent-hook)
526 (add-hook 'message-sent-hook (if gnus-agent 'gnus-agent-possibly-do-gcc
527 'gnus-inews-do-gcc) nil t)
529 (make-local-hook 'message-header-hook)
530 (add-hook 'message-header-hook 'gnus-agent-possibly-save-gcc nil t))
531 (setq message-post-method
533 (gnus-post-method arg ,gnus-newsgroup-name)))
534 (setq message-newsreader (setq message-mailer (gnus-extended-version)))
536 `(set-window-configuration ,winconf) 'exit 'postpone 'kill)
537 (let ((to-be-marked (cond
539 (article (if (listp article) article (list article)))
542 `(when (gnus-buffer-exists-p ,buffer)
546 (if (eq config 'forward)
547 `(gnus-summary-mark-article-as-forwarded ',to-be-marked)
548 `(gnus-summary-mark-article-as-replied ',to-be-marked)))))
551 (put 'gnus-setup-message 'lisp-indent-function 1)
552 (put 'gnus-setup-message 'edebug-form-spec '(form body))
554 ;;; Post news commands of Gnus group mode and summary mode
556 (defun gnus-group-mail (&optional arg)
557 "Start composing a mail.
558 If ARG, use the group under the point to find a posting style.
559 If ARG is 1, prompt for a group name to find the posting style."
561 ;; We can't `let' gnus-newsgroup-name here, since that leads
562 ;; to local variables leaking.
563 (let ((group gnus-newsgroup-name)
564 ;; make sure last viewed article doesn't affect posting styles:
566 (buffer (current-buffer)))
569 (setq gnus-newsgroup-name
571 (if (= 1 (prefix-numeric-value arg))
572 (completing-read "Use posting style of group: "
573 gnus-active-hashtb nil
574 (gnus-read-active-file-p))
575 (gnus-group-group-name))
577 ;; #### see comment in gnus-setup-message -- drv
578 (gnus-setup-message 'message (message-mail)))
581 (setq gnus-newsgroup-name group)))))
583 (defun gnus-group-news (&optional arg)
584 "Start composing a news.
585 If ARG, post to group under point.
586 If ARG is 1, prompt for group name to post to.
588 This function prepares a news even when using mail groups. This is useful
589 for posting messages to mail groups without actually sending them over the
590 network. The corresponding backend must have a 'request-post method."
592 ;; We can't `let' gnus-newsgroup-name here, since that leads
593 ;; to local variables leaking.
594 (let ((group gnus-newsgroup-name)
595 ;; make sure last viewed article doesn't affect posting styles:
597 (buffer (current-buffer)))
600 (setq gnus-newsgroup-name
602 (if (= 1 (prefix-numeric-value arg))
603 (completing-read "Use group: "
604 gnus-active-hashtb nil
605 (gnus-read-active-file-p))
606 (gnus-group-group-name))
608 ;; #### see comment in gnus-setup-message -- drv
609 (gnus-setup-message 'message
610 (message-news (gnus-group-real-name gnus-newsgroup-name))))
613 (setq gnus-newsgroup-name group)))))
615 (defun gnus-group-post-news (&optional arg)
616 "Start composing a message (a news by default).
617 If ARG, post to group under point. If ARG is 1, prompt for group name.
618 Depending on the selected group, the message might be either a mail or
621 ;; Bind this variable here to make message mode hooks work ok.
622 (let ((gnus-newsgroup-name
624 (if (= 1 (prefix-numeric-value arg))
625 (completing-read "Newsgroup: " gnus-active-hashtb nil
626 (gnus-read-active-file-p))
627 (gnus-group-group-name))
629 ;; make sure last viewed article doesn't affect posting styles:
631 (gnus-post-news 'post gnus-newsgroup-name nil nil nil nil
632 (string= gnus-newsgroup-name ""))))
634 (defun gnus-summary-mail-other-window (&optional arg)
635 "Start composing a mail in another window.
636 Use the posting of the current group by default.
637 If ARG, don't do that. If ARG is 1, prompt for group name to find the
640 ;; We can't `let' gnus-newsgroup-name here, since that leads
641 ;; to local variables leaking.
642 (let ((group gnus-newsgroup-name)
643 ;; make sure last viewed article doesn't affect posting styles:
645 (buffer (current-buffer)))
648 (setq gnus-newsgroup-name
650 (if (= 1 (prefix-numeric-value arg))
651 (completing-read "Use group: "
652 gnus-active-hashtb nil
653 (gnus-read-active-file-p))
655 gnus-newsgroup-name))
656 ;; #### see comment in gnus-setup-message -- drv
657 (gnus-setup-message 'message (message-mail)))
660 (setq gnus-newsgroup-name group)))))
662 (defun gnus-summary-news-other-window (&optional arg)
663 "Start composing a news in another window.
664 Post to the current group by default.
665 If ARG, don't do that. If ARG is 1, prompt for group name to post to.
667 This function prepares a news even when using mail groups. This is useful
668 for posting messages to mail groups without actually sending them over the
669 network. The corresponding backend must have a 'request-post method."
671 ;; We can't `let' gnus-newsgroup-name here, since that leads
672 ;; to local variables leaking.
673 (let ((group gnus-newsgroup-name)
674 ;; make sure last viewed article doesn't affect posting styles:
676 (buffer (current-buffer)))
679 (setq gnus-newsgroup-name
681 (if (= 1 (prefix-numeric-value arg))
682 (completing-read "Use group: "
683 gnus-active-hashtb nil
684 (gnus-read-active-file-p))
686 gnus-newsgroup-name))
687 ;; #### see comment in gnus-setup-message -- drv
688 (gnus-setup-message 'message
689 (message-news (gnus-group-real-name gnus-newsgroup-name))))
692 (setq gnus-newsgroup-name group)))))
694 (defun gnus-summary-post-news (&optional arg)
695 "Start composing a message. Post to the current group by default.
696 If ARG, don't do that. If ARG is 1, prompt for a group name to post to.
697 Depending on the selected group, the message might be either a mail or
700 ;; Bind this variable here to make message mode hooks work ok.
701 (let ((gnus-newsgroup-name
703 (if (= 1 (prefix-numeric-value arg))
704 (completing-read "Newsgroup: " gnus-active-hashtb nil
705 (gnus-read-active-file-p))
707 gnus-newsgroup-name))
708 ;; make sure last viewed article doesn't affect posting styles:
710 (gnus-post-news 'post gnus-newsgroup-name)))
713 (defun gnus-summary-followup (yank &optional force-news)
714 "Compose a followup to an article.
715 If prefix argument YANK is non-nil, the original article is yanked
717 YANK is a list of elements, where the car of each element is the
718 article number, and the two following numbers is the region to be
721 (list (and current-prefix-arg
722 (gnus-summary-work-articles 1))))
724 (gnus-summary-goto-subject
725 (if (listp (car yank))
728 (save-window-excursion
729 (gnus-summary-select-article))
730 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
731 (gnus-newsgroup-name gnus-newsgroup-name))
733 (gnus-post-news nil gnus-newsgroup-name
734 headers gnus-article-buffer
736 (gnus-summary-handle-replysign)))
738 (defun gnus-summary-followup-with-original (n &optional force-news)
739 "Compose a followup to an article and include the original article."
741 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
743 (defun gnus-summary-followup-to-mail (&optional arg)
744 "Followup to the current mail message via news."
746 (list (and current-prefix-arg
747 (gnus-summary-work-articles 1))))
748 (gnus-summary-followup arg t))
750 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
751 "Followup to the current mail message via news."
753 (gnus-summary-followup (gnus-summary-work-articles arg) t))
755 (defun gnus-inews-yank-articles (articles)
756 (let (beg article yank-string)
758 (while (setq article (pop articles))
759 (when (listp article)
760 (setq yank-string (nth 1 article)
761 article (nth 0 article)))
762 (save-window-excursion
763 (set-buffer gnus-summary-buffer)
764 (gnus-summary-select-article nil nil nil article)
765 (gnus-summary-remove-process-mark article))
766 (gnus-copy-article-buffer nil yank-string)
767 (let ((message-reply-buffer gnus-article-copy)
768 (message-reply-headers
769 ;; The headers are decoded.
770 (with-current-buffer gnus-article-copy
772 (nnheader-narrow-to-headers)
773 (nnheader-parse-naked-head)))))
774 (message-yank-original)
775 (setq beg (or beg (mark t))))
781 (defun gnus-summary-cancel-article (&optional n symp)
782 "Cancel an article you posted.
783 Uses the process-prefix convention. If given the symbolic
784 prefix `a', cancel using the standard posting method; if not
785 post using the current select method."
786 (interactive (gnus-interactive "P\ny"))
787 (let ((articles (gnus-summary-work-articles n))
790 (gnus-post-method (eq ',symp 'a) ,gnus-newsgroup-name)))
792 (while (setq article (pop articles))
793 (when (gnus-summary-select-article t nil nil article)
794 (when (gnus-eval-in-buffer-window gnus-original-article-buffer
795 (message-cancel-news))
796 (gnus-summary-mark-as-read article gnus-canceled-mark)
797 (gnus-cache-remove-article 1))
798 (gnus-article-hide-headers-if-wanted))
799 (gnus-summary-remove-process-mark article))))
801 (defun gnus-summary-supersede-article ()
802 "Compose an article that will supersede a previous article.
803 This is done simply by taking the old article and adding a Supersedes
804 header line with the old Message-ID."
806 (let ((article (gnus-summary-article-number)))
807 (gnus-setup-message 'reply-yank
808 (gnus-summary-select-article t)
809 (set-buffer gnus-original-article-buffer)
813 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
815 (set-buffer ,gnus-summary-buffer)
816 (gnus-cache-possibly-remove-article ,article nil nil nil t)
817 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
818 message-send-actions))))
822 (defun gnus-copy-article-buffer (&optional article-buffer yank-string)
823 ;; make a copy of the article buffer with all text properties removed
824 ;; this copy is in the buffer gnus-article-copy.
825 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
826 ;; this buffer should be passed to all mail/news reply/post routines.
827 (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
829 (set-buffer gnus-article-copy)
830 (mm-enable-multibyte))
831 (let ((article-buffer (or article-buffer gnus-article-buffer))
833 (if (not (and (get-buffer article-buffer)
834 (gnus-buffer-exists-p article-buffer)))
835 (error "Can't find any article buffer")
837 (set-buffer article-buffer)
838 (let ((gnus-newsgroup-charset (or gnus-article-charset
839 gnus-newsgroup-charset))
840 (gnus-newsgroup-ignored-charsets
841 (or gnus-article-ignored-charsets
842 gnus-newsgroup-ignored-charsets)))
844 ;; Copy over the (displayed) article buffer, delete
845 ;; hidden text and remove text properties.
847 (copy-to-buffer gnus-article-copy (point-min) (point-max))
848 (set-buffer gnus-article-copy)
851 (delete-region (point) (point-max))
852 (insert yank-string))
853 (gnus-article-delete-text-of-type 'annotation)
854 (gnus-remove-text-with-property 'gnus-prev)
855 (gnus-remove-text-with-property 'gnus-next)
856 (gnus-remove-text-with-property 'gnus-decoration)
859 (buffer-substring-no-properties (point-min) (point-max))
861 ;; Find the original headers.
862 (set-buffer gnus-original-article-buffer)
863 (goto-char (point-min))
864 (while (looking-at message-unix-mail-delimiter)
866 (let ((mail-header-separator ""))
868 end (or (message-goto-body)
869 ;; There may be just a header.
871 ;; Delete the headers from the displayed articles.
872 (set-buffer gnus-article-copy)
873 (let ((mail-header-separator ""))
874 (delete-region (goto-char (point-min))
875 (or (message-goto-body) (point-max))))
876 ;; Insert the original article headers.
877 (insert-buffer-substring gnus-original-article-buffer beg end)
879 (let ((gnus-article-decode-hook
880 (delq 'article-decode-charset
881 (copy-sequence gnus-article-decode-hook))))
882 (run-hooks 'gnus-article-decode-hook)))))
885 (defun gnus-post-news (post &optional group header article-buffer yank subject
888 (gnus-copy-article-buffer))
889 (let ((gnus-article-reply (and article-buffer (gnus-summary-article-number)))
890 (gnus-article-yanked-articles yank)
891 (add-to-list gnus-add-to-list))
892 (gnus-setup-message (cond (yank 'reply-yank)
893 (article-buffer 'reply)
895 (let* ((group (or group gnus-newsgroup-name))
896 (charset (gnus-group-name-charset nil group))
898 to-address to-group mailing-list to-list
901 (setq to-address (gnus-parameter-to-address group)
902 to-group (gnus-group-find-parameter group 'to-group)
903 to-list (gnus-parameter-to-list group)
904 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
905 mailing-list (when gnus-mailing-list-groups
906 (string-match gnus-mailing-list-groups group))
907 group (gnus-group-name-decode (gnus-group-real-name group)
909 (if (or (and to-group
910 (gnus-news-group-p to-group))
913 (and (gnus-news-group-p
914 (or pgroup gnus-newsgroup-name)
915 (or header gnus-current-article))
921 (message-news (or to-group group))
922 (set-buffer gnus-article-copy)
923 (gnus-msg-treat-broken-reply-to)
924 (message-followup (if (or newsgroup-p force-news)
925 (if (save-restriction
926 (article-narrow-to-head)
927 (message-fetch-field "newsgroups"))
934 (message-mail (or to-address to-list))
935 ;; Arrange for mail groups that have no `to-address' to
936 ;; get that when the user sends off the mail.
937 (when (and (not to-list)
940 (push (list 'gnus-inews-add-to-address pgroup)
941 message-send-actions)))
942 (set-buffer gnus-article-copy)
943 (gnus-msg-treat-broken-reply-to)
944 (message-wide-reply to-address)))
946 (gnus-inews-yank-articles yank))))))
948 (defun gnus-msg-treat-broken-reply-to (&optional force)
949 "Remove the Reply-to header if broken-reply-to."
951 (gnus-group-find-parameter
952 gnus-newsgroup-name 'broken-reply-to))
954 (message-narrow-to-head)
955 (message-remove-header "reply-to"))))
957 (defun gnus-post-method (arg group &optional silent)
958 "Return the posting method based on GROUP and ARG.
959 If SILENT, don't prompt the user."
960 (let ((gnus-post-method (or (gnus-parameter-post-method group)
962 (group-method (gnus-find-method-for-group group)))
964 ;; If the group-method is nil (which shouldn't happen) we use
965 ;; the default method.
967 (or (and (listp gnus-post-method) ;If not current/native/nil
968 (not (listp (car gnus-post-method))) ; and not a list of methods
969 gnus-post-method) ;then use it.
971 message-post-method))
972 ;; We want the inverse of the default
973 ((and arg (not (eq arg 0)))
974 (if (eq gnus-post-method 'current)
977 ;; We query the user for a post method.
979 (and (listp gnus-post-method)
980 (listp (car gnus-post-method))))
982 ;; Collect all methods we know about.
984 (when (listp gnus-post-method)
985 (if (listp (car gnus-post-method))
987 (list gnus-post-method)))
988 gnus-secondary-select-methods
989 (mapcar 'cdr gnus-server-alist)
990 (mapcar 'car gnus-opened-servers)
991 (list gnus-select-method)
992 (list group-method)))
993 method-alist post-methods method)
994 ;; Weed out all mail methods.
996 (setq method (gnus-server-get-method "" (pop methods)))
997 (when (and (or (gnus-method-option-p method 'post)
998 (gnus-method-option-p method 'post-mail))
999 (not (member method post-methods)))
1000 (push method post-methods)))
1001 ;; Create a name-method alist.
1005 (if (equal (cadr m) "")
1006 (list (symbol-name (car m)) m)
1007 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m)))
1012 (setq gnus-last-posting-server
1014 gnus-last-posting-server)
1015 ;; Just use the last value.
1016 gnus-last-posting-server
1018 "Posting method: " method-alist nil t
1019 (cons (or gnus-last-posting-server "") 0))))
1021 ;; Override normal method.
1022 ((and (eq gnus-post-method 'current)
1023 (not (memq (car group-method) gnus-discouraged-post-methods))
1024 (gnus-get-function group-method 'request-post t))
1027 ;; Use gnus-post-method.
1028 ((listp gnus-post-method) ;A method...
1029 (assert (not (listp (car gnus-post-method)))) ;... not a list of methods.
1031 ;; Use the normal select method (nil or native).
1032 (t gnus-select-method))))
1036 ;; Dummies to avoid byte-compile warning.
1038 (defvar nnspool-rejected-article-hook)
1039 (defvar xemacs-codename))
1041 (defun gnus-extended-version ()
1042 "Stringified Gnus version and Emacs version.
1043 See the variable `gnus-user-agent'."
1047 (prin1-to-string (gnus-continuum-version gnus-version) t)
1048 " (" gnus-version ")"))
1051 ((eq gnus-user-agent 'full)
1052 system-configuration)
1053 ((eq gnus-user-agent 'emacs-gnus-type)
1054 (symbol-name system-type))
1058 ((eq gnus-user-agent 'gnus)
1060 ((string-match "^\\(\\([.0-9]+\\)*\\)\\.[0-9]+$" emacs-version)
1061 (concat "Emacs/" (match-string 1 emacs-version)
1063 (concat " (" system-v ")")
1066 "\\([A-Z]*[Mm][Aa][Cc][Ss]\\)[^(]*\\(\\((beta.*)\\|'\\)\\)?"
1069 (match-string 1 emacs-version)
1070 (format "/%d.%d" emacs-major-version emacs-minor-version)
1071 (if (match-beginning 3)
1072 (match-string 3 emacs-version)
1074 (if (boundp 'xemacs-codename)
1076 " (" xemacs-codename
1078 (concat ", " system-v ")")
1081 (t emacs-version))))
1082 (if (stringp gnus-user-agent)
1086 (concat " " emacs-v))))))
1090 ;;; Gnus Mail Functions
1093 ;;; Mail reply commands of Gnus summary mode
1095 (defun gnus-summary-reply (&optional yank wide very-wide)
1096 "Start composing a mail reply to the current message.
1097 If prefix argument YANK is non-nil, the original article is yanked
1099 If WIDE, make a wide reply.
1100 If VERY-WIDE, make a very wide reply."
1102 (list (and current-prefix-arg
1103 (gnus-summary-work-articles 1))))
1104 ;; Allow user to require confirmation before replying by mail to the
1105 ;; author of a news article (or mail message).
1107 (not (or (gnus-news-group-p gnus-newsgroup-name)
1108 gnus-confirm-treat-mail-like-news))
1109 (not (cond ((stringp gnus-confirm-mail-reply-to-news)
1110 (string-match gnus-confirm-mail-reply-to-news
1111 gnus-newsgroup-name))
1112 ((functionp gnus-confirm-mail-reply-to-news)
1113 (funcall gnus-confirm-mail-reply-to-news gnus-newsgroup-name))
1114 (t gnus-confirm-mail-reply-to-news)))
1115 (y-or-n-p "Really reply by mail to article author? "))
1117 (if (listp (car yank))
1120 (gnus-article-reply (or article (gnus-summary-article-number)))
1121 (gnus-article-yanked-articles yank)
1123 ;; Stripping headers should be specified with mail-yank-ignored-headers.
1125 (gnus-summary-goto-subject article))
1126 (gnus-setup-message (if yank 'reply-yank 'reply)
1128 (gnus-summary-select-article)
1129 (dolist (article very-wide)
1130 (gnus-summary-select-article nil nil nil article)
1132 (set-buffer (gnus-copy-article-buffer))
1133 (gnus-msg-treat-broken-reply-to)
1135 (message-narrow-to-head)
1136 (setq headers (concat headers (buffer-string)))))))
1137 (set-buffer (gnus-copy-article-buffer))
1138 (gnus-msg-treat-broken-reply-to gnus-msg-force-broken-reply-to)
1140 (message-narrow-to-head)
1144 (goto-char (point-max)))
1145 (mml-quote-region (point) (point-max))
1146 (message-reply nil wide)
1148 (gnus-inews-yank-articles yank))
1149 (gnus-summary-handle-replysign)))))
1151 (defun gnus-summary-handle-replysign ()
1152 "Check the various replysign variables and take action accordingly."
1153 (when (or gnus-message-replysign gnus-message-replyencrypt)
1154 (let (signed encrypted)
1156 (set-buffer gnus-article-buffer)
1157 (setq signed (memq 'signed gnus-article-wash-types))
1158 (setq encrypted (memq 'encrypted gnus-article-wash-types)))
1159 (cond ((and gnus-message-replyencrypt encrypted)
1160 (mml-secure-message mml-default-encrypt-method
1161 (if gnus-message-replysignencrypted
1164 ((and gnus-message-replysign signed)
1165 (mml-secure-message mml-default-sign-method 'sign))))))
1167 (defun gnus-summary-reply-with-original (n &optional wide)
1168 "Start composing a reply mail to the current message.
1169 The original article will be yanked."
1171 (gnus-summary-reply (gnus-summary-work-articles n) wide))
1173 (defun gnus-summary-reply-broken-reply-to (&optional yank wide very-wide)
1174 "Like `gnus-summary-reply' except removing reply-to field.
1175 If prefix argument YANK is non-nil, the original article is yanked
1177 If WIDE, make a wide reply.
1178 If VERY-WIDE, make a very wide reply."
1180 (list (and current-prefix-arg
1181 (gnus-summary-work-articles 1))))
1182 (let ((gnus-msg-force-broken-reply-to t))
1183 (gnus-summary-reply yank wide very-wide)))
1185 (defun gnus-summary-reply-broken-reply-to-with-original (n &optional wide)
1186 "Like `gnus-summary-reply-with-original' except removing reply-to field.
1187 The original article will be yanked."
1189 (gnus-summary-reply-broken-reply-to (gnus-summary-work-articles n) wide))
1191 (defun gnus-summary-wide-reply (&optional yank)
1192 "Start composing a wide reply mail to the current message.
1193 If prefix argument YANK is non-nil, the original article is yanked
1196 (list (and current-prefix-arg
1197 (gnus-summary-work-articles 1))))
1198 (gnus-summary-reply yank t))
1200 (defun gnus-summary-wide-reply-with-original (n)
1201 "Start composing a wide reply mail to the current message.
1202 The original article will be yanked."
1204 (gnus-summary-reply-with-original n t))
1206 (defun gnus-summary-very-wide-reply (&optional yank)
1207 "Start composing a very wide reply mail to the current message.
1208 If prefix argument YANK is non-nil, the original article is yanked
1211 (list (and current-prefix-arg
1212 (gnus-summary-work-articles 1))))
1213 (gnus-summary-reply yank t (gnus-summary-work-articles yank)))
1215 (defun gnus-summary-very-wide-reply-with-original (n)
1216 "Start composing a very wide reply mail to the current message.
1217 The original article will be yanked."
1220 (gnus-summary-work-articles n) t (gnus-summary-work-articles n)))
1222 (defun gnus-summary-mail-forward (&optional arg post)
1223 "Forward the current message(s) to another user.
1224 If process marks exist, forward all marked messages;
1225 if ARG is nil, see `message-forward-as-mime' and `message-forward-show-mml';
1226 if ARG is 1, decode the message and forward directly inline;
1227 if ARG is 2, forward message as an rfc822 MIME section;
1228 if ARG is 3, decode message and forward as an rfc822 MIME section;
1229 if ARG is 4, forward message directly inline;
1230 otherwise, use flipped `message-forward-as-mime'.
1231 If POST, post instead of mail.
1232 For the `inline' alternatives, also see the variable
1233 `message-forward-ignored-headers'."
1235 (if (cdr (gnus-summary-work-articles nil))
1236 ;; Process marks are given.
1237 (gnus-uu-digest-mail-forward arg post)
1238 ;; No process marks.
1239 (let ((message-forward-as-mime message-forward-as-mime)
1240 (message-forward-show-mml message-forward-show-mml))
1244 (setq message-forward-as-mime nil
1245 message-forward-show-mml t))
1247 (setq message-forward-as-mime t
1248 message-forward-show-mml nil))
1250 (setq message-forward-as-mime t
1251 message-forward-show-mml t))
1253 (setq message-forward-as-mime nil
1254 message-forward-show-mml nil))
1256 (setq message-forward-as-mime (not message-forward-as-mime))))
1257 (let* ((gnus-article-reply (gnus-summary-article-number))
1258 (gnus-article-yanked-articles (list gnus-article-reply)))
1259 (gnus-setup-message 'forward
1260 (gnus-summary-select-article)
1261 (let ((mail-parse-charset
1262 (or (and (gnus-buffer-live-p gnus-article-buffer)
1263 (with-current-buffer gnus-article-buffer
1264 gnus-article-charset))
1265 gnus-newsgroup-charset))
1266 (mail-parse-ignored-charsets
1267 gnus-newsgroup-ignored-charsets))
1268 (set-buffer gnus-original-article-buffer)
1269 (message-forward post)))))))
1271 (defun gnus-summary-resend-message (address n)
1272 "Resend the current article to ADDRESS."
1274 (list (message-read-from-minibuffer
1275 "Resend message(s) to: "
1276 (when (and gnus-summary-resend-default-address
1277 (gnus-buffer-live-p gnus-original-article-buffer))
1278 ;; If some other article is currently selected, the
1279 ;; initial-contents is wrong. Whatever, it is just the
1280 ;; initial-contents.
1281 (with-current-buffer gnus-original-article-buffer
1282 (nnmail-fetch-field "to"))))
1283 current-prefix-arg))
1284 (let ((articles (gnus-summary-work-articles n))
1286 (while (setq article (pop articles))
1287 (gnus-summary-select-article nil nil nil article)
1289 (set-buffer gnus-original-article-buffer)
1290 (message-resend address))
1291 (gnus-summary-mark-article-as-forwarded article))))
1293 ;; From: Matthieu Moy <Matthieu.Moy@imag.fr>
1294 (defun gnus-summary-resend-message-edit ()
1295 "Resend an article that has already been sent.
1296 A new buffer will be created to allow the user to modify body and
1297 contents of the message, and then, everything will happen as when
1298 composing a new message."
1300 (let ((article (gnus-summary-article-number)))
1301 (gnus-setup-message 'reply-yank
1302 (gnus-summary-select-article t)
1303 (set-buffer gnus-original-article-buffer)
1304 (let ((cur (current-buffer))
1305 (to (message-fetch-field "to")))
1306 ;; Get a normal message buffer.
1307 (message-pop-to-buffer (message-buffer-name "Resend" to))
1308 (insert-buffer-substring cur)
1310 (message-narrow-to-head-1)
1311 ;; Gnus will generate a new one when sending.
1312 (message-remove-header "Message-ID")
1313 (message-remove-header message-ignored-resent-headers t)
1314 ;; Remove unwanted headers.
1315 (goto-char (point-max))
1316 (insert mail-header-separator)
1317 (goto-char (point-min))
1318 (re-search-forward "^To:\\|^Newsgroups:" nil 'move)
1322 (defun gnus-summary-post-forward (&optional arg)
1323 "Forward the current article to a newsgroup.
1324 See `gnus-summary-mail-forward' for ARG."
1326 (gnus-summary-mail-forward arg t))
1328 (defvar gnus-nastygram-message
1329 "The following article was inappropriately posted to %s.\n\n"
1330 "Format string to insert in nastygrams.
1331 The current group name will be inserted at \"%s\".")
1333 (defun gnus-summary-mail-nastygram (n)
1334 "Send a nastygram to the author of the current article."
1336 (when (or gnus-expert-user
1338 "Really send a nastygram to the author of the current article? "))
1339 (let ((group gnus-newsgroup-name))
1340 (gnus-summary-reply-with-original n)
1341 (set-buffer gnus-message-buffer)
1343 (insert (format gnus-nastygram-message group))
1344 (message-send-and-exit))))
1346 (defun gnus-summary-mail-crosspost-complaint (n)
1347 "Send a complaint about crossposting to the current article(s)."
1349 (let ((articles (gnus-summary-work-articles n))
1351 (while (setq article (pop articles))
1352 (set-buffer gnus-summary-buffer)
1353 (gnus-summary-goto-subject article)
1354 (let ((group (gnus-group-real-name gnus-newsgroup-name))
1355 newsgroups followup-to)
1356 (gnus-summary-select-article)
1357 (set-buffer gnus-original-article-buffer)
1358 (if (and (<= (length (message-tokenize-header
1360 (mail-fetch-field "newsgroups"))
1363 (or (not (setq followup-to (mail-fetch-field "followup-to")))
1364 (not (member group (message-tokenize-header
1365 followup-to ", ")))))
1367 (gnus-message 1 "Followup-to restricted")
1368 (gnus-message 1 "Not a crossposted article"))
1369 (set-buffer gnus-summary-buffer)
1370 (gnus-summary-reply-with-original 1)
1371 (set-buffer gnus-message-buffer)
1373 (insert (format gnus-crosspost-complaint newsgroups group))
1374 (message-goto-subject)
1375 (re-search-forward " *$")
1376 (replace-match " (crosspost notification)" t t)
1377 (gnus-deactivate-mark)
1378 (when (gnus-y-or-n-p "Send this complaint? ")
1379 (message-send-and-exit)))))))
1381 (defun gnus-mail-parse-comma-list ()
1384 (skip-chars-forward " ")
1387 (skip-chars-forward "^,")
1392 (narrow-to-region beg (point))
1395 (while (search-forward "\"" nil t)
1399 (skip-chars-forward ",")
1400 (skip-chars-forward "^,"))
1401 (skip-chars-backward " ")
1402 (push (buffer-substring beg (point))
1404 (skip-chars-forward "^,")
1405 (skip-chars-forward ", "))
1408 (defun gnus-inews-add-to-address (group)
1409 (let ((to-address (mail-fetch-field "to")))
1410 (when (and to-address
1412 ;; This mail group doesn't have a `to-list', so we add one
1414 (when (gnus-y-or-n-p
1415 (format "Do you want to add this as `to-list': %s " to-address))
1416 (gnus-group-add-parameter group (cons 'to-list to-address))))))
1418 (defun gnus-put-message ()
1419 "Put the current message in some group and return to Gnus."
1421 (let ((reply gnus-article-reply)
1422 (winconf gnus-prev-winconf)
1423 (group gnus-newsgroup-name))
1425 (not (gnus-group-read-only-p group)))
1426 (setq group (read-string "Put in group: " nil (gnus-writable-groups))))
1428 (when (gnus-gethash group gnus-newsrc-hashtb)
1429 (error "No such group: %s" group))
1433 (message-narrow-to-headers)
1434 (let ((gnus-deletable-headers nil))
1435 (message-generate-headers
1436 (if (message-news-p)
1437 message-required-news-headers
1438 message-required-mail-headers)))
1439 (goto-char (point-max))
1440 (if (string-match " " group)
1441 (insert "Gcc: \"" group "\"\n")
1442 (insert "Gcc: " group "\n"))
1445 (when (and (get-buffer gnus-group-buffer)
1446 (gnus-buffer-exists-p (car-safe reply))
1448 (set-buffer (car reply))
1449 (gnus-summary-mark-article-as-replied (cdr reply)))
1451 (set-window-configuration winconf))))
1453 (defun gnus-article-mail (yank)
1454 "Send a reply to the address near point.
1455 If YANK is non-nil, include the original article."
1459 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
1460 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
1462 (gnus-msg-mail address)
1464 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
1466 (defvar nntp-server-type)
1468 "Send a bug report to the Gnus maintainers."
1470 (unless (gnus-alive-p)
1471 (error "Gnus has been shut down"))
1472 (gnus-setup-message (if (message-mail-user-agent) 'message 'bug)
1473 (unless (message-mail-user-agent)
1474 (delete-other-windows)
1475 (when gnus-bug-create-help-buffer
1476 (switch-to-buffer "*Gnus Help Bug*")
1478 (insert gnus-bug-message)
1479 (goto-char (point-min)))
1480 (message-pop-to-buffer "*Gnus Bug*"))
1481 (let ((message-this-is-mail t))
1482 (message-setup `((To . ,gnus-maintainer) (Subject . ""))))
1483 (when gnus-bug-create-help-buffer
1484 (push `(gnus-bug-kill-buffer) message-send-actions))
1485 (goto-char (point-min))
1486 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
1488 (insert (gnus-version) "\n"
1489 (emacs-version) "\n")
1490 (when (and (boundp 'nntp-server-type)
1491 (stringp nntp-server-type))
1492 (insert nntp-server-type))
1493 (insert "\n\n\n\n\n")
1496 (set-buffer (gnus-get-buffer-create " *gnus environment info*"))
1499 (setq text (buffer-string)))
1500 (insert "<#part type=application/emacs-lisp disposition=inline description=\"User settings\">\n" text "\n<#/part>"))
1501 (goto-char (point-min))
1502 (search-forward "Subject: " nil t)
1505 (defun gnus-bug-kill-buffer ()
1506 (when (get-buffer "*Gnus Help Bug*")
1507 (kill-buffer "*Gnus Help Bug*")))
1509 (defun gnus-summary-yank-message (buffer n)
1510 "Yank the current article into a composed message."
1512 (list (completing-read "Buffer: " (mapcar 'list (message-buffers)) nil t)
1513 current-prefix-arg))
1514 (gnus-summary-iterate n
1515 (let ((gnus-display-mime-function nil)
1516 (gnus-inhibit-treatment t))
1517 (gnus-summary-select-article))
1520 (message-yank-buffer gnus-article-buffer))))
1522 (defun gnus-debug ()
1523 "Attempts to go through the Gnus source file and report what variables have been changed.
1524 The source file has to be in the Emacs load path."
1526 (let ((files gnus-debug-files)
1528 file expr olist sym)
1529 (gnus-message 4 "Please wait while we snoop your variables...")
1531 ;; Go through all the files looking for non-default values for variables.
1533 (set-buffer (gnus-get-buffer-create " *gnus bug info*"))
1536 (when (and (setq file (locate-library (pop files)))
1537 (file-exists-p file))
1538 (insert-file-contents file)
1539 (goto-char (point-min))
1540 (if (not (re-search-forward "^;;* *Internal variables" nil t))
1541 (gnus-message 4 "Malformed sources in file %s" file)
1542 (narrow-to-region (point-min) (point))
1543 (goto-char (point-min))
1544 (while (setq expr (ignore-errors (read (current-buffer))))
1546 (and (or (eq (car expr) 'defvar)
1547 (eq (car expr) 'defcustom))
1548 (stringp (nth 3 expr))
1549 (not (memq (nth 1 expr) gnus-debug-exclude-variables))
1550 (or (not (boundp (nth 1 expr)))
1551 (not (equal (eval (nth 2 expr))
1552 (symbol-value (nth 1 expr)))))
1553 (push (nth 1 expr) olist)))))))
1554 (kill-buffer (current-buffer)))
1555 (when (setq olist (nreverse olist))
1556 (insert "------------------ Environment follows ------------------\n\n"))
1558 (if (boundp (car olist))
1560 (pp `(setq ,(car olist)
1561 ,(if (or (consp (setq sym (symbol-value (car olist))))
1563 (not (or (eq sym nil)
1565 (list 'quote (symbol-value (car olist)))
1566 (symbol-value (car olist))))
1568 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
1569 (setq olist (cdr olist)))
1571 ;; Remove any control chars - they seem to cause trouble for some
1572 ;; mailers. (Byte-compiled output from the stuff above.)
1574 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
1575 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
1578 ;;; Treatment of rejected articles.
1581 (defun gnus-summary-resend-bounced-mail (&optional fetch)
1582 "Re-mail the current message.
1583 This only makes sense if the current message is a bounce message than
1584 contains some mail you have written which has been bounced back to
1586 If FETCH, try to fetch the article that this is a reply to, if indeed
1589 (gnus-summary-select-article t)
1590 (set-buffer gnus-original-article-buffer)
1591 (gnus-setup-message 'compose-bounce
1592 (let* ((references (mail-fetch-field "references"))
1593 (parent (and references (gnus-parent-id references))))
1595 ;; If there are references, we fetch the article we answered to.
1597 (gnus-summary-refer-article parent)
1598 (gnus-summary-show-all-headers)))))
1602 (defun gnus-inews-group-method (group)
1604 ;; If the group doesn't exist, we assume
1605 ;; it's an archive group...
1606 ((and (null (gnus-get-info group))
1607 (eq (car (gnus-server-to-method gnus-message-archive-method))
1608 (car (gnus-server-to-method (gnus-group-method group)))))
1609 gnus-message-archive-method)
1611 ((gnus-info-method (gnus-get-info group))
1612 (gnus-info-method (gnus-get-info group)))
1614 (t (gnus-server-to-method (gnus-group-method group)))))
1616 ;; Do Gcc handling, which copied the message over to some group.
1617 (defun gnus-inews-do-gcc (&optional gcc)
1621 (message-narrow-to-headers)
1622 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
1623 (cur (current-buffer))
1624 groups group method group-art
1625 mml-externalize-attachments)
1627 (message-remove-header "gcc")
1629 (setq groups (message-unquote-tokens
1630 (message-tokenize-header gcc " ,")))
1631 ;; Copy the article over to some group(s).
1632 (while (setq group (pop groups))
1633 (unless (gnus-check-server
1634 (setq method (gnus-inews-group-method group)))
1635 (error "Can't open server %s" (if (stringp method) method
1637 (unless (gnus-request-group group nil method)
1638 (gnus-request-create-group group method))
1639 (setq mml-externalize-attachments
1640 (if (stringp gnus-gcc-externalize-attachments)
1641 (string-match gnus-gcc-externalize-attachments group)
1642 gnus-gcc-externalize-attachments))
1644 (nnheader-set-temp-buffer " *acc*")
1645 (insert-buffer-substring cur)
1646 (message-encode-message-body)
1648 (message-narrow-to-headers)
1649 (let* ((mail-parse-charset message-default-charset)
1650 (newsgroups-field (save-restriction
1651 (message-narrow-to-headers-or-head)
1652 (message-fetch-field "Newsgroups")))
1653 (followup-field (save-restriction
1654 (message-narrow-to-headers-or-head)
1655 (message-fetch-field "Followup-To")))
1656 ;; BUG: We really need to get the charset for
1657 ;; each name in the Newsgroups and Followup-To
1658 ;; lines to allow crossposting between group
1659 ;; namess with incompatible character sets.
1660 ;; -- Per Abrahamsen <abraham@dina.kvl.dk> 2001-10-08.
1661 (group-field-charset
1662 (gnus-group-name-charset
1663 method (or newsgroups-field "")))
1664 (followup-field-charset
1665 (gnus-group-name-charset
1666 method (or followup-field "")))
1667 (rfc2047-header-encoding-alist
1669 (when group-field-charset
1670 (list (cons "Newsgroups" group-field-charset)))
1671 (when followup-field-charset
1672 (list (cons "Followup-To" followup-field-charset)))
1673 rfc2047-header-encoding-alist)))
1674 (mail-encode-encoded-word-buffer)))
1675 (goto-char (point-min))
1676 (when (re-search-forward
1677 (concat "^" (regexp-quote mail-header-separator) "$")
1679 (replace-match "" t t ))
1680 (unless (setq group-art
1681 (gnus-request-accept-article group method t t))
1682 (gnus-message 1 "Couldn't store article in group %s: %s"
1683 group (gnus-status-message method))
1685 (when (and group-art
1686 ;; FIXME: Should gcc-mark-as-read work when
1687 ;; Gnus is not running?
1689 (or gnus-gcc-mark-as-read
1690 gnus-inews-mark-gcc-as-read))
1691 (gnus-group-mark-article-read group (cdr group-art)))
1692 (kill-buffer (current-buffer)))))))))
1694 (defun gnus-inews-insert-gcc ()
1695 "Insert Gcc headers based on `gnus-outgoing-message-group'."
1698 (message-narrow-to-headers)
1699 (let* ((group gnus-outgoing-message-group)
1701 ((gnus-functionp group)
1703 ((or (stringp group) (list group))
1708 (if (string-match " " gcc)
1709 (concat "\"" gcc "\"")
1711 (mapconcat (lambda (group)
1712 (if (string-match " " group)
1713 (concat "\"" group "\"")
1718 (defun gnus-inews-insert-archive-gcc (&optional group)
1719 "Insert the Gcc to say where the article is to be archived."
1720 (let* ((var gnus-message-archive-group)
1721 (group (or group gnus-newsgroup-name ""))
1723 (and gnus-newsgroup-name
1724 (not (equal gnus-newsgroup-name ""))
1725 (gnus-group-find-parameter
1726 gnus-newsgroup-name 'gcc-self)))
1730 ((null gnus-message-archive-method)
1734 ;; Just a single group.
1737 ;; We don't want this.
1739 ((and (listp var) (stringp (car var)))
1740 ;; A list of groups.
1742 ((gnus-functionp var)
1744 (funcall var group))
1746 ;; An alist of regexps/functions/forms.
1751 ((stringp (caar var))
1753 (when (string-match (caar var) group)
1755 ((gnus-functionp (car var))
1757 (funcall (car var) group))
1759 (eval (car var)))))))
1760 (setq var (cdr var)))
1763 (when (or groups gcc-self-val)
1764 (when (stringp groups)
1765 (setq groups (list groups)))
1768 (message-narrow-to-headers)
1769 (goto-char (point-max))
1772 ;; Use the `gcc-self' param value instead.
1775 (if (stringp gcc-self-val)
1776 (if (string-match " " gcc-self-val)
1777 (concat "\"" gcc-self-val "\"")
1779 (if (string-match " " group)
1780 (concat "\"" group "\"")
1782 (if (not (eq gcc-self-val 'none))
1787 ;; Use the list of groups.
1788 (while (setq name (pop groups))
1789 (let ((str (if (string-match ":" name)
1791 (gnus-group-prefixed-name
1792 name gnus-message-archive-method))))
1793 (insert (if (string-match " " str)
1794 (concat "\"" str "\"")
1800 (defun gnus-mailing-list-followup-to ()
1801 "Look at the headers in the current buffer and return a Mail-Followup-To address."
1802 (let ((x-been-there (gnus-fetch-original-field "x-beenthere"))
1803 (list-post (gnus-fetch-original-field "list-post")))
1804 (when (and list-post
1805 (string-match "mailto:\\([^>]+\\)" list-post))
1806 (setq list-post (match-string 1 list-post)))
1812 (defun gnus-configure-posting-styles (&optional group-name)
1813 "Configure posting styles according to `gnus-posting-styles'."
1814 (unless gnus-inhibit-posting-styles
1815 (let ((group (or group-name gnus-newsgroup-name ""))
1816 (styles gnus-posting-styles)
1817 style match variable attribute value v results
1818 filep name address element)
1819 ;; If the group has a posting-style parameter, add it at the end with a
1820 ;; regexp matching everything, to be sure it takes precedence over all
1822 (when gnus-newsgroup-name
1823 (let ((tmp-style (gnus-group-find-parameter group 'posting-style t)))
1825 (setq styles (append styles (list (cons ".*" tmp-style)))))))
1826 ;; Go through all styles and look for matches.
1827 (dolist (style styles)
1828 (setq match (pop style))
1829 (goto-char (point-min))
1832 ;; Regexp string match on the group name.
1833 (string-match match group))
1835 ;; Obsolete format of header match.
1836 (and (gnus-buffer-live-p gnus-article-copy)
1837 (with-current-buffer gnus-article-copy
1838 (let ((header (message-fetch-field (pop style))))
1840 (string-match (pop style) header))))))
1841 ((or (symbolp match)
1842 (gnus-functionp match))
1844 ((gnus-functionp match)
1845 ;; Function to be called.
1848 ;; Variable to be checked.
1849 (symbol-value match))))
1852 ((eq (car match) 'header)
1853 ;; New format of header match.
1854 (and (gnus-buffer-live-p gnus-article-copy)
1855 (with-current-buffer gnus-article-copy
1856 (let ((header (message-fetch-field (nth 1 match))))
1858 (string-match (nth 2 match) header))))))
1860 ;; This is a form to be evaled.
1862 ;; We have a match, so we set the variables.
1863 (dolist (attribute style)
1864 (setq element (pop attribute)
1869 ((eq (car attribute) :file)
1872 ((eq (car attribute) :value)
1876 ;; We get the value.
1881 ((or (symbolp value)
1882 (gnus-functionp value))
1883 (cond ((gnus-functionp value)
1886 (symbol-value value))))
1889 ;; Translate obsolescent value.
1891 ((eq element 'signature-file)
1892 (setq element 'signature
1894 ((eq element 'x-face-file)
1895 (setq element 'x-face
1897 ;; Get the contents of file elems.
1899 (setq v (with-temp-buffer
1900 (insert-file-contents v)
1901 (goto-char (point-max))
1905 (setq results (delq (assoc element results) results))
1906 (push (cons element v) results))))
1907 ;; Now we have all the styles, so we insert them.
1908 (setq name (assq 'name results)
1909 address (assq 'address results))
1910 (setq results (delq name (delq address results)))
1911 ;; make-local-hook is not obsolete in Emacs 20 or XEmacs.
1912 (make-local-hook 'message-setup-hook)
1913 (setq results (sort results (lambda (x y)
1914 (string-lessp (car x) (car y)))))
1915 (dolist (result results)
1916 (add-hook 'message-setup-hook
1918 ((eq 'eval (car result))
1920 ((eq 'body (car result))
1924 (insert ,(cdr result)))))
1925 ((eq 'signature (car result))
1926 (set (make-local-variable 'message-signature) nil)
1927 (set (make-local-variable 'message-signature-file) nil)
1928 (if (not (cdr result))
1932 (let ((message-signature ,(cdr result)))
1933 (when message-signature
1934 (message-insert-signature)))))))
1937 (if (symbolp (car result))
1938 (capitalize (symbol-name (car result)))
1942 (message-remove-header ,header)
1943 (let ((value ,(cdr result)))
1946 (insert ,header ": " value)
1948 (insert "\n")))))))))
1950 (when (or name address)
1951 (add-hook 'message-setup-hook
1953 (set (make-local-variable 'user-mail-address)
1954 ,(or (cdr address) user-mail-address))
1955 (let ((user-full-name ,(or (cdr name) (user-full-name)))
1957 ,(or (cdr address) user-mail-address)))
1959 (message-remove-header "From")
1961 (insert "From: " (message-make-from) "\n"))))
1964 ;;; Allow redefinition of functions.
1970 ;;; gnus-msg.el ends here