1 ;;; gnus-msg.el --- mail and post interface for 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>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
30 (eval-when-compile (require 'cl))
37 (defcustom gnus-post-method 'current
38 "*Preferred method for posting USENET news.
40 If this variable is `current' (which is the default), Gnus will use
41 the \"current\" select method when posting. If it is `native', Gnus
42 will use the native select method when posting.
44 This method will not be used in mail groups and the like, only in
47 If not `native' nor `current', the value must be a valid method as discussed
48 in the documentation of `gnus-select-method'. It can also be a list of
49 methods. If that is the case, the user will be queried for what select
50 method to use when posting."
51 :group 'gnus-group-foreign
52 :link '(custom-manual "(gnus)Posting Server")
53 :type `(choice (const native)
55 (sexp :tag "Methods" ,gnus-select-method)))
57 (defcustom gnus-outgoing-message-group nil
58 "*All outgoing messages will be put in this group.
59 If you want to store all your outgoing mail and articles in the group
60 \"nnml:archive\", you set this variable to that value. This variable
61 can also be a list of group names.
63 If you want to have greater control over what group to put each
64 message in, you can set this variable to a function that checks the
65 current newsgroup name and then returns a suitable group name (or list
68 :type '(choice (string :tag "Group")
71 (defcustom gnus-mailing-list-groups nil
72 "*Regexp matching groups that are really mailing lists.
73 This is useful when you're reading a mailing list that has been
74 gatewayed to a newsgroup, and you want to followup to an article in
79 (defcustom gnus-add-to-list nil
80 "*If non-nil, add a `to-list' parameter automatically."
84 (defcustom gnus-crosspost-complaint
87 You posted the article below with the following Newsgroups header:
91 The %s group, at least, was an inappropriate recipient
92 of this message. Please trim your Newsgroups header to exclude this
93 group before posting in the future.
98 "Format string to be inserted when complaining about crossposts.
99 The first %s will be replaced by the Newsgroups header;
100 the second with the current group name."
104 (defcustom gnus-message-setup-hook nil
105 "Hook run after setting up a message buffer."
109 (defcustom gnus-bug-create-help-buffer t
110 "*Should we create the *Gnus Help Bug* buffer?"
114 (defcustom gnus-posting-styles nil
115 "*Alist of styles to use when posting.
116 See Info node `(gnus)Posting Styles'."
118 :type '(repeat (cons (choice (regexp)
121 (string :tag "Header")
122 (regexp :tag "Regexp"))
126 (choice (const signature)
127 (const signature-file)
134 (string :tag "Header"))
140 (defcustom gnus-gcc-mark-as-read nil
141 "If non-nil, automatically mark Gcc articles as read."
146 (defvar gnus-inews-mark-gcc-as-read nil
147 "Obsolete variable. Use `gnus-gcc-mark-as-read' instead.")
149 (make-obsolete-variable 'gnus-inews-mark-gcc-as-read
150 'gnus-gcc-mark-as-read)
152 (defcustom gnus-gcc-externalize-attachments nil
153 "Should local-file attachments be included as external parts in Gcc copies?
154 If it is `all', attach files as external parts;
155 if a regexp and matches the Gcc group name, attach files as external parts;
156 If nil, attach files as normal parts."
159 :type '(choice (const nil :tag "None")
160 (const all :tag "Any")
161 (string :tag "Regexp")))
163 (defcustom gnus-group-posting-charset-alist
164 '(("^\\(no\\|fr\\)\\.[^,]*\\(,[ \t\n]*\\(no\\|fr\\)\\.[^,]*\\)*$" iso-8859-1 (iso-8859-1))
165 ("^\\(fido7\\|relcom\\)\\.[^,]*\\(,[ \t\n]*\\(fido7\\|relcom\\)\\.[^,]*\\)*$" koi8-r (koi8-r))
166 (message-this-is-mail nil nil)
167 (message-this-is-news nil t))
168 "Alist of regexps and permitted unencoded charsets for posting.
169 Each element of the alist has the form (TEST HEADER BODY-LIST), where
170 TEST is either a regular expression matching the newsgroup header or a
172 HEADER is the charset which may be left unencoded in the header (nil
173 means encode all charsets),
174 BODY-LIST is a list of charsets which may be encoded using 8bit
175 content-transfer encoding in the body, or one of the special values
176 nil (always encode using quoted-printable) or t (always use 8bit).
178 Note that any value other than nil for HEADER infringes some RFCs, so
179 use this option with care."
180 :type '(repeat (list :tag "Permitted unencoded charsets"
182 (regexp :tag "Group")
183 (const :tag "Mail message" :value message-this-is-mail)
184 (const :tag "News article" :value message-this-is-news))
185 (choice :tag "Header"
186 (const :tag "None" nil)
187 (symbol :tag "Charset"))
189 (const :tag "Any" :value t)
190 (const :tag "None" :value nil)
191 (repeat :tag "Charsets"
192 (symbol :tag "Charset")))))
193 :group 'gnus-charset)
195 (defcustom gnus-debug-files
196 '("gnus.el" "gnus-sum.el" "gnus-group.el"
197 "gnus-art.el" "gnus-start.el" "gnus-async.el"
198 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
199 "gnus-agent.el" "gnus-cache.el" "gnus-srvr.el"
200 "mm-util.el" "mm-decode.el" "nnmail.el" "message.el")
201 "Files whose variables will be reported in `gnus-bug'."
204 :type '(repeat (string :tag "File")))
206 (defcustom gnus-debug-exclude-variables
207 '(mm-mime-mule-charset-alist
208 nnmail-split-fancy message-minibuffer-local-map)
209 "Variables that should not be reported in `gnus-bug'."
212 :type '(repeat (symbol :tag "Variable")))
214 (defcustom gnus-discouraged-post-methods
215 '(nndraft nnml nnimap nnmaildir nnmh nnfolder nndir)
216 "A list of back ends that are not used in \"real\" newsgroups.
217 This variable is used only when `gnus-post-method' is `current'."
219 :group 'gnus-group-foreign
220 :type '(repeat (symbol :tag "Back end")))
222 (defcustom gnus-message-replysign
224 "Automatically sign replys to signed messages.
225 See also the `mml-default-sign-method' variable."
229 (defcustom gnus-message-replyencrypt
231 "Automatically encrypt replys to encrypted messages.
232 See also the `mml-default-encrypt-method' variable."
236 (defcustom gnus-message-replysignencrypted
238 "Setting this causes automatically encryped messages to also be signed."
242 ;;; Internal variables.
244 (defvar gnus-inhibit-posting-styles nil
245 "Inhibit the use of posting styles.")
247 (defvar gnus-message-buffer "*Mail Gnus*")
248 (defvar gnus-article-copy nil)
249 (defvar gnus-check-before-posting nil)
250 (defvar gnus-last-posting-server nil)
251 (defvar gnus-message-group-art nil)
253 (defvar gnus-msg-force-broken-reply-to nil)
255 (defconst gnus-bug-message
256 "Sending a bug report to the Gnus Towers.
257 ========================================
259 The buffer below is a mail buffer. When you press `C-c C-c', it will
260 be sent to the Gnus Bug Exterminators.
262 The thing near the bottom of the buffer is how the environment
263 settings will be included in the mail. Please do not delete that.
264 They will tell the Bug People what your environment is, so that it
265 will be easier to locate the bugs.
267 If you have found a bug that makes Emacs go \"beep\", set
268 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
269 and include the backtrace in your bug report.
271 Please describe the bug in annoying, painstaking detail.
273 Thank you for your help in stamping out bugs.
277 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
278 (autoload 'news-setup "rnewspost")
279 (autoload 'news-reply-mode "rnewspost")
280 (autoload 'rmail-dont-reply-to "mail-utils")
281 (autoload 'rmail-output "rmailout"))
285 ;;; Gnus Posting Functions
288 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
289 "p" gnus-summary-post-news
290 "i" gnus-summary-news-other-window
291 "f" gnus-summary-followup
292 "F" gnus-summary-followup-with-original
293 "c" gnus-summary-cancel-article
294 "s" gnus-summary-supersede-article
295 "r" gnus-summary-reply
296 "y" gnus-summary-yank-message
297 "R" gnus-summary-reply-with-original
298 "w" gnus-summary-wide-reply
299 "W" gnus-summary-wide-reply-with-original
300 "v" gnus-summary-very-wide-reply
301 "V" gnus-summary-very-wide-reply-with-original
302 "n" gnus-summary-followup-to-mail
303 "N" gnus-summary-followup-to-mail-with-original
304 "m" gnus-summary-mail-other-window
305 "u" gnus-uu-post-news
306 "\M-c" gnus-summary-mail-crosspost-complaint
307 "Br" gnus-summary-reply-broken-reply-to
308 "BR" gnus-summary-reply-broken-reply-to-with-original
309 "om" gnus-summary-mail-forward
310 "op" gnus-summary-post-forward
311 "Om" gnus-uu-digest-mail-forward
312 "Op" gnus-uu-digest-post-forward)
314 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
315 "b" gnus-summary-resend-bounced-mail
316 ;; "c" gnus-summary-send-draft
317 "r" gnus-summary-resend-message
318 "e" gnus-summary-resend-message-edit)
320 ;;; Internal functions.
322 (defvar gnus-article-reply nil)
323 (defmacro gnus-setup-message (config &rest forms)
324 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
325 (buffer (make-symbol "gnus-setup-message-buffer"))
326 (article (make-symbol "gnus-setup-message-article"))
327 (group (make-symbol "gnus-setup-message-group")))
328 `(let ((,winconf (current-window-configuration))
329 (,buffer (buffer-name (current-buffer)))
330 (,article gnus-article-reply)
331 (,group gnus-newsgroup-name)
332 (message-header-setup-hook
333 (copy-sequence message-header-setup-hook))
334 (mbl mml-buffer-list)
335 (message-mode-hook (copy-sequence message-mode-hook)))
336 (setq mml-buffer-list nil)
337 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
338 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
339 ;; #### FIXME: for a reason that I did not manage to identify yet,
340 ;; the variable `gnus-newsgroup-name' does not honor a dynamically
341 ;; scoped or setq'ed value from a caller like `C-u gnus-summary-mail'.
342 ;; After evaluation of @forms below, it gets the value we actually want
343 ;; to override, and the posting styles are used. For that reason, I've
344 ;; added an optional argument to `gnus-configure-posting-styles' to
345 ;; make sure that the correct value for the group name is used. -- drv
346 (add-hook 'message-mode-hook
348 (gnus-configure-posting-styles ,group)))
352 (gnus-inews-add-send-actions ,winconf ,buffer ,article ,config)
353 (gnus-inews-insert-draft-meta-information ,group ,article)
354 (setq gnus-message-buffer (current-buffer))
355 (set (make-local-variable 'gnus-message-group-art)
356 (cons ,group ,article))
357 (set (make-local-variable 'gnus-newsgroup-name) ,group)
358 (gnus-run-hooks 'gnus-message-setup-hook)
359 (if (eq major-mode 'message-mode)
360 (let ((mbl1 mml-buffer-list))
361 (setq mml-buffer-list mbl) ;; Global value
362 (set (make-local-variable 'mml-buffer-list) mbl1);; Local value
363 ;; LOCAL argument of add-hook differs between GNU Emacs
364 ;; and XEmacs. make-local-hook makes sure they are local.
365 (make-local-hook 'kill-buffer-hook)
366 (make-local-hook 'change-major-mode-hook)
367 (add-hook 'change-major-mode-hook 'mml-destroy-buffers nil t)
368 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))
369 (mml-destroy-buffers)
370 (setq mml-buffer-list mbl)))
372 (gnus-configure-windows ,config t)
373 (run-hooks 'post-command-hook)
374 (set-buffer-modified-p nil))))
376 (defun gnus-inews-insert-draft-meta-information (group article)
379 (not (string= group ""))
380 (not (message-fetch-field gnus-draft-meta-information-header)))
381 (goto-char (point-min))
382 (insert gnus-draft-meta-information-header ": (\"" group "\" "
383 (if article (number-to-string
390 (defun gnus-msg-mail (&optional to subject other-headers continue
391 switch-action yank-action send-actions)
392 "Start editing a mail message to be sent.
393 Like `message-mail', but with Gnus paraphernalia, particularly the
394 Gcc: header for archiving purposes."
396 (let ((buf (current-buffer))
398 (gnus-setup-message 'message
399 (message-mail to subject other-headers continue
400 nil yank-action send-actions))
402 (setq mail-buf (current-buffer))
403 (switch-to-buffer buf)
404 (apply switch-action mail-buf nil)))
405 ;; COMPOSEFUNC should return t if succeed. Undocumented ???
408 (defvar save-selected-window-window)
411 (defun gnus-button-mailto (address)
413 (set-buffer (gnus-copy-article-buffer))
414 (gnus-setup-message 'message
415 (message-reply address))
416 (and (boundp 'save-selected-window-window)
417 (not (window-live-p save-selected-window-window))
418 (setq save-selected-window-window (selected-window))))
421 (defun gnus-button-reply (&optional to-address wide)
422 "Like `message-reply'."
424 (gnus-setup-message 'message
425 (message-reply to-address wide))
426 (and (boundp 'save-selected-window-window)
427 (not (window-live-p save-selected-window-window))
428 (setq save-selected-window-window (selected-window))))
431 (define-mail-user-agent 'gnus-user-agent
432 'gnus-msg-mail 'message-send-and-exit
433 'message-kill-buffer 'message-send-hook)
435 (defun gnus-setup-posting-charset (group)
436 (let ((alist gnus-group-posting-charset-alist)
437 (group (or group ""))
441 (while (setq elem (pop alist))
442 (when (or (and (stringp (car elem))
443 (string-match (car elem) group))
444 (and (gnus-functionp (car elem))
445 (funcall (car elem) group))
446 (and (symbolp (car elem))
447 (symbol-value (car elem))))
448 (throw 'found (cons (cadr elem) (caddr elem)))))))))
450 (defun gnus-inews-add-send-actions (winconf buffer article &optional config)
451 (make-local-hook 'message-sent-hook)
452 (add-hook 'message-sent-hook (if gnus-agent 'gnus-agent-possibly-do-gcc
453 'gnus-inews-do-gcc) nil t)
455 (make-local-hook 'message-header-hook)
456 (add-hook 'message-header-hook 'gnus-agent-possibly-save-gcc nil t))
457 (setq message-post-method
459 (gnus-post-method arg ,gnus-newsgroup-name)))
460 (setq message-newsreader (setq message-mailer (gnus-extended-version)))
462 `(set-window-configuration ,winconf) 'exit 'postpone 'kill)
464 `(when (gnus-buffer-exists-p ,buffer)
468 (if (eq config 'forward)
469 `(gnus-summary-mark-article-as-forwarded ',article)
470 `(gnus-summary-mark-article-as-replied ',article)))))
473 (put 'gnus-setup-message 'lisp-indent-function 1)
474 (put 'gnus-setup-message 'edebug-form-spec '(form body))
476 ;;; Post news commands of Gnus group mode and summary mode
478 (defun gnus-group-mail (&optional arg)
479 "Start composing a mail.
480 If ARG, use the group under the point to find a posting style.
481 If ARG is 1, prompt for a group name to find the posting style."
483 ;; We can't `let' gnus-newsgroup-name here, since that leads
484 ;; to local variables leaking.
485 (let ((group gnus-newsgroup-name)
486 (buffer (current-buffer)))
489 (setq gnus-newsgroup-name
491 (if (= 1 (prefix-numeric-value arg))
492 (completing-read "Use posting style of group: "
493 gnus-active-hashtb nil
494 (gnus-read-active-file-p))
495 (gnus-group-group-name))
497 ;; #### see comment in gnus-setup-message -- drv
498 (gnus-setup-message 'message (message-mail)))
501 (setq gnus-newsgroup-name group)))))
503 (defun gnus-group-news (&optional arg)
504 "Start composing a news.
505 If ARG, post to group under point.
506 If ARG is 1, prompt for group name to post to.
508 This function prepares a news even when using mail groups. This is useful
509 for posting messages to mail groups without actually sending them over the
510 network. The corresponding backend must have a 'request-post method."
512 ;; We can't `let' gnus-newsgroup-name here, since that leads
513 ;; to local variables leaking.
514 (let ((group gnus-newsgroup-name)
515 (buffer (current-buffer)))
518 (setq gnus-newsgroup-name
520 (if (= 1 (prefix-numeric-value arg))
521 (completing-read "Use group: "
522 gnus-active-hashtb nil
523 (gnus-read-active-file-p))
524 (gnus-group-group-name))
526 ;; #### see comment in gnus-setup-message -- drv
527 (gnus-setup-message 'message
528 (message-news (gnus-group-real-name gnus-newsgroup-name))))
531 (setq gnus-newsgroup-name group)))))
533 (defun gnus-group-post-news (&optional arg)
534 "Start composing a message (a news by default).
535 If ARG, post to group under point. If ARG is 1, prompt for group name.
536 Depending on the selected group, the message might be either a mail or
539 ;; Bind this variable here to make message mode hooks work ok.
540 (let ((gnus-newsgroup-name
542 (if (= 1 (prefix-numeric-value arg))
543 (completing-read "Newsgroup: " gnus-active-hashtb nil
544 (gnus-read-active-file-p))
545 (gnus-group-group-name))
547 (gnus-post-news 'post gnus-newsgroup-name)))
549 (defun gnus-summary-mail-other-window (&optional arg)
550 "Start composing a mail in another window.
551 Use the posting of the current group by default.
552 If ARG, don't do that. If ARG is 1, prompt for group name to find the
555 ;; We can't `let' gnus-newsgroup-name here, since that leads
556 ;; to local variables leaking.
557 (let ((group gnus-newsgroup-name)
558 (buffer (current-buffer)))
561 (setq gnus-newsgroup-name
563 (if (= 1 (prefix-numeric-value arg))
564 (completing-read "Use group: "
565 gnus-active-hashtb nil
566 (gnus-read-active-file-p))
568 gnus-newsgroup-name))
569 ;; #### see comment in gnus-setup-message -- drv
570 (gnus-setup-message 'message (message-mail)))
573 (setq gnus-newsgroup-name group)))))
575 (defun gnus-summary-news-other-window (&optional arg)
576 "Start composing a news in another window.
577 Post to the current group by default.
578 If ARG, don't do that. If ARG is 1, prompt for group name to post to.
580 This function prepares a news even when using mail groups. This is useful
581 for posting messages to mail groups without actually sending them over the
582 network. The corresponding backend must have a 'request-post method."
584 ;; We can't `let' gnus-newsgroup-name here, since that leads
585 ;; to local variables leaking.
586 (let ((group gnus-newsgroup-name)
587 (buffer (current-buffer)))
590 (setq gnus-newsgroup-name
592 (if (= 1 (prefix-numeric-value arg))
593 (completing-read "Use group: "
594 gnus-active-hashtb nil
595 (gnus-read-active-file-p))
597 gnus-newsgroup-name))
598 ;; #### see comment in gnus-setup-message -- drv
599 (gnus-setup-message 'message
600 (message-news (gnus-group-real-name gnus-newsgroup-name))))
603 (setq gnus-newsgroup-name group)))))
605 (defun gnus-summary-post-news (&optional arg)
606 "Start composing a message. Post to the current group by default.
607 If ARG, don't do that. If ARG is 1, prompt for a group name to post to.
608 Depending on the selected group, the message might be either a mail or
611 ;; Bind this variable here to make message mode hooks work ok.
612 (let ((gnus-newsgroup-name
614 (if (= 1 (prefix-numeric-value arg))
615 (completing-read "Newsgroup: " gnus-active-hashtb nil
616 (gnus-read-active-file-p))
618 gnus-newsgroup-name)))
619 (gnus-post-news 'post gnus-newsgroup-name)))
622 (defun gnus-summary-followup (yank &optional force-news)
623 "Compose a followup to an article.
624 If prefix argument YANK is non-nil, the original article is yanked
626 YANK is a list of elements, where the car of each element is the
627 article number, and the two following numbers is the region to be
630 (list (and current-prefix-arg
631 (gnus-summary-work-articles 1))))
633 (gnus-summary-goto-subject
634 (if (listp (car yank))
637 (save-window-excursion
638 (gnus-summary-select-article))
639 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
640 (gnus-newsgroup-name gnus-newsgroup-name))
642 (gnus-post-news nil gnus-newsgroup-name
643 headers gnus-article-buffer
644 yank nil force-news)))
646 (defun gnus-summary-followup-with-original (n &optional force-news)
647 "Compose a followup to an article and include the original article."
649 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
651 (defun gnus-summary-followup-to-mail (&optional arg)
652 "Followup to the current mail message via news."
654 (list (and current-prefix-arg
655 (gnus-summary-work-articles 1))))
656 (gnus-summary-followup arg t))
658 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
659 "Followup to the current mail message via news."
661 (gnus-summary-followup (gnus-summary-work-articles arg) t))
663 (defun gnus-inews-yank-articles (articles)
664 (let (beg article yank-string)
666 (while (setq article (pop articles))
667 (when (listp article)
668 (setq yank-string (nth 1 article)
669 article (nth 0 article)))
670 (save-window-excursion
671 (set-buffer gnus-summary-buffer)
672 (gnus-summary-select-article nil nil nil article)
673 (gnus-summary-remove-process-mark article))
674 (gnus-copy-article-buffer nil yank-string)
675 (let ((message-reply-buffer gnus-article-copy)
676 (message-reply-headers
677 ;; The headers are decoded.
678 (with-current-buffer gnus-article-copy
679 (nnheader-parse-head t))))
680 (message-yank-original)
681 (setq beg (or beg (mark t))))
687 (defun gnus-summary-cancel-article (&optional n symp)
688 "Cancel an article you posted.
689 Uses the process-prefix convention. If given the symbolic
690 prefix `a', cancel using the standard posting method; if not
691 post using the current select method."
692 (interactive (gnus-interactive "P\ny"))
693 (let ((articles (gnus-summary-work-articles n))
696 (gnus-post-method (eq ',symp 'a) ,gnus-newsgroup-name)))
698 (while (setq article (pop articles))
699 (when (gnus-summary-select-article t nil nil article)
700 (when (gnus-eval-in-buffer-window gnus-original-article-buffer
701 (message-cancel-news))
702 (gnus-summary-mark-as-read article gnus-canceled-mark)
703 (gnus-cache-remove-article 1))
704 (gnus-article-hide-headers-if-wanted))
705 (gnus-summary-remove-process-mark article))))
707 (defun gnus-summary-supersede-article ()
708 "Compose an article that will supersede a previous article.
709 This is done simply by taking the old article and adding a Supersedes
710 header line with the old Message-ID."
712 (let ((article (gnus-summary-article-number)))
713 (gnus-setup-message 'reply-yank
714 (gnus-summary-select-article t)
715 (set-buffer gnus-original-article-buffer)
719 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
721 (set-buffer ,gnus-summary-buffer)
722 (gnus-cache-possibly-remove-article ,article nil nil nil t)
723 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
724 message-send-actions))))
728 (defun gnus-copy-article-buffer (&optional article-buffer yank-string)
729 ;; make a copy of the article buffer with all text properties removed
730 ;; this copy is in the buffer gnus-article-copy.
731 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
732 ;; this buffer should be passed to all mail/news reply/post routines.
733 (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
735 (set-buffer gnus-article-copy)
736 (mm-enable-multibyte))
737 (let ((article-buffer (or article-buffer gnus-article-buffer))
739 (if (not (and (get-buffer article-buffer)
740 (gnus-buffer-exists-p article-buffer)))
741 (error "Can't find any article buffer")
743 (set-buffer article-buffer)
744 (let ((gnus-newsgroup-charset (or gnus-article-charset
745 gnus-newsgroup-charset))
746 (gnus-newsgroup-ignored-charsets
747 (or gnus-article-ignored-charsets
748 gnus-newsgroup-ignored-charsets)))
750 ;; Copy over the (displayed) article buffer, delete
751 ;; hidden text and remove text properties.
753 (copy-to-buffer gnus-article-copy (point-min) (point-max))
754 (set-buffer gnus-article-copy)
757 (delete-region (point) (point-max))
758 (insert yank-string))
759 (gnus-article-delete-text-of-type 'annotation)
760 (gnus-remove-text-with-property 'gnus-prev)
761 (gnus-remove-text-with-property 'gnus-next)
762 (gnus-remove-text-with-property 'gnus-decoration)
765 (buffer-substring-no-properties (point-min) (point-max))
767 ;; Find the original headers.
768 (set-buffer gnus-original-article-buffer)
769 (goto-char (point-min))
770 (while (looking-at message-unix-mail-delimiter)
773 end (or (message-goto-body) beg))
774 ;; Delete the headers from the displayed articles.
775 (set-buffer gnus-article-copy)
776 (delete-region (goto-char (point-min))
777 (or (message-goto-body) (point-max)))
778 ;; Insert the original article headers.
779 (insert-buffer-substring gnus-original-article-buffer beg end)
781 (let ((gnus-article-decode-hook
782 (delq 'article-decode-charset
783 (copy-sequence gnus-article-decode-hook))))
784 (run-hooks 'gnus-article-decode-hook)))))
787 (defun gnus-post-news (post &optional group header article-buffer yank subject
790 (gnus-copy-article-buffer))
791 (let ((gnus-article-reply (and article-buffer (gnus-summary-article-number)))
792 (add-to-list gnus-add-to-list))
793 (gnus-setup-message (cond (yank 'reply-yank)
794 (article-buffer 'reply)
796 (let* ((group (or group gnus-newsgroup-name))
797 (charset (gnus-group-name-charset nil group))
799 to-address to-group mailing-list to-list
802 (setq to-address (gnus-parameter-to-address group)
803 to-group (gnus-group-find-parameter group 'to-group)
804 to-list (gnus-parameter-to-list group)
805 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
806 mailing-list (when gnus-mailing-list-groups
807 (string-match gnus-mailing-list-groups group))
808 group (gnus-group-name-decode (gnus-group-real-name group)
810 (if (or (and to-group
811 (gnus-news-group-p to-group))
814 (and (gnus-news-group-p
815 (or pgroup gnus-newsgroup-name)
816 (or header gnus-current-article))
822 (message-news (or to-group group))
823 (set-buffer gnus-article-copy)
824 (gnus-msg-treat-broken-reply-to)
825 (message-followup (if (or newsgroup-p force-news)
826 (if (save-restriction
827 (article-narrow-to-head)
828 (message-fetch-field "newsgroups"))
835 (message-mail (or to-address to-list))
836 ;; Arrange for mail groups that have no `to-address' to
837 ;; get that when the user sends off the mail.
838 (when (and (not to-list)
841 (push (list 'gnus-inews-add-to-address pgroup)
842 message-send-actions)))
843 (set-buffer gnus-article-copy)
844 (gnus-msg-treat-broken-reply-to)
845 (message-wide-reply to-address)))
847 (gnus-inews-yank-articles yank))))))
849 (defun gnus-msg-treat-broken-reply-to (&optional force)
850 "Remove the Reply-to header iff broken-reply-to."
852 (gnus-group-find-parameter
853 gnus-newsgroup-name 'broken-reply-to))
855 (message-narrow-to-head)
856 (message-remove-header "reply-to"))))
858 (defun gnus-post-method (arg group &optional silent)
859 "Return the posting method based on GROUP and ARG.
860 If SILENT, don't prompt the user."
861 (let ((gnus-post-method (or (gnus-parameter-post-method group)
863 (group-method (gnus-find-method-for-group group)))
865 ;; If the group-method is nil (which shouldn't happen) we use
866 ;; the default method.
868 (or (and (listp gnus-post-method) ;If not current/native/nil
869 (not (listp (car gnus-post-method))) ; and not a list of methods
870 gnus-post-method) ;then use it.
872 message-post-method))
873 ;; We want the inverse of the default
874 ((and arg (not (eq arg 0)))
875 (if (eq gnus-post-method 'current)
878 ;; We query the user for a post method.
880 (and (listp gnus-post-method)
881 (listp (car gnus-post-method))))
883 ;; Collect all methods we know about.
885 (when (listp gnus-post-method)
886 (if (listp (car gnus-post-method))
888 (list gnus-post-method)))
889 gnus-secondary-select-methods
890 (mapcar 'cdr gnus-server-alist)
891 (mapcar 'car gnus-opened-servers)
892 (list gnus-select-method)
893 (list group-method)))
894 method-alist post-methods method)
895 ;; Weed out all mail methods.
897 (setq method (gnus-server-get-method "" (pop methods)))
898 (when (and (or (gnus-method-option-p method 'post)
899 (gnus-method-option-p method 'post-mail))
900 (not (member method post-methods)))
901 (push method post-methods)))
902 ;; Create a name-method alist.
906 (if (equal (cadr m) "")
907 (list (symbol-name (car m)) m)
908 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m)))
913 (setq gnus-last-posting-server
915 gnus-last-posting-server)
916 ;; Just use the last value.
917 gnus-last-posting-server
919 "Posting method: " method-alist nil t
920 (cons (or gnus-last-posting-server "") 0))))
922 ;; Override normal method.
923 ((and (eq gnus-post-method 'current)
924 (not (memq (car group-method) gnus-discouraged-post-methods))
925 (gnus-get-function group-method 'request-post t))
928 ;; Use gnus-post-method.
929 ((listp gnus-post-method) ;A method...
930 (assert (not (listp (car gnus-post-method)))) ;... not a list of methods.
932 ;; Use the normal select method (nil or native).
933 (t gnus-select-method))))
937 ;; Dummies to avoid byte-compile warning.
939 (defvar nnspool-rejected-article-hook)
940 (defvar xemacs-codename))
942 (defun gnus-extended-version ()
943 "Stringified Gnus version and Emacs version."
946 "Gnus/" (prin1-to-string (gnus-continuum-version gnus-version) t)
947 " (" gnus-version ")"
950 ((string-match "^\\(\\([.0-9]+\\)*\\)\\.[0-9]+$" emacs-version)
951 (concat "Emacs/" (match-string 1 emacs-version)
952 " (" system-configuration ")"))
953 ((string-match "\\([A-Z]*[Mm][Aa][Cc][Ss]\\)[^(]*\\(\\((beta.*)\\|'\\)\\)?"
955 (concat (match-string 1 emacs-version)
956 (format "/%d.%d" emacs-major-version emacs-minor-version)
957 (if (match-beginning 3)
958 (match-string 3 emacs-version)
960 (if (boundp 'xemacs-codename)
961 (concat " (" xemacs-codename ", " system-configuration ")")
967 ;;; Gnus Mail Functions
970 ;;; Mail reply commands of Gnus summary mode
972 (defun gnus-summary-reply (&optional yank wide very-wide)
973 "Start composing a mail reply to the current message.
974 If prefix argument YANK is non-nil, the original article is yanked
976 If WIDE, make a wide reply.
977 If VERY-WIDE, make a very wide reply."
979 (list (and current-prefix-arg
980 (gnus-summary-work-articles 1))))
982 (if (listp (car yank))
985 (gnus-article-reply (or article (gnus-summary-article-number)))
987 ;; Stripping headers should be specified with mail-yank-ignored-headers.
989 (gnus-summary-goto-subject article))
990 (gnus-setup-message (if yank 'reply-yank 'reply)
992 (gnus-summary-select-article)
993 (dolist (article very-wide)
994 (gnus-summary-select-article nil nil nil article)
996 (set-buffer (gnus-copy-article-buffer))
997 (gnus-msg-treat-broken-reply-to)
999 (message-narrow-to-head)
1000 (setq headers (concat headers (buffer-string)))))))
1001 (set-buffer (gnus-copy-article-buffer))
1002 (gnus-msg-treat-broken-reply-to gnus-msg-force-broken-reply-to)
1004 (message-narrow-to-head)
1008 (goto-char (point-max)))
1009 (mml-quote-region (point) (point-max))
1010 (message-reply nil wide)
1012 (gnus-inews-yank-articles yank))
1013 (when (or gnus-message-replysign gnus-message-replyencrypt)
1014 (let (signed encrypted)
1016 (set-buffer gnus-article-buffer)
1017 (setq signed (memq 'signed gnus-article-wash-types))
1018 (setq encrypted (memq 'encrypted gnus-article-wash-types)))
1019 (cond ((and gnus-message-replysign signed)
1020 (mml-secure-message mml-default-sign-method 'sign))
1021 ((and gnus-message-replyencrypt encrypted)
1022 (mml-secure-message mml-default-encrypt-method
1023 (if gnus-message-replysignencrypted
1027 (defun gnus-summary-reply-with-original (n &optional wide)
1028 "Start composing a reply mail to the current message.
1029 The original article will be yanked."
1031 (gnus-summary-reply (gnus-summary-work-articles n) wide))
1033 (defun gnus-summary-reply-broken-reply-to (&optional yank wide very-wide)
1034 "Like `gnus-summary-reply' except removing reply-to field.
1035 If prefix argument YANK is non-nil, the original article is yanked
1037 If WIDE, make a wide reply.
1038 If VERY-WIDE, make a very wide reply."
1040 (list (and current-prefix-arg
1041 (gnus-summary-work-articles 1))))
1042 (let ((gnus-msg-force-broken-reply-to t))
1043 (gnus-summary-reply yank wide very-wide)))
1045 (defun gnus-summary-reply-broken-reply-to-with-original (n &optional wide)
1046 "Like `gnus-summary-reply-with-original' except removing reply-to field.
1047 The original article will be yanked."
1049 (gnus-summary-reply-broken-reply-to (gnus-summary-work-articles n) wide))
1051 (defun gnus-summary-wide-reply (&optional yank)
1052 "Start composing a wide reply mail to the current message.
1053 If prefix argument YANK is non-nil, the original article is yanked
1056 (list (and current-prefix-arg
1057 (gnus-summary-work-articles 1))))
1058 (gnus-summary-reply yank t))
1060 (defun gnus-summary-wide-reply-with-original (n)
1061 "Start composing a wide reply mail to the current message.
1062 The original article will be yanked."
1064 (gnus-summary-reply-with-original n t))
1066 (defun gnus-summary-very-wide-reply (&optional yank)
1067 "Start composing a very wide reply mail to the current message.
1068 If prefix argument YANK is non-nil, the original article is yanked
1071 (list (and current-prefix-arg
1072 (gnus-summary-work-articles 1))))
1073 (gnus-summary-reply yank t (gnus-summary-work-articles yank)))
1075 (defun gnus-summary-very-wide-reply-with-original (n)
1076 "Start composing a very wide reply mail to the current message.
1077 The original article will be yanked."
1080 (gnus-summary-work-articles n) t (gnus-summary-work-articles n)))
1082 (defun gnus-summary-mail-forward (&optional arg post)
1083 "Forward the current message(s) to another user.
1084 If process marks exist, forward all marked messages;
1085 if ARG is nil, see `message-forward-as-mime' and `message-forward-show-mml';
1086 if ARG is 1, decode the message and forward directly inline;
1087 if ARG is 2, forward message as an rfc822 MIME section;
1088 if ARG is 3, decode message and forward as an rfc822 MIME section;
1089 if ARG is 4, forward message directly inline;
1090 otherwise, use flipped `message-forward-as-mime'.
1091 If POST, post instead of mail.
1092 For the `inline' alternatives, also see the variable
1093 `message-forward-ignored-headers'."
1095 (if (null (cdr (gnus-summary-work-articles nil)))
1096 (let ((message-forward-as-mime message-forward-as-mime)
1097 (message-forward-show-mml message-forward-show-mml))
1101 (setq message-forward-as-mime nil
1102 message-forward-show-mml t))
1104 (setq message-forward-as-mime t
1105 message-forward-show-mml nil))
1107 (setq message-forward-as-mime t
1108 message-forward-show-mml t))
1110 (setq message-forward-as-mime nil
1111 message-forward-show-mml nil))
1113 (setq message-forward-as-mime (not message-forward-as-mime))))
1114 (let ((gnus-article-reply (gnus-summary-article-number)))
1115 (gnus-setup-message 'forward
1116 (gnus-summary-select-article)
1117 (let ((mail-parse-charset
1118 (or (and (gnus-buffer-live-p gnus-article-buffer)
1119 (with-current-buffer gnus-article-buffer
1120 gnus-article-charset))
1121 gnus-newsgroup-charset))
1122 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
1123 (set-buffer gnus-original-article-buffer)
1124 (message-forward post)))))
1125 (gnus-uu-digest-mail-forward arg post)))
1127 (defun gnus-summary-resend-message (address n)
1128 "Resend the current article to ADDRESS."
1130 (list (message-read-from-minibuffer
1131 "Resend message(s) to: "
1132 (when (gnus-buffer-live-p gnus-original-article-buffer)
1133 ;; If some other article is currently selected, the
1134 ;; initial-contents is wrong. Whatever, it is just the
1135 ;; initial-contents.
1136 (with-current-buffer gnus-original-article-buffer
1137 (nnmail-fetch-field "to"))))
1138 current-prefix-arg))
1139 (let ((articles (gnus-summary-work-articles n))
1141 (while (setq article (pop articles))
1142 (gnus-summary-select-article nil nil nil article)
1144 (set-buffer gnus-original-article-buffer)
1145 (message-resend address))
1146 (gnus-summary-mark-article-as-forwarded article))))
1148 ;; From: Matthieu Moy <Matthieu.Moy@imag.fr>
1149 (defun gnus-summary-resend-message-edit ()
1150 "Resend an article that has already been sent.
1151 A new buffer will be created to allow the user to modify body and
1152 contents of the message, and then, everything will happen as when
1153 composing a new message."
1155 (let ((article (gnus-summary-article-number)))
1156 (gnus-setup-message 'reply-yank
1157 (gnus-summary-select-article t)
1158 (set-buffer gnus-original-article-buffer)
1159 (let ((cur (current-buffer))
1160 (to (message-fetch-field "to")))
1161 ;; Get a normal message buffer.
1162 (message-pop-to-buffer (message-buffer-name "Resend" to))
1163 (insert-buffer-substring cur)
1165 (message-narrow-to-head-1)
1166 ;; Gnus will generate a new one when sending.
1167 (message-remove-header "Message-ID")
1168 (message-remove-header message-ignored-resent-headers t)
1169 ;; Remove unwanted headers.
1170 (goto-char (point-max))
1171 (insert mail-header-separator)
1172 (goto-char (point-min))
1173 (re-search-forward "^To:\\|^Newsgroups:" nil 'move)
1177 (defun gnus-summary-post-forward (&optional arg)
1178 "Forward the current article to a newsgroup.
1179 See `gnus-summary-mail-forward' for ARG."
1181 (gnus-summary-mail-forward arg t))
1183 (defvar gnus-nastygram-message
1184 "The following article was inappropriately posted to %s.\n\n"
1185 "Format string to insert in nastygrams.
1186 The current group name will be inserted at \"%s\".")
1188 (defun gnus-summary-mail-nastygram (n)
1189 "Send a nastygram to the author of the current article."
1191 (when (or gnus-expert-user
1193 "Really send a nastygram to the author of the current article? "))
1194 (let ((group gnus-newsgroup-name))
1195 (gnus-summary-reply-with-original n)
1196 (set-buffer gnus-message-buffer)
1198 (insert (format gnus-nastygram-message group))
1199 (message-send-and-exit))))
1201 (defun gnus-summary-mail-crosspost-complaint (n)
1202 "Send a complaint about crossposting to the current article(s)."
1204 (let ((articles (gnus-summary-work-articles n))
1206 (while (setq article (pop articles))
1207 (set-buffer gnus-summary-buffer)
1208 (gnus-summary-goto-subject article)
1209 (let ((group (gnus-group-real-name gnus-newsgroup-name))
1210 newsgroups followup-to)
1211 (gnus-summary-select-article)
1212 (set-buffer gnus-original-article-buffer)
1213 (if (and (<= (length (message-tokenize-header
1215 (mail-fetch-field "newsgroups"))
1218 (or (not (setq followup-to (mail-fetch-field "followup-to")))
1219 (not (member group (message-tokenize-header
1220 followup-to ", ")))))
1222 (gnus-message 1 "Followup-to restricted")
1223 (gnus-message 1 "Not a crossposted article"))
1224 (set-buffer gnus-summary-buffer)
1225 (gnus-summary-reply-with-original 1)
1226 (set-buffer gnus-message-buffer)
1228 (insert (format gnus-crosspost-complaint newsgroups group))
1229 (message-goto-subject)
1230 (re-search-forward " *$")
1231 (replace-match " (crosspost notification)" t t)
1232 (gnus-deactivate-mark)
1233 (when (gnus-y-or-n-p "Send this complaint? ")
1234 (message-send-and-exit)))))))
1236 (defun gnus-mail-parse-comma-list ()
1239 (skip-chars-forward " ")
1242 (skip-chars-forward "^,")
1247 (narrow-to-region beg (point))
1250 (while (search-forward "\"" nil t)
1254 (skip-chars-forward ",")
1255 (skip-chars-forward "^,"))
1256 (skip-chars-backward " ")
1257 (push (buffer-substring beg (point))
1259 (skip-chars-forward "^,")
1260 (skip-chars-forward ", "))
1263 (defun gnus-inews-add-to-address (group)
1264 (let ((to-address (mail-fetch-field "to")))
1265 (when (and to-address
1267 ;; This mail group doesn't have a `to-list', so we add one
1269 (when (gnus-y-or-n-p
1270 (format "Do you want to add this as `to-list': %s " to-address))
1271 (gnus-group-add-parameter group (cons 'to-list to-address))))))
1273 (defun gnus-put-message ()
1274 "Put the current message in some group and return to Gnus."
1276 (let ((reply gnus-article-reply)
1277 (winconf gnus-prev-winconf)
1278 (group gnus-newsgroup-name))
1280 (not (gnus-group-read-only-p group)))
1281 (setq group (read-string "Put in group: " nil (gnus-writable-groups))))
1283 (when (gnus-gethash group gnus-newsrc-hashtb)
1284 (error "No such group: %s" group))
1288 (message-narrow-to-headers)
1289 (let ((gnus-deletable-headers nil))
1290 (message-generate-headers
1291 (if (message-news-p)
1292 message-required-news-headers
1293 message-required-mail-headers)))
1294 (goto-char (point-max))
1295 (insert "Gcc: " group "\n")
1298 (when (and (get-buffer gnus-group-buffer)
1299 (gnus-buffer-exists-p (car-safe reply))
1301 (set-buffer (car reply))
1302 (gnus-summary-mark-article-as-replied (cdr reply)))
1304 (set-window-configuration winconf))))
1306 (defun gnus-article-mail (yank)
1307 "Send a reply to the address near point.
1308 If YANK is non-nil, include the original article."
1312 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
1313 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
1315 (gnus-msg-mail address)
1317 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
1319 (defvar nntp-server-type)
1321 "Send a bug report to the Gnus maintainers."
1323 (unless (gnus-alive-p)
1324 (error "Gnus has been shut down"))
1325 (gnus-setup-message (if (message-mail-user-agent) 'message 'bug)
1326 (unless (message-mail-user-agent)
1327 (delete-other-windows)
1328 (when gnus-bug-create-help-buffer
1329 (switch-to-buffer "*Gnus Help Bug*")
1331 (insert gnus-bug-message)
1332 (goto-char (point-min)))
1333 (message-pop-to-buffer "*Gnus Bug*"))
1334 (let ((message-this-is-mail t))
1335 (message-setup `((To . ,gnus-maintainer) (Subject . ""))))
1336 (when gnus-bug-create-help-buffer
1337 (push `(gnus-bug-kill-buffer) message-send-actions))
1338 (goto-char (point-min))
1339 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
1341 (insert (gnus-version) "\n"
1342 (emacs-version) "\n")
1343 (when (and (boundp 'nntp-server-type)
1344 (stringp nntp-server-type))
1345 (insert nntp-server-type))
1346 (insert "\n\n\n\n\n")
1349 (set-buffer (gnus-get-buffer-create " *gnus environment info*"))
1352 (setq text (buffer-string)))
1353 (insert "<#part type=application/emacs-lisp disposition=inline description=\"User settings\">\n" text "\n<#/part>"))
1354 (goto-char (point-min))
1355 (search-forward "Subject: " nil t)
1358 (defun gnus-bug-kill-buffer ()
1359 (when (get-buffer "*Gnus Help Bug*")
1360 (kill-buffer "*Gnus Help Bug*")))
1362 (defun gnus-summary-yank-message (buffer n)
1363 "Yank the current article into a composed message."
1365 (list (completing-read "Buffer: " (mapcar 'list (message-buffers)) nil t)
1366 current-prefix-arg))
1367 (gnus-summary-iterate n
1368 (let ((gnus-display-mime-function nil)
1369 (gnus-inhibit-treatment t))
1370 (gnus-summary-select-article))
1373 (message-yank-buffer gnus-article-buffer))))
1375 (defun gnus-debug ()
1376 "Attempts to go through the Gnus source file and report what variables have been changed.
1377 The source file has to be in the Emacs load path."
1379 (let ((files gnus-debug-files)
1381 file expr olist sym)
1382 (gnus-message 4 "Please wait while we snoop your variables...")
1384 ;; Go through all the files looking for non-default values for variables.
1386 (set-buffer (gnus-get-buffer-create " *gnus bug info*"))
1389 (when (and (setq file (locate-library (pop files)))
1390 (file-exists-p file))
1391 (insert-file-contents file)
1392 (goto-char (point-min))
1393 (if (not (re-search-forward "^;;* *Internal variables" nil t))
1394 (gnus-message 4 "Malformed sources in file %s" file)
1395 (narrow-to-region (point-min) (point))
1396 (goto-char (point-min))
1397 (while (setq expr (ignore-errors (read (current-buffer))))
1399 (and (or (eq (car expr) 'defvar)
1400 (eq (car expr) 'defcustom))
1401 (stringp (nth 3 expr))
1402 (not (memq (nth 1 expr) gnus-debug-exclude-variables))
1403 (or (not (boundp (nth 1 expr)))
1404 (not (equal (eval (nth 2 expr))
1405 (symbol-value (nth 1 expr)))))
1406 (push (nth 1 expr) olist)))))))
1407 (kill-buffer (current-buffer)))
1408 (when (setq olist (nreverse olist))
1409 (insert "------------------ Environment follows ------------------\n\n"))
1411 (if (boundp (car olist))
1413 (pp `(setq ,(car olist)
1414 ,(if (or (consp (setq sym (symbol-value (car olist))))
1416 (not (or (eq sym nil)
1418 (list 'quote (symbol-value (car olist)))
1419 (symbol-value (car olist))))
1422 (format "(setq %s 'whatever)\n" (car olist))))
1423 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
1424 (setq olist (cdr olist)))
1426 ;; Remove any control chars - they seem to cause trouble for some
1427 ;; mailers. (Byte-compiled output from the stuff above.)
1429 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
1430 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
1433 ;;; Treatment of rejected articles.
1436 (defun gnus-summary-resend-bounced-mail (&optional fetch)
1437 "Re-mail the current message.
1438 This only makes sense if the current message is a bounce message than
1439 contains some mail you have written which has been bounced back to
1441 If FETCH, try to fetch the article that this is a reply to, if indeed
1444 (gnus-summary-select-article t)
1445 (set-buffer gnus-original-article-buffer)
1446 (gnus-setup-message 'compose-bounce
1447 (let* ((references (mail-fetch-field "references"))
1448 (parent (and references (gnus-parent-id references))))
1450 ;; If there are references, we fetch the article we answered to.
1452 (gnus-summary-refer-article parent)
1453 (gnus-summary-show-all-headers)))))
1457 (defun gnus-inews-group-method (group)
1459 ;; If the group doesn't exist, we assume
1460 ;; it's an archive group...
1461 ((and (null (gnus-get-info group))
1462 (eq (car (gnus-server-to-method gnus-message-archive-method))
1463 (car (gnus-server-to-method (gnus-group-method group)))))
1464 gnus-message-archive-method)
1466 ((gnus-info-method (gnus-get-info group))
1467 (gnus-info-method (gnus-get-info group)))
1469 (t (gnus-server-to-method (gnus-group-method group)))))
1471 ;; Do Gcc handling, which copied the message over to some group.
1472 (defun gnus-inews-do-gcc (&optional gcc)
1476 (message-narrow-to-headers)
1477 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
1478 (cur (current-buffer))
1479 groups group method group-art
1480 mml-externalize-attachments)
1482 (message-remove-header "gcc")
1484 (setq groups (message-unquote-tokens
1485 (message-tokenize-header gcc " ,")))
1486 ;; Copy the article over to some group(s).
1487 (while (setq group (pop groups))
1488 (unless (gnus-check-server
1489 (setq method (gnus-inews-group-method group)))
1490 (error "Can't open server %s" (if (stringp method) method
1492 (unless (gnus-request-group group nil method)
1493 (gnus-request-create-group group method))
1494 (setq mml-externalize-attachments
1495 (if (stringp gnus-gcc-externalize-attachments)
1496 (string-match gnus-gcc-externalize-attachments group)
1497 gnus-gcc-externalize-attachments))
1499 (nnheader-set-temp-buffer " *acc*")
1500 (insert-buffer-substring cur)
1501 (message-encode-message-body)
1503 (message-narrow-to-headers)
1504 (let* ((mail-parse-charset message-default-charset)
1505 (newsgroups-field (save-restriction
1506 (message-narrow-to-headers-or-head)
1507 (message-fetch-field "Newsgroups")))
1508 (followup-field (save-restriction
1509 (message-narrow-to-headers-or-head)
1510 (message-fetch-field "Followup-To")))
1511 ;; BUG: We really need to get the charset for
1512 ;; each name in the Newsgroups and Followup-To
1513 ;; lines to allow crossposting between group
1514 ;; namess with incompatible character sets.
1515 ;; -- Per Abrahamsen <abraham@dina.kvl.dk> 2001-10-08.
1516 (group-field-charset
1517 (gnus-group-name-charset
1518 method (or newsgroups-field "")))
1519 (followup-field-charset
1520 (gnus-group-name-charset
1521 method (or followup-field "")))
1522 (rfc2047-header-encoding-alist
1524 (when group-field-charset
1525 (list (cons "Newsgroups" group-field-charset)))
1526 (when followup-field-charset
1527 (list (cons "Followup-To" followup-field-charset)))
1528 rfc2047-header-encoding-alist)))
1529 (mail-encode-encoded-word-buffer)))
1530 (goto-char (point-min))
1531 (when (re-search-forward
1532 (concat "^" (regexp-quote mail-header-separator) "$")
1534 (replace-match "" t t ))
1535 (unless (setq group-art
1536 (gnus-request-accept-article group method t t))
1537 (gnus-message 1 "Couldn't store article in group %s: %s"
1538 group (gnus-status-message method))
1540 (when (and group-art
1541 (or gnus-gcc-mark-as-read
1542 gnus-inews-mark-gcc-as-read))
1543 (gnus-group-mark-article-read group (cdr group-art)))
1544 (kill-buffer (current-buffer)))))))))
1546 (defun gnus-inews-insert-gcc ()
1547 "Insert Gcc headers based on `gnus-outgoing-message-group'."
1550 (message-narrow-to-headers)
1551 (let* ((group gnus-outgoing-message-group)
1553 ((gnus-functionp group)
1555 ((or (stringp group) (list group))
1559 (if (stringp gcc) gcc
1560 (mapconcat 'identity gcc " "))
1563 (defun gnus-inews-insert-archive-gcc (&optional group)
1564 "Insert the Gcc to say where the article is to be archived."
1565 (let* ((var gnus-message-archive-group)
1566 (group (or group gnus-newsgroup-name ""))
1568 (and gnus-newsgroup-name
1569 (not (equal gnus-newsgroup-name ""))
1570 (gnus-group-find-parameter
1571 gnus-newsgroup-name 'gcc-self)))
1575 ((null gnus-message-archive-method)
1579 ;; Just a single group.
1582 ;; We don't want this.
1584 ((and (listp var) (stringp (car var)))
1585 ;; A list of groups.
1587 ((gnus-functionp var)
1589 (funcall var group))
1591 ;; An alist of regexps/functions/forms.
1596 ((stringp (caar var))
1598 (when (string-match (caar var) group)
1600 ((gnus-functionp (car var))
1602 (funcall (car var) group))
1604 (eval (car var)))))))
1605 (setq var (cdr var)))
1608 (when (or groups gcc-self-val)
1609 (when (stringp groups)
1610 (setq groups (list groups)))
1613 (message-narrow-to-headers)
1614 (goto-char (point-max))
1617 ;; Use the `gcc-self' param value instead.
1620 (if (stringp gcc-self-val)
1623 (if (not (eq gcc-self-val 'none))
1628 ;; Use the list of groups.
1629 (while (setq name (pop groups))
1630 (insert (if (string-match ":" name)
1632 (gnus-group-prefixed-name
1633 name gnus-message-archive-method)))
1640 (defun gnus-configure-posting-styles (&optional group-name)
1641 "Configure posting styles according to `gnus-posting-styles'."
1642 (unless gnus-inhibit-posting-styles
1643 (let ((group (or group-name gnus-newsgroup-name ""))
1644 (styles gnus-posting-styles)
1645 style match variable attribute value v results
1646 filep name address element)
1647 ;; If the group has a posting-style parameter, add it at the end with a
1648 ;; regexp matching everything, to be sure it takes precedence over all
1650 (when gnus-newsgroup-name
1651 (let ((tmp-style (gnus-group-find-parameter group 'posting-style t)))
1653 (setq styles (append styles (list (cons ".*" tmp-style)))))))
1654 ;; Go through all styles and look for matches.
1655 (dolist (style styles)
1656 (setq match (pop style))
1657 (goto-char (point-min))
1660 ;; Regexp string match on the group name.
1661 (string-match match group))
1663 ;; Obsolete format of header match.
1664 (and (gnus-buffer-live-p gnus-article-copy)
1665 (with-current-buffer gnus-article-copy
1666 (let ((header (message-fetch-field (pop style))))
1668 (string-match (pop style) header))))))
1669 ((or (symbolp match)
1670 (gnus-functionp match))
1672 ((gnus-functionp match)
1673 ;; Function to be called.
1676 ;; Variable to be checked.
1677 (symbol-value match))))
1680 ((eq (car match) 'header)
1681 ;; New format of header match.
1682 (and (gnus-buffer-live-p gnus-article-copy)
1683 (with-current-buffer gnus-article-copy
1684 (let ((header (message-fetch-field (nth 1 match))))
1686 (string-match (nth 2 match) header))))))
1688 ;; This is a form to be evaled.
1690 ;; We have a match, so we set the variables.
1691 (dolist (attribute style)
1692 (setq element (pop attribute)
1697 ((eq (car attribute) :file)
1700 ((eq (car attribute) :value)
1704 ;; We get the value.
1709 ((or (symbolp value)
1710 (gnus-functionp value))
1711 (cond ((gnus-functionp value)
1714 (symbol-value value))))
1717 ;; Translate obsolescent value.
1719 ((eq element 'signature-file)
1720 (setq element 'signature
1722 ((eq element 'x-face-file)
1723 (setq element 'x-face
1725 ;; Get the contents of file elems.
1727 (setq v (with-temp-buffer
1728 (insert-file-contents v)
1729 (goto-char (point-max))
1733 (setq results (delq (assoc element results) results))
1734 (push (cons element v) results))))
1735 ;; Now we have all the styles, so we insert them.
1736 (setq name (assq 'name results)
1737 address (assq 'address results))
1738 (setq results (delq name (delq address results)))
1739 ;; make-local-hook is not obsolete in Emacs 20 or XEmacs.
1740 (make-local-hook 'message-setup-hook)
1741 (dolist (result results)
1742 (add-hook 'message-setup-hook
1744 ((eq 'eval (car result))
1746 ((eq 'body (car result))
1750 (insert ,(cdr result)))))
1751 ((eq 'signature (car result))
1752 (set (make-local-variable 'message-signature) nil)
1753 (set (make-local-variable 'message-signature-file) nil)
1754 (if (not (cdr result))
1758 (let ((message-signature ,(cdr result)))
1759 (when message-signature
1760 (message-insert-signature)))))))
1763 (if (symbolp (car result))
1764 (capitalize (symbol-name (car result)))
1768 (message-remove-header ,header)
1769 (let ((value ,(cdr result)))
1772 (insert ,header ": " value "\n"))))))))
1774 (when (or name address)
1775 (add-hook 'message-setup-hook
1777 (set (make-local-variable 'user-mail-address)
1778 ,(or (cdr address) user-mail-address))
1779 (let ((user-full-name ,(or (cdr name) (user-full-name)))
1781 ,(or (cdr address) user-mail-address)))
1783 (message-remove-header "From")
1785 (insert "From: " (message-make-from) "\n"))))
1788 ;;; Allow redefinition of functions.
1794 ;;; gnus-msg.el ends here