1 ;;; gnus-msg.el --- mail and post interface for Gnus
3 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
4 ;; 2004, 2005, 2006 Free Software Foundation, Inc.
6 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
7 ;; Lars Magne Ingebrigtsen <larsi@gnus.org>
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 ;; Boston, MA 02110-1301, USA.
31 (eval-when-compile (require 'cl))
39 (defcustom gnus-post-method 'current
40 "*Preferred method for posting USENET news.
42 If this variable is `current' (which is the default), Gnus will use
43 the \"current\" select method when posting. If it is `native', Gnus
44 will use the native select method when posting.
46 This method will not be used in mail groups and the like, only in
49 If not `native' nor `current', the value must be a valid method as discussed
50 in the documentation of `gnus-select-method'. It can also be a list of
51 methods. If that is the case, the user will be queried for what select
52 method to use when posting."
53 :group 'gnus-group-foreign
54 :link '(custom-manual "(gnus)Posting Server")
55 :type `(choice (const native)
57 (sexp :tag "Methods" ,gnus-select-method)))
59 (defcustom gnus-outgoing-message-group nil
60 "*All outgoing messages will be put in this group.
61 If you want to store all your outgoing mail and articles in the group
62 \"nnml:archive\", you set this variable to that value. This variable
63 can also be a list of group names.
65 If you want to have greater control over what group to put each
66 message in, you can set this variable to a function that checks the
67 current newsgroup name and then returns a suitable group name (or list
70 :type '(choice (const nil)
73 (repeat :tag "List of groups" (string :tag "Group"))))
75 (defcustom gnus-mailing-list-groups nil
76 "*If non-nil a regexp matching groups that are really mailing lists.
77 This is useful when you're reading a mailing list that has been
78 gatewayed to a newsgroup, and you want to followup to an article in
81 :type '(choice (regexp)
84 (defcustom gnus-add-to-list nil
85 "*If non-nil, add a `to-list' parameter automatically."
89 (defcustom gnus-crosspost-complaint
92 You posted the article below with the following Newsgroups header:
96 The %s group, at least, was an inappropriate recipient
97 of this message. Please trim your Newsgroups header to exclude this
98 group before posting in the future.
103 "Format string to be inserted when complaining about crossposts.
104 The first %s will be replaced by the Newsgroups header;
105 the second with the current group name."
109 (defcustom gnus-message-setup-hook nil
110 "Hook run after setting up a message buffer."
114 (defcustom gnus-bug-create-help-buffer t
115 "*Should we create the *Gnus Help Bug* buffer?"
119 (defcustom gnus-posting-styles nil
120 "*Alist of styles to use when posting.
121 See Info node `(gnus)Posting Styles'."
123 :link '(custom-manual "(gnus)Posting Styles")
124 :type '(repeat (cons (choice (regexp)
127 (string :tag "Header")
128 (regexp :tag "Regexp"))
132 (choice (const signature)
133 (const signature-file)
140 (string :tag "Header"))
146 (defcustom gnus-gcc-mark-as-read nil
147 "If non-nil, automatically mark Gcc articles as read."
152 (make-obsolete-variable 'gnus-inews-mark-gcc-as-read
153 'gnus-gcc-mark-as-read)
155 (defcustom gnus-gcc-externalize-attachments nil
156 "Should local-file attachments be included as external parts in Gcc copies?
157 If it is `all', attach files as external parts;
158 if a regexp and matches the Gcc group name, attach files as external parts;
159 if nil, attach files as normal parts."
162 :type '(choice (const nil :tag "None")
163 (const all :tag "Any")
164 (string :tag "Regexp")))
166 (gnus-define-group-parameter
167 posting-charset-alist
170 "Return the permitted unencoded charsets for posting of GROUP."
171 :variable gnus-group-posting-charset-alist
173 '(("^\\(no\\|fr\\)\\.[^,]*\\(,[ \t\n]*\\(no\\|fr\\)\\.[^,]*\\)*$" iso-8859-1 (iso-8859-1))
174 ("^\\(fido7\\|relcom\\)\\.[^,]*\\(,[ \t\n]*\\(fido7\\|relcom\\)\\.[^,]*\\)*$" koi8-r (koi8-r))
175 (message-this-is-mail nil nil)
176 (message-this-is-news nil t))
178 "Alist of regexps and permitted unencoded charsets for posting.
179 Each element of the alist has the form (TEST HEADER BODY-LIST), where
180 TEST is either a regular expression matching the newsgroup header or a
182 HEADER is the charset which may be left unencoded in the header (nil
183 means encode all charsets),
184 BODY-LIST is a list of charsets which may be encoded using 8bit
185 content-transfer encoding in the body, or one of the special values
186 nil (always encode using quoted-printable) or t (always use 8bit).
188 Note that any value other than nil for HEADER infringes some RFCs, so
189 use this option with care."
190 :variable-group gnus-charset
192 '(repeat (list :tag "Permitted unencoded charsets"
194 (regexp :tag "Group")
195 (const :tag "Mail message" :value message-this-is-mail)
196 (const :tag "News article" :value message-this-is-news))
197 (choice :tag "Header"
198 (const :tag "None" nil)
199 (symbol :tag "Charset"))
201 (const :tag "Any" :value t)
202 (const :tag "None" :value nil)
203 (repeat :tag "Charsets"
204 (symbol :tag "Charset")))))
205 :parameter-type '(choice :tag "Permitted unencoded charsets"
208 :parameter-document "\
209 List of charsets that are permitted to be unencoded.")
211 (defcustom gnus-debug-files
212 '("gnus.el" "gnus-sum.el" "gnus-group.el"
213 "gnus-art.el" "gnus-start.el" "gnus-async.el"
214 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
215 "gnus-agent.el" "gnus-cache.el" "gnus-srvr.el"
216 "mm-util.el" "mm-decode.el" "nnmail.el" "message.el")
217 "Files whose variables will be reported in `gnus-bug'."
220 :type '(repeat (string :tag "File")))
222 (defcustom gnus-debug-exclude-variables
223 '(mm-mime-mule-charset-alist
224 nnmail-split-fancy message-minibuffer-local-map)
225 "Variables that should not be reported in `gnus-bug'."
228 :type '(repeat (symbol :tag "Variable")))
230 (defcustom gnus-discouraged-post-methods
231 '(nndraft nnml nnimap nnmaildir nnmh nnfolder nndir)
232 "A list of back ends that are not used in \"real\" newsgroups.
233 This variable is used only when `gnus-post-method' is `current'."
235 :group 'gnus-group-foreign
236 :type '(repeat (symbol :tag "Back end")))
238 (defcustom gnus-message-replysign
240 "Automatically sign replies to signed messages.
241 See also the `mml-default-sign-method' variable."
245 (defcustom gnus-message-replyencrypt
247 "Automatically encrypt replies to encrypted messages.
248 See also the `mml-default-encrypt-method' variable."
252 (defcustom gnus-message-replysignencrypted
254 "Setting this causes automatically encrypted messages to also be signed."
258 (defcustom gnus-confirm-mail-reply-to-news (and gnus-novice-user
259 (not gnus-expert-user))
260 "If non-nil, Gnus requests confirmation when replying to news.
261 This is done because new users often reply by mistake when reading
263 This can also be a function receiving the group name as the only
264 parameter which should return non-nil iff a confirmation is needed, or
265 a regexp, in which case a confirmation is asked for iff the group name
269 :type '(choice (const :tag "No" nil)
271 (regexp :tag "Iff group matches regexp")
272 (function :tag "Iff function evaluates to non-nil")))
274 (defcustom gnus-confirm-treat-mail-like-news
276 "If non-nil, Gnus will treat mail like news with regard to confirmation
277 when replying by mail. See the `gnus-confirm-mail-reply-to-news' variable
278 for fine-tuning this.
279 If nil, Gnus will never ask for confirmation if replying to mail."
284 (defcustom gnus-summary-resend-default-address t
285 "If non-nil, Gnus tries to suggest a default address to resend to.
286 If nil, the address field will always be empty after invoking
287 `gnus-summary-resend-message'."
292 (defcustom gnus-message-highlight-citation (fboundp 'font-lock-add-keywords)
293 "Enable highlighting of different citation levels in message-mode."
294 :version "23.0" ;; No Gnus
299 (autoload 'gnus-message-citation-mode "gnus-msg" nil t)
301 ;;; Internal variables.
303 (defvar gnus-inhibit-posting-styles nil
304 "Inhibit the use of posting styles.")
306 (defvar gnus-article-yanked-articles nil)
307 (defvar gnus-message-buffer "*Mail Gnus*")
308 (defvar gnus-article-copy nil)
309 (defvar gnus-check-before-posting nil)
310 (defvar gnus-last-posting-server nil)
311 (defvar gnus-message-group-art nil)
313 (defvar gnus-msg-force-broken-reply-to nil)
315 (defconst gnus-bug-message
316 "Sending a bug report to the Gnus Towers.
317 ========================================
319 The buffer below is a mail buffer. When you press `C-c C-c', it will
320 be sent to the Gnus Bug Exterminators.
322 The thing near the bottom of the buffer is how the environment
323 settings will be included in the mail. Please do not delete that.
324 They will tell the Bug People what your environment is, so that it
325 will be easier to locate the bugs.
327 If you have found a bug that makes Emacs go \"beep\", set
328 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
329 and include the backtrace in your bug report.
331 Please describe the bug in annoying, painstaking detail.
333 Thank you for your help in stamping out bugs.
337 (autoload 'gnus-uu-post-news "gnus-uu" nil t))
341 ;;; Gnus Posting Functions
344 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
345 "p" gnus-summary-post-news
346 "i" gnus-summary-news-other-window
347 "f" gnus-summary-followup
348 "F" gnus-summary-followup-with-original
349 "c" gnus-summary-cancel-article
350 "s" gnus-summary-supersede-article
351 "r" gnus-summary-reply
352 "y" gnus-summary-yank-message
353 "R" gnus-summary-reply-with-original
354 "w" gnus-summary-wide-reply
355 "W" gnus-summary-wide-reply-with-original
356 "v" gnus-summary-very-wide-reply
357 "V" gnus-summary-very-wide-reply-with-original
358 "n" gnus-summary-followup-to-mail
359 "N" gnus-summary-followup-to-mail-with-original
360 "m" gnus-summary-mail-other-window
361 "u" gnus-uu-post-news
362 "\M-c" gnus-summary-mail-crosspost-complaint
363 "Br" gnus-summary-reply-broken-reply-to
364 "BR" gnus-summary-reply-broken-reply-to-with-original
365 "om" gnus-summary-mail-forward
366 "op" gnus-summary-post-forward
367 "Om" gnus-uu-digest-mail-forward
368 "Op" gnus-uu-digest-post-forward)
370 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
371 "b" gnus-summary-resend-bounced-mail
372 ;; "c" gnus-summary-send-draft
373 "r" gnus-summary-resend-message
374 "e" gnus-summary-resend-message-edit)
376 ;;; Internal functions.
378 (defun gnus-inews-make-draft (articles)
380 (gnus-inews-make-draft-meta-information
381 ,gnus-newsgroup-name ',articles)))
383 (defvar gnus-article-reply nil)
384 (defmacro gnus-setup-message (config &rest forms)
385 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
386 (buffer (make-symbol "gnus-setup-message-buffer"))
387 (article (make-symbol "gnus-setup-message-article"))
388 (yanked (make-symbol "gnus-setup-yanked-articles"))
389 (group (make-symbol "gnus-setup-message-group")))
390 `(let ((,winconf (current-window-configuration))
391 (,buffer (buffer-name (current-buffer)))
392 (,article gnus-article-reply)
393 (,yanked gnus-article-yanked-articles)
394 (,group gnus-newsgroup-name)
395 (message-header-setup-hook
396 (copy-sequence message-header-setup-hook))
397 (mbl mml-buffer-list)
398 (message-mode-hook (copy-sequence message-mode-hook)))
399 (setq mml-buffer-list nil)
400 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
401 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
402 ;; #### FIXME: for a reason that I did not manage to identify yet,
403 ;; the variable `gnus-newsgroup-name' does not honor a dynamically
404 ;; scoped or setq'ed value from a caller like `C-u gnus-summary-mail'.
405 ;; After evaluation of @forms below, it gets the value we actually want
406 ;; to override, and the posting styles are used. For that reason, I've
407 ;; added an optional argument to `gnus-configure-posting-styles' to
408 ;; make sure that the correct value for the group name is used. -- drv
409 (add-hook 'message-mode-hook
410 (if (memq ,config '(reply-yank reply))
412 (gnus-configure-posting-styles ,group))
414 ;; There may be an old " *gnus article copy*" buffer.
415 (let (gnus-article-copy)
416 (gnus-configure-posting-styles ,group)))))
417 (gnus-pull ',(intern gnus-draft-meta-information-header)
418 message-required-headers)
420 (not (string= ,group "")))
422 (intern gnus-draft-meta-information-header)
423 (gnus-inews-make-draft (or ,yanked ,article)))
424 message-required-headers))
428 (gnus-inews-add-send-actions ,winconf ,buffer ,article ,config
430 (setq gnus-message-buffer (current-buffer))
431 (set (make-local-variable 'gnus-message-group-art)
432 (cons ,group ,article))
433 (set (make-local-variable 'gnus-newsgroup-name) ,group)
434 ;; Enable highlighting of different citation levels
435 (when gnus-message-highlight-citation
436 (gnus-message-citation-mode 1))
437 (gnus-run-hooks 'gnus-message-setup-hook)
438 (if (eq major-mode 'message-mode)
439 (let ((mbl1 mml-buffer-list))
440 (setq mml-buffer-list mbl) ;; Global value
441 (set (make-local-variable 'mml-buffer-list) mbl1);; Local value
442 (gnus-make-local-hook 'kill-buffer-hook)
443 (gnus-make-local-hook 'change-major-mode-hook)
444 (add-hook 'change-major-mode-hook 'mml-destroy-buffers nil t)
445 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))
446 (mml-destroy-buffers)
447 (setq mml-buffer-list mbl)))
448 (message-hide-headers)
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 articles)
455 (when (numberp articles)
456 (setq articles (list articles)))
457 (concat "(\"" group "\""
471 (defun gnus-msg-mail (&optional to subject other-headers continue
472 switch-action yank-action send-actions)
473 "Start editing a mail message to be sent.
474 Like `message-mail', but with Gnus paraphernalia, particularly the
475 Gcc: header for archiving purposes."
477 (let ((buf (current-buffer))
479 (gnus-setup-message 'message
480 (message-mail to subject other-headers continue
481 nil yank-action send-actions))
483 (setq mail-buf (current-buffer))
484 (switch-to-buffer buf)
485 (apply switch-action mail-buf nil)))
486 ;; COMPOSEFUNC should return t if succeed. Undocumented ???
490 (defun gnus-button-mailto (address)
492 (set-buffer (gnus-copy-article-buffer))
493 (gnus-setup-message 'message
494 (message-reply address)))
497 (defun gnus-button-reply (&optional to-address wide)
498 "Like `message-reply'."
500 (gnus-setup-message 'message
501 (message-reply to-address wide)))
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 (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 (gnus-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 (gnus-make-local-hook 'message-header-hook)
530 (add-hook 'message-header-hook 'gnus-agent-possibly-save-gcc nil t))
531 (setq message-post-method
532 `(lambda (&optional arg)
533 (gnus-post-method arg ,gnus-newsgroup-name)))
534 (setq message-newsreader (setq message-mailer (gnus-extended-version)))
536 `(when (gnus-buffer-exists-p ,buffer)
537 (set-window-configuration ,winconf))
538 'exit 'postpone 'kill)
539 (let ((to-be-marked (cond
542 (lambda (x) (if (listp x) (car x) x)) yanked))
543 (article (if (listp article) article (list article)))
546 `(when (gnus-buffer-exists-p ,buffer)
550 (if (eq config 'forward)
551 `(gnus-summary-mark-article-as-forwarded ',to-be-marked)
552 `(gnus-summary-mark-article-as-replied ',to-be-marked)))))
555 (put 'gnus-setup-message 'lisp-indent-function 1)
556 (put 'gnus-setup-message 'edebug-form-spec '(form body))
558 ;;; Post news commands of Gnus group mode and summary mode
560 (defun gnus-group-mail (&optional arg)
561 "Start composing a mail.
562 If ARG, use the group under the point to find a posting style.
563 If ARG is 1, prompt for a group name to find the posting style."
565 ;; We can't `let' gnus-newsgroup-name here, since that leads
566 ;; to local variables leaking.
567 (let ((group gnus-newsgroup-name)
568 ;; make sure last viewed article doesn't affect posting styles:
570 (buffer (current-buffer)))
573 (setq gnus-newsgroup-name
575 (if (= 1 (prefix-numeric-value arg))
576 (completing-read "Use posting style of group: "
577 gnus-active-hashtb nil
578 (gnus-read-active-file-p))
579 (gnus-group-group-name))
581 ;; #### see comment in gnus-setup-message -- drv
582 (gnus-setup-message 'message (message-mail)))
585 (setq gnus-newsgroup-name group)))))
587 (defun gnus-group-news (&optional arg)
588 "Start composing a news.
589 If ARG, post to group under point.
590 If ARG is 1, prompt for group name to post to.
592 This function prepares a news even when using mail groups. This is useful
593 for posting messages to mail groups without actually sending them over the
594 network. The corresponding back end must have a 'request-post method."
596 ;; We can't `let' gnus-newsgroup-name here, since that leads
597 ;; to local variables leaking.
598 (let ((group gnus-newsgroup-name)
599 ;; make sure last viewed article doesn't affect posting styles:
601 (buffer (current-buffer)))
604 (setq gnus-newsgroup-name
606 (if (= 1 (prefix-numeric-value arg))
607 (completing-read "Use group: "
608 gnus-active-hashtb nil
609 (gnus-read-active-file-p))
610 (gnus-group-group-name))
612 ;; #### see comment in gnus-setup-message -- drv
613 (gnus-setup-message 'message
614 (message-news (gnus-group-real-name gnus-newsgroup-name))))
617 (setq gnus-newsgroup-name group)))))
619 (defun gnus-group-post-news (&optional arg)
620 "Start composing a message (a news by default).
621 If ARG, post to group under point. If ARG is 1, prompt for group name.
622 Depending on the selected group, the message might be either a mail or
625 ;; Bind this variable here to make message mode hooks work ok.
626 (let ((gnus-newsgroup-name
628 (if (= 1 (prefix-numeric-value arg))
629 (completing-read "Newsgroup: " gnus-active-hashtb nil
630 (gnus-read-active-file-p))
631 (gnus-group-group-name))
633 ;; make sure last viewed article doesn't affect posting styles:
635 (gnus-post-news 'post gnus-newsgroup-name nil nil nil nil
636 (string= gnus-newsgroup-name ""))))
638 (defun gnus-summary-mail-other-window (&optional arg)
639 "Start composing a mail in another window.
640 Use the posting of the current group by default.
641 If ARG, don't do that. If ARG is 1, prompt for group name to find the
644 ;; We can't `let' gnus-newsgroup-name here, since that leads
645 ;; to local variables leaking.
646 (let ((group gnus-newsgroup-name)
647 ;; make sure last viewed article doesn't affect posting styles:
649 (buffer (current-buffer)))
652 (setq gnus-newsgroup-name
654 (if (= 1 (prefix-numeric-value arg))
655 (completing-read "Use group: "
656 gnus-active-hashtb nil
657 (gnus-read-active-file-p))
659 gnus-newsgroup-name))
660 ;; #### see comment in gnus-setup-message -- drv
661 (gnus-setup-message 'message (message-mail)))
664 (setq gnus-newsgroup-name group)))))
666 (defun gnus-summary-news-other-window (&optional arg)
667 "Start composing a news in another window.
668 Post to the current group by default.
669 If ARG, don't do that. If ARG is 1, prompt for group name to post to.
671 This function prepares a news even when using mail groups. This is useful
672 for posting messages to mail groups without actually sending them over the
673 network. The corresponding back end must have a 'request-post method."
675 ;; We can't `let' gnus-newsgroup-name here, since that leads
676 ;; to local variables leaking.
677 (let ((group gnus-newsgroup-name)
678 ;; make sure last viewed article doesn't affect posting styles:
680 (buffer (current-buffer)))
683 (setq gnus-newsgroup-name
685 (if (= 1 (prefix-numeric-value arg))
686 (completing-read "Use group: "
687 gnus-active-hashtb nil
688 (gnus-read-active-file-p))
690 gnus-newsgroup-name))
691 ;; #### see comment in gnus-setup-message -- drv
692 (gnus-setup-message 'message
694 (message-news (gnus-group-real-name gnus-newsgroup-name))
695 (set (make-local-variable 'gnus-discouraged-post-methods)
697 (car (gnus-find-method-for-group gnus-newsgroup-name))
698 gnus-discouraged-post-methods)))))
701 (setq gnus-newsgroup-name group)))))
703 (defun gnus-summary-post-news (&optional arg)
704 "Start composing a message. Post to the current group by default.
705 If ARG, don't do that. If ARG is 1, prompt for a group name to post to.
706 Depending on the selected group, the message might be either a mail or
709 ;; Bind this variable here to make message mode hooks work ok.
710 (let ((gnus-newsgroup-name
712 (if (= 1 (prefix-numeric-value arg))
713 (completing-read "Newsgroup: " gnus-active-hashtb nil
714 (gnus-read-active-file-p))
716 gnus-newsgroup-name))
717 ;; make sure last viewed article doesn't affect posting styles:
719 (gnus-post-news 'post gnus-newsgroup-name)))
722 (defun gnus-summary-followup (yank &optional force-news)
723 "Compose a followup to an article.
724 If prefix argument YANK is non-nil, the original article is yanked
726 YANK is a list of elements, where the car of each element is the
727 article number, and the cdr is the string to be yanked."
729 (list (and current-prefix-arg
730 (gnus-summary-work-articles 1))))
732 (gnus-summary-goto-subject
733 (if (listp (car yank))
736 (save-window-excursion
737 (gnus-summary-select-article))
738 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
739 (gnus-newsgroup-name gnus-newsgroup-name))
741 (gnus-post-news nil gnus-newsgroup-name
742 headers gnus-article-buffer
744 (gnus-summary-handle-replysign)))
746 (defun gnus-summary-followup-with-original (n &optional force-news)
747 "Compose a followup to an article and include the original article.
748 The text in the region will be yanked. If the region isn't
749 active, the entire article will be yanked."
751 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
753 (defun gnus-summary-followup-to-mail (&optional arg)
754 "Followup to the current mail message via news."
756 (list (and current-prefix-arg
757 (gnus-summary-work-articles 1))))
758 (gnus-summary-followup arg t))
760 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
761 "Followup to the current mail message via news."
763 (gnus-summary-followup (gnus-summary-work-articles arg) t))
765 (defun gnus-inews-yank-articles (articles)
766 (let (beg article yank-string)
768 (while (setq article (pop articles))
769 (when (listp article)
770 (setq yank-string (nth 1 article)
771 article (nth 0 article)))
772 (save-window-excursion
773 (set-buffer gnus-summary-buffer)
774 (gnus-summary-select-article nil nil nil article)
775 (gnus-summary-remove-process-mark article))
776 (gnus-copy-article-buffer nil yank-string)
777 (let ((message-reply-buffer gnus-article-copy)
778 (message-reply-headers
779 ;; The headers are decoded.
780 (with-current-buffer gnus-article-copy
782 (nnheader-narrow-to-headers)
783 (nnheader-parse-naked-head)))))
784 (message-yank-original)
785 (setq beg (or beg (mark t))))
791 (defun gnus-summary-cancel-article (&optional n symp)
792 "Cancel an article you posted.
793 Uses the process-prefix convention. If given the symbolic
794 prefix `a', cancel using the standard posting method; if not
795 post using the current select method."
796 (interactive (gnus-interactive "P\ny"))
797 (let ((message-post-method
799 (gnus-post-method (eq ',symp 'a) ,gnus-newsgroup-name))))
800 (dolist (article (gnus-summary-work-articles n))
801 (when (gnus-summary-select-article t nil nil article)
802 (when (gnus-eval-in-buffer-window gnus-original-article-buffer
803 (message-cancel-news))
804 (gnus-summary-mark-as-read article gnus-canceled-mark)
805 (gnus-cache-remove-article 1))
806 (gnus-article-hide-headers-if-wanted))
807 (gnus-summary-remove-process-mark article))))
809 (defun gnus-summary-supersede-article ()
810 "Compose an article that will supersede a previous article.
811 This is done simply by taking the old article and adding a Supersedes
812 header line with the old Message-ID."
814 (let ((article (gnus-summary-article-number)))
815 (gnus-setup-message 'reply-yank
816 (gnus-summary-select-article t)
817 (set-buffer gnus-original-article-buffer)
821 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
823 (set-buffer ,gnus-summary-buffer)
824 (gnus-cache-possibly-remove-article ,article nil nil nil t)
825 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
826 message-send-actions))))
830 (defun gnus-copy-article-buffer (&optional article-buffer yank-string)
831 ;; make a copy of the article buffer with all text properties removed
832 ;; this copy is in the buffer gnus-article-copy.
833 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
834 ;; this buffer should be passed to all mail/news reply/post routines.
835 (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
837 (set-buffer gnus-article-copy)
838 (mm-enable-multibyte))
839 (let ((article-buffer (or article-buffer gnus-article-buffer))
841 (if (not (and (get-buffer article-buffer)
842 (gnus-buffer-exists-p article-buffer)))
843 (error "Can't find any article buffer")
845 (set-buffer article-buffer)
846 (let ((gnus-newsgroup-charset (or gnus-article-charset
847 gnus-newsgroup-charset))
848 (gnus-newsgroup-ignored-charsets
849 (or gnus-article-ignored-charsets
850 gnus-newsgroup-ignored-charsets)))
852 ;; Copy over the (displayed) article buffer, delete
853 ;; hidden text and remove text properties.
855 (copy-to-buffer gnus-article-copy (point-min) (point-max))
856 (set-buffer gnus-article-copy)
859 (delete-region (point) (point-max))
860 (insert yank-string))
861 (gnus-article-delete-text-of-type 'annotation)
862 (gnus-article-delete-text-of-type 'multipart)
863 (gnus-remove-text-with-property 'gnus-prev)
864 (gnus-remove-text-with-property 'gnus-next)
865 (gnus-remove-text-with-property 'gnus-decoration)
868 (buffer-substring-no-properties (point-min) (point-max))
870 ;; Find the original headers.
871 (set-buffer gnus-original-article-buffer)
872 (goto-char (point-min))
873 (while (looking-at message-unix-mail-delimiter)
875 (let ((mail-header-separator ""))
877 end (or (message-goto-body)
878 ;; There may be just a header.
880 ;; Delete the headers from the displayed articles.
881 (set-buffer gnus-article-copy)
882 (let ((mail-header-separator ""))
883 (delete-region (goto-char (point-min))
884 (or (message-goto-body) (point-max))))
885 ;; Insert the original article headers.
886 (insert-buffer-substring gnus-original-article-buffer beg end)
888 (let ((gnus-article-decode-hook
889 (delq 'article-decode-charset
890 (copy-sequence gnus-article-decode-hook)))
891 (rfc2047-quote-decoded-words-containing-tspecials t))
892 (run-hooks 'gnus-article-decode-hook)))))
895 (defun gnus-post-news (post &optional group header article-buffer yank subject
898 (gnus-copy-article-buffer))
899 (let ((gnus-article-reply (and article-buffer (gnus-summary-article-number)))
900 (gnus-article-yanked-articles yank)
901 (add-to-list gnus-add-to-list))
902 (gnus-setup-message (cond (yank 'reply-yank)
903 (article-buffer 'reply)
905 (let* ((group (or group gnus-newsgroup-name))
906 (charset (gnus-group-name-charset nil group))
908 to-address to-group mailing-list to-list
911 (setq to-address (gnus-parameter-to-address group)
912 to-group (gnus-group-find-parameter group 'to-group)
913 to-list (gnus-parameter-to-list group)
914 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
915 mailing-list (when gnus-mailing-list-groups
916 (string-match gnus-mailing-list-groups group))
917 group (gnus-group-name-decode (gnus-group-real-name group)
919 (if (or (and to-group
920 (gnus-news-group-p to-group))
923 (and (gnus-news-group-p
924 (or pgroup gnus-newsgroup-name)
925 (or header gnus-current-article))
933 (and (not (gnus-virtual-group-p pgroup)) group)))
934 (set-buffer gnus-article-copy)
935 (gnus-msg-treat-broken-reply-to)
936 (message-followup (if (or newsgroup-p force-news)
937 (if (save-restriction
938 (article-narrow-to-head)
939 (message-fetch-field "newsgroups"))
946 (message-mail (or to-address to-list))
947 ;; Arrange for mail groups that have no `to-address' to
948 ;; get that when the user sends off the mail.
949 (when (and (not to-list)
952 (push (list 'gnus-inews-add-to-address pgroup)
953 message-send-actions)))
954 (set-buffer gnus-article-copy)
955 (gnus-msg-treat-broken-reply-to)
956 (message-wide-reply to-address)))
958 (gnus-inews-yank-articles yank))))))
960 (defun gnus-msg-treat-broken-reply-to (&optional force)
961 "Remove the Reply-to header if broken-reply-to."
963 (gnus-group-find-parameter
964 gnus-newsgroup-name 'broken-reply-to))
966 (message-narrow-to-head)
967 (message-remove-header "reply-to"))))
969 (defun gnus-post-method (arg group &optional silent)
970 "Return the posting method based on GROUP and ARG.
971 If SILENT, don't prompt the user."
972 (let ((gnus-post-method (or (gnus-parameter-post-method group)
974 (group-method (gnus-find-method-for-group group)))
976 ;; If the group-method is nil (which shouldn't happen) we use
977 ;; the default method.
979 (or (and (listp gnus-post-method) ;If not current/native/nil
980 (not (listp (car gnus-post-method))) ; and not a list of methods
981 gnus-post-method) ;then use it.
983 message-post-method))
984 ;; We want the inverse of the default
985 ((and arg (not (eq arg 0)))
986 (if (eq gnus-post-method 'current)
989 ;; We query the user for a post method.
991 (and (listp gnus-post-method)
992 (listp (car gnus-post-method))))
994 ;; Collect all methods we know about.
996 (when (listp gnus-post-method)
997 (if (listp (car gnus-post-method))
999 (list gnus-post-method)))
1000 gnus-secondary-select-methods
1001 (mapcar 'cdr gnus-server-alist)
1002 (mapcar 'car gnus-opened-servers)
1003 (list gnus-select-method)
1004 (list group-method)))
1005 method-alist post-methods method)
1006 ;; Weed out all mail methods.
1008 (setq method (gnus-server-get-method "" (pop methods)))
1009 (when (and (or (gnus-method-option-p method 'post)
1010 (gnus-method-option-p method 'post-mail))
1011 (not (member method post-methods)))
1012 (push method post-methods)))
1013 ;; Create a name-method alist.
1017 (if (equal (cadr m) "")
1018 (list (symbol-name (car m)) m)
1019 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m)))
1024 (setq gnus-last-posting-server
1026 gnus-last-posting-server)
1027 ;; Just use the last value.
1028 gnus-last-posting-server
1030 "Posting method: " method-alist nil t
1031 (cons (or gnus-last-posting-server "") 0))))
1033 ;; Override normal method.
1034 ((and (eq gnus-post-method 'current)
1035 (not (memq (car group-method) gnus-discouraged-post-methods))
1036 (gnus-get-function group-method 'request-post t))
1039 ;; Use gnus-post-method.
1040 ((listp gnus-post-method) ;A method...
1041 (assert (not (listp (car gnus-post-method)))) ;... not a list of methods.
1043 ;; Use the normal select method (nil or native).
1044 (t gnus-select-method))))
1048 (defun gnus-extended-version ()
1049 "Stringified Gnus version and Emacs version.
1050 See the variable `gnus-user-agent'."
1052 (if (stringp gnus-user-agent)
1054 ;; `gnus-user-agent' is a list:
1055 (let* ((float-output-format nil)
1057 (when (memq 'gnus gnus-user-agent)
1059 (prin1-to-string (gnus-continuum-version gnus-version) t)
1060 " (" gnus-version ")")))
1061 (emacs-v (gnus-emacs-version)))
1062 (concat gnus-v (when (and gnus-v emacs-v) " ")
1067 ;;; Gnus Mail Functions
1070 ;;; Mail reply commands of Gnus summary mode
1072 (defun gnus-summary-reply (&optional yank wide very-wide)
1073 "Start composing a mail reply to the current message.
1074 If prefix argument YANK is non-nil, the original article is yanked
1076 If WIDE, make a wide reply.
1077 If VERY-WIDE, make a very wide reply."
1079 (list (and current-prefix-arg
1080 (gnus-summary-work-articles 1))))
1081 ;; Allow user to require confirmation before replying by mail to the
1082 ;; author of a news article (or mail message).
1084 (not (or (gnus-news-group-p gnus-newsgroup-name)
1085 gnus-confirm-treat-mail-like-news))
1086 (not (cond ((stringp gnus-confirm-mail-reply-to-news)
1087 (string-match gnus-confirm-mail-reply-to-news
1088 gnus-newsgroup-name))
1089 ((functionp gnus-confirm-mail-reply-to-news)
1090 (funcall gnus-confirm-mail-reply-to-news gnus-newsgroup-name))
1091 (t gnus-confirm-mail-reply-to-news)))
1092 (y-or-n-p "Really reply by mail to article author? "))
1094 (if (listp (car yank))
1097 (gnus-article-reply (or article (gnus-summary-article-number)))
1098 (gnus-article-yanked-articles yank)
1100 ;; Stripping headers should be specified with mail-yank-ignored-headers.
1102 (gnus-summary-goto-subject article))
1103 (gnus-setup-message (if yank 'reply-yank 'reply)
1105 (gnus-summary-select-article)
1106 (dolist (article very-wide)
1107 (gnus-summary-select-article nil nil nil article)
1109 (set-buffer (gnus-copy-article-buffer))
1110 (gnus-msg-treat-broken-reply-to)
1112 (message-narrow-to-head)
1113 (setq headers (concat headers (buffer-string)))))))
1114 (set-buffer (gnus-copy-article-buffer))
1115 (gnus-msg-treat-broken-reply-to gnus-msg-force-broken-reply-to)
1117 (message-narrow-to-head)
1121 (goto-char (point-max)))
1122 (mml-quote-region (point) (point-max))
1123 (message-reply nil wide)
1125 (gnus-inews-yank-articles yank))
1126 (gnus-summary-handle-replysign)))))
1128 (defun gnus-summary-handle-replysign ()
1129 "Check the various replysign variables and take action accordingly."
1130 (when (or gnus-message-replysign gnus-message-replyencrypt)
1131 (let (signed encrypted)
1133 (set-buffer gnus-article-buffer)
1134 (setq signed (memq 'signed gnus-article-wash-types))
1135 (setq encrypted (memq 'encrypted gnus-article-wash-types)))
1136 (cond ((and gnus-message-replyencrypt encrypted)
1137 (mml-secure-message mml-default-encrypt-method
1138 (if gnus-message-replysignencrypted
1141 ((and gnus-message-replysign signed)
1142 (mml-secure-message mml-default-sign-method 'sign))))))
1144 (defun gnus-summary-reply-with-original (n &optional wide)
1145 "Start composing a reply mail to the current message.
1146 The original article will be yanked."
1148 (gnus-summary-reply (gnus-summary-work-articles n) wide))
1150 (defun gnus-summary-reply-broken-reply-to (&optional yank wide very-wide)
1151 "Like `gnus-summary-reply' except removing reply-to field.
1152 If prefix argument YANK is non-nil, the original article is yanked
1154 If WIDE, make a wide reply.
1155 If VERY-WIDE, make a very wide reply."
1157 (list (and current-prefix-arg
1158 (gnus-summary-work-articles 1))))
1159 (let ((gnus-msg-force-broken-reply-to t))
1160 (gnus-summary-reply yank wide very-wide)))
1162 (defun gnus-summary-reply-broken-reply-to-with-original (n &optional wide)
1163 "Like `gnus-summary-reply-with-original' except removing reply-to field.
1164 The original article will be yanked."
1166 (gnus-summary-reply-broken-reply-to (gnus-summary-work-articles n) wide))
1168 (defun gnus-summary-wide-reply (&optional yank)
1169 "Start composing a wide reply mail to the current message.
1170 If prefix argument YANK is non-nil, the original article is yanked
1173 (list (and current-prefix-arg
1174 (gnus-summary-work-articles 1))))
1175 (gnus-summary-reply yank t))
1177 (defun gnus-summary-wide-reply-with-original (n)
1178 "Start composing a wide reply mail to the current message.
1179 The original article will be yanked.
1180 Uses the process/prefix convention."
1182 (gnus-summary-reply-with-original n t))
1184 (defun gnus-summary-very-wide-reply (&optional yank)
1185 "Start composing a very wide reply mail to the current message.
1186 If prefix argument YANK is non-nil, the original article is yanked
1189 (list (and current-prefix-arg
1190 (gnus-summary-work-articles 1))))
1191 (gnus-summary-reply yank t (gnus-summary-work-articles yank)))
1193 (defun gnus-summary-very-wide-reply-with-original (n)
1194 "Start composing a very wide reply mail to the current message.
1195 The original article will be yanked."
1198 (gnus-summary-work-articles n) t (gnus-summary-work-articles n)))
1200 (defun gnus-summary-mail-forward (&optional arg post)
1201 "Forward the current message(s) to another user.
1202 If process marks exist, forward all marked messages;
1203 if ARG is nil, see `message-forward-as-mime' and `message-forward-show-mml';
1204 if ARG is 1, decode the message and forward directly inline;
1205 if ARG is 2, forward message as an rfc822 MIME section;
1206 if ARG is 3, decode message and forward as an rfc822 MIME section;
1207 if ARG is 4, forward message directly inline;
1208 otherwise, use flipped `message-forward-as-mime'.
1209 If POST, post instead of mail.
1210 For the `inline' alternatives, also see the variable
1211 `message-forward-ignored-headers'."
1213 (if (cdr (gnus-summary-work-articles nil))
1214 ;; Process marks are given.
1215 (gnus-uu-digest-mail-forward arg post)
1216 ;; No process marks.
1217 (let ((message-forward-as-mime message-forward-as-mime)
1218 (message-forward-show-mml message-forward-show-mml))
1222 (setq message-forward-as-mime nil
1223 message-forward-show-mml t))
1225 (setq message-forward-as-mime t
1226 message-forward-show-mml nil))
1228 (setq message-forward-as-mime t
1229 message-forward-show-mml t))
1231 (setq message-forward-as-mime nil
1232 message-forward-show-mml nil))
1234 (setq message-forward-as-mime (not message-forward-as-mime))))
1235 (let* ((gnus-article-reply (gnus-summary-article-number))
1236 (gnus-article-yanked-articles (list gnus-article-reply)))
1237 (gnus-setup-message 'forward
1238 (gnus-summary-select-article)
1239 (let ((mail-parse-charset
1240 (or (and (gnus-buffer-live-p gnus-article-buffer)
1241 (with-current-buffer gnus-article-buffer
1242 gnus-article-charset))
1243 gnus-newsgroup-charset))
1244 (mail-parse-ignored-charsets
1245 gnus-newsgroup-ignored-charsets))
1246 (set-buffer gnus-original-article-buffer)
1247 (message-forward post)))))))
1249 (defun gnus-summary-resend-message (address n)
1250 "Resend the current article to ADDRESS."
1252 (list (message-read-from-minibuffer
1253 "Resend message(s) to: "
1254 (when (and gnus-summary-resend-default-address
1255 (gnus-buffer-live-p gnus-original-article-buffer))
1256 ;; If some other article is currently selected, the
1257 ;; initial-contents is wrong. Whatever, it is just the
1258 ;; initial-contents.
1259 (with-current-buffer gnus-original-article-buffer
1260 (nnmail-fetch-field "to"))))
1261 current-prefix-arg))
1262 (dolist (article (gnus-summary-work-articles n))
1263 (gnus-summary-select-article nil nil nil article)
1265 (set-buffer gnus-original-article-buffer)
1266 (message-resend address))
1267 (gnus-summary-mark-article-as-forwarded article)))
1269 ;; From: Matthieu Moy <Matthieu.Moy@imag.fr>
1270 (defun gnus-summary-resend-message-edit ()
1271 "Resend an article that has already been sent.
1272 A new buffer will be created to allow the user to modify body and
1273 contents of the message, and then, everything will happen as when
1274 composing a new message."
1276 (let ((article (gnus-summary-article-number)))
1277 (gnus-setup-message 'reply-yank
1278 (gnus-summary-select-article t)
1279 (set-buffer gnus-original-article-buffer)
1280 (let ((cur (current-buffer))
1281 (to (message-fetch-field "to")))
1282 ;; Get a normal message buffer.
1283 (message-pop-to-buffer (message-buffer-name "Resend" to))
1284 (insert-buffer-substring cur)
1286 (message-narrow-to-head-1)
1287 ;; Gnus will generate a new one when sending.
1288 (message-remove-header "Message-ID")
1289 (message-remove-header message-ignored-resent-headers t)
1290 ;; Remove unwanted headers.
1291 (goto-char (point-max))
1292 (insert mail-header-separator)
1293 (goto-char (point-min))
1294 (when (re-search-forward "^To:\\|^Newsgroups:" nil 'move)
1298 (defun gnus-summary-post-forward (&optional arg)
1299 "Forward the current article to a newsgroup.
1300 See `gnus-summary-mail-forward' for ARG."
1302 (gnus-summary-mail-forward arg t))
1304 (defvar gnus-nastygram-message
1305 "The following article was inappropriately posted to %s.\n\n"
1306 "Format string to insert in nastygrams.
1307 The current group name will be inserted at \"%s\".")
1309 (defun gnus-summary-mail-nastygram (n)
1310 "Send a nastygram to the author of the current article."
1312 (when (or gnus-expert-user
1314 "Really send a nastygram to the author of the current article? "))
1315 (let ((group gnus-newsgroup-name))
1316 (gnus-summary-reply-with-original n)
1317 (set-buffer gnus-message-buffer)
1319 (insert (format gnus-nastygram-message group))
1320 (message-send-and-exit))))
1322 (defun gnus-summary-mail-crosspost-complaint (n)
1323 "Send a complaint about crossposting to the current article(s)."
1325 (dolist (article (gnus-summary-work-articles n))
1326 (set-buffer gnus-summary-buffer)
1327 (gnus-summary-goto-subject article)
1328 (let ((group (gnus-group-real-name gnus-newsgroup-name))
1329 newsgroups followup-to)
1330 (gnus-summary-select-article)
1331 (set-buffer gnus-original-article-buffer)
1332 (if (and (<= (length (message-tokenize-header
1334 (mail-fetch-field "newsgroups"))
1337 (or (not (setq followup-to (mail-fetch-field "followup-to")))
1338 (not (member group (message-tokenize-header
1339 followup-to ", ")))))
1341 (gnus-message 1 "Followup-to restricted")
1342 (gnus-message 1 "Not a crossposted article"))
1343 (set-buffer gnus-summary-buffer)
1344 (gnus-summary-reply-with-original 1)
1345 (set-buffer gnus-message-buffer)
1347 (insert (format gnus-crosspost-complaint newsgroups group))
1348 (message-goto-subject)
1349 (re-search-forward " *$")
1350 (replace-match " (crosspost notification)" t t)
1351 (gnus-deactivate-mark)
1352 (when (gnus-y-or-n-p "Send this complaint? ")
1353 (message-send-and-exit))))))
1355 (defun gnus-mail-parse-comma-list ()
1358 (skip-chars-forward " ")
1361 (skip-chars-forward "^,")
1366 (narrow-to-region beg (point))
1369 (while (search-forward "\"" nil t)
1373 (skip-chars-forward ",")
1374 (skip-chars-forward "^,"))
1375 (skip-chars-backward " ")
1376 (push (buffer-substring beg (point))
1378 (skip-chars-forward "^,")
1379 (skip-chars-forward ", "))
1382 (defun gnus-inews-add-to-address (group)
1383 (let ((to-address (mail-fetch-field "to")))
1384 (when (and to-address
1386 ;; This mail group doesn't have a `to-list', so we add one
1388 (when (gnus-y-or-n-p
1389 (format "Do you want to add this as `to-list': %s? " to-address))
1390 (gnus-group-add-parameter group (cons 'to-list to-address))))))
1392 (defun gnus-put-message ()
1393 "Put the current message in some group and return to Gnus."
1395 (let ((reply gnus-article-reply)
1396 (winconf gnus-prev-winconf)
1397 (group gnus-newsgroup-name))
1399 (not (gnus-group-read-only-p group)))
1400 (setq group (read-string "Put in group: " nil (gnus-writable-groups))))
1402 (when (gnus-group-entry group)
1403 (error "No such group: %s" group))
1407 (message-narrow-to-headers)
1408 (let ((gnus-deletable-headers nil))
1409 (message-generate-headers
1410 (if (message-news-p)
1411 message-required-news-headers
1412 message-required-mail-headers)))
1413 (goto-char (point-max))
1414 (if (string-match " " group)
1415 (insert "Gcc: \"" group "\"\n")
1416 (insert "Gcc: " group "\n"))
1419 (when (and (get-buffer gnus-group-buffer)
1420 (gnus-buffer-exists-p (car-safe reply))
1422 (set-buffer (car reply))
1423 (gnus-summary-mark-article-as-replied (cdr reply)))
1425 (set-window-configuration winconf))))
1427 (defun gnus-article-mail (yank)
1428 "Send a reply to the address near point.
1429 If YANK is non-nil, include the original article."
1433 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
1434 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
1436 (gnus-msg-mail address)
1438 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
1440 (defvar nntp-server-type)
1442 "Send a bug report to the Gnus maintainers."
1444 (unless (gnus-alive-p)
1445 (error "Gnus has been shut down"))
1446 (gnus-setup-message (if (message-mail-user-agent) 'message 'bug)
1447 (unless (message-mail-user-agent)
1448 (delete-other-windows)
1449 (when gnus-bug-create-help-buffer
1450 (switch-to-buffer "*Gnus Help Bug*")
1452 (insert gnus-bug-message)
1453 (goto-char (point-min)))
1454 (message-pop-to-buffer "*Gnus Bug*"))
1455 (let ((message-this-is-mail t))
1456 (message-setup `((To . ,gnus-maintainer) (Subject . ""))))
1457 (when gnus-bug-create-help-buffer
1458 (push `(gnus-bug-kill-buffer) message-send-actions))
1459 (goto-char (point-min))
1460 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
1462 (insert (gnus-version) "\n"
1463 (emacs-version) "\n")
1464 (when (and (boundp 'nntp-server-type)
1465 (stringp nntp-server-type))
1466 (insert nntp-server-type))
1467 (insert "\n\n\n\n\n")
1470 (set-buffer (gnus-get-buffer-create " *gnus environment info*"))
1473 (setq text (buffer-string)))
1474 (insert "<#part type=application/emacs-lisp disposition=inline description=\"User settings\">\n" text "\n<#/part>"))
1475 (goto-char (point-min))
1476 (search-forward "Subject: " nil t)
1479 (defun gnus-bug-kill-buffer ()
1480 (when (get-buffer "*Gnus Help Bug*")
1481 (kill-buffer "*Gnus Help Bug*")))
1483 (defun gnus-summary-yank-message (buffer n)
1484 "Yank the current article into a composed message."
1486 (list (completing-read "Buffer: " (mapcar 'list (message-buffers)) nil t)
1487 current-prefix-arg))
1488 (gnus-summary-iterate n
1489 (let ((gnus-inhibit-treatment t))
1490 (gnus-summary-select-article))
1493 (message-yank-buffer gnus-article-buffer))))
1495 (defun gnus-debug ()
1496 "Attempts to go through the Gnus source file and report what variables have been changed.
1497 The source file has to be in the Emacs load path."
1499 (let ((files gnus-debug-files)
1501 file expr olist sym)
1502 (gnus-message 4 "Please wait while we snoop your variables...")
1504 ;; Go through all the files looking for non-default values for variables.
1506 (set-buffer (gnus-get-buffer-create " *gnus bug info*"))
1509 (when (and (setq file (locate-library (pop files)))
1510 (file-exists-p file))
1511 (insert-file-contents file)
1512 (goto-char (point-min))
1513 (if (not (re-search-forward "^;;* *Internal variables" nil t))
1514 (gnus-message 4 "Malformed sources in file %s" file)
1515 (narrow-to-region (point-min) (point))
1516 (goto-char (point-min))
1517 (while (setq expr (ignore-errors (read (current-buffer))))
1519 (and (or (eq (car expr) 'defvar)
1520 (eq (car expr) 'defcustom))
1521 (stringp (nth 3 expr))
1522 (not (memq (nth 1 expr) gnus-debug-exclude-variables))
1523 (or (not (boundp (nth 1 expr)))
1524 (not (equal (eval (nth 2 expr))
1525 (symbol-value (nth 1 expr)))))
1526 (push (nth 1 expr) olist)))))))
1527 (kill-buffer (current-buffer)))
1528 (when (setq olist (nreverse olist))
1529 (insert "------------------ Environment follows ------------------\n\n"))
1531 (if (boundp (car olist))
1535 ,(if (or (consp (setq sym (symbol-value (car olist))))
1537 (not (or (eq sym nil)
1539 (list 'quote (symbol-value (car olist)))
1540 (symbol-value (car olist))))))
1541 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
1542 (setq olist (cdr olist)))
1544 ;; Remove any control chars - they seem to cause trouble for some
1545 ;; mailers. (Byte-compiled output from the stuff above.)
1547 (while (re-search-forward (mm-string-as-multibyte
1548 "[\000-\010\013-\037\200-\237]") nil t)
1549 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
1552 ;;; Treatment of rejected articles.
1555 (defun gnus-summary-resend-bounced-mail (&optional fetch)
1556 "Re-mail the current message.
1557 This only makes sense if the current message is a bounce message that
1558 contains some mail you have written which has been bounced back to
1560 If FETCH, try to fetch the article that this is a reply to, if indeed
1563 (gnus-summary-select-article t)
1564 (set-buffer gnus-original-article-buffer)
1565 (gnus-setup-message 'compose-bounce
1566 (let* ((references (mail-fetch-field "references"))
1567 (parent (and references (gnus-parent-id references))))
1569 ;; If there are references, we fetch the article we answered to.
1571 (gnus-summary-refer-article parent)
1572 (gnus-summary-show-all-headers)))))
1576 (defun gnus-inews-group-method (group)
1578 ;; If the group doesn't exist, we assume
1579 ;; it's an archive group...
1580 ((and (null (gnus-get-info group))
1581 (eq (car (gnus-server-to-method gnus-message-archive-method))
1582 (car (gnus-server-to-method (gnus-group-method group)))))
1583 gnus-message-archive-method)
1585 ((gnus-info-method (gnus-get-info group))
1586 (gnus-info-method (gnus-get-info group)))
1588 (t (gnus-server-to-method (gnus-group-method group)))))
1590 ;; Do Gcc handling, which copied the message over to some group.
1591 (defun gnus-inews-do-gcc (&optional gcc)
1595 (message-narrow-to-headers)
1596 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
1597 (cur (current-buffer))
1598 groups group method group-art
1599 mml-externalize-attachments)
1601 (message-remove-header "gcc")
1603 (setq groups (message-unquote-tokens
1604 (message-tokenize-header gcc " ,")))
1605 ;; Copy the article over to some group(s).
1606 (while (setq group (pop groups))
1607 (unless (gnus-check-server
1608 (setq method (gnus-inews-group-method group)))
1609 (error "Can't open server %s" (if (stringp method) method
1611 (unless (gnus-request-group group nil method)
1612 (gnus-request-create-group group method))
1613 (setq mml-externalize-attachments
1614 (if (stringp gnus-gcc-externalize-attachments)
1615 (string-match gnus-gcc-externalize-attachments group)
1616 gnus-gcc-externalize-attachments))
1618 (nnheader-set-temp-buffer " *acc*")
1619 (insert-buffer-substring cur)
1620 (message-encode-message-body)
1622 (message-narrow-to-headers)
1623 (let* ((mail-parse-charset message-default-charset)
1624 (newsgroups-field (save-restriction
1625 (message-narrow-to-headers-or-head)
1626 (message-fetch-field "Newsgroups")))
1627 (followup-field (save-restriction
1628 (message-narrow-to-headers-or-head)
1629 (message-fetch-field "Followup-To")))
1630 ;; BUG: We really need to get the charset for
1631 ;; each name in the Newsgroups and Followup-To
1632 ;; lines to allow crossposting between group
1633 ;; namess with incompatible character sets.
1634 ;; -- Per Abrahamsen <abraham@dina.kvl.dk> 2001-10-08.
1635 (group-field-charset
1636 (gnus-group-name-charset
1637 method (or newsgroups-field "")))
1638 (followup-field-charset
1639 (gnus-group-name-charset
1640 method (or followup-field "")))
1641 (rfc2047-header-encoding-alist
1643 (when group-field-charset
1644 (list (cons "Newsgroups" group-field-charset)))
1645 (when followup-field-charset
1646 (list (cons "Followup-To" followup-field-charset)))
1647 rfc2047-header-encoding-alist)))
1648 (mail-encode-encoded-word-buffer)))
1649 (goto-char (point-min))
1650 (when (re-search-forward
1651 (concat "^" (regexp-quote mail-header-separator) "$")
1653 (replace-match "" t t ))
1654 (when (or (not (gnus-check-backend-function
1655 'request-accept-article group))
1656 (not (setq group-art
1657 (gnus-request-accept-article
1658 group method t t))))
1659 (gnus-message 1 "Couldn't store article in group %s: %s"
1660 group (gnus-status-message method)))
1661 (when (and group-art
1662 ;; FIXME: Should gcc-mark-as-read work when
1663 ;; Gnus is not running?
1665 (or gnus-gcc-mark-as-read
1667 (boundp 'gnus-inews-mark-gcc-as-read)
1668 (symbol-value 'gnus-inews-mark-gcc-as-read))))
1669 (gnus-group-mark-article-read group (cdr group-art)))
1670 (kill-buffer (current-buffer)))))))))
1672 (defun gnus-inews-insert-gcc ()
1673 "Insert Gcc headers based on `gnus-outgoing-message-group'."
1676 (message-narrow-to-headers)
1677 (let* ((group gnus-outgoing-message-group)
1681 ((or (stringp group) (listp group))
1686 (if (string-match " " gcc)
1687 (concat "\"" gcc "\"")
1689 (mapconcat (lambda (group)
1690 (if (string-match " " group)
1691 (concat "\"" group "\"")
1696 (defun gnus-inews-insert-archive-gcc (&optional group)
1697 "Insert the Gcc to say where the article is to be archived."
1698 (let* ((var gnus-message-archive-group)
1699 (group (or group gnus-newsgroup-name ""))
1701 (and gnus-newsgroup-name
1702 (not (equal gnus-newsgroup-name ""))
1703 (gnus-group-find-parameter
1704 gnus-newsgroup-name 'gcc-self)))
1708 ((null gnus-message-archive-method)
1712 ;; Just a single group.
1715 ;; We don't want this.
1717 ((and (listp var) (stringp (car var)))
1718 ;; A list of groups.
1722 (funcall var group))
1724 ;; An alist of regexps/functions/forms.
1729 ((stringp (caar var))
1731 (when (string-match (caar var) group)
1733 ((functionp (car var))
1735 (funcall (car var) group))
1737 (eval (car var)))))))
1738 (setq var (cdr var)))
1741 (when (or groups gcc-self-val)
1742 (when (stringp groups)
1743 (setq groups (list groups)))
1746 (message-narrow-to-headers)
1747 (goto-char (point-max))
1750 ;; Use the `gcc-self' param value instead.
1753 (if (stringp gcc-self-val)
1754 (if (string-match " " gcc-self-val)
1755 (concat "\"" gcc-self-val "\"")
1757 ;; In nndoc groups, we use the parent group name
1758 ;; instead of the current group.
1759 (let ((group (or (gnus-group-find-parameter
1760 gnus-newsgroup-name 'parent-group)
1762 (if (string-match " " group)
1763 (concat "\"" group "\"")
1765 (if (not (eq gcc-self-val 'none))
1767 (gnus-delete-line)))
1768 ;; Use the list of groups.
1769 (while (setq name (pop groups))
1770 (let ((str (if (string-match ":" name)
1772 (gnus-group-prefixed-name
1773 name gnus-message-archive-method))))
1774 (insert (if (string-match " " str)
1775 (concat "\"" str "\"")
1781 (defun gnus-mailing-list-followup-to ()
1782 "Look at the headers in the current buffer and return a Mail-Followup-To address."
1783 (let ((x-been-there (gnus-fetch-original-field "x-beenthere"))
1784 (list-post (gnus-fetch-original-field "list-post")))
1785 (when (and list-post
1786 (string-match "mailto:\\([^>]+\\)" list-post))
1787 (setq list-post (match-string 1 list-post)))
1793 (defun gnus-configure-posting-styles (&optional group-name)
1794 "Configure posting styles according to `gnus-posting-styles'."
1795 (unless gnus-inhibit-posting-styles
1796 (let ((group (or group-name gnus-newsgroup-name ""))
1797 (styles gnus-posting-styles)
1798 style match attribute value v results
1799 filep name address element)
1800 ;; If the group has a posting-style parameter, add it at the end with a
1801 ;; regexp matching everything, to be sure it takes precedence over all
1803 (when gnus-newsgroup-name
1804 (let ((tmp-style (gnus-group-find-parameter group 'posting-style t)))
1806 (setq styles (append styles (list (cons ".*" tmp-style)))))))
1807 ;; Go through all styles and look for matches.
1808 (dolist (style styles)
1809 (setq match (pop style))
1810 (goto-char (point-min))
1813 ;; Regexp string match on the group name.
1814 (string-match match group))
1816 ;; Obsolete format of header match.
1817 (and (gnus-buffer-live-p gnus-article-copy)
1818 (with-current-buffer gnus-article-copy
1820 (nnheader-narrow-to-headers)
1821 (let ((header (message-fetch-field (pop style))))
1823 (string-match (pop style) header)))))))
1824 ((or (symbolp match)
1828 ;; Function to be called.
1831 ;; Variable to be checked.
1832 (symbol-value match))))
1835 ((eq (car match) 'header)
1836 ;; New format of header match.
1837 (and (gnus-buffer-live-p gnus-article-copy)
1838 (with-current-buffer gnus-article-copy
1840 (nnheader-narrow-to-headers)
1841 (let ((header (message-fetch-field (nth 1 match))))
1843 (string-match (nth 2 match) header)))))))
1845 ;; This is a form to be evaled.
1847 ;; We have a match, so we set the variables.
1848 (dolist (attribute style)
1849 (setq element (pop attribute)
1853 ((eq (car attribute) :file)
1856 ((eq (car attribute) :value)
1860 ;; We get the value.
1865 ((or (symbolp value)
1867 (cond ((functionp value)
1870 (symbol-value value))))
1873 ;; Translate obsolescent value.
1875 ((eq element 'signature-file)
1876 (setq element 'signature
1878 ((eq element 'x-face-file)
1879 (setq element 'x-face
1881 ;; Get the contents of file elems.
1883 (setq v (with-temp-buffer
1884 (insert-file-contents v)
1888 (goto-char (point-max))
1889 (if (zerop (skip-chars-backward "\n"))
1892 (setq results (delq (assoc element results) results))
1893 (push (cons element v) results))))
1894 ;; Now we have all the styles, so we insert them.
1895 (setq name (assq 'name results)
1896 address (assq 'address results))
1897 (setq results (delq name (delq address results)))
1898 (gnus-make-local-hook 'message-setup-hook)
1899 (setq results (sort results (lambda (x y)
1900 (string-lessp (car x) (car y)))))
1901 (dolist (result results)
1902 (add-hook 'message-setup-hook
1904 ((eq 'eval (car result))
1906 ((eq 'body (car result))
1910 (insert ,(cdr result)))))
1911 ((eq 'signature (car result))
1912 (set (make-local-variable 'message-signature) nil)
1913 (set (make-local-variable 'message-signature-file) nil)
1914 (if (not (cdr result))
1918 (let ((message-signature ,(cdr result)))
1919 (when message-signature
1920 (message-insert-signature)))))))
1923 (if (symbolp (car result))
1924 (capitalize (symbol-name (car result)))
1928 (message-remove-header ,header)
1929 (let ((value ,(cdr result)))
1932 (insert ,header ": " value)
1934 (insert "\n")))))))))
1936 (when (or name address)
1937 (add-hook 'message-setup-hook
1939 (set (make-local-variable 'user-mail-address)
1940 ,(or (cdr address) user-mail-address))
1941 (let ((user-full-name ,(or (cdr name) (user-full-name)))
1943 ,(or (cdr address) user-mail-address)))
1945 (message-remove-header "From")
1947 (insert "From: " (message-make-from) "\n"))))
1950 ;;; Allow redefinition of functions.
1956 ;;; arch-tag: 9f22b2f5-1c0a-49de-916e-4c88e984852b
1957 ;;; gnus-msg.el ends here