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, 2007 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 3, 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."
112 :options '(message-remove-blank-cited-lines)
115 (defcustom gnus-bug-create-help-buffer t
116 "*Should we create the *Gnus Help Bug* buffer?"
120 (defcustom gnus-posting-styles nil
121 "*Alist of styles to use when posting.
122 See Info node `(gnus)Posting Styles'."
124 :link '(custom-manual "(gnus)Posting Styles")
125 :type '(repeat (cons (choice (regexp)
128 (string :tag "Header")
129 (regexp :tag "Regexp"))
133 (choice (const signature)
134 (const signature-file)
141 (string :tag "Header"))
147 (defcustom gnus-gcc-mark-as-read nil
148 "If non-nil, automatically mark Gcc articles as read."
153 (make-obsolete-variable 'gnus-inews-mark-gcc-as-read
154 'gnus-gcc-mark-as-read)
156 (defcustom gnus-gcc-externalize-attachments nil
157 "Should local-file attachments be included as external parts in Gcc copies?
158 If it is `all', attach files as external parts;
159 if a regexp and matches the Gcc group name, attach files as external parts;
160 if nil, attach files as normal parts."
163 :type '(choice (const nil :tag "None")
164 (const all :tag "Any")
165 (string :tag "Regexp")))
167 (gnus-define-group-parameter
168 posting-charset-alist
171 "Return the permitted unencoded charsets for posting of GROUP."
172 :variable gnus-group-posting-charset-alist
174 '(("^\\(no\\|fr\\)\\.[^,]*\\(,[ \t\n]*\\(no\\|fr\\)\\.[^,]*\\)*$" iso-8859-1 (iso-8859-1))
175 ("^\\(fido7\\|relcom\\)\\.[^,]*\\(,[ \t\n]*\\(fido7\\|relcom\\)\\.[^,]*\\)*$" koi8-r (koi8-r))
176 (message-this-is-mail nil nil)
177 (message-this-is-news nil t))
179 "Alist of regexps and permitted unencoded charsets for posting.
180 Each element of the alist has the form (TEST HEADER BODY-LIST), where
181 TEST is either a regular expression matching the newsgroup header or a
183 HEADER is the charset which may be left unencoded in the header (nil
184 means encode all charsets),
185 BODY-LIST is a list of charsets which may be encoded using 8bit
186 content-transfer encoding in the body, or one of the special values
187 nil (always encode using quoted-printable) or t (always use 8bit).
189 Note that any value other than nil for HEADER infringes some RFCs, so
190 use this option with care."
191 :variable-group gnus-charset
193 '(repeat (list :tag "Permitted unencoded charsets"
195 (regexp :tag "Group")
196 (const :tag "Mail message" :value message-this-is-mail)
197 (const :tag "News article" :value message-this-is-news))
198 (choice :tag "Header"
199 (const :tag "None" nil)
200 (symbol :tag "Charset"))
202 (const :tag "Any" :value t)
203 (const :tag "None" :value nil)
204 (repeat :tag "Charsets"
205 (symbol :tag "Charset")))))
206 :parameter-type '(choice :tag "Permitted unencoded charsets"
209 :parameter-document "\
210 List of charsets that are permitted to be unencoded.")
212 (defcustom gnus-debug-files
213 '("gnus.el" "gnus-sum.el" "gnus-group.el"
214 "gnus-art.el" "gnus-start.el" "gnus-async.el"
215 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
216 "gnus-agent.el" "gnus-cache.el" "gnus-srvr.el"
217 "mm-util.el" "mm-decode.el" "nnmail.el" "message.el")
218 "Files whose variables will be reported in `gnus-bug'."
221 :type '(repeat (string :tag "File")))
223 (defcustom gnus-debug-exclude-variables
224 '(mm-mime-mule-charset-alist
225 nnmail-split-fancy message-minibuffer-local-map)
226 "Variables that should not be reported in `gnus-bug'."
229 :type '(repeat (symbol :tag "Variable")))
231 (defcustom gnus-discouraged-post-methods
232 '(nndraft nnml nnimap nnmaildir nnmh nnfolder nndir)
233 "A list of back ends that are not used in \"real\" newsgroups.
234 This variable is used only when `gnus-post-method' is `current'."
236 :group 'gnus-group-foreign
237 :type '(repeat (symbol :tag "Back end")))
239 (defcustom gnus-message-replysign
241 "Automatically sign replies to signed messages.
242 See also the `mml-default-sign-method' variable."
246 (defcustom gnus-message-replyencrypt
248 "Automatically encrypt replies to encrypted messages.
249 See also the `mml-default-encrypt-method' variable."
253 (defcustom gnus-message-replysignencrypted
255 "Setting this causes automatically encrypted messages to also be signed."
259 (defcustom gnus-confirm-mail-reply-to-news (and gnus-novice-user
260 (not gnus-expert-user))
261 "If non-nil, Gnus requests confirmation when replying to news.
262 This is done because new users often reply by mistake when reading
264 This can also be a function receiving the group name as the only
265 parameter, which should return non-nil if a confirmation is needed; or
266 a regexp, in which case a confirmation is asked for if the group name
270 :type '(choice (const :tag "No" nil)
272 (regexp :tag "If group matches regexp")
273 (function :tag "If function evaluates to non-nil")))
275 (defcustom gnus-confirm-treat-mail-like-news
277 "If non-nil, Gnus will treat mail like news with regard to confirmation
278 when replying by mail. See the `gnus-confirm-mail-reply-to-news' variable
279 for fine-tuning this.
280 If nil, Gnus will never ask for confirmation if replying to mail."
285 (defcustom gnus-summary-resend-default-address t
286 "If non-nil, Gnus tries to suggest a default address to resend to.
287 If nil, the address field will always be empty after invoking
288 `gnus-summary-resend-message'."
293 (defcustom gnus-message-highlight-citation
294 t ;; gnus-treat-highlight-citation ;; gnus-cite dependency
295 "Enable highlighting of different citation levels in message-mode."
296 :version "23.0" ;; No Gnus
301 (autoload 'gnus-message-citation-mode "gnus-cite" nil t)
303 ;;; Internal variables.
305 (defvar gnus-inhibit-posting-styles nil
306 "Inhibit the use of posting styles.")
308 (defvar gnus-article-yanked-articles nil)
309 (defvar gnus-message-buffer "*Mail Gnus*")
310 (defvar gnus-article-copy nil)
311 (defvar gnus-check-before-posting nil)
312 (defvar gnus-last-posting-server nil)
313 (defvar gnus-message-group-art nil)
315 (defvar gnus-msg-force-broken-reply-to nil)
317 (defconst gnus-bug-message
318 "Sending a bug report to the Gnus Towers.
319 ========================================
321 The buffer below is a mail buffer. When you press `C-c C-c', it will
322 be sent to the Gnus Bug Exterminators.
324 The thing near the bottom of the buffer is how the environment
325 settings will be included in the mail. Please do not delete that.
326 They will tell the Bug People what your environment is, so that it
327 will be easier to locate the bugs.
329 If you have found a bug that makes Emacs go \"beep\", set
330 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
331 and include the backtrace in your bug report.
333 Please describe the bug in annoying, painstaking detail.
335 Thank you for your help in stamping out bugs.
339 (autoload 'gnus-uu-post-news "gnus-uu" nil t))
343 ;;; Gnus Posting Functions
346 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
347 "p" gnus-summary-post-news
348 "i" gnus-summary-news-other-window
349 "f" gnus-summary-followup
350 "F" gnus-summary-followup-with-original
351 "c" gnus-summary-cancel-article
352 "s" gnus-summary-supersede-article
353 "r" gnus-summary-reply
354 "y" gnus-summary-yank-message
355 "R" gnus-summary-reply-with-original
356 "w" gnus-summary-wide-reply
357 "W" gnus-summary-wide-reply-with-original
358 "v" gnus-summary-very-wide-reply
359 "V" gnus-summary-very-wide-reply-with-original
360 "n" gnus-summary-followup-to-mail
361 "N" gnus-summary-followup-to-mail-with-original
362 "m" gnus-summary-mail-other-window
363 "u" gnus-uu-post-news
364 "\M-c" gnus-summary-mail-crosspost-complaint
365 "Br" gnus-summary-reply-broken-reply-to
366 "BR" gnus-summary-reply-broken-reply-to-with-original
367 "om" gnus-summary-mail-forward
368 "op" gnus-summary-post-forward
369 "Om" gnus-uu-digest-mail-forward
370 "Op" gnus-uu-digest-post-forward)
372 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
373 "b" gnus-summary-resend-bounced-mail
374 ;; "c" gnus-summary-send-draft
375 "r" gnus-summary-resend-message
376 "e" gnus-summary-resend-message-edit)
378 ;;; Internal functions.
380 (defun gnus-inews-make-draft (articles)
382 (gnus-inews-make-draft-meta-information
383 ,(gnus-group-decoded-name gnus-newsgroup-name) ',articles)))
385 (defvar gnus-article-reply nil)
386 (defmacro gnus-setup-message (config &rest forms)
387 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
388 (buffer (make-symbol "gnus-setup-message-buffer"))
389 (article (make-symbol "gnus-setup-message-article"))
390 (yanked (make-symbol "gnus-setup-yanked-articles"))
391 (group (make-symbol "gnus-setup-message-group")))
392 `(let ((,winconf (current-window-configuration))
393 (,buffer (buffer-name (current-buffer)))
394 (,article gnus-article-reply)
395 (,yanked gnus-article-yanked-articles)
396 (,group gnus-newsgroup-name)
397 (message-header-setup-hook
398 (copy-sequence message-header-setup-hook))
399 (mbl mml-buffer-list)
400 (message-mode-hook (copy-sequence message-mode-hook)))
401 (setq mml-buffer-list nil)
402 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
403 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
404 ;; message-newsreader and message-mailer were formerly set in
405 ;; gnus-inews-add-send-actions, but this is too late when
406 ;; message-generate-headers-first is used. --ansel
407 (add-hook 'message-mode-hook
409 (setq message-newsreader
410 (setq message-mailer (gnus-extended-version)))))
411 ;; #### FIXME: for a reason that I did not manage to identify yet,
412 ;; the variable `gnus-newsgroup-name' does not honor a dynamically
413 ;; scoped or setq'ed value from a caller like `C-u gnus-summary-mail'.
414 ;; After evaluation of @forms below, it gets the value we actually want
415 ;; to override, and the posting styles are used. For that reason, I've
416 ;; added an optional argument to `gnus-configure-posting-styles' to
417 ;; make sure that the correct value for the group name is used. -- drv
418 (add-hook 'message-mode-hook
419 (if (memq ,config '(reply-yank reply))
421 (gnus-configure-posting-styles ,group))
423 ;; There may be an old " *gnus article copy*" buffer.
424 (let (gnus-article-copy)
425 (gnus-configure-posting-styles ,group)))))
426 (gnus-pull ',(intern gnus-draft-meta-information-header)
427 message-required-headers)
429 (not (string= ,group "")))
431 (intern gnus-draft-meta-information-header)
432 (gnus-inews-make-draft (or ,yanked ,article)))
433 message-required-headers))
437 (gnus-inews-add-send-actions ,winconf ,buffer ,article ,config
439 (setq gnus-message-buffer (current-buffer))
440 (set (make-local-variable 'gnus-message-group-art)
441 (cons ,group ,article))
442 (set (make-local-variable 'gnus-newsgroup-name) ,group)
443 ;; Enable highlighting of different citation levels
444 (when gnus-message-highlight-citation
445 (gnus-message-citation-mode 1))
446 (gnus-run-hooks 'gnus-message-setup-hook)
447 (if (eq major-mode 'message-mode)
448 (let ((mbl1 mml-buffer-list))
449 (setq mml-buffer-list mbl) ;; Global value
450 (set (make-local-variable 'mml-buffer-list) mbl1);; Local value
451 (gnus-make-local-hook 'kill-buffer-hook)
452 (gnus-make-local-hook 'change-major-mode-hook)
453 (add-hook 'change-major-mode-hook 'mml-destroy-buffers nil t)
454 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))
455 (mml-destroy-buffers)
456 (setq mml-buffer-list mbl)))
457 (message-hide-headers)
459 (gnus-configure-windows ,config t)
460 (run-hooks 'post-command-hook)
461 (set-buffer-modified-p nil))))
463 (defun gnus-inews-make-draft-meta-information (group articles)
464 (when (numberp articles)
465 (setq articles (list articles)))
466 (concat "(\"" group "\""
480 (defun gnus-msg-mail (&optional to subject other-headers continue
481 switch-action yank-action send-actions)
482 "Start editing a mail message to be sent.
483 Like `message-mail', but with Gnus paraphernalia, particularly the
484 Gcc: header for archiving purposes."
486 (let ((buf (current-buffer))
488 (gnus-setup-message 'message
489 (message-mail to subject other-headers continue
490 nil yank-action send-actions))
492 (setq mail-buf (current-buffer))
493 (switch-to-buffer buf)
494 (apply switch-action mail-buf nil)))
495 ;; COMPOSEFUNC should return t if succeed. Undocumented ???
499 (defun gnus-button-mailto (address)
501 (set-buffer (gnus-copy-article-buffer))
502 (gnus-setup-message 'message
503 (message-reply address)))
506 (defun gnus-button-reply (&optional to-address wide)
507 "Like `message-reply'."
509 (gnus-setup-message 'message
510 (message-reply to-address wide)))
513 (define-mail-user-agent 'gnus-user-agent
514 'gnus-msg-mail 'message-send-and-exit
515 'message-kill-buffer 'message-send-hook)
517 (defun gnus-setup-posting-charset (group)
518 (let ((alist gnus-group-posting-charset-alist)
519 (group (or group ""))
523 (while (setq elem (pop alist))
524 (when (or (and (stringp (car elem))
525 (string-match (car elem) group))
526 (and (functionp (car elem))
527 (funcall (car elem) group))
528 (and (symbolp (car elem))
529 (symbol-value (car elem))))
530 (throw 'found (cons (cadr elem) (caddr elem)))))))))
532 (defun gnus-inews-add-send-actions (winconf buffer article
533 &optional config yanked)
534 (gnus-make-local-hook 'message-sent-hook)
535 (add-hook 'message-sent-hook (if gnus-agent 'gnus-agent-possibly-do-gcc
536 'gnus-inews-do-gcc) nil t)
538 (gnus-make-local-hook 'message-header-hook)
539 (add-hook 'message-header-hook 'gnus-agent-possibly-save-gcc nil t))
540 (setq message-post-method
541 `(lambda (&optional arg)
542 (gnus-post-method arg ,gnus-newsgroup-name)))
544 `(when (gnus-buffer-exists-p ,buffer)
545 (set-window-configuration ,winconf))
546 'exit 'postpone 'kill)
547 (let ((to-be-marked (cond
550 (lambda (x) (if (listp x) (car x) x)) yanked))
551 (article (if (listp article) article (list article)))
554 `(when (gnus-buffer-exists-p ,buffer)
558 (if (eq config 'forward)
559 `(gnus-summary-mark-article-as-forwarded ',to-be-marked)
560 `(gnus-summary-mark-article-as-replied ',to-be-marked)))))
563 (put 'gnus-setup-message 'lisp-indent-function 1)
564 (put 'gnus-setup-message 'edebug-form-spec '(form body))
566 ;;; Post news commands of Gnus group mode and summary mode
568 (defun gnus-group-mail (&optional arg)
569 "Start composing a mail.
570 If ARG, use the group under the point to find a posting style.
571 If ARG is 1, prompt for a group name to find the posting style."
573 ;; We can't `let' gnus-newsgroup-name here, since that leads
574 ;; to local variables leaking.
575 (let ((group gnus-newsgroup-name)
576 ;; make sure last viewed article doesn't affect posting styles:
578 (buffer (current-buffer)))
581 (setq gnus-newsgroup-name
583 (if (= 1 (prefix-numeric-value arg))
584 (gnus-group-completing-read
585 "Use posting style of group: "
586 nil nil (gnus-read-active-file-p))
587 (gnus-group-group-name))
589 ;; #### see comment in gnus-setup-message -- drv
590 (gnus-setup-message 'message (message-mail)))
593 (setq gnus-newsgroup-name group)))))
595 (defun gnus-group-news (&optional arg)
596 "Start composing a news.
597 If ARG, post to group under point.
598 If ARG is 1, prompt for group name to post to.
600 This function prepares a news even when using mail groups. This is useful
601 for posting messages to mail groups without actually sending them over the
602 network. The corresponding back end must have a 'request-post method."
604 ;; We can't `let' gnus-newsgroup-name here, since that leads
605 ;; to local variables leaking.
606 (let ((group gnus-newsgroup-name)
607 ;; make sure last viewed article doesn't affect posting styles:
609 (buffer (current-buffer)))
612 (setq gnus-newsgroup-name
614 (if (= 1 (prefix-numeric-value arg))
615 (gnus-group-completing-read "Use group: "
617 (gnus-read-active-file-p))
618 (gnus-group-group-name))
620 ;; #### see comment in gnus-setup-message -- drv
621 (gnus-setup-message 'message
622 (message-news (gnus-group-real-name gnus-newsgroup-name))))
625 (setq gnus-newsgroup-name group)))))
627 (defun gnus-group-post-news (&optional arg)
628 "Start composing a message (a news by default).
629 If ARG, post to group under point. If ARG is 1, prompt for group name.
630 Depending on the selected group, the message might be either a mail or
633 ;; Bind this variable here to make message mode hooks work ok.
634 (let ((gnus-newsgroup-name
636 (if (= 1 (prefix-numeric-value arg))
637 (gnus-group-completing-read "Newsgroup: " nil nil
638 (gnus-read-active-file-p))
639 (gnus-group-group-name))
641 ;; make sure last viewed article doesn't affect posting styles:
643 (gnus-post-news 'post gnus-newsgroup-name nil nil nil nil
644 (string= gnus-newsgroup-name ""))))
646 (defun gnus-summary-mail-other-window (&optional arg)
647 "Start composing a mail in another window.
648 Use the posting of the current group by default.
649 If ARG, don't do that. If ARG is 1, prompt for group name to find the
652 ;; We can't `let' gnus-newsgroup-name here, since that leads
653 ;; to local variables leaking.
654 (let ((group gnus-newsgroup-name)
655 ;; make sure last viewed article doesn't affect posting styles:
657 (buffer (current-buffer)))
660 (setq gnus-newsgroup-name
662 (if (= 1 (prefix-numeric-value arg))
663 (gnus-group-completing-read "Use group: "
665 (gnus-read-active-file-p))
667 gnus-newsgroup-name))
668 ;; #### see comment in gnus-setup-message -- drv
669 (gnus-setup-message 'message (message-mail)))
672 (setq gnus-newsgroup-name group)))))
674 (defun gnus-summary-news-other-window (&optional arg)
675 "Start composing a news in another window.
676 Post to the current group by default.
677 If ARG, don't do that. If ARG is 1, prompt for group name to post to.
679 This function prepares a news even when using mail groups. This is useful
680 for posting messages to mail groups without actually sending them over the
681 network. The corresponding back end must have a 'request-post method."
683 ;; We can't `let' gnus-newsgroup-name here, since that leads
684 ;; to local variables leaking.
685 (let ((group gnus-newsgroup-name)
686 ;; make sure last viewed article doesn't affect posting styles:
688 (buffer (current-buffer)))
691 (setq gnus-newsgroup-name
693 (if (= 1 (prefix-numeric-value arg))
694 (gnus-group-completing-read "Use group: "
696 (gnus-read-active-file-p))
698 gnus-newsgroup-name))
699 ;; #### see comment in gnus-setup-message -- drv
700 (gnus-setup-message 'message
702 (message-news (gnus-group-real-name gnus-newsgroup-name))
703 (set (make-local-variable 'gnus-discouraged-post-methods)
705 (car (gnus-find-method-for-group gnus-newsgroup-name))
706 gnus-discouraged-post-methods)))))
709 (setq gnus-newsgroup-name group)))))
711 (defun gnus-summary-post-news (&optional arg)
712 "Start composing a message. Post to the current group by default.
713 If ARG, don't do that. If ARG is 1, prompt for a group name to post to.
714 Depending on the selected group, the message might be either a mail or
717 ;; Bind this variable here to make message mode hooks work ok.
718 (let ((gnus-newsgroup-name
720 (if (= 1 (prefix-numeric-value arg))
721 (gnus-group-completing-read "Newsgroup: " nil nil
722 (gnus-read-active-file-p))
724 gnus-newsgroup-name))
725 ;; make sure last viewed article doesn't affect posting styles:
727 (gnus-post-news 'post gnus-newsgroup-name)))
730 (defun gnus-summary-followup (yank &optional force-news)
731 "Compose a followup to an article.
732 If prefix argument YANK is non-nil, the original article is yanked
734 YANK is a list of elements, where the car of each element is the
735 article number, and the cdr is the string to be yanked."
737 (list (and current-prefix-arg
738 (gnus-summary-work-articles 1))))
740 (gnus-summary-goto-subject
741 (if (listp (car yank))
744 (save-window-excursion
745 (gnus-summary-select-article))
746 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
747 (gnus-newsgroup-name gnus-newsgroup-name))
749 (gnus-post-news nil gnus-newsgroup-name
750 headers gnus-article-buffer
752 (gnus-summary-handle-replysign)))
754 (defun gnus-summary-followup-with-original (n &optional force-news)
755 "Compose a followup to an article and include the original article.
756 The text in the region will be yanked. If the region isn't
757 active, the entire article will be yanked."
759 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
761 (defun gnus-summary-followup-to-mail (&optional arg)
762 "Followup to the current mail message via news."
764 (list (and current-prefix-arg
765 (gnus-summary-work-articles 1))))
766 (gnus-summary-followup arg t))
768 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
769 "Followup to the current mail message via news."
771 (gnus-summary-followup (gnus-summary-work-articles arg) t))
773 (defun gnus-inews-yank-articles (articles)
774 (let (beg article yank-string)
776 (while (setq article (pop articles))
777 (when (listp article)
778 (setq yank-string (nth 1 article)
779 article (nth 0 article)))
780 (save-window-excursion
781 (set-buffer gnus-summary-buffer)
782 (gnus-summary-select-article nil nil nil article)
783 (gnus-summary-remove-process-mark article))
784 (gnus-copy-article-buffer nil yank-string)
785 (let ((message-reply-buffer gnus-article-copy)
786 (message-reply-headers
787 ;; The headers are decoded.
788 (with-current-buffer gnus-article-copy
790 (nnheader-narrow-to-headers)
791 (nnheader-parse-naked-head)))))
792 (message-yank-original)
793 (message-exchange-point-and-mark)
794 (setq beg (or beg (mark t))))
800 (defun gnus-summary-cancel-article (&optional n symp)
801 "Cancel an article you posted.
802 Uses the process-prefix convention. If given the symbolic
803 prefix `a', cancel using the standard posting method; if not
804 post using the current select method."
805 (interactive (gnus-interactive "P\ny"))
806 (let ((message-post-method
808 (gnus-post-method (eq ',symp 'a) ,gnus-newsgroup-name))))
809 (dolist (article (gnus-summary-work-articles n))
810 (when (gnus-summary-select-article t nil nil article)
811 (when (gnus-eval-in-buffer-window gnus-original-article-buffer
812 (message-cancel-news))
813 (gnus-summary-mark-as-read article gnus-canceled-mark)
814 (gnus-cache-remove-article 1))
815 (gnus-article-hide-headers-if-wanted))
816 (gnus-summary-remove-process-mark article))))
818 (defun gnus-summary-supersede-article ()
819 "Compose an article that will supersede a previous article.
820 This is done simply by taking the old article and adding a Supersedes
821 header line with the old Message-ID."
823 (let ((article (gnus-summary-article-number)))
824 (gnus-setup-message 'reply-yank
825 (gnus-summary-select-article t)
826 (set-buffer gnus-original-article-buffer)
830 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
832 (set-buffer ,gnus-summary-buffer)
833 (gnus-cache-possibly-remove-article ,article nil nil nil t)
834 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
835 message-send-actions)
837 (gnus-inews-insert-archive-gcc)
838 (gnus-inews-insert-gcc))))
842 (defun gnus-copy-article-buffer (&optional article-buffer yank-string)
843 ;; make a copy of the article buffer with all text properties removed
844 ;; this copy is in the buffer gnus-article-copy.
845 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
846 ;; this buffer should be passed to all mail/news reply/post routines.
847 (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
849 (set-buffer gnus-article-copy)
850 (mm-enable-multibyte))
851 (let ((article-buffer (or article-buffer gnus-article-buffer))
853 (if (not (and (get-buffer article-buffer)
854 (gnus-buffer-exists-p article-buffer)))
855 (error "Can't find any article buffer")
857 (set-buffer article-buffer)
858 (let ((gnus-newsgroup-charset (or gnus-article-charset
859 gnus-newsgroup-charset))
860 (gnus-newsgroup-ignored-charsets
861 (or gnus-article-ignored-charsets
862 gnus-newsgroup-ignored-charsets)))
864 ;; Copy over the (displayed) article buffer, delete
865 ;; hidden text and remove text properties.
867 (copy-to-buffer gnus-article-copy (point-min) (point-max))
868 (set-buffer gnus-article-copy)
871 (delete-region (point) (point-max))
872 (insert yank-string))
873 (gnus-article-delete-text-of-type 'annotation)
874 (gnus-article-delete-text-of-type 'multipart)
875 (gnus-remove-text-with-property 'gnus-prev)
876 (gnus-remove-text-with-property 'gnus-next)
877 (gnus-remove-text-with-property 'gnus-decoration)
880 (buffer-substring-no-properties (point-min) (point-max))
882 ;; Find the original headers.
883 (set-buffer gnus-original-article-buffer)
884 (goto-char (point-min))
885 (while (looking-at message-unix-mail-delimiter)
887 (let ((mail-header-separator ""))
889 end (or (message-goto-body)
890 ;; There may be just a header.
892 ;; Delete the headers from the displayed articles.
893 (set-buffer gnus-article-copy)
894 (let ((mail-header-separator ""))
895 (delete-region (goto-char (point-min))
896 (or (message-goto-body) (point-max))))
897 ;; Insert the original article headers.
898 (insert-buffer-substring gnus-original-article-buffer beg end)
900 (let ((gnus-article-decode-hook
901 (delq 'article-decode-charset
902 (copy-sequence gnus-article-decode-hook)))
903 (rfc2047-quote-decoded-words-containing-tspecials t))
904 (run-hooks 'gnus-article-decode-hook)))))
907 (defun gnus-post-news (post &optional group header article-buffer yank subject
910 (gnus-copy-article-buffer))
911 (let ((gnus-article-reply (and article-buffer (gnus-summary-article-number)))
912 (gnus-article-yanked-articles yank)
913 (add-to-list gnus-add-to-list))
914 (gnus-setup-message (cond (yank 'reply-yank)
915 (article-buffer 'reply)
917 (let* ((group (or group gnus-newsgroup-name))
918 (charset (gnus-group-name-charset nil group))
920 to-address to-group mailing-list to-list
923 (setq to-address (gnus-parameter-to-address group)
924 to-group (gnus-group-find-parameter group 'to-group)
925 to-list (gnus-parameter-to-list group)
926 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
927 mailing-list (when gnus-mailing-list-groups
928 (string-match gnus-mailing-list-groups group))
929 group (gnus-group-name-decode (gnus-group-real-name group)
931 (if (or (and to-group
932 (gnus-news-group-p to-group))
935 (and (gnus-news-group-p
936 (or pgroup gnus-newsgroup-name)
937 (or header gnus-current-article))
945 (and (not (gnus-virtual-group-p pgroup)) group)))
946 (set-buffer gnus-article-copy)
947 (gnus-msg-treat-broken-reply-to)
948 (message-followup (if (or newsgroup-p force-news)
949 (if (save-restriction
950 (article-narrow-to-head)
951 (message-fetch-field "newsgroups"))
958 (message-mail (or to-address to-list))
959 ;; Arrange for mail groups that have no `to-address' to
960 ;; get that when the user sends off the mail.
961 (when (and (not to-list)
964 (push (list 'gnus-inews-add-to-address pgroup)
965 message-send-actions)))
966 (set-buffer gnus-article-copy)
967 (gnus-msg-treat-broken-reply-to)
968 (message-wide-reply to-address)))
970 (gnus-inews-yank-articles yank))))))
972 (defun gnus-msg-treat-broken-reply-to (&optional force)
973 "Remove the Reply-to header if broken-reply-to."
975 (gnus-group-find-parameter
976 gnus-newsgroup-name 'broken-reply-to))
978 (message-narrow-to-head)
979 (message-remove-header "reply-to"))))
981 (defun gnus-post-method (arg group &optional silent)
982 "Return the posting method based on GROUP and ARG.
983 If SILENT, don't prompt the user."
984 (let ((gnus-post-method (or (gnus-parameter-post-method group)
986 (group-method (gnus-find-method-for-group group)))
988 ;; If the group-method is nil (which shouldn't happen) we use
989 ;; the default method.
991 (or (and (listp gnus-post-method) ;If not current/native/nil
992 (not (listp (car gnus-post-method))) ; and not a list of methods
993 gnus-post-method) ;then use it.
995 message-post-method))
996 ;; We want the inverse of the default
997 ((and arg (not (eq arg 0)))
998 (if (eq gnus-post-method 'current)
1001 ;; We query the user for a post method.
1003 (and (listp gnus-post-method)
1004 (listp (car gnus-post-method))))
1006 ;; Collect all methods we know about.
1008 (when (listp gnus-post-method)
1009 (if (listp (car gnus-post-method))
1011 (list gnus-post-method)))
1012 gnus-secondary-select-methods
1013 (mapcar 'cdr gnus-server-alist)
1014 (mapcar 'car gnus-opened-servers)
1015 (list gnus-select-method)
1016 (list group-method)))
1017 method-alist post-methods method)
1018 ;; Weed out all mail methods.
1020 (setq method (gnus-server-get-method "" (pop methods)))
1021 (when (and (or (gnus-method-option-p method 'post)
1022 (gnus-method-option-p method 'post-mail))
1023 (not (member method post-methods)))
1024 (push method post-methods)))
1025 ;; Create a name-method alist.
1029 (if (equal (cadr m) "")
1030 (list (symbol-name (car m)) m)
1031 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m)))
1036 (setq gnus-last-posting-server
1038 gnus-last-posting-server)
1039 ;; Just use the last value.
1040 gnus-last-posting-server
1042 "Posting method: " method-alist nil t
1043 (cons (or gnus-last-posting-server "") 0))))
1045 ;; Override normal method.
1046 ((and (eq gnus-post-method 'current)
1047 (not (memq (car group-method) gnus-discouraged-post-methods))
1048 (gnus-get-function group-method 'request-post t))
1051 ;; Use gnus-post-method.
1052 ((listp gnus-post-method) ;A method...
1053 (assert (not (listp (car gnus-post-method)))) ;... not a list of methods.
1055 ;; Use the normal select method (nil or native).
1056 (t gnus-select-method))))
1060 (defun gnus-extended-version ()
1061 "Stringified Gnus version and Emacs version.
1062 See the variable `gnus-user-agent'."
1064 (if (stringp gnus-user-agent)
1066 ;; `gnus-user-agent' is a list:
1067 (let* ((float-output-format nil)
1069 (when (memq 'gnus gnus-user-agent)
1071 (prin1-to-string (gnus-continuum-version gnus-version) t)
1072 " (" gnus-version ")")))
1073 (emacs-v (gnus-emacs-version)))
1074 (concat gnus-v (when (and gnus-v emacs-v) " ")
1079 ;;; Gnus Mail Functions
1082 ;;; Mail reply commands of Gnus summary mode
1084 (defun gnus-summary-reply (&optional yank wide very-wide)
1085 "Start composing a mail reply to the current message.
1086 If prefix argument YANK is non-nil, the original article is yanked
1088 If WIDE, make a wide reply.
1089 If VERY-WIDE, make a very wide reply."
1091 (list (and current-prefix-arg
1092 (gnus-summary-work-articles 1))))
1093 ;; Allow user to require confirmation before replying by mail to the
1094 ;; author of a news article (or mail message).
1096 (not (or (gnus-news-group-p gnus-newsgroup-name)
1097 gnus-confirm-treat-mail-like-news))
1098 (not (cond ((stringp gnus-confirm-mail-reply-to-news)
1099 (string-match gnus-confirm-mail-reply-to-news
1100 gnus-newsgroup-name))
1101 ((functionp gnus-confirm-mail-reply-to-news)
1102 (funcall gnus-confirm-mail-reply-to-news gnus-newsgroup-name))
1103 (t gnus-confirm-mail-reply-to-news)))
1104 (y-or-n-p "Really reply by mail to article author? "))
1106 (if (listp (car yank))
1109 (gnus-article-reply (or article (gnus-summary-article-number)))
1110 (gnus-article-yanked-articles yank)
1112 ;; Stripping headers should be specified with mail-yank-ignored-headers.
1114 (gnus-summary-goto-subject article))
1115 (gnus-setup-message (if yank 'reply-yank 'reply)
1117 (gnus-summary-select-article)
1118 (dolist (article very-wide)
1119 (gnus-summary-select-article nil nil nil article)
1121 (set-buffer (gnus-copy-article-buffer))
1122 (gnus-msg-treat-broken-reply-to)
1124 (message-narrow-to-head)
1125 (setq headers (concat headers (buffer-string)))))))
1126 (set-buffer (gnus-copy-article-buffer))
1127 (gnus-msg-treat-broken-reply-to gnus-msg-force-broken-reply-to)
1129 (message-narrow-to-head)
1133 (goto-char (point-max)))
1134 (mml-quote-region (point) (point-max))
1135 (message-reply nil wide)
1137 (gnus-inews-yank-articles yank))
1138 (gnus-summary-handle-replysign)))))
1140 (defun gnus-summary-handle-replysign ()
1141 "Check the various replysign variables and take action accordingly."
1142 (when (or gnus-message-replysign gnus-message-replyencrypt)
1143 (let (signed encrypted)
1145 (set-buffer gnus-article-buffer)
1146 (setq signed (memq 'signed gnus-article-wash-types))
1147 (setq encrypted (memq 'encrypted gnus-article-wash-types)))
1148 (cond ((and gnus-message-replyencrypt encrypted)
1149 (mml-secure-message mml-default-encrypt-method
1150 (if gnus-message-replysignencrypted
1153 ((and gnus-message-replysign signed)
1154 (mml-secure-message mml-default-sign-method 'sign))))))
1156 (defun gnus-summary-reply-with-original (n &optional wide)
1157 "Start composing a reply mail to the current message.
1158 The original article will be yanked."
1160 (gnus-summary-reply (gnus-summary-work-articles n) wide))
1162 (defun gnus-summary-reply-broken-reply-to (&optional yank wide very-wide)
1163 "Like `gnus-summary-reply' except removing reply-to field.
1164 If prefix argument YANK is non-nil, the original article is yanked
1166 If WIDE, make a wide reply.
1167 If VERY-WIDE, make a very wide reply."
1169 (list (and current-prefix-arg
1170 (gnus-summary-work-articles 1))))
1171 (let ((gnus-msg-force-broken-reply-to t))
1172 (gnus-summary-reply yank wide very-wide)))
1174 (defun gnus-summary-reply-broken-reply-to-with-original (n &optional wide)
1175 "Like `gnus-summary-reply-with-original' except removing reply-to field.
1176 The original article will be yanked."
1178 (gnus-summary-reply-broken-reply-to (gnus-summary-work-articles n) wide))
1180 (defun gnus-summary-wide-reply (&optional yank)
1181 "Start composing a wide reply mail to the current message.
1182 If prefix argument YANK is non-nil, the original article is yanked
1185 (list (and current-prefix-arg
1186 (gnus-summary-work-articles 1))))
1187 (gnus-summary-reply yank t))
1189 (defun gnus-summary-wide-reply-with-original (n)
1190 "Start composing a wide reply mail to the current message.
1191 The original article will be yanked.
1192 Uses the process/prefix convention."
1194 (gnus-summary-reply-with-original n t))
1196 (defun gnus-summary-very-wide-reply (&optional yank)
1197 "Start composing a very wide reply mail to the current message.
1198 If prefix argument YANK is non-nil, the original article is yanked
1201 (list (and current-prefix-arg
1202 (gnus-summary-work-articles 1))))
1203 (gnus-summary-reply yank t (gnus-summary-work-articles yank)))
1205 (defun gnus-summary-very-wide-reply-with-original (n)
1206 "Start composing a very wide reply mail to the current message.
1207 The original article will be yanked."
1210 (gnus-summary-work-articles n) t (gnus-summary-work-articles n)))
1212 (defun gnus-summary-mail-forward (&optional arg post)
1213 "Forward the current message(s) to another user.
1214 If process marks exist, forward all marked messages;
1215 if ARG is nil, see `message-forward-as-mime' and `message-forward-show-mml';
1216 if ARG is 1, decode the message and forward directly inline;
1217 if ARG is 2, forward message as an rfc822 MIME section;
1218 if ARG is 3, decode message and forward as an rfc822 MIME section;
1219 if ARG is 4, forward message directly inline;
1220 otherwise, use flipped `message-forward-as-mime'.
1221 If POST, post instead of mail.
1222 For the `inline' alternatives, also see the variable
1223 `message-forward-ignored-headers'."
1225 (if (cdr (gnus-summary-work-articles nil))
1226 ;; Process marks are given.
1227 (gnus-uu-digest-mail-forward arg post)
1228 ;; No process marks.
1229 (let ((message-forward-as-mime message-forward-as-mime)
1230 (message-forward-show-mml message-forward-show-mml))
1234 (setq message-forward-as-mime nil
1235 message-forward-show-mml t))
1237 (setq message-forward-as-mime t
1238 message-forward-show-mml nil))
1240 (setq message-forward-as-mime t
1241 message-forward-show-mml t))
1243 (setq message-forward-as-mime nil
1244 message-forward-show-mml nil))
1246 (setq message-forward-as-mime (not message-forward-as-mime))))
1247 (let* ((gnus-article-reply (gnus-summary-article-number))
1248 (gnus-article-yanked-articles (list gnus-article-reply)))
1249 (gnus-setup-message 'forward
1250 (gnus-summary-select-article)
1251 (let ((mail-parse-charset
1252 (or (and (gnus-buffer-live-p gnus-article-buffer)
1253 (with-current-buffer gnus-article-buffer
1254 gnus-article-charset))
1255 gnus-newsgroup-charset))
1256 (mail-parse-ignored-charsets
1257 gnus-newsgroup-ignored-charsets))
1258 (set-buffer gnus-original-article-buffer)
1259 (message-forward post)))))))
1261 (defun gnus-summary-resend-message (address n)
1262 "Resend the current article to ADDRESS."
1264 (list (message-read-from-minibuffer
1265 "Resend message(s) to: "
1266 (when (and gnus-summary-resend-default-address
1267 (gnus-buffer-live-p gnus-original-article-buffer))
1268 ;; If some other article is currently selected, the
1269 ;; initial-contents is wrong. Whatever, it is just the
1270 ;; initial-contents.
1271 (with-current-buffer gnus-original-article-buffer
1272 (nnmail-fetch-field "to"))))
1273 current-prefix-arg))
1274 (dolist (article (gnus-summary-work-articles n))
1275 (gnus-summary-select-article nil nil nil article)
1277 (set-buffer gnus-original-article-buffer)
1278 (message-resend address))
1279 (gnus-summary-mark-article-as-forwarded article)))
1281 ;; From: Matthieu Moy <Matthieu.Moy@imag.fr>
1282 (defun gnus-summary-resend-message-edit ()
1283 "Resend an article that has already been sent.
1284 A new buffer will be created to allow the user to modify body and
1285 contents of the message, and then, everything will happen as when
1286 composing a new message."
1288 (let ((article (gnus-summary-article-number)))
1289 (gnus-setup-message 'reply-yank
1290 (gnus-summary-select-article t)
1291 (set-buffer gnus-original-article-buffer)
1292 (let ((cur (current-buffer))
1293 (to (message-fetch-field "to")))
1294 ;; Get a normal message buffer.
1295 (message-pop-to-buffer (message-buffer-name "Resend" to))
1296 (insert-buffer-substring cur)
1298 (message-narrow-to-head-1)
1299 ;; Gnus will generate a new one when sending.
1300 (message-remove-header "Message-ID")
1301 ;; Remove unwanted headers.
1302 (message-remove-header message-ignored-resent-headers t)
1303 (goto-char (point-max))
1304 (insert mail-header-separator)
1306 (gnus-inews-insert-archive-gcc)
1307 (gnus-inews-insert-gcc)
1308 (goto-char (point-min))
1309 (when (re-search-forward "^To:\\|^Newsgroups:" nil 'move)
1313 (defun gnus-summary-post-forward (&optional arg)
1314 "Forward the current article to a newsgroup.
1315 See `gnus-summary-mail-forward' for ARG."
1317 (gnus-summary-mail-forward arg t))
1319 (defvar gnus-nastygram-message
1320 "The following article was inappropriately posted to %s.\n\n"
1321 "Format string to insert in nastygrams.
1322 The current group name will be inserted at \"%s\".")
1324 (defun gnus-summary-mail-nastygram (n)
1325 "Send a nastygram to the author of the current article."
1327 (when (or gnus-expert-user
1329 "Really send a nastygram to the author of the current article? "))
1330 (let ((group gnus-newsgroup-name))
1331 (gnus-summary-reply-with-original n)
1332 (set-buffer gnus-message-buffer)
1334 (insert (format gnus-nastygram-message group))
1335 (message-send-and-exit))))
1337 (defun gnus-summary-mail-crosspost-complaint (n)
1338 "Send a complaint about crossposting to the current article(s)."
1340 (dolist (article (gnus-summary-work-articles n))
1341 (set-buffer gnus-summary-buffer)
1342 (gnus-summary-goto-subject article)
1343 (let ((group (gnus-group-real-name gnus-newsgroup-name))
1344 newsgroups followup-to)
1345 (gnus-summary-select-article)
1346 (set-buffer gnus-original-article-buffer)
1347 (if (and (<= (length (message-tokenize-header
1349 (mail-fetch-field "newsgroups"))
1352 (or (not (setq followup-to (mail-fetch-field "followup-to")))
1353 (not (member group (message-tokenize-header
1354 followup-to ", ")))))
1356 (gnus-message 1 "Followup-to restricted")
1357 (gnus-message 1 "Not a crossposted article"))
1358 (set-buffer gnus-summary-buffer)
1359 (gnus-summary-reply-with-original 1)
1360 (set-buffer gnus-message-buffer)
1362 (insert (format gnus-crosspost-complaint newsgroups group))
1363 (message-goto-subject)
1364 (re-search-forward " *$")
1365 (replace-match " (crosspost notification)" t t)
1366 (gnus-deactivate-mark)
1367 (when (gnus-y-or-n-p "Send this complaint? ")
1368 (message-send-and-exit))))))
1370 (defun gnus-mail-parse-comma-list ()
1373 (skip-chars-forward " ")
1376 (skip-chars-forward "^,")
1381 (narrow-to-region beg (point))
1384 (while (search-forward "\"" nil t)
1388 (skip-chars-forward ",")
1389 (skip-chars-forward "^,"))
1390 (skip-chars-backward " ")
1391 (push (buffer-substring beg (point))
1393 (skip-chars-forward "^,")
1394 (skip-chars-forward ", "))
1397 (defun gnus-inews-add-to-address (group)
1398 (let ((to-address (mail-fetch-field "to")))
1399 (when (and to-address
1401 ;; This mail group doesn't have a `to-list', so we add one
1403 (when (gnus-y-or-n-p
1404 (format "Do you want to add this as `to-list': %s? " to-address))
1405 (gnus-group-add-parameter group (cons 'to-list to-address))))))
1407 (defun gnus-put-message ()
1408 "Put the current message in some group and return to Gnus."
1410 (let ((reply gnus-article-reply)
1411 (winconf gnus-prev-winconf)
1412 (group gnus-newsgroup-name))
1414 (not (gnus-group-read-only-p group)))
1415 (setq group (read-string "Put in group: " nil (gnus-writable-groups))))
1417 (when (gnus-group-entry group)
1418 (error "No such group: %s" group))
1422 (message-narrow-to-headers)
1423 (let ((gnus-deletable-headers nil))
1424 (message-generate-headers
1425 (if (message-news-p)
1426 message-required-news-headers
1427 message-required-mail-headers)))
1428 (goto-char (point-max))
1429 (if (string-match " " group)
1430 (insert "Gcc: \"" group "\"\n")
1431 (insert "Gcc: " group "\n"))
1434 (when (and (get-buffer gnus-group-buffer)
1435 (gnus-buffer-exists-p (car-safe reply))
1437 (set-buffer (car reply))
1438 (gnus-summary-mark-article-as-replied (cdr reply)))
1440 (set-window-configuration winconf))))
1442 (defun gnus-article-mail (yank)
1443 "Send a reply to the address near point.
1444 If YANK is non-nil, include the original article."
1448 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
1449 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
1451 (gnus-msg-mail address)
1453 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
1455 (defvar nntp-server-type)
1457 "Send a bug report to the Gnus maintainers."
1459 (unless (gnus-alive-p)
1460 (error "Gnus has been shut down"))
1461 (gnus-setup-message (if (message-mail-user-agent) 'message 'bug)
1462 (unless (message-mail-user-agent)
1463 (delete-other-windows)
1464 (when gnus-bug-create-help-buffer
1465 (switch-to-buffer "*Gnus Help Bug*")
1467 (insert gnus-bug-message)
1468 (goto-char (point-min)))
1469 (message-pop-to-buffer "*Gnus Bug*"))
1470 (let ((message-this-is-mail t))
1471 (message-setup `((To . ,gnus-maintainer) (Subject . ""))))
1472 (when gnus-bug-create-help-buffer
1473 (push `(gnus-bug-kill-buffer) message-send-actions))
1474 (goto-char (point-min))
1475 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
1477 (insert (gnus-version) "\n"
1478 (emacs-version) "\n")
1479 (when (and (boundp 'nntp-server-type)
1480 (stringp nntp-server-type))
1481 (insert nntp-server-type))
1482 (insert "\n\n\n\n\n")
1485 (set-buffer (gnus-get-buffer-create " *gnus environment info*"))
1488 (setq text (buffer-string)))
1489 (insert "<#part type=application/emacs-lisp disposition=inline description=\"User settings\">\n" text "\n<#/part>"))
1490 (goto-char (point-min))
1491 (search-forward "Subject: " nil t)
1494 (defun gnus-bug-kill-buffer ()
1495 (when (get-buffer "*Gnus Help Bug*")
1496 (kill-buffer "*Gnus Help Bug*")))
1498 (defun gnus-summary-yank-message (buffer n)
1499 "Yank the current article into a composed message."
1501 (list (completing-read "Buffer: " (mapcar 'list (message-buffers)) nil t)
1502 current-prefix-arg))
1503 (gnus-summary-iterate n
1504 (let ((gnus-inhibit-treatment t))
1505 (gnus-summary-select-article))
1508 (message-yank-buffer gnus-article-buffer))))
1510 (defun gnus-debug ()
1511 "Attempts to go through the Gnus source file and report what variables have been changed.
1512 The source file has to be in the Emacs load path."
1514 (let ((files gnus-debug-files)
1516 file expr olist sym)
1517 (gnus-message 4 "Please wait while we snoop your variables...")
1519 ;; Go through all the files looking for non-default values for variables.
1521 (set-buffer (gnus-get-buffer-create " *gnus bug info*"))
1524 (when (and (setq file (locate-library (pop files)))
1525 (file-exists-p file))
1526 (insert-file-contents file)
1527 (goto-char (point-min))
1528 (if (not (re-search-forward "^;;* *Internal variables" nil t))
1529 (gnus-message 4 "Malformed sources in file %s" file)
1530 (narrow-to-region (point-min) (point))
1531 (goto-char (point-min))
1532 (while (setq expr (ignore-errors (read (current-buffer))))
1534 (and (or (eq (car expr) 'defvar)
1535 (eq (car expr) 'defcustom))
1536 (stringp (nth 3 expr))
1537 (not (memq (nth 1 expr) gnus-debug-exclude-variables))
1538 (or (not (boundp (nth 1 expr)))
1539 (not (equal (eval (nth 2 expr))
1540 (symbol-value (nth 1 expr)))))
1541 (push (nth 1 expr) olist)))))))
1542 (kill-buffer (current-buffer)))
1543 (when (setq olist (nreverse olist))
1544 (insert "------------------ Environment follows ------------------\n\n"))
1546 (if (boundp (car olist))
1550 ,(if (or (consp (setq sym (symbol-value (car olist))))
1552 (not (or (eq sym nil)
1554 (list 'quote (symbol-value (car olist)))
1555 (symbol-value (car olist))))))
1556 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
1557 (setq olist (cdr olist)))
1559 ;; Remove any control chars - they seem to cause trouble for some
1560 ;; mailers. (Byte-compiled output from the stuff above.)
1562 (while (re-search-forward (mm-string-as-multibyte
1563 "[\000-\010\013-\037\200-\237]") nil t)
1564 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
1567 ;;; Treatment of rejected articles.
1570 (defun gnus-summary-resend-bounced-mail (&optional fetch)
1571 "Re-mail the current message.
1572 This only makes sense if the current message is a bounce message that
1573 contains some mail you have written which has been bounced back to
1575 If FETCH, try to fetch the article that this is a reply to, if indeed
1578 (gnus-summary-select-article t)
1579 (let (summary-buffer parent)
1582 (setq summary-buffer (current-buffer))
1583 (set-buffer gnus-original-article-buffer)
1585 (when (re-search-forward "^References:\n?" nil t)
1586 (while (memq (char-after) '(?\t ? ))
1588 (skip-chars-backward "\t\n ")
1590 (gnus-parent-id (buffer-substring (match-end 0) (point))))))
1591 (set-buffer gnus-original-article-buffer))
1592 (gnus-setup-message 'compose-bounce
1595 (gnus-inews-insert-archive-gcc)
1596 (gnus-inews-insert-gcc)
1597 ;; If there are references, we fetch the article we answered to.
1599 (with-current-buffer summary-buffer
1600 (gnus-summary-refer-article parent)
1601 (gnus-summary-show-all-headers))))))
1605 (defun gnus-inews-group-method (group)
1607 ;; If the group doesn't exist, we assume
1608 ;; it's an archive group...
1609 ((and (null (gnus-get-info group))
1610 (eq (car (gnus-server-to-method gnus-message-archive-method))
1611 (car (gnus-server-to-method (gnus-group-method group)))))
1612 gnus-message-archive-method)
1614 ((gnus-info-method (gnus-get-info group))
1615 (gnus-info-method (gnus-get-info group)))
1617 (t (gnus-server-to-method (gnus-group-method group)))))
1619 ;; Do Gcc handling, which copied the message over to some group.
1620 (defun gnus-inews-do-gcc (&optional gcc)
1624 (message-narrow-to-headers)
1625 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
1626 (cur (current-buffer))
1627 groups group method group-art
1628 mml-externalize-attachments)
1630 (message-remove-header "gcc")
1632 (setq groups (message-unquote-tokens
1633 (message-tokenize-header gcc " ,")))
1634 ;; Copy the article over to some group(s).
1635 (while (setq group (pop groups))
1636 (unless (gnus-check-server
1637 (setq method (gnus-inews-group-method group)))
1638 (error "Can't open server %s" (if (stringp method) method
1640 (unless (gnus-request-group group nil method)
1641 (gnus-request-create-group group method))
1642 (setq mml-externalize-attachments
1643 (if (stringp gnus-gcc-externalize-attachments)
1644 (string-match gnus-gcc-externalize-attachments group)
1645 gnus-gcc-externalize-attachments))
1647 (nnheader-set-temp-buffer " *acc*")
1648 (insert-buffer-substring cur)
1649 (message-encode-message-body)
1651 (message-narrow-to-headers)
1652 (let* ((mail-parse-charset message-default-charset)
1653 (newsgroups-field (save-restriction
1654 (message-narrow-to-headers-or-head)
1655 (message-fetch-field "Newsgroups")))
1656 (followup-field (save-restriction
1657 (message-narrow-to-headers-or-head)
1658 (message-fetch-field "Followup-To")))
1659 ;; BUG: We really need to get the charset for
1660 ;; each name in the Newsgroups and Followup-To
1661 ;; lines to allow crossposting between group
1662 ;; namess with incompatible character sets.
1663 ;; -- Per Abrahamsen <abraham@dina.kvl.dk> 2001-10-08.
1664 (group-field-charset
1665 (gnus-group-name-charset
1666 method (or newsgroups-field "")))
1667 (followup-field-charset
1668 (gnus-group-name-charset
1669 method (or followup-field "")))
1670 (rfc2047-header-encoding-alist
1672 (when group-field-charset
1673 (list (cons "Newsgroups" group-field-charset)))
1674 (when followup-field-charset
1675 (list (cons "Followup-To" followup-field-charset)))
1676 rfc2047-header-encoding-alist)))
1677 (mail-encode-encoded-word-buffer)))
1678 (goto-char (point-min))
1679 (when (re-search-forward
1680 (concat "^" (regexp-quote mail-header-separator) "$")
1682 (replace-match "" t t ))
1683 (when (or (not (gnus-check-backend-function
1684 'request-accept-article group))
1685 (not (setq group-art
1686 (gnus-request-accept-article
1687 group method t t))))
1688 (gnus-message 1 "Couldn't store article in group %s: %s"
1689 group (gnus-status-message method)))
1690 (when (and group-art
1691 ;; FIXME: Should gcc-mark-as-read work when
1692 ;; Gnus is not running?
1694 (or gnus-gcc-mark-as-read
1696 (boundp 'gnus-inews-mark-gcc-as-read)
1697 (symbol-value 'gnus-inews-mark-gcc-as-read))))
1698 (gnus-group-mark-article-read group (cdr group-art)))
1699 (kill-buffer (current-buffer)))))))))
1701 (defun gnus-inews-insert-gcc ()
1702 "Insert Gcc headers based on `gnus-outgoing-message-group'."
1705 (message-narrow-to-headers)
1706 (let* ((group gnus-outgoing-message-group)
1710 ((or (stringp group) (listp group))
1715 (if (string-match " " gcc)
1716 (concat "\"" gcc "\"")
1718 (mapconcat (lambda (group)
1719 (if (string-match " " group)
1720 (concat "\"" group "\"")
1725 (defun gnus-inews-insert-archive-gcc (&optional group)
1726 "Insert the Gcc to say where the article is to be archived."
1727 (setq group (cond (group
1728 (gnus-group-decoded-name group))
1729 (gnus-newsgroup-name
1730 (gnus-group-decoded-name gnus-newsgroup-name))
1733 (let* ((var gnus-message-archive-group)
1735 (and gnus-newsgroup-name
1736 (not (equal gnus-newsgroup-name ""))
1737 (gnus-group-find-parameter
1738 gnus-newsgroup-name 'gcc-self)))
1742 ((null gnus-message-archive-method)
1746 ;; Just a single group.
1749 ;; We don't want this.
1751 ((and (listp var) (stringp (car var)))
1752 ;; A list of groups.
1756 (funcall var group))
1758 ;; An alist of regexps/functions/forms.
1763 ((stringp (caar var))
1765 (when (string-match (caar var) group)
1767 ((functionp (car var))
1769 (funcall (car var) group))
1771 (eval (car var)))))))
1772 (setq var (cdr var)))
1775 (when (or groups gcc-self-val)
1776 (when (stringp groups)
1777 (setq groups (list groups)))
1780 (message-narrow-to-headers)
1781 (goto-char (point-max))
1784 ;; Use the `gcc-self' param value instead.
1787 (if (stringp gcc-self-val)
1788 (if (string-match " " gcc-self-val)
1789 (concat "\"" gcc-self-val "\"")
1791 ;; In nndoc groups, we use the parent group name
1792 ;; instead of the current group.
1793 (let ((group (or (gnus-group-find-parameter
1794 gnus-newsgroup-name 'parent-group)
1796 (if (string-match " " group)
1797 (concat "\"" group "\"")
1799 (if (not (eq gcc-self-val 'none))
1801 (gnus-delete-line)))
1802 ;; Use the list of groups.
1803 (while (setq name (pop groups))
1804 (let ((str (if (string-match ":" name)
1806 (gnus-group-prefixed-name
1807 name gnus-message-archive-method))))
1808 (insert (if (string-match " " str)
1809 (concat "\"" str "\"")
1815 (defun gnus-mailing-list-followup-to ()
1816 "Look at the headers in the current buffer and return a Mail-Followup-To address."
1817 (let ((x-been-there (gnus-fetch-original-field "x-beenthere"))
1818 (list-post (gnus-fetch-original-field "list-post")))
1819 (when (and list-post
1820 (string-match "mailto:\\([^>]+\\)" list-post))
1821 (setq list-post (match-string 1 list-post)))
1827 (defun gnus-configure-posting-styles (&optional group-name)
1828 "Configure posting styles according to `gnus-posting-styles'."
1829 (unless gnus-inhibit-posting-styles
1830 (let ((group (or group-name gnus-newsgroup-name ""))
1831 (styles gnus-posting-styles)
1832 style match attribute value v results
1833 filep name address element)
1834 ;; If the group has a posting-style parameter, add it at the end with a
1835 ;; regexp matching everything, to be sure it takes precedence over all
1837 (when gnus-newsgroup-name
1838 (let ((tmp-style (gnus-group-find-parameter group 'posting-style t)))
1840 (setq styles (append styles (list (cons ".*" tmp-style)))))))
1841 ;; Go through all styles and look for matches.
1842 (dolist (style styles)
1843 (setq match (pop style))
1844 (goto-char (point-min))
1847 ;; Regexp string match on the group name.
1848 (string-match match group))
1850 ;; Obsolete format of header match.
1851 (and (gnus-buffer-live-p gnus-article-copy)
1852 (with-current-buffer gnus-article-copy
1854 (nnheader-narrow-to-headers)
1855 (let ((header (message-fetch-field (pop style))))
1857 (string-match (pop style) header)))))))
1858 ((or (symbolp match)
1862 ;; Function to be called.
1865 ;; Variable to be checked.
1866 (symbol-value match))))
1869 ((eq (car match) 'header)
1870 ;; New format of header match.
1871 (and (gnus-buffer-live-p gnus-article-copy)
1872 (with-current-buffer gnus-article-copy
1874 (nnheader-narrow-to-headers)
1875 (let ((header (message-fetch-field (nth 1 match))))
1877 (string-match (nth 2 match) header)))))))
1879 ;; This is a form to be evaled.
1881 ;; We have a match, so we set the variables.
1882 (dolist (attribute style)
1883 (setq element (pop attribute)
1887 ((eq (car attribute) :file)
1890 ((eq (car attribute) :value)
1894 ;; We get the value.
1899 ((or (symbolp value)
1901 (cond ((functionp value)
1904 (symbol-value value))))
1907 ;; Translate obsolescent value.
1909 ((eq element 'signature-file)
1910 (setq element 'signature
1912 ((eq element 'x-face-file)
1913 (setq element 'x-face
1915 ;; Post-processing for the signature posting-style:
1916 (and (eq element 'signature) filep
1917 message-signature-directory
1918 ;; don't actually use the signature directory
1919 ;; if message-signature-file contains a path.
1920 (not (file-name-directory v))
1921 (setq v (nnheader-concat message-signature-directory v)))
1922 ;; Get the contents of file elems.
1924 (setq v (with-temp-buffer
1925 (insert-file-contents v)
1929 (goto-char (point-max))
1930 (if (zerop (skip-chars-backward "\n"))
1933 (setq results (delq (assoc element results) results))
1934 (push (cons element v) results))))
1935 ;; Now we have all the styles, so we insert them.
1936 (setq name (assq 'name results)
1937 address (assq 'address results))
1938 (setq results (delq name (delq address results)))
1939 (gnus-make-local-hook 'message-setup-hook)
1940 (setq results (sort results (lambda (x y)
1941 (string-lessp (car x) (car y)))))
1942 (dolist (result results)
1943 (add-hook 'message-setup-hook
1945 ((eq 'eval (car result))
1947 ((eq 'body (car result))
1951 (insert ,(cdr result)))))
1952 ((eq 'signature (car result))
1953 (set (make-local-variable 'message-signature) nil)
1954 (set (make-local-variable 'message-signature-file) nil)
1955 (if (not (cdr result))
1959 (let ((message-signature ,(cdr result)))
1960 (when message-signature
1961 (message-insert-signature)))))))
1964 (if (symbolp (car result))
1965 (capitalize (symbol-name (car result)))
1969 (message-remove-header ,header)
1970 (let ((value ,(cdr result)))
1973 (insert ,header ": " value)
1975 (insert "\n")))))))))
1977 (when (or name address)
1978 (add-hook 'message-setup-hook
1980 (set (make-local-variable 'user-mail-address)
1981 ,(or (cdr address) user-mail-address))
1982 (let ((user-full-name ,(or (cdr name) (user-full-name)))
1984 ,(or (cdr address) user-mail-address)))
1986 (message-remove-header "From")
1988 (insert "From: " (message-make-from) "\n"))))
1991 ;;; Allow redefinition of functions.
1997 ;;; arch-tag: 9f22b2f5-1c0a-49de-916e-4c88e984852b
1998 ;;; gnus-msg.el ends here