1 ;;; gnus-msg.el --- mail and post interface for Gnus
2 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
3 ;; Free Software Foundation, Inc.
5 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
6 ;; Lars Magne Ingebrigtsen <larsi@gnus.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
30 (eval-when-compile (require 'cl))
38 (defcustom gnus-post-method 'current
39 "*Preferred method for posting USENET news.
41 If this variable is `current' (which is the default), Gnus will use
42 the \"current\" select method when posting. If it is `native', Gnus
43 will use the native select method when posting.
45 This method will not be used in mail groups and the like, only in
48 If not `native' nor `current', the value must be a valid method as discussed
49 in the documentation of `gnus-select-method'. It can also be a list of
50 methods. If that is the case, the user will be queried for what select
51 method to use when posting."
52 :group 'gnus-group-foreign
53 :link '(custom-manual "(gnus)Posting Server")
54 :type `(choice (const native)
56 (sexp :tag "Methods" ,gnus-select-method)))
58 (defcustom gnus-outgoing-message-group nil
59 "*All outgoing messages will be put in this group.
60 If you want to store all your outgoing mail and articles in the group
61 \"nnml:archive\", you set this variable to that value. This variable
62 can also be a list of group names.
64 If you want to have greater control over what group to put each
65 message in, you can set this variable to a function that checks the
66 current newsgroup name and then returns a suitable group name (or list
69 :type '(choice (string :tag "Group")
72 (defcustom gnus-mailing-list-groups nil
73 "*Regexp matching groups that are really mailing lists.
74 This is useful when you're reading a mailing list that has been
75 gatewayed to a newsgroup, and you want to followup to an article in
80 (defcustom gnus-add-to-list nil
81 "*If non-nil, add a `to-list' parameter automatically."
85 (defcustom gnus-crosspost-complaint
88 You posted the article below with the following Newsgroups header:
92 The %s group, at least, was an inappropriate recipient
93 of this message. Please trim your Newsgroups header to exclude this
94 group before posting in the future.
99 "Format string to be inserted when complaining about crossposts.
100 The first %s will be replaced by the Newsgroups header;
101 the second with the current group name."
105 (defcustom gnus-message-setup-hook nil
106 "Hook run after setting up a message buffer."
110 (defcustom gnus-bug-create-help-buffer t
111 "*Should we create the *Gnus Help Bug* buffer?"
115 (defcustom gnus-posting-styles nil
116 "*Alist of styles to use when posting.
117 See Info node `(gnus)Posting Styles'."
119 :link '(custom-manual "(gnus)Posting Styles")
120 :type '(repeat (cons (choice (regexp)
123 (string :tag "Header")
124 (regexp :tag "Regexp"))
128 (choice (const signature)
129 (const signature-file)
136 (string :tag "Header"))
142 (defcustom gnus-gcc-mark-as-read nil
143 "If non-nil, automatically mark Gcc articles as read."
148 (defvar gnus-inews-mark-gcc-as-read nil
149 "Obsolete variable. Use `gnus-gcc-mark-as-read' instead.")
151 (make-obsolete-variable 'gnus-inews-mark-gcc-as-read
152 'gnus-gcc-mark-as-read)
154 (defcustom gnus-gcc-externalize-attachments nil
155 "Should local-file attachments be included as external parts in Gcc copies?
156 If it is `all', attach files as external parts;
157 if a regexp and matches the Gcc group name, attach files as external parts;
158 if nil, attach files as normal parts."
161 :type '(choice (const nil :tag "None")
162 (const all :tag "Any")
163 (string :tag "Regexp")))
165 (gnus-define-group-parameter
166 posting-charset-alist
169 "Return the permitted unencoded charsets for posting of GROUP."
170 :variable gnus-group-posting-charset-alist
172 '(("^\\(no\\|fr\\)\\.[^,]*\\(,[ \t\n]*\\(no\\|fr\\)\\.[^,]*\\)*$" iso-8859-1 (iso-8859-1))
173 ("^\\(fido7\\|relcom\\)\\.[^,]*\\(,[ \t\n]*\\(fido7\\|relcom\\)\\.[^,]*\\)*$" koi8-r (koi8-r))
174 (message-this-is-mail nil nil)
175 (message-this-is-news nil t))
177 "Alist of regexps and permitted unencoded charsets for posting.
178 Each element of the alist has the form (TEST HEADER BODY-LIST), where
179 TEST is either a regular expression matching the newsgroup header or a
181 HEADER is the charset which may be left unencoded in the header (nil
182 means encode all charsets),
183 BODY-LIST is a list of charsets which may be encoded using 8bit
184 content-transfer encoding in the body, or one of the special values
185 nil (always encode using quoted-printable) or t (always use 8bit).
187 Note that any value other than nil for HEADER infringes some RFCs, so
188 use this option with care."
189 :variable-group gnus-charset
191 '(repeat (list :tag "Permitted unencoded charsets"
193 (regexp :tag "Group")
194 (const :tag "Mail message" :value message-this-is-mail)
195 (const :tag "News article" :value message-this-is-news))
196 (choice :tag "Header"
197 (const :tag "None" nil)
198 (symbol :tag "Charset"))
200 (const :tag "Any" :value t)
201 (const :tag "None" :value nil)
202 (repeat :tag "Charsets"
203 (symbol :tag "Charset")))))
204 :parameter-type '(choice :tag "Permitted unencoded charsets"
207 :parameter-document "\
208 List of charsets that are permitted to be unencoded.")
210 (defcustom gnus-debug-files
211 '("gnus.el" "gnus-sum.el" "gnus-group.el"
212 "gnus-art.el" "gnus-start.el" "gnus-async.el"
213 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
214 "gnus-agent.el" "gnus-cache.el" "gnus-srvr.el"
215 "mm-util.el" "mm-decode.el" "nnmail.el" "message.el")
216 "Files whose variables will be reported in `gnus-bug'."
219 :type '(repeat (string :tag "File")))
221 (defcustom gnus-debug-exclude-variables
222 '(mm-mime-mule-charset-alist
223 nnmail-split-fancy message-minibuffer-local-map)
224 "Variables that should not be reported in `gnus-bug'."
227 :type '(repeat (symbol :tag "Variable")))
229 (defcustom gnus-discouraged-post-methods
230 '(nndraft nnml nnimap nnmaildir nnmh nnfolder nndir)
231 "A list of back ends that are not used in \"real\" newsgroups.
232 This variable is used only when `gnus-post-method' is `current'."
234 :group 'gnus-group-foreign
235 :type '(repeat (symbol :tag "Back end")))
237 (defcustom gnus-message-replysign
239 "Automatically sign replies to signed messages.
240 See also the `mml-default-sign-method' variable."
244 (defcustom gnus-message-replyencrypt
246 "Automatically encrypt replies to encrypted messages.
247 See also the `mml-default-encrypt-method' variable."
251 (defcustom gnus-message-replysignencrypted
253 "Setting this causes automatically encryped messages to also be signed."
257 (defcustom gnus-confirm-mail-reply-to-news nil
258 "If non-nil, Gnus requests confirmation when replying to news.
259 This is done because new users often reply by mistake when reading
261 This can also be a function receiving the group name as the only
262 parameter which should return non-nil iff a confirmation is needed, or
263 a regexp, in which case a confirmation is asked for iff the group name
266 :type '(choice (const :tag "No" nil)
268 (regexp :tag "Iff group matches regexp")
269 (function :tag "Iff function evaluates to non-nil")))
271 (defcustom gnus-confirm-treat-mail-like-news
273 "If non-nil, Gnus will treat mail like news with regard to confirmation
274 when replying by mail. See the `gnus-confirm-mail-reply-to-news' variable
275 for fine-tuning this.
276 If nil, Gnus will never ask for confirmation if replying to mail."
280 (defcustom gnus-summary-resend-default-address t
281 "If non-nil, Gnus tries to suggest a default address to resend to.
282 If nil, the address field will always be empty after invoking
283 `gnus-summary-resend-message'."
287 (defcustom gnus-user-agent 'emacs-gnus-type
288 "Which information should be exposed in the User-Agent header.
290 It can be one of the symbols `gnus' \(show only Gnus version\), `emacs-gnus'
291 \(show only Emacs and Gnus versions\), `emacs-gnus-config' \(same as
292 `emacs-gnus' plus system configuration\), `emacs-gnus-type' \(same as
293 `emacs-gnus' plus system type\) or a custom string. If you set it to a
294 string, be sure to use a valid format, see RFC 2616."
297 (item :tag "Show Gnus and Emacs versions and system type"
299 (item :tag "Show Gnus and Emacs versions and system configuration"
301 (item :tag "Show Gnus and Emacs versions" emacs-gnus)
302 (item :tag "Show only Gnus version" gnus)
303 (string :tag "Other")))
305 ;;; Internal variables.
307 (defvar gnus-inhibit-posting-styles nil
308 "Inhibit the use of posting styles.")
310 (defvar gnus-article-yanked-articles nil)
311 (defvar gnus-message-buffer "*Mail Gnus*")
312 (defvar gnus-article-copy nil)
313 (defvar gnus-check-before-posting nil)
314 (defvar gnus-last-posting-server nil)
315 (defvar gnus-message-group-art nil)
317 (defvar gnus-msg-force-broken-reply-to nil)
319 (defconst gnus-bug-message
320 "Sending a bug report to the Gnus Towers.
321 ========================================
323 The buffer below is a mail buffer. When you press `C-c C-c', it will
324 be sent to the Gnus Bug Exterminators.
326 The thing near the bottom of the buffer is how the environment
327 settings will be included in the mail. Please do not delete that.
328 They will tell the Bug People what your environment is, so that it
329 will be easier to locate the bugs.
331 If you have found a bug that makes Emacs go \"beep\", set
332 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
333 and include the backtrace in your bug report.
335 Please describe the bug in annoying, painstaking detail.
337 Thank you for your help in stamping out bugs.
341 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
342 (autoload 'news-setup "rnewspost")
343 (autoload 'news-reply-mode "rnewspost")
344 (autoload 'rmail-dont-reply-to "mail-utils")
345 (autoload 'rmail-output "rmailout"))
349 ;;; Gnus Posting Functions
352 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
353 "p" gnus-summary-post-news
354 "i" gnus-summary-news-other-window
355 "f" gnus-summary-followup
356 "F" gnus-summary-followup-with-original
357 "c" gnus-summary-cancel-article
358 "s" gnus-summary-supersede-article
359 "r" gnus-summary-reply
360 "y" gnus-summary-yank-message
361 "R" gnus-summary-reply-with-original
362 "w" gnus-summary-wide-reply
363 "W" gnus-summary-wide-reply-with-original
364 "v" gnus-summary-very-wide-reply
365 "V" gnus-summary-very-wide-reply-with-original
366 "n" gnus-summary-followup-to-mail
367 "N" gnus-summary-followup-to-mail-with-original
368 "m" gnus-summary-mail-other-window
369 "u" gnus-uu-post-news
370 "\M-c" gnus-summary-mail-crosspost-complaint
371 "Br" gnus-summary-reply-broken-reply-to
372 "BR" gnus-summary-reply-broken-reply-to-with-original
373 "om" gnus-summary-mail-forward
374 "op" gnus-summary-post-forward
375 "Om" gnus-uu-digest-mail-forward
376 "Op" gnus-uu-digest-post-forward)
378 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
379 "b" gnus-summary-resend-bounced-mail
380 ;; "c" gnus-summary-send-draft
381 "r" gnus-summary-resend-message
382 "e" gnus-summary-resend-message-edit)
384 ;;; Internal functions.
386 (defun gnus-inews-make-draft ()
388 (gnus-inews-make-draft-meta-information
389 ,gnus-newsgroup-name ',gnus-article-reply)))
391 (defvar gnus-article-reply nil)
392 (defmacro gnus-setup-message (config &rest forms)
393 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
394 (buffer (make-symbol "gnus-setup-message-buffer"))
395 (article (make-symbol "gnus-setup-message-article"))
396 (yanked (make-symbol "gnus-setup-yanked-articles"))
397 (group (make-symbol "gnus-setup-message-group")))
398 `(let ((,winconf (current-window-configuration))
399 (,buffer (buffer-name (current-buffer)))
400 (,article gnus-article-reply)
401 (,yanked gnus-article-yanked-articles)
402 (,group gnus-newsgroup-name)
403 (message-header-setup-hook
404 (copy-sequence message-header-setup-hook))
405 (mbl mml-buffer-list)
406 (message-mode-hook (copy-sequence message-mode-hook)))
407 (setq mml-buffer-list nil)
408 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
409 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
410 ;; #### FIXME: for a reason that I did not manage to identify yet,
411 ;; the variable `gnus-newsgroup-name' does not honor a dynamically
412 ;; scoped or setq'ed value from a caller like `C-u gnus-summary-mail'.
413 ;; After evaluation of @forms below, it gets the value we actually want
414 ;; to override, and the posting styles are used. For that reason, I've
415 ;; added an optional argument to `gnus-configure-posting-styles' to
416 ;; make sure that the correct value for the group name is used. -- drv
417 (add-hook 'message-mode-hook
419 (gnus-configure-posting-styles ,group)))
420 (gnus-pull ',(intern gnus-draft-meta-information-header)
421 message-required-headers)
423 (not (string= ,group "")))
425 (intern gnus-draft-meta-information-header)
426 (gnus-inews-make-draft))
427 message-required-headers))
431 (gnus-inews-add-send-actions ,winconf ,buffer ,article ,config
433 (setq gnus-message-buffer (current-buffer))
434 (set (make-local-variable 'gnus-message-group-art)
435 (cons ,group ,article))
436 (set (make-local-variable 'gnus-newsgroup-name) ,group)
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 ;; LOCAL argument of add-hook differs between GNU Emacs
443 ;; and XEmacs. make-local-hook makes sure they are local.
444 (make-local-hook 'kill-buffer-hook)
445 (make-local-hook 'change-major-mode-hook)
446 (add-hook 'change-major-mode-hook 'mml-destroy-buffers nil t)
447 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))
448 (mml-destroy-buffers)
449 (setq mml-buffer-list mbl)))
451 (gnus-configure-windows ,config t)
452 (run-hooks 'post-command-hook)
453 (set-buffer-modified-p nil))))
455 (defun gnus-inews-make-draft-meta-information (group article)
456 (concat "(\"" group "\" "
457 (if article (number-to-string
464 (defun gnus-msg-mail (&optional to subject other-headers continue
465 switch-action yank-action send-actions)
466 "Start editing a mail message to be sent.
467 Like `message-mail', but with Gnus paraphernalia, particularly the
468 Gcc: header for archiving purposes."
470 (let ((buf (current-buffer))
472 (gnus-setup-message 'message
473 (message-mail to subject other-headers continue
474 nil yank-action send-actions))
476 (setq mail-buf (current-buffer))
477 (switch-to-buffer buf)
478 (apply switch-action mail-buf nil)))
479 ;; COMPOSEFUNC should return t if succeed. Undocumented ???
482 (defvar save-selected-window-window)
485 (defun gnus-button-mailto (address)
487 (set-buffer (gnus-copy-article-buffer))
488 (gnus-setup-message 'message
489 (message-reply address))
490 (and (boundp 'save-selected-window-window)
491 (not (window-live-p save-selected-window-window))
492 (setq save-selected-window-window (selected-window))))
495 (defun gnus-button-reply (&optional to-address wide)
496 "Like `message-reply'."
498 (gnus-setup-message 'message
499 (message-reply to-address wide))
500 (and (boundp 'save-selected-window-window)
501 (not (window-live-p save-selected-window-window))
502 (setq save-selected-window-window (selected-window))))
505 (define-mail-user-agent 'gnus-user-agent
506 'gnus-msg-mail 'message-send-and-exit
507 'message-kill-buffer 'message-send-hook)
509 (defun gnus-setup-posting-charset (group)
510 (let ((alist gnus-group-posting-charset-alist)
511 (group (or group ""))
515 (while (setq elem (pop alist))
516 (when (or (and (stringp (car elem))
517 (string-match (car elem) group))
518 (and (gnus-functionp (car elem))
519 (funcall (car elem) group))
520 (and (symbolp (car elem))
521 (symbol-value (car elem))))
522 (throw 'found (cons (cadr elem) (caddr elem)))))))))
524 (defun gnus-inews-add-send-actions (winconf buffer article
525 &optional config yanked)
526 (make-local-hook 'message-sent-hook)
527 (add-hook 'message-sent-hook (if gnus-agent 'gnus-agent-possibly-do-gcc
528 'gnus-inews-do-gcc) nil t)
530 (make-local-hook 'message-header-hook)
531 (add-hook 'message-header-hook 'gnus-agent-possibly-save-gcc nil t))
532 (setq message-post-method
534 (gnus-post-method arg ,gnus-newsgroup-name)))
535 (setq message-newsreader (setq message-mailer (gnus-extended-version)))
537 `(when (gnus-buffer-exists-p ,buffer)
538 (set-window-configuration ,winconf))
539 'exit 'postpone 'kill)
540 (let ((to-be-marked (cond
542 (article (if (listp article) article (list article)))
545 `(when (gnus-buffer-exists-p ,buffer)
549 (if (eq config 'forward)
550 `(gnus-summary-mark-article-as-forwarded ',to-be-marked)
551 `(gnus-summary-mark-article-as-replied ',to-be-marked)))))
554 (put 'gnus-setup-message 'lisp-indent-function 1)
555 (put 'gnus-setup-message 'edebug-form-spec '(form body))
557 ;;; Post news commands of Gnus group mode and summary mode
559 (defun gnus-group-mail (&optional arg)
560 "Start composing a mail.
561 If ARG, use the group under the point to find a posting style.
562 If ARG is 1, prompt for a group name to find the posting style."
564 ;; We can't `let' gnus-newsgroup-name here, since that leads
565 ;; to local variables leaking.
566 (let ((group gnus-newsgroup-name)
567 ;; make sure last viewed article doesn't affect posting styles:
569 (buffer (current-buffer)))
572 (setq gnus-newsgroup-name
574 (if (= 1 (prefix-numeric-value arg))
575 (completing-read "Use posting style of group: "
576 gnus-active-hashtb nil
577 (gnus-read-active-file-p))
578 (gnus-group-group-name))
580 ;; #### see comment in gnus-setup-message -- drv
581 (gnus-setup-message 'message (message-mail)))
584 (setq gnus-newsgroup-name group)))))
586 (defun gnus-group-news (&optional arg)
587 "Start composing a news.
588 If ARG, post to group under point.
589 If ARG is 1, prompt for group name to post to.
591 This function prepares a news even when using mail groups. This is useful
592 for posting messages to mail groups without actually sending them over the
593 network. The corresponding backend must have a 'request-post method."
595 ;; We can't `let' gnus-newsgroup-name here, since that leads
596 ;; to local variables leaking.
597 (let ((group gnus-newsgroup-name)
598 ;; make sure last viewed article doesn't affect posting styles:
600 (buffer (current-buffer)))
603 (setq gnus-newsgroup-name
605 (if (= 1 (prefix-numeric-value arg))
606 (completing-read "Use group: "
607 gnus-active-hashtb nil
608 (gnus-read-active-file-p))
609 (gnus-group-group-name))
611 ;; #### see comment in gnus-setup-message -- drv
612 (gnus-setup-message 'message
613 (message-news (gnus-group-real-name gnus-newsgroup-name))))
616 (setq gnus-newsgroup-name group)))))
618 (defun gnus-group-post-news (&optional arg)
619 "Start composing a message (a news by default).
620 If ARG, post to group under point. If ARG is 1, prompt for group name.
621 Depending on the selected group, the message might be either a mail or
624 ;; Bind this variable here to make message mode hooks work ok.
625 (let ((gnus-newsgroup-name
627 (if (= 1 (prefix-numeric-value arg))
628 (completing-read "Newsgroup: " gnus-active-hashtb nil
629 (gnus-read-active-file-p))
630 (gnus-group-group-name))
632 ;; make sure last viewed article doesn't affect posting styles:
634 (gnus-post-news 'post gnus-newsgroup-name nil nil nil nil
635 (string= gnus-newsgroup-name ""))))
637 (defun gnus-summary-mail-other-window (&optional arg)
638 "Start composing a mail in another window.
639 Use the posting of the current group by default.
640 If ARG, don't do that. If ARG is 1, prompt for group name to find the
643 ;; We can't `let' gnus-newsgroup-name here, since that leads
644 ;; to local variables leaking.
645 (let ((group gnus-newsgroup-name)
646 ;; make sure last viewed article doesn't affect posting styles:
648 (buffer (current-buffer)))
651 (setq gnus-newsgroup-name
653 (if (= 1 (prefix-numeric-value arg))
654 (completing-read "Use group: "
655 gnus-active-hashtb nil
656 (gnus-read-active-file-p))
658 gnus-newsgroup-name))
659 ;; #### see comment in gnus-setup-message -- drv
660 (gnus-setup-message 'message (message-mail)))
663 (setq gnus-newsgroup-name group)))))
665 (defun gnus-summary-news-other-window (&optional arg)
666 "Start composing a news in another window.
667 Post to the current group by default.
668 If ARG, don't do that. If ARG is 1, prompt for group name to post to.
670 This function prepares a news even when using mail groups. This is useful
671 for posting messages to mail groups without actually sending them over the
672 network. The corresponding backend must have a 'request-post method."
674 ;; We can't `let' gnus-newsgroup-name here, since that leads
675 ;; to local variables leaking.
676 (let ((group gnus-newsgroup-name)
677 ;; make sure last viewed article doesn't affect posting styles:
679 (buffer (current-buffer)))
682 (setq gnus-newsgroup-name
684 (if (= 1 (prefix-numeric-value arg))
685 (completing-read "Use group: "
686 gnus-active-hashtb nil
687 (gnus-read-active-file-p))
689 gnus-newsgroup-name))
690 ;; #### see comment in gnus-setup-message -- drv
691 (gnus-setup-message 'message
692 (message-news (gnus-group-real-name gnus-newsgroup-name))))
695 (setq gnus-newsgroup-name group)))))
697 (defun gnus-summary-post-news (&optional arg)
698 "Start composing a message. Post to the current group by default.
699 If ARG, don't do that. If ARG is 1, prompt for a group name to post to.
700 Depending on the selected group, the message might be either a mail or
703 ;; Bind this variable here to make message mode hooks work ok.
704 (let ((gnus-newsgroup-name
706 (if (= 1 (prefix-numeric-value arg))
707 (completing-read "Newsgroup: " gnus-active-hashtb nil
708 (gnus-read-active-file-p))
710 gnus-newsgroup-name))
711 ;; make sure last viewed article doesn't affect posting styles:
713 (gnus-post-news 'post gnus-newsgroup-name)))
716 (defun gnus-summary-followup (yank &optional force-news)
717 "Compose a followup to an article.
718 If prefix argument YANK is non-nil, the original article is yanked
720 YANK is a list of elements, where the car of each element is the
721 article number, and the two following numbers is the region to be
724 (list (and current-prefix-arg
725 (gnus-summary-work-articles 1))))
727 (gnus-summary-goto-subject
728 (if (listp (car yank))
731 (save-window-excursion
732 (gnus-summary-select-article))
733 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
734 (gnus-newsgroup-name gnus-newsgroup-name))
736 (gnus-post-news nil gnus-newsgroup-name
737 headers gnus-article-buffer
739 (gnus-summary-handle-replysign)))
741 (defun gnus-summary-followup-with-original (n &optional force-news)
742 "Compose a followup to an article and include the original article."
744 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
746 (defun gnus-summary-followup-to-mail (&optional arg)
747 "Followup to the current mail message via news."
749 (list (and current-prefix-arg
750 (gnus-summary-work-articles 1))))
751 (gnus-summary-followup arg t))
753 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
754 "Followup to the current mail message via news."
756 (gnus-summary-followup (gnus-summary-work-articles arg) t))
758 (defun gnus-inews-yank-articles (articles)
759 (let (beg article yank-string)
761 (while (setq article (pop articles))
762 (when (listp article)
763 (setq yank-string (nth 1 article)
764 article (nth 0 article)))
765 (save-window-excursion
766 (set-buffer gnus-summary-buffer)
767 (gnus-summary-select-article nil nil nil article)
768 (gnus-summary-remove-process-mark article))
769 (gnus-copy-article-buffer nil yank-string)
770 (let ((message-reply-buffer gnus-article-copy)
771 (message-reply-headers
772 ;; The headers are decoded.
773 (with-current-buffer gnus-article-copy
775 (nnheader-narrow-to-headers)
776 (nnheader-parse-naked-head)))))
777 (message-yank-original)
778 (setq beg (or beg (mark t))))
784 (defun gnus-summary-cancel-article (&optional n symp)
785 "Cancel an article you posted.
786 Uses the process-prefix convention. If given the symbolic
787 prefix `a', cancel using the standard posting method; if not
788 post using the current select method."
789 (interactive (gnus-interactive "P\ny"))
790 (let ((articles (gnus-summary-work-articles n))
793 (gnus-post-method (eq ',symp 'a) ,gnus-newsgroup-name)))
795 (while (setq article (pop articles))
796 (when (gnus-summary-select-article t nil nil article)
797 (when (gnus-eval-in-buffer-window gnus-original-article-buffer
798 (message-cancel-news))
799 (gnus-summary-mark-as-read article gnus-canceled-mark)
800 (gnus-cache-remove-article 1))
801 (gnus-article-hide-headers-if-wanted))
802 (gnus-summary-remove-process-mark article))))
804 (defun gnus-summary-supersede-article ()
805 "Compose an article that will supersede a previous article.
806 This is done simply by taking the old article and adding a Supersedes
807 header line with the old Message-ID."
809 (let ((article (gnus-summary-article-number)))
810 (gnus-setup-message 'reply-yank
811 (gnus-summary-select-article t)
812 (set-buffer gnus-original-article-buffer)
816 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
818 (set-buffer ,gnus-summary-buffer)
819 (gnus-cache-possibly-remove-article ,article nil nil nil t)
820 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
821 message-send-actions))))
825 (defun gnus-copy-article-buffer (&optional article-buffer yank-string)
826 ;; make a copy of the article buffer with all text properties removed
827 ;; this copy is in the buffer gnus-article-copy.
828 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
829 ;; this buffer should be passed to all mail/news reply/post routines.
830 (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
832 (set-buffer gnus-article-copy)
833 (mm-enable-multibyte))
834 (let ((article-buffer (or article-buffer gnus-article-buffer))
836 (if (not (and (get-buffer article-buffer)
837 (gnus-buffer-exists-p article-buffer)))
838 (error "Can't find any article buffer")
840 (set-buffer article-buffer)
841 (let ((gnus-newsgroup-charset (or gnus-article-charset
842 gnus-newsgroup-charset))
843 (gnus-newsgroup-ignored-charsets
844 (or gnus-article-ignored-charsets
845 gnus-newsgroup-ignored-charsets)))
847 ;; Copy over the (displayed) article buffer, delete
848 ;; hidden text and remove text properties.
850 (copy-to-buffer gnus-article-copy (point-min) (point-max))
851 (set-buffer gnus-article-copy)
854 (delete-region (point) (point-max))
855 (insert yank-string))
856 (gnus-article-delete-text-of-type 'annotation)
857 (gnus-remove-text-with-property 'gnus-prev)
858 (gnus-remove-text-with-property 'gnus-next)
859 (gnus-remove-text-with-property 'gnus-decoration)
862 (buffer-substring-no-properties (point-min) (point-max))
864 ;; Find the original headers.
865 (set-buffer gnus-original-article-buffer)
866 (goto-char (point-min))
867 (while (looking-at message-unix-mail-delimiter)
869 (let ((mail-header-separator ""))
871 end (or (message-goto-body)
872 ;; There may be just a header.
874 ;; Delete the headers from the displayed articles.
875 (set-buffer gnus-article-copy)
876 (let ((mail-header-separator ""))
877 (delete-region (goto-char (point-min))
878 (or (message-goto-body) (point-max))))
879 ;; Insert the original article headers.
880 (insert-buffer-substring gnus-original-article-buffer beg end)
882 (let ((gnus-article-decode-hook
883 (delq 'article-decode-charset
884 (copy-sequence gnus-article-decode-hook))))
885 (run-hooks 'gnus-article-decode-hook)))))
888 (defun gnus-post-news (post &optional group header article-buffer yank subject
891 (gnus-copy-article-buffer))
892 (let ((gnus-article-reply (and article-buffer (gnus-summary-article-number)))
893 (gnus-article-yanked-articles yank)
894 (add-to-list gnus-add-to-list))
895 (gnus-setup-message (cond (yank 'reply-yank)
896 (article-buffer 'reply)
898 (let* ((group (or group gnus-newsgroup-name))
899 (charset (gnus-group-name-charset nil group))
901 to-address to-group mailing-list to-list
904 (setq to-address (gnus-parameter-to-address group)
905 to-group (gnus-group-find-parameter group 'to-group)
906 to-list (gnus-parameter-to-list group)
907 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
908 mailing-list (when gnus-mailing-list-groups
909 (string-match gnus-mailing-list-groups group))
910 group (gnus-group-name-decode (gnus-group-real-name group)
912 (if (or (and to-group
913 (gnus-news-group-p to-group))
916 (and (gnus-news-group-p
917 (or pgroup gnus-newsgroup-name)
918 (or header gnus-current-article))
924 (message-news (or to-group group))
925 (set-buffer gnus-article-copy)
926 (gnus-msg-treat-broken-reply-to)
927 (message-followup (if (or newsgroup-p force-news)
928 (if (save-restriction
929 (article-narrow-to-head)
930 (message-fetch-field "newsgroups"))
937 (message-mail (or to-address to-list))
938 ;; Arrange for mail groups that have no `to-address' to
939 ;; get that when the user sends off the mail.
940 (when (and (not to-list)
943 (push (list 'gnus-inews-add-to-address pgroup)
944 message-send-actions)))
945 (set-buffer gnus-article-copy)
946 (gnus-msg-treat-broken-reply-to)
947 (message-wide-reply to-address)))
949 (gnus-inews-yank-articles yank))))))
951 (defun gnus-msg-treat-broken-reply-to (&optional force)
952 "Remove the Reply-to header if broken-reply-to."
954 (gnus-group-find-parameter
955 gnus-newsgroup-name 'broken-reply-to))
957 (message-narrow-to-head)
958 (message-remove-header "reply-to"))))
960 (defun gnus-post-method (arg group &optional silent)
961 "Return the posting method based on GROUP and ARG.
962 If SILENT, don't prompt the user."
963 (let ((gnus-post-method (or (gnus-parameter-post-method group)
965 (group-method (gnus-find-method-for-group group)))
967 ;; If the group-method is nil (which shouldn't happen) we use
968 ;; the default method.
970 (or (and (listp gnus-post-method) ;If not current/native/nil
971 (not (listp (car gnus-post-method))) ; and not a list of methods
972 gnus-post-method) ;then use it.
974 message-post-method))
975 ;; We want the inverse of the default
976 ((and arg (not (eq arg 0)))
977 (if (eq gnus-post-method 'current)
980 ;; We query the user for a post method.
982 (and (listp gnus-post-method)
983 (listp (car gnus-post-method))))
985 ;; Collect all methods we know about.
987 (when (listp gnus-post-method)
988 (if (listp (car gnus-post-method))
990 (list gnus-post-method)))
991 gnus-secondary-select-methods
992 (mapcar 'cdr gnus-server-alist)
993 (mapcar 'car gnus-opened-servers)
994 (list gnus-select-method)
995 (list group-method)))
996 method-alist post-methods method)
997 ;; Weed out all mail methods.
999 (setq method (gnus-server-get-method "" (pop methods)))
1000 (when (and (or (gnus-method-option-p method 'post)
1001 (gnus-method-option-p method 'post-mail))
1002 (not (member method post-methods)))
1003 (push method post-methods)))
1004 ;; Create a name-method alist.
1008 (if (equal (cadr m) "")
1009 (list (symbol-name (car m)) m)
1010 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m)))
1015 (setq gnus-last-posting-server
1017 gnus-last-posting-server)
1018 ;; Just use the last value.
1019 gnus-last-posting-server
1021 "Posting method: " method-alist nil t
1022 (cons (or gnus-last-posting-server "") 0))))
1024 ;; Override normal method.
1025 ((and (eq gnus-post-method 'current)
1026 (not (memq (car group-method) gnus-discouraged-post-methods))
1027 (gnus-get-function group-method 'request-post t))
1030 ;; Use gnus-post-method.
1031 ((listp gnus-post-method) ;A method...
1032 (assert (not (listp (car gnus-post-method)))) ;... not a list of methods.
1034 ;; Use the normal select method (nil or native).
1035 (t gnus-select-method))))
1039 ;; Dummies to avoid byte-compile warning.
1041 (defvar nnspool-rejected-article-hook)
1042 (defvar xemacs-codename))
1044 (defun gnus-extended-version ()
1045 "Stringified Gnus version and Emacs version.
1046 See the variable `gnus-user-agent'."
1050 (prin1-to-string (gnus-continuum-version gnus-version) t)
1051 " (" gnus-version ")"))
1054 ((eq gnus-user-agent 'emacs-gnus-config)
1055 system-configuration)
1056 ((eq gnus-user-agent 'emacs-gnus-type)
1057 (symbol-name system-type))
1061 ((eq gnus-user-agent 'gnus)
1063 ((string-match "^\\(\\([.0-9]+\\)*\\)\\.[0-9]+$" emacs-version)
1064 (concat "Emacs/" (match-string 1 emacs-version)
1066 (concat " (" system-v ")")
1069 "\\([A-Z]*[Mm][Aa][Cc][Ss]\\)[^(]*\\(\\((beta.*)\\|'\\)\\)?"
1072 (match-string 1 emacs-version)
1073 (format "/%d.%d" emacs-major-version emacs-minor-version)
1074 (if (match-beginning 3)
1075 (match-string 3 emacs-version)
1077 (if (boundp 'xemacs-codename)
1079 " (" xemacs-codename
1081 (concat ", " system-v ")")
1084 (t emacs-version))))
1085 (if (stringp gnus-user-agent)
1089 (concat " " emacs-v))))))
1093 ;;; Gnus Mail Functions
1096 ;;; Mail reply commands of Gnus summary mode
1098 (defun gnus-summary-reply (&optional yank wide very-wide)
1099 "Start composing a mail reply to the current message.
1100 If prefix argument YANK is non-nil, the original article is yanked
1102 If WIDE, make a wide reply.
1103 If VERY-WIDE, make a very wide reply."
1105 (list (and current-prefix-arg
1106 (gnus-summary-work-articles 1))))
1107 ;; Allow user to require confirmation before replying by mail to the
1108 ;; author of a news article (or mail message).
1110 (not (or (gnus-news-group-p gnus-newsgroup-name)
1111 gnus-confirm-treat-mail-like-news))
1112 (not (cond ((stringp gnus-confirm-mail-reply-to-news)
1113 (string-match gnus-confirm-mail-reply-to-news
1114 gnus-newsgroup-name))
1115 ((functionp gnus-confirm-mail-reply-to-news)
1116 (funcall gnus-confirm-mail-reply-to-news gnus-newsgroup-name))
1117 (t gnus-confirm-mail-reply-to-news)))
1118 (y-or-n-p "Really reply by mail to article author? "))
1120 (if (listp (car yank))
1123 (gnus-article-reply (or article (gnus-summary-article-number)))
1124 (gnus-article-yanked-articles yank)
1126 ;; Stripping headers should be specified with mail-yank-ignored-headers.
1128 (gnus-summary-goto-subject article))
1129 (gnus-setup-message (if yank 'reply-yank 'reply)
1131 (gnus-summary-select-article)
1132 (dolist (article very-wide)
1133 (gnus-summary-select-article nil nil nil article)
1135 (set-buffer (gnus-copy-article-buffer))
1136 (gnus-msg-treat-broken-reply-to)
1138 (message-narrow-to-head)
1139 (setq headers (concat headers (buffer-string)))))))
1140 (set-buffer (gnus-copy-article-buffer))
1141 (gnus-msg-treat-broken-reply-to gnus-msg-force-broken-reply-to)
1143 (message-narrow-to-head)
1147 (goto-char (point-max)))
1148 (mml-quote-region (point) (point-max))
1149 (message-reply nil wide)
1151 (gnus-inews-yank-articles yank))
1152 (gnus-summary-handle-replysign)))))
1154 (defun gnus-summary-handle-replysign ()
1155 "Check the various replysign variables and take action accordingly."
1156 (when (or gnus-message-replysign gnus-message-replyencrypt)
1157 (let (signed encrypted)
1159 (set-buffer gnus-article-buffer)
1160 (setq signed (memq 'signed gnus-article-wash-types))
1161 (setq encrypted (memq 'encrypted gnus-article-wash-types)))
1162 (cond ((and gnus-message-replyencrypt encrypted)
1163 (mml-secure-message mml-default-encrypt-method
1164 (if gnus-message-replysignencrypted
1167 ((and gnus-message-replysign signed)
1168 (mml-secure-message mml-default-sign-method 'sign))))))
1170 (defun gnus-summary-reply-with-original (n &optional wide)
1171 "Start composing a reply mail to the current message.
1172 The original article will be yanked."
1174 (gnus-summary-reply (gnus-summary-work-articles n) wide))
1176 (defun gnus-summary-reply-broken-reply-to (&optional yank wide very-wide)
1177 "Like `gnus-summary-reply' except removing reply-to field.
1178 If prefix argument YANK is non-nil, the original article is yanked
1180 If WIDE, make a wide reply.
1181 If VERY-WIDE, make a very wide reply."
1183 (list (and current-prefix-arg
1184 (gnus-summary-work-articles 1))))
1185 (let ((gnus-msg-force-broken-reply-to t))
1186 (gnus-summary-reply yank wide very-wide)))
1188 (defun gnus-summary-reply-broken-reply-to-with-original (n &optional wide)
1189 "Like `gnus-summary-reply-with-original' except removing reply-to field.
1190 The original article will be yanked."
1192 (gnus-summary-reply-broken-reply-to (gnus-summary-work-articles n) wide))
1194 (defun gnus-summary-wide-reply (&optional yank)
1195 "Start composing a wide reply mail to the current message.
1196 If prefix argument YANK is non-nil, the original article is yanked
1199 (list (and current-prefix-arg
1200 (gnus-summary-work-articles 1))))
1201 (gnus-summary-reply yank t))
1203 (defun gnus-summary-wide-reply-with-original (n)
1204 "Start composing a wide reply mail to the current message.
1205 The original article will be yanked."
1207 (gnus-summary-reply-with-original n t))
1209 (defun gnus-summary-very-wide-reply (&optional yank)
1210 "Start composing a very wide reply mail to the current message.
1211 If prefix argument YANK is non-nil, the original article is yanked
1214 (list (and current-prefix-arg
1215 (gnus-summary-work-articles 1))))
1216 (gnus-summary-reply yank t (gnus-summary-work-articles yank)))
1218 (defun gnus-summary-very-wide-reply-with-original (n)
1219 "Start composing a very wide reply mail to the current message.
1220 The original article will be yanked."
1223 (gnus-summary-work-articles n) t (gnus-summary-work-articles n)))
1225 (defun gnus-summary-mail-forward (&optional arg post)
1226 "Forward the current message(s) to another user.
1227 If process marks exist, forward all marked messages;
1228 if ARG is nil, see `message-forward-as-mime' and `message-forward-show-mml';
1229 if ARG is 1, decode the message and forward directly inline;
1230 if ARG is 2, forward message as an rfc822 MIME section;
1231 if ARG is 3, decode message and forward as an rfc822 MIME section;
1232 if ARG is 4, forward message directly inline;
1233 otherwise, use flipped `message-forward-as-mime'.
1234 If POST, post instead of mail.
1235 For the `inline' alternatives, also see the variable
1236 `message-forward-ignored-headers'."
1238 (if (cdr (gnus-summary-work-articles nil))
1239 ;; Process marks are given.
1240 (gnus-uu-digest-mail-forward arg post)
1241 ;; No process marks.
1242 (let ((message-forward-as-mime message-forward-as-mime)
1243 (message-forward-show-mml message-forward-show-mml))
1247 (setq message-forward-as-mime nil
1248 message-forward-show-mml t))
1250 (setq message-forward-as-mime t
1251 message-forward-show-mml nil))
1253 (setq message-forward-as-mime t
1254 message-forward-show-mml t))
1256 (setq message-forward-as-mime nil
1257 message-forward-show-mml nil))
1259 (setq message-forward-as-mime (not message-forward-as-mime))))
1260 (let* ((gnus-article-reply (gnus-summary-article-number))
1261 (gnus-article-yanked-articles (list gnus-article-reply)))
1262 (gnus-setup-message 'forward
1263 (gnus-summary-select-article)
1264 (let ((mail-parse-charset
1265 (or (and (gnus-buffer-live-p gnus-article-buffer)
1266 (with-current-buffer gnus-article-buffer
1267 gnus-article-charset))
1268 gnus-newsgroup-charset))
1269 (mail-parse-ignored-charsets
1270 gnus-newsgroup-ignored-charsets))
1271 (set-buffer gnus-original-article-buffer)
1272 (message-forward post)))))))
1274 (defun gnus-summary-resend-message (address n)
1275 "Resend the current article to ADDRESS."
1277 (list (message-read-from-minibuffer
1278 "Resend message(s) to: "
1279 (when (and gnus-summary-resend-default-address
1280 (gnus-buffer-live-p gnus-original-article-buffer))
1281 ;; If some other article is currently selected, the
1282 ;; initial-contents is wrong. Whatever, it is just the
1283 ;; initial-contents.
1284 (with-current-buffer gnus-original-article-buffer
1285 (nnmail-fetch-field "to"))))
1286 current-prefix-arg))
1287 (let ((articles (gnus-summary-work-articles n))
1289 (while (setq article (pop articles))
1290 (gnus-summary-select-article nil nil nil article)
1292 (set-buffer gnus-original-article-buffer)
1293 (message-resend address))
1294 (gnus-summary-mark-article-as-forwarded article))))
1296 ;; From: Matthieu Moy <Matthieu.Moy@imag.fr>
1297 (defun gnus-summary-resend-message-edit ()
1298 "Resend an article that has already been sent.
1299 A new buffer will be created to allow the user to modify body and
1300 contents of the message, and then, everything will happen as when
1301 composing a new message."
1303 (let ((article (gnus-summary-article-number)))
1304 (gnus-setup-message 'reply-yank
1305 (gnus-summary-select-article t)
1306 (set-buffer gnus-original-article-buffer)
1307 (let ((cur (current-buffer))
1308 (to (message-fetch-field "to")))
1309 ;; Get a normal message buffer.
1310 (message-pop-to-buffer (message-buffer-name "Resend" to))
1311 (insert-buffer-substring cur)
1313 (message-narrow-to-head-1)
1314 ;; Gnus will generate a new one when sending.
1315 (message-remove-header "Message-ID")
1316 (message-remove-header message-ignored-resent-headers t)
1317 ;; Remove unwanted headers.
1318 (goto-char (point-max))
1319 (insert mail-header-separator)
1320 (goto-char (point-min))
1321 (re-search-forward "^To:\\|^Newsgroups:" nil 'move)
1325 (defun gnus-summary-post-forward (&optional arg)
1326 "Forward the current article to a newsgroup.
1327 See `gnus-summary-mail-forward' for ARG."
1329 (gnus-summary-mail-forward arg t))
1331 (defvar gnus-nastygram-message
1332 "The following article was inappropriately posted to %s.\n\n"
1333 "Format string to insert in nastygrams.
1334 The current group name will be inserted at \"%s\".")
1336 (defun gnus-summary-mail-nastygram (n)
1337 "Send a nastygram to the author of the current article."
1339 (when (or gnus-expert-user
1341 "Really send a nastygram to the author of the current article? "))
1342 (let ((group gnus-newsgroup-name))
1343 (gnus-summary-reply-with-original n)
1344 (set-buffer gnus-message-buffer)
1346 (insert (format gnus-nastygram-message group))
1347 (message-send-and-exit))))
1349 (defun gnus-summary-mail-crosspost-complaint (n)
1350 "Send a complaint about crossposting to the current article(s)."
1352 (let ((articles (gnus-summary-work-articles n))
1354 (while (setq article (pop articles))
1355 (set-buffer gnus-summary-buffer)
1356 (gnus-summary-goto-subject article)
1357 (let ((group (gnus-group-real-name gnus-newsgroup-name))
1358 newsgroups followup-to)
1359 (gnus-summary-select-article)
1360 (set-buffer gnus-original-article-buffer)
1361 (if (and (<= (length (message-tokenize-header
1363 (mail-fetch-field "newsgroups"))
1366 (or (not (setq followup-to (mail-fetch-field "followup-to")))
1367 (not (member group (message-tokenize-header
1368 followup-to ", ")))))
1370 (gnus-message 1 "Followup-to restricted")
1371 (gnus-message 1 "Not a crossposted article"))
1372 (set-buffer gnus-summary-buffer)
1373 (gnus-summary-reply-with-original 1)
1374 (set-buffer gnus-message-buffer)
1376 (insert (format gnus-crosspost-complaint newsgroups group))
1377 (message-goto-subject)
1378 (re-search-forward " *$")
1379 (replace-match " (crosspost notification)" t t)
1380 (gnus-deactivate-mark)
1381 (when (gnus-y-or-n-p "Send this complaint? ")
1382 (message-send-and-exit)))))))
1384 (defun gnus-mail-parse-comma-list ()
1387 (skip-chars-forward " ")
1390 (skip-chars-forward "^,")
1395 (narrow-to-region beg (point))
1398 (while (search-forward "\"" nil t)
1402 (skip-chars-forward ",")
1403 (skip-chars-forward "^,"))
1404 (skip-chars-backward " ")
1405 (push (buffer-substring beg (point))
1407 (skip-chars-forward "^,")
1408 (skip-chars-forward ", "))
1411 (defun gnus-inews-add-to-address (group)
1412 (let ((to-address (mail-fetch-field "to")))
1413 (when (and to-address
1415 ;; This mail group doesn't have a `to-list', so we add one
1417 (when (gnus-y-or-n-p
1418 (format "Do you want to add this as `to-list': %s " to-address))
1419 (gnus-group-add-parameter group (cons 'to-list to-address))))))
1421 (defun gnus-put-message ()
1422 "Put the current message in some group and return to Gnus."
1424 (let ((reply gnus-article-reply)
1425 (winconf gnus-prev-winconf)
1426 (group gnus-newsgroup-name))
1428 (not (gnus-group-read-only-p group)))
1429 (setq group (read-string "Put in group: " nil (gnus-writable-groups))))
1431 (when (gnus-gethash group gnus-newsrc-hashtb)
1432 (error "No such group: %s" group))
1436 (message-narrow-to-headers)
1437 (let ((gnus-deletable-headers nil))
1438 (message-generate-headers
1439 (if (message-news-p)
1440 message-required-news-headers
1441 message-required-mail-headers)))
1442 (goto-char (point-max))
1443 (if (string-match " " group)
1444 (insert "Gcc: \"" group "\"\n")
1445 (insert "Gcc: " group "\n"))
1448 (when (and (get-buffer gnus-group-buffer)
1449 (gnus-buffer-exists-p (car-safe reply))
1451 (set-buffer (car reply))
1452 (gnus-summary-mark-article-as-replied (cdr reply)))
1454 (set-window-configuration winconf))))
1456 (defun gnus-article-mail (yank)
1457 "Send a reply to the address near point.
1458 If YANK is non-nil, include the original article."
1462 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
1463 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
1465 (gnus-msg-mail address)
1467 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
1469 (defvar nntp-server-type)
1471 "Send a bug report to the Gnus maintainers."
1473 (unless (gnus-alive-p)
1474 (error "Gnus has been shut down"))
1475 (gnus-setup-message (if (message-mail-user-agent) 'message 'bug)
1476 (unless (message-mail-user-agent)
1477 (delete-other-windows)
1478 (when gnus-bug-create-help-buffer
1479 (switch-to-buffer "*Gnus Help Bug*")
1481 (insert gnus-bug-message)
1482 (goto-char (point-min)))
1483 (message-pop-to-buffer "*Gnus Bug*"))
1484 (let ((message-this-is-mail t))
1485 (message-setup `((To . ,gnus-maintainer) (Subject . ""))))
1486 (when gnus-bug-create-help-buffer
1487 (push `(gnus-bug-kill-buffer) message-send-actions))
1488 (goto-char (point-min))
1489 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
1491 (insert (gnus-version) "\n"
1492 (emacs-version) "\n")
1493 (when (and (boundp 'nntp-server-type)
1494 (stringp nntp-server-type))
1495 (insert nntp-server-type))
1496 (insert "\n\n\n\n\n")
1499 (set-buffer (gnus-get-buffer-create " *gnus environment info*"))
1502 (setq text (buffer-string)))
1503 (insert "<#part type=application/emacs-lisp disposition=inline description=\"User settings\">\n" text "\n<#/part>"))
1504 (goto-char (point-min))
1505 (search-forward "Subject: " nil t)
1508 (defun gnus-bug-kill-buffer ()
1509 (when (get-buffer "*Gnus Help Bug*")
1510 (kill-buffer "*Gnus Help Bug*")))
1512 (defun gnus-summary-yank-message (buffer n)
1513 "Yank the current article into a composed message."
1515 (list (completing-read "Buffer: " (mapcar 'list (message-buffers)) nil t)
1516 current-prefix-arg))
1517 (gnus-summary-iterate n
1518 (let ((gnus-display-mime-function nil)
1519 (gnus-inhibit-treatment t))
1520 (gnus-summary-select-article))
1523 (message-yank-buffer gnus-article-buffer))))
1525 (defun gnus-debug ()
1526 "Attempts to go through the Gnus source file and report what variables have been changed.
1527 The source file has to be in the Emacs load path."
1529 (let ((files gnus-debug-files)
1531 file expr olist sym)
1532 (gnus-message 4 "Please wait while we snoop your variables...")
1534 ;; Go through all the files looking for non-default values for variables.
1536 (set-buffer (gnus-get-buffer-create " *gnus bug info*"))
1539 (when (and (setq file (locate-library (pop files)))
1540 (file-exists-p file))
1541 (insert-file-contents file)
1542 (goto-char (point-min))
1543 (if (not (re-search-forward "^;;* *Internal variables" nil t))
1544 (gnus-message 4 "Malformed sources in file %s" file)
1545 (narrow-to-region (point-min) (point))
1546 (goto-char (point-min))
1547 (while (setq expr (ignore-errors (read (current-buffer))))
1549 (and (or (eq (car expr) 'defvar)
1550 (eq (car expr) 'defcustom))
1551 (stringp (nth 3 expr))
1552 (not (memq (nth 1 expr) gnus-debug-exclude-variables))
1553 (or (not (boundp (nth 1 expr)))
1554 (not (equal (eval (nth 2 expr))
1555 (symbol-value (nth 1 expr)))))
1556 (push (nth 1 expr) olist)))))))
1557 (kill-buffer (current-buffer)))
1558 (when (setq olist (nreverse olist))
1559 (insert "------------------ Environment follows ------------------\n\n"))
1561 (if (boundp (car olist))
1563 (pp `(setq ,(car olist)
1564 ,(if (or (consp (setq sym (symbol-value (car olist))))
1566 (not (or (eq sym nil)
1568 (list 'quote (symbol-value (car olist)))
1569 (symbol-value (car olist))))
1571 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
1572 (setq olist (cdr olist)))
1574 ;; Remove any control chars - they seem to cause trouble for some
1575 ;; mailers. (Byte-compiled output from the stuff above.)
1577 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
1578 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
1581 ;;; Treatment of rejected articles.
1584 (defun gnus-summary-resend-bounced-mail (&optional fetch)
1585 "Re-mail the current message.
1586 This only makes sense if the current message is a bounce message than
1587 contains some mail you have written which has been bounced back to
1589 If FETCH, try to fetch the article that this is a reply to, if indeed
1592 (gnus-summary-select-article t)
1593 (set-buffer gnus-original-article-buffer)
1594 (gnus-setup-message 'compose-bounce
1595 (let* ((references (mail-fetch-field "references"))
1596 (parent (and references (gnus-parent-id references))))
1598 ;; If there are references, we fetch the article we answered to.
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 (unless (setq group-art
1684 (gnus-request-accept-article group method t t))
1685 (gnus-message 1 "Couldn't store article in group %s: %s"
1686 group (gnus-status-message method))
1688 (when (and group-art
1689 ;; FIXME: Should gcc-mark-as-read work when
1690 ;; Gnus is not running?
1692 (or gnus-gcc-mark-as-read
1693 gnus-inews-mark-gcc-as-read))
1694 (gnus-group-mark-article-read group (cdr group-art)))
1695 (kill-buffer (current-buffer)))))))))
1697 (defun gnus-inews-insert-gcc ()
1698 "Insert Gcc headers based on `gnus-outgoing-message-group'."
1701 (message-narrow-to-headers)
1702 (let* ((group gnus-outgoing-message-group)
1704 ((gnus-functionp group)
1706 ((or (stringp group) (list group))
1711 (if (string-match " " gcc)
1712 (concat "\"" gcc "\"")
1714 (mapconcat (lambda (group)
1715 (if (string-match " " group)
1716 (concat "\"" group "\"")
1721 (defun gnus-inews-insert-archive-gcc (&optional group)
1722 "Insert the Gcc to say where the article is to be archived."
1723 (let* ((var gnus-message-archive-group)
1724 (group (or group gnus-newsgroup-name ""))
1726 (and gnus-newsgroup-name
1727 (not (equal gnus-newsgroup-name ""))
1728 (gnus-group-find-parameter
1729 gnus-newsgroup-name 'gcc-self)))
1733 ((null gnus-message-archive-method)
1737 ;; Just a single group.
1740 ;; We don't want this.
1742 ((and (listp var) (stringp (car var)))
1743 ;; A list of groups.
1745 ((gnus-functionp var)
1747 (funcall var group))
1749 ;; An alist of regexps/functions/forms.
1754 ((stringp (caar var))
1756 (when (string-match (caar var) group)
1758 ((gnus-functionp (car var))
1760 (funcall (car var) group))
1762 (eval (car var)))))))
1763 (setq var (cdr var)))
1766 (when (or groups gcc-self-val)
1767 (when (stringp groups)
1768 (setq groups (list groups)))
1771 (message-narrow-to-headers)
1772 (goto-char (point-max))
1775 ;; Use the `gcc-self' param value instead.
1778 (if (stringp gcc-self-val)
1779 (if (string-match " " gcc-self-val)
1780 (concat "\"" gcc-self-val "\"")
1782 (if (string-match " " group)
1783 (concat "\"" group "\"")
1785 (if (not (eq gcc-self-val 'none))
1787 (gnus-delete-line)))
1788 ;; Use the list of groups.
1789 (while (setq name (pop groups))
1790 (let ((str (if (string-match ":" name)
1792 (gnus-group-prefixed-name
1793 name gnus-message-archive-method))))
1794 (insert (if (string-match " " str)
1795 (concat "\"" str "\"")
1801 (defun gnus-mailing-list-followup-to ()
1802 "Look at the headers in the current buffer and return a Mail-Followup-To address."
1803 (let ((x-been-there (gnus-fetch-original-field "x-beenthere"))
1804 (list-post (gnus-fetch-original-field "list-post")))
1805 (when (and list-post
1806 (string-match "mailto:\\([^>]+\\)" list-post))
1807 (setq list-post (match-string 1 list-post)))
1813 (defun gnus-configure-posting-styles (&optional group-name)
1814 "Configure posting styles according to `gnus-posting-styles'."
1815 (unless gnus-inhibit-posting-styles
1816 (let ((group (or group-name gnus-newsgroup-name ""))
1817 (styles gnus-posting-styles)
1818 style match variable attribute value v results
1819 filep name address element)
1820 ;; If the group has a posting-style parameter, add it at the end with a
1821 ;; regexp matching everything, to be sure it takes precedence over all
1823 (when gnus-newsgroup-name
1824 (let ((tmp-style (gnus-group-find-parameter group 'posting-style t)))
1826 (setq styles (append styles (list (cons ".*" tmp-style)))))))
1827 ;; Go through all styles and look for matches.
1828 (dolist (style styles)
1829 (setq match (pop style))
1830 (goto-char (point-min))
1833 ;; Regexp string match on the group name.
1834 (string-match match group))
1836 ;; Obsolete format of header match.
1837 (and (gnus-buffer-live-p gnus-article-copy)
1838 (with-current-buffer gnus-article-copy
1839 (let ((header (message-fetch-field (pop style))))
1841 (string-match (pop style) header))))))
1842 ((or (symbolp match)
1843 (gnus-functionp match))
1845 ((gnus-functionp match)
1846 ;; Function to be called.
1849 ;; Variable to be checked.
1850 (symbol-value match))))
1853 ((eq (car match) 'header)
1854 ;; New format of header match.
1855 (and (gnus-buffer-live-p gnus-article-copy)
1856 (with-current-buffer gnus-article-copy
1857 (let ((header (message-fetch-field (nth 1 match))))
1859 (string-match (nth 2 match) header))))))
1861 ;; This is a form to be evaled.
1863 ;; We have a match, so we set the variables.
1864 (dolist (attribute style)
1865 (setq element (pop attribute)
1870 ((eq (car attribute) :file)
1873 ((eq (car attribute) :value)
1877 ;; We get the value.
1882 ((or (symbolp value)
1883 (gnus-functionp value))
1884 (cond ((gnus-functionp value)
1887 (symbol-value value))))
1890 ;; Translate obsolescent value.
1892 ((eq element 'signature-file)
1893 (setq element 'signature
1895 ((eq element 'x-face-file)
1896 (setq element 'x-face
1898 ;; Get the contents of file elems.
1900 (setq v (with-temp-buffer
1901 (insert-file-contents v)
1902 (goto-char (point-max))
1906 (setq results (delq (assoc element results) results))
1907 (push (cons element v) results))))
1908 ;; Now we have all the styles, so we insert them.
1909 (setq name (assq 'name results)
1910 address (assq 'address results))
1911 (setq results (delq name (delq address results)))
1912 ;; make-local-hook is not obsolete in Emacs 20 or XEmacs.
1913 (make-local-hook 'message-setup-hook)
1914 (setq results (sort results (lambda (x y)
1915 (string-lessp (car x) (car y)))))
1916 (dolist (result results)
1917 (add-hook 'message-setup-hook
1919 ((eq 'eval (car result))
1921 ((eq 'body (car result))
1925 (insert ,(cdr result)))))
1926 ((eq 'signature (car result))
1927 (set (make-local-variable 'message-signature) nil)
1928 (set (make-local-variable 'message-signature-file) nil)
1929 (if (not (cdr result))
1933 (let ((message-signature ,(cdr result)))
1934 (when message-signature
1935 (message-insert-signature)))))))
1938 (if (symbolp (car result))
1939 (capitalize (symbol-name (car result)))
1943 (message-remove-header ,header)
1944 (let ((value ,(cdr result)))
1947 (insert ,header ": " value)
1949 (insert "\n")))))))))
1951 (when (or name address)
1952 (add-hook 'message-setup-hook
1954 (set (make-local-variable 'user-mail-address)
1955 ,(or (cdr address) user-mail-address))
1956 (let ((user-full-name ,(or (cdr name) (user-full-name)))
1958 ,(or (cdr address) user-mail-address)))
1960 (message-remove-header "From")
1962 (insert "From: " (message-make-from) "\n"))))
1965 ;;; Allow redefinition of functions.
1971 ;;; gnus-msg.el ends here