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 (defcustom gnus-group-posting-charset-alist
169 '(("^\\(no\\|fr\\)\\.[^,]*\\(,[ \t\n]*\\(no\\|fr\\)\\.[^,]*\\)*$" iso-8859-1 (iso-8859-1))
170 ("^\\(fido7\\|relcom\\)\\.[^,]*\\(,[ \t\n]*\\(fido7\\|relcom\\)\\.[^,]*\\)*$" koi8-r (koi8-r))
171 (message-this-is-mail nil nil)
172 (message-this-is-news nil t))
173 "Alist of regexps and permitted unencoded charsets for posting.
174 Each element of the alist has the form (TEST HEADER BODY-LIST), where
175 TEST is either a regular expression matching the newsgroup header or a
177 HEADER is the charset which may be left unencoded in the header (nil
178 means encode all charsets),
179 BODY-LIST is a list of charsets which may be encoded using 8bit
180 content-transfer encoding in the body, or one of the special values
181 nil (always encode using quoted-printable) or t (always use 8bit).
183 Note that any value other than nil for HEADER infringes some RFCs, so
184 use this option with care."
185 :type '(repeat (list :tag "Permitted unencoded charsets"
187 (regexp :tag "Group")
188 (const :tag "Mail message"
189 :value message-this-is-mail)
190 (const :tag "News article"
191 :value message-this-is-news))
192 (choice :tag "Header"
193 (const :tag "None" nil)
194 (symbol :tag "Charset"))
196 (const :tag "Any" :value t)
197 (const :tag "None" :value nil)
198 (repeat :tag "Charsets"
199 (symbol :tag "Charset")))))
200 :group 'gnus-charset)
202 (defcustom gnus-debug-files
203 '("gnus.el" "gnus-sum.el" "gnus-group.el"
204 "gnus-art.el" "gnus-start.el" "gnus-async.el"
205 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
206 "gnus-agent.el" "gnus-cache.el" "gnus-srvr.el"
207 "mm-util.el" "mm-decode.el" "nnmail.el" "nntp.el" "message.el")
208 "Files whose variables will be reported in `gnus-bug'."
211 :type '(repeat (string :tag "File")))
213 (defcustom gnus-debug-exclude-variables
214 '(mm-mime-mule-charset-alist
215 nnmail-split-fancy message-minibuffer-local-map)
216 "Variables that should not be reported in `gnus-bug'."
219 :type '(repeat (symbol :tag "Variable")))
221 (defcustom gnus-discouraged-post-methods
222 '(nndraft nnml nnimap nnmaildir nnmh nnfolder nndir)
223 "A list of back ends that are not used in \"real\" newsgroups.
224 This variable is used only when `gnus-post-method' is `current'."
226 :group 'gnus-group-foreign
227 :type '(repeat (symbol :tag "Back end")))
229 (defcustom gnus-message-replysign
231 "Automatically sign replys to signed messages.
232 See also the `mml-default-sign-method' variable."
236 (defcustom gnus-message-replyencrypt
238 "Automatically encrypt replys to encrypted messages.
239 See also the `mml-default-encrypt-method' variable."
243 (defcustom gnus-message-replysignencrypted
245 "Setting this causes automatically encryped messages to also be signed."
249 (defcustom gnus-confirm-mail-reply-to-news nil
250 "If non-nil, Gnus requests confirmation when replying to news.
251 This is done because new users often reply by mistake when reading
256 ;;; Internal variables.
258 (defvar gnus-inhibit-posting-styles nil
259 "Inhibit the use of posting styles.")
261 (defvar gnus-message-buffer "*Mail Gnus*")
262 (defvar gnus-article-copy nil)
263 (defvar gnus-check-before-posting nil)
264 (defvar gnus-last-posting-server nil)
265 (defvar gnus-message-group-art nil)
267 (defvar gnus-msg-force-broken-reply-to nil)
269 (defconst gnus-bug-message
270 (format "Sending a bug report to the Gnus Towers.
271 ========================================
273 This gnus is the %s%s.
274 If you think the bug is a Semi-gnus bug, send a bug report to Semi-gnus
275 Developers. (the addresses below are mailing list addresses)
277 ========================================
279 The buffer below is a mail buffer. When you press `C-c C-c', it will
280 be sent to the Gnus Bug Exterminators.
282 The thing near the bottom of the buffer is how the environment
283 settings will be included in the mail. Please do not delete that.
284 They will tell the Bug People what your environment is, so that it
285 will be easier to locate the bugs.
287 If you have found a bug that makes Emacs go \"beep\", set
288 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
289 and include the backtrace in your bug report.
291 Please describe the bug in annoying, painstaking detail.
293 Thank you for your help in stamping out bugs.
296 (if (string= gnus-product-name "Semi-gnus")
298 ", a modified version of Semi-gnus")))
301 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
302 (autoload 'news-setup "rnewspost")
303 (autoload 'news-reply-mode "rnewspost")
304 (autoload 'rmail-dont-reply-to "mail-utils")
305 (autoload 'rmail-output "rmailout"))
309 ;;; Gnus Posting Functions
312 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
313 "p" gnus-summary-post-news
314 "i" gnus-summary-news-other-window
315 "f" gnus-summary-followup
316 "F" gnus-summary-followup-with-original
317 "c" gnus-summary-cancel-article
318 "s" gnus-summary-supersede-article
319 "r" gnus-summary-reply
320 "y" gnus-summary-yank-message
321 "R" gnus-summary-reply-with-original
322 "w" gnus-summary-wide-reply
323 "W" gnus-summary-wide-reply-with-original
324 "v" gnus-summary-very-wide-reply
325 "V" gnus-summary-very-wide-reply-with-original
326 "n" gnus-summary-followup-to-mail
327 "N" gnus-summary-followup-to-mail-with-original
328 "m" gnus-summary-mail-other-window
329 "u" gnus-uu-post-news
330 "\M-c" gnus-summary-mail-crosspost-complaint
331 "Br" gnus-summary-reply-broken-reply-to
332 "BR" gnus-summary-reply-broken-reply-to-with-original
333 "om" gnus-summary-mail-forward
334 "op" gnus-summary-post-forward
335 "Om" gnus-summary-digest-mail-forward
336 "Op" gnus-summary-digest-post-forward)
338 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
339 "b" gnus-summary-resend-bounced-mail
340 ;; "c" gnus-summary-send-draft
341 "r" gnus-summary-resend-message
342 "e" gnus-summary-resend-message-edit)
344 ;;; Internal functions.
346 (defvar gnus-article-reply nil)
347 (defmacro gnus-setup-message (config &rest forms)
348 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
349 (buffer (make-symbol "gnus-setup-message-buffer"))
350 (article (make-symbol "gnus-setup-message-article"))
351 (group (make-symbol "gnus-setup-message-group")))
352 `(let ((,winconf (current-window-configuration))
353 (,buffer (buffer-name (current-buffer)))
354 (,article gnus-article-reply)
355 (,group gnus-newsgroup-name)
356 (message-header-setup-hook
357 (copy-sequence message-header-setup-hook))
358 (message-mode-hook (copy-sequence message-mode-hook))
359 (message-startup-parameter-alist
360 '((reply-buffer . gnus-copy-article-buffer)
361 (original-buffer . gnus-original-article-buffer)
362 (user-agent . Gnus))))
363 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
364 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
365 ;; #### FIXME: for a reason that I did not manage to identify yet,
366 ;; the variable `gnus-newsgroup-name' does not honor a dynamically
367 ;; scoped or setq'ed value from a caller like `C-u gnus-summary-mail'.
368 ;; After evaluation of @forms below, it gets the value we actually want
369 ;; to override, and the posting styles are used. For that reason, I've
370 ;; added an optional argument to `gnus-configure-posting-styles' to
371 ;; make sure that the correct value for the group name is used. -- drv
372 (add-hook 'message-mode-hook
374 (gnus-configure-posting-styles ,group)))
378 (gnus-inews-add-send-actions ,winconf ,buffer ,article ,config)
379 (gnus-inews-insert-draft-meta-information ,group ,article)
380 (setq gnus-message-buffer (current-buffer))
381 (set (make-local-variable 'gnus-message-group-art)
382 (cons ,group ,article))
383 (set (make-local-variable 'gnus-newsgroup-name) ,group)
384 (gnus-maybe-setup-default-charset)
385 (gnus-run-hooks 'gnus-message-setup-hook))
387 (gnus-configure-windows ,config t)
388 (run-hooks 'post-command-hook)
389 (set-buffer-modified-p nil))))
391 (defun gnus-inews-insert-draft-meta-information (group article)
394 (not (string= group ""))
395 (not (message-fetch-field gnus-draft-meta-information-header)))
396 (goto-char (point-min))
397 (insert gnus-draft-meta-information-header ": (\"" group "\" "
398 (if article (number-to-string
405 (defun gnus-msg-mail (&optional to subject other-headers continue
406 switch-action yank-action send-actions)
407 "Start editing a mail message to be sent.
408 Like `message-mail', but with Gnus paraphernalia, particularly the
409 Gcc: header for archiving purposes."
411 (let ((buf (current-buffer))
413 (gnus-setup-message 'message
414 (message-mail to subject other-headers continue
415 nil yank-action send-actions))
417 (setq mail-buf (current-buffer))
418 (switch-to-buffer buf)
419 (apply switch-action mail-buf nil)))
420 ;; COMPOSEFUNC should return t if succeed. Undocumented ???
423 (defvar save-selected-window-window)
426 (defun gnus-button-mailto (address)
428 (set-buffer (gnus-copy-article-buffer))
429 (gnus-setup-message 'message
430 (message-reply address))
431 (and (boundp 'save-selected-window-window)
432 (not (window-live-p save-selected-window-window))
433 (setq save-selected-window-window (selected-window))))
436 (defun gnus-button-reply (&optional to-address wide)
437 "Like `message-reply'."
439 (gnus-setup-message 'message
440 (message-reply to-address wide))
441 (and (boundp 'save-selected-window-window)
442 (not (window-live-p save-selected-window-window))
443 (setq save-selected-window-window (selected-window))))
446 (define-mail-user-agent 'gnus-user-agent
447 'gnus-msg-mail 'message-send-and-exit
448 'message-kill-buffer 'message-send-hook)
450 (defun gnus-setup-posting-charset (group)
451 (let ((alist gnus-group-posting-charset-alist)
452 (group (or group ""))
456 (while (setq elem (pop alist))
457 (when (or (and (stringp (car elem))
458 (string-match (car elem) group))
459 (and (gnus-functionp (car elem))
460 (funcall (car elem) group))
461 (and (symbolp (car elem))
462 (symbol-value (car elem))))
463 (throw 'found (cons (cadr elem) (caddr elem)))))))))
465 (defun gnus-inews-add-send-actions (winconf buffer article &optional config)
466 (make-local-hook 'message-sent-hook)
467 (add-hook 'message-sent-hook (if gnus-agent 'gnus-agent-possibly-do-gcc
468 'gnus-inews-do-gcc) nil t)
470 (make-local-hook 'message-header-hook)
471 (add-hook 'message-header-hook 'gnus-agent-possibly-save-gcc nil t))
472 (setq message-post-method
474 (gnus-post-method arg ,gnus-newsgroup-name)))
475 (setq message-user-agent (gnus-extended-version))
476 (when (not message-use-multi-frames)
478 `(set-window-configuration ,winconf) 'exit 'postpone 'kill))
480 `(when (gnus-buffer-exists-p ,buffer)
484 (if (eq config 'forward)
485 `(gnus-summary-mark-article-as-forwarded ',article)
486 `(gnus-summary-mark-article-as-replied ',article)))))
489 (put 'gnus-setup-message 'lisp-indent-function 1)
490 (put 'gnus-setup-message 'edebug-form-spec '(form body))
492 ;;; Post news commands of Gnus group mode and summary mode
494 (defun gnus-group-mail (&optional arg)
495 "Start composing a mail.
496 If ARG, use the group under the point to find a posting style.
497 If ARG is 1, prompt for a group name to find the posting style."
499 ;; We can't `let' gnus-newsgroup-name here, since that leads
500 ;; to local variables leaking.
501 (let ((group gnus-newsgroup-name)
502 ;; make sure last viewed article doesn't affect posting styles:
504 (buffer (current-buffer)))
507 (setq gnus-newsgroup-name
509 (if (= 1 (prefix-numeric-value arg))
510 (completing-read "Use posting style of group: "
511 gnus-active-hashtb nil
512 (gnus-read-active-file-p))
513 (gnus-group-group-name))
515 ;; #### see comment in gnus-setup-message -- drv
516 (gnus-setup-message 'message (message-mail)))
519 (setq gnus-newsgroup-name group)))))
521 (defun gnus-group-news (&optional arg)
522 "Start composing a news.
523 If ARG, post to group under point.
524 If ARG is 1, prompt for group name to post to.
526 This function prepares a news even when using mail groups. This is useful
527 for posting messages to mail groups without actually sending them over the
528 network. The corresponding backend must have a 'request-post method."
530 ;; We can't `let' gnus-newsgroup-name here, since that leads
531 ;; to local variables leaking.
532 (let ((group gnus-newsgroup-name)
533 ;; make sure last viewed article doesn't affect posting styles:
535 (buffer (current-buffer)))
538 (setq gnus-newsgroup-name
540 (if (= 1 (prefix-numeric-value arg))
541 (completing-read "Use group: "
542 gnus-active-hashtb nil
543 (gnus-read-active-file-p))
544 (gnus-group-group-name))
546 ;; #### see comment in gnus-setup-message -- drv
547 (gnus-setup-message 'message
548 (message-news (gnus-group-real-name gnus-newsgroup-name))))
551 (setq gnus-newsgroup-name group)))))
553 (defun gnus-group-post-news (&optional arg)
554 "Start composing a message (a news by default).
555 If ARG, post to group under point. If ARG is 1, prompt for group name.
556 Depending on the selected group, the message might be either a mail or
559 ;; Bind this variable here to make message mode hooks work ok.
560 (let ((gnus-newsgroup-name
562 (if (= 1 (prefix-numeric-value arg))
563 (completing-read "Newsgroup: " gnus-active-hashtb nil
564 (gnus-read-active-file-p))
565 (gnus-group-group-name))
567 ;; make sure last viewed article doesn't affect posting styles:
569 (gnus-post-news 'post gnus-newsgroup-name)))
571 (defun gnus-summary-mail-other-window (&optional arg)
572 "Start composing a mail in another window.
573 Use the posting of the current group by default.
574 If ARG, don't do that. If ARG is 1, prompt for group name to find the
577 ;; We can't `let' gnus-newsgroup-name here, since that leads
578 ;; to local variables leaking.
579 (let ((group gnus-newsgroup-name)
580 ;; make sure last viewed article doesn't affect posting styles:
582 (buffer (current-buffer)))
585 (setq gnus-newsgroup-name
587 (if (= 1 (prefix-numeric-value arg))
588 (completing-read "Use group: "
589 gnus-active-hashtb nil
590 (gnus-read-active-file-p))
592 gnus-newsgroup-name))
593 ;; #### see comment in gnus-setup-message -- drv
594 (gnus-setup-message 'message (message-mail)))
597 (setq gnus-newsgroup-name group)))))
599 (defun gnus-summary-news-other-window (&optional arg)
600 "Start composing a news in another window.
601 Post to the current group by default.
602 If ARG, don't do that. If ARG is 1, prompt for group name to post to.
604 This function prepares a news even when using mail groups. This is useful
605 for posting messages to mail groups without actually sending them over the
606 network. The corresponding backend must have a 'request-post method."
608 ;; We can't `let' gnus-newsgroup-name here, since that leads
609 ;; to local variables leaking.
610 (let ((group gnus-newsgroup-name)
611 ;; make sure last viewed article doesn't affect posting styles:
613 (buffer (current-buffer)))
616 (setq gnus-newsgroup-name
618 (if (= 1 (prefix-numeric-value arg))
619 (completing-read "Use group: "
620 gnus-active-hashtb nil
621 (gnus-read-active-file-p))
623 gnus-newsgroup-name))
624 ;; #### see comment in gnus-setup-message -- drv
625 (gnus-setup-message 'message
626 (message-news (gnus-group-real-name gnus-newsgroup-name))))
629 (setq gnus-newsgroup-name group)))))
631 (defun gnus-summary-post-news (&optional arg)
632 "Start composing a message. Post to the current group by default.
633 If ARG, don't do that. If ARG is 1, prompt for a group name to post to.
634 Depending on the selected group, the message might be either a mail or
637 ;; Bind this variable here to make message mode hooks work ok.
638 (let ((gnus-newsgroup-name
640 (if (= 1 (prefix-numeric-value arg))
641 (completing-read "Newsgroup: " gnus-active-hashtb nil
642 (gnus-read-active-file-p))
644 gnus-newsgroup-name))
645 ;; make sure last viewed article doesn't affect posting styles:
647 (gnus-post-news 'post gnus-newsgroup-name)))
650 (defun gnus-summary-followup (yank &optional force-news)
651 "Compose a followup to an article.
652 If prefix argument YANK is non-nil, the original article is yanked
654 YANK is a list of elements, where the car of each element is the
655 article number, and the two following numbers is the region to be
658 (list (and current-prefix-arg
659 (gnus-summary-work-articles 1))))
661 (gnus-summary-goto-subject
662 (if (listp (car yank))
665 (save-window-excursion
666 (gnus-summary-select-article))
667 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
668 (gnus-newsgroup-name gnus-newsgroup-name))
670 (gnus-post-news nil gnus-newsgroup-name
671 headers gnus-article-buffer
673 (gnus-summary-handle-replysign)))
675 (defun gnus-summary-followup-with-original (n &optional force-news)
676 "Compose a followup to an article and include the original article."
678 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
680 (defun gnus-summary-followup-to-mail (&optional arg)
681 "Followup to the current mail message via news."
683 (list (and current-prefix-arg
684 (gnus-summary-work-articles 1))))
685 (gnus-summary-followup arg t))
687 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
688 "Followup to the current mail message via news."
690 (gnus-summary-followup (gnus-summary-work-articles arg) t))
692 (defun gnus-inews-yank-articles (articles)
693 (let (beg article yank-string
694 (more-than-one (cdr articles))
695 (cur (current-buffer))
698 (while (setq article (pop articles))
699 (when (listp article)
700 (setq yank-string (nth 1 article)
701 article (nth 0 article)))
702 (save-window-excursion
703 (set-buffer gnus-summary-buffer)
704 (gnus-summary-select-article nil nil nil article)
705 (gnus-summary-remove-process-mark article))
707 ;; Gathering references.
709 (setq refs (message-list-references
711 (mail-header-references gnus-current-headers)
712 (mail-header-message-id gnus-current-headers)))
713 (when message-use-multi-frames
714 (when (setq window (get-buffer-window cur t))
715 (select-frame (window-frame window)))))
717 (gnus-copy-article-buffer nil yank-string)
718 (let ((message-reply-buffer gnus-article-copy)
719 (message-reply-headers
720 ;; The headers are decoded.
721 (with-current-buffer gnus-article-copy
723 (nnheader-narrow-to-headers)
724 (ietf-drums-unfold-fws)
725 (nnheader-parse-head t)))))
726 (message-yank-original)
727 (setq beg (or beg (mark t))))
732 ;; Replace with the gathered references.
736 (message-narrow-to-headers)
737 (let ((case-fold-search t))
738 (if (re-search-forward "^References:\\([\t ]+.+\n\\)+" nil t)
740 (goto-char (point-max))))
742 (list (or (assq 'References message-header-format-alist)
743 '(References . message-shorten-references)))
744 (list (cons 'References
745 (mapconcat 'identity (nreverse refs) " "))))
746 (backward-delete-char 1))
752 (defun gnus-summary-cancel-article (&optional n symp)
753 "Cancel an article you posted.
754 Uses the process-prefix convention. If given the symbolic
755 prefix `a', cancel using the standard posting method; if not
756 post using the current select method."
757 (interactive (gnus-interactive "P\ny"))
758 (let ((articles (gnus-summary-work-articles n))
761 (gnus-post-method (eq ',symp 'a) ,gnus-newsgroup-name)))
763 (while (setq article (pop articles))
764 (when (gnus-summary-select-article t nil nil article)
765 (when (gnus-eval-in-buffer-window gnus-article-buffer
767 (set-buffer gnus-original-article-buffer)
768 (message-cancel-news)))
769 (gnus-summary-mark-as-read article gnus-canceled-mark)
770 (gnus-cache-remove-article 1))
771 (gnus-article-hide-headers-if-wanted))
772 (gnus-summary-remove-process-mark article))))
774 (defun gnus-summary-supersede-article ()
775 "Compose an article that will supersede a previous article.
776 This is done simply by taking the old article and adding a Supersedes
777 header line with the old Message-ID."
779 (let ((article (gnus-summary-article-number)))
780 (gnus-setup-message 'reply-yank
781 (gnus-summary-select-article t)
782 (set-buffer gnus-original-article-buffer)
786 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
788 (set-buffer ,gnus-summary-buffer)
789 (gnus-cache-possibly-remove-article ,article nil nil nil t)
790 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
791 message-send-actions))))
795 (defun gnus-copy-article-buffer (&optional article-buffer yank-string)
796 ;; make a copy of the article buffer with all text properties removed
797 ;; this copy is in the buffer gnus-article-copy.
798 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
799 ;; this buffer should be passed to all mail/news reply/post routines.
800 (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
801 (let ((article-buffer (or article-buffer gnus-article-buffer))
803 (if (not (and (get-buffer article-buffer)
804 (gnus-buffer-exists-p article-buffer)))
805 (error "Can't find any article buffer")
807 (set-buffer article-buffer)
808 (let ((gnus-newsgroup-charset (or gnus-article-charset
809 gnus-newsgroup-charset))
810 (gnus-newsgroup-ignored-charsets
811 (or gnus-article-ignored-charsets
812 gnus-newsgroup-ignored-charsets)))
814 ;; Copy over the (displayed) article buffer, delete
815 ;; hidden text and remove text properties.
817 (let ((inhibit-read-only t))
818 (copy-to-buffer gnus-article-copy (point-min) (point-max))
819 (set-buffer gnus-article-copy)
822 (delete-region (point) (point-max))
823 (insert yank-string))
824 ;; Encode bitmap smileys to ordinary text.
825 ;; Possibly, the original text might be restored.
826 (static-unless (featurep 'xemacs)
827 (when (featurep 'smiley-mule)
828 (smiley-encode-buffer)))
829 (gnus-article-delete-text-of-type 'annotation)
830 (gnus-remove-text-with-property 'gnus-prev)
831 (gnus-remove-text-with-property 'gnus-next)
832 (gnus-remove-text-with-property 'gnus-decoration)
833 (gnus-remove-text-with-property 'x-face-mule-bitmap-image)
836 (static-if (featurep 'xemacs)
837 ;; Revome smiley extents for (possibly) XEmacs 21.1.
839 (buffer-substring-no-properties (point-min)
841 (buffer-substring-no-properties (point-min) (point-max)))
843 ;; Find the original headers.
844 (set-buffer gnus-original-article-buffer)
845 (goto-char (point-min))
846 (while (looking-at message-unix-mail-delimiter)
849 end (or (message-goto-body) beg))
850 ;; Delete the headers from the displayed articles.
851 (set-buffer gnus-article-copy)
852 (delete-region (goto-char (point-min))
853 (or (message-goto-body) (point-max)))
854 ;; Insert the original article headers.
855 (insert-buffer-substring gnus-original-article-buffer beg end)
857 (let ((gnus-article-decode-hook
858 (delq 'article-decode-charset
859 (copy-sequence gnus-article-decode-hook))))
860 ;; Needed for T-gnus.
861 (add-hook 'gnus-article-decode-hook
862 'article-decode-encoded-words)
863 (run-hooks 'gnus-article-decode-hook)))))
866 (defun gnus-post-news (post &optional group header article-buffer yank subject
869 (gnus-copy-article-buffer))
870 (let ((gnus-article-reply (and article-buffer (gnus-summary-article-number)))
871 (add-to-list gnus-add-to-list))
872 (gnus-setup-message (cond (yank 'reply-yank)
873 (article-buffer 'reply)
875 (let* ((group (or group gnus-newsgroup-name))
876 (charset (gnus-group-name-charset nil group))
878 to-address to-group mailing-list to-list
881 (setq to-address (gnus-parameter-to-address group)
882 to-group (gnus-group-find-parameter group 'to-group)
883 to-list (gnus-parameter-to-list group)
884 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
885 mailing-list (when gnus-mailing-list-groups
886 (string-match gnus-mailing-list-groups group))
887 group (gnus-group-name-decode (gnus-group-real-name group)
889 (if (or (and to-group
890 (gnus-news-group-p to-group))
893 (and (gnus-news-group-p
894 (or pgroup gnus-newsgroup-name)
895 (or header gnus-current-article))
901 (message-news (or to-group group))
902 (set-buffer gnus-article-copy)
903 (gnus-msg-treat-broken-reply-to)
904 (message-followup (if (or newsgroup-p force-news)
905 (if (save-restriction
906 (article-narrow-to-head)
907 (message-fetch-field "newsgroups"))
914 (message-mail (or to-address to-list))
915 ;; Arrange for mail groups that have no `to-address' to
916 ;; get that when the user sends off the mail.
917 (when (and (not to-list)
920 (push (list 'gnus-inews-add-to-address pgroup)
921 message-send-actions)))
922 (set-buffer gnus-article-copy)
923 (gnus-msg-treat-broken-reply-to)
924 (message-wide-reply to-address)))
926 (gnus-inews-yank-articles yank))))))
928 (defun gnus-msg-treat-broken-reply-to (&optional force)
929 "Remove the Reply-to header iff broken-reply-to."
931 (gnus-group-find-parameter
932 gnus-newsgroup-name 'broken-reply-to))
934 (message-narrow-to-head)
935 (message-remove-header "reply-to"))))
937 (defun gnus-post-method (arg group &optional silent)
938 "Return the posting method based on GROUP and ARG.
939 If SILENT, don't prompt the user."
940 (let ((gnus-post-method (or (gnus-parameter-post-method group)
942 (group-method (gnus-find-method-for-group group)))
944 ;; If the group-method is nil (which shouldn't happen) we use
945 ;; the default method.
947 (or (and (listp gnus-post-method) ;If not current/native/nil
948 (not (listp (car gnus-post-method))) ; and not a list of methods
949 gnus-post-method) ;then use it.
951 message-post-method))
952 ;; We want the inverse of the default
953 ((and arg (not (eq arg 0)))
954 (if (eq gnus-post-method 'current)
957 ;; We query the user for a post method.
959 (and (listp gnus-post-method)
960 (listp (car gnus-post-method))))
962 ;; Collect all methods we know about.
964 (when (listp gnus-post-method)
965 (if (listp (car gnus-post-method))
967 (list gnus-post-method)))
968 gnus-secondary-select-methods
969 (mapcar 'cdr gnus-server-alist)
970 (mapcar 'car gnus-opened-servers)
971 (list gnus-select-method)
972 (list group-method)))
973 method-alist post-methods method)
974 ;; Weed out all mail methods.
976 (setq method (gnus-server-get-method "" (pop methods)))
977 (when (and (or (gnus-method-option-p method 'post)
978 (gnus-method-option-p method 'post-mail))
979 (not (member method post-methods)))
980 (push method post-methods)))
981 ;; Create a name-method alist.
985 (if (equal (cadr m) "")
986 (list (symbol-name (car m)) m)
987 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m)))
992 (setq gnus-last-posting-server
994 gnus-last-posting-server)
995 ;; Just use the last value.
996 gnus-last-posting-server
998 "Posting method: " method-alist nil t
999 (cons (or gnus-last-posting-server "") 0))))
1001 ;; Override normal method.
1002 ((and (eq gnus-post-method 'current)
1003 (not (memq (car group-method) gnus-discouraged-post-methods))
1004 (gnus-get-function group-method 'request-post t))
1007 ;; Use gnus-post-method.
1008 ((listp gnus-post-method) ;A method...
1009 (assert (not (listp (car gnus-post-method)))) ;... not a list of methods.
1011 ;; Use the normal select method (nil or native).
1012 (t gnus-select-method))))
1015 (defun gnus-message-make-user-agent (&optional include-mime-info max-column
1017 "Return a user-agent info. If INCLUDE-MIME-INFO is non-nil and the
1018 variable `mime-edit-user-agent-value' is bound, the value will be
1019 included in the return value. If MAX-COLUMN is specified, the return
1020 value will be folded up as it were filled. NEWLINE-PRODUCT specifies
1021 whether a newline should be inserted in front of each product-token.
1022 If the value is t or `hard', it works strictly. Otherwise, if it is
1023 non-nil (e.g. `soft'), it works semi-strictly.
1025 Here is an example of how to use this function:
1027 \(add-hook 'gnus-message-setup-hook
1029 (setq message-user-agent nil)
1032 (message-narrow-to-headers)
1033 (goto-char (point-max))
1034 (insert \"User-Agent: \"
1035 (gnus-message-make-user-agent t 76 'soft)
1038 (let ((user-agent (if (and include-mime-info
1039 (boundp 'mime-edit-user-agent-value))
1040 (concat (gnus-extended-version)
1042 mime-edit-user-agent-value)
1043 (gnus-extended-version))))
1045 (unless (natnump max-column)
1046 (setq max-column 76))
1048 (set-buffer-multibyte t)
1049 (insert (mapconcat 'identity (split-string user-agent) " "))
1050 (goto-char (point-min))
1052 start agent agents width element swidth)
1053 (while (re-search-forward "\\([^ ]+\\) ?" nil t)
1054 (setq start (match-beginning 0))
1055 (if (eq (char-after start) ?\()
1059 (push (buffer-substring start (point)) agent))
1061 (push (nreverse agent) agents))
1062 (setq agent (list (match-string 1)))))
1064 (push (nreverse agent) agents))
1065 (setq agents (nreverse agents))
1066 (if (> (+ 12 (string-width (caar agents))) max-column)
1067 (setq user-agent "\n"
1072 (setq agent (car agents)
1073 agents (cdr agents))
1074 (when (and (not bol)
1075 (or (memq newline-product '(t hard))
1076 (and newline-product
1078 (string-width (mapconcat 'identity
1081 (setq user-agent (concat user-agent "\n")
1085 (setq element (car agent)
1086 swidth (string-width element)
1089 (setq user-agent (if (member user-agent '("" "\n"))
1090 (concat user-agent element)
1091 (concat user-agent " " element))
1092 width (+ width 1 swidth)
1094 (if (> (+ width 1 swidth) max-column)
1095 (setq user-agent (concat user-agent "\n " element)
1097 (setq user-agent (concat user-agent " " element)
1098 width (+ width 1 swidth)))))))))
1103 ;;; Gnus Mail Functions
1106 ;;; Mail reply commands of Gnus summary mode
1108 (defun gnus-summary-reply (&optional yank wide very-wide)
1109 "Start composing a mail reply to the current message.
1110 If prefix argument YANK is non-nil, the original article is yanked
1112 If WIDE, make a wide reply.
1113 If VERY-WIDE, make a very wide reply."
1115 (list (and current-prefix-arg
1116 (gnus-summary-work-articles 1))))
1117 ;; Allow user to require confirmation before replying by mail to the
1118 ;; author of a news article.
1119 (when (or (not (gnus-news-group-p gnus-newsgroup-name))
1120 (not gnus-confirm-mail-reply-to-news)
1121 (y-or-n-p "Really reply by mail to article author? "))
1123 (if (listp (car yank))
1126 (gnus-article-reply (or article (gnus-summary-article-number)))
1128 ;; Stripping headers should be specified with mail-yank-ignored-headers.
1130 (gnus-summary-goto-subject article))
1131 (gnus-setup-message (if yank 'reply-yank 'reply)
1133 (gnus-summary-select-article)
1134 (dolist (article very-wide)
1135 (gnus-summary-select-article nil nil nil article)
1137 (set-buffer (gnus-copy-article-buffer))
1138 (gnus-msg-treat-broken-reply-to)
1140 (message-narrow-to-head)
1141 (setq headers (concat headers (buffer-string)))))))
1142 (set-buffer (gnus-copy-article-buffer))
1143 (gnus-msg-treat-broken-reply-to gnus-msg-force-broken-reply-to)
1145 (message-narrow-to-head)
1149 (goto-char (point-max)))
1150 (message-reply nil wide)
1152 (gnus-inews-yank-articles yank))
1153 (gnus-summary-handle-replysign)))))
1155 (defun gnus-summary-handle-replysign ()
1156 "Check the various replysign variables and take action accordingly."
1157 (when nil;;(or gnus-message-replysign gnus-message-replyencrypt)
1158 (let (signed encrypted)
1160 (set-buffer gnus-article-buffer)
1161 (setq signed (memq 'signed gnus-article-wash-types))
1162 (setq encrypted (memq 'encrypted gnus-article-wash-types)))
1163 (cond ((and gnus-message-replysign signed)
1164 (mml-secure-message mml-default-sign-method 'sign))
1165 ((and gnus-message-replyencrypt encrypted)
1166 (mml-secure-message mml-default-encrypt-method
1167 (if gnus-message-replysignencrypted
1171 (defun gnus-summary-reply-with-original (n &optional wide)
1172 "Start composing a reply mail to the current message.
1173 The original article will be yanked."
1175 (gnus-summary-reply (gnus-summary-work-articles n) wide))
1177 (defun gnus-summary-reply-broken-reply-to (&optional yank wide very-wide)
1178 "Like `gnus-summary-reply' except removing reply-to field.
1179 If prefix argument YANK is non-nil, the original article is yanked
1181 If WIDE, make a wide reply.
1182 If VERY-WIDE, make a very wide reply."
1184 (list (and current-prefix-arg
1185 (gnus-summary-work-articles 1))))
1186 (let ((gnus-msg-force-broken-reply-to t))
1187 (gnus-summary-reply yank wide very-wide)))
1189 (defun gnus-summary-reply-broken-reply-to-with-original (n &optional wide)
1190 "Like `gnus-summary-reply-with-original' except removing reply-to field.
1191 The original article will be yanked."
1193 (gnus-summary-reply-broken-reply-to (gnus-summary-work-articles n) wide))
1195 (defun gnus-summary-wide-reply (&optional yank)
1196 "Start composing a wide reply mail to the current message.
1197 If prefix argument YANK is non-nil, the original article is yanked
1200 (list (and current-prefix-arg
1201 (gnus-summary-work-articles 1))))
1202 (gnus-summary-reply yank t))
1204 (defun gnus-summary-wide-reply-with-original (n)
1205 "Start composing a wide reply mail to the current message.
1206 The original article will be yanked."
1208 (gnus-summary-reply-with-original n t))
1210 (defun gnus-summary-very-wide-reply (&optional yank)
1211 "Start composing a very wide reply mail to the current message.
1212 If prefix argument YANK is non-nil, the original article is yanked
1215 (list (and current-prefix-arg
1216 (gnus-summary-work-articles 1))))
1217 (gnus-summary-reply yank t (gnus-summary-work-articles yank)))
1219 (defun gnus-summary-very-wide-reply-with-original (n)
1220 "Start composing a very wide reply mail to the current message.
1221 The original article will be yanked."
1224 (gnus-summary-work-articles n) t (gnus-summary-work-articles n)))
1226 (defun gnus-summary-mail-forward (&optional full-headers post)
1227 "Forward the current message(s) to another user.
1228 If process marks exist, forward all marked messages;
1229 If FULL-HEADERS (the prefix), include full headers when forwarding.
1231 Note that this function definition for T-gnus is totally different
1232 from the original Gnus."
1234 (if (null (cdr (gnus-summary-work-articles nil)))
1235 (gnus-setup-message 'forward
1236 (gnus-summary-select-article)
1237 (let ((charset default-mime-charset))
1238 (set-buffer gnus-original-article-buffer)
1239 (make-local-variable 'default-mime-charset)
1240 (setq default-mime-charset charset))
1241 (let ((message-included-forward-headers
1242 (if full-headers "" message-included-forward-headers)))
1243 (message-forward post)))
1244 (gnus-summary-digest-mail-forward nil post)))
1246 (defun gnus-summary-digest-mail-forward (&optional n post)
1247 "Digests and forwards all articles in this series.
1248 If N is a positive number, forward the N next articles.
1249 If N is a negative number, forward the N previous articles.
1250 If N is nil and any articles have been marked with the process mark,
1251 forward those articles instead.
1252 Optional POST will use news to forward instead of mail."
1254 (let ((articles (gnus-summary-work-articles n))
1255 (topics "Topics:\n")
1256 subject article frame)
1257 (when (car articles)
1258 (gnus-setup-message 'forward
1259 (gnus-summary-select-article)
1261 (setq articles (sort articles '<)
1262 subject "Digested Articles")
1263 (with-current-buffer gnus-original-article-buffer
1264 (setq subject (message-make-forward-subject))))
1266 (message-news nil subject)
1267 (message-mail nil subject))
1268 (when (and message-use-multi-frames (cdr articles))
1269 (setq frame (window-frame (get-buffer-window (current-buffer)))))
1271 (while (setq article (pop articles))
1272 (save-window-excursion
1273 (set-buffer gnus-summary-buffer)
1274 (gnus-summary-select-article nil nil nil article)
1275 (setq topics (concat topics " "
1276 (mail-header-subject gnus-current-headers)
1278 (gnus-summary-remove-process-mark article))
1280 (select-frame frame))
1281 (insert (mime-make-tag "message" "rfc822") "\n")
1282 (narrow-to-region (point) (point))
1283 (insert-buffer-substring gnus-original-article-buffer)
1285 (article-narrow-to-head)
1286 (message-remove-header message-included-forward-headers t nil t))
1287 (goto-char (point-max))
1293 (mime-edit-enclose-digest-region (point)(mark t))))))
1295 (defun gnus-summary-digest-post-forward (&optional n)
1296 "Digest and forwards all articles in this series to a newsgroup.
1297 If N is a positive number, forward the N next articles.
1298 If N is a negative number, forward the N previous articles.
1299 If N is nil and any articles have been marked with the process mark,
1300 forward those articles instead."
1302 (gnus-summary-digest-mail-forward n t))
1304 (defun gnus-summary-resend-message (address n)
1305 "Resend the current article to ADDRESS."
1307 (list (message-read-from-minibuffer
1308 "Resend message(s) to: "
1309 (when (gnus-buffer-live-p gnus-original-article-buffer)
1310 ;; If some other article is currently selected, the
1311 ;; initial-contents is wrong. Whatever, it is just the
1312 ;; initial-contents.
1313 (with-current-buffer gnus-original-article-buffer
1314 (nnmail-fetch-field "to"))))
1315 current-prefix-arg))
1316 (let ((articles (gnus-summary-work-articles n))
1318 (while (setq article (pop articles))
1319 (gnus-summary-select-article nil nil nil article)
1321 (set-buffer gnus-original-article-buffer)
1322 (message-resend address))
1323 (gnus-summary-mark-article-as-forwarded article))))
1325 ;; From: Matthieu Moy <Matthieu.Moy@imag.fr>
1326 (defun gnus-summary-resend-message-edit ()
1327 "Resend an article that has already been sent.
1328 A new buffer will be created to allow the user to modify body and
1329 contents of the message, and then, everything will happen as when
1330 composing a new message."
1332 (let ((article (gnus-summary-article-number)))
1333 (gnus-setup-message 'reply-yank
1334 (gnus-summary-select-article t)
1335 (set-buffer gnus-original-article-buffer)
1336 (let ((cur (current-buffer))
1337 (to (message-fetch-field "to")))
1338 ;; Get a normal message buffer.
1339 (message-pop-to-buffer (message-buffer-name "Resend" to))
1340 (insert-buffer-substring cur)
1342 ;; T-gnus change: Use MIME-Edit to recompose a message.
1344 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
1345 (fset 'mime-edit-decode-single-part-in-buffer
1346 (lambda (&rest args)
1347 (if (let ((content-type (car args)))
1348 (and (eq 'message (mime-content-type-primary-type
1350 (eq 'rfc822 (mime-content-type-subtype
1352 (setcar (cdr args) 'not-decode-text))
1355 (mime-edit-again nil t)
1356 (fset 'mime-edit-decode-single-part-in-buffer ofn)))
1357 (message-narrow-to-head-1)
1358 (insert "From: " (message-make-from) "\n")
1359 (while (re-search-forward "^From:" nil t)
1361 (insert "Original-"))
1362 (message-remove-header "^>From[\t ]" t)
1364 ;; Gnus will generate a new one when sending.
1365 (message-remove-header "Message-ID")
1366 (message-remove-header message-ignored-resent-headers t)
1367 ;; Remove unwanted headers.
1368 (goto-char (point-max))
1369 (insert mail-header-separator)
1370 (goto-char (point-min))
1371 (re-search-forward "^To:\\|^Newsgroups:" nil 'move)
1375 (defun gnus-summary-post-forward (&optional full-headers)
1376 "Forward the current article to a newsgroup.
1377 If FULL-HEADERS (the prefix), include full headers when forwarding."
1379 (gnus-summary-mail-forward full-headers t))
1381 (defvar gnus-nastygram-message
1382 "The following article was inappropriately posted to %s.\n\n"
1383 "Format string to insert in nastygrams.
1384 The current group name will be inserted at \"%s\".")
1386 (defun gnus-summary-mail-nastygram (n)
1387 "Send a nastygram to the author of the current article."
1389 (when (or gnus-expert-user
1391 "Really send a nastygram to the author of the current article? "))
1392 (let ((group gnus-newsgroup-name))
1393 (gnus-summary-reply-with-original n)
1394 (set-buffer gnus-message-buffer)
1396 (insert (format gnus-nastygram-message group))
1397 (message-send-and-exit))))
1399 (defun gnus-summary-mail-crosspost-complaint (n)
1400 "Send a complaint about crossposting to the current article(s)."
1402 (let ((articles (gnus-summary-work-articles n))
1404 (while (setq article (pop articles))
1405 (set-buffer gnus-summary-buffer)
1406 (gnus-summary-goto-subject article)
1407 (let ((group (gnus-group-real-name gnus-newsgroup-name))
1408 newsgroups followup-to)
1409 (gnus-summary-select-article)
1410 (set-buffer gnus-original-article-buffer)
1411 (if (and (<= (length (message-tokenize-header
1413 (mail-fetch-field "newsgroups"))
1416 (or (not (setq followup-to (mail-fetch-field "followup-to")))
1417 (not (member group (message-tokenize-header
1418 followup-to ", ")))))
1420 (gnus-message 1 "Followup-to restricted")
1421 (gnus-message 1 "Not a crossposted article"))
1422 (set-buffer gnus-summary-buffer)
1423 (gnus-summary-reply-with-original 1)
1424 (set-buffer gnus-message-buffer)
1426 (insert (format gnus-crosspost-complaint newsgroups group))
1427 (message-goto-subject)
1428 (re-search-forward " *$")
1429 (replace-match " (crosspost notification)" t t)
1430 (gnus-deactivate-mark)
1431 (when (gnus-y-or-n-p "Send this complaint? ")
1432 (message-send-and-exit)))))))
1434 (defun gnus-mail-parse-comma-list ()
1437 (skip-chars-forward " ")
1440 (skip-chars-forward "^,")
1445 (narrow-to-region beg (point))
1448 (while (search-forward "\"" nil t)
1452 (skip-chars-forward ",")
1453 (skip-chars-forward "^,"))
1454 (skip-chars-backward " ")
1455 (push (buffer-substring beg (point))
1457 (skip-chars-forward "^,")
1458 (skip-chars-forward ", "))
1461 (defun gnus-inews-add-to-address (group)
1462 (let ((to-address (mail-fetch-field "to")))
1463 (when (and to-address
1465 ;; This mail group doesn't have a `to-list', so we add one
1467 (when (gnus-y-or-n-p
1468 (format "Do you want to add this as `to-list': %s " to-address))
1469 (gnus-group-add-parameter group (cons 'to-list to-address))))))
1471 (defun gnus-put-message ()
1472 "Put the current message in some group and return to Gnus."
1474 (let ((reply gnus-article-reply)
1475 (winconf gnus-prev-winconf)
1476 (group gnus-newsgroup-name))
1478 (not (gnus-group-read-only-p group)))
1479 (setq group (read-string "Put in group: " nil (gnus-writable-groups))))
1481 (when (gnus-gethash group gnus-newsrc-hashtb)
1482 (error "No such group: %s" group))
1486 (message-narrow-to-headers)
1487 (let ((gnus-deletable-headers nil))
1488 (message-generate-headers
1489 (if (message-news-p)
1490 message-required-news-headers
1491 message-required-mail-headers)))
1492 (goto-char (point-max))
1493 (insert "Gcc: " group "\n")
1496 (when (and (get-buffer gnus-group-buffer)
1497 (gnus-buffer-exists-p (car-safe reply))
1499 (set-buffer (car reply))
1500 (gnus-summary-mark-article-as-replied (cdr reply)))
1502 (set-window-configuration winconf))))
1504 (defun gnus-article-mail (yank)
1505 "Send a reply to the address near point.
1506 If YANK is non-nil, include the original article."
1510 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
1511 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
1513 (gnus-msg-mail address)
1515 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
1517 (defvar nntp-server-type)
1519 "Send a bug report to the Gnus maintainers."
1521 (unless (gnus-alive-p)
1522 (error "Gnus has been shut down"))
1523 (gnus-setup-message (if (message-mail-user-agent) 'message 'bug)
1524 (unless (message-mail-user-agent)
1525 (message-pop-to-buffer "*Gnus Bug*")
1526 (delete-other-windows)
1527 (when gnus-bug-create-help-buffer
1528 (switch-to-buffer "*Gnus Help Bug*")
1530 (insert gnus-bug-message)
1531 (goto-char (point-min))
1533 (set-buffer "*Gnus Bug*")))
1534 (let ((message-this-is-mail t))
1535 (message-setup `((To . ,gnus-maintainer) (Subject . ""))))
1536 (when gnus-bug-create-help-buffer
1537 (push `(gnus-bug-kill-buffer) message-send-actions))
1538 (goto-char (point-min))
1539 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
1541 (insert gnus-product-name " " gnus-version-number
1542 " (r" gnus-revision-number ") "
1543 "based on " gnus-original-product-name " v"
1544 gnus-original-version-number "\n"
1545 (emacs-version) "\n")
1546 (when (and (boundp 'nntp-server-type)
1547 (stringp nntp-server-type))
1548 (insert nntp-server-type))
1549 (insert "\n\n\n\n\n")
1550 (let (mime-content-types)
1551 (mime-edit-insert-tag
1552 "application" "emacs-lisp"
1553 "\nContent-Disposition: inline\nContent-Description: User settings"))
1554 (insert (with-temp-buffer
1557 (let (mime-content-types)
1558 (mime-edit-insert-tag "text" "plain"))
1559 (goto-char (point-min))
1560 (search-forward "Subject: " nil t)
1563 (defun gnus-bug-kill-buffer ()
1564 (when (get-buffer "*Gnus Help Bug*")
1565 (kill-buffer "*Gnus Help Bug*")))
1567 (defun gnus-summary-yank-message (buffer n)
1568 "Yank the current article into a composed message."
1570 (list (completing-read "Buffer: " (mapcar 'list (message-buffers)) nil t)
1571 current-prefix-arg))
1572 (when (gnus-buffer-live-p buffer)
1573 (let ((summary-frame (selected-frame))
1574 (message-frame (when (static-if (featurep 'xemacs)
1575 (device-on-window-system-p)
1577 (let ((window (get-buffer-window buffer t)))
1579 (window-frame window)))))
1580 (separator (concat "^" (regexp-quote mail-header-separator)
1582 (gnus-summary-iterate n
1583 (gnus-summary-select-article)
1584 (gnus-copy-article-buffer)
1585 (when (frame-live-p message-frame)
1586 (raise-frame message-frame)
1587 (select-frame message-frame))
1588 (with-current-buffer buffer
1589 (when (save-excursion
1591 (let (case-fold-search)
1592 (and (not (re-search-backward separator nil t))
1593 (re-search-forward separator nil t))))
1594 (goto-char (match-end 0)))
1595 (message-yank-buffer gnus-article-copy))
1596 (select-frame summary-frame))
1597 (when (frame-live-p message-frame)
1598 (select-frame message-frame)))))
1600 (defun gnus-debug ()
1601 "Attempts to go through the Gnus source file and report what variables have been changed.
1602 The source file has to be in the Emacs load path."
1604 (let ((files gnus-debug-files)
1606 file expr olist sym)
1607 (gnus-message 4 "Please wait while we snoop your variables...")
1608 ;; Go through all the files looking for non-default values for variables.
1611 (set-buffer (gnus-get-buffer-create " *gnus bug info*"))
1614 (when (and (setq file (locate-library (pop files)))
1615 (file-exists-p file))
1616 (insert-file-contents file)
1617 (goto-char (point-min))
1618 (if (not (re-search-forward "^;;* *Internal variables" nil t))
1619 (gnus-message 4 "Malformed sources in file %s" file)
1620 (narrow-to-region (point-min) (point))
1621 (goto-char (point-min))
1622 (while (setq expr (ignore-errors (read (current-buffer))))
1624 (and (memq (car expr) '(defvar defcustom defvoo))
1625 (stringp (nth 3 expr))
1626 (not (memq (nth 1 expr) gnus-debug-exclude-variables))
1627 (or (not (boundp (nth 1 expr)))
1628 (not (equal (eval (nth 2 expr))
1629 (symbol-value (nth 1 expr)))))
1630 (push (nth 1 expr) olist)))))))
1631 (kill-buffer (current-buffer)))
1632 (when (setq olist (nreverse olist))
1633 (insert ";----------------- Environment follows ------------------\n\n"))
1635 (if (boundp (car olist))
1637 (pp `(setq ,(car olist)
1638 ,(if (or (consp (setq sym (symbol-value (car olist))))
1640 (not (or (eq sym nil)
1642 (list 'quote (symbol-value (car olist)))
1643 (symbol-value (car olist))))
1646 (format "(setq %s 'whatever)\n" (car olist))))
1647 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
1648 (setq olist (cdr olist)))
1649 ;; Remove any control chars - they seem to cause trouble for some
1650 ;; mailers. (Byte-compiled output from the stuff above.)
1652 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
1653 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
1655 ;; Break MIME tags purposely.
1657 (while (re-search-forward mime-edit-tag-regexp nil t)
1658 (goto-char (1+ (match-beginning 0)))
1661 ;;; Treatment of rejected articles.
1664 (defun gnus-summary-resend-bounced-mail (&optional fetch)
1665 "Re-mail the current message.
1666 This only makes sense if the current message is a bounce message than
1667 contains some mail you have written which has been bounced back to
1669 If FETCH, try to fetch the article that this is a reply to, if indeed
1672 (gnus-summary-select-article t)
1673 (set-buffer gnus-original-article-buffer)
1674 (gnus-setup-message 'compose-bounce
1675 (let* ((references (mail-fetch-field "references"))
1676 (parent (and references (gnus-parent-id references))))
1678 ;; If there are references, we fetch the article we answered to.
1680 (gnus-summary-refer-article parent)
1681 (gnus-summary-show-all-headers)))))
1685 (defun gnus-inews-group-method (group)
1687 ;; If the group doesn't exist, we assume
1688 ;; it's an archive group...
1689 ((and (null (gnus-get-info group))
1690 (eq (car (gnus-server-to-method gnus-message-archive-method))
1691 (car (gnus-server-to-method (gnus-group-method group)))))
1692 gnus-message-archive-method)
1694 ((gnus-info-method (gnus-get-info group))
1695 (gnus-info-method (gnus-get-info group)))
1697 (t (gnus-server-to-method (gnus-group-method group)))))
1699 ;; Do Gcc handling, which copied the message over to some group.
1700 (defun gnus-inews-do-gcc (&optional gcc)
1704 (message-narrow-to-headers)
1705 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
1706 (coding-system-for-write 'raw-text)
1707 (output-coding-system 'raw-text)
1708 groups group method group-art
1709 mml-externalize-attachments)
1711 (message-remove-header "gcc")
1713 (setq groups (message-unquote-tokens
1714 (message-tokenize-header gcc " ,")))
1715 ;; Copy the article over to some group(s).
1716 (while (setq group (pop groups))
1717 (unless (gnus-check-server
1718 (setq method (gnus-inews-group-method group)))
1719 (error "Can't open server %s" (if (stringp method) method
1721 (unless (gnus-request-group group nil method)
1722 (gnus-request-create-group group method))
1723 (setq mml-externalize-attachments
1724 (if (stringp gnus-gcc-externalize-attachments)
1725 (string-match gnus-gcc-externalize-attachments group)
1726 gnus-gcc-externalize-attachments))
1728 (nnheader-set-temp-buffer " *acc*")
1729 (insert-buffer-substring message-encoding-buffer)
1730 (gnus-run-hooks 'gnus-before-do-gcc-hook)
1731 (goto-char (point-min))
1732 (when (re-search-forward
1733 (concat "^" (regexp-quote mail-header-separator) "$")
1735 (replace-match "" t t ))
1736 (unless (setq group-art
1737 (gnus-request-accept-article group method t t))
1738 (gnus-message 1 "Couldn't store article in group %s: %s"
1739 group (gnus-status-message method))
1741 (when (and group-art
1742 (or gnus-gcc-mark-as-read
1743 gnus-inews-mark-gcc-as-read))
1744 (gnus-group-mark-article-read group (cdr group-art)))
1745 (kill-buffer (current-buffer)))))))))
1747 (defun gnus-inews-insert-gcc ()
1748 "Insert Gcc headers based on `gnus-outgoing-message-group'."
1751 (message-narrow-to-headers)
1752 (let* ((group gnus-outgoing-message-group)
1754 ((gnus-functionp group)
1756 ((or (stringp group) (list group))
1760 (if (stringp gcc) gcc
1761 (mapconcat 'identity gcc " "))
1764 (defun gnus-inews-insert-archive-gcc (&optional group)
1765 "Insert the Gcc to say where the article is to be archived."
1766 (let* ((var gnus-message-archive-group)
1767 (group (or group gnus-newsgroup-name ""))
1769 (and gnus-newsgroup-name
1770 (not (equal gnus-newsgroup-name ""))
1771 (gnus-group-find-parameter
1772 gnus-newsgroup-name 'gcc-self)))
1776 ((null gnus-message-archive-method)
1780 ;; Just a single group.
1783 ;; We don't want this.
1785 ((and (listp var) (stringp (car var)))
1786 ;; A list of groups.
1788 ((gnus-functionp var)
1790 (funcall var group))
1792 ;; An alist of regexps/functions/forms.
1797 ((stringp (caar var))
1799 (when (string-match (caar var) group)
1801 ((gnus-functionp (car var))
1803 (funcall (car var) group))
1805 (eval (car var)))))))
1806 (setq var (cdr var)))
1809 (when (or groups gcc-self-val)
1810 (when (stringp groups)
1811 (setq groups (list groups)))
1814 (message-narrow-to-headers)
1815 (goto-char (point-max))
1818 ;; Use the `gcc-self' param value instead.
1821 (if (stringp gcc-self-val)
1824 (if (not (eq gcc-self-val 'none))
1829 ;; Use the list of groups.
1830 (while (setq name (pop groups))
1831 (insert (if (string-match ":" name)
1833 (gnus-group-prefixed-name
1834 name gnus-message-archive-method)))
1841 (defun gnus-configure-posting-styles (&optional group-name)
1842 "Configure posting styles according to `gnus-posting-styles'."
1843 (unless gnus-inhibit-posting-styles
1844 (let ((group (or group-name gnus-newsgroup-name ""))
1845 (styles gnus-posting-styles)
1846 style match variable attribute value v results
1847 filep name address element)
1848 ;; If the group has a posting-style parameter, add it at the end with a
1849 ;; regexp matching everything, to be sure it takes precedence over all
1851 (when gnus-newsgroup-name
1852 (let ((tmp-style (gnus-group-find-parameter group 'posting-style t)))
1854 (setq styles (append styles (list (cons ".*" tmp-style)))))))
1855 ;; Go through all styles and look for matches.
1856 (dolist (style styles)
1857 (setq match (pop style))
1858 (goto-char (point-min))
1861 ;; Regexp string match on the group name.
1862 (string-match match group))
1864 ;; Obsolete format of header match.
1865 (and (gnus-buffer-live-p gnus-article-copy)
1866 (with-current-buffer gnus-article-copy
1867 (let ((header (message-fetch-field (pop style))))
1869 (string-match (pop style) header))))))
1870 ((or (symbolp match)
1871 (gnus-functionp match))
1873 ((gnus-functionp match)
1874 ;; Function to be called.
1877 ;; Variable to be checked.
1878 (symbol-value match))))
1881 ((eq (car match) 'header)
1882 ;; New format of header match.
1883 (and (gnus-buffer-live-p gnus-article-copy)
1884 (with-current-buffer gnus-article-copy
1885 (let ((header (message-fetch-field (nth 1 match))))
1887 (string-match (nth 2 match) header))))))
1889 ;; This is a form to be evaled.
1891 ;; We have a match, so we set the variables.
1892 (dolist (attribute style)
1893 (setq element (pop attribute)
1898 ((eq (car attribute) ':file)
1901 ((eq (car attribute) :value)
1905 ;; We get the value.
1910 ((or (symbolp value)
1911 (gnus-functionp value))
1912 (cond ((gnus-functionp value)
1915 (symbol-value value))))
1918 ;; Translate obsolescent value.
1920 ((eq element 'signature-file)
1921 (setq element 'signature
1923 ((eq element 'x-face-file)
1924 (setq element 'x-face
1926 ;; Get the contents of file elems.
1928 (setq v (with-temp-buffer
1929 (insert-file-contents v)
1930 (goto-char (point-max))
1934 (setq results (delq (assoc element results) results))
1935 (push (cons element v) results))))
1936 ;; Now we have all the styles, so we insert them.
1937 (setq name (assq 'name results)
1938 address (assq 'address results))
1939 (setq results (delq name (delq address results)))
1940 ;; make-local-hook is not obsolete in Emacs 20 or XEmacs.
1941 (make-local-hook 'message-setup-hook)
1942 (dolist (result results)
1943 (add-hook 'message-setup-hook
1945 ((eq 'eval (car result))
1947 ((eq 'body (car result))
1951 (insert ,(cdr result)))))
1952 ((eq 'signature (car result))
1953 (set (make-local-variable 'message-signature) nil)
1954 (set (make-local-variable 'message-signature-file) nil)
1955 (if (not (cdr result))
1959 (let ((message-signature ,(cdr result)))
1960 (when message-signature
1961 (message-insert-signature)))))))
1964 (if (symbolp (car result))
1965 (capitalize (symbol-name (car result)))
1969 (message-remove-header ,header)
1970 (let ((value ,(cdr result)))
1973 (insert ,header ": " value "\n"))))))))
1975 (when (or name address)
1976 (add-hook 'message-setup-hook
1978 (set (make-local-variable 'user-mail-address)
1979 ,(or (cdr address) user-mail-address))
1980 (let ((user-full-name ,(or (cdr name) (user-full-name)))
1982 ,(or (cdr address) user-mail-address)))
1984 (message-remove-header "From")
1986 (insert "From: " (message-make-from) "\n"))))
1990 ;;; @ for MIME Edit mode
1993 (defun gnus-maybe-setup-default-charset ()
1995 (and (boundp 'gnus-summary-buffer)
1996 (buffer-live-p gnus-summary-buffer)
1998 (set-buffer gnus-summary-buffer)
1999 default-mime-charset))))
2002 (make-local-variable 'default-mime-charset)
2003 (setq default-mime-charset charset)
2007 ;;; @ for MIME view mode
2010 (defun gnus-following-method (buf)
2011 (gnus-setup-message 'reply-yank
2013 (if (message-news-p)
2015 (message-reply nil 'wide))
2016 (let ((message-reply-buffer buf))
2017 (message-yank-original))
2018 (message-goto-body))
2022 ;;; Allow redefinition of functions.
2028 ;;; gnus-msg.el ends here