1 ;;; gnus-msg.el --- mail and post interface for Semi-gnus
3 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
4 ;; 2004, 2005 Free Software Foundation, Inc.
6 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
7 ;; Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
9 ;; Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp>
10 ;; Katsumi Yamaoka <yamaoka@jpl.org>
11 ;; Kiyokazu SUTO <suto@merry.xmath.ous.ac.jp>
12 ;; Keywords: mail, news, MIME
14 ;; This file is part of GNU Emacs.
16 ;; GNU Emacs is free software; you can redistribute it and/or modify
17 ;; it under the terms of the GNU General Public License as published by
18 ;; the Free Software Foundation; either version 2, or (at your option)
21 ;; GNU Emacs is distributed in the hope that it will be useful,
22 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
23 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 ;; GNU General Public License for more details.
26 ;; You should have received a copy of the GNU General Public License
27 ;; along with GNU Emacs; see the file COPYING. If not, write to the
28 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
29 ;; Boston, MA 02110-1301, USA.
35 (eval-when-compile (require 'cl))
36 (eval-when-compile (require 'static))
44 (defcustom gnus-post-method 'current
45 "*Preferred method for posting USENET news.
47 If this variable is `current' (which is the default), Gnus will use
48 the \"current\" select method when posting. If it is `native', Gnus
49 will use the native select method when posting.
51 This method will not be used in mail groups and the like, only in
54 If not `native' nor `current', the value must be a valid method as discussed
55 in the documentation of `gnus-select-method'. It can also be a list of
56 methods. If that is the case, the user will be queried for what select
57 method to use when posting."
58 :group 'gnus-group-foreign
59 :link '(custom-manual "(gnus)Posting Server")
60 :type `(choice (const native)
62 (sexp :tag "Methods" ,gnus-select-method)))
64 (defcustom gnus-outgoing-message-group nil
65 "*All outgoing messages will be put in this group.
66 If you want to store all your outgoing mail and articles in the group
67 \"nnml:archive\", you set this variable to that value. This variable
68 can also be a list of group names.
70 If you want to have greater control over what group to put each
71 message in, you can set this variable to a function that checks the
72 current newsgroup name and then returns a suitable group name (or list
75 :type '(choice (string :tag "Group")
78 (defcustom gnus-mailing-list-groups nil
79 "*If non-nil a regexp matching groups that are really mailing lists.
80 This is useful when you're reading a mailing list that has been
81 gatewayed to a newsgroup, and you want to followup to an article in
84 :type '(choice (regexp)
87 (defcustom gnus-add-to-list nil
88 "*If non-nil, add a `to-list' parameter automatically."
92 (defcustom gnus-crosspost-complaint
95 You posted the article below with the following Newsgroups header:
99 The %s group, at least, was an inappropriate recipient
100 of this message. Please trim your Newsgroups header to exclude this
101 group before posting in the future.
106 "Format string to be inserted when complaining about crossposts.
107 The first %s will be replaced by the Newsgroups header;
108 the second with the current group name."
112 (defcustom gnus-message-setup-hook nil
113 "Hook run after setting up a message buffer."
117 (defcustom gnus-bug-create-help-buffer t
118 "*Should we create the *Gnus Help Bug* buffer?"
122 (defcustom gnus-posting-styles nil
123 "*Alist of styles to use when posting.
124 See Info node `(gnus)Posting Styles'."
126 :link '(custom-manual "(gnus)Posting Styles")
127 :type '(repeat (cons (choice (regexp)
130 (string :tag "Header")
131 (regexp :tag "Regexp"))
135 (choice (const signature)
136 (const signature-file)
144 (string :tag "Header"))
150 (defcustom gnus-named-posting-styles nil
151 "Alist mapping names to the user-defined posting styles."
153 :type '(repeat (cons string
155 (choice (const signature)
156 (const signature-file)
164 (string :tag "Header"))
170 (defcustom gnus-gcc-mark-as-read nil
171 "If non-nil, automatically mark Gcc articles as read."
176 (make-obsolete-variable 'gnus-inews-mark-gcc-as-read
177 'gnus-gcc-mark-as-read)
179 (defcustom gnus-gcc-externalize-attachments nil
180 "Should local-file attachments be included as external parts in Gcc copies?
181 If it is `all', attach files as external parts;
182 if a regexp and matches the Gcc group name, attach files as external parts;
183 if nil, attach files as normal parts."
186 :type '(choice (const nil :tag "None")
187 (const all :tag "Any")
188 (string :tag "Regexp")))
190 (gnus-define-group-parameter
191 posting-charset-alist
194 "Return the permitted unencoded charsets for posting of GROUP."
195 :variable gnus-group-posting-charset-alist
197 '(("^\\(no\\|fr\\)\\.[^,]*\\(,[ \t\n]*\\(no\\|fr\\)\\.[^,]*\\)*$" iso-8859-1 (iso-8859-1))
198 ("^\\(fido7\\|relcom\\)\\.[^,]*\\(,[ \t\n]*\\(fido7\\|relcom\\)\\.[^,]*\\)*$" koi8-r (koi8-r))
199 (message-this-is-mail nil nil)
200 (message-this-is-news nil t))
202 "Alist of regexps and permitted unencoded charsets for posting.
203 Each element of the alist has the form (TEST HEADER BODY-LIST), where
204 TEST is either a regular expression matching the newsgroup header or a
206 HEADER is the charset which may be left unencoded in the header (nil
207 means encode all charsets),
208 BODY-LIST is a list of charsets which may be encoded using 8bit
209 content-transfer encoding in the body, or one of the special values
210 nil (always encode using quoted-printable) or t (always use 8bit).
212 Note that any value other than nil for HEADER infringes some RFCs, so
213 use this option with care."
214 :variable-group gnus-charset
216 '(repeat (list :tag "Permitted unencoded charsets"
218 (regexp :tag "Group")
219 (const :tag "Mail message" :value message-this-is-mail)
220 (const :tag "News article" :value message-this-is-news))
221 (choice :tag "Header"
222 (const :tag "None" nil)
223 (symbol :tag "Charset"))
225 (const :tag "Any" :value t)
226 (const :tag "None" :value nil)
227 (repeat :tag "Charsets"
228 (symbol :tag "Charset")))))
229 :parameter-type '(choice :tag "Permitted unencoded charsets"
232 :parameter-document "\
233 List of charsets that are permitted to be unencoded.")
235 (defcustom gnus-debug-files
236 '("gnus.el" "gnus-sum.el" "gnus-group.el"
237 "gnus-art.el" "gnus-start.el" "gnus-async.el"
238 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
239 "gnus-agent.el" "gnus-cache.el" "gnus-srvr.el"
240 "mm-util.el" "mm-decode.el" "nnmail.el" "nntp.el" "message.el")
241 "Files whose variables will be reported in `gnus-bug'."
244 :type '(repeat (string :tag "File")))
246 (defcustom gnus-debug-exclude-variables
247 '(mm-mime-mule-charset-alist
248 nnmail-split-fancy message-minibuffer-local-map)
249 "Variables that should not be reported in `gnus-bug'."
252 :type '(repeat (symbol :tag "Variable")))
254 (defcustom gnus-discouraged-post-methods
255 '(nndraft nnml nnimap nnmaildir nnmh nnfolder nndir)
256 "A list of back ends that are not used in \"real\" newsgroups.
257 This variable is used only when `gnus-post-method' is `current'."
259 :group 'gnus-group-foreign
260 :type '(repeat (symbol :tag "Back end")))
262 (defcustom gnus-message-replysign
264 "Automatically sign replies to signed messages.
265 See also the `mml-default-sign-method' variable."
269 (defcustom gnus-message-replyencrypt
271 "Automatically encrypt replies to encrypted messages.
272 See also the `mml-default-encrypt-method' variable."
276 (defcustom gnus-message-replysignencrypted
278 "Setting this causes automatically encrypted messages to also be signed."
282 (defcustom gnus-confirm-mail-reply-to-news (and gnus-novice-user
283 (not gnus-expert-user))
284 "If non-nil, Gnus requests confirmation when replying to news.
285 This is done because new users often reply by mistake when reading
287 This can also be a function receiving the group name as the only
288 parameter which should return non-nil iff a confirmation is needed, or
289 a regexp, in which case a confirmation is asked for iff the group name
293 :type '(choice (const :tag "No" nil)
295 (regexp :tag "Iff group matches regexp")
296 (function :tag "Iff function evaluates to non-nil")))
298 (defcustom gnus-confirm-treat-mail-like-news
300 "If non-nil, Gnus will treat mail like news with regard to confirmation
301 when replying by mail. See the `gnus-confirm-mail-reply-to-news' variable
302 for fine-tuning this.
303 If nil, Gnus will never ask for confirmation if replying to mail."
308 (defcustom gnus-summary-resend-default-address t
309 "If non-nil, Gnus tries to suggest a default address to resend to.
310 If nil, the address field will always be empty after invoking
311 `gnus-summary-resend-message'."
316 ;;; Internal variables.
318 (defvar gnus-inhibit-posting-styles nil
319 "Inhibit the use of posting styles.")
321 (defvar gnus-article-yanked-articles nil)
322 (defvar gnus-message-buffer "*Mail Gnus*")
323 (defvar gnus-article-copy nil)
324 (defvar gnus-check-before-posting nil)
325 (defvar gnus-last-posting-server nil)
326 (defvar gnus-message-group-art nil)
328 (defvar gnus-msg-force-broken-reply-to nil)
330 (defconst gnus-bug-message
331 (format "Sending a bug report to the Gnus Towers.
332 ========================================
334 This gnus is the %s%s.
335 If you think the bug is a Semi-gnus bug, send a bug report to Semi-gnus
336 Developers. (the addresses below are mailing list addresses)
338 ========================================
340 The buffer below is a mail buffer. When you press `C-c C-c', it will
341 be sent to the Gnus Bug Exterminators.
343 The thing near the bottom of the buffer is how the environment
344 settings will be included in the mail. Please do not delete that.
345 They will tell the Bug People what your environment is, so that it
346 will be easier to locate the bugs.
348 If you have found a bug that makes Emacs go \"beep\", set
349 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
350 and include the backtrace in your bug report.
352 Please describe the bug in annoying, painstaking detail.
354 Thank you for your help in stamping out bugs.
357 (if (string= gnus-product-name "Semi-gnus")
359 ", a modified version of Semi-gnus")))
362 (autoload 'gnus-uu-post-news "gnus-uu" nil t))
366 ;;; Gnus Posting Functions
369 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
370 "p" gnus-summary-post-news
371 "i" gnus-summary-news-other-window
372 "f" gnus-summary-followup
373 "F" gnus-summary-followup-with-original
374 "c" gnus-summary-cancel-article
375 "s" gnus-summary-supersede-article
376 "r" gnus-summary-reply
377 "y" gnus-summary-yank-message
378 "R" gnus-summary-reply-with-original
379 "w" gnus-summary-wide-reply
380 "W" gnus-summary-wide-reply-with-original
381 "v" gnus-summary-very-wide-reply
382 "V" gnus-summary-very-wide-reply-with-original
383 "n" gnus-summary-followup-to-mail
384 "N" gnus-summary-followup-to-mail-with-original
385 "m" gnus-summary-mail-other-window
386 "u" gnus-uu-post-news
387 "\M-c" gnus-summary-mail-crosspost-complaint
388 "Br" gnus-summary-reply-broken-reply-to
389 "BR" gnus-summary-reply-broken-reply-to-with-original
390 "om" gnus-summary-mail-forward
391 "op" gnus-summary-post-forward
392 "Om" gnus-summary-digest-mail-forward
393 "Op" gnus-summary-digest-post-forward
394 "P" gnus-summary-execute-command-with-posting-style)
396 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
397 "b" gnus-summary-resend-bounced-mail
398 ;; "c" gnus-summary-send-draft
399 "r" gnus-summary-resend-message
400 "e" gnus-summary-resend-message-edit)
402 ;;; Internal functions.
404 (defun gnus-inews-make-draft (articles)
406 (gnus-inews-make-draft-meta-information
407 ,gnus-newsgroup-name ',articles)))
409 (defvar gnus-article-reply nil)
410 (defmacro gnus-setup-message (config &rest forms)
411 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
412 (buffer (make-symbol "gnus-setup-message-buffer"))
413 (article (make-symbol "gnus-setup-message-article"))
414 (yanked (make-symbol "gnus-setup-yanked-articles"))
415 (group (make-symbol "gnus-setup-message-group")))
416 `(let ((,winconf (current-window-configuration))
417 (,buffer (buffer-name (current-buffer)))
418 (,article gnus-article-reply)
419 (,yanked gnus-article-yanked-articles)
420 (,group gnus-newsgroup-name)
421 (message-header-setup-hook
422 (copy-sequence message-header-setup-hook))
423 (message-mode-hook (copy-sequence message-mode-hook))
424 (message-startup-parameter-alist
425 '((reply-buffer . gnus-copy-article-buffer)
426 (original-buffer . gnus-original-article-buffer)
427 (user-agent . Gnus))))
428 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
429 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
430 ;; #### FIXME: for a reason that I did not manage to identify yet,
431 ;; the variable `gnus-newsgroup-name' does not honor a dynamically
432 ;; scoped or setq'ed value from a caller like `C-u gnus-summary-mail'.
433 ;; After evaluation of @forms below, it gets the value we actually want
434 ;; to override, and the posting styles are used. For that reason, I've
435 ;; added an optional argument to `gnus-configure-posting-styles' to
436 ;; make sure that the correct value for the group name is used. -- drv
437 (add-hook 'message-mode-hook
438 (if (memq ,config '(reply-yank reply))
440 (gnus-configure-posting-styles ,group))
442 ;; There may be an old " *gnus article copy*" buffer.
443 (let (gnus-article-copy)
444 (gnus-configure-posting-styles ,group)))))
445 (gnus-pull ',(intern gnus-draft-meta-information-header)
446 message-required-headers)
448 (not (string= ,group "")))
450 (intern gnus-draft-meta-information-header)
451 (gnus-inews-make-draft (or ,yanked ,article)))
452 message-required-headers))
456 (gnus-inews-add-send-actions ,winconf ,buffer ,article ,config
458 (setq gnus-message-buffer (current-buffer))
459 (set (make-local-variable 'gnus-message-group-art)
460 (cons ,group ,article))
461 (set (make-local-variable 'gnus-newsgroup-name) ,group)
462 (gnus-maybe-setup-default-charset)
463 (gnus-run-hooks 'gnus-message-setup-hook))
464 (message-hide-headers)
466 (gnus-configure-windows ,config t)
467 (run-hooks 'post-command-hook)
468 (set-buffer-modified-p nil))))
470 (defun gnus-inews-make-draft-meta-information (group articles)
471 (when (numberp articles)
472 (setq articles (list articles)))
473 (concat "(\"" group "\""
487 (defun gnus-msg-mail (&optional to subject other-headers continue
488 switch-action yank-action send-actions)
489 "Start editing a mail message to be sent.
490 Like `message-mail', but with Gnus paraphernalia, particularly the
491 Gcc: header for archiving purposes."
493 (let ((buf (current-buffer))
495 (gnus-setup-message 'message
496 (message-mail to subject other-headers continue
497 nil yank-action send-actions))
499 (setq mail-buf (current-buffer))
500 (switch-to-buffer buf)
501 (apply switch-action mail-buf nil)))
502 ;; COMPOSEFUNC should return t if succeed. Undocumented ???
506 (defun gnus-button-mailto (address)
508 (set-buffer (gnus-copy-article-buffer))
509 (gnus-setup-message 'message
510 (message-reply address)))
513 (defun gnus-button-reply (&optional to-address wide)
514 "Like `message-reply'."
516 (gnus-setup-message 'message
517 (message-reply to-address wide)))
520 (define-mail-user-agent 'gnus-user-agent
521 'gnus-msg-mail 'message-send-and-exit
522 'message-kill-buffer 'message-send-hook)
524 (defun gnus-setup-posting-charset (group)
525 (let ((alist gnus-group-posting-charset-alist)
526 (group (or group ""))
530 (while (setq elem (pop alist))
531 (when (or (and (stringp (car elem))
532 (string-match (car elem) group))
533 (and (functionp (car elem))
534 (funcall (car elem) group))
535 (and (symbolp (car elem))
536 (symbol-value (car elem))))
537 (throw 'found (cons (cadr elem) (caddr elem)))))))))
539 (defun gnus-inews-add-send-actions (winconf buffer article
540 &optional config yanked)
541 (gnus-make-local-hook 'message-sent-hook)
542 (add-hook 'message-sent-hook (if gnus-agent 'gnus-agent-possibly-do-gcc
543 'gnus-inews-do-gcc) nil t)
545 (gnus-make-local-hook 'message-header-hook)
546 (add-hook 'message-header-hook 'gnus-agent-possibly-save-gcc nil t))
547 (setq message-post-method
548 `(lambda (&optional arg)
549 (gnus-post-method arg ,gnus-newsgroup-name)))
550 (setq message-user-agent (gnus-message-make-user-agent))
551 (unless message-use-multi-frames
553 `(if (gnus-buffer-exists-p ,buffer)
554 (set-window-configuration ,winconf))
555 'exit 'postpone 'kill))
556 (let ((to-be-marked (cond
559 (lambda (x) (if (listp x) (car x) x)) yanked))
560 (article (if (listp article) article (list article)))
563 `(when (gnus-buffer-exists-p ,buffer)
567 (if (eq config 'forward)
568 `(gnus-summary-mark-article-as-forwarded ',to-be-marked)
569 `(gnus-summary-mark-article-as-replied ',to-be-marked)))))
572 (put 'gnus-setup-message 'lisp-indent-function 1)
573 (put 'gnus-setup-message 'edebug-form-spec '(form body))
575 ;;; Post news commands of Gnus group mode and summary mode
577 (defun gnus-group-mail (&optional arg)
578 "Start composing a mail.
579 If ARG, use the group under the point to find a posting style.
580 If ARG is 1, prompt for a group name to find the posting style."
582 ;; We can't `let' gnus-newsgroup-name here, since that leads
583 ;; to local variables leaking.
584 (let ((group gnus-newsgroup-name)
585 ;; make sure last viewed article doesn't affect posting styles:
587 (buffer (current-buffer)))
590 (setq gnus-newsgroup-name
592 (if (= 1 (prefix-numeric-value arg))
593 (completing-read "Use posting style of group: "
594 gnus-active-hashtb nil
595 (gnus-read-active-file-p))
596 (gnus-group-group-name))
598 ;; #### see comment in gnus-setup-message -- drv
599 (gnus-setup-message 'message (message-mail)))
602 (setq gnus-newsgroup-name group)))))
604 (defun gnus-group-news (&optional arg)
605 "Start composing a news.
606 If ARG, post to group under point.
607 If ARG is 1, prompt for group name to post to.
609 This function prepares a news even when using mail groups. This is useful
610 for posting messages to mail groups without actually sending them over the
611 network. The corresponding back end must have a 'request-post method."
613 ;; We can't `let' gnus-newsgroup-name here, since that leads
614 ;; to local variables leaking.
615 (let ((group gnus-newsgroup-name)
616 ;; make sure last viewed article doesn't affect posting styles:
618 (buffer (current-buffer)))
621 (setq gnus-newsgroup-name
623 (if (= 1 (prefix-numeric-value arg))
624 (completing-read "Use group: "
625 gnus-active-hashtb nil
626 (gnus-read-active-file-p))
627 (gnus-group-group-name))
629 ;; #### see comment in gnus-setup-message -- drv
630 (gnus-setup-message 'message
631 (message-news (gnus-group-real-name gnus-newsgroup-name))))
634 (setq gnus-newsgroup-name group)))))
636 (defun gnus-group-post-news (&optional arg)
637 "Start composing a message (a news by default).
638 If ARG, post to group under point. If ARG is 1, prompt for group name.
639 Depending on the selected group, the message might be either a mail or
642 ;; Bind this variable here to make message mode hooks work ok.
643 (let ((gnus-newsgroup-name
645 (if (= 1 (prefix-numeric-value arg))
646 (completing-read "Newsgroup: " gnus-active-hashtb nil
647 (gnus-read-active-file-p))
648 (gnus-group-group-name))
650 ;; make sure last viewed article doesn't affect posting styles:
652 (gnus-post-news 'post gnus-newsgroup-name nil nil nil nil
653 (string= gnus-newsgroup-name ""))))
655 (defun gnus-summary-mail-other-window (&optional arg)
656 "Start composing a mail in another window.
657 Use the posting of the current group by default.
658 If ARG, don't do that. If ARG is 1, prompt for group name to find the
661 ;; We can't `let' gnus-newsgroup-name here, since that leads
662 ;; to local variables leaking.
663 (let ((group gnus-newsgroup-name)
664 ;; make sure last viewed article doesn't affect posting styles:
666 (buffer (current-buffer)))
669 (setq gnus-newsgroup-name
671 (if (= 1 (prefix-numeric-value arg))
672 (completing-read "Use group: "
673 gnus-active-hashtb nil
674 (gnus-read-active-file-p))
676 gnus-newsgroup-name))
677 ;; #### see comment in gnus-setup-message -- drv
678 (gnus-setup-message 'message (message-mail)))
681 (setq gnus-newsgroup-name group)))))
683 (defun gnus-summary-news-other-window (&optional arg)
684 "Start composing a news in another window.
685 Post to the current group by default.
686 If ARG, don't do that. If ARG is 1, prompt for group name to post to.
688 This function prepares a news even when using mail groups. This is useful
689 for posting messages to mail groups without actually sending them over the
690 network. The corresponding back end must have a 'request-post method."
692 ;; We can't `let' gnus-newsgroup-name here, since that leads
693 ;; to local variables leaking.
694 (let ((group gnus-newsgroup-name)
695 ;; make sure last viewed article doesn't affect posting styles:
697 (buffer (current-buffer)))
700 (setq gnus-newsgroup-name
702 (if (= 1 (prefix-numeric-value arg))
703 (completing-read "Use group: "
704 gnus-active-hashtb nil
705 (gnus-read-active-file-p))
707 gnus-newsgroup-name))
708 ;; #### see comment in gnus-setup-message -- drv
709 (gnus-setup-message 'message
711 (message-news (gnus-group-real-name gnus-newsgroup-name))
712 (set (make-local-variable 'gnus-discouraged-post-methods)
714 (car (gnus-find-method-for-group gnus-newsgroup-name))
715 gnus-discouraged-post-methods)))))
718 (setq gnus-newsgroup-name group)))))
720 (defun gnus-summary-post-news (&optional arg)
721 "Start composing a message. Post to the current group by default.
722 If ARG, don't do that. If ARG is 1, prompt for a group name to post to.
723 Depending on the selected group, the message might be either a mail or
726 ;; Bind this variable here to make message mode hooks work ok.
727 (let ((gnus-newsgroup-name
729 (if (= 1 (prefix-numeric-value arg))
730 (completing-read "Newsgroup: " gnus-active-hashtb nil
731 (gnus-read-active-file-p))
733 gnus-newsgroup-name))
734 ;; make sure last viewed article doesn't affect posting styles:
736 (gnus-post-news 'post gnus-newsgroup-name)))
739 (defun gnus-summary-followup (yank &optional force-news)
740 "Compose a followup to an article.
741 If prefix argument YANK is non-nil, the original article is yanked
743 YANK is a list of elements, where the car of each element is the
744 article number, and the cdr is the string to be yanked."
746 (list (and current-prefix-arg
747 (gnus-summary-work-articles 1))))
749 (gnus-summary-goto-subject
750 (if (listp (car yank))
753 (save-window-excursion
754 (gnus-summary-select-article))
755 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
756 (gnus-newsgroup-name gnus-newsgroup-name))
758 (gnus-post-news nil gnus-newsgroup-name
759 headers gnus-article-buffer
761 (gnus-summary-handle-replysign)))
763 (defun gnus-summary-followup-with-original (n &optional force-news)
764 "Compose a followup to an article and include the original article.
765 The text in the region will be yanked. If the region isn't
766 active, the entire article will be yanked."
768 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
770 (defun gnus-summary-followup-to-mail (&optional arg)
771 "Followup to the current mail message via news."
773 (list (and current-prefix-arg
774 (gnus-summary-work-articles 1))))
775 (gnus-summary-followup arg t))
777 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
778 "Followup to the current mail message via news."
780 (gnus-summary-followup (gnus-summary-work-articles arg) t))
782 (defun gnus-inews-yank-articles (articles)
783 (let (beg article yank-string
784 (more-than-one (cdr articles))
785 (cur (current-buffer))
788 (while (setq article (pop articles))
789 (when (listp article)
790 (setq yank-string (nth 1 article)
791 article (nth 0 article)))
792 (save-window-excursion
793 (set-buffer gnus-summary-buffer)
794 (gnus-summary-select-article nil nil nil article)
795 (gnus-summary-remove-process-mark article))
797 ;; Gathering references.
799 (setq refs (message-list-references
801 (mail-header-references gnus-current-headers)
802 (mail-header-message-id gnus-current-headers)))
803 (when message-use-multi-frames
804 (when (setq window (get-buffer-window cur t))
805 (select-frame (window-frame window)))))
807 (gnus-copy-article-buffer nil yank-string)
808 (let ((message-reply-buffer gnus-article-copy)
809 (message-reply-headers
810 ;; The headers are decoded.
811 (with-current-buffer gnus-article-copy
813 (nnheader-narrow-to-headers)
814 (nnheader-parse-naked-head)))))
815 (message-yank-original)
816 (setq beg (or beg (mark t))))
821 ;; Replace with the gathered references.
825 (message-narrow-to-headers)
826 (let ((case-fold-search t))
827 (if (re-search-forward "^References:\\([\t ]+.+\n\\)+" nil t)
829 (goto-char (point-max))))
831 (list (or (assq 'References message-header-format-alist)
832 '(References . message-shorten-references)))
833 (list (cons 'References
834 (mapconcat 'identity (nreverse refs) " ")))))
840 (defun gnus-summary-cancel-article (&optional n symp)
841 "Cancel an article you posted.
842 Uses the process-prefix convention. If given the symbolic
843 prefix `a', cancel using the standard posting method; if not
844 post using the current select method."
845 (interactive (gnus-interactive "P\ny"))
846 (let ((message-post-method
848 (gnus-post-method (eq ',symp 'a) ,gnus-newsgroup-name))))
849 (dolist (article (gnus-summary-work-articles n))
850 (when (gnus-summary-select-article t nil nil article)
851 (when (gnus-eval-in-buffer-window gnus-article-buffer
853 (set-buffer gnus-original-article-buffer)
854 (message-cancel-news)))
855 (gnus-summary-mark-as-read article gnus-canceled-mark)
856 (gnus-cache-remove-article 1))
857 (gnus-article-hide-headers-if-wanted))
858 (gnus-summary-remove-process-mark article))))
860 (defun gnus-summary-supersede-article ()
861 "Compose an article that will supersede a previous article.
862 This is done simply by taking the old article and adding a Supersedes
863 header line with the old Message-ID."
865 (let ((article (gnus-summary-article-number)))
866 (gnus-setup-message 'reply-yank
867 (gnus-summary-select-article t)
868 (set-buffer gnus-original-article-buffer)
872 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
874 (set-buffer ,gnus-summary-buffer)
875 (gnus-cache-possibly-remove-article ,article nil nil nil t)
876 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
877 message-send-actions))))
881 (defun gnus-copy-article-buffer (&optional article-buffer yank-string)
882 ;; make a copy of the article buffer with all text properties removed
883 ;; this copy is in the buffer gnus-article-copy.
884 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
885 ;; this buffer should be passed to all mail/news reply/post routines.
886 (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
888 (set-buffer gnus-article-copy)
889 (set-buffer-multibyte t))
890 (let ((article-buffer (or article-buffer gnus-article-buffer))
892 (if (not (and (get-buffer article-buffer)
893 (gnus-buffer-exists-p article-buffer)))
894 (error "Can't find any article buffer")
896 (set-buffer article-buffer)
897 (let ((gnus-newsgroup-charset (or gnus-article-charset
898 gnus-newsgroup-charset))
899 (gnus-newsgroup-ignored-charsets
900 (or gnus-article-ignored-charsets
901 gnus-newsgroup-ignored-charsets)))
903 ;; Copy over the (displayed) article buffer, delete
904 ;; hidden text and remove text properties.
906 (copy-to-buffer gnus-article-copy (point-min) (point-max))
907 (set-buffer gnus-article-copy)
908 ;; There's invisible and intangible text in T-gnus. Especially,
909 ;; if there is a boundary line (X-Boundary: ------------------),
910 ;; in the end of a header, it will cause a serious problem.
911 (add-text-properties (point-min) (point-max)
912 '(invisible nil intangible nil))
915 (delete-region (point) (point-max))
916 (insert yank-string))
917 ;; Encode bitmap smileys to ordinary text.
918 ;; Possibly, the original text might be restored.
919 (static-unless (featurep 'xemacs)
920 (when (featurep 'smiley-mule)
921 (smiley-encode-buffer)))
922 (gnus-article-delete-text-of-type 'annotation)
923 (gnus-remove-text-with-property 'gnus-prev)
924 (gnus-remove-text-with-property 'gnus-next)
925 (gnus-remove-text-with-property 'gnus-decoration)
928 (static-if (featurep 'xemacs)
929 ;; Revome smiley extents for (possibly) XEmacs 21.1.
931 (buffer-substring-no-properties (point-min)
933 (buffer-substring-no-properties (point-min) (point-max)))
935 ;; Find the original headers.
936 (set-buffer gnus-original-article-buffer)
937 (goto-char (point-min))
938 (while (looking-at message-unix-mail-delimiter)
940 (let ((mail-header-separator ""))
942 end (or (message-goto-body)
943 ;; There may be just a header.
945 ;; Delete the headers from the displayed articles.
946 (set-buffer gnus-article-copy)
947 (let ((mail-header-separator ""))
948 (delete-region (goto-char (point-min))
949 (or (message-goto-body) (point-max))))
950 ;; Insert the original article headers.
951 (insert-buffer-substring gnus-original-article-buffer beg end)
953 (let ((gnus-article-decode-hook
954 (delq 'article-decode-charset
955 (copy-sequence gnus-article-decode-hook))))
956 ;; Needed for T-gnus.
957 (add-hook 'gnus-article-decode-hook
958 'article-decode-encoded-words)
959 (run-hooks 'gnus-article-decode-hook)))))
962 (defun gnus-post-news (post &optional group header article-buffer yank subject
965 (gnus-copy-article-buffer))
966 (let ((gnus-article-reply (and article-buffer (gnus-summary-article-number)))
967 (gnus-article-yanked-articles yank)
968 (add-to-list gnus-add-to-list))
969 (gnus-setup-message (cond (yank 'reply-yank)
970 (article-buffer 'reply)
972 (let* ((group (or group gnus-newsgroup-name))
973 (charset (gnus-group-name-charset nil group))
975 to-address to-group mailing-list to-list
978 (setq to-address (gnus-parameter-to-address group)
979 to-group (gnus-group-find-parameter group 'to-group)
980 to-list (gnus-parameter-to-list group)
981 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
982 mailing-list (when gnus-mailing-list-groups
983 (string-match gnus-mailing-list-groups group))
984 group (gnus-group-name-decode (gnus-group-real-name group)
986 (if (or (and to-group
987 (gnus-news-group-p to-group))
990 (and (gnus-news-group-p
991 (or pgroup gnus-newsgroup-name)
992 (or header gnus-current-article))
1000 (and (not (gnus-virtual-group-p pgroup)) group)))
1001 (set-buffer gnus-article-copy)
1002 (gnus-msg-treat-broken-reply-to)
1003 (message-followup (if (or newsgroup-p force-news)
1004 (if (save-restriction
1005 (article-narrow-to-head)
1006 (message-fetch-field "newsgroups"))
1013 (message-mail (or to-address to-list))
1014 ;; Arrange for mail groups that have no `to-address' to
1015 ;; get that when the user sends off the mail.
1016 (when (and (not to-list)
1019 (push (list 'gnus-inews-add-to-address pgroup)
1020 message-send-actions)))
1021 (set-buffer gnus-article-copy)
1022 (gnus-msg-treat-broken-reply-to)
1023 (message-wide-reply to-address)))
1025 (gnus-inews-yank-articles yank))))))
1027 (defun gnus-msg-treat-broken-reply-to (&optional force)
1028 "Remove the Reply-to header if broken-reply-to."
1030 (gnus-group-find-parameter
1031 gnus-newsgroup-name 'broken-reply-to))
1033 (message-narrow-to-head)
1034 (message-remove-header "reply-to"))))
1036 (defun gnus-post-method (arg group &optional silent)
1037 "Return the posting method based on GROUP and ARG.
1038 If SILENT, don't prompt the user."
1039 (let ((gnus-post-method (or (gnus-parameter-post-method group)
1041 (group-method (gnus-find-method-for-group group)))
1043 ;; If the group-method is nil (which shouldn't happen) we use
1044 ;; the default method.
1045 ((null group-method)
1046 (or (and (listp gnus-post-method) ;If not current/native/nil
1047 (not (listp (car gnus-post-method))) ; and not a list of methods
1048 gnus-post-method) ;then use it.
1050 message-post-method))
1051 ;; We want the inverse of the default
1052 ((and arg (not (eq arg 0)))
1053 (if (eq gnus-post-method 'current)
1056 ;; We query the user for a post method.
1058 (and (listp gnus-post-method)
1059 (listp (car gnus-post-method))))
1061 ;; Collect all methods we know about.
1063 (when (listp gnus-post-method)
1064 (if (listp (car gnus-post-method))
1066 (list gnus-post-method)))
1067 gnus-secondary-select-methods
1068 (mapcar 'cdr gnus-server-alist)
1069 (mapcar 'car gnus-opened-servers)
1070 (list gnus-select-method)
1071 (list group-method)))
1072 method-alist post-methods method)
1073 ;; Weed out all mail methods.
1075 (setq method (gnus-server-get-method "" (pop methods)))
1076 (when (and (or (gnus-method-option-p method 'post)
1077 (gnus-method-option-p method 'post-mail))
1078 (not (member method post-methods)))
1079 (push method post-methods)))
1080 ;; Create a name-method alist.
1084 (if (equal (cadr m) "")
1085 (list (symbol-name (car m)) m)
1086 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m)))
1091 (setq gnus-last-posting-server
1093 gnus-last-posting-server)
1094 ;; Just use the last value.
1095 gnus-last-posting-server
1097 "Posting method: " method-alist nil t
1098 (cons (or gnus-last-posting-server "") 0))))
1100 ;; Override normal method.
1101 ((and (eq gnus-post-method 'current)
1102 (not (memq (car group-method) gnus-discouraged-post-methods))
1103 (gnus-get-function group-method 'request-post t))
1106 ;; Use gnus-post-method.
1107 ((listp gnus-post-method) ;A method...
1108 (assert (not (listp (car gnus-post-method)))) ;... not a list of methods.
1110 ;; Use the normal select method (nil or native).
1111 (t gnus-select-method))))
1114 (defun gnus-message-make-user-agent (&optional dummy max-column
1116 "Return a user-agent info. If MAX-COLUMN is specified, the return
1117 value will be folded up as it were filled. NEWLINE-PRODUCT specifies
1118 whether a newline should be inserted in front of each product-token;
1119 if the value is t or `hard', it works strictly. Otherwise, if it is
1120 non-nil (e.g. `soft'), it works semi-strictly."
1121 (let ((user-agent (gnus-extended-version)))
1123 (unless (natnump max-column)
1124 (setq max-column 76))
1126 (set-buffer-multibyte t)
1127 (insert (mapconcat 'identity (split-string user-agent) " "))
1128 (goto-char (point-min))
1130 start agent agents width element swidth)
1131 (while (re-search-forward "\\([^ ]+\\) ?" nil t)
1132 (setq start (match-beginning 0))
1133 (if (eq (char-after start) ?\()
1137 (push (buffer-substring start (point)) agent))
1139 (push (nreverse agent) agents))
1140 (setq agent (list (match-string 1)))))
1142 (push (nreverse agent) agents))
1143 (setq agents (nreverse agents))
1144 (if (> (+ 12 (string-width (caar agents))) max-column)
1145 (setq user-agent "\n"
1150 (setq agent (car agents)
1151 agents (cdr agents))
1152 (when (and (not bol)
1153 (or (memq newline-product '(t hard))
1154 (and newline-product
1156 (string-width (mapconcat 'identity
1159 (setq user-agent (concat user-agent "\n")
1163 (setq element (car agent)
1164 swidth (string-width element)
1167 (setq user-agent (if (member user-agent '("" "\n"))
1168 (concat user-agent element)
1169 (concat user-agent " " element))
1170 width (+ width 1 swidth)
1172 (if (> (+ width 1 swidth) max-column)
1173 (setq user-agent (concat user-agent "\n " element)
1175 (setq user-agent (concat user-agent " " element)
1176 width (+ width 1 swidth)))))))))
1181 ;;; Gnus Mail Functions
1184 ;;; Mail reply commands of Gnus summary mode
1186 (defun gnus-summary-reply (&optional yank wide very-wide)
1187 "Start composing a mail reply to the current message.
1188 If prefix argument YANK is non-nil, the original article is yanked
1190 If WIDE, make a wide reply.
1191 If VERY-WIDE, make a very wide reply."
1193 (list (and current-prefix-arg
1194 (gnus-summary-work-articles 1))))
1195 ;; Allow user to require confirmation before replying by mail to the
1196 ;; author of a news article (or mail message).
1198 (not (or (gnus-news-group-p gnus-newsgroup-name)
1199 gnus-confirm-treat-mail-like-news))
1200 (not (cond ((stringp gnus-confirm-mail-reply-to-news)
1201 (string-match gnus-confirm-mail-reply-to-news
1202 gnus-newsgroup-name))
1203 ((functionp gnus-confirm-mail-reply-to-news)
1204 (funcall gnus-confirm-mail-reply-to-news gnus-newsgroup-name))
1205 (t gnus-confirm-mail-reply-to-news)))
1206 (y-or-n-p "Really reply by mail to article author? "))
1208 (if (listp (car yank))
1211 (gnus-article-reply (or article (gnus-summary-article-number)))
1212 (gnus-article-yanked-articles yank)
1214 ;; Stripping headers should be specified with mail-yank-ignored-headers.
1216 (gnus-summary-goto-subject article))
1217 (gnus-setup-message (if yank 'reply-yank 'reply)
1219 (gnus-summary-select-article)
1220 (dolist (article very-wide)
1221 (gnus-summary-select-article nil nil nil article)
1223 (set-buffer (gnus-copy-article-buffer))
1224 (gnus-msg-treat-broken-reply-to)
1226 (message-narrow-to-head)
1227 (setq headers (concat headers (buffer-string)))))))
1228 (set-buffer (gnus-copy-article-buffer))
1229 (gnus-msg-treat-broken-reply-to gnus-msg-force-broken-reply-to)
1231 (message-narrow-to-head)
1235 (goto-char (point-max)))
1236 (message-reply nil wide)
1238 (gnus-inews-yank-articles yank))
1239 (gnus-summary-handle-replysign)))))
1241 (defun gnus-summary-handle-replysign ()
1242 "Check the various replysign variables and take action accordingly."
1243 (when nil;;(or gnus-message-replysign gnus-message-replyencrypt)
1244 (let (signed encrypted)
1246 (set-buffer gnus-article-buffer)
1247 (setq signed (memq 'signed gnus-article-wash-types))
1248 (setq encrypted (memq 'encrypted gnus-article-wash-types)))
1249 (cond ((and gnus-message-replyencrypt encrypted)
1250 (mml-secure-message mml-default-encrypt-method
1251 (if gnus-message-replysignencrypted
1254 ((and gnus-message-replysign signed)
1255 (mml-secure-message mml-default-sign-method 'sign))))))
1257 (defun gnus-summary-reply-with-original (n &optional wide)
1258 "Start composing a reply mail to the current message.
1259 The original article will be yanked."
1261 (gnus-summary-reply (gnus-summary-work-articles n) wide))
1263 (defun gnus-summary-reply-broken-reply-to (&optional yank wide very-wide)
1264 "Like `gnus-summary-reply' except removing reply-to field.
1265 If prefix argument YANK is non-nil, the original article is yanked
1267 If WIDE, make a wide reply.
1268 If VERY-WIDE, make a very wide reply."
1270 (list (and current-prefix-arg
1271 (gnus-summary-work-articles 1))))
1272 (let ((gnus-msg-force-broken-reply-to t))
1273 (gnus-summary-reply yank wide very-wide)))
1275 (defun gnus-summary-reply-broken-reply-to-with-original (n &optional wide)
1276 "Like `gnus-summary-reply-with-original' except removing reply-to field.
1277 The original article will be yanked."
1279 (gnus-summary-reply-broken-reply-to (gnus-summary-work-articles n) wide))
1281 (defun gnus-summary-wide-reply (&optional yank)
1282 "Start composing a wide reply mail to the current message.
1283 If prefix argument YANK is non-nil, the original article is yanked
1286 (list (and current-prefix-arg
1287 (gnus-summary-work-articles 1))))
1288 (gnus-summary-reply yank t))
1290 (defun gnus-summary-wide-reply-with-original (n)
1291 "Start composing a wide reply mail to the current message.
1292 The original article will be yanked.
1293 Uses the process/prefix convention."
1295 (gnus-summary-reply-with-original n t))
1297 (defun gnus-summary-very-wide-reply (&optional yank)
1298 "Start composing a very wide reply mail to the current message.
1299 If prefix argument YANK is non-nil, the original article is yanked
1302 (list (and current-prefix-arg
1303 (gnus-summary-work-articles 1))))
1304 (gnus-summary-reply yank t (gnus-summary-work-articles yank)))
1306 (defun gnus-summary-very-wide-reply-with-original (n)
1307 "Start composing a very wide reply mail to the current message.
1308 The original article will be yanked."
1311 (gnus-summary-work-articles n) t (gnus-summary-work-articles n)))
1313 (defun gnus-summary-mail-forward (&optional full-headers post)
1314 "Forward the current message(s) to another user.
1315 If process marks exist, forward all marked messages;
1316 If FULL-HEADERS (the prefix), include full headers when forwarding.
1318 Note that this function definition for T-gnus is totally different
1319 from the original Gnus."
1321 (if (cdr (gnus-summary-work-articles nil))
1322 ;; Process marks are given.
1323 (gnus-summary-digest-mail-forward nil post)
1324 ;; No process marks.
1325 (let* ((gnus-article-reply (gnus-summary-article-number))
1326 (gnus-article-yanked-articles (list gnus-article-reply))
1328 (message-included-forward-headers
1329 (if full-headers "" message-included-forward-headers)))
1330 (gnus-setup-message 'forward
1331 (gnus-summary-select-article)
1332 (setq charset default-mime-charset)
1333 (set-buffer gnus-original-article-buffer)
1334 (make-local-variable 'default-mime-charset)
1335 (setq default-mime-charset charset)
1336 (message-forward post)))))
1338 (defun gnus-summary-digest-mail-forward (&optional n post)
1339 "Digests and forwards all articles in this series.
1340 If N is a positive number, forward the N next articles.
1341 If N is a negative number, forward the N previous articles.
1342 If N is nil and any articles have been marked with the process mark,
1343 forward those articles instead.
1344 Optional POST will use news to forward instead of mail."
1346 (let* ((articles (gnus-summary-work-articles n))
1347 (gnus-article-yanked-articles (copy-sequence articles))
1348 (topics "Topics:\n")
1349 subject article frame)
1350 (when (car articles)
1351 (gnus-setup-message 'forward
1352 (gnus-summary-select-article)
1354 (setq articles (sort articles '<)
1355 subject "Digested Articles")
1356 (with-current-buffer gnus-original-article-buffer
1357 (setq subject (message-make-forward-subject))))
1359 (message-news nil subject)
1360 (message-mail nil subject))
1361 (when (and message-use-multi-frames (cdr articles))
1362 (setq frame (window-frame (get-buffer-window (current-buffer)))))
1364 (while (setq article (pop articles))
1365 (save-window-excursion
1366 (set-buffer gnus-summary-buffer)
1367 (gnus-summary-select-article nil nil nil article)
1368 (setq topics (concat topics " "
1369 (mail-header-subject gnus-current-headers)
1371 (gnus-summary-remove-process-mark article))
1373 (select-frame frame))
1374 (insert (mime-make-tag "message" "rfc822") "\n")
1375 (narrow-to-region (point) (point))
1376 (insert-buffer-substring gnus-original-article-buffer)
1378 (article-narrow-to-head)
1379 (message-remove-header message-included-forward-headers t nil t))
1380 (goto-char (point-max))
1386 (mime-edit-enclose-digest-region (point)(mark t))))))
1388 (defun gnus-summary-digest-post-forward (&optional n)
1389 "Digest and forwards all articles in this series to a newsgroup.
1390 If N is a positive number, forward the N next articles.
1391 If N is a negative number, forward the N previous articles.
1392 If N is nil and any articles have been marked with the process mark,
1393 forward those articles instead."
1395 (gnus-summary-digest-mail-forward n t))
1397 (defun gnus-summary-resend-message (address n)
1398 "Resend the current article to ADDRESS."
1400 (list (message-read-from-minibuffer
1401 "Resend message(s) to: "
1402 (when (and gnus-summary-resend-default-address
1403 (gnus-buffer-live-p gnus-original-article-buffer))
1404 ;; If some other article is currently selected, the
1405 ;; initial-contents is wrong. Whatever, it is just the
1406 ;; initial-contents.
1407 (with-current-buffer gnus-original-article-buffer
1408 (nnmail-fetch-field "to"))))
1409 current-prefix-arg))
1410 (dolist (article (gnus-summary-work-articles n))
1411 (gnus-summary-select-article nil nil nil article)
1413 (set-buffer gnus-original-article-buffer)
1414 (message-resend address))
1415 (gnus-summary-mark-article-as-forwarded article)))
1417 ;; From: Matthieu Moy <Matthieu.Moy@imag.fr>
1418 (defun gnus-summary-resend-message-edit ()
1419 "Resend an article that has already been sent.
1420 A new buffer will be created to allow the user to modify body and
1421 contents of the message, and then, everything will happen as when
1422 composing a new message."
1424 (let ((article (gnus-summary-article-number)))
1425 (gnus-setup-message 'reply-yank
1426 (gnus-summary-select-article t)
1427 (set-buffer gnus-original-article-buffer)
1428 (let ((cur (current-buffer))
1429 (to (message-fetch-field "to")))
1430 ;; Get a normal message buffer.
1431 (message-pop-to-buffer (message-buffer-name "Resend" to))
1432 (insert-buffer-substring cur)
1434 ;; T-gnus change: Use MIME-Edit to recompose a message.
1436 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
1437 (fset 'mime-edit-decode-single-part-in-buffer
1438 (lambda (&rest args)
1439 (if (let ((content-type (car args)))
1440 (and (eq 'message (mime-content-type-primary-type
1442 (eq 'rfc822 (mime-content-type-subtype
1444 (setcar (cdr args) 'not-decode-text))
1447 (mime-edit-again nil t)
1448 (fset 'mime-edit-decode-single-part-in-buffer ofn)))
1449 (message-narrow-to-head-1)
1450 (insert "From: " (message-make-from) "\n")
1451 (while (re-search-forward "^From:" nil t)
1453 (insert "Original-"))
1454 (message-remove-header "^>From[\t ]" t)
1456 ;; Gnus will generate a new one when sending.
1457 (message-remove-header "Message-ID")
1458 (message-remove-header message-ignored-resent-headers t)
1459 ;; Remove unwanted headers.
1460 (goto-char (point-max))
1461 (insert mail-header-separator)
1462 (goto-char (point-min))
1463 (when (re-search-forward "^To:\\|^Newsgroups:" nil 'move)
1467 (defun gnus-summary-post-forward (&optional full-headers)
1468 "Forward the current article to a newsgroup.
1469 If FULL-HEADERS (the prefix), include full headers when forwarding."
1471 (gnus-summary-mail-forward full-headers t))
1473 (defvar gnus-nastygram-message
1474 "The following article was inappropriately posted to %s.\n\n"
1475 "Format string to insert in nastygrams.
1476 The current group name will be inserted at \"%s\".")
1478 (defun gnus-summary-mail-nastygram (n)
1479 "Send a nastygram to the author of the current article."
1481 (when (or gnus-expert-user
1483 "Really send a nastygram to the author of the current article? "))
1484 (let ((group gnus-newsgroup-name))
1485 (gnus-summary-reply-with-original n)
1486 (set-buffer gnus-message-buffer)
1488 (insert (format gnus-nastygram-message group))
1489 (message-send-and-exit))))
1491 (defun gnus-summary-mail-crosspost-complaint (n)
1492 "Send a complaint about crossposting to the current article(s)."
1494 (dolist (article (gnus-summary-work-articles n))
1495 (set-buffer gnus-summary-buffer)
1496 (gnus-summary-goto-subject article)
1497 (let ((group (gnus-group-real-name gnus-newsgroup-name))
1498 newsgroups followup-to)
1499 (gnus-summary-select-article)
1500 (set-buffer gnus-original-article-buffer)
1501 (if (and (<= (length (message-tokenize-header
1503 (mail-fetch-field "newsgroups"))
1506 (or (not (setq followup-to (mail-fetch-field "followup-to")))
1507 (not (member group (message-tokenize-header
1508 followup-to ", ")))))
1510 (gnus-message 1 "Followup-to restricted")
1511 (gnus-message 1 "Not a crossposted article"))
1512 (set-buffer gnus-summary-buffer)
1513 (gnus-summary-reply-with-original 1)
1514 (set-buffer gnus-message-buffer)
1516 (insert (format gnus-crosspost-complaint newsgroups group))
1517 (message-goto-subject)
1518 (re-search-forward " *$")
1519 (replace-match " (crosspost notification)" t t)
1520 (gnus-deactivate-mark)
1521 (when (gnus-y-or-n-p "Send this complaint? ")
1522 (message-send-and-exit))))))
1524 (defun gnus-mail-parse-comma-list ()
1527 (skip-chars-forward " ")
1530 (skip-chars-forward "^,")
1535 (narrow-to-region beg (point))
1538 (while (search-forward "\"" nil t)
1542 (skip-chars-forward ",")
1543 (skip-chars-forward "^,"))
1544 (skip-chars-backward " ")
1545 (push (buffer-substring beg (point))
1547 (skip-chars-forward "^,")
1548 (skip-chars-forward ", "))
1551 (defun gnus-inews-add-to-address (group)
1552 (let ((to-address (mail-fetch-field "to")))
1553 (when (and to-address
1555 ;; This mail group doesn't have a `to-list', so we add one
1557 (when (gnus-y-or-n-p
1558 (format "Do you want to add this as `to-list': %s? " to-address))
1559 (gnus-group-add-parameter group (cons 'to-list to-address))))))
1561 (defun gnus-put-message ()
1562 "Put the current message in some group and return to Gnus."
1564 (let ((reply gnus-article-reply)
1565 (winconf gnus-prev-winconf)
1566 (group gnus-newsgroup-name))
1568 (not (gnus-group-read-only-p group)))
1569 (setq group (read-string "Put in group: " nil (gnus-writable-groups))))
1571 (when (gnus-group-entry group)
1572 (error "No such group: %s" group))
1576 (message-narrow-to-headers)
1577 (let ((gnus-deletable-headers nil))
1578 (message-generate-headers
1579 (if (message-news-p)
1580 message-required-news-headers
1581 message-required-mail-headers)))
1582 (goto-char (point-max))
1583 (if (string-match " " group)
1584 (insert "Gcc: \"" group "\"\n")
1585 (insert "Gcc: " group "\n"))
1588 (when (and (get-buffer gnus-group-buffer)
1589 (gnus-buffer-exists-p (car-safe reply))
1591 (set-buffer (car reply))
1592 (gnus-summary-mark-article-as-replied (cdr reply)))
1594 (set-window-configuration winconf))))
1596 (defun gnus-article-mail (yank)
1597 "Send a reply to the address near point.
1598 If YANK is non-nil, include the original article."
1602 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
1603 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
1605 (gnus-msg-mail address)
1607 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
1609 (defvar nntp-server-type)
1611 "Send a bug report to the Gnus maintainers."
1613 (unless (gnus-alive-p)
1614 (error "Gnus has been shut down"))
1615 (gnus-setup-message (if (message-mail-user-agent) 'message 'bug)
1616 (unless (message-mail-user-agent)
1617 (message-pop-to-buffer "*Gnus Bug*")
1618 (delete-other-windows)
1619 (when gnus-bug-create-help-buffer
1620 (switch-to-buffer "*Gnus Help Bug*")
1622 (insert gnus-bug-message)
1623 (goto-char (point-min))
1625 (set-buffer "*Gnus Bug*")))
1626 (let ((message-this-is-mail t))
1627 (message-setup `((To . ,gnus-maintainer) (Subject . ""))))
1628 (when gnus-bug-create-help-buffer
1629 (push `(gnus-bug-kill-buffer) message-send-actions))
1630 (goto-char (point-min))
1631 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
1633 (insert gnus-product-name " " gnus-version-number
1634 " (r" gnus-revision-number ") "
1635 "based on " gnus-original-product-name " v"
1636 gnus-original-version-number "\n"
1637 (emacs-version) "\n")
1638 (when (and (boundp 'nntp-server-type)
1639 (stringp nntp-server-type))
1640 (insert nntp-server-type))
1641 (insert "\n\n\n\n\n")
1642 (let (mime-content-types)
1643 (mime-edit-insert-tag
1644 "application" "emacs-lisp"
1645 "\nContent-Disposition: inline\nContent-Description: User settings"))
1646 (insert (with-temp-buffer
1649 (let (mime-content-types)
1650 (mime-edit-insert-tag "text" "plain"))
1651 (goto-char (point-min))
1652 (search-forward "Subject: " nil t)
1655 (defun gnus-bug-kill-buffer ()
1656 (when (get-buffer "*Gnus Help Bug*")
1657 (kill-buffer "*Gnus Help Bug*")))
1659 (defun gnus-summary-yank-message (buffer n)
1660 "Yank the current article into a composed message."
1662 (list (completing-read "Buffer: " (mapcar 'list (message-buffers)) nil t)
1663 current-prefix-arg))
1664 (when (gnus-buffer-live-p buffer)
1665 (let ((summary-frame (selected-frame))
1666 (message-frame (when (static-if (featurep 'xemacs)
1667 (device-on-window-system-p)
1669 (let ((window (get-buffer-window buffer t)))
1671 (window-frame window)))))
1672 (separator (concat "^" (regexp-quote mail-header-separator)
1674 (gnus-summary-iterate n
1675 (gnus-summary-select-article)
1676 (gnus-copy-article-buffer)
1677 (when (frame-live-p message-frame)
1678 (raise-frame message-frame)
1679 (select-frame message-frame))
1680 (with-current-buffer buffer
1681 (when (save-excursion
1683 (let (case-fold-search)
1684 (and (not (re-search-backward separator nil t))
1685 (re-search-forward separator nil t))))
1686 (goto-char (match-end 0)))
1687 (message-yank-buffer gnus-article-copy))
1688 (select-frame summary-frame))
1689 (when (frame-live-p message-frame)
1690 (select-frame message-frame)))))
1692 (defun gnus-debug ()
1693 "Attempts to go through the Gnus source file and report what variables have been changed.
1694 The source file has to be in the Emacs load path."
1696 (let ((files gnus-debug-files)
1698 file expr olist sym)
1699 (gnus-message 4 "Please wait while we snoop your variables...")
1700 ;; Go through all the files looking for non-default values for variables.
1703 (set-buffer (gnus-get-buffer-create " *gnus bug info*"))
1706 (when (and (setq file (locate-library (pop files)))
1707 (file-exists-p file))
1708 (insert-file-contents file)
1709 (goto-char (point-min))
1710 (if (not (re-search-forward "^;;* *Internal variables" nil t))
1711 (gnus-message 4 "Malformed sources in file %s" file)
1712 (narrow-to-region (point-min) (point))
1713 (goto-char (point-min))
1714 (while (setq expr (ignore-errors (read (current-buffer))))
1716 (and (memq (car expr) '(defvar defcustom defvoo))
1717 (stringp (nth 3 expr))
1718 (not (memq (nth 1 expr) gnus-debug-exclude-variables))
1719 (or (not (boundp (nth 1 expr)))
1720 (not (equal (eval (nth 2 expr))
1721 (symbol-value (nth 1 expr)))))
1722 (push (nth 1 expr) olist)))))))
1723 (kill-buffer (current-buffer)))
1724 (when (setq olist (nreverse olist))
1725 (insert ";----------------- Environment follows ------------------\n\n"))
1727 (if (boundp (car olist))
1731 ,(if (or (consp (setq sym (symbol-value (car olist))))
1733 (not (or (eq sym nil)
1735 (list 'quote (symbol-value (car olist)))
1736 (symbol-value (car olist))))))
1737 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
1738 (setq olist (cdr olist)))
1739 ;; Remove any control chars - they seem to cause trouble for some
1740 ;; mailers. (Byte-compiled output from the stuff above.)
1742 (while (re-search-forward (string-as-multibyte
1743 "[\000-\010\013-\037\200-\237]") nil t)
1744 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
1746 ;; Break MIME tags purposely.
1748 (while (re-search-forward mime-edit-tag-regexp nil t)
1749 (goto-char (1+ (match-beginning 0)))
1752 ;;; Treatment of rejected articles.
1755 (defun gnus-summary-resend-bounced-mail (&optional fetch)
1756 "Re-mail the current message.
1757 This only makes sense if the current message is a bounce message that
1758 contains some mail you have written which has been bounced back to
1760 If FETCH, try to fetch the article that this is a reply to, if indeed
1763 (gnus-summary-select-article t)
1764 (set-buffer gnus-original-article-buffer)
1765 (gnus-setup-message 'compose-bounce
1766 (let* ((references (mail-fetch-field "references"))
1767 (parent (and references (gnus-parent-id references))))
1769 ;; If there are references, we fetch the article we answered to.
1771 (gnus-summary-refer-article parent)
1772 (gnus-summary-show-all-headers)))))
1776 (defun gnus-inews-group-method (group)
1778 ;; If the group doesn't exist, we assume
1779 ;; it's an archive group...
1780 ((and (null (gnus-get-info group))
1781 (eq (car (gnus-server-to-method gnus-message-archive-method))
1782 (car (gnus-server-to-method (gnus-group-method group)))))
1783 gnus-message-archive-method)
1785 ((gnus-info-method (gnus-get-info group))
1786 (gnus-info-method (gnus-get-info group)))
1788 (t (gnus-server-to-method (gnus-group-method group)))))
1790 ;; Do Gcc handling, which copied the message over to some group.
1791 (defun gnus-inews-do-gcc (&optional gcc)
1795 (message-narrow-to-headers)
1796 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
1797 (coding-system-for-write 'raw-text)
1798 groups group method group-art
1799 mml-externalize-attachments)
1801 (message-remove-header "gcc")
1803 (setq groups (message-unquote-tokens
1804 (message-tokenize-header gcc " ,")))
1805 ;; Copy the article over to some group(s).
1806 (while (setq group (pop groups))
1807 (unless (gnus-check-server
1808 (setq method (gnus-inews-group-method group)))
1809 (error "Can't open server %s" (if (stringp method) method
1811 (unless (gnus-request-group group nil method)
1812 (gnus-request-create-group group method))
1813 (setq mml-externalize-attachments
1814 (if (stringp gnus-gcc-externalize-attachments)
1815 (string-match gnus-gcc-externalize-attachments group)
1816 gnus-gcc-externalize-attachments))
1818 (nnheader-set-temp-buffer " *acc*")
1819 (insert-buffer-substring message-encoding-buffer)
1820 (gnus-run-hooks 'gnus-before-do-gcc-hook)
1821 (goto-char (point-min))
1822 (when (re-search-forward
1823 (concat "^" (regexp-quote mail-header-separator) "$")
1825 (replace-match "" t t ))
1826 (when (or (not (gnus-check-backend-function
1827 'request-accept-article group))
1828 (not (setq group-art
1829 (gnus-request-accept-article
1830 group method t t))))
1831 (gnus-message 1 "Couldn't store article in group %s: %s"
1832 group (gnus-status-message method)))
1833 (when (and group-art
1834 ;; FIXME: Should gcc-mark-as-read work when
1835 ;; Gnus is not running?
1837 (or gnus-gcc-mark-as-read
1839 (boundp 'gnus-inews-mark-gcc-as-read)
1840 (symbol-value 'gnus-inews-mark-gcc-as-read))))
1841 (gnus-group-mark-article-read group (cdr group-art)))
1842 (kill-buffer (current-buffer)))))))))
1844 (defun gnus-inews-insert-gcc ()
1845 "Insert Gcc headers based on `gnus-outgoing-message-group'."
1848 (message-narrow-to-headers)
1849 (let* ((group gnus-outgoing-message-group)
1853 ((or (stringp group) (listp group))
1858 (if (string-match " " gcc)
1859 (concat "\"" gcc "\"")
1861 (mapconcat (lambda (group)
1862 (if (string-match " " group)
1863 (concat "\"" group "\"")
1868 (defun gnus-inews-insert-archive-gcc (&optional group)
1869 "Insert the Gcc to say where the article is to be archived."
1870 (let* ((var gnus-message-archive-group)
1871 (group (or group gnus-newsgroup-name ""))
1873 (and gnus-newsgroup-name
1874 (not (equal gnus-newsgroup-name ""))
1875 (gnus-group-find-parameter
1876 gnus-newsgroup-name 'gcc-self)))
1880 ((null gnus-message-archive-method)
1884 ;; Just a single group.
1887 ;; We don't want this.
1889 ((and (listp var) (stringp (car var)))
1890 ;; A list of groups.
1894 (funcall var group))
1896 ;; An alist of regexps/functions/forms.
1901 ((stringp (caar var))
1903 (when (string-match (caar var) group)
1905 ((functionp (car var))
1907 (funcall (car var) group))
1909 (eval (car var)))))))
1910 (setq var (cdr var)))
1913 (when (or groups gcc-self-val)
1914 (when (stringp groups)
1915 (setq groups (list groups)))
1918 (message-narrow-to-headers)
1919 (goto-char (point-max))
1922 ;; Use the `gcc-self' param value instead.
1925 (if (stringp gcc-self-val)
1926 (if (string-match " " gcc-self-val)
1927 (concat "\"" gcc-self-val "\"")
1929 ;; In nndoc groups, we use the parent group name
1930 ;; instead of the current group.
1931 (let ((group (or (gnus-group-find-parameter
1932 gnus-newsgroup-name 'parent-group)
1934 (if (string-match " " group)
1935 (concat "\"" group "\"")
1937 (if (not (eq gcc-self-val 'none))
1939 (gnus-delete-line)))
1940 ;; Use the list of groups.
1941 (while (setq name (pop groups))
1942 (let ((str (if (string-match ":" name)
1944 (gnus-group-prefixed-name
1945 name gnus-message-archive-method))))
1946 (insert (if (string-match " " str)
1947 (concat "\"" str "\"")
1953 (defun gnus-mailing-list-followup-to ()
1954 "Look at the headers in the current buffer and return a Mail-Followup-To address."
1955 (let ((x-been-there (gnus-fetch-original-field "x-beenthere"))
1956 (list-post (gnus-fetch-original-field "list-post")))
1957 (when (and list-post
1958 (string-match "mailto:\\([^>]+\\)" list-post))
1959 (setq list-post (match-string 1 list-post)))
1965 (defun gnus-configure-posting-styles (&optional group-name)
1966 "Configure posting styles according to `gnus-posting-styles'."
1967 (unless gnus-inhibit-posting-styles
1968 (let ((group (or group-name gnus-newsgroup-name ""))
1969 (styles gnus-posting-styles)
1970 style match attribute results
1972 ;; If the group has a posting-style parameter, add it at the end with a
1973 ;; regexp matching everything, to be sure it takes precedence over all
1975 (when gnus-newsgroup-name
1976 (let ((tmp-style (gnus-group-find-parameter group 'posting-style t)))
1978 (setq styles (append styles (list (cons ".*" tmp-style)))))))
1979 ;; Go through all styles and look for matches.
1980 (dolist (style styles)
1981 (setq match (pop style))
1982 (goto-char (point-min))
1985 ;; Regexp string match on the group name.
1986 (string-match match group))
1988 ;; Obsolete format of header match.
1989 (and (gnus-buffer-live-p gnus-article-copy)
1990 (with-current-buffer gnus-article-copy
1992 (nnheader-narrow-to-headers)
1993 (let ((header (message-fetch-field (pop style))))
1995 (string-match (pop style) header)))))))
1996 ((or (symbolp match)
2000 ;; Function to be called.
2003 ;; Variable to be checked.
2004 (symbol-value match))))
2007 ((eq (car match) 'header)
2008 ;; New format of header match.
2009 (and (gnus-buffer-live-p gnus-article-copy)
2010 (with-current-buffer gnus-article-copy
2012 (nnheader-narrow-to-headers)
2013 (let ((header (message-fetch-field (nth 1 match))))
2015 (string-match (nth 2 match) header)))))))
2017 ;; This is a form to be evaled.
2019 ;; We have a match, so we set the variables.
2020 (setq style (gnus-configure-posting-style style nil))
2021 (dolist (attribute style)
2022 (setq results (delq (assoc (car attribute) results) results))
2023 (push attribute results))))
2024 ;; Now we have all the styles, so we insert them.
2025 (setq name (assq 'name results)
2026 address (assq 'address results))
2027 (setq results (delq name (delq address results)))
2028 (gnus-make-local-hook 'message-setup-hook)
2029 (setq results (sort results (lambda (x y)
2030 (string-lessp (car x) (car y)))))
2031 (dolist (result results)
2032 (add-hook 'message-setup-hook
2034 ((eq 'eval (car result))
2036 ((eq 'body (car result))
2040 (insert ,(cdr result)))))
2041 ((eq 'signature (car result))
2042 (set (make-local-variable 'message-signature) nil)
2043 (set (make-local-variable 'message-signature-file) nil)
2044 (if (not (cdr result))
2048 (let ((message-signature ,(cdr result)))
2049 (when message-signature
2050 (message-insert-signature)))))))
2053 (if (symbolp (car result))
2054 (capitalize (symbol-name (car result)))
2058 (message-remove-header ,header)
2059 (let ((value ,(cdr result)))
2062 (insert ,header ": " value)
2064 (insert "\n")))))))))
2066 (when (or name address)
2067 (add-hook 'message-setup-hook
2069 (set (make-local-variable 'user-mail-address)
2070 ,(or (cdr address) user-mail-address))
2071 (let ((user-full-name ,(or (cdr name) (user-full-name)))
2073 ,(or (cdr address) user-mail-address)))
2075 (message-remove-header "From")
2077 (insert "From: " (message-make-from) "\n"))))
2080 ;; splitted from gnus-configure-posting-styles to allow recursive traversal.
2081 (defun gnus-configure-posting-style (style stack)
2082 "Parse one posting style STYLE and returns the value as an alist."
2083 (let (results element variable filep value v)
2084 (dolist (attribute style)
2085 (setq element (pop attribute)
2090 ((eq (car attribute) ':file)
2093 ((eq (car attribute) :value)
2097 ;; We get the value.
2102 ((or (symbolp value)
2104 (cond ((functionp value)
2107 (symbol-value value))))
2110 ;; Translate obsolescent value.
2112 ((eq element 'signature-file)
2113 (setq element 'signature
2115 ((eq element 'x-face-file)
2116 (setq element 'x-face
2118 ;; Get the contents of file elems.
2120 (setq v (with-temp-buffer
2121 (insert-file-contents v)
2122 (buffer-substring (point-min)
2124 (goto-char (point-max))
2125 (if (zerop (skip-chars-backward "\n"))
2128 (if (eq element 'import)
2130 (if (member v stack)
2131 (error "Circular import of \"%s\"" v))
2133 (nconc (nreverse (gnus-configure-posting-style
2134 (cdr (assoc v gnus-named-posting-styles))
2137 (push (cons element v) results)))
2138 (nreverse results)))
2140 (defun gnus-summary-execute-command-with-posting-style (style command)
2141 "Temporarily select a posting-style named STYLE and execute COMMAND."
2143 (let ((style (completing-read "Posting style: "
2144 gnus-named-posting-styles nil t)))
2148 (format "Command to execute with %s: " style))))))
2149 (let ((gnus-posting-styles (list (list ".*" (list 'import style)))))
2150 (call-interactively command)))
2153 ;;; @ for MIME Edit mode
2156 (defun gnus-maybe-setup-default-charset ()
2158 (and (boundp 'gnus-summary-buffer)
2159 (buffer-live-p gnus-summary-buffer)
2161 (set-buffer gnus-summary-buffer)
2162 default-mime-charset))))
2165 (make-local-variable 'default-mime-charset)
2166 (setq default-mime-charset charset)
2170 ;;; @ for MIME view mode
2173 (defun gnus-following-method (buf)
2174 (gnus-setup-message 'reply-yank
2176 (if (message-news-p)
2178 (message-reply nil 'wide))
2179 (let ((message-reply-buffer buf))
2180 (message-yank-original))
2181 (message-goto-body))
2185 ;;; Allow redefinition of functions.
2191 ;;; gnus-msg.el ends here