1 ;;; gnus-msg.el --- mail and post interface for Semi-gnus
2 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 ;; Free Software Foundation, Inc.
5 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
6 ;; Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
8 ;; Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp>
9 ;; Katsumi Yamaoka <yamaoka@jpl.org>
10 ;; Kiyokazu SUTO <suto@merry.xmath.ous.ac.jp>
11 ;; Keywords: mail, news, MIME
13 ;; This file is part of GNU Emacs.
15 ;; GNU Emacs is free software; you can redistribute it and/or modify
16 ;; it under the terms of the GNU General Public License as published by
17 ;; the Free Software Foundation; either version 2, or (at your option)
20 ;; GNU Emacs is distributed in the hope that it will be useful,
21 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 ;; GNU General Public License for more details.
25 ;; You should have received a copy of the GNU General Public License
26 ;; along with GNU Emacs; see the file COPYING. If not, write to the
27 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
28 ;; Boston, MA 02111-1307, USA.
34 (eval-when-compile (require 'cl))
35 (eval-when-compile (require 'static))
42 (defcustom gnus-post-method 'current
43 "*Preferred method for posting USENET news.
45 If this variable is `current' (which is the default), Gnus will use
46 the \"current\" select method when posting. If it is `native', Gnus
47 will use the native select method when posting.
49 This method will not be used in mail groups and the like, only in
52 If not `native' nor `current', the value must be a valid method as discussed
53 in the documentation of `gnus-select-method'. It can also be a list of
54 methods. If that is the case, the user will be queried for what select
55 method to use when posting."
56 :group 'gnus-group-foreign
57 :link '(custom-manual "(gnus)Posting Server")
58 :type `(choice (const native)
60 (sexp :tag "Methods" ,gnus-select-method)))
62 (defcustom gnus-outgoing-message-group nil
63 "*All outgoing messages will be put in this group.
64 If you want to store all your outgoing mail and articles in the group
65 \"nnml:archive\", you set this variable to that value. This variable
66 can also be a list of group names.
68 If you want to have greater control over what group to put each
69 message in, you can set this variable to a function that checks the
70 current newsgroup name and then returns a suitable group name (or list
73 :type '(choice (string :tag "Group")
76 (defcustom gnus-mailing-list-groups nil
77 "*Regexp matching groups that are really mailing lists.
78 This is useful when you're reading a mailing list that has been
79 gatewayed to a newsgroup, and you want to followup to an article in
84 (defcustom gnus-add-to-list nil
85 "*If non-nil, add a `to-list' parameter automatically."
89 (defcustom gnus-crosspost-complaint
92 You posted the article below with the following Newsgroups header:
96 The %s group, at least, was an inappropriate recipient
97 of this message. Please trim your Newsgroups header to exclude this
98 group before posting in the future.
103 "Format string to be inserted when complaining about crossposts.
104 The first %s will be replaced by the Newsgroups header;
105 the second with the current group name."
109 (defcustom gnus-message-setup-hook nil
110 "Hook run after setting up a message buffer."
114 (defcustom gnus-bug-create-help-buffer t
115 "*Should we create the *Gnus Help Bug* buffer?"
119 (defcustom gnus-posting-styles nil
120 "*Alist of styles to use when posting.
121 See Info node `(gnus)Posting Styles'."
123 :link '(custom-manual "(gnus)Posting Styles")
124 :type '(repeat (cons (choice (regexp)
127 (string :tag "Header")
128 (regexp :tag "Regexp"))
132 (choice (const signature)
133 (const signature-file)
141 (string :tag "Header"))
147 (defcustom gnus-named-posting-styles nil
148 "Alist mapping names to the user-defined posting styles."
150 :type '(repeat (cons string
152 (choice (const signature)
153 (const signature-file)
161 (string :tag "Header"))
167 (defcustom gnus-gcc-mark-as-read nil
168 "If non-nil, automatically mark Gcc articles as read."
173 (defvar gnus-inews-mark-gcc-as-read nil
174 "Obsolete variable. Use `gnus-gcc-mark-as-read' instead.")
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 replys to signed messages.
265 See also the `mml-default-sign-method' variable."
269 (defcustom gnus-message-replyencrypt
271 "Automatically encrypt replys to encrypted messages.
272 See also the `mml-default-encrypt-method' variable."
276 (defcustom gnus-message-replysignencrypted
278 "Setting this causes automatically encryped messages to also be signed."
282 (defcustom gnus-confirm-mail-reply-to-news nil
283 "If non-nil, Gnus requests confirmation when replying to news.
284 This is done because new users often reply by mistake when reading
289 (defcustom gnus-summary-resend-default-address t
290 "If non-nil, Gnus tries to suggest a default address to resend to.
291 If nil, the address field will always be empty after invoking
292 `gnus-summary-resend-message'."
296 ;;; Internal variables.
298 (defvar gnus-inhibit-posting-styles nil
299 "Inhibit the use of posting styles.")
301 (defvar gnus-article-yanked-articles nil)
302 (defvar gnus-message-buffer "*Mail Gnus*")
303 (defvar gnus-article-copy nil)
304 (defvar gnus-check-before-posting nil)
305 (defvar gnus-last-posting-server nil)
306 (defvar gnus-message-group-art nil)
308 (defvar gnus-msg-force-broken-reply-to nil)
310 (defconst gnus-bug-message
311 (format "Sending a bug report to the Gnus Towers.
312 ========================================
314 This gnus is the %s%s.
315 If you think the bug is a Semi-gnus bug, send a bug report to Semi-gnus
316 Developers. (the addresses below are mailing list addresses)
318 ========================================
320 The buffer below is a mail buffer. When you press `C-c C-c', it will
321 be sent to the Gnus Bug Exterminators.
323 The thing near the bottom of the buffer is how the environment
324 settings will be included in the mail. Please do not delete that.
325 They will tell the Bug People what your environment is, so that it
326 will be easier to locate the bugs.
328 If you have found a bug that makes Emacs go \"beep\", set
329 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
330 and include the backtrace in your bug report.
332 Please describe the bug in annoying, painstaking detail.
334 Thank you for your help in stamping out bugs.
337 (if (string= gnus-product-name "Semi-gnus")
339 ", a modified version of Semi-gnus")))
342 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
343 (autoload 'news-setup "rnewspost")
344 (autoload 'news-reply-mode "rnewspost")
345 (autoload 'rmail-dont-reply-to "mail-utils")
346 (autoload 'rmail-output "rmailout"))
350 ;;; Gnus Posting Functions
353 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
354 "p" gnus-summary-post-news
355 "i" gnus-summary-news-other-window
356 "f" gnus-summary-followup
357 "F" gnus-summary-followup-with-original
358 "c" gnus-summary-cancel-article
359 "s" gnus-summary-supersede-article
360 "r" gnus-summary-reply
361 "y" gnus-summary-yank-message
362 "R" gnus-summary-reply-with-original
363 "w" gnus-summary-wide-reply
364 "W" gnus-summary-wide-reply-with-original
365 "v" gnus-summary-very-wide-reply
366 "V" gnus-summary-very-wide-reply-with-original
367 "n" gnus-summary-followup-to-mail
368 "N" gnus-summary-followup-to-mail-with-original
369 "m" gnus-summary-mail-other-window
370 "u" gnus-uu-post-news
371 "\M-c" gnus-summary-mail-crosspost-complaint
372 "Br" gnus-summary-reply-broken-reply-to
373 "BR" gnus-summary-reply-broken-reply-to-with-original
374 "om" gnus-summary-mail-forward
375 "op" gnus-summary-post-forward
376 "Om" gnus-summary-digest-mail-forward
377 "Op" gnus-summary-digest-post-forward
378 "P" gnus-summary-execute-command-with-posting-style)
380 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
381 "b" gnus-summary-resend-bounced-mail
382 ;; "c" gnus-summary-send-draft
383 "r" gnus-summary-resend-message
384 "e" gnus-summary-resend-message-edit)
386 ;;; Internal functions.
388 (defun gnus-inews-make-draft ()
390 (gnus-inews-make-draft-meta-information
391 ,gnus-newsgroup-name ,gnus-article-reply)))
393 (defvar gnus-article-reply nil)
394 (defmacro gnus-setup-message (config &rest forms)
395 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
396 (buffer (make-symbol "gnus-setup-message-buffer"))
397 (article (make-symbol "gnus-setup-message-article"))
398 (yanked (make-symbol "gnus-setup-yanked-articles"))
399 (group (make-symbol "gnus-setup-message-group")))
400 `(let ((,winconf (current-window-configuration))
401 (,buffer (buffer-name (current-buffer)))
402 (,article gnus-article-reply)
403 (,yanked gnus-article-yanked-articles)
404 (,group gnus-newsgroup-name)
405 (message-header-setup-hook
406 (copy-sequence message-header-setup-hook))
407 (message-mode-hook (copy-sequence message-mode-hook))
408 (message-startup-parameter-alist
409 '((reply-buffer . gnus-copy-article-buffer)
410 (original-buffer . gnus-original-article-buffer)
411 (user-agent . Gnus))))
412 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
413 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
414 ;; #### FIXME: for a reason that I did not manage to identify yet,
415 ;; the variable `gnus-newsgroup-name' does not honor a dynamically
416 ;; scoped or setq'ed value from a caller like `C-u gnus-summary-mail'.
417 ;; After evaluation of @forms below, it gets the value we actually want
418 ;; to override, and the posting styles are used. For that reason, I've
419 ;; added an optional argument to `gnus-configure-posting-styles' to
420 ;; make sure that the correct value for the group name is used. -- drv
421 (add-hook 'message-mode-hook
423 (gnus-configure-posting-styles ,group)))
424 (gnus-pull ',(intern gnus-draft-meta-information-header)
425 message-required-headers)
427 (not (string= ,group "")))
429 (intern gnus-draft-meta-information-header)
430 (gnus-inews-make-draft))
431 message-required-headers))
435 (gnus-inews-add-send-actions ,winconf ,buffer ,article ,config
437 (setq gnus-message-buffer (current-buffer))
438 (set (make-local-variable 'gnus-message-group-art)
439 (cons ,group ,article))
440 (set (make-local-variable 'gnus-newsgroup-name) ,group)
441 (gnus-maybe-setup-default-charset)
442 (gnus-run-hooks 'gnus-message-setup-hook))
444 (gnus-configure-windows ,config t)
445 (run-hooks 'post-command-hook)
446 (set-buffer-modified-p nil))))
448 (defun gnus-inews-make-draft-meta-information (group article)
449 (concat "(\"" group "\" "
450 (if article (number-to-string
457 (defun gnus-msg-mail (&optional to subject other-headers continue
458 switch-action yank-action send-actions)
459 "Start editing a mail message to be sent.
460 Like `message-mail', but with Gnus paraphernalia, particularly the
461 Gcc: header for archiving purposes."
463 (let ((buf (current-buffer))
465 (gnus-setup-message 'message
466 (message-mail to subject other-headers continue
467 nil yank-action send-actions))
469 (setq mail-buf (current-buffer))
470 (switch-to-buffer buf)
471 (apply switch-action mail-buf nil)))
472 ;; COMPOSEFUNC should return t if succeed. Undocumented ???
475 (defvar save-selected-window-window)
478 (defun gnus-button-mailto (address)
480 (set-buffer (gnus-copy-article-buffer))
481 (gnus-setup-message 'message
482 (message-reply address))
483 (and (boundp 'save-selected-window-window)
484 (not (window-live-p save-selected-window-window))
485 (setq save-selected-window-window (selected-window))))
488 (defun gnus-button-reply (&optional to-address wide)
489 "Like `message-reply'."
491 (gnus-setup-message 'message
492 (message-reply to-address wide))
493 (and (boundp 'save-selected-window-window)
494 (not (window-live-p save-selected-window-window))
495 (setq save-selected-window-window (selected-window))))
498 (define-mail-user-agent 'gnus-user-agent
499 'gnus-msg-mail 'message-send-and-exit
500 'message-kill-buffer 'message-send-hook)
502 (defun gnus-setup-posting-charset (group)
503 (let ((alist gnus-group-posting-charset-alist)
504 (group (or group ""))
508 (while (setq elem (pop alist))
509 (when (or (and (stringp (car elem))
510 (string-match (car elem) group))
511 (and (gnus-functionp (car elem))
512 (funcall (car elem) group))
513 (and (symbolp (car elem))
514 (symbol-value (car elem))))
515 (throw 'found (cons (cadr elem) (caddr elem)))))))))
517 (defun gnus-inews-add-send-actions (winconf buffer article
518 &optional config yanked)
519 (make-local-hook 'message-sent-hook)
520 (add-hook 'message-sent-hook (if gnus-agent 'gnus-agent-possibly-do-gcc
521 'gnus-inews-do-gcc) nil t)
523 (make-local-hook 'message-header-hook)
524 (add-hook 'message-header-hook 'gnus-agent-possibly-save-gcc nil t))
525 (setq message-post-method
527 (gnus-post-method arg ,gnus-newsgroup-name)))
528 (setq message-user-agent (gnus-extended-version))
529 (when (not message-use-multi-frames)
531 `(set-window-configuration ,winconf) 'exit 'postpone 'kill))
533 `(when (gnus-buffer-exists-p ,buffer)
537 (if (eq config 'forward)
538 `(gnus-summary-mark-article-as-forwarded ',yanked)
539 `(gnus-summary-mark-article-as-replied ',yanked)))))
542 (put 'gnus-setup-message 'lisp-indent-function 1)
543 (put 'gnus-setup-message 'edebug-form-spec '(form body))
545 ;;; Post news commands of Gnus group mode and summary mode
547 (defun gnus-group-mail (&optional arg)
548 "Start composing a mail.
549 If ARG, use the group under the point to find a posting style.
550 If ARG is 1, prompt for a group name to find the posting style."
552 ;; We can't `let' gnus-newsgroup-name here, since that leads
553 ;; to local variables leaking.
554 (let ((group gnus-newsgroup-name)
555 ;; make sure last viewed article doesn't affect posting styles:
557 (buffer (current-buffer)))
560 (setq gnus-newsgroup-name
562 (if (= 1 (prefix-numeric-value arg))
563 (completing-read "Use posting style of group: "
564 gnus-active-hashtb nil
565 (gnus-read-active-file-p))
566 (gnus-group-group-name))
568 ;; #### see comment in gnus-setup-message -- drv
569 (gnus-setup-message 'message (message-mail)))
572 (setq gnus-newsgroup-name group)))))
574 (defun gnus-group-news (&optional arg)
575 "Start composing a news.
576 If ARG, post to group under point.
577 If ARG is 1, prompt for group name to post to.
579 This function prepares a news even when using mail groups. This is useful
580 for posting messages to mail groups without actually sending them over the
581 network. The corresponding backend must have a 'request-post method."
583 ;; We can't `let' gnus-newsgroup-name here, since that leads
584 ;; to local variables leaking.
585 (let ((group gnus-newsgroup-name)
586 ;; make sure last viewed article doesn't affect posting styles:
588 (buffer (current-buffer)))
591 (setq gnus-newsgroup-name
593 (if (= 1 (prefix-numeric-value arg))
594 (completing-read "Use group: "
595 gnus-active-hashtb nil
596 (gnus-read-active-file-p))
597 (gnus-group-group-name))
599 ;; #### see comment in gnus-setup-message -- drv
600 (gnus-setup-message 'message
601 (message-news (gnus-group-real-name gnus-newsgroup-name))))
604 (setq gnus-newsgroup-name group)))))
606 (defun gnus-group-post-news (&optional arg)
607 "Start composing a message (a news by default).
608 If ARG, post to group under point. If ARG is 1, prompt for group name.
609 Depending on the selected group, the message might be either a mail or
612 ;; Bind this variable here to make message mode hooks work ok.
613 (let ((gnus-newsgroup-name
615 (if (= 1 (prefix-numeric-value arg))
616 (completing-read "Newsgroup: " gnus-active-hashtb nil
617 (gnus-read-active-file-p))
618 (gnus-group-group-name))
620 ;; make sure last viewed article doesn't affect posting styles:
622 (gnus-post-news 'post gnus-newsgroup-name)))
624 (defun gnus-summary-mail-other-window (&optional arg)
625 "Start composing a mail in another window.
626 Use the posting of the current group by default.
627 If ARG, don't do that. If ARG is 1, prompt for group name to find the
630 ;; We can't `let' gnus-newsgroup-name here, since that leads
631 ;; to local variables leaking.
632 (let ((group gnus-newsgroup-name)
633 ;; make sure last viewed article doesn't affect posting styles:
635 (buffer (current-buffer)))
638 (setq gnus-newsgroup-name
640 (if (= 1 (prefix-numeric-value arg))
641 (completing-read "Use group: "
642 gnus-active-hashtb nil
643 (gnus-read-active-file-p))
645 gnus-newsgroup-name))
646 ;; #### see comment in gnus-setup-message -- drv
647 (gnus-setup-message 'message (message-mail)))
650 (setq gnus-newsgroup-name group)))))
652 (defun gnus-summary-news-other-window (&optional arg)
653 "Start composing a news in another window.
654 Post to the current group by default.
655 If ARG, don't do that. If ARG is 1, prompt for group name to post to.
657 This function prepares a news even when using mail groups. This is useful
658 for posting messages to mail groups without actually sending them over the
659 network. The corresponding backend must have a 'request-post method."
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
679 (message-news (gnus-group-real-name gnus-newsgroup-name))))
682 (setq gnus-newsgroup-name group)))))
684 (defun gnus-summary-post-news (&optional arg)
685 "Start composing a message. Post to the current group by default.
686 If ARG, don't do that. If ARG is 1, prompt for a group name to post to.
687 Depending on the selected group, the message might be either a mail or
690 ;; Bind this variable here to make message mode hooks work ok.
691 (let ((gnus-newsgroup-name
693 (if (= 1 (prefix-numeric-value arg))
694 (completing-read "Newsgroup: " gnus-active-hashtb nil
695 (gnus-read-active-file-p))
697 gnus-newsgroup-name))
698 ;; make sure last viewed article doesn't affect posting styles:
700 (gnus-post-news 'post gnus-newsgroup-name)))
703 (defun gnus-summary-followup (yank &optional force-news)
704 "Compose a followup to an article.
705 If prefix argument YANK is non-nil, the original article is yanked
707 YANK is a list of elements, where the car of each element is the
708 article number, and the two following numbers is the region to be
711 (list (and current-prefix-arg
712 (gnus-summary-work-articles 1))))
714 (gnus-summary-goto-subject
715 (if (listp (car yank))
718 (save-window-excursion
719 (gnus-summary-select-article))
720 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
721 (gnus-newsgroup-name gnus-newsgroup-name))
723 (gnus-post-news nil gnus-newsgroup-name
724 headers gnus-article-buffer
726 (gnus-summary-handle-replysign)))
728 (defun gnus-summary-followup-with-original (n &optional force-news)
729 "Compose a followup to an article and include the original article."
731 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
733 (defun gnus-summary-followup-to-mail (&optional arg)
734 "Followup to the current mail message via news."
736 (list (and current-prefix-arg
737 (gnus-summary-work-articles 1))))
738 (gnus-summary-followup arg t))
740 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
741 "Followup to the current mail message via news."
743 (gnus-summary-followup (gnus-summary-work-articles arg) t))
745 (defun gnus-inews-yank-articles (articles)
746 (let (beg article yank-string
747 (more-than-one (cdr articles))
748 (cur (current-buffer))
751 (while (setq article (pop articles))
752 (when (listp article)
753 (setq yank-string (nth 1 article)
754 article (nth 0 article)))
755 (save-window-excursion
756 (set-buffer gnus-summary-buffer)
757 (gnus-summary-select-article nil nil nil article)
758 (gnus-summary-remove-process-mark article))
760 ;; Gathering references.
762 (setq refs (message-list-references
764 (mail-header-references gnus-current-headers)
765 (mail-header-message-id gnus-current-headers)))
766 (when message-use-multi-frames
767 (when (setq window (get-buffer-window cur t))
768 (select-frame (window-frame window)))))
770 (gnus-copy-article-buffer nil yank-string)
771 (let ((message-reply-buffer gnus-article-copy)
772 (message-reply-headers
773 ;; The headers are decoded.
774 (with-current-buffer gnus-article-copy
776 (nnheader-narrow-to-headers)
777 (nnheader-parse-naked-head)))))
778 (message-yank-original)
779 (setq beg (or beg (mark t))))
784 ;; Replace with the gathered references.
788 (message-narrow-to-headers)
789 (let ((case-fold-search t))
790 (if (re-search-forward "^References:\\([\t ]+.+\n\\)+" nil t)
792 (goto-char (point-max))))
794 (list (or (assq 'References message-header-format-alist)
795 '(References . message-shorten-references)))
796 (list (cons 'References
797 (mapconcat 'identity (nreverse refs) " "))))
798 (backward-delete-char 1))
804 (defun gnus-summary-cancel-article (&optional n symp)
805 "Cancel an article you posted.
806 Uses the process-prefix convention. If given the symbolic
807 prefix `a', cancel using the standard posting method; if not
808 post using the current select method."
809 (interactive (gnus-interactive "P\ny"))
810 (let ((articles (gnus-summary-work-articles n))
813 (gnus-post-method (eq ',symp 'a) ,gnus-newsgroup-name)))
815 (while (setq article (pop articles))
816 (when (gnus-summary-select-article t nil nil article)
817 (when (gnus-eval-in-buffer-window gnus-article-buffer
819 (set-buffer gnus-original-article-buffer)
820 (message-cancel-news)))
821 (gnus-summary-mark-as-read article gnus-canceled-mark)
822 (gnus-cache-remove-article 1))
823 (gnus-article-hide-headers-if-wanted))
824 (gnus-summary-remove-process-mark article))))
826 (defun gnus-summary-supersede-article ()
827 "Compose an article that will supersede a previous article.
828 This is done simply by taking the old article and adding a Supersedes
829 header line with the old Message-ID."
831 (let ((article (gnus-summary-article-number)))
832 (gnus-setup-message 'reply-yank
833 (gnus-summary-select-article t)
834 (set-buffer gnus-original-article-buffer)
838 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
840 (set-buffer ,gnus-summary-buffer)
841 (gnus-cache-possibly-remove-article ,article nil nil nil t)
842 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
843 message-send-actions))))
847 (defun gnus-copy-article-buffer (&optional article-buffer yank-string)
848 ;; make a copy of the article buffer with all text properties removed
849 ;; this copy is in the buffer gnus-article-copy.
850 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
851 ;; this buffer should be passed to all mail/news reply/post routines.
852 (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
854 (set-buffer gnus-article-copy)
855 (set-buffer-multibyte t))
856 (let ((article-buffer (or article-buffer gnus-article-buffer))
858 (if (not (and (get-buffer article-buffer)
859 (gnus-buffer-exists-p article-buffer)))
860 (error "Can't find any article buffer")
862 (set-buffer article-buffer)
863 (let ((gnus-newsgroup-charset (or gnus-article-charset
864 gnus-newsgroup-charset))
865 (gnus-newsgroup-ignored-charsets
866 (or gnus-article-ignored-charsets
867 gnus-newsgroup-ignored-charsets)))
869 ;; Copy over the (displayed) article buffer, delete
870 ;; hidden text and remove text properties.
872 (copy-to-buffer gnus-article-copy (point-min) (point-max))
873 (set-buffer gnus-article-copy)
874 ;; There's invisible and intangible text in T-gnus. Especially,
875 ;; if there is a boundary line (X-Boundary: ------------------),
876 ;; in the end of a header, it will cause a serious problem.
877 (add-text-properties (point-min) (point-max)
878 '(invisible nil intangible nil))
881 (delete-region (point) (point-max))
882 (insert yank-string))
883 ;; Encode bitmap smileys to ordinary text.
884 ;; Possibly, the original text might be restored.
885 (static-unless (featurep 'xemacs)
886 (when (featurep 'smiley-mule)
887 (smiley-encode-buffer)))
888 (gnus-article-delete-text-of-type 'annotation)
889 (gnus-remove-text-with-property 'gnus-prev)
890 (gnus-remove-text-with-property 'gnus-next)
891 (gnus-remove-text-with-property 'gnus-decoration)
892 (gnus-remove-text-with-property 'x-face-mule-bitmap-image)
895 (static-if (featurep 'xemacs)
896 ;; Revome smiley extents for (possibly) XEmacs 21.1.
898 (buffer-substring-no-properties (point-min)
900 (buffer-substring-no-properties (point-min) (point-max)))
902 ;; Find the original headers.
903 (set-buffer gnus-original-article-buffer)
904 (goto-char (point-min))
905 (while (looking-at message-unix-mail-delimiter)
907 (let ((mail-header-separator ""))
909 end (or (message-goto-body) beg)))
910 ;; Delete the headers from the displayed articles.
911 (set-buffer gnus-article-copy)
912 (let ((mail-header-separator ""))
913 (delete-region (goto-char (point-min))
914 (or (message-goto-body) (point-max))))
915 ;; Insert the original article headers.
916 (insert-buffer-substring gnus-original-article-buffer beg end)
918 (let ((gnus-article-decode-hook
919 (delq 'article-decode-charset
920 (copy-sequence gnus-article-decode-hook))))
921 ;; Needed for T-gnus.
922 (add-hook 'gnus-article-decode-hook
923 'article-decode-encoded-words)
924 (run-hooks 'gnus-article-decode-hook)))))
927 (defun gnus-post-news (post &optional group header article-buffer yank subject
930 (gnus-copy-article-buffer))
931 (let ((gnus-article-reply (and article-buffer (gnus-summary-article-number)))
932 (gnus-article-yanked-articles yank)
933 (add-to-list gnus-add-to-list))
934 (gnus-setup-message (cond (yank 'reply-yank)
935 (article-buffer 'reply)
937 (let* ((group (or group gnus-newsgroup-name))
938 (charset (gnus-group-name-charset nil group))
940 to-address to-group mailing-list to-list
943 (setq to-address (gnus-parameter-to-address group)
944 to-group (gnus-group-find-parameter group 'to-group)
945 to-list (gnus-parameter-to-list group)
946 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
947 mailing-list (when gnus-mailing-list-groups
948 (string-match gnus-mailing-list-groups group))
949 group (gnus-group-name-decode (gnus-group-real-name group)
951 (if (or (and to-group
952 (gnus-news-group-p to-group))
955 (and (gnus-news-group-p
956 (or pgroup gnus-newsgroup-name)
957 (or header gnus-current-article))
963 (message-news (or to-group group))
964 (set-buffer gnus-article-copy)
965 (gnus-msg-treat-broken-reply-to)
966 (message-followup (if (or newsgroup-p force-news)
967 (if (save-restriction
968 (article-narrow-to-head)
969 (message-fetch-field "newsgroups"))
976 (message-mail (or to-address to-list))
977 ;; Arrange for mail groups that have no `to-address' to
978 ;; get that when the user sends off the mail.
979 (when (and (not to-list)
982 (push (list 'gnus-inews-add-to-address pgroup)
983 message-send-actions)))
984 (set-buffer gnus-article-copy)
985 (gnus-msg-treat-broken-reply-to)
986 (message-wide-reply to-address)))
988 (gnus-inews-yank-articles yank))))))
990 (defun gnus-msg-treat-broken-reply-to (&optional force)
991 "Remove the Reply-to header if broken-reply-to."
993 (gnus-group-find-parameter
994 gnus-newsgroup-name 'broken-reply-to))
996 (message-narrow-to-head)
997 (message-remove-header "reply-to"))))
999 (defun gnus-post-method (arg group &optional silent)
1000 "Return the posting method based on GROUP and ARG.
1001 If SILENT, don't prompt the user."
1002 (let ((gnus-post-method (or (gnus-parameter-post-method group)
1004 (group-method (gnus-find-method-for-group group)))
1006 ;; If the group-method is nil (which shouldn't happen) we use
1007 ;; the default method.
1008 ((null group-method)
1009 (or (and (listp gnus-post-method) ;If not current/native/nil
1010 (not (listp (car gnus-post-method))) ; and not a list of methods
1011 gnus-post-method) ;then use it.
1013 message-post-method))
1014 ;; We want the inverse of the default
1015 ((and arg (not (eq arg 0)))
1016 (if (eq gnus-post-method 'current)
1019 ;; We query the user for a post method.
1021 (and (listp gnus-post-method)
1022 (listp (car gnus-post-method))))
1024 ;; Collect all methods we know about.
1026 (when (listp gnus-post-method)
1027 (if (listp (car gnus-post-method))
1029 (list gnus-post-method)))
1030 gnus-secondary-select-methods
1031 (mapcar 'cdr gnus-server-alist)
1032 (mapcar 'car gnus-opened-servers)
1033 (list gnus-select-method)
1034 (list group-method)))
1035 method-alist post-methods method)
1036 ;; Weed out all mail methods.
1038 (setq method (gnus-server-get-method "" (pop methods)))
1039 (when (and (or (gnus-method-option-p method 'post)
1040 (gnus-method-option-p method 'post-mail))
1041 (not (member method post-methods)))
1042 (push method post-methods)))
1043 ;; Create a name-method alist.
1047 (if (equal (cadr m) "")
1048 (list (symbol-name (car m)) m)
1049 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m)))
1054 (setq gnus-last-posting-server
1056 gnus-last-posting-server)
1057 ;; Just use the last value.
1058 gnus-last-posting-server
1060 "Posting method: " method-alist nil t
1061 (cons (or gnus-last-posting-server "") 0))))
1063 ;; Override normal method.
1064 ((and (eq gnus-post-method 'current)
1065 (not (memq (car group-method) gnus-discouraged-post-methods))
1066 (gnus-get-function group-method 'request-post t))
1069 ;; Use gnus-post-method.
1070 ((listp gnus-post-method) ;A method...
1071 (assert (not (listp (car gnus-post-method)))) ;... not a list of methods.
1073 ;; Use the normal select method (nil or native).
1074 (t gnus-select-method))))
1077 (defun gnus-message-make-user-agent (&optional include-mime-info max-column
1079 "Return a user-agent info. If INCLUDE-MIME-INFO is non-nil and the
1080 variable `mime-edit-user-agent-value' is bound, the value will be
1081 included in the return value. If MAX-COLUMN is specified, the return
1082 value will be folded up as it were filled. NEWLINE-PRODUCT specifies
1083 whether a newline should be inserted in front of each product-token.
1084 If the value is t or `hard', it works strictly. Otherwise, if it is
1085 non-nil (e.g. `soft'), it works semi-strictly.
1087 Here is an example of how to use this function:
1089 \(add-hook 'gnus-message-setup-hook
1091 (setq message-user-agent nil)
1094 (message-narrow-to-headers)
1095 (goto-char (point-max))
1096 (insert \"User-Agent: \"
1097 (gnus-message-make-user-agent t 76 'soft)
1100 (let ((user-agent (if (and include-mime-info
1101 (boundp 'mime-edit-user-agent-value))
1102 (concat (gnus-extended-version)
1104 mime-edit-user-agent-value)
1105 (gnus-extended-version))))
1107 (unless (natnump max-column)
1108 (setq max-column 76))
1110 (set-buffer-multibyte t)
1111 (insert (mapconcat 'identity (split-string user-agent) " "))
1112 (goto-char (point-min))
1114 start agent agents width element swidth)
1115 (while (re-search-forward "\\([^ ]+\\) ?" nil t)
1116 (setq start (match-beginning 0))
1117 (if (eq (char-after start) ?\()
1121 (push (buffer-substring start (point)) agent))
1123 (push (nreverse agent) agents))
1124 (setq agent (list (match-string 1)))))
1126 (push (nreverse agent) agents))
1127 (setq agents (nreverse agents))
1128 (if (> (+ 12 (string-width (caar agents))) max-column)
1129 (setq user-agent "\n"
1134 (setq agent (car agents)
1135 agents (cdr agents))
1136 (when (and (not bol)
1137 (or (memq newline-product '(t hard))
1138 (and newline-product
1140 (string-width (mapconcat 'identity
1143 (setq user-agent (concat user-agent "\n")
1147 (setq element (car agent)
1148 swidth (string-width element)
1151 (setq user-agent (if (member user-agent '("" "\n"))
1152 (concat user-agent element)
1153 (concat user-agent " " element))
1154 width (+ width 1 swidth)
1156 (if (> (+ width 1 swidth) max-column)
1157 (setq user-agent (concat user-agent "\n " element)
1159 (setq user-agent (concat user-agent " " element)
1160 width (+ width 1 swidth)))))))))
1165 ;;; Gnus Mail Functions
1168 ;;; Mail reply commands of Gnus summary mode
1170 (defun gnus-summary-reply (&optional yank wide very-wide)
1171 "Start composing a mail reply to the current message.
1172 If prefix argument YANK is non-nil, the original article is yanked
1174 If WIDE, make a wide reply.
1175 If VERY-WIDE, make a very wide reply."
1177 (list (and current-prefix-arg
1178 (gnus-summary-work-articles 1))))
1179 ;; Allow user to require confirmation before replying by mail to the
1180 ;; author of a news article.
1181 (when (or (not (gnus-news-group-p gnus-newsgroup-name))
1182 (not gnus-confirm-mail-reply-to-news)
1183 (y-or-n-p "Really reply by mail to article author? "))
1185 (if (listp (car yank))
1188 (gnus-article-reply (or article (gnus-summary-article-number)))
1189 (gnus-article-yanked-articles yank)
1191 ;; Stripping headers should be specified with mail-yank-ignored-headers.
1193 (gnus-summary-goto-subject article))
1194 (gnus-setup-message (if yank 'reply-yank 'reply)
1196 (gnus-summary-select-article)
1197 (dolist (article very-wide)
1198 (gnus-summary-select-article nil nil nil article)
1200 (set-buffer (gnus-copy-article-buffer))
1201 (gnus-msg-treat-broken-reply-to)
1203 (message-narrow-to-head)
1204 (setq headers (concat headers (buffer-string)))))))
1205 (set-buffer (gnus-copy-article-buffer))
1206 (gnus-msg-treat-broken-reply-to gnus-msg-force-broken-reply-to)
1208 (message-narrow-to-head)
1212 (goto-char (point-max)))
1213 (message-reply nil wide)
1215 (gnus-inews-yank-articles yank))
1216 (gnus-summary-handle-replysign)))))
1218 (defun gnus-summary-handle-replysign ()
1219 "Check the various replysign variables and take action accordingly."
1220 (when nil;;(or gnus-message-replysign gnus-message-replyencrypt)
1221 (let (signed encrypted)
1223 (set-buffer gnus-article-buffer)
1224 (setq signed (memq 'signed gnus-article-wash-types))
1225 (setq encrypted (memq 'encrypted gnus-article-wash-types)))
1226 (cond ((and gnus-message-replyencrypt encrypted)
1227 (mml-secure-message mml-default-encrypt-method
1228 (if gnus-message-replysignencrypted
1231 ((and gnus-message-replysign signed)
1232 (mml-secure-message mml-default-sign-method 'sign))))))
1234 (defun gnus-summary-reply-with-original (n &optional wide)
1235 "Start composing a reply mail to the current message.
1236 The original article will be yanked."
1238 (gnus-summary-reply (gnus-summary-work-articles n) wide))
1240 (defun gnus-summary-reply-broken-reply-to (&optional yank wide very-wide)
1241 "Like `gnus-summary-reply' except removing reply-to field.
1242 If prefix argument YANK is non-nil, the original article is yanked
1244 If WIDE, make a wide reply.
1245 If VERY-WIDE, make a very wide reply."
1247 (list (and current-prefix-arg
1248 (gnus-summary-work-articles 1))))
1249 (let ((gnus-msg-force-broken-reply-to t))
1250 (gnus-summary-reply yank wide very-wide)))
1252 (defun gnus-summary-reply-broken-reply-to-with-original (n &optional wide)
1253 "Like `gnus-summary-reply-with-original' except removing reply-to field.
1254 The original article will be yanked."
1256 (gnus-summary-reply-broken-reply-to (gnus-summary-work-articles n) wide))
1258 (defun gnus-summary-wide-reply (&optional yank)
1259 "Start composing a wide reply mail to the current message.
1260 If prefix argument YANK is non-nil, the original article is yanked
1263 (list (and current-prefix-arg
1264 (gnus-summary-work-articles 1))))
1265 (gnus-summary-reply yank t))
1267 (defun gnus-summary-wide-reply-with-original (n)
1268 "Start composing a wide reply mail to the current message.
1269 The original article will be yanked."
1271 (gnus-summary-reply-with-original n t))
1273 (defun gnus-summary-very-wide-reply (&optional yank)
1274 "Start composing a very wide reply mail to the current message.
1275 If prefix argument YANK is non-nil, the original article is yanked
1278 (list (and current-prefix-arg
1279 (gnus-summary-work-articles 1))))
1280 (gnus-summary-reply yank t (gnus-summary-work-articles yank)))
1282 (defun gnus-summary-very-wide-reply-with-original (n)
1283 "Start composing a very wide reply mail to the current message.
1284 The original article will be yanked."
1287 (gnus-summary-work-articles n) t (gnus-summary-work-articles n)))
1289 (defun gnus-summary-mail-forward (&optional full-headers post)
1290 "Forward the current message(s) to another user.
1291 If process marks exist, forward all marked messages;
1292 If FULL-HEADERS (the prefix), include full headers when forwarding.
1294 Note that this function definition for T-gnus is totally different
1295 from the original Gnus."
1297 (if (cdr (gnus-summary-work-articles nil))
1298 ;; Process marks are given.
1299 (gnus-summary-digest-mail-forward nil post)
1300 ;; No process marks.
1301 (let* ((gnus-article-reply (gnus-summary-article-number))
1302 (gnus-article-yanked-articles (list (list gnus-article-reply)))
1304 (message-included-forward-headers
1305 (if full-headers "" message-included-forward-headers)))
1306 (gnus-setup-message 'forward
1307 (gnus-summary-select-article)
1308 (setq charset default-mime-charset)
1309 (set-buffer gnus-original-article-buffer)
1310 (make-local-variable 'default-mime-charset)
1311 (setq default-mime-charset charset)
1312 (message-forward post)))))
1314 (defun gnus-summary-digest-mail-forward (&optional n post)
1315 "Digests and forwards all articles in this series.
1316 If N is a positive number, forward the N next articles.
1317 If N is a negative number, forward the N previous articles.
1318 If N is nil and any articles have been marked with the process mark,
1319 forward those articles instead.
1320 Optional POST will use news to forward instead of mail."
1322 (let ((articles (gnus-summary-work-articles n))
1323 (topics "Topics:\n")
1324 subject article frame)
1325 (when (car articles)
1326 (gnus-setup-message 'forward
1327 (gnus-summary-select-article)
1329 (setq articles (sort articles '<)
1330 subject "Digested Articles")
1331 (with-current-buffer gnus-original-article-buffer
1332 (setq subject (message-make-forward-subject))))
1334 (message-news nil subject)
1335 (message-mail nil subject))
1336 (when (and message-use-multi-frames (cdr articles))
1337 (setq frame (window-frame (get-buffer-window (current-buffer)))))
1339 (while (setq article (pop articles))
1340 (save-window-excursion
1341 (set-buffer gnus-summary-buffer)
1342 (gnus-summary-select-article nil nil nil article)
1343 (setq topics (concat topics " "
1344 (mail-header-subject gnus-current-headers)
1346 (gnus-summary-remove-process-mark article))
1348 (select-frame frame))
1349 (insert (mime-make-tag "message" "rfc822") "\n")
1350 (narrow-to-region (point) (point))
1351 (insert-buffer-substring gnus-original-article-buffer)
1353 (article-narrow-to-head)
1354 (message-remove-header message-included-forward-headers t nil t))
1355 (goto-char (point-max))
1361 (mime-edit-enclose-digest-region (point)(mark t))))))
1363 (defun gnus-summary-digest-post-forward (&optional n)
1364 "Digest and forwards all articles in this series to a newsgroup.
1365 If N is a positive number, forward the N next articles.
1366 If N is a negative number, forward the N previous articles.
1367 If N is nil and any articles have been marked with the process mark,
1368 forward those articles instead."
1370 (gnus-summary-digest-mail-forward n t))
1372 (defun gnus-summary-resend-message (address n)
1373 "Resend the current article to ADDRESS."
1375 (list (message-read-from-minibuffer
1376 "Resend message(s) to: "
1377 (when (and gnus-summary-resend-default-address
1378 (gnus-buffer-live-p gnus-original-article-buffer))
1379 ;; If some other article is currently selected, the
1380 ;; initial-contents is wrong. Whatever, it is just the
1381 ;; initial-contents.
1382 (with-current-buffer gnus-original-article-buffer
1383 (nnmail-fetch-field "to"))))
1384 current-prefix-arg))
1385 (let ((articles (gnus-summary-work-articles n))
1387 (while (setq article (pop articles))
1388 (gnus-summary-select-article nil nil nil article)
1390 (set-buffer gnus-original-article-buffer)
1391 (message-resend address))
1392 (gnus-summary-mark-article-as-forwarded article))))
1394 ;; From: Matthieu Moy <Matthieu.Moy@imag.fr>
1395 (defun gnus-summary-resend-message-edit ()
1396 "Resend an article that has already been sent.
1397 A new buffer will be created to allow the user to modify body and
1398 contents of the message, and then, everything will happen as when
1399 composing a new message."
1401 (let ((article (gnus-summary-article-number)))
1402 (gnus-setup-message 'reply-yank
1403 (gnus-summary-select-article t)
1404 (set-buffer gnus-original-article-buffer)
1405 (let ((cur (current-buffer))
1406 (to (message-fetch-field "to")))
1407 ;; Get a normal message buffer.
1408 (message-pop-to-buffer (message-buffer-name "Resend" to))
1409 (insert-buffer-substring cur)
1411 ;; T-gnus change: Use MIME-Edit to recompose a message.
1413 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
1414 (fset 'mime-edit-decode-single-part-in-buffer
1415 (lambda (&rest args)
1416 (if (let ((content-type (car args)))
1417 (and (eq 'message (mime-content-type-primary-type
1419 (eq 'rfc822 (mime-content-type-subtype
1421 (setcar (cdr args) 'not-decode-text))
1424 (mime-edit-again nil t)
1425 (fset 'mime-edit-decode-single-part-in-buffer ofn)))
1426 (message-narrow-to-head-1)
1427 (insert "From: " (message-make-from) "\n")
1428 (while (re-search-forward "^From:" nil t)
1430 (insert "Original-"))
1431 (message-remove-header "^>From[\t ]" t)
1433 ;; Gnus will generate a new one when sending.
1434 (message-remove-header "Message-ID")
1435 (message-remove-header message-ignored-resent-headers t)
1436 ;; Remove unwanted headers.
1437 (goto-char (point-max))
1438 (insert mail-header-separator)
1439 (goto-char (point-min))
1440 (re-search-forward "^To:\\|^Newsgroups:" nil 'move)
1444 (defun gnus-summary-post-forward (&optional full-headers)
1445 "Forward the current article to a newsgroup.
1446 If FULL-HEADERS (the prefix), include full headers when forwarding."
1448 (gnus-summary-mail-forward full-headers t))
1450 (defvar gnus-nastygram-message
1451 "The following article was inappropriately posted to %s.\n\n"
1452 "Format string to insert in nastygrams.
1453 The current group name will be inserted at \"%s\".")
1455 (defun gnus-summary-mail-nastygram (n)
1456 "Send a nastygram to the author of the current article."
1458 (when (or gnus-expert-user
1460 "Really send a nastygram to the author of the current article? "))
1461 (let ((group gnus-newsgroup-name))
1462 (gnus-summary-reply-with-original n)
1463 (set-buffer gnus-message-buffer)
1465 (insert (format gnus-nastygram-message group))
1466 (message-send-and-exit))))
1468 (defun gnus-summary-mail-crosspost-complaint (n)
1469 "Send a complaint about crossposting to the current article(s)."
1471 (let ((articles (gnus-summary-work-articles n))
1473 (while (setq article (pop articles))
1474 (set-buffer gnus-summary-buffer)
1475 (gnus-summary-goto-subject article)
1476 (let ((group (gnus-group-real-name gnus-newsgroup-name))
1477 newsgroups followup-to)
1478 (gnus-summary-select-article)
1479 (set-buffer gnus-original-article-buffer)
1480 (if (and (<= (length (message-tokenize-header
1482 (mail-fetch-field "newsgroups"))
1485 (or (not (setq followup-to (mail-fetch-field "followup-to")))
1486 (not (member group (message-tokenize-header
1487 followup-to ", ")))))
1489 (gnus-message 1 "Followup-to restricted")
1490 (gnus-message 1 "Not a crossposted article"))
1491 (set-buffer gnus-summary-buffer)
1492 (gnus-summary-reply-with-original 1)
1493 (set-buffer gnus-message-buffer)
1495 (insert (format gnus-crosspost-complaint newsgroups group))
1496 (message-goto-subject)
1497 (re-search-forward " *$")
1498 (replace-match " (crosspost notification)" t t)
1499 (gnus-deactivate-mark)
1500 (when (gnus-y-or-n-p "Send this complaint? ")
1501 (message-send-and-exit)))))))
1503 (defun gnus-mail-parse-comma-list ()
1506 (skip-chars-forward " ")
1509 (skip-chars-forward "^,")
1514 (narrow-to-region beg (point))
1517 (while (search-forward "\"" nil t)
1521 (skip-chars-forward ",")
1522 (skip-chars-forward "^,"))
1523 (skip-chars-backward " ")
1524 (push (buffer-substring beg (point))
1526 (skip-chars-forward "^,")
1527 (skip-chars-forward ", "))
1530 (defun gnus-inews-add-to-address (group)
1531 (let ((to-address (mail-fetch-field "to")))
1532 (when (and to-address
1534 ;; This mail group doesn't have a `to-list', so we add one
1536 (when (gnus-y-or-n-p
1537 (format "Do you want to add this as `to-list': %s " to-address))
1538 (gnus-group-add-parameter group (cons 'to-list to-address))))))
1540 (defun gnus-put-message ()
1541 "Put the current message in some group and return to Gnus."
1543 (let ((reply gnus-article-reply)
1544 (winconf gnus-prev-winconf)
1545 (group gnus-newsgroup-name))
1547 (not (gnus-group-read-only-p group)))
1548 (setq group (read-string "Put in group: " nil (gnus-writable-groups))))
1550 (when (gnus-gethash group gnus-newsrc-hashtb)
1551 (error "No such group: %s" group))
1555 (message-narrow-to-headers)
1556 (let ((gnus-deletable-headers nil))
1557 (message-generate-headers
1558 (if (message-news-p)
1559 message-required-news-headers
1560 message-required-mail-headers)))
1561 (goto-char (point-max))
1562 (if (string-match " " group)
1563 (insert "Gcc: \"" group "\"\n")
1564 (insert "Gcc: " group "\n"))
1567 (when (and (get-buffer gnus-group-buffer)
1568 (gnus-buffer-exists-p (car-safe reply))
1570 (set-buffer (car reply))
1571 (gnus-summary-mark-article-as-replied (cdr reply)))
1573 (set-window-configuration winconf))))
1575 (defun gnus-article-mail (yank)
1576 "Send a reply to the address near point.
1577 If YANK is non-nil, include the original article."
1581 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
1582 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
1584 (gnus-msg-mail address)
1586 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
1588 (defvar nntp-server-type)
1590 "Send a bug report to the Gnus maintainers."
1592 (unless (gnus-alive-p)
1593 (error "Gnus has been shut down"))
1594 (gnus-setup-message (if (message-mail-user-agent) 'message 'bug)
1595 (unless (message-mail-user-agent)
1596 (message-pop-to-buffer "*Gnus Bug*")
1597 (delete-other-windows)
1598 (when gnus-bug-create-help-buffer
1599 (switch-to-buffer "*Gnus Help Bug*")
1601 (insert gnus-bug-message)
1602 (goto-char (point-min))
1604 (set-buffer "*Gnus Bug*")))
1605 (let ((message-this-is-mail t))
1606 (message-setup `((To . ,gnus-maintainer) (Subject . ""))))
1607 (when gnus-bug-create-help-buffer
1608 (push `(gnus-bug-kill-buffer) message-send-actions))
1609 (goto-char (point-min))
1610 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
1612 (insert gnus-product-name " " gnus-version-number
1613 " (r" gnus-revision-number ") "
1614 "based on " gnus-original-product-name " v"
1615 gnus-original-version-number "\n"
1616 (emacs-version) "\n")
1617 (when (and (boundp 'nntp-server-type)
1618 (stringp nntp-server-type))
1619 (insert nntp-server-type))
1620 (insert "\n\n\n\n\n")
1621 (let (mime-content-types)
1622 (mime-edit-insert-tag
1623 "application" "emacs-lisp"
1624 "\nContent-Disposition: inline\nContent-Description: User settings"))
1625 (insert (with-temp-buffer
1628 (let (mime-content-types)
1629 (mime-edit-insert-tag "text" "plain"))
1630 (goto-char (point-min))
1631 (search-forward "Subject: " nil t)
1634 (defun gnus-bug-kill-buffer ()
1635 (when (get-buffer "*Gnus Help Bug*")
1636 (kill-buffer "*Gnus Help Bug*")))
1638 (defun gnus-summary-yank-message (buffer n)
1639 "Yank the current article into a composed message."
1641 (list (completing-read "Buffer: " (mapcar 'list (message-buffers)) nil t)
1642 current-prefix-arg))
1643 (when (gnus-buffer-live-p buffer)
1644 (let ((summary-frame (selected-frame))
1645 (message-frame (when (static-if (featurep 'xemacs)
1646 (device-on-window-system-p)
1648 (let ((window (get-buffer-window buffer t)))
1650 (window-frame window)))))
1651 (separator (concat "^" (regexp-quote mail-header-separator)
1653 (gnus-summary-iterate n
1654 (gnus-summary-select-article)
1655 (gnus-copy-article-buffer)
1656 (when (frame-live-p message-frame)
1657 (raise-frame message-frame)
1658 (select-frame message-frame))
1659 (with-current-buffer buffer
1660 (when (save-excursion
1662 (let (case-fold-search)
1663 (and (not (re-search-backward separator nil t))
1664 (re-search-forward separator nil t))))
1665 (goto-char (match-end 0)))
1666 (message-yank-buffer gnus-article-copy))
1667 (select-frame summary-frame))
1668 (when (frame-live-p message-frame)
1669 (select-frame message-frame)))))
1671 (defun gnus-debug ()
1672 "Attempts to go through the Gnus source file and report what variables have been changed.
1673 The source file has to be in the Emacs load path."
1675 (let ((files gnus-debug-files)
1677 file expr olist sym)
1678 (gnus-message 4 "Please wait while we snoop your variables...")
1679 ;; Go through all the files looking for non-default values for variables.
1682 (set-buffer (gnus-get-buffer-create " *gnus bug info*"))
1685 (when (and (setq file (locate-library (pop files)))
1686 (file-exists-p file))
1687 (insert-file-contents file)
1688 (goto-char (point-min))
1689 (if (not (re-search-forward "^;;* *Internal variables" nil t))
1690 (gnus-message 4 "Malformed sources in file %s" file)
1691 (narrow-to-region (point-min) (point))
1692 (goto-char (point-min))
1693 (while (setq expr (ignore-errors (read (current-buffer))))
1695 (and (memq (car expr) '(defvar defcustom defvoo))
1696 (stringp (nth 3 expr))
1697 (not (memq (nth 1 expr) gnus-debug-exclude-variables))
1698 (or (not (boundp (nth 1 expr)))
1699 (not (equal (eval (nth 2 expr))
1700 (symbol-value (nth 1 expr)))))
1701 (push (nth 1 expr) olist)))))))
1702 (kill-buffer (current-buffer)))
1703 (when (setq olist (nreverse olist))
1704 (insert ";----------------- Environment follows ------------------\n\n"))
1706 (if (boundp (car olist))
1708 (pp `(setq ,(car olist)
1709 ,(if (or (consp (setq sym (symbol-value (car olist))))
1711 (not (or (eq sym nil)
1713 (list 'quote (symbol-value (car olist)))
1714 (symbol-value (car olist))))
1717 (format "(setq %s 'whatever)\n" (car olist))))
1718 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
1719 (setq olist (cdr olist)))
1720 ;; Remove any control chars - they seem to cause trouble for some
1721 ;; mailers. (Byte-compiled output from the stuff above.)
1723 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
1724 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
1726 ;; Break MIME tags purposely.
1728 (while (re-search-forward mime-edit-tag-regexp nil t)
1729 (goto-char (1+ (match-beginning 0)))
1732 ;;; Treatment of rejected articles.
1735 (defun gnus-summary-resend-bounced-mail (&optional fetch)
1736 "Re-mail the current message.
1737 This only makes sense if the current message is a bounce message than
1738 contains some mail you have written which has been bounced back to
1740 If FETCH, try to fetch the article that this is a reply to, if indeed
1743 (gnus-summary-select-article t)
1744 (set-buffer gnus-original-article-buffer)
1745 (gnus-setup-message 'compose-bounce
1746 (let* ((references (mail-fetch-field "references"))
1747 (parent (and references (gnus-parent-id references))))
1749 ;; If there are references, we fetch the article we answered to.
1751 (gnus-summary-refer-article parent)
1752 (gnus-summary-show-all-headers)))))
1756 (defun gnus-inews-group-method (group)
1758 ;; If the group doesn't exist, we assume
1759 ;; it's an archive group...
1760 ((and (null (gnus-get-info group))
1761 (eq (car (gnus-server-to-method gnus-message-archive-method))
1762 (car (gnus-server-to-method (gnus-group-method group)))))
1763 gnus-message-archive-method)
1765 ((gnus-info-method (gnus-get-info group))
1766 (gnus-info-method (gnus-get-info group)))
1768 (t (gnus-server-to-method (gnus-group-method group)))))
1770 ;; Do Gcc handling, which copied the message over to some group.
1771 (defun gnus-inews-do-gcc (&optional gcc)
1775 (message-narrow-to-headers)
1776 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
1777 (coding-system-for-write 'raw-text)
1778 (output-coding-system 'raw-text)
1779 groups group method group-art
1780 mml-externalize-attachments)
1782 (message-remove-header "gcc")
1784 (setq groups (message-unquote-tokens
1785 (message-tokenize-header gcc " ,")))
1786 ;; Copy the article over to some group(s).
1787 (while (setq group (pop groups))
1788 (unless (gnus-check-server
1789 (setq method (gnus-inews-group-method group)))
1790 (error "Can't open server %s" (if (stringp method) method
1792 (unless (gnus-request-group group nil method)
1793 (gnus-request-create-group group method))
1794 (setq mml-externalize-attachments
1795 (if (stringp gnus-gcc-externalize-attachments)
1796 (string-match gnus-gcc-externalize-attachments group)
1797 gnus-gcc-externalize-attachments))
1799 (nnheader-set-temp-buffer " *acc*")
1800 (insert-buffer-substring message-encoding-buffer)
1801 (gnus-run-hooks 'gnus-before-do-gcc-hook)
1802 (goto-char (point-min))
1803 (when (re-search-forward
1804 (concat "^" (regexp-quote mail-header-separator) "$")
1806 (replace-match "" t t ))
1807 (unless (setq group-art
1808 (gnus-request-accept-article group method t t))
1809 (gnus-message 1 "Couldn't store article in group %s: %s"
1810 group (gnus-status-message method))
1812 (when (and group-art
1813 (or gnus-gcc-mark-as-read
1814 gnus-inews-mark-gcc-as-read))
1815 (gnus-group-mark-article-read group (cdr group-art)))
1816 (kill-buffer (current-buffer)))))))))
1818 (defun gnus-inews-insert-gcc ()
1819 "Insert Gcc headers based on `gnus-outgoing-message-group'."
1822 (message-narrow-to-headers)
1823 (let* ((group gnus-outgoing-message-group)
1825 ((gnus-functionp group)
1827 ((or (stringp group) (list group))
1832 (if (string-match " " gcc)
1833 (concat "\"" gcc "\"")
1835 (mapconcat (lambda (group)
1836 (if (string-match " " group)
1837 (concat "\"" group "\"")
1842 (defun gnus-inews-insert-archive-gcc (&optional group)
1843 "Insert the Gcc to say where the article is to be archived."
1844 (let* ((var gnus-message-archive-group)
1845 (group (or group gnus-newsgroup-name ""))
1847 (and gnus-newsgroup-name
1848 (not (equal gnus-newsgroup-name ""))
1849 (gnus-group-find-parameter
1850 gnus-newsgroup-name 'gcc-self)))
1854 ((null gnus-message-archive-method)
1858 ;; Just a single group.
1861 ;; We don't want this.
1863 ((and (listp var) (stringp (car var)))
1864 ;; A list of groups.
1866 ((gnus-functionp var)
1868 (funcall var group))
1870 ;; An alist of regexps/functions/forms.
1875 ((stringp (caar var))
1877 (when (string-match (caar var) group)
1879 ((gnus-functionp (car var))
1881 (funcall (car var) group))
1883 (eval (car var)))))))
1884 (setq var (cdr var)))
1887 (when (or groups gcc-self-val)
1888 (when (stringp groups)
1889 (setq groups (list groups)))
1892 (message-narrow-to-headers)
1893 (goto-char (point-max))
1896 ;; Use the `gcc-self' param value instead.
1899 (if (stringp gcc-self-val)
1900 (if (string-match " " gcc-self-val)
1901 (concat "\"" gcc-self-val "\"")
1903 (if (string-match " " group)
1904 (concat "\"" group "\"")
1906 (if (not (eq gcc-self-val 'none))
1911 ;; Use the list of groups.
1912 (while (setq name (pop groups))
1913 (let ((str (if (string-match ":" name)
1915 (gnus-group-prefixed-name
1916 name gnus-message-archive-method))))
1917 (insert (if (string-match " " str)
1918 (concat "\"" str "\"")
1926 (defun gnus-configure-posting-styles (&optional group-name)
1927 "Configure posting styles according to `gnus-posting-styles'."
1928 (unless gnus-inhibit-posting-styles
1929 (let ((group (or group-name gnus-newsgroup-name ""))
1930 (styles gnus-posting-styles)
1931 style match attribute results
1933 ;; If the group has a posting-style parameter, add it at the end with a
1934 ;; regexp matching everything, to be sure it takes precedence over all
1936 (when gnus-newsgroup-name
1937 (let ((tmp-style (gnus-group-find-parameter group 'posting-style t)))
1939 (setq styles (append styles (list (cons ".*" tmp-style)))))))
1940 ;; Go through all styles and look for matches.
1941 (dolist (style styles)
1942 (setq match (pop style))
1943 (goto-char (point-min))
1946 ;; Regexp string match on the group name.
1947 (string-match match group))
1949 ;; Obsolete format of header match.
1950 (and (gnus-buffer-live-p gnus-article-copy)
1951 (with-current-buffer gnus-article-copy
1952 (let ((header (message-fetch-field (pop style))))
1954 (string-match (pop style) header))))))
1955 ((or (symbolp match)
1956 (gnus-functionp match))
1958 ((gnus-functionp match)
1959 ;; Function to be called.
1962 ;; Variable to be checked.
1963 (symbol-value match))))
1966 ((eq (car match) 'header)
1967 ;; New format of header match.
1968 (and (gnus-buffer-live-p gnus-article-copy)
1969 (with-current-buffer gnus-article-copy
1970 (let ((header (message-fetch-field (nth 1 match))))
1972 (string-match (nth 2 match) header))))))
1974 ;; This is a form to be evaled.
1976 ;; We have a match, so we set the variables.
1977 (setq style (gnus-configure-posting-style style nil))
1978 (dolist (attribute style)
1979 (setq results (delq (assoc (car attribute) results) results))
1980 (push attribute results))))
1981 ;; Now we have all the styles, so we insert them.
1982 (setq name (assq 'name results)
1983 address (assq 'address results))
1984 (setq results (delq name (delq address results)))
1985 ;; make-local-hook is not obsolete in Emacs 20 or XEmacs.
1986 (make-local-hook 'message-setup-hook)
1987 (setq results (sort results (lambda (x y)
1988 (string-lessp (car x) (car y)))))
1989 (dolist (result results)
1990 (add-hook 'message-setup-hook
1992 ((eq 'eval (car result))
1994 ((eq 'body (car result))
1998 (insert ,(cdr result)))))
1999 ((eq 'signature (car result))
2000 (set (make-local-variable 'message-signature) nil)
2001 (set (make-local-variable 'message-signature-file) nil)
2002 (if (not (cdr result))
2006 (let ((message-signature ,(cdr result)))
2007 (when message-signature
2008 (message-insert-signature)))))))
2011 (if (symbolp (car result))
2012 (capitalize (symbol-name (car result)))
2016 (message-remove-header ,header)
2017 (let ((value ,(cdr result)))
2020 (insert ,header ": " value "\n"))))))))
2022 (when (or name address)
2023 (add-hook 'message-setup-hook
2025 (set (make-local-variable 'user-mail-address)
2026 ,(or (cdr address) user-mail-address))
2027 (let ((user-full-name ,(or (cdr name) (user-full-name)))
2029 ,(or (cdr address) user-mail-address)))
2031 (message-remove-header "From")
2033 (insert "From: " (message-make-from) "\n"))))
2036 ;; splitted from gnus-configure-posting-styles to allow recursive traversal.
2037 (defun gnus-configure-posting-style (style stack)
2038 "Parse one posting style STYLE and returns the value as an alist."
2039 (let (results element variable filep value v)
2040 (dolist (attribute style)
2041 (setq element (pop attribute)
2046 ((eq (car attribute) ':file)
2049 ((eq (car attribute) :value)
2053 ;; We get the value.
2058 ((or (symbolp value)
2059 (gnus-functionp value))
2060 (cond ((gnus-functionp value)
2063 (symbol-value value))))
2066 ;; Translate obsolescent value.
2068 ((eq element 'signature-file)
2069 (setq element 'signature
2071 ((eq element 'x-face-file)
2072 (setq element 'x-face
2074 ;; Get the contents of file elems.
2076 (setq v (with-temp-buffer
2077 (insert-file-contents v)
2078 (goto-char (point-max))
2082 (if (eq element 'import)
2084 (if (member v stack)
2085 (error "Circular import of \"%s\"" v))
2087 (nconc (nreverse (gnus-configure-posting-style
2088 (cdr (assoc v gnus-named-posting-styles))
2091 (push (cons element v) results)))
2092 (nreverse results)))
2094 (defun gnus-summary-execute-command-with-posting-style (style command)
2095 "Temporarily select a posting-style named STYLE and execute COMMAND."
2097 (let ((style (completing-read "Posting style: "
2098 gnus-named-posting-styles nil t)))
2102 (format "Command to execute with %s: " style))))))
2103 (let ((gnus-posting-styles (list (list ".*" (list 'import style)))))
2104 (call-interactively command)))
2107 ;;; @ for MIME Edit mode
2110 (defun gnus-maybe-setup-default-charset ()
2112 (and (boundp 'gnus-summary-buffer)
2113 (buffer-live-p gnus-summary-buffer)
2115 (set-buffer gnus-summary-buffer)
2116 default-mime-charset))))
2119 (make-local-variable 'default-mime-charset)
2120 (setq default-mime-charset charset)
2124 ;;; @ for MIME view mode
2127 (defun gnus-following-method (buf)
2128 (gnus-setup-message 'reply-yank
2130 (if (message-news-p)
2132 (message-reply nil 'wide))
2133 (let ((message-reply-buffer buf))
2134 (message-yank-original))
2135 (message-goto-body))
2139 ;;; Allow redefinition of functions.
2145 ;;; gnus-msg.el ends here