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 :type '(repeat (cons (choice (regexp)
126 (string :tag "Header")
127 (regexp :tag "Regexp"))
131 (choice (const signature)
132 (const signature-file)
139 (string :tag "Header"))
145 (defcustom gnus-gcc-mark-as-read nil
146 "If non-nil, automatically mark Gcc articles as read."
151 (defvar gnus-inews-mark-gcc-as-read nil
152 "Obsolete variable. Use `gnus-gcc-mark-as-read' instead.")
154 (make-obsolete-variable 'gnus-inews-mark-gcc-as-read
155 'gnus-gcc-mark-as-read)
157 (defcustom gnus-gcc-externalize-attachments nil
158 "Should local-file attachments be included as external parts in Gcc copies?
159 If it is `all', attach files as external parts;
160 if a regexp and matches the Gcc group name, attach files as external parts;
161 If nil, attach files as normal parts."
164 :type '(choice (const nil :tag "None")
165 (const all :tag "Any")
166 (string :tag "Regexp")))
168 (gnus-define-group-parameter
169 posting-charset-alist
172 "Return the permitted unencoded charsets for posting of GROUP."
173 :variable gnus-group-posting-charset-alist
175 '(("^\\(no\\|fr\\)\\.[^,]*\\(,[ \t\n]*\\(no\\|fr\\)\\.[^,]*\\)*$" iso-8859-1 (iso-8859-1))
176 ("^\\(fido7\\|relcom\\)\\.[^,]*\\(,[ \t\n]*\\(fido7\\|relcom\\)\\.[^,]*\\)*$" koi8-r (koi8-r))
177 (message-this-is-mail nil nil)
178 (message-this-is-news nil t))
180 "Alist of regexps and permitted unencoded charsets for posting.
181 Each element of the alist has the form (TEST HEADER BODY-LIST), where
182 TEST is either a regular expression matching the newsgroup header or a
184 HEADER is the charset which may be left unencoded in the header (nil
185 means encode all charsets),
186 BODY-LIST is a list of charsets which may be encoded using 8bit
187 content-transfer encoding in the body, or one of the special values
188 nil (always encode using quoted-printable) or t (always use 8bit).
190 Note that any value other than nil for HEADER infringes some RFCs, so
191 use this option with care."
192 :variable-group gnus-charset
194 '(repeat (list :tag "Permitted unencoded charsets"
196 (regexp :tag "Group")
197 (const :tag "Mail message" :value message-this-is-mail)
198 (const :tag "News article" :value message-this-is-news))
199 (choice :tag "Header"
200 (const :tag "None" nil)
201 (symbol :tag "Charset"))
203 (const :tag "Any" :value t)
204 (const :tag "None" :value nil)
205 (repeat :tag "Charsets"
206 (symbol :tag "Charset")))))
207 :parameter-type '(choice :tag "Permitted unencoded charsets"
210 :parameter-document "\
211 List of charsets that are permitted to be unencoded.")
213 (defcustom gnus-debug-files
214 '("gnus.el" "gnus-sum.el" "gnus-group.el"
215 "gnus-art.el" "gnus-start.el" "gnus-async.el"
216 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
217 "gnus-agent.el" "gnus-cache.el" "gnus-srvr.el"
218 "mm-util.el" "mm-decode.el" "nnmail.el" "nntp.el" "message.el")
219 "Files whose variables will be reported in `gnus-bug'."
222 :type '(repeat (string :tag "File")))
224 (defcustom gnus-debug-exclude-variables
225 '(mm-mime-mule-charset-alist
226 nnmail-split-fancy message-minibuffer-local-map)
227 "Variables that should not be reported in `gnus-bug'."
230 :type '(repeat (symbol :tag "Variable")))
232 (defcustom gnus-discouraged-post-methods
233 '(nndraft nnml nnimap nnmaildir nnmh nnfolder nndir)
234 "A list of back ends that are not used in \"real\" newsgroups.
235 This variable is used only when `gnus-post-method' is `current'."
237 :group 'gnus-group-foreign
238 :type '(repeat (symbol :tag "Back end")))
240 (defcustom gnus-message-replysign
242 "Automatically sign replys to signed messages.
243 See also the `mml-default-sign-method' variable."
247 (defcustom gnus-message-replyencrypt
249 "Automatically encrypt replys to encrypted messages.
250 See also the `mml-default-encrypt-method' variable."
254 (defcustom gnus-message-replysignencrypted
256 "Setting this causes automatically encryped messages to also be signed."
260 (defcustom gnus-confirm-mail-reply-to-news nil
261 "If non-nil, Gnus requests confirmation when replying to news.
262 This is done because new users often reply by mistake when reading
267 (defcustom gnus-summary-resend-default-address t
268 "If non-nil, Gnus tries to suggest a default address to resend to.
269 If nil, the address field will always be empty after invoking
270 `gnus-summary-resend-message'."
274 ;;; Internal variables.
276 (defvar gnus-inhibit-posting-styles nil
277 "Inhibit the use of posting styles.")
279 (defvar gnus-message-buffer "*Mail Gnus*")
280 (defvar gnus-article-copy nil)
281 (defvar gnus-check-before-posting nil)
282 (defvar gnus-last-posting-server nil)
283 (defvar gnus-message-group-art nil)
285 (defvar gnus-msg-force-broken-reply-to nil)
287 (defconst gnus-bug-message
288 (format "Sending a bug report to the Gnus Towers.
289 ========================================
291 This gnus is the %s%s.
292 If you think the bug is a Semi-gnus bug, send a bug report to Semi-gnus
293 Developers. (the addresses below are mailing list addresses)
295 ========================================
297 The buffer below is a mail buffer. When you press `C-c C-c', it will
298 be sent to the Gnus Bug Exterminators.
300 The thing near the bottom of the buffer is how the environment
301 settings will be included in the mail. Please do not delete that.
302 They will tell the Bug People what your environment is, so that it
303 will be easier to locate the bugs.
305 If you have found a bug that makes Emacs go \"beep\", set
306 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
307 and include the backtrace in your bug report.
309 Please describe the bug in annoying, painstaking detail.
311 Thank you for your help in stamping out bugs.
314 (if (string= gnus-product-name "Semi-gnus")
316 ", a modified version of Semi-gnus")))
319 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
320 (autoload 'news-setup "rnewspost")
321 (autoload 'news-reply-mode "rnewspost")
322 (autoload 'rmail-dont-reply-to "mail-utils")
323 (autoload 'rmail-output "rmailout"))
327 ;;; Gnus Posting Functions
330 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
331 "p" gnus-summary-post-news
332 "i" gnus-summary-news-other-window
333 "f" gnus-summary-followup
334 "F" gnus-summary-followup-with-original
335 "c" gnus-summary-cancel-article
336 "s" gnus-summary-supersede-article
337 "r" gnus-summary-reply
338 "y" gnus-summary-yank-message
339 "R" gnus-summary-reply-with-original
340 "w" gnus-summary-wide-reply
341 "W" gnus-summary-wide-reply-with-original
342 "v" gnus-summary-very-wide-reply
343 "V" gnus-summary-very-wide-reply-with-original
344 "n" gnus-summary-followup-to-mail
345 "N" gnus-summary-followup-to-mail-with-original
346 "m" gnus-summary-mail-other-window
347 "u" gnus-uu-post-news
348 "\M-c" gnus-summary-mail-crosspost-complaint
349 "Br" gnus-summary-reply-broken-reply-to
350 "BR" gnus-summary-reply-broken-reply-to-with-original
351 "om" gnus-summary-mail-forward
352 "op" gnus-summary-post-forward
353 "Om" gnus-summary-digest-mail-forward
354 "Op" gnus-summary-digest-post-forward)
356 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
357 "b" gnus-summary-resend-bounced-mail
358 ;; "c" gnus-summary-send-draft
359 "r" gnus-summary-resend-message
360 "e" gnus-summary-resend-message-edit)
362 ;;; Internal functions.
364 (defvar gnus-article-reply nil)
365 (defmacro gnus-setup-message (config &rest forms)
366 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
367 (buffer (make-symbol "gnus-setup-message-buffer"))
368 (article (make-symbol "gnus-setup-message-article"))
369 (group (make-symbol "gnus-setup-message-group")))
370 `(let ((,winconf (current-window-configuration))
371 (,buffer (buffer-name (current-buffer)))
372 (,article gnus-article-reply)
373 (,group gnus-newsgroup-name)
374 (message-header-setup-hook
375 (copy-sequence message-header-setup-hook))
376 (message-mode-hook (copy-sequence message-mode-hook))
377 (message-startup-parameter-alist
378 '((reply-buffer . gnus-copy-article-buffer)
379 (original-buffer . gnus-original-article-buffer)
380 (user-agent . Gnus))))
381 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
382 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
383 ;; #### FIXME: for a reason that I did not manage to identify yet,
384 ;; the variable `gnus-newsgroup-name' does not honor a dynamically
385 ;; scoped or setq'ed value from a caller like `C-u gnus-summary-mail'.
386 ;; After evaluation of @forms below, it gets the value we actually want
387 ;; to override, and the posting styles are used. For that reason, I've
388 ;; added an optional argument to `gnus-configure-posting-styles' to
389 ;; make sure that the correct value for the group name is used. -- drv
390 (add-hook 'message-mode-hook
392 (gnus-configure-posting-styles ,group)))
396 (gnus-inews-add-send-actions ,winconf ,buffer ,article ,config)
397 (gnus-inews-insert-draft-meta-information ,group ,article)
398 (setq gnus-message-buffer (current-buffer))
399 (set (make-local-variable 'gnus-message-group-art)
400 (cons ,group ,article))
401 (set (make-local-variable 'gnus-newsgroup-name) ,group)
402 (gnus-maybe-setup-default-charset)
403 (gnus-run-hooks 'gnus-message-setup-hook))
405 (gnus-configure-windows ,config t)
406 (run-hooks 'post-command-hook)
407 (set-buffer-modified-p nil))))
409 (defun gnus-inews-insert-draft-meta-information (group article)
412 (not (string= group ""))
413 (not (message-fetch-field gnus-draft-meta-information-header)))
414 (goto-char (point-min))
415 (insert gnus-draft-meta-information-header ": (\"" group "\" "
416 (if article (number-to-string
423 (defun gnus-msg-mail (&optional to subject other-headers continue
424 switch-action yank-action send-actions)
425 "Start editing a mail message to be sent.
426 Like `message-mail', but with Gnus paraphernalia, particularly the
427 Gcc: header for archiving purposes."
429 (let ((buf (current-buffer))
431 (gnus-setup-message 'message
432 (message-mail to subject other-headers continue
433 nil yank-action send-actions))
435 (setq mail-buf (current-buffer))
436 (switch-to-buffer buf)
437 (apply switch-action mail-buf nil)))
438 ;; COMPOSEFUNC should return t if succeed. Undocumented ???
441 (defvar save-selected-window-window)
444 (defun gnus-button-mailto (address)
446 (set-buffer (gnus-copy-article-buffer))
447 (gnus-setup-message 'message
448 (message-reply address))
449 (and (boundp 'save-selected-window-window)
450 (not (window-live-p save-selected-window-window))
451 (setq save-selected-window-window (selected-window))))
454 (defun gnus-button-reply (&optional to-address wide)
455 "Like `message-reply'."
457 (gnus-setup-message 'message
458 (message-reply to-address wide))
459 (and (boundp 'save-selected-window-window)
460 (not (window-live-p save-selected-window-window))
461 (setq save-selected-window-window (selected-window))))
464 (define-mail-user-agent 'gnus-user-agent
465 'gnus-msg-mail 'message-send-and-exit
466 'message-kill-buffer 'message-send-hook)
468 (defun gnus-setup-posting-charset (group)
469 (let ((alist gnus-group-posting-charset-alist)
470 (group (or group ""))
474 (while (setq elem (pop alist))
475 (when (or (and (stringp (car elem))
476 (string-match (car elem) group))
477 (and (gnus-functionp (car elem))
478 (funcall (car elem) group))
479 (and (symbolp (car elem))
480 (symbol-value (car elem))))
481 (throw 'found (cons (cadr elem) (caddr elem)))))))))
483 (defun gnus-inews-add-send-actions (winconf buffer article &optional config)
484 (make-local-hook 'message-sent-hook)
485 (add-hook 'message-sent-hook (if gnus-agent 'gnus-agent-possibly-do-gcc
486 'gnus-inews-do-gcc) nil t)
488 (make-local-hook 'message-header-hook)
489 (add-hook 'message-header-hook 'gnus-agent-possibly-save-gcc nil t))
490 (setq message-post-method
492 (gnus-post-method arg ,gnus-newsgroup-name)))
493 (setq message-user-agent (gnus-extended-version))
494 (when (not message-use-multi-frames)
496 `(set-window-configuration ,winconf) 'exit 'postpone 'kill))
498 `(when (gnus-buffer-exists-p ,buffer)
502 (if (eq config 'forward)
503 `(gnus-summary-mark-article-as-forwarded ',article)
504 `(gnus-summary-mark-article-as-replied ',article)))))
507 (put 'gnus-setup-message 'lisp-indent-function 1)
508 (put 'gnus-setup-message 'edebug-form-spec '(form body))
510 ;;; Post news commands of Gnus group mode and summary mode
512 (defun gnus-group-mail (&optional arg)
513 "Start composing a mail.
514 If ARG, use the group under the point to find a posting style.
515 If ARG is 1, prompt for a group name to find the posting style."
517 ;; We can't `let' gnus-newsgroup-name here, since that leads
518 ;; to local variables leaking.
519 (let ((group gnus-newsgroup-name)
520 ;; make sure last viewed article doesn't affect posting styles:
522 (buffer (current-buffer)))
525 (setq gnus-newsgroup-name
527 (if (= 1 (prefix-numeric-value arg))
528 (completing-read "Use posting style of group: "
529 gnus-active-hashtb nil
530 (gnus-read-active-file-p))
531 (gnus-group-group-name))
533 ;; #### see comment in gnus-setup-message -- drv
534 (gnus-setup-message 'message (message-mail)))
537 (setq gnus-newsgroup-name group)))))
539 (defun gnus-group-news (&optional arg)
540 "Start composing a news.
541 If ARG, post to group under point.
542 If ARG is 1, prompt for group name to post to.
544 This function prepares a news even when using mail groups. This is useful
545 for posting messages to mail groups without actually sending them over the
546 network. The corresponding backend must have a 'request-post method."
548 ;; We can't `let' gnus-newsgroup-name here, since that leads
549 ;; to local variables leaking.
550 (let ((group gnus-newsgroup-name)
551 ;; make sure last viewed article doesn't affect posting styles:
553 (buffer (current-buffer)))
556 (setq gnus-newsgroup-name
558 (if (= 1 (prefix-numeric-value arg))
559 (completing-read "Use group: "
560 gnus-active-hashtb nil
561 (gnus-read-active-file-p))
562 (gnus-group-group-name))
564 ;; #### see comment in gnus-setup-message -- drv
565 (gnus-setup-message 'message
566 (message-news (gnus-group-real-name gnus-newsgroup-name))))
569 (setq gnus-newsgroup-name group)))))
571 (defun gnus-group-post-news (&optional arg)
572 "Start composing a message (a news by default).
573 If ARG, post to group under point. If ARG is 1, prompt for group name.
574 Depending on the selected group, the message might be either a mail or
577 ;; Bind this variable here to make message mode hooks work ok.
578 (let ((gnus-newsgroup-name
580 (if (= 1 (prefix-numeric-value arg))
581 (completing-read "Newsgroup: " gnus-active-hashtb nil
582 (gnus-read-active-file-p))
583 (gnus-group-group-name))
585 ;; make sure last viewed article doesn't affect posting styles:
587 (gnus-post-news 'post gnus-newsgroup-name)))
589 (defun gnus-summary-mail-other-window (&optional arg)
590 "Start composing a mail in another window.
591 Use the posting of the current group by default.
592 If ARG, don't do that. If ARG is 1, prompt for group name to find the
595 ;; We can't `let' gnus-newsgroup-name here, since that leads
596 ;; to local variables leaking.
597 (let ((group gnus-newsgroup-name)
598 ;; make sure last viewed article doesn't affect posting styles:
600 (buffer (current-buffer)))
603 (setq gnus-newsgroup-name
605 (if (= 1 (prefix-numeric-value arg))
606 (completing-read "Use group: "
607 gnus-active-hashtb nil
608 (gnus-read-active-file-p))
610 gnus-newsgroup-name))
611 ;; #### see comment in gnus-setup-message -- drv
612 (gnus-setup-message 'message (message-mail)))
615 (setq gnus-newsgroup-name group)))))
617 (defun gnus-summary-news-other-window (&optional arg)
618 "Start composing a news in another window.
619 Post to the current group by default.
620 If ARG, don't do that. If ARG is 1, prompt for group name to post to.
622 This function prepares a news even when using mail groups. This is useful
623 for posting messages to mail groups without actually sending them over the
624 network. The corresponding backend must have a 'request-post method."
626 ;; We can't `let' gnus-newsgroup-name here, since that leads
627 ;; to local variables leaking.
628 (let ((group gnus-newsgroup-name)
629 ;; make sure last viewed article doesn't affect posting styles:
631 (buffer (current-buffer)))
634 (setq gnus-newsgroup-name
636 (if (= 1 (prefix-numeric-value arg))
637 (completing-read "Use group: "
638 gnus-active-hashtb nil
639 (gnus-read-active-file-p))
641 gnus-newsgroup-name))
642 ;; #### see comment in gnus-setup-message -- drv
643 (gnus-setup-message 'message
644 (message-news (gnus-group-real-name gnus-newsgroup-name))))
647 (setq gnus-newsgroup-name group)))))
649 (defun gnus-summary-post-news (&optional arg)
650 "Start composing a message. Post to the current group by default.
651 If ARG, don't do that. If ARG is 1, prompt for a group name to post to.
652 Depending on the selected group, the message might be either a mail or
655 ;; Bind this variable here to make message mode hooks work ok.
656 (let ((gnus-newsgroup-name
658 (if (= 1 (prefix-numeric-value arg))
659 (completing-read "Newsgroup: " gnus-active-hashtb nil
660 (gnus-read-active-file-p))
662 gnus-newsgroup-name))
663 ;; make sure last viewed article doesn't affect posting styles:
665 (gnus-post-news 'post gnus-newsgroup-name)))
668 (defun gnus-summary-followup (yank &optional force-news)
669 "Compose a followup to an article.
670 If prefix argument YANK is non-nil, the original article is yanked
672 YANK is a list of elements, where the car of each element is the
673 article number, and the two following numbers is the region to be
676 (list (and current-prefix-arg
677 (gnus-summary-work-articles 1))))
679 (gnus-summary-goto-subject
680 (if (listp (car yank))
683 (save-window-excursion
684 (gnus-summary-select-article))
685 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
686 (gnus-newsgroup-name gnus-newsgroup-name))
688 (gnus-post-news nil gnus-newsgroup-name
689 headers gnus-article-buffer
691 (gnus-summary-handle-replysign)))
693 (defun gnus-summary-followup-with-original (n &optional force-news)
694 "Compose a followup to an article and include the original article."
696 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
698 (defun gnus-summary-followup-to-mail (&optional arg)
699 "Followup to the current mail message via news."
701 (list (and current-prefix-arg
702 (gnus-summary-work-articles 1))))
703 (gnus-summary-followup arg t))
705 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
706 "Followup to the current mail message via news."
708 (gnus-summary-followup (gnus-summary-work-articles arg) t))
710 (defun gnus-inews-yank-articles (articles)
711 (let (beg article yank-string
712 (more-than-one (cdr articles))
713 (cur (current-buffer))
716 (while (setq article (pop articles))
717 (when (listp article)
718 (setq yank-string (nth 1 article)
719 article (nth 0 article)))
720 (save-window-excursion
721 (set-buffer gnus-summary-buffer)
722 (gnus-summary-select-article nil nil nil article)
723 (gnus-summary-remove-process-mark article))
725 ;; Gathering references.
727 (setq refs (message-list-references
729 (mail-header-references gnus-current-headers)
730 (mail-header-message-id gnus-current-headers)))
731 (when message-use-multi-frames
732 (when (setq window (get-buffer-window cur t))
733 (select-frame (window-frame window)))))
735 (gnus-copy-article-buffer nil yank-string)
736 (let ((message-reply-buffer gnus-article-copy)
737 (message-reply-headers
738 ;; The headers are decoded.
739 (with-current-buffer gnus-article-copy
741 (nnheader-narrow-to-headers)
742 (ietf-drums-unfold-fws)
743 (nnheader-parse-head t)))))
744 (message-yank-original)
745 (setq beg (or beg (mark t))))
750 ;; Replace with the gathered references.
754 (message-narrow-to-headers)
755 (let ((case-fold-search t))
756 (if (re-search-forward "^References:\\([\t ]+.+\n\\)+" nil t)
758 (goto-char (point-max))))
760 (list (or (assq 'References message-header-format-alist)
761 '(References . message-shorten-references)))
762 (list (cons 'References
763 (mapconcat 'identity (nreverse refs) " "))))
764 (backward-delete-char 1))
770 (defun gnus-summary-cancel-article (&optional n symp)
771 "Cancel an article you posted.
772 Uses the process-prefix convention. If given the symbolic
773 prefix `a', cancel using the standard posting method; if not
774 post using the current select method."
775 (interactive (gnus-interactive "P\ny"))
776 (let ((articles (gnus-summary-work-articles n))
779 (gnus-post-method (eq ',symp 'a) ,gnus-newsgroup-name)))
781 (while (setq article (pop articles))
782 (when (gnus-summary-select-article t nil nil article)
783 (when (gnus-eval-in-buffer-window gnus-article-buffer
785 (set-buffer gnus-original-article-buffer)
786 (message-cancel-news)))
787 (gnus-summary-mark-as-read article gnus-canceled-mark)
788 (gnus-cache-remove-article 1))
789 (gnus-article-hide-headers-if-wanted))
790 (gnus-summary-remove-process-mark article))))
792 (defun gnus-summary-supersede-article ()
793 "Compose an article that will supersede a previous article.
794 This is done simply by taking the old article and adding a Supersedes
795 header line with the old Message-ID."
797 (let ((article (gnus-summary-article-number)))
798 (gnus-setup-message 'reply-yank
799 (gnus-summary-select-article t)
800 (set-buffer gnus-original-article-buffer)
804 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
806 (set-buffer ,gnus-summary-buffer)
807 (gnus-cache-possibly-remove-article ,article nil nil nil t)
808 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
809 message-send-actions))))
813 (defun gnus-copy-article-buffer (&optional article-buffer yank-string)
814 ;; make a copy of the article buffer with all text properties removed
815 ;; this copy is in the buffer gnus-article-copy.
816 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
817 ;; this buffer should be passed to all mail/news reply/post routines.
818 (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
819 (let ((article-buffer (or article-buffer gnus-article-buffer))
821 (if (not (and (get-buffer article-buffer)
822 (gnus-buffer-exists-p article-buffer)))
823 (error "Can't find any article buffer")
825 (set-buffer article-buffer)
826 (let ((gnus-newsgroup-charset (or gnus-article-charset
827 gnus-newsgroup-charset))
828 (gnus-newsgroup-ignored-charsets
829 (or gnus-article-ignored-charsets
830 gnus-newsgroup-ignored-charsets)))
832 ;; Copy over the (displayed) article buffer, delete
833 ;; hidden text and remove text properties.
835 (let ((inhibit-read-only t))
836 (copy-to-buffer gnus-article-copy (point-min) (point-max))
837 (set-buffer gnus-article-copy)
840 (delete-region (point) (point-max))
841 (insert yank-string))
842 ;; Encode bitmap smileys to ordinary text.
843 ;; Possibly, the original text might be restored.
844 (static-unless (featurep 'xemacs)
845 (when (featurep 'smiley-mule)
846 (smiley-encode-buffer)))
847 (gnus-article-delete-text-of-type 'annotation)
848 (gnus-remove-text-with-property 'gnus-prev)
849 (gnus-remove-text-with-property 'gnus-next)
850 (gnus-remove-text-with-property 'gnus-decoration)
851 (gnus-remove-text-with-property 'x-face-mule-bitmap-image)
854 (static-if (featurep 'xemacs)
855 ;; Revome smiley extents for (possibly) XEmacs 21.1.
857 (buffer-substring-no-properties (point-min)
859 (buffer-substring-no-properties (point-min) (point-max)))
861 ;; Find the original headers.
862 (set-buffer gnus-original-article-buffer)
863 (goto-char (point-min))
864 (while (looking-at message-unix-mail-delimiter)
867 end (or (message-goto-body) beg))
868 ;; Delete the headers from the displayed articles.
869 (set-buffer gnus-article-copy)
870 (delete-region (goto-char (point-min))
871 (or (message-goto-body) (point-max)))
872 ;; Insert the original article headers.
873 (insert-buffer-substring gnus-original-article-buffer beg end)
875 (let ((gnus-article-decode-hook
876 (delq 'article-decode-charset
877 (copy-sequence gnus-article-decode-hook))))
878 ;; Needed for T-gnus.
879 (add-hook 'gnus-article-decode-hook
880 'article-decode-encoded-words)
881 (run-hooks 'gnus-article-decode-hook)))))
884 (defun gnus-post-news (post &optional group header article-buffer yank subject
887 (gnus-copy-article-buffer))
888 (let ((gnus-article-reply (and article-buffer (gnus-summary-article-number)))
889 (add-to-list gnus-add-to-list))
890 (gnus-setup-message (cond (yank 'reply-yank)
891 (article-buffer 'reply)
893 (let* ((group (or group gnus-newsgroup-name))
894 (charset (gnus-group-name-charset nil group))
896 to-address to-group mailing-list to-list
899 (setq to-address (gnus-parameter-to-address group)
900 to-group (gnus-group-find-parameter group 'to-group)
901 to-list (gnus-parameter-to-list group)
902 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
903 mailing-list (when gnus-mailing-list-groups
904 (string-match gnus-mailing-list-groups group))
905 group (gnus-group-name-decode (gnus-group-real-name group)
907 (if (or (and to-group
908 (gnus-news-group-p to-group))
911 (and (gnus-news-group-p
912 (or pgroup gnus-newsgroup-name)
913 (or header gnus-current-article))
919 (message-news (or to-group group))
920 (set-buffer gnus-article-copy)
921 (gnus-msg-treat-broken-reply-to)
922 (message-followup (if (or newsgroup-p force-news)
923 (if (save-restriction
924 (article-narrow-to-head)
925 (message-fetch-field "newsgroups"))
932 (message-mail (or to-address to-list))
933 ;; Arrange for mail groups that have no `to-address' to
934 ;; get that when the user sends off the mail.
935 (when (and (not to-list)
938 (push (list 'gnus-inews-add-to-address pgroup)
939 message-send-actions)))
940 (set-buffer gnus-article-copy)
941 (gnus-msg-treat-broken-reply-to)
942 (message-wide-reply to-address)))
944 (gnus-inews-yank-articles yank))))))
946 (defun gnus-msg-treat-broken-reply-to (&optional force)
947 "Remove the Reply-to header iff broken-reply-to."
949 (gnus-group-find-parameter
950 gnus-newsgroup-name 'broken-reply-to))
952 (message-narrow-to-head)
953 (message-remove-header "reply-to"))))
955 (defun gnus-post-method (arg group &optional silent)
956 "Return the posting method based on GROUP and ARG.
957 If SILENT, don't prompt the user."
958 (let ((gnus-post-method (or (gnus-parameter-post-method group)
960 (group-method (gnus-find-method-for-group group)))
962 ;; If the group-method is nil (which shouldn't happen) we use
963 ;; the default method.
965 (or (and (listp gnus-post-method) ;If not current/native/nil
966 (not (listp (car gnus-post-method))) ; and not a list of methods
967 gnus-post-method) ;then use it.
969 message-post-method))
970 ;; We want the inverse of the default
971 ((and arg (not (eq arg 0)))
972 (if (eq gnus-post-method 'current)
975 ;; We query the user for a post method.
977 (and (listp gnus-post-method)
978 (listp (car gnus-post-method))))
980 ;; Collect all methods we know about.
982 (when (listp gnus-post-method)
983 (if (listp (car gnus-post-method))
985 (list gnus-post-method)))
986 gnus-secondary-select-methods
987 (mapcar 'cdr gnus-server-alist)
988 (mapcar 'car gnus-opened-servers)
989 (list gnus-select-method)
990 (list group-method)))
991 method-alist post-methods method)
992 ;; Weed out all mail methods.
994 (setq method (gnus-server-get-method "" (pop methods)))
995 (when (and (or (gnus-method-option-p method 'post)
996 (gnus-method-option-p method 'post-mail))
997 (not (member method post-methods)))
998 (push method post-methods)))
999 ;; Create a name-method alist.
1003 (if (equal (cadr m) "")
1004 (list (symbol-name (car m)) m)
1005 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m)))
1010 (setq gnus-last-posting-server
1012 gnus-last-posting-server)
1013 ;; Just use the last value.
1014 gnus-last-posting-server
1016 "Posting method: " method-alist nil t
1017 (cons (or gnus-last-posting-server "") 0))))
1019 ;; Override normal method.
1020 ((and (eq gnus-post-method 'current)
1021 (not (memq (car group-method) gnus-discouraged-post-methods))
1022 (gnus-get-function group-method 'request-post t))
1025 ;; Use gnus-post-method.
1026 ((listp gnus-post-method) ;A method...
1027 (assert (not (listp (car gnus-post-method)))) ;... not a list of methods.
1029 ;; Use the normal select method (nil or native).
1030 (t gnus-select-method))))
1033 (defun gnus-message-make-user-agent (&optional include-mime-info max-column
1035 "Return a user-agent info. If INCLUDE-MIME-INFO is non-nil and the
1036 variable `mime-edit-user-agent-value' is bound, the value will be
1037 included in the return value. If MAX-COLUMN is specified, the return
1038 value will be folded up as it were filled. NEWLINE-PRODUCT specifies
1039 whether a newline should be inserted in front of each product-token.
1040 If the value is t or `hard', it works strictly. Otherwise, if it is
1041 non-nil (e.g. `soft'), it works semi-strictly.
1043 Here is an example of how to use this function:
1045 \(add-hook 'gnus-message-setup-hook
1047 (setq message-user-agent nil)
1050 (message-narrow-to-headers)
1051 (goto-char (point-max))
1052 (insert \"User-Agent: \"
1053 (gnus-message-make-user-agent t 76 'soft)
1056 (let ((user-agent (if (and include-mime-info
1057 (boundp 'mime-edit-user-agent-value))
1058 (concat (gnus-extended-version)
1060 mime-edit-user-agent-value)
1061 (gnus-extended-version))))
1063 (unless (natnump max-column)
1064 (setq max-column 76))
1066 (set-buffer-multibyte t)
1067 (insert (mapconcat 'identity (split-string user-agent) " "))
1068 (goto-char (point-min))
1070 start agent agents width element swidth)
1071 (while (re-search-forward "\\([^ ]+\\) ?" nil t)
1072 (setq start (match-beginning 0))
1073 (if (eq (char-after start) ?\()
1077 (push (buffer-substring start (point)) agent))
1079 (push (nreverse agent) agents))
1080 (setq agent (list (match-string 1)))))
1082 (push (nreverse agent) agents))
1083 (setq agents (nreverse agents))
1084 (if (> (+ 12 (string-width (caar agents))) max-column)
1085 (setq user-agent "\n"
1090 (setq agent (car agents)
1091 agents (cdr agents))
1092 (when (and (not bol)
1093 (or (memq newline-product '(t hard))
1094 (and newline-product
1096 (string-width (mapconcat 'identity
1099 (setq user-agent (concat user-agent "\n")
1103 (setq element (car agent)
1104 swidth (string-width element)
1107 (setq user-agent (if (member user-agent '("" "\n"))
1108 (concat user-agent element)
1109 (concat user-agent " " element))
1110 width (+ width 1 swidth)
1112 (if (> (+ width 1 swidth) max-column)
1113 (setq user-agent (concat user-agent "\n " element)
1115 (setq user-agent (concat user-agent " " element)
1116 width (+ width 1 swidth)))))))))
1121 ;;; Gnus Mail Functions
1124 ;;; Mail reply commands of Gnus summary mode
1126 (defun gnus-summary-reply (&optional yank wide very-wide)
1127 "Start composing a mail reply to the current message.
1128 If prefix argument YANK is non-nil, the original article is yanked
1130 If WIDE, make a wide reply.
1131 If VERY-WIDE, make a very wide reply."
1133 (list (and current-prefix-arg
1134 (gnus-summary-work-articles 1))))
1135 ;; Allow user to require confirmation before replying by mail to the
1136 ;; author of a news article.
1137 (when (or (not (gnus-news-group-p gnus-newsgroup-name))
1138 (not gnus-confirm-mail-reply-to-news)
1139 (y-or-n-p "Really reply by mail to article author? "))
1141 (if (listp (car yank))
1144 (gnus-article-reply (or article (gnus-summary-article-number)))
1146 ;; Stripping headers should be specified with mail-yank-ignored-headers.
1148 (gnus-summary-goto-subject article))
1149 (gnus-setup-message (if yank 'reply-yank 'reply)
1151 (gnus-summary-select-article)
1152 (dolist (article very-wide)
1153 (gnus-summary-select-article nil nil nil article)
1155 (set-buffer (gnus-copy-article-buffer))
1156 (gnus-msg-treat-broken-reply-to)
1158 (message-narrow-to-head)
1159 (setq headers (concat headers (buffer-string)))))))
1160 (set-buffer (gnus-copy-article-buffer))
1161 (gnus-msg-treat-broken-reply-to gnus-msg-force-broken-reply-to)
1163 (message-narrow-to-head)
1167 (goto-char (point-max)))
1168 (message-reply nil wide)
1170 (gnus-inews-yank-articles yank))
1171 (gnus-summary-handle-replysign)))))
1173 (defun gnus-summary-handle-replysign ()
1174 "Check the various replysign variables and take action accordingly."
1175 (when nil;;(or gnus-message-replysign gnus-message-replyencrypt)
1176 (let (signed encrypted)
1178 (set-buffer gnus-article-buffer)
1179 (setq signed (memq 'signed gnus-article-wash-types))
1180 (setq encrypted (memq 'encrypted gnus-article-wash-types)))
1181 (cond ((and gnus-message-replyencrypt encrypted)
1182 (mml-secure-message mml-default-encrypt-method
1183 (if gnus-message-replysignencrypted
1186 ((and gnus-message-replysign signed)
1187 (mml-secure-message mml-default-sign-method 'sign))))))
1189 (defun gnus-summary-reply-with-original (n &optional wide)
1190 "Start composing a reply mail to the current message.
1191 The original article will be yanked."
1193 (gnus-summary-reply (gnus-summary-work-articles n) wide))
1195 (defun gnus-summary-reply-broken-reply-to (&optional yank wide very-wide)
1196 "Like `gnus-summary-reply' except removing reply-to field.
1197 If prefix argument YANK is non-nil, the original article is yanked
1199 If WIDE, make a wide reply.
1200 If VERY-WIDE, make a very wide reply."
1202 (list (and current-prefix-arg
1203 (gnus-summary-work-articles 1))))
1204 (let ((gnus-msg-force-broken-reply-to t))
1205 (gnus-summary-reply yank wide very-wide)))
1207 (defun gnus-summary-reply-broken-reply-to-with-original (n &optional wide)
1208 "Like `gnus-summary-reply-with-original' except removing reply-to field.
1209 The original article will be yanked."
1211 (gnus-summary-reply-broken-reply-to (gnus-summary-work-articles n) wide))
1213 (defun gnus-summary-wide-reply (&optional yank)
1214 "Start composing a wide reply mail to the current message.
1215 If prefix argument YANK is non-nil, the original article is yanked
1218 (list (and current-prefix-arg
1219 (gnus-summary-work-articles 1))))
1220 (gnus-summary-reply yank t))
1222 (defun gnus-summary-wide-reply-with-original (n)
1223 "Start composing a wide reply mail to the current message.
1224 The original article will be yanked."
1226 (gnus-summary-reply-with-original n t))
1228 (defun gnus-summary-very-wide-reply (&optional yank)
1229 "Start composing a very wide reply mail to the current message.
1230 If prefix argument YANK is non-nil, the original article is yanked
1233 (list (and current-prefix-arg
1234 (gnus-summary-work-articles 1))))
1235 (gnus-summary-reply yank t (gnus-summary-work-articles yank)))
1237 (defun gnus-summary-very-wide-reply-with-original (n)
1238 "Start composing a very wide reply mail to the current message.
1239 The original article will be yanked."
1242 (gnus-summary-work-articles n) t (gnus-summary-work-articles n)))
1244 (defun gnus-summary-mail-forward (&optional full-headers post)
1245 "Forward the current message(s) to another user.
1246 If process marks exist, forward all marked messages;
1247 If FULL-HEADERS (the prefix), include full headers when forwarding.
1249 Note that this function definition for T-gnus is totally different
1250 from the original Gnus."
1252 (if (null (cdr (gnus-summary-work-articles nil)))
1253 (gnus-setup-message 'forward
1254 (gnus-summary-select-article)
1255 (let ((charset default-mime-charset))
1256 (set-buffer gnus-original-article-buffer)
1257 (make-local-variable 'default-mime-charset)
1258 (setq default-mime-charset charset))
1259 (let ((message-included-forward-headers
1260 (if full-headers "" message-included-forward-headers)))
1261 (message-forward post)))
1262 (gnus-summary-digest-mail-forward nil post)))
1264 (defun gnus-summary-digest-mail-forward (&optional n post)
1265 "Digests and forwards all articles in this series.
1266 If N is a positive number, forward the N next articles.
1267 If N is a negative number, forward the N previous articles.
1268 If N is nil and any articles have been marked with the process mark,
1269 forward those articles instead.
1270 Optional POST will use news to forward instead of mail."
1272 (let ((articles (gnus-summary-work-articles n))
1273 (topics "Topics:\n")
1274 subject article frame)
1275 (when (car articles)
1276 (gnus-setup-message 'forward
1277 (gnus-summary-select-article)
1279 (setq articles (sort articles '<)
1280 subject "Digested Articles")
1281 (with-current-buffer gnus-original-article-buffer
1282 (setq subject (message-make-forward-subject))))
1284 (message-news nil subject)
1285 (message-mail nil subject))
1286 (when (and message-use-multi-frames (cdr articles))
1287 (setq frame (window-frame (get-buffer-window (current-buffer)))))
1289 (while (setq article (pop articles))
1290 (save-window-excursion
1291 (set-buffer gnus-summary-buffer)
1292 (gnus-summary-select-article nil nil nil article)
1293 (setq topics (concat topics " "
1294 (mail-header-subject gnus-current-headers)
1296 (gnus-summary-remove-process-mark article))
1298 (select-frame frame))
1299 (insert (mime-make-tag "message" "rfc822") "\n")
1300 (narrow-to-region (point) (point))
1301 (insert-buffer-substring gnus-original-article-buffer)
1303 (article-narrow-to-head)
1304 (message-remove-header message-included-forward-headers t nil t))
1305 (goto-char (point-max))
1311 (mime-edit-enclose-digest-region (point)(mark t))))))
1313 (defun gnus-summary-digest-post-forward (&optional n)
1314 "Digest and forwards all articles in this series to a newsgroup.
1315 If N is a positive number, forward the N next articles.
1316 If N is a negative number, forward the N previous articles.
1317 If N is nil and any articles have been marked with the process mark,
1318 forward those articles instead."
1320 (gnus-summary-digest-mail-forward n t))
1322 (defun gnus-summary-resend-message (address n)
1323 "Resend the current article to ADDRESS."
1325 (list (message-read-from-minibuffer
1326 "Resend message(s) to: "
1327 (when (and gnus-summary-resend-default-address
1328 (gnus-buffer-live-p gnus-original-article-buffer))
1329 ;; If some other article is currently selected, the
1330 ;; initial-contents is wrong. Whatever, it is just the
1331 ;; initial-contents.
1332 (with-current-buffer gnus-original-article-buffer
1333 (nnmail-fetch-field "to"))))
1334 current-prefix-arg))
1335 (let ((articles (gnus-summary-work-articles n))
1337 (while (setq article (pop articles))
1338 (gnus-summary-select-article nil nil nil article)
1340 (set-buffer gnus-original-article-buffer)
1341 (message-resend address))
1342 (gnus-summary-mark-article-as-forwarded article))))
1344 ;; From: Matthieu Moy <Matthieu.Moy@imag.fr>
1345 (defun gnus-summary-resend-message-edit ()
1346 "Resend an article that has already been sent.
1347 A new buffer will be created to allow the user to modify body and
1348 contents of the message, and then, everything will happen as when
1349 composing a new message."
1351 (let ((article (gnus-summary-article-number)))
1352 (gnus-setup-message 'reply-yank
1353 (gnus-summary-select-article t)
1354 (set-buffer gnus-original-article-buffer)
1355 (let ((cur (current-buffer))
1356 (to (message-fetch-field "to")))
1357 ;; Get a normal message buffer.
1358 (message-pop-to-buffer (message-buffer-name "Resend" to))
1359 (insert-buffer-substring cur)
1361 ;; T-gnus change: Use MIME-Edit to recompose a message.
1363 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
1364 (fset 'mime-edit-decode-single-part-in-buffer
1365 (lambda (&rest args)
1366 (if (let ((content-type (car args)))
1367 (and (eq 'message (mime-content-type-primary-type
1369 (eq 'rfc822 (mime-content-type-subtype
1371 (setcar (cdr args) 'not-decode-text))
1374 (mime-edit-again nil t)
1375 (fset 'mime-edit-decode-single-part-in-buffer ofn)))
1376 (message-narrow-to-head-1)
1377 (insert "From: " (message-make-from) "\n")
1378 (while (re-search-forward "^From:" nil t)
1380 (insert "Original-"))
1381 (message-remove-header "^>From[\t ]" t)
1383 ;; Gnus will generate a new one when sending.
1384 (message-remove-header "Message-ID")
1385 (message-remove-header message-ignored-resent-headers t)
1386 ;; Remove unwanted headers.
1387 (goto-char (point-max))
1388 (insert mail-header-separator)
1389 (goto-char (point-min))
1390 (re-search-forward "^To:\\|^Newsgroups:" nil 'move)
1394 (defun gnus-summary-post-forward (&optional full-headers)
1395 "Forward the current article to a newsgroup.
1396 If FULL-HEADERS (the prefix), include full headers when forwarding."
1398 (gnus-summary-mail-forward full-headers t))
1400 (defvar gnus-nastygram-message
1401 "The following article was inappropriately posted to %s.\n\n"
1402 "Format string to insert in nastygrams.
1403 The current group name will be inserted at \"%s\".")
1405 (defun gnus-summary-mail-nastygram (n)
1406 "Send a nastygram to the author of the current article."
1408 (when (or gnus-expert-user
1410 "Really send a nastygram to the author of the current article? "))
1411 (let ((group gnus-newsgroup-name))
1412 (gnus-summary-reply-with-original n)
1413 (set-buffer gnus-message-buffer)
1415 (insert (format gnus-nastygram-message group))
1416 (message-send-and-exit))))
1418 (defun gnus-summary-mail-crosspost-complaint (n)
1419 "Send a complaint about crossposting to the current article(s)."
1421 (let ((articles (gnus-summary-work-articles n))
1423 (while (setq article (pop articles))
1424 (set-buffer gnus-summary-buffer)
1425 (gnus-summary-goto-subject article)
1426 (let ((group (gnus-group-real-name gnus-newsgroup-name))
1427 newsgroups followup-to)
1428 (gnus-summary-select-article)
1429 (set-buffer gnus-original-article-buffer)
1430 (if (and (<= (length (message-tokenize-header
1432 (mail-fetch-field "newsgroups"))
1435 (or (not (setq followup-to (mail-fetch-field "followup-to")))
1436 (not (member group (message-tokenize-header
1437 followup-to ", ")))))
1439 (gnus-message 1 "Followup-to restricted")
1440 (gnus-message 1 "Not a crossposted article"))
1441 (set-buffer gnus-summary-buffer)
1442 (gnus-summary-reply-with-original 1)
1443 (set-buffer gnus-message-buffer)
1445 (insert (format gnus-crosspost-complaint newsgroups group))
1446 (message-goto-subject)
1447 (re-search-forward " *$")
1448 (replace-match " (crosspost notification)" t t)
1449 (gnus-deactivate-mark)
1450 (when (gnus-y-or-n-p "Send this complaint? ")
1451 (message-send-and-exit)))))))
1453 (defun gnus-mail-parse-comma-list ()
1456 (skip-chars-forward " ")
1459 (skip-chars-forward "^,")
1464 (narrow-to-region beg (point))
1467 (while (search-forward "\"" nil t)
1471 (skip-chars-forward ",")
1472 (skip-chars-forward "^,"))
1473 (skip-chars-backward " ")
1474 (push (buffer-substring beg (point))
1476 (skip-chars-forward "^,")
1477 (skip-chars-forward ", "))
1480 (defun gnus-inews-add-to-address (group)
1481 (let ((to-address (mail-fetch-field "to")))
1482 (when (and to-address
1484 ;; This mail group doesn't have a `to-list', so we add one
1486 (when (gnus-y-or-n-p
1487 (format "Do you want to add this as `to-list': %s " to-address))
1488 (gnus-group-add-parameter group (cons 'to-list to-address))))))
1490 (defun gnus-put-message ()
1491 "Put the current message in some group and return to Gnus."
1493 (let ((reply gnus-article-reply)
1494 (winconf gnus-prev-winconf)
1495 (group gnus-newsgroup-name))
1497 (not (gnus-group-read-only-p group)))
1498 (setq group (read-string "Put in group: " nil (gnus-writable-groups))))
1500 (when (gnus-gethash group gnus-newsrc-hashtb)
1501 (error "No such group: %s" group))
1505 (message-narrow-to-headers)
1506 (let ((gnus-deletable-headers nil))
1507 (message-generate-headers
1508 (if (message-news-p)
1509 message-required-news-headers
1510 message-required-mail-headers)))
1511 (goto-char (point-max))
1512 (if (string-match " " group)
1513 (insert "Gcc: \"" group "\"\n")
1514 (insert "Gcc: " group "\n"))
1517 (when (and (get-buffer gnus-group-buffer)
1518 (gnus-buffer-exists-p (car-safe reply))
1520 (set-buffer (car reply))
1521 (gnus-summary-mark-article-as-replied (cdr reply)))
1523 (set-window-configuration winconf))))
1525 (defun gnus-article-mail (yank)
1526 "Send a reply to the address near point.
1527 If YANK is non-nil, include the original article."
1531 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
1532 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
1534 (gnus-msg-mail address)
1536 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
1538 (defvar nntp-server-type)
1540 "Send a bug report to the Gnus maintainers."
1542 (unless (gnus-alive-p)
1543 (error "Gnus has been shut down"))
1544 (gnus-setup-message (if (message-mail-user-agent) 'message 'bug)
1545 (unless (message-mail-user-agent)
1546 (message-pop-to-buffer "*Gnus Bug*")
1547 (delete-other-windows)
1548 (when gnus-bug-create-help-buffer
1549 (switch-to-buffer "*Gnus Help Bug*")
1551 (insert gnus-bug-message)
1552 (goto-char (point-min))
1554 (set-buffer "*Gnus Bug*")))
1555 (let ((message-this-is-mail t))
1556 (message-setup `((To . ,gnus-maintainer) (Subject . ""))))
1557 (when gnus-bug-create-help-buffer
1558 (push `(gnus-bug-kill-buffer) message-send-actions))
1559 (goto-char (point-min))
1560 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
1562 (insert gnus-product-name " " gnus-version-number
1563 " (r" gnus-revision-number ") "
1564 "based on " gnus-original-product-name " v"
1565 gnus-original-version-number "\n"
1566 (emacs-version) "\n")
1567 (when (and (boundp 'nntp-server-type)
1568 (stringp nntp-server-type))
1569 (insert nntp-server-type))
1570 (insert "\n\n\n\n\n")
1571 (let (mime-content-types)
1572 (mime-edit-insert-tag
1573 "application" "emacs-lisp"
1574 "\nContent-Disposition: inline\nContent-Description: User settings"))
1575 (insert (with-temp-buffer
1578 (let (mime-content-types)
1579 (mime-edit-insert-tag "text" "plain"))
1580 (goto-char (point-min))
1581 (search-forward "Subject: " nil t)
1584 (defun gnus-bug-kill-buffer ()
1585 (when (get-buffer "*Gnus Help Bug*")
1586 (kill-buffer "*Gnus Help Bug*")))
1588 (defun gnus-summary-yank-message (buffer n)
1589 "Yank the current article into a composed message."
1591 (list (completing-read "Buffer: " (mapcar 'list (message-buffers)) nil t)
1592 current-prefix-arg))
1593 (when (gnus-buffer-live-p buffer)
1594 (let ((summary-frame (selected-frame))
1595 (message-frame (when (static-if (featurep 'xemacs)
1596 (device-on-window-system-p)
1598 (let ((window (get-buffer-window buffer t)))
1600 (window-frame window)))))
1601 (separator (concat "^" (regexp-quote mail-header-separator)
1603 (gnus-summary-iterate n
1604 (gnus-summary-select-article)
1605 (gnus-copy-article-buffer)
1606 (when (frame-live-p message-frame)
1607 (raise-frame message-frame)
1608 (select-frame message-frame))
1609 (with-current-buffer buffer
1610 (when (save-excursion
1612 (let (case-fold-search)
1613 (and (not (re-search-backward separator nil t))
1614 (re-search-forward separator nil t))))
1615 (goto-char (match-end 0)))
1616 (message-yank-buffer gnus-article-copy))
1617 (select-frame summary-frame))
1618 (when (frame-live-p message-frame)
1619 (select-frame message-frame)))))
1621 (defun gnus-debug ()
1622 "Attempts to go through the Gnus source file and report what variables have been changed.
1623 The source file has to be in the Emacs load path."
1625 (let ((files gnus-debug-files)
1627 file expr olist sym)
1628 (gnus-message 4 "Please wait while we snoop your variables...")
1629 ;; Go through all the files looking for non-default values for variables.
1632 (set-buffer (gnus-get-buffer-create " *gnus bug info*"))
1635 (when (and (setq file (locate-library (pop files)))
1636 (file-exists-p file))
1637 (insert-file-contents file)
1638 (goto-char (point-min))
1639 (if (not (re-search-forward "^;;* *Internal variables" nil t))
1640 (gnus-message 4 "Malformed sources in file %s" file)
1641 (narrow-to-region (point-min) (point))
1642 (goto-char (point-min))
1643 (while (setq expr (ignore-errors (read (current-buffer))))
1645 (and (memq (car expr) '(defvar defcustom defvoo))
1646 (stringp (nth 3 expr))
1647 (not (memq (nth 1 expr) gnus-debug-exclude-variables))
1648 (or (not (boundp (nth 1 expr)))
1649 (not (equal (eval (nth 2 expr))
1650 (symbol-value (nth 1 expr)))))
1651 (push (nth 1 expr) olist)))))))
1652 (kill-buffer (current-buffer)))
1653 (when (setq olist (nreverse olist))
1654 (insert ";----------------- Environment follows ------------------\n\n"))
1656 (if (boundp (car olist))
1658 (pp `(setq ,(car olist)
1659 ,(if (or (consp (setq sym (symbol-value (car olist))))
1661 (not (or (eq sym nil)
1663 (list 'quote (symbol-value (car olist)))
1664 (symbol-value (car olist))))
1667 (format "(setq %s 'whatever)\n" (car olist))))
1668 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
1669 (setq olist (cdr olist)))
1670 ;; Remove any control chars - they seem to cause trouble for some
1671 ;; mailers. (Byte-compiled output from the stuff above.)
1673 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
1674 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
1676 ;; Break MIME tags purposely.
1678 (while (re-search-forward mime-edit-tag-regexp nil t)
1679 (goto-char (1+ (match-beginning 0)))
1682 ;;; Treatment of rejected articles.
1685 (defun gnus-summary-resend-bounced-mail (&optional fetch)
1686 "Re-mail the current message.
1687 This only makes sense if the current message is a bounce message than
1688 contains some mail you have written which has been bounced back to
1690 If FETCH, try to fetch the article that this is a reply to, if indeed
1693 (gnus-summary-select-article t)
1694 (set-buffer gnus-original-article-buffer)
1695 (gnus-setup-message 'compose-bounce
1696 (let* ((references (mail-fetch-field "references"))
1697 (parent (and references (gnus-parent-id references))))
1699 ;; If there are references, we fetch the article we answered to.
1701 (gnus-summary-refer-article parent)
1702 (gnus-summary-show-all-headers)))))
1706 (defun gnus-inews-group-method (group)
1708 ;; If the group doesn't exist, we assume
1709 ;; it's an archive group...
1710 ((and (null (gnus-get-info group))
1711 (eq (car (gnus-server-to-method gnus-message-archive-method))
1712 (car (gnus-server-to-method (gnus-group-method group)))))
1713 gnus-message-archive-method)
1715 ((gnus-info-method (gnus-get-info group))
1716 (gnus-info-method (gnus-get-info group)))
1718 (t (gnus-server-to-method (gnus-group-method group)))))
1720 ;; Do Gcc handling, which copied the message over to some group.
1721 (defun gnus-inews-do-gcc (&optional gcc)
1725 (message-narrow-to-headers)
1726 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
1727 (coding-system-for-write 'raw-text)
1728 (output-coding-system 'raw-text)
1729 groups group method group-art
1730 mml-externalize-attachments)
1732 (message-remove-header "gcc")
1734 (setq groups (message-unquote-tokens
1735 (message-tokenize-header gcc " ,")))
1736 ;; Copy the article over to some group(s).
1737 (while (setq group (pop groups))
1738 (unless (gnus-check-server
1739 (setq method (gnus-inews-group-method group)))
1740 (error "Can't open server %s" (if (stringp method) method
1742 (unless (gnus-request-group group nil method)
1743 (gnus-request-create-group group method))
1744 (setq mml-externalize-attachments
1745 (if (stringp gnus-gcc-externalize-attachments)
1746 (string-match gnus-gcc-externalize-attachments group)
1747 gnus-gcc-externalize-attachments))
1749 (nnheader-set-temp-buffer " *acc*")
1750 (insert-buffer-substring message-encoding-buffer)
1751 (gnus-run-hooks 'gnus-before-do-gcc-hook)
1752 (goto-char (point-min))
1753 (when (re-search-forward
1754 (concat "^" (regexp-quote mail-header-separator) "$")
1756 (replace-match "" t t ))
1757 (unless (setq group-art
1758 (gnus-request-accept-article group method t t))
1759 (gnus-message 1 "Couldn't store article in group %s: %s"
1760 group (gnus-status-message method))
1762 (when (and group-art
1763 (or gnus-gcc-mark-as-read
1764 gnus-inews-mark-gcc-as-read))
1765 (gnus-group-mark-article-read group (cdr group-art)))
1766 (kill-buffer (current-buffer)))))))))
1768 (defun gnus-inews-insert-gcc ()
1769 "Insert Gcc headers based on `gnus-outgoing-message-group'."
1772 (message-narrow-to-headers)
1773 (let* ((group gnus-outgoing-message-group)
1775 ((gnus-functionp group)
1777 ((or (stringp group) (list group))
1782 (if (string-match " " gcc)
1783 (concat "\"" gcc "\"")
1785 (mapconcat (lambda (group)
1786 (if (string-match " " group)
1787 (concat "\"" group "\"")
1792 (defun gnus-inews-insert-archive-gcc (&optional group)
1793 "Insert the Gcc to say where the article is to be archived."
1794 (let* ((var gnus-message-archive-group)
1795 (group (or group gnus-newsgroup-name ""))
1797 (and gnus-newsgroup-name
1798 (not (equal gnus-newsgroup-name ""))
1799 (gnus-group-find-parameter
1800 gnus-newsgroup-name 'gcc-self)))
1804 ((null gnus-message-archive-method)
1808 ;; Just a single group.
1811 ;; We don't want this.
1813 ((and (listp var) (stringp (car var)))
1814 ;; A list of groups.
1816 ((gnus-functionp var)
1818 (funcall var group))
1820 ;; An alist of regexps/functions/forms.
1825 ((stringp (caar var))
1827 (when (string-match (caar var) group)
1829 ((gnus-functionp (car var))
1831 (funcall (car var) group))
1833 (eval (car var)))))))
1834 (setq var (cdr var)))
1837 (when (or groups gcc-self-val)
1838 (when (stringp groups)
1839 (setq groups (list groups)))
1842 (message-narrow-to-headers)
1843 (goto-char (point-max))
1846 ;; Use the `gcc-self' param value instead.
1849 (if (stringp gcc-self-val)
1850 (if (string-match " " gcc-self-val)
1851 (concat "\"" gcc-self-val "\"")
1853 (if (string-match " " group)
1854 (concat "\"" group "\"")
1856 (if (not (eq gcc-self-val 'none))
1861 ;; Use the list of groups.
1862 (while (setq name (pop groups))
1863 (let ((str (if (string-match ":" name)
1865 (gnus-group-prefixed-name
1866 name gnus-message-archive-method))))
1867 (insert (if (string-match " " str)
1868 (concat "\"" str "\"")
1876 (defun gnus-configure-posting-styles (&optional group-name)
1877 "Configure posting styles according to `gnus-posting-styles'."
1878 (unless gnus-inhibit-posting-styles
1879 (let ((group (or group-name gnus-newsgroup-name ""))
1880 (styles gnus-posting-styles)
1881 style match variable attribute value v results
1882 filep name address element)
1883 ;; If the group has a posting-style parameter, add it at the end with a
1884 ;; regexp matching everything, to be sure it takes precedence over all
1886 (when gnus-newsgroup-name
1887 (let ((tmp-style (gnus-group-find-parameter group 'posting-style t)))
1889 (setq styles (append styles (list (cons ".*" tmp-style)))))))
1890 ;; Go through all styles and look for matches.
1891 (dolist (style styles)
1892 (setq match (pop style))
1893 (goto-char (point-min))
1896 ;; Regexp string match on the group name.
1897 (string-match match group))
1899 ;; Obsolete format of header match.
1900 (and (gnus-buffer-live-p gnus-article-copy)
1901 (with-current-buffer gnus-article-copy
1902 (let ((header (message-fetch-field (pop style))))
1904 (string-match (pop style) header))))))
1905 ((or (symbolp match)
1906 (gnus-functionp match))
1908 ((gnus-functionp match)
1909 ;; Function to be called.
1912 ;; Variable to be checked.
1913 (symbol-value match))))
1916 ((eq (car match) 'header)
1917 ;; New format of header match.
1918 (and (gnus-buffer-live-p gnus-article-copy)
1919 (with-current-buffer gnus-article-copy
1920 (let ((header (message-fetch-field (nth 1 match))))
1922 (string-match (nth 2 match) header))))))
1924 ;; This is a form to be evaled.
1926 ;; We have a match, so we set the variables.
1927 (dolist (attribute style)
1928 (setq element (pop attribute)
1933 ((eq (car attribute) ':file)
1936 ((eq (car attribute) :value)
1940 ;; We get the value.
1945 ((or (symbolp value)
1946 (gnus-functionp value))
1947 (cond ((gnus-functionp value)
1950 (symbol-value value))))
1953 ;; Translate obsolescent value.
1955 ((eq element 'signature-file)
1956 (setq element 'signature
1958 ((eq element 'x-face-file)
1959 (setq element 'x-face
1961 ;; Get the contents of file elems.
1963 (setq v (with-temp-buffer
1964 (insert-file-contents v)
1965 (goto-char (point-max))
1969 (setq results (delq (assoc element results) results))
1970 (push (cons element v) results))))
1971 ;; Now we have all the styles, so we insert them.
1972 (setq name (assq 'name results)
1973 address (assq 'address results))
1974 (setq results (delq name (delq address results)))
1975 ;; make-local-hook is not obsolete in Emacs 20 or XEmacs.
1976 (make-local-hook 'message-setup-hook)
1977 (dolist (result results)
1978 (add-hook 'message-setup-hook
1980 ((eq 'eval (car result))
1982 ((eq 'body (car result))
1986 (insert ,(cdr result)))))
1987 ((eq 'signature (car result))
1988 (set (make-local-variable 'message-signature) nil)
1989 (set (make-local-variable 'message-signature-file) nil)
1990 (if (not (cdr result))
1994 (let ((message-signature ,(cdr result)))
1995 (when message-signature
1996 (message-insert-signature)))))))
1999 (if (symbolp (car result))
2000 (capitalize (symbol-name (car result)))
2004 (message-remove-header ,header)
2005 (let ((value ,(cdr result)))
2008 (insert ,header ": " value "\n"))))))))
2010 (when (or name address)
2011 (add-hook 'message-setup-hook
2013 (set (make-local-variable 'user-mail-address)
2014 ,(or (cdr address) user-mail-address))
2015 (let ((user-full-name ,(or (cdr name) (user-full-name)))
2017 ,(or (cdr address) user-mail-address)))
2019 (message-remove-header "From")
2021 (insert "From: " (message-make-from) "\n"))))
2025 ;;; @ for MIME Edit mode
2028 (defun gnus-maybe-setup-default-charset ()
2030 (and (boundp 'gnus-summary-buffer)
2031 (buffer-live-p gnus-summary-buffer)
2033 (set-buffer gnus-summary-buffer)
2034 default-mime-charset))))
2037 (make-local-variable 'default-mime-charset)
2038 (setq default-mime-charset charset)
2042 ;;; @ for MIME view mode
2045 (defun gnus-following-method (buf)
2046 (gnus-setup-message 'reply-yank
2048 (if (message-news-p)
2050 (message-reply nil 'wide))
2051 (let ((message-reply-buffer buf))
2052 (message-yank-original))
2053 (message-goto-body))
2057 ;;; Allow redefinition of functions.
2063 ;;; gnus-msg.el ends here