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 (defcustom gnus-confirm-mail-reply-to-news nil
243 "If non-nil, Gnus requests confirmation when replying to news.
244 This is done because new users often reply by mistake when reading
249 (defcustom gnus-summary-resend-default-address t
250 "If non-nil, Gnus tries to suggest a default address to resend to.
251 If nil, the address field will always be empty after invoking
252 `gnus-summary-resend-message'."
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 "Sending a bug report to the Gnus Towers.
271 ========================================
273 The buffer below is a mail buffer. When you press `C-c C-c', it will
274 be sent to the Gnus Bug Exterminators.
276 The thing near the bottom of the buffer is how the environment
277 settings will be included in the mail. Please do not delete that.
278 They will tell the Bug People what your environment is, so that it
279 will be easier to locate the bugs.
281 If you have found a bug that makes Emacs go \"beep\", set
282 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
283 and include the backtrace in your bug report.
285 Please describe the bug in annoying, painstaking detail.
287 Thank you for your help in stamping out bugs.
291 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
292 (autoload 'news-setup "rnewspost")
293 (autoload 'news-reply-mode "rnewspost")
294 (autoload 'rmail-dont-reply-to "mail-utils")
295 (autoload 'rmail-output "rmailout"))
299 ;;; Gnus Posting Functions
302 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
303 "p" gnus-summary-post-news
304 "i" gnus-summary-news-other-window
305 "f" gnus-summary-followup
306 "F" gnus-summary-followup-with-original
307 "c" gnus-summary-cancel-article
308 "s" gnus-summary-supersede-article
309 "r" gnus-summary-reply
310 "y" gnus-summary-yank-message
311 "R" gnus-summary-reply-with-original
312 "w" gnus-summary-wide-reply
313 "W" gnus-summary-wide-reply-with-original
314 "v" gnus-summary-very-wide-reply
315 "V" gnus-summary-very-wide-reply-with-original
316 "n" gnus-summary-followup-to-mail
317 "N" gnus-summary-followup-to-mail-with-original
318 "m" gnus-summary-mail-other-window
319 "u" gnus-uu-post-news
320 "\M-c" gnus-summary-mail-crosspost-complaint
321 "Br" gnus-summary-reply-broken-reply-to
322 "BR" gnus-summary-reply-broken-reply-to-with-original
323 "om" gnus-summary-mail-forward
324 "op" gnus-summary-post-forward
325 "Om" gnus-uu-digest-mail-forward
326 "Op" gnus-uu-digest-post-forward)
328 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
329 "b" gnus-summary-resend-bounced-mail
330 ;; "c" gnus-summary-send-draft
331 "r" gnus-summary-resend-message
332 "e" gnus-summary-resend-message-edit)
334 ;;; Internal functions.
336 (defvar gnus-article-reply nil)
337 (defmacro gnus-setup-message (config &rest forms)
338 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
339 (buffer (make-symbol "gnus-setup-message-buffer"))
340 (article (make-symbol "gnus-setup-message-article"))
341 (group (make-symbol "gnus-setup-message-group")))
342 `(let ((,winconf (current-window-configuration))
343 (,buffer (buffer-name (current-buffer)))
344 (,article gnus-article-reply)
345 (,group gnus-newsgroup-name)
346 (message-header-setup-hook
347 (copy-sequence message-header-setup-hook))
348 (mbl mml-buffer-list)
349 (message-mode-hook (copy-sequence message-mode-hook)))
350 (setq mml-buffer-list nil)
351 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
352 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
353 ;; #### FIXME: for a reason that I did not manage to identify yet,
354 ;; the variable `gnus-newsgroup-name' does not honor a dynamically
355 ;; scoped or setq'ed value from a caller like `C-u gnus-summary-mail'.
356 ;; After evaluation of @forms below, it gets the value we actually want
357 ;; to override, and the posting styles are used. For that reason, I've
358 ;; added an optional argument to `gnus-configure-posting-styles' to
359 ;; make sure that the correct value for the group name is used. -- drv
360 (add-hook 'message-mode-hook
362 (gnus-configure-posting-styles ,group)))
366 (gnus-inews-add-send-actions ,winconf ,buffer ,article ,config)
367 (gnus-inews-insert-draft-meta-information ,group ,article)
368 (setq gnus-message-buffer (current-buffer))
369 (set (make-local-variable 'gnus-message-group-art)
370 (cons ,group ,article))
371 (set (make-local-variable 'gnus-newsgroup-name) ,group)
372 (gnus-run-hooks 'gnus-message-setup-hook)
373 (if (eq major-mode 'message-mode)
374 (let ((mbl1 mml-buffer-list))
375 (setq mml-buffer-list mbl) ;; Global value
376 (set (make-local-variable 'mml-buffer-list) mbl1);; Local value
377 ;; LOCAL argument of add-hook differs between GNU Emacs
378 ;; and XEmacs. make-local-hook makes sure they are local.
379 (make-local-hook 'kill-buffer-hook)
380 (make-local-hook 'change-major-mode-hook)
381 (add-hook 'change-major-mode-hook 'mml-destroy-buffers nil t)
382 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))
383 (mml-destroy-buffers)
384 (setq mml-buffer-list mbl)))
386 (gnus-configure-windows ,config t)
387 (run-hooks 'post-command-hook)
388 (set-buffer-modified-p nil))))
390 (defun gnus-inews-insert-draft-meta-information (group article)
393 (not (string= group ""))
394 (not (message-fetch-field gnus-draft-meta-information-header)))
395 (goto-char (point-min))
396 (insert gnus-draft-meta-information-header ": (\"" group "\" "
397 (if article (number-to-string
404 (defun gnus-msg-mail (&optional to subject other-headers continue
405 switch-action yank-action send-actions)
406 "Start editing a mail message to be sent.
407 Like `message-mail', but with Gnus paraphernalia, particularly the
408 Gcc: header for archiving purposes."
410 (let ((buf (current-buffer))
412 (gnus-setup-message 'message
413 (message-mail to subject other-headers continue
414 nil yank-action send-actions))
416 (setq mail-buf (current-buffer))
417 (switch-to-buffer buf)
418 (apply switch-action mail-buf nil)))
419 ;; COMPOSEFUNC should return t if succeed. Undocumented ???
422 (defvar save-selected-window-window)
425 (defun gnus-button-mailto (address)
427 (set-buffer (gnus-copy-article-buffer))
428 (gnus-setup-message 'message
429 (message-reply address))
430 (and (boundp 'save-selected-window-window)
431 (not (window-live-p save-selected-window-window))
432 (setq save-selected-window-window (selected-window))))
435 (defun gnus-button-reply (&optional to-address wide)
436 "Like `message-reply'."
438 (gnus-setup-message 'message
439 (message-reply to-address wide))
440 (and (boundp 'save-selected-window-window)
441 (not (window-live-p save-selected-window-window))
442 (setq save-selected-window-window (selected-window))))
445 (define-mail-user-agent 'gnus-user-agent
446 'gnus-msg-mail 'message-send-and-exit
447 'message-kill-buffer 'message-send-hook)
449 (defun gnus-setup-posting-charset (group)
450 (let ((alist gnus-group-posting-charset-alist)
451 (group (or group ""))
455 (while (setq elem (pop alist))
456 (when (or (and (stringp (car elem))
457 (string-match (car elem) group))
458 (and (gnus-functionp (car elem))
459 (funcall (car elem) group))
460 (and (symbolp (car elem))
461 (symbol-value (car elem))))
462 (throw 'found (cons (cadr elem) (caddr elem)))))))))
464 (defun gnus-inews-add-send-actions (winconf buffer article &optional config)
465 (make-local-hook 'message-sent-hook)
466 (add-hook 'message-sent-hook (if gnus-agent 'gnus-agent-possibly-do-gcc
467 'gnus-inews-do-gcc) nil t)
469 (make-local-hook 'message-header-hook)
470 (add-hook 'message-header-hook 'gnus-agent-possibly-save-gcc nil t))
471 (setq message-post-method
473 (gnus-post-method arg ,gnus-newsgroup-name)))
474 (setq message-newsreader (setq message-mailer (gnus-extended-version)))
476 `(set-window-configuration ,winconf) 'exit 'postpone 'kill)
478 `(when (gnus-buffer-exists-p ,buffer)
482 (if (eq config 'forward)
483 `(gnus-summary-mark-article-as-forwarded ',article)
484 `(gnus-summary-mark-article-as-replied ',article)))))
487 (put 'gnus-setup-message 'lisp-indent-function 1)
488 (put 'gnus-setup-message 'edebug-form-spec '(form body))
490 ;;; Post news commands of Gnus group mode and summary mode
492 (defun gnus-group-mail (&optional arg)
493 "Start composing a mail.
494 If ARG, use the group under the point to find a posting style.
495 If ARG is 1, prompt for a group name to find the posting style."
497 ;; We can't `let' gnus-newsgroup-name here, since that leads
498 ;; to local variables leaking.
499 (let ((group gnus-newsgroup-name)
500 ;; make sure last viewed article doesn't affect posting styles:
502 (buffer (current-buffer)))
505 (setq gnus-newsgroup-name
507 (if (= 1 (prefix-numeric-value arg))
508 (completing-read "Use posting style of group: "
509 gnus-active-hashtb nil
510 (gnus-read-active-file-p))
511 (gnus-group-group-name))
513 ;; #### see comment in gnus-setup-message -- drv
514 (gnus-setup-message 'message (message-mail)))
517 (setq gnus-newsgroup-name group)))))
519 (defun gnus-group-news (&optional arg)
520 "Start composing a news.
521 If ARG, post to group under point.
522 If ARG is 1, prompt for group name to post to.
524 This function prepares a news even when using mail groups. This is useful
525 for posting messages to mail groups without actually sending them over the
526 network. The corresponding backend must have a 'request-post method."
528 ;; We can't `let' gnus-newsgroup-name here, since that leads
529 ;; to local variables leaking.
530 (let ((group gnus-newsgroup-name)
531 ;; make sure last viewed article doesn't affect posting styles:
533 (buffer (current-buffer)))
536 (setq gnus-newsgroup-name
538 (if (= 1 (prefix-numeric-value arg))
539 (completing-read "Use group: "
540 gnus-active-hashtb nil
541 (gnus-read-active-file-p))
542 (gnus-group-group-name))
544 ;; #### see comment in gnus-setup-message -- drv
545 (gnus-setup-message 'message
546 (message-news (gnus-group-real-name gnus-newsgroup-name))))
549 (setq gnus-newsgroup-name group)))))
551 (defun gnus-group-post-news (&optional arg)
552 "Start composing a message (a news by default).
553 If ARG, post to group under point. If ARG is 1, prompt for group name.
554 Depending on the selected group, the message might be either a mail or
557 ;; Bind this variable here to make message mode hooks work ok.
558 (let ((gnus-newsgroup-name
560 (if (= 1 (prefix-numeric-value arg))
561 (completing-read "Newsgroup: " gnus-active-hashtb nil
562 (gnus-read-active-file-p))
563 (gnus-group-group-name))
565 ;; make sure last viewed article doesn't affect posting styles:
567 (gnus-post-news 'post gnus-newsgroup-name)))
569 (defun gnus-summary-mail-other-window (&optional arg)
570 "Start composing a mail in another window.
571 Use the posting of the current group by default.
572 If ARG, don't do that. If ARG is 1, prompt for group name to find the
575 ;; We can't `let' gnus-newsgroup-name here, since that leads
576 ;; to local variables leaking.
577 (let ((group gnus-newsgroup-name)
578 ;; make sure last viewed article doesn't affect posting styles:
580 (buffer (current-buffer)))
583 (setq gnus-newsgroup-name
585 (if (= 1 (prefix-numeric-value arg))
586 (completing-read "Use group: "
587 gnus-active-hashtb nil
588 (gnus-read-active-file-p))
590 gnus-newsgroup-name))
591 ;; #### see comment in gnus-setup-message -- drv
592 (gnus-setup-message 'message (message-mail)))
595 (setq gnus-newsgroup-name group)))))
597 (defun gnus-summary-news-other-window (&optional arg)
598 "Start composing a news in another window.
599 Post to the current group by default.
600 If ARG, don't do that. If ARG is 1, prompt for group name to post to.
602 This function prepares a news even when using mail groups. This is useful
603 for posting messages to mail groups without actually sending them over the
604 network. The corresponding backend must have a 'request-post method."
606 ;; We can't `let' gnus-newsgroup-name here, since that leads
607 ;; to local variables leaking.
608 (let ((group gnus-newsgroup-name)
609 ;; make sure last viewed article doesn't affect posting styles:
611 (buffer (current-buffer)))
614 (setq gnus-newsgroup-name
616 (if (= 1 (prefix-numeric-value arg))
617 (completing-read "Use group: "
618 gnus-active-hashtb nil
619 (gnus-read-active-file-p))
621 gnus-newsgroup-name))
622 ;; #### see comment in gnus-setup-message -- drv
623 (gnus-setup-message 'message
624 (message-news (gnus-group-real-name gnus-newsgroup-name))))
627 (setq gnus-newsgroup-name group)))))
629 (defun gnus-summary-post-news (&optional arg)
630 "Start composing a message. Post to the current group by default.
631 If ARG, don't do that. If ARG is 1, prompt for a group name to post to.
632 Depending on the selected group, the message might be either a mail or
635 ;; Bind this variable here to make message mode hooks work ok.
636 (let ((gnus-newsgroup-name
638 (if (= 1 (prefix-numeric-value arg))
639 (completing-read "Newsgroup: " gnus-active-hashtb nil
640 (gnus-read-active-file-p))
642 gnus-newsgroup-name))
643 ;; make sure last viewed article doesn't affect posting styles:
645 (gnus-post-news 'post gnus-newsgroup-name)))
648 (defun gnus-summary-followup (yank &optional force-news)
649 "Compose a followup to an article.
650 If prefix argument YANK is non-nil, the original article is yanked
652 YANK is a list of elements, where the car of each element is the
653 article number, and the two following numbers is the region to be
656 (list (and current-prefix-arg
657 (gnus-summary-work-articles 1))))
659 (gnus-summary-goto-subject
660 (if (listp (car yank))
663 (save-window-excursion
664 (gnus-summary-select-article))
665 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
666 (gnus-newsgroup-name gnus-newsgroup-name))
668 (gnus-post-news nil gnus-newsgroup-name
669 headers gnus-article-buffer
671 (gnus-summary-handle-replysign)))
673 (defun gnus-summary-followup-with-original (n &optional force-news)
674 "Compose a followup to an article and include the original article."
676 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
678 (defun gnus-summary-followup-to-mail (&optional arg)
679 "Followup to the current mail message via news."
681 (list (and current-prefix-arg
682 (gnus-summary-work-articles 1))))
683 (gnus-summary-followup arg t))
685 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
686 "Followup to the current mail message via news."
688 (gnus-summary-followup (gnus-summary-work-articles arg) t))
690 (defun gnus-inews-yank-articles (articles)
691 (let (beg article yank-string)
693 (while (setq article (pop articles))
694 (when (listp article)
695 (setq yank-string (nth 1 article)
696 article (nth 0 article)))
697 (save-window-excursion
698 (set-buffer gnus-summary-buffer)
699 (gnus-summary-select-article nil nil nil article)
700 (gnus-summary-remove-process-mark article))
701 (gnus-copy-article-buffer nil yank-string)
702 (let ((message-reply-buffer gnus-article-copy)
703 (message-reply-headers
704 ;; The headers are decoded.
705 (with-current-buffer gnus-article-copy
707 (nnheader-narrow-to-headers)
708 (ietf-drums-unfold-fws)
709 (nnheader-parse-head t)))))
710 (message-yank-original)
711 (setq beg (or beg (mark t))))
717 (defun gnus-summary-cancel-article (&optional n symp)
718 "Cancel an article you posted.
719 Uses the process-prefix convention. If given the symbolic
720 prefix `a', cancel using the standard posting method; if not
721 post using the current select method."
722 (interactive (gnus-interactive "P\ny"))
723 (let ((articles (gnus-summary-work-articles n))
726 (gnus-post-method (eq ',symp 'a) ,gnus-newsgroup-name)))
728 (while (setq article (pop articles))
729 (when (gnus-summary-select-article t nil nil article)
730 (when (gnus-eval-in-buffer-window gnus-original-article-buffer
731 (message-cancel-news))
732 (gnus-summary-mark-as-read article gnus-canceled-mark)
733 (gnus-cache-remove-article 1))
734 (gnus-article-hide-headers-if-wanted))
735 (gnus-summary-remove-process-mark article))))
737 (defun gnus-summary-supersede-article ()
738 "Compose an article that will supersede a previous article.
739 This is done simply by taking the old article and adding a Supersedes
740 header line with the old Message-ID."
742 (let ((article (gnus-summary-article-number)))
743 (gnus-setup-message 'reply-yank
744 (gnus-summary-select-article t)
745 (set-buffer gnus-original-article-buffer)
749 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
751 (set-buffer ,gnus-summary-buffer)
752 (gnus-cache-possibly-remove-article ,article nil nil nil t)
753 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
754 message-send-actions))))
758 (defun gnus-copy-article-buffer (&optional article-buffer yank-string)
759 ;; make a copy of the article buffer with all text properties removed
760 ;; this copy is in the buffer gnus-article-copy.
761 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
762 ;; this buffer should be passed to all mail/news reply/post routines.
763 (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
765 (set-buffer gnus-article-copy)
766 (mm-enable-multibyte))
767 (let ((article-buffer (or article-buffer gnus-article-buffer))
769 (if (not (and (get-buffer article-buffer)
770 (gnus-buffer-exists-p article-buffer)))
771 (error "Can't find any article buffer")
773 (set-buffer article-buffer)
774 (let ((gnus-newsgroup-charset (or gnus-article-charset
775 gnus-newsgroup-charset))
776 (gnus-newsgroup-ignored-charsets
777 (or gnus-article-ignored-charsets
778 gnus-newsgroup-ignored-charsets)))
780 ;; Copy over the (displayed) article buffer, delete
781 ;; hidden text and remove text properties.
783 (copy-to-buffer gnus-article-copy (point-min) (point-max))
784 (set-buffer gnus-article-copy)
787 (delete-region (point) (point-max))
788 (insert yank-string))
789 (gnus-article-delete-text-of-type 'annotation)
790 (gnus-remove-text-with-property 'gnus-prev)
791 (gnus-remove-text-with-property 'gnus-next)
792 (gnus-remove-text-with-property 'gnus-decoration)
795 (buffer-substring-no-properties (point-min) (point-max))
797 ;; Find the original headers.
798 (set-buffer gnus-original-article-buffer)
799 (goto-char (point-min))
800 (while (looking-at message-unix-mail-delimiter)
803 end (or (message-goto-body) beg))
804 ;; Delete the headers from the displayed articles.
805 (set-buffer gnus-article-copy)
806 (delete-region (goto-char (point-min))
807 (or (message-goto-body) (point-max)))
808 ;; Insert the original article headers.
809 (insert-buffer-substring gnus-original-article-buffer beg end)
811 (let ((gnus-article-decode-hook
812 (delq 'article-decode-charset
813 (copy-sequence gnus-article-decode-hook))))
814 (run-hooks 'gnus-article-decode-hook)))))
817 (defun gnus-post-news (post &optional group header article-buffer yank subject
820 (gnus-copy-article-buffer))
821 (let ((gnus-article-reply (and article-buffer (gnus-summary-article-number)))
822 (add-to-list gnus-add-to-list))
823 (gnus-setup-message (cond (yank 'reply-yank)
824 (article-buffer 'reply)
826 (let* ((group (or group gnus-newsgroup-name))
827 (charset (gnus-group-name-charset nil group))
829 to-address to-group mailing-list to-list
832 (setq to-address (gnus-parameter-to-address group)
833 to-group (gnus-group-find-parameter group 'to-group)
834 to-list (gnus-parameter-to-list group)
835 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
836 mailing-list (when gnus-mailing-list-groups
837 (string-match gnus-mailing-list-groups group))
838 group (gnus-group-name-decode (gnus-group-real-name group)
840 (if (or (and to-group
841 (gnus-news-group-p to-group))
844 (and (gnus-news-group-p
845 (or pgroup gnus-newsgroup-name)
846 (or header gnus-current-article))
852 (message-news (or to-group group))
853 (set-buffer gnus-article-copy)
854 (gnus-msg-treat-broken-reply-to)
855 (message-followup (if (or newsgroup-p force-news)
856 (if (save-restriction
857 (article-narrow-to-head)
858 (message-fetch-field "newsgroups"))
865 (message-mail (or to-address to-list))
866 ;; Arrange for mail groups that have no `to-address' to
867 ;; get that when the user sends off the mail.
868 (when (and (not to-list)
871 (push (list 'gnus-inews-add-to-address pgroup)
872 message-send-actions)))
873 (set-buffer gnus-article-copy)
874 (gnus-msg-treat-broken-reply-to)
875 (message-wide-reply to-address)))
877 (gnus-inews-yank-articles yank))))))
879 (defun gnus-msg-treat-broken-reply-to (&optional force)
880 "Remove the Reply-to header iff broken-reply-to."
882 (gnus-group-find-parameter
883 gnus-newsgroup-name 'broken-reply-to))
885 (message-narrow-to-head)
886 (message-remove-header "reply-to"))))
888 (defun gnus-post-method (arg group &optional silent)
889 "Return the posting method based on GROUP and ARG.
890 If SILENT, don't prompt the user."
891 (let ((gnus-post-method (or (gnus-parameter-post-method group)
893 (group-method (gnus-find-method-for-group group)))
895 ;; If the group-method is nil (which shouldn't happen) we use
896 ;; the default method.
898 (or (and (listp gnus-post-method) ;If not current/native/nil
899 (not (listp (car gnus-post-method))) ; and not a list of methods
900 gnus-post-method) ;then use it.
902 message-post-method))
903 ;; We want the inverse of the default
904 ((and arg (not (eq arg 0)))
905 (if (eq gnus-post-method 'current)
908 ;; We query the user for a post method.
910 (and (listp gnus-post-method)
911 (listp (car gnus-post-method))))
913 ;; Collect all methods we know about.
915 (when (listp gnus-post-method)
916 (if (listp (car gnus-post-method))
918 (list gnus-post-method)))
919 gnus-secondary-select-methods
920 (mapcar 'cdr gnus-server-alist)
921 (mapcar 'car gnus-opened-servers)
922 (list gnus-select-method)
923 (list group-method)))
924 method-alist post-methods method)
925 ;; Weed out all mail methods.
927 (setq method (gnus-server-get-method "" (pop methods)))
928 (when (and (or (gnus-method-option-p method 'post)
929 (gnus-method-option-p method 'post-mail))
930 (not (member method post-methods)))
931 (push method post-methods)))
932 ;; Create a name-method alist.
936 (if (equal (cadr m) "")
937 (list (symbol-name (car m)) m)
938 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m)))
943 (setq gnus-last-posting-server
945 gnus-last-posting-server)
946 ;; Just use the last value.
947 gnus-last-posting-server
949 "Posting method: " method-alist nil t
950 (cons (or gnus-last-posting-server "") 0))))
952 ;; Override normal method.
953 ((and (eq gnus-post-method 'current)
954 (not (memq (car group-method) gnus-discouraged-post-methods))
955 (gnus-get-function group-method 'request-post t))
958 ;; Use gnus-post-method.
959 ((listp gnus-post-method) ;A method...
960 (assert (not (listp (car gnus-post-method)))) ;... not a list of methods.
962 ;; Use the normal select method (nil or native).
963 (t gnus-select-method))))
967 ;; Dummies to avoid byte-compile warning.
969 (defvar nnspool-rejected-article-hook)
970 (defvar xemacs-codename))
972 (defun gnus-extended-version ()
973 "Stringified Gnus version and Emacs version."
976 "Gnus/" (prin1-to-string (gnus-continuum-version gnus-version) t)
977 " (" gnus-version ")"
980 ((string-match "^\\(\\([.0-9]+\\)*\\)\\.[0-9]+$" emacs-version)
981 (concat "Emacs/" (match-string 1 emacs-version)
982 " (" system-configuration ")"))
983 ((string-match "\\([A-Z]*[Mm][Aa][Cc][Ss]\\)[^(]*\\(\\((beta.*)\\|'\\)\\)?"
985 (concat (match-string 1 emacs-version)
986 (format "/%d.%d" emacs-major-version emacs-minor-version)
987 (if (match-beginning 3)
988 (match-string 3 emacs-version)
990 (if (boundp 'xemacs-codename)
991 (concat " (" xemacs-codename ", " system-configuration ")")
997 ;;; Gnus Mail Functions
1000 ;;; Mail reply commands of Gnus summary mode
1002 (defun gnus-summary-reply (&optional yank wide very-wide)
1003 "Start composing a mail reply to the current message.
1004 If prefix argument YANK is non-nil, the original article is yanked
1006 If WIDE, make a wide reply.
1007 If VERY-WIDE, make a very wide reply."
1009 (list (and current-prefix-arg
1010 (gnus-summary-work-articles 1))))
1011 ;; Allow user to require confirmation before replying by mail to the
1012 ;; author of a news article.
1013 (when (or (not (gnus-news-group-p gnus-newsgroup-name))
1014 (not gnus-confirm-mail-reply-to-news)
1015 (y-or-n-p "Really reply by mail to article author? "))
1017 (if (listp (car yank))
1020 (gnus-article-reply (or article (gnus-summary-article-number)))
1022 ;; Stripping headers should be specified with mail-yank-ignored-headers.
1024 (gnus-summary-goto-subject article))
1025 (gnus-setup-message (if yank 'reply-yank 'reply)
1027 (gnus-summary-select-article)
1028 (dolist (article very-wide)
1029 (gnus-summary-select-article nil nil nil article)
1031 (set-buffer (gnus-copy-article-buffer))
1032 (gnus-msg-treat-broken-reply-to)
1034 (message-narrow-to-head)
1035 (setq headers (concat headers (buffer-string)))))))
1036 (set-buffer (gnus-copy-article-buffer))
1037 (gnus-msg-treat-broken-reply-to gnus-msg-force-broken-reply-to)
1039 (message-narrow-to-head)
1043 (goto-char (point-max)))
1044 (mml-quote-region (point) (point-max))
1045 (message-reply nil wide)
1047 (gnus-inews-yank-articles yank))
1048 (gnus-summary-handle-replysign)))))
1050 (defun gnus-summary-handle-replysign ()
1051 "Check the various replysign variables and take action accordingly."
1052 (when (or gnus-message-replysign gnus-message-replyencrypt)
1053 (let (signed encrypted)
1055 (set-buffer gnus-article-buffer)
1056 (setq signed (memq 'signed gnus-article-wash-types))
1057 (setq encrypted (memq 'encrypted gnus-article-wash-types)))
1058 (cond ((and gnus-message-replysign signed)
1059 (mml-secure-message mml-default-sign-method 'sign))
1060 ((and gnus-message-replyencrypt encrypted)
1061 (mml-secure-message mml-default-encrypt-method
1062 (if gnus-message-replysignencrypted
1066 (defun gnus-summary-reply-with-original (n &optional wide)
1067 "Start composing a reply mail to the current message.
1068 The original article will be yanked."
1070 (gnus-summary-reply (gnus-summary-work-articles n) wide))
1072 (defun gnus-summary-reply-broken-reply-to (&optional yank wide very-wide)
1073 "Like `gnus-summary-reply' except removing reply-to field.
1074 If prefix argument YANK is non-nil, the original article is yanked
1076 If WIDE, make a wide reply.
1077 If VERY-WIDE, make a very wide reply."
1079 (list (and current-prefix-arg
1080 (gnus-summary-work-articles 1))))
1081 (let ((gnus-msg-force-broken-reply-to t))
1082 (gnus-summary-reply yank wide very-wide)))
1084 (defun gnus-summary-reply-broken-reply-to-with-original (n &optional wide)
1085 "Like `gnus-summary-reply-with-original' except removing reply-to field.
1086 The original article will be yanked."
1088 (gnus-summary-reply-broken-reply-to (gnus-summary-work-articles n) wide))
1090 (defun gnus-summary-wide-reply (&optional yank)
1091 "Start composing a wide reply mail to the current message.
1092 If prefix argument YANK is non-nil, the original article is yanked
1095 (list (and current-prefix-arg
1096 (gnus-summary-work-articles 1))))
1097 (gnus-summary-reply yank t))
1099 (defun gnus-summary-wide-reply-with-original (n)
1100 "Start composing a wide reply mail to the current message.
1101 The original article will be yanked."
1103 (gnus-summary-reply-with-original n t))
1105 (defun gnus-summary-very-wide-reply (&optional yank)
1106 "Start composing a very wide reply mail to the current message.
1107 If prefix argument YANK is non-nil, the original article is yanked
1110 (list (and current-prefix-arg
1111 (gnus-summary-work-articles 1))))
1112 (gnus-summary-reply yank t (gnus-summary-work-articles yank)))
1114 (defun gnus-summary-very-wide-reply-with-original (n)
1115 "Start composing a very wide reply mail to the current message.
1116 The original article will be yanked."
1119 (gnus-summary-work-articles n) t (gnus-summary-work-articles n)))
1121 (defun gnus-summary-mail-forward (&optional arg post)
1122 "Forward the current message(s) to another user.
1123 If process marks exist, forward all marked messages;
1124 if ARG is nil, see `message-forward-as-mime' and `message-forward-show-mml';
1125 if ARG is 1, decode the message and forward directly inline;
1126 if ARG is 2, forward message as an rfc822 MIME section;
1127 if ARG is 3, decode message and forward as an rfc822 MIME section;
1128 if ARG is 4, forward message directly inline;
1129 otherwise, use flipped `message-forward-as-mime'.
1130 If POST, post instead of mail.
1131 For the `inline' alternatives, also see the variable
1132 `message-forward-ignored-headers'."
1134 (if (null (cdr (gnus-summary-work-articles nil)))
1135 (let ((message-forward-as-mime message-forward-as-mime)
1136 (message-forward-show-mml message-forward-show-mml))
1140 (setq message-forward-as-mime nil
1141 message-forward-show-mml t))
1143 (setq message-forward-as-mime t
1144 message-forward-show-mml nil))
1146 (setq message-forward-as-mime t
1147 message-forward-show-mml t))
1149 (setq message-forward-as-mime nil
1150 message-forward-show-mml nil))
1152 (setq message-forward-as-mime (not message-forward-as-mime))))
1153 (let ((gnus-article-reply (gnus-summary-article-number)))
1154 (gnus-setup-message 'forward
1155 (gnus-summary-select-article)
1156 (let ((mail-parse-charset
1157 (or (and (gnus-buffer-live-p gnus-article-buffer)
1158 (with-current-buffer gnus-article-buffer
1159 gnus-article-charset))
1160 gnus-newsgroup-charset))
1161 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
1162 (set-buffer gnus-original-article-buffer)
1163 (message-forward post)))))
1164 (gnus-uu-digest-mail-forward arg post)))
1166 (defun gnus-summary-resend-message (address n)
1167 "Resend the current article to ADDRESS."
1169 (list (message-read-from-minibuffer
1170 "Resend message(s) to: "
1171 (when (and gnus-summary-resend-default-address
1172 (gnus-buffer-live-p gnus-original-article-buffer))
1173 ;; If some other article is currently selected, the
1174 ;; initial-contents is wrong. Whatever, it is just the
1175 ;; initial-contents.
1176 (with-current-buffer gnus-original-article-buffer
1177 (nnmail-fetch-field "to"))))
1178 current-prefix-arg))
1179 (let ((articles (gnus-summary-work-articles n))
1181 (while (setq article (pop articles))
1182 (gnus-summary-select-article nil nil nil article)
1184 (set-buffer gnus-original-article-buffer)
1185 (message-resend address))
1186 (gnus-summary-mark-article-as-forwarded article))))
1188 ;; From: Matthieu Moy <Matthieu.Moy@imag.fr>
1189 (defun gnus-summary-resend-message-edit ()
1190 "Resend an article that has already been sent.
1191 A new buffer will be created to allow the user to modify body and
1192 contents of the message, and then, everything will happen as when
1193 composing a new message."
1195 (let ((article (gnus-summary-article-number)))
1196 (gnus-setup-message 'reply-yank
1197 (gnus-summary-select-article t)
1198 (set-buffer gnus-original-article-buffer)
1199 (let ((cur (current-buffer))
1200 (to (message-fetch-field "to")))
1201 ;; Get a normal message buffer.
1202 (message-pop-to-buffer (message-buffer-name "Resend" to))
1203 (insert-buffer-substring cur)
1205 (message-narrow-to-head-1)
1206 ;; Gnus will generate a new one when sending.
1207 (message-remove-header "Message-ID")
1208 (message-remove-header message-ignored-resent-headers t)
1209 ;; Remove unwanted headers.
1210 (goto-char (point-max))
1211 (insert mail-header-separator)
1212 (goto-char (point-min))
1213 (re-search-forward "^To:\\|^Newsgroups:" nil 'move)
1217 (defun gnus-summary-post-forward (&optional arg)
1218 "Forward the current article to a newsgroup.
1219 See `gnus-summary-mail-forward' for ARG."
1221 (gnus-summary-mail-forward arg t))
1223 (defvar gnus-nastygram-message
1224 "The following article was inappropriately posted to %s.\n\n"
1225 "Format string to insert in nastygrams.
1226 The current group name will be inserted at \"%s\".")
1228 (defun gnus-summary-mail-nastygram (n)
1229 "Send a nastygram to the author of the current article."
1231 (when (or gnus-expert-user
1233 "Really send a nastygram to the author of the current article? "))
1234 (let ((group gnus-newsgroup-name))
1235 (gnus-summary-reply-with-original n)
1236 (set-buffer gnus-message-buffer)
1238 (insert (format gnus-nastygram-message group))
1239 (message-send-and-exit))))
1241 (defun gnus-summary-mail-crosspost-complaint (n)
1242 "Send a complaint about crossposting to the current article(s)."
1244 (let ((articles (gnus-summary-work-articles n))
1246 (while (setq article (pop articles))
1247 (set-buffer gnus-summary-buffer)
1248 (gnus-summary-goto-subject article)
1249 (let ((group (gnus-group-real-name gnus-newsgroup-name))
1250 newsgroups followup-to)
1251 (gnus-summary-select-article)
1252 (set-buffer gnus-original-article-buffer)
1253 (if (and (<= (length (message-tokenize-header
1255 (mail-fetch-field "newsgroups"))
1258 (or (not (setq followup-to (mail-fetch-field "followup-to")))
1259 (not (member group (message-tokenize-header
1260 followup-to ", ")))))
1262 (gnus-message 1 "Followup-to restricted")
1263 (gnus-message 1 "Not a crossposted article"))
1264 (set-buffer gnus-summary-buffer)
1265 (gnus-summary-reply-with-original 1)
1266 (set-buffer gnus-message-buffer)
1268 (insert (format gnus-crosspost-complaint newsgroups group))
1269 (message-goto-subject)
1270 (re-search-forward " *$")
1271 (replace-match " (crosspost notification)" t t)
1272 (gnus-deactivate-mark)
1273 (when (gnus-y-or-n-p "Send this complaint? ")
1274 (message-send-and-exit)))))))
1276 (defun gnus-mail-parse-comma-list ()
1279 (skip-chars-forward " ")
1282 (skip-chars-forward "^,")
1287 (narrow-to-region beg (point))
1290 (while (search-forward "\"" nil t)
1294 (skip-chars-forward ",")
1295 (skip-chars-forward "^,"))
1296 (skip-chars-backward " ")
1297 (push (buffer-substring beg (point))
1299 (skip-chars-forward "^,")
1300 (skip-chars-forward ", "))
1303 (defun gnus-inews-add-to-address (group)
1304 (let ((to-address (mail-fetch-field "to")))
1305 (when (and to-address
1307 ;; This mail group doesn't have a `to-list', so we add one
1309 (when (gnus-y-or-n-p
1310 (format "Do you want to add this as `to-list': %s " to-address))
1311 (gnus-group-add-parameter group (cons 'to-list to-address))))))
1313 (defun gnus-put-message ()
1314 "Put the current message in some group and return to Gnus."
1316 (let ((reply gnus-article-reply)
1317 (winconf gnus-prev-winconf)
1318 (group gnus-newsgroup-name))
1320 (not (gnus-group-read-only-p group)))
1321 (setq group (read-string "Put in group: " nil (gnus-writable-groups))))
1323 (when (gnus-gethash group gnus-newsrc-hashtb)
1324 (error "No such group: %s" group))
1328 (message-narrow-to-headers)
1329 (let ((gnus-deletable-headers nil))
1330 (message-generate-headers
1331 (if (message-news-p)
1332 message-required-news-headers
1333 message-required-mail-headers)))
1334 (goto-char (point-max))
1335 (insert "Gcc: " group "\n")
1338 (when (and (get-buffer gnus-group-buffer)
1339 (gnus-buffer-exists-p (car-safe reply))
1341 (set-buffer (car reply))
1342 (gnus-summary-mark-article-as-replied (cdr reply)))
1344 (set-window-configuration winconf))))
1346 (defun gnus-article-mail (yank)
1347 "Send a reply to the address near point.
1348 If YANK is non-nil, include the original article."
1352 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
1353 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
1355 (gnus-msg-mail address)
1357 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
1359 (defvar nntp-server-type)
1361 "Send a bug report to the Gnus maintainers."
1363 (unless (gnus-alive-p)
1364 (error "Gnus has been shut down"))
1365 (gnus-setup-message (if (message-mail-user-agent) 'message 'bug)
1366 (unless (message-mail-user-agent)
1367 (delete-other-windows)
1368 (when gnus-bug-create-help-buffer
1369 (switch-to-buffer "*Gnus Help Bug*")
1371 (insert gnus-bug-message)
1372 (goto-char (point-min)))
1373 (message-pop-to-buffer "*Gnus Bug*"))
1374 (let ((message-this-is-mail t))
1375 (message-setup `((To . ,gnus-maintainer) (Subject . ""))))
1376 (when gnus-bug-create-help-buffer
1377 (push `(gnus-bug-kill-buffer) message-send-actions))
1378 (goto-char (point-min))
1379 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
1381 (insert (gnus-version) "\n"
1382 (emacs-version) "\n")
1383 (when (and (boundp 'nntp-server-type)
1384 (stringp nntp-server-type))
1385 (insert nntp-server-type))
1386 (insert "\n\n\n\n\n")
1389 (set-buffer (gnus-get-buffer-create " *gnus environment info*"))
1392 (setq text (buffer-string)))
1393 (insert "<#part type=application/emacs-lisp disposition=inline description=\"User settings\">\n" text "\n<#/part>"))
1394 (goto-char (point-min))
1395 (search-forward "Subject: " nil t)
1398 (defun gnus-bug-kill-buffer ()
1399 (when (get-buffer "*Gnus Help Bug*")
1400 (kill-buffer "*Gnus Help Bug*")))
1402 (defun gnus-summary-yank-message (buffer n)
1403 "Yank the current article into a composed message."
1405 (list (completing-read "Buffer: " (mapcar 'list (message-buffers)) nil t)
1406 current-prefix-arg))
1407 (gnus-summary-iterate n
1408 (let ((gnus-display-mime-function nil)
1409 (gnus-inhibit-treatment t))
1410 (gnus-summary-select-article))
1413 (message-yank-buffer gnus-article-buffer))))
1415 (defun gnus-debug ()
1416 "Attempts to go through the Gnus source file and report what variables have been changed.
1417 The source file has to be in the Emacs load path."
1419 (let ((files gnus-debug-files)
1421 file expr olist sym)
1422 (gnus-message 4 "Please wait while we snoop your variables...")
1424 ;; Go through all the files looking for non-default values for variables.
1426 (set-buffer (gnus-get-buffer-create " *gnus bug info*"))
1429 (when (and (setq file (locate-library (pop files)))
1430 (file-exists-p file))
1431 (insert-file-contents file)
1432 (goto-char (point-min))
1433 (if (not (re-search-forward "^;;* *Internal variables" nil t))
1434 (gnus-message 4 "Malformed sources in file %s" file)
1435 (narrow-to-region (point-min) (point))
1436 (goto-char (point-min))
1437 (while (setq expr (ignore-errors (read (current-buffer))))
1439 (and (or (eq (car expr) 'defvar)
1440 (eq (car expr) 'defcustom))
1441 (stringp (nth 3 expr))
1442 (not (memq (nth 1 expr) gnus-debug-exclude-variables))
1443 (or (not (boundp (nth 1 expr)))
1444 (not (equal (eval (nth 2 expr))
1445 (symbol-value (nth 1 expr)))))
1446 (push (nth 1 expr) olist)))))))
1447 (kill-buffer (current-buffer)))
1448 (when (setq olist (nreverse olist))
1449 (insert "------------------ Environment follows ------------------\n\n"))
1451 (if (boundp (car olist))
1453 (pp `(setq ,(car olist)
1454 ,(if (or (consp (setq sym (symbol-value (car olist))))
1456 (not (or (eq sym nil)
1458 (list 'quote (symbol-value (car olist)))
1459 (symbol-value (car olist))))
1462 (format "(setq %s 'whatever)\n" (car olist))))
1463 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
1464 (setq olist (cdr olist)))
1466 ;; Remove any control chars - they seem to cause trouble for some
1467 ;; mailers. (Byte-compiled output from the stuff above.)
1469 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
1470 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
1473 ;;; Treatment of rejected articles.
1476 (defun gnus-summary-resend-bounced-mail (&optional fetch)
1477 "Re-mail the current message.
1478 This only makes sense if the current message is a bounce message than
1479 contains some mail you have written which has been bounced back to
1481 If FETCH, try to fetch the article that this is a reply to, if indeed
1484 (gnus-summary-select-article t)
1485 (set-buffer gnus-original-article-buffer)
1486 (gnus-setup-message 'compose-bounce
1487 (let* ((references (mail-fetch-field "references"))
1488 (parent (and references (gnus-parent-id references))))
1490 ;; If there are references, we fetch the article we answered to.
1492 (gnus-summary-refer-article parent)
1493 (gnus-summary-show-all-headers)))))
1497 (defun gnus-inews-group-method (group)
1499 ;; If the group doesn't exist, we assume
1500 ;; it's an archive group...
1501 ((and (null (gnus-get-info group))
1502 (eq (car (gnus-server-to-method gnus-message-archive-method))
1503 (car (gnus-server-to-method (gnus-group-method group)))))
1504 gnus-message-archive-method)
1506 ((gnus-info-method (gnus-get-info group))
1507 (gnus-info-method (gnus-get-info group)))
1509 (t (gnus-server-to-method (gnus-group-method group)))))
1511 ;; Do Gcc handling, which copied the message over to some group.
1512 (defun gnus-inews-do-gcc (&optional gcc)
1516 (message-narrow-to-headers)
1517 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
1518 (cur (current-buffer))
1519 groups group method group-art
1520 mml-externalize-attachments)
1522 (message-remove-header "gcc")
1524 (setq groups (message-unquote-tokens
1525 (message-tokenize-header gcc " ,")))
1526 ;; Copy the article over to some group(s).
1527 (while (setq group (pop groups))
1528 (unless (gnus-check-server
1529 (setq method (gnus-inews-group-method group)))
1530 (error "Can't open server %s" (if (stringp method) method
1532 (unless (gnus-request-group group nil method)
1533 (gnus-request-create-group group method))
1534 (setq mml-externalize-attachments
1535 (if (stringp gnus-gcc-externalize-attachments)
1536 (string-match gnus-gcc-externalize-attachments group)
1537 gnus-gcc-externalize-attachments))
1539 (nnheader-set-temp-buffer " *acc*")
1540 (insert-buffer-substring cur)
1541 (message-encode-message-body)
1543 (message-narrow-to-headers)
1544 (let* ((mail-parse-charset message-default-charset)
1545 (newsgroups-field (save-restriction
1546 (message-narrow-to-headers-or-head)
1547 (message-fetch-field "Newsgroups")))
1548 (followup-field (save-restriction
1549 (message-narrow-to-headers-or-head)
1550 (message-fetch-field "Followup-To")))
1551 ;; BUG: We really need to get the charset for
1552 ;; each name in the Newsgroups and Followup-To
1553 ;; lines to allow crossposting between group
1554 ;; namess with incompatible character sets.
1555 ;; -- Per Abrahamsen <abraham@dina.kvl.dk> 2001-10-08.
1556 (group-field-charset
1557 (gnus-group-name-charset
1558 method (or newsgroups-field "")))
1559 (followup-field-charset
1560 (gnus-group-name-charset
1561 method (or followup-field "")))
1562 (rfc2047-header-encoding-alist
1564 (when group-field-charset
1565 (list (cons "Newsgroups" group-field-charset)))
1566 (when followup-field-charset
1567 (list (cons "Followup-To" followup-field-charset)))
1568 rfc2047-header-encoding-alist)))
1569 (mail-encode-encoded-word-buffer)))
1570 (goto-char (point-min))
1571 (when (re-search-forward
1572 (concat "^" (regexp-quote mail-header-separator) "$")
1574 (replace-match "" t t ))
1575 (unless (setq group-art
1576 (gnus-request-accept-article group method t t))
1577 (gnus-message 1 "Couldn't store article in group %s: %s"
1578 group (gnus-status-message method))
1580 (when (and group-art
1581 (or gnus-gcc-mark-as-read
1582 gnus-inews-mark-gcc-as-read))
1583 (gnus-group-mark-article-read group (cdr group-art)))
1584 (kill-buffer (current-buffer)))))))))
1586 (defun gnus-inews-insert-gcc ()
1587 "Insert Gcc headers based on `gnus-outgoing-message-group'."
1590 (message-narrow-to-headers)
1591 (let* ((group gnus-outgoing-message-group)
1593 ((gnus-functionp group)
1595 ((or (stringp group) (list group))
1599 (if (stringp gcc) gcc
1600 (mapconcat 'identity gcc " "))
1603 (defun gnus-inews-insert-archive-gcc (&optional group)
1604 "Insert the Gcc to say where the article is to be archived."
1605 (let* ((var gnus-message-archive-group)
1606 (group (or group gnus-newsgroup-name ""))
1608 (and gnus-newsgroup-name
1609 (not (equal gnus-newsgroup-name ""))
1610 (gnus-group-find-parameter
1611 gnus-newsgroup-name 'gcc-self)))
1615 ((null gnus-message-archive-method)
1619 ;; Just a single group.
1622 ;; We don't want this.
1624 ((and (listp var) (stringp (car var)))
1625 ;; A list of groups.
1627 ((gnus-functionp var)
1629 (funcall var group))
1631 ;; An alist of regexps/functions/forms.
1636 ((stringp (caar var))
1638 (when (string-match (caar var) group)
1640 ((gnus-functionp (car var))
1642 (funcall (car var) group))
1644 (eval (car var)))))))
1645 (setq var (cdr var)))
1648 (when (or groups gcc-self-val)
1649 (when (stringp groups)
1650 (setq groups (list groups)))
1653 (message-narrow-to-headers)
1654 (goto-char (point-max))
1657 ;; Use the `gcc-self' param value instead.
1660 (if (stringp gcc-self-val)
1663 (if (not (eq gcc-self-val 'none))
1668 ;; Use the list of groups.
1669 (while (setq name (pop groups))
1670 (insert (if (string-match ":" name)
1672 (gnus-group-prefixed-name
1673 name gnus-message-archive-method)))
1680 (defun gnus-configure-posting-styles (&optional group-name)
1681 "Configure posting styles according to `gnus-posting-styles'."
1682 (unless gnus-inhibit-posting-styles
1683 (let ((group (or group-name gnus-newsgroup-name ""))
1684 (styles gnus-posting-styles)
1685 style match variable attribute value v results
1686 filep name address element)
1687 ;; If the group has a posting-style parameter, add it at the end with a
1688 ;; regexp matching everything, to be sure it takes precedence over all
1690 (when gnus-newsgroup-name
1691 (let ((tmp-style (gnus-group-find-parameter group 'posting-style t)))
1693 (setq styles (append styles (list (cons ".*" tmp-style)))))))
1694 ;; Go through all styles and look for matches.
1695 (dolist (style styles)
1696 (setq match (pop style))
1697 (goto-char (point-min))
1700 ;; Regexp string match on the group name.
1701 (string-match match group))
1703 ;; Obsolete format of header match.
1704 (and (gnus-buffer-live-p gnus-article-copy)
1705 (with-current-buffer gnus-article-copy
1706 (let ((header (message-fetch-field (pop style))))
1708 (string-match (pop style) header))))))
1709 ((or (symbolp match)
1710 (gnus-functionp match))
1712 ((gnus-functionp match)
1713 ;; Function to be called.
1716 ;; Variable to be checked.
1717 (symbol-value match))))
1720 ((eq (car match) 'header)
1721 ;; New format of header match.
1722 (and (gnus-buffer-live-p gnus-article-copy)
1723 (with-current-buffer gnus-article-copy
1724 (let ((header (message-fetch-field (nth 1 match))))
1726 (string-match (nth 2 match) header))))))
1728 ;; This is a form to be evaled.
1730 ;; We have a match, so we set the variables.
1731 (dolist (attribute style)
1732 (setq element (pop attribute)
1737 ((eq (car attribute) :file)
1740 ((eq (car attribute) :value)
1744 ;; We get the value.
1749 ((or (symbolp value)
1750 (gnus-functionp value))
1751 (cond ((gnus-functionp value)
1754 (symbol-value value))))
1757 ;; Translate obsolescent value.
1759 ((eq element 'signature-file)
1760 (setq element 'signature
1762 ((eq element 'x-face-file)
1763 (setq element 'x-face
1765 ;; Get the contents of file elems.
1767 (setq v (with-temp-buffer
1768 (insert-file-contents v)
1769 (goto-char (point-max))
1773 (setq results (delq (assoc element results) results))
1774 (push (cons element v) results))))
1775 ;; Now we have all the styles, so we insert them.
1776 (setq name (assq 'name results)
1777 address (assq 'address results))
1778 (setq results (delq name (delq address results)))
1779 ;; make-local-hook is not obsolete in Emacs 20 or XEmacs.
1780 (make-local-hook 'message-setup-hook)
1781 (dolist (result results)
1782 (add-hook 'message-setup-hook
1784 ((eq 'eval (car result))
1786 ((eq 'body (car result))
1790 (insert ,(cdr result)))))
1791 ((eq 'signature (car result))
1792 (set (make-local-variable 'message-signature) nil)
1793 (set (make-local-variable 'message-signature-file) nil)
1794 (if (not (cdr result))
1798 (let ((message-signature ,(cdr result)))
1799 (when message-signature
1800 (message-insert-signature)))))))
1803 (if (symbolp (car result))
1804 (capitalize (symbol-name (car result)))
1808 (message-remove-header ,header)
1809 (let ((value ,(cdr result)))
1812 (insert ,header ": " value "\n"))))))))
1814 (when (or name address)
1815 (add-hook 'message-setup-hook
1817 (set (make-local-variable 'user-mail-address)
1818 ,(or (cdr address) user-mail-address))
1819 (let ((user-full-name ,(or (cdr name) (user-full-name)))
1821 ,(or (cdr address) user-mail-address)))
1823 (message-remove-header "From")
1825 (insert "From: " (message-make-from) "\n"))))
1828 ;;; Allow redefinition of functions.
1834 ;;; gnus-msg.el ends here