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 ;;; Internal variables.
251 (defvar gnus-inhibit-posting-styles nil
252 "Inhibit the use of posting styles.")
254 (defvar gnus-message-buffer "*Mail Gnus*")
255 (defvar gnus-article-copy nil)
256 (defvar gnus-check-before-posting nil)
257 (defvar gnus-last-posting-server nil)
258 (defvar gnus-message-group-art nil)
260 (defvar gnus-msg-force-broken-reply-to nil)
262 (defconst gnus-bug-message
263 "Sending a bug report to the Gnus Towers.
264 ========================================
266 The buffer below is a mail buffer. When you press `C-c C-c', it will
267 be sent to the Gnus Bug Exterminators.
269 The thing near the bottom of the buffer is how the environment
270 settings will be included in the mail. Please do not delete that.
271 They will tell the Bug People what your environment is, so that it
272 will be easier to locate the bugs.
274 If you have found a bug that makes Emacs go \"beep\", set
275 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
276 and include the backtrace in your bug report.
278 Please describe the bug in annoying, painstaking detail.
280 Thank you for your help in stamping out bugs.
284 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
285 (autoload 'news-setup "rnewspost")
286 (autoload 'news-reply-mode "rnewspost")
287 (autoload 'rmail-dont-reply-to "mail-utils")
288 (autoload 'rmail-output "rmailout"))
292 ;;; Gnus Posting Functions
295 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
296 "p" gnus-summary-post-news
297 "i" gnus-summary-news-other-window
298 "f" gnus-summary-followup
299 "F" gnus-summary-followup-with-original
300 "c" gnus-summary-cancel-article
301 "s" gnus-summary-supersede-article
302 "r" gnus-summary-reply
303 "y" gnus-summary-yank-message
304 "R" gnus-summary-reply-with-original
305 "w" gnus-summary-wide-reply
306 "W" gnus-summary-wide-reply-with-original
307 "v" gnus-summary-very-wide-reply
308 "V" gnus-summary-very-wide-reply-with-original
309 "n" gnus-summary-followup-to-mail
310 "N" gnus-summary-followup-to-mail-with-original
311 "m" gnus-summary-mail-other-window
312 "u" gnus-uu-post-news
313 "\M-c" gnus-summary-mail-crosspost-complaint
314 "Br" gnus-summary-reply-broken-reply-to
315 "BR" gnus-summary-reply-broken-reply-to-with-original
316 "om" gnus-summary-mail-forward
317 "op" gnus-summary-post-forward
318 "Om" gnus-uu-digest-mail-forward
319 "Op" gnus-uu-digest-post-forward)
321 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
322 "b" gnus-summary-resend-bounced-mail
323 ;; "c" gnus-summary-send-draft
324 "r" gnus-summary-resend-message
325 "e" gnus-summary-resend-message-edit)
327 ;;; Internal functions.
329 (defvar gnus-article-reply nil)
330 (defmacro gnus-setup-message (config &rest forms)
331 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
332 (buffer (make-symbol "gnus-setup-message-buffer"))
333 (article (make-symbol "gnus-setup-message-article"))
334 (group (make-symbol "gnus-setup-message-group")))
335 `(let ((,winconf (current-window-configuration))
336 (,buffer (buffer-name (current-buffer)))
337 (,article gnus-article-reply)
338 (,group gnus-newsgroup-name)
339 (message-header-setup-hook
340 (copy-sequence message-header-setup-hook))
341 (mbl mml-buffer-list)
342 (message-mode-hook (copy-sequence message-mode-hook)))
343 (setq mml-buffer-list nil)
344 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
345 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
346 ;; #### FIXME: for a reason that I did not manage to identify yet,
347 ;; the variable `gnus-newsgroup-name' does not honor a dynamically
348 ;; scoped or setq'ed value from a caller like `C-u gnus-summary-mail'.
349 ;; After evaluation of @forms below, it gets the value we actually want
350 ;; to override, and the posting styles are used. For that reason, I've
351 ;; added an optional argument to `gnus-configure-posting-styles' to
352 ;; make sure that the correct value for the group name is used. -- drv
353 (add-hook 'message-mode-hook
355 (gnus-configure-posting-styles ,group)))
359 (gnus-inews-add-send-actions ,winconf ,buffer ,article ,config)
360 (gnus-inews-insert-draft-meta-information ,group ,article)
361 (setq gnus-message-buffer (current-buffer))
362 (set (make-local-variable 'gnus-message-group-art)
363 (cons ,group ,article))
364 (set (make-local-variable 'gnus-newsgroup-name) ,group)
365 (gnus-run-hooks 'gnus-message-setup-hook)
366 (if (eq major-mode 'message-mode)
367 (let ((mbl1 mml-buffer-list))
368 (setq mml-buffer-list mbl) ;; Global value
369 (set (make-local-variable 'mml-buffer-list) mbl1);; Local value
370 ;; LOCAL argument of add-hook differs between GNU Emacs
371 ;; and XEmacs. make-local-hook makes sure they are local.
372 (make-local-hook 'kill-buffer-hook)
373 (make-local-hook 'change-major-mode-hook)
374 (add-hook 'change-major-mode-hook 'mml-destroy-buffers nil t)
375 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))
376 (mml-destroy-buffers)
377 (setq mml-buffer-list mbl)))
379 (gnus-configure-windows ,config t)
380 (run-hooks 'post-command-hook)
381 (set-buffer-modified-p nil))))
383 (defun gnus-inews-insert-draft-meta-information (group article)
386 (not (string= group ""))
387 (not (message-fetch-field gnus-draft-meta-information-header)))
388 (goto-char (point-min))
389 (insert gnus-draft-meta-information-header ": (\"" group "\" "
390 (if article (number-to-string
397 (defun gnus-msg-mail (&optional to subject other-headers continue
398 switch-action yank-action send-actions)
399 "Start editing a mail message to be sent.
400 Like `message-mail', but with Gnus paraphernalia, particularly the
401 Gcc: header for archiving purposes."
403 (let ((buf (current-buffer))
405 (gnus-setup-message 'message
406 (message-mail to subject other-headers continue
407 nil yank-action send-actions))
409 (setq mail-buf (current-buffer))
410 (switch-to-buffer buf)
411 (apply switch-action mail-buf nil)))
412 ;; COMPOSEFUNC should return t if succeed. Undocumented ???
415 (defvar save-selected-window-window)
418 (defun gnus-button-mailto (address)
420 (set-buffer (gnus-copy-article-buffer))
421 (gnus-setup-message 'message
422 (message-reply address))
423 (and (boundp 'save-selected-window-window)
424 (not (window-live-p save-selected-window-window))
425 (setq save-selected-window-window (selected-window))))
428 (defun gnus-button-reply (&optional to-address wide)
429 "Like `message-reply'."
431 (gnus-setup-message 'message
432 (message-reply to-address wide))
433 (and (boundp 'save-selected-window-window)
434 (not (window-live-p save-selected-window-window))
435 (setq save-selected-window-window (selected-window))))
438 (define-mail-user-agent 'gnus-user-agent
439 'gnus-msg-mail 'message-send-and-exit
440 'message-kill-buffer 'message-send-hook)
442 (defun gnus-setup-posting-charset (group)
443 (let ((alist gnus-group-posting-charset-alist)
444 (group (or group ""))
448 (while (setq elem (pop alist))
449 (when (or (and (stringp (car elem))
450 (string-match (car elem) group))
451 (and (gnus-functionp (car elem))
452 (funcall (car elem) group))
453 (and (symbolp (car elem))
454 (symbol-value (car elem))))
455 (throw 'found (cons (cadr elem) (caddr elem)))))))))
457 (defun gnus-inews-add-send-actions (winconf buffer article &optional config)
458 (make-local-hook 'message-sent-hook)
459 (add-hook 'message-sent-hook (if gnus-agent 'gnus-agent-possibly-do-gcc
460 'gnus-inews-do-gcc) nil t)
462 (make-local-hook 'message-header-hook)
463 (add-hook 'message-header-hook 'gnus-agent-possibly-save-gcc nil t))
464 (setq message-post-method
466 (gnus-post-method arg ,gnus-newsgroup-name)))
467 (setq message-newsreader (setq message-mailer (gnus-extended-version)))
469 `(set-window-configuration ,winconf) 'exit 'postpone 'kill)
471 `(when (gnus-buffer-exists-p ,buffer)
475 (if (eq config 'forward)
476 `(gnus-summary-mark-article-as-forwarded ',article)
477 `(gnus-summary-mark-article-as-replied ',article)))))
480 (put 'gnus-setup-message 'lisp-indent-function 1)
481 (put 'gnus-setup-message 'edebug-form-spec '(form body))
483 ;;; Post news commands of Gnus group mode and summary mode
485 (defun gnus-group-mail (&optional arg)
486 "Start composing a mail.
487 If ARG, use the group under the point to find a posting style.
488 If ARG is 1, prompt for a group name to find the posting style."
490 ;; We can't `let' gnus-newsgroup-name here, since that leads
491 ;; to local variables leaking.
492 (let ((group gnus-newsgroup-name)
493 ;; make sure last viewed article doesn't affect posting styles:
495 (buffer (current-buffer)))
498 (setq gnus-newsgroup-name
500 (if (= 1 (prefix-numeric-value arg))
501 (completing-read "Use posting style of group: "
502 gnus-active-hashtb nil
503 (gnus-read-active-file-p))
504 (gnus-group-group-name))
506 ;; #### see comment in gnus-setup-message -- drv
507 (gnus-setup-message 'message (message-mail)))
510 (setq gnus-newsgroup-name group)))))
512 (defun gnus-group-news (&optional arg)
513 "Start composing a news.
514 If ARG, post to group under point.
515 If ARG is 1, prompt for group name to post to.
517 This function prepares a news even when using mail groups. This is useful
518 for posting messages to mail groups without actually sending them over the
519 network. The corresponding backend must have a 'request-post method."
521 ;; We can't `let' gnus-newsgroup-name here, since that leads
522 ;; to local variables leaking.
523 (let ((group gnus-newsgroup-name)
524 ;; make sure last viewed article doesn't affect posting styles:
526 (buffer (current-buffer)))
529 (setq gnus-newsgroup-name
531 (if (= 1 (prefix-numeric-value arg))
532 (completing-read "Use group: "
533 gnus-active-hashtb nil
534 (gnus-read-active-file-p))
535 (gnus-group-group-name))
537 ;; #### see comment in gnus-setup-message -- drv
538 (gnus-setup-message 'message
539 (message-news (gnus-group-real-name gnus-newsgroup-name))))
542 (setq gnus-newsgroup-name group)))))
544 (defun gnus-group-post-news (&optional arg)
545 "Start composing a message (a news by default).
546 If ARG, post to group under point. If ARG is 1, prompt for group name.
547 Depending on the selected group, the message might be either a mail or
550 ;; Bind this variable here to make message mode hooks work ok.
551 (let ((gnus-newsgroup-name
553 (if (= 1 (prefix-numeric-value arg))
554 (completing-read "Newsgroup: " gnus-active-hashtb nil
555 (gnus-read-active-file-p))
556 (gnus-group-group-name))
558 ;; make sure last viewed article doesn't affect posting styles:
560 (gnus-post-news 'post gnus-newsgroup-name)))
562 (defun gnus-summary-mail-other-window (&optional arg)
563 "Start composing a mail in another window.
564 Use the posting of the current group by default.
565 If ARG, don't do that. If ARG is 1, prompt for group name to find the
568 ;; We can't `let' gnus-newsgroup-name here, since that leads
569 ;; to local variables leaking.
570 (let ((group gnus-newsgroup-name)
571 ;; make sure last viewed article doesn't affect posting styles:
573 (buffer (current-buffer)))
576 (setq gnus-newsgroup-name
578 (if (= 1 (prefix-numeric-value arg))
579 (completing-read "Use group: "
580 gnus-active-hashtb nil
581 (gnus-read-active-file-p))
583 gnus-newsgroup-name))
584 ;; #### see comment in gnus-setup-message -- drv
585 (gnus-setup-message 'message (message-mail)))
588 (setq gnus-newsgroup-name group)))))
590 (defun gnus-summary-news-other-window (&optional arg)
591 "Start composing a news in another window.
592 Post to the current group by default.
593 If ARG, don't do that. If ARG is 1, prompt for group name to post to.
595 This function prepares a news even when using mail groups. This is useful
596 for posting messages to mail groups without actually sending them over the
597 network. The corresponding backend must have a 'request-post method."
599 ;; We can't `let' gnus-newsgroup-name here, since that leads
600 ;; to local variables leaking.
601 (let ((group gnus-newsgroup-name)
602 ;; make sure last viewed article doesn't affect posting styles:
604 (buffer (current-buffer)))
607 (setq gnus-newsgroup-name
609 (if (= 1 (prefix-numeric-value arg))
610 (completing-read "Use group: "
611 gnus-active-hashtb nil
612 (gnus-read-active-file-p))
614 gnus-newsgroup-name))
615 ;; #### see comment in gnus-setup-message -- drv
616 (gnus-setup-message 'message
617 (message-news (gnus-group-real-name gnus-newsgroup-name))))
620 (setq gnus-newsgroup-name group)))))
622 (defun gnus-summary-post-news (&optional arg)
623 "Start composing a message. Post to the current group by default.
624 If ARG, don't do that. If ARG is 1, prompt for a group name to post to.
625 Depending on the selected group, the message might be either a mail or
628 ;; Bind this variable here to make message mode hooks work ok.
629 (let ((gnus-newsgroup-name
631 (if (= 1 (prefix-numeric-value arg))
632 (completing-read "Newsgroup: " gnus-active-hashtb nil
633 (gnus-read-active-file-p))
635 gnus-newsgroup-name))
636 ;; make sure last viewed article doesn't affect posting styles:
638 (gnus-post-news 'post gnus-newsgroup-name)))
641 (defun gnus-summary-followup (yank &optional force-news)
642 "Compose a followup to an article.
643 If prefix argument YANK is non-nil, the original article is yanked
645 YANK is a list of elements, where the car of each element is the
646 article number, and the two following numbers is the region to be
649 (list (and current-prefix-arg
650 (gnus-summary-work-articles 1))))
652 (gnus-summary-goto-subject
653 (if (listp (car yank))
656 (save-window-excursion
657 (gnus-summary-select-article))
658 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
659 (gnus-newsgroup-name gnus-newsgroup-name))
661 (gnus-post-news nil gnus-newsgroup-name
662 headers gnus-article-buffer
664 (gnus-summary-handle-replysign)))
666 (defun gnus-summary-followup-with-original (n &optional force-news)
667 "Compose a followup to an article and include the original article."
669 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
671 (defun gnus-summary-followup-to-mail (&optional arg)
672 "Followup to the current mail message via news."
674 (list (and current-prefix-arg
675 (gnus-summary-work-articles 1))))
676 (gnus-summary-followup arg t))
678 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
679 "Followup to the current mail message via news."
681 (gnus-summary-followup (gnus-summary-work-articles arg) t))
683 (defun gnus-inews-yank-articles (articles)
684 (let (beg article yank-string)
686 (while (setq article (pop articles))
687 (when (listp article)
688 (setq yank-string (nth 1 article)
689 article (nth 0 article)))
690 (save-window-excursion
691 (set-buffer gnus-summary-buffer)
692 (gnus-summary-select-article nil nil nil article)
693 (gnus-summary-remove-process-mark article))
694 (gnus-copy-article-buffer nil yank-string)
695 (let ((message-reply-buffer gnus-article-copy)
696 (message-reply-headers
697 ;; The headers are decoded.
698 (with-current-buffer gnus-article-copy
700 (nnheader-narrow-to-headers)
701 (ietf-drums-unfold-fws)
702 (nnheader-parse-head t)))))
703 (message-yank-original)
704 (setq beg (or beg (mark t))))
710 (defun gnus-summary-cancel-article (&optional n symp)
711 "Cancel an article you posted.
712 Uses the process-prefix convention. If given the symbolic
713 prefix `a', cancel using the standard posting method; if not
714 post using the current select method."
715 (interactive (gnus-interactive "P\ny"))
716 (let ((articles (gnus-summary-work-articles n))
719 (gnus-post-method (eq ',symp 'a) ,gnus-newsgroup-name)))
721 (while (setq article (pop articles))
722 (when (gnus-summary-select-article t nil nil article)
723 (when (gnus-eval-in-buffer-window gnus-original-article-buffer
724 (message-cancel-news))
725 (gnus-summary-mark-as-read article gnus-canceled-mark)
726 (gnus-cache-remove-article 1))
727 (gnus-article-hide-headers-if-wanted))
728 (gnus-summary-remove-process-mark article))))
730 (defun gnus-summary-supersede-article ()
731 "Compose an article that will supersede a previous article.
732 This is done simply by taking the old article and adding a Supersedes
733 header line with the old Message-ID."
735 (let ((article (gnus-summary-article-number)))
736 (gnus-setup-message 'reply-yank
737 (gnus-summary-select-article t)
738 (set-buffer gnus-original-article-buffer)
742 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
744 (set-buffer ,gnus-summary-buffer)
745 (gnus-cache-possibly-remove-article ,article nil nil nil t)
746 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
747 message-send-actions))))
751 (defun gnus-copy-article-buffer (&optional article-buffer yank-string)
752 ;; make a copy of the article buffer with all text properties removed
753 ;; this copy is in the buffer gnus-article-copy.
754 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
755 ;; this buffer should be passed to all mail/news reply/post routines.
756 (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
758 (set-buffer gnus-article-copy)
759 (mm-enable-multibyte))
760 (let ((article-buffer (or article-buffer gnus-article-buffer))
762 (if (not (and (get-buffer article-buffer)
763 (gnus-buffer-exists-p article-buffer)))
764 (error "Can't find any article buffer")
766 (set-buffer article-buffer)
767 (let ((gnus-newsgroup-charset (or gnus-article-charset
768 gnus-newsgroup-charset))
769 (gnus-newsgroup-ignored-charsets
770 (or gnus-article-ignored-charsets
771 gnus-newsgroup-ignored-charsets)))
773 ;; Copy over the (displayed) article buffer, delete
774 ;; hidden text and remove text properties.
776 (copy-to-buffer gnus-article-copy (point-min) (point-max))
777 (set-buffer gnus-article-copy)
780 (delete-region (point) (point-max))
781 (insert yank-string))
782 (gnus-article-delete-text-of-type 'annotation)
783 (gnus-remove-text-with-property 'gnus-prev)
784 (gnus-remove-text-with-property 'gnus-next)
785 (gnus-remove-text-with-property 'gnus-decoration)
788 (buffer-substring-no-properties (point-min) (point-max))
790 ;; Find the original headers.
791 (set-buffer gnus-original-article-buffer)
792 (goto-char (point-min))
793 (while (looking-at message-unix-mail-delimiter)
796 end (or (message-goto-body) beg))
797 ;; Delete the headers from the displayed articles.
798 (set-buffer gnus-article-copy)
799 (delete-region (goto-char (point-min))
800 (or (message-goto-body) (point-max)))
801 ;; Insert the original article headers.
802 (insert-buffer-substring gnus-original-article-buffer beg end)
804 (let ((gnus-article-decode-hook
805 (delq 'article-decode-charset
806 (copy-sequence gnus-article-decode-hook))))
807 (run-hooks 'gnus-article-decode-hook)))))
810 (defun gnus-post-news (post &optional group header article-buffer yank subject
813 (gnus-copy-article-buffer))
814 (let ((gnus-article-reply (and article-buffer (gnus-summary-article-number)))
815 (add-to-list gnus-add-to-list))
816 (gnus-setup-message (cond (yank 'reply-yank)
817 (article-buffer 'reply)
819 (let* ((group (or group gnus-newsgroup-name))
820 (charset (gnus-group-name-charset nil group))
822 to-address to-group mailing-list to-list
825 (setq to-address (gnus-parameter-to-address group)
826 to-group (gnus-group-find-parameter group 'to-group)
827 to-list (gnus-parameter-to-list group)
828 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
829 mailing-list (when gnus-mailing-list-groups
830 (string-match gnus-mailing-list-groups group))
831 group (gnus-group-name-decode (gnus-group-real-name group)
833 (if (or (and to-group
834 (gnus-news-group-p to-group))
837 (and (gnus-news-group-p
838 (or pgroup gnus-newsgroup-name)
839 (or header gnus-current-article))
845 (message-news (or to-group group))
846 (set-buffer gnus-article-copy)
847 (gnus-msg-treat-broken-reply-to)
848 (message-followup (if (or newsgroup-p force-news)
849 (if (save-restriction
850 (article-narrow-to-head)
851 (message-fetch-field "newsgroups"))
858 (message-mail (or to-address to-list))
859 ;; Arrange for mail groups that have no `to-address' to
860 ;; get that when the user sends off the mail.
861 (when (and (not to-list)
864 (push (list 'gnus-inews-add-to-address pgroup)
865 message-send-actions)))
866 (set-buffer gnus-article-copy)
867 (gnus-msg-treat-broken-reply-to)
868 (message-wide-reply to-address)))
870 (gnus-inews-yank-articles yank))))))
872 (defun gnus-msg-treat-broken-reply-to (&optional force)
873 "Remove the Reply-to header iff broken-reply-to."
875 (gnus-group-find-parameter
876 gnus-newsgroup-name 'broken-reply-to))
878 (message-narrow-to-head)
879 (message-remove-header "reply-to"))))
881 (defun gnus-post-method (arg group &optional silent)
882 "Return the posting method based on GROUP and ARG.
883 If SILENT, don't prompt the user."
884 (let ((gnus-post-method (or (gnus-parameter-post-method group)
886 (group-method (gnus-find-method-for-group group)))
888 ;; If the group-method is nil (which shouldn't happen) we use
889 ;; the default method.
891 (or (and (listp gnus-post-method) ;If not current/native/nil
892 (not (listp (car gnus-post-method))) ; and not a list of methods
893 gnus-post-method) ;then use it.
895 message-post-method))
896 ;; We want the inverse of the default
897 ((and arg (not (eq arg 0)))
898 (if (eq gnus-post-method 'current)
901 ;; We query the user for a post method.
903 (and (listp gnus-post-method)
904 (listp (car gnus-post-method))))
906 ;; Collect all methods we know about.
908 (when (listp gnus-post-method)
909 (if (listp (car gnus-post-method))
911 (list gnus-post-method)))
912 gnus-secondary-select-methods
913 (mapcar 'cdr gnus-server-alist)
914 (mapcar 'car gnus-opened-servers)
915 (list gnus-select-method)
916 (list group-method)))
917 method-alist post-methods method)
918 ;; Weed out all mail methods.
920 (setq method (gnus-server-get-method "" (pop methods)))
921 (when (and (or (gnus-method-option-p method 'post)
922 (gnus-method-option-p method 'post-mail))
923 (not (member method post-methods)))
924 (push method post-methods)))
925 ;; Create a name-method alist.
929 (if (equal (cadr m) "")
930 (list (symbol-name (car m)) m)
931 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m)))
936 (setq gnus-last-posting-server
938 gnus-last-posting-server)
939 ;; Just use the last value.
940 gnus-last-posting-server
942 "Posting method: " method-alist nil t
943 (cons (or gnus-last-posting-server "") 0))))
945 ;; Override normal method.
946 ((and (eq gnus-post-method 'current)
947 (not (memq (car group-method) gnus-discouraged-post-methods))
948 (gnus-get-function group-method 'request-post t))
951 ;; Use gnus-post-method.
952 ((listp gnus-post-method) ;A method...
953 (assert (not (listp (car gnus-post-method)))) ;... not a list of methods.
955 ;; Use the normal select method (nil or native).
956 (t gnus-select-method))))
960 ;; Dummies to avoid byte-compile warning.
962 (defvar nnspool-rejected-article-hook)
963 (defvar xemacs-codename))
965 (defun gnus-extended-version ()
966 "Stringified Gnus version and Emacs version."
969 "Gnus/" (prin1-to-string (gnus-continuum-version gnus-version) t)
970 " (" gnus-version ")"
973 ((string-match "^\\(\\([.0-9]+\\)*\\)\\.[0-9]+$" emacs-version)
974 (concat "Emacs/" (match-string 1 emacs-version)
975 " (" system-configuration ")"))
976 ((string-match "\\([A-Z]*[Mm][Aa][Cc][Ss]\\)[^(]*\\(\\((beta.*)\\|'\\)\\)?"
978 (concat (match-string 1 emacs-version)
979 (format "/%d.%d" emacs-major-version emacs-minor-version)
980 (if (match-beginning 3)
981 (match-string 3 emacs-version)
983 (if (boundp 'xemacs-codename)
984 (concat " (" xemacs-codename ", " system-configuration ")")
990 ;;; Gnus Mail Functions
993 ;;; Mail reply commands of Gnus summary mode
995 (defun gnus-summary-reply (&optional yank wide very-wide)
996 "Start composing a mail reply to the current message.
997 If prefix argument YANK is non-nil, the original article is yanked
999 If WIDE, make a wide reply.
1000 If VERY-WIDE, make a very wide reply."
1002 (list (and current-prefix-arg
1003 (gnus-summary-work-articles 1))))
1004 ;; Allow user to require confirmation before replying by mail to the
1005 ;; author of a news article.
1006 (when (or (not (gnus-news-group-p gnus-newsgroup-name))
1007 (not gnus-confirm-mail-reply-to-news)
1008 (y-or-n-p "Really reply by mail to article author? "))
1010 (if (listp (car yank))
1013 (gnus-article-reply (or article (gnus-summary-article-number)))
1015 ;; Stripping headers should be specified with mail-yank-ignored-headers.
1017 (gnus-summary-goto-subject article))
1018 (gnus-setup-message (if yank 'reply-yank 'reply)
1020 (gnus-summary-select-article)
1021 (dolist (article very-wide)
1022 (gnus-summary-select-article nil nil nil article)
1024 (set-buffer (gnus-copy-article-buffer))
1025 (gnus-msg-treat-broken-reply-to)
1027 (message-narrow-to-head)
1028 (setq headers (concat headers (buffer-string)))))))
1029 (set-buffer (gnus-copy-article-buffer))
1030 (gnus-msg-treat-broken-reply-to gnus-msg-force-broken-reply-to)
1032 (message-narrow-to-head)
1036 (goto-char (point-max)))
1037 (mml-quote-region (point) (point-max))
1038 (message-reply nil wide)
1040 (gnus-inews-yank-articles yank))
1041 (gnus-summary-handle-replysign)))))
1043 (defun gnus-summary-handle-replysign ()
1044 "Check the various replysign variables and take action accordingly."
1045 (when (or gnus-message-replysign gnus-message-replyencrypt)
1046 (let (signed encrypted)
1048 (set-buffer gnus-article-buffer)
1049 (setq signed (memq 'signed gnus-article-wash-types))
1050 (setq encrypted (memq 'encrypted gnus-article-wash-types)))
1051 (cond ((and gnus-message-replysign signed)
1052 (mml-secure-message mml-default-sign-method 'sign))
1053 ((and gnus-message-replyencrypt encrypted)
1054 (mml-secure-message mml-default-encrypt-method
1055 (if gnus-message-replysignencrypted
1059 (defun gnus-summary-reply-with-original (n &optional wide)
1060 "Start composing a reply mail to the current message.
1061 The original article will be yanked."
1063 (gnus-summary-reply (gnus-summary-work-articles n) wide))
1065 (defun gnus-summary-reply-broken-reply-to (&optional yank wide very-wide)
1066 "Like `gnus-summary-reply' except removing reply-to field.
1067 If prefix argument YANK is non-nil, the original article is yanked
1069 If WIDE, make a wide reply.
1070 If VERY-WIDE, make a very wide reply."
1072 (list (and current-prefix-arg
1073 (gnus-summary-work-articles 1))))
1074 (let ((gnus-msg-force-broken-reply-to t))
1075 (gnus-summary-reply yank wide very-wide)))
1077 (defun gnus-summary-reply-broken-reply-to-with-original (n &optional wide)
1078 "Like `gnus-summary-reply-with-original' except removing reply-to field.
1079 The original article will be yanked."
1081 (gnus-summary-reply-broken-reply-to (gnus-summary-work-articles n) wide))
1083 (defun gnus-summary-wide-reply (&optional yank)
1084 "Start composing a wide reply mail to the current message.
1085 If prefix argument YANK is non-nil, the original article is yanked
1088 (list (and current-prefix-arg
1089 (gnus-summary-work-articles 1))))
1090 (gnus-summary-reply yank t))
1092 (defun gnus-summary-wide-reply-with-original (n)
1093 "Start composing a wide reply mail to the current message.
1094 The original article will be yanked."
1096 (gnus-summary-reply-with-original n t))
1098 (defun gnus-summary-very-wide-reply (&optional yank)
1099 "Start composing a very wide reply mail to the current message.
1100 If prefix argument YANK is non-nil, the original article is yanked
1103 (list (and current-prefix-arg
1104 (gnus-summary-work-articles 1))))
1105 (gnus-summary-reply yank t (gnus-summary-work-articles yank)))
1107 (defun gnus-summary-very-wide-reply-with-original (n)
1108 "Start composing a very wide reply mail to the current message.
1109 The original article will be yanked."
1112 (gnus-summary-work-articles n) t (gnus-summary-work-articles n)))
1114 (defun gnus-summary-mail-forward (&optional arg post)
1115 "Forward the current message(s) to another user.
1116 If process marks exist, forward all marked messages;
1117 if ARG is nil, see `message-forward-as-mime' and `message-forward-show-mml';
1118 if ARG is 1, decode the message and forward directly inline;
1119 if ARG is 2, forward message as an rfc822 MIME section;
1120 if ARG is 3, decode message and forward as an rfc822 MIME section;
1121 if ARG is 4, forward message directly inline;
1122 otherwise, use flipped `message-forward-as-mime'.
1123 If POST, post instead of mail.
1124 For the `inline' alternatives, also see the variable
1125 `message-forward-ignored-headers'."
1127 (if (null (cdr (gnus-summary-work-articles nil)))
1128 (let ((message-forward-as-mime message-forward-as-mime)
1129 (message-forward-show-mml message-forward-show-mml))
1133 (setq message-forward-as-mime nil
1134 message-forward-show-mml t))
1136 (setq message-forward-as-mime t
1137 message-forward-show-mml nil))
1139 (setq message-forward-as-mime t
1140 message-forward-show-mml t))
1142 (setq message-forward-as-mime nil
1143 message-forward-show-mml nil))
1145 (setq message-forward-as-mime (not message-forward-as-mime))))
1146 (let ((gnus-article-reply (gnus-summary-article-number)))
1147 (gnus-setup-message 'forward
1148 (gnus-summary-select-article)
1149 (let ((mail-parse-charset
1150 (or (and (gnus-buffer-live-p gnus-article-buffer)
1151 (with-current-buffer gnus-article-buffer
1152 gnus-article-charset))
1153 gnus-newsgroup-charset))
1154 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
1155 (set-buffer gnus-original-article-buffer)
1156 (message-forward post)))))
1157 (gnus-uu-digest-mail-forward arg post)))
1159 (defun gnus-summary-resend-message (address n)
1160 "Resend the current article to ADDRESS."
1162 (list (message-read-from-minibuffer
1163 "Resend message(s) to: "
1164 (when (gnus-buffer-live-p gnus-original-article-buffer)
1165 ;; If some other article is currently selected, the
1166 ;; initial-contents is wrong. Whatever, it is just the
1167 ;; initial-contents.
1168 (with-current-buffer gnus-original-article-buffer
1169 (nnmail-fetch-field "to"))))
1170 current-prefix-arg))
1171 (let ((articles (gnus-summary-work-articles n))
1173 (while (setq article (pop articles))
1174 (gnus-summary-select-article nil nil nil article)
1176 (set-buffer gnus-original-article-buffer)
1177 (message-resend address))
1178 (gnus-summary-mark-article-as-forwarded article))))
1180 ;; From: Matthieu Moy <Matthieu.Moy@imag.fr>
1181 (defun gnus-summary-resend-message-edit ()
1182 "Resend an article that has already been sent.
1183 A new buffer will be created to allow the user to modify body and
1184 contents of the message, and then, everything will happen as when
1185 composing a new message."
1187 (let ((article (gnus-summary-article-number)))
1188 (gnus-setup-message 'reply-yank
1189 (gnus-summary-select-article t)
1190 (set-buffer gnus-original-article-buffer)
1191 (let ((cur (current-buffer))
1192 (to (message-fetch-field "to")))
1193 ;; Get a normal message buffer.
1194 (message-pop-to-buffer (message-buffer-name "Resend" to))
1195 (insert-buffer-substring cur)
1197 (message-narrow-to-head-1)
1198 ;; Gnus will generate a new one when sending.
1199 (message-remove-header "Message-ID")
1200 (message-remove-header message-ignored-resent-headers t)
1201 ;; Remove unwanted headers.
1202 (goto-char (point-max))
1203 (insert mail-header-separator)
1204 (goto-char (point-min))
1205 (re-search-forward "^To:\\|^Newsgroups:" nil 'move)
1209 (defun gnus-summary-post-forward (&optional arg)
1210 "Forward the current article to a newsgroup.
1211 See `gnus-summary-mail-forward' for ARG."
1213 (gnus-summary-mail-forward arg t))
1215 (defvar gnus-nastygram-message
1216 "The following article was inappropriately posted to %s.\n\n"
1217 "Format string to insert in nastygrams.
1218 The current group name will be inserted at \"%s\".")
1220 (defun gnus-summary-mail-nastygram (n)
1221 "Send a nastygram to the author of the current article."
1223 (when (or gnus-expert-user
1225 "Really send a nastygram to the author of the current article? "))
1226 (let ((group gnus-newsgroup-name))
1227 (gnus-summary-reply-with-original n)
1228 (set-buffer gnus-message-buffer)
1230 (insert (format gnus-nastygram-message group))
1231 (message-send-and-exit))))
1233 (defun gnus-summary-mail-crosspost-complaint (n)
1234 "Send a complaint about crossposting to the current article(s)."
1236 (let ((articles (gnus-summary-work-articles n))
1238 (while (setq article (pop articles))
1239 (set-buffer gnus-summary-buffer)
1240 (gnus-summary-goto-subject article)
1241 (let ((group (gnus-group-real-name gnus-newsgroup-name))
1242 newsgroups followup-to)
1243 (gnus-summary-select-article)
1244 (set-buffer gnus-original-article-buffer)
1245 (if (and (<= (length (message-tokenize-header
1247 (mail-fetch-field "newsgroups"))
1250 (or (not (setq followup-to (mail-fetch-field "followup-to")))
1251 (not (member group (message-tokenize-header
1252 followup-to ", ")))))
1254 (gnus-message 1 "Followup-to restricted")
1255 (gnus-message 1 "Not a crossposted article"))
1256 (set-buffer gnus-summary-buffer)
1257 (gnus-summary-reply-with-original 1)
1258 (set-buffer gnus-message-buffer)
1260 (insert (format gnus-crosspost-complaint newsgroups group))
1261 (message-goto-subject)
1262 (re-search-forward " *$")
1263 (replace-match " (crosspost notification)" t t)
1264 (gnus-deactivate-mark)
1265 (when (gnus-y-or-n-p "Send this complaint? ")
1266 (message-send-and-exit)))))))
1268 (defun gnus-mail-parse-comma-list ()
1271 (skip-chars-forward " ")
1274 (skip-chars-forward "^,")
1279 (narrow-to-region beg (point))
1282 (while (search-forward "\"" nil t)
1286 (skip-chars-forward ",")
1287 (skip-chars-forward "^,"))
1288 (skip-chars-backward " ")
1289 (push (buffer-substring beg (point))
1291 (skip-chars-forward "^,")
1292 (skip-chars-forward ", "))
1295 (defun gnus-inews-add-to-address (group)
1296 (let ((to-address (mail-fetch-field "to")))
1297 (when (and to-address
1299 ;; This mail group doesn't have a `to-list', so we add one
1301 (when (gnus-y-or-n-p
1302 (format "Do you want to add this as `to-list': %s " to-address))
1303 (gnus-group-add-parameter group (cons 'to-list to-address))))))
1305 (defun gnus-put-message ()
1306 "Put the current message in some group and return to Gnus."
1308 (let ((reply gnus-article-reply)
1309 (winconf gnus-prev-winconf)
1310 (group gnus-newsgroup-name))
1312 (not (gnus-group-read-only-p group)))
1313 (setq group (read-string "Put in group: " nil (gnus-writable-groups))))
1315 (when (gnus-gethash group gnus-newsrc-hashtb)
1316 (error "No such group: %s" group))
1320 (message-narrow-to-headers)
1321 (let ((gnus-deletable-headers nil))
1322 (message-generate-headers
1323 (if (message-news-p)
1324 message-required-news-headers
1325 message-required-mail-headers)))
1326 (goto-char (point-max))
1327 (insert "Gcc: " group "\n")
1330 (when (and (get-buffer gnus-group-buffer)
1331 (gnus-buffer-exists-p (car-safe reply))
1333 (set-buffer (car reply))
1334 (gnus-summary-mark-article-as-replied (cdr reply)))
1336 (set-window-configuration winconf))))
1338 (defun gnus-article-mail (yank)
1339 "Send a reply to the address near point.
1340 If YANK is non-nil, include the original article."
1344 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
1345 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
1347 (gnus-msg-mail address)
1349 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
1351 (defvar nntp-server-type)
1353 "Send a bug report to the Gnus maintainers."
1355 (unless (gnus-alive-p)
1356 (error "Gnus has been shut down"))
1357 (gnus-setup-message (if (message-mail-user-agent) 'message 'bug)
1358 (unless (message-mail-user-agent)
1359 (delete-other-windows)
1360 (when gnus-bug-create-help-buffer
1361 (switch-to-buffer "*Gnus Help Bug*")
1363 (insert gnus-bug-message)
1364 (goto-char (point-min)))
1365 (message-pop-to-buffer "*Gnus Bug*"))
1366 (let ((message-this-is-mail t))
1367 (message-setup `((To . ,gnus-maintainer) (Subject . ""))))
1368 (when gnus-bug-create-help-buffer
1369 (push `(gnus-bug-kill-buffer) message-send-actions))
1370 (goto-char (point-min))
1371 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
1373 (insert (gnus-version) "\n"
1374 (emacs-version) "\n")
1375 (when (and (boundp 'nntp-server-type)
1376 (stringp nntp-server-type))
1377 (insert nntp-server-type))
1378 (insert "\n\n\n\n\n")
1381 (set-buffer (gnus-get-buffer-create " *gnus environment info*"))
1384 (setq text (buffer-string)))
1385 (insert "<#part type=application/emacs-lisp disposition=inline description=\"User settings\">\n" text "\n<#/part>"))
1386 (goto-char (point-min))
1387 (search-forward "Subject: " nil t)
1390 (defun gnus-bug-kill-buffer ()
1391 (when (get-buffer "*Gnus Help Bug*")
1392 (kill-buffer "*Gnus Help Bug*")))
1394 (defun gnus-summary-yank-message (buffer n)
1395 "Yank the current article into a composed message."
1397 (list (completing-read "Buffer: " (mapcar 'list (message-buffers)) nil t)
1398 current-prefix-arg))
1399 (gnus-summary-iterate n
1400 (let ((gnus-display-mime-function nil)
1401 (gnus-inhibit-treatment t))
1402 (gnus-summary-select-article))
1405 (message-yank-buffer gnus-article-buffer))))
1407 (defun gnus-debug ()
1408 "Attempts to go through the Gnus source file and report what variables have been changed.
1409 The source file has to be in the Emacs load path."
1411 (let ((files gnus-debug-files)
1413 file expr olist sym)
1414 (gnus-message 4 "Please wait while we snoop your variables...")
1416 ;; Go through all the files looking for non-default values for variables.
1418 (set-buffer (gnus-get-buffer-create " *gnus bug info*"))
1421 (when (and (setq file (locate-library (pop files)))
1422 (file-exists-p file))
1423 (insert-file-contents file)
1424 (goto-char (point-min))
1425 (if (not (re-search-forward "^;;* *Internal variables" nil t))
1426 (gnus-message 4 "Malformed sources in file %s" file)
1427 (narrow-to-region (point-min) (point))
1428 (goto-char (point-min))
1429 (while (setq expr (ignore-errors (read (current-buffer))))
1431 (and (or (eq (car expr) 'defvar)
1432 (eq (car expr) 'defcustom))
1433 (stringp (nth 3 expr))
1434 (not (memq (nth 1 expr) gnus-debug-exclude-variables))
1435 (or (not (boundp (nth 1 expr)))
1436 (not (equal (eval (nth 2 expr))
1437 (symbol-value (nth 1 expr)))))
1438 (push (nth 1 expr) olist)))))))
1439 (kill-buffer (current-buffer)))
1440 (when (setq olist (nreverse olist))
1441 (insert "------------------ Environment follows ------------------\n\n"))
1443 (if (boundp (car olist))
1445 (pp `(setq ,(car olist)
1446 ,(if (or (consp (setq sym (symbol-value (car olist))))
1448 (not (or (eq sym nil)
1450 (list 'quote (symbol-value (car olist)))
1451 (symbol-value (car olist))))
1454 (format "(setq %s 'whatever)\n" (car olist))))
1455 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
1456 (setq olist (cdr olist)))
1458 ;; Remove any control chars - they seem to cause trouble for some
1459 ;; mailers. (Byte-compiled output from the stuff above.)
1461 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
1462 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
1465 ;;; Treatment of rejected articles.
1468 (defun gnus-summary-resend-bounced-mail (&optional fetch)
1469 "Re-mail the current message.
1470 This only makes sense if the current message is a bounce message than
1471 contains some mail you have written which has been bounced back to
1473 If FETCH, try to fetch the article that this is a reply to, if indeed
1476 (gnus-summary-select-article t)
1477 (set-buffer gnus-original-article-buffer)
1478 (gnus-setup-message 'compose-bounce
1479 (let* ((references (mail-fetch-field "references"))
1480 (parent (and references (gnus-parent-id references))))
1482 ;; If there are references, we fetch the article we answered to.
1484 (gnus-summary-refer-article parent)
1485 (gnus-summary-show-all-headers)))))
1489 (defun gnus-inews-group-method (group)
1491 ;; If the group doesn't exist, we assume
1492 ;; it's an archive group...
1493 ((and (null (gnus-get-info group))
1494 (eq (car (gnus-server-to-method gnus-message-archive-method))
1495 (car (gnus-server-to-method (gnus-group-method group)))))
1496 gnus-message-archive-method)
1498 ((gnus-info-method (gnus-get-info group))
1499 (gnus-info-method (gnus-get-info group)))
1501 (t (gnus-server-to-method (gnus-group-method group)))))
1503 ;; Do Gcc handling, which copied the message over to some group.
1504 (defun gnus-inews-do-gcc (&optional gcc)
1508 (message-narrow-to-headers)
1509 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
1510 (cur (current-buffer))
1511 groups group method group-art
1512 mml-externalize-attachments)
1514 (message-remove-header "gcc")
1516 (setq groups (message-unquote-tokens
1517 (message-tokenize-header gcc " ,")))
1518 ;; Copy the article over to some group(s).
1519 (while (setq group (pop groups))
1520 (unless (gnus-check-server
1521 (setq method (gnus-inews-group-method group)))
1522 (error "Can't open server %s" (if (stringp method) method
1524 (unless (gnus-request-group group nil method)
1525 (gnus-request-create-group group method))
1526 (setq mml-externalize-attachments
1527 (if (stringp gnus-gcc-externalize-attachments)
1528 (string-match gnus-gcc-externalize-attachments group)
1529 gnus-gcc-externalize-attachments))
1531 (nnheader-set-temp-buffer " *acc*")
1532 (insert-buffer-substring cur)
1533 (message-encode-message-body)
1535 (message-narrow-to-headers)
1536 (let* ((mail-parse-charset message-default-charset)
1537 (newsgroups-field (save-restriction
1538 (message-narrow-to-headers-or-head)
1539 (message-fetch-field "Newsgroups")))
1540 (followup-field (save-restriction
1541 (message-narrow-to-headers-or-head)
1542 (message-fetch-field "Followup-To")))
1543 ;; BUG: We really need to get the charset for
1544 ;; each name in the Newsgroups and Followup-To
1545 ;; lines to allow crossposting between group
1546 ;; namess with incompatible character sets.
1547 ;; -- Per Abrahamsen <abraham@dina.kvl.dk> 2001-10-08.
1548 (group-field-charset
1549 (gnus-group-name-charset
1550 method (or newsgroups-field "")))
1551 (followup-field-charset
1552 (gnus-group-name-charset
1553 method (or followup-field "")))
1554 (rfc2047-header-encoding-alist
1556 (when group-field-charset
1557 (list (cons "Newsgroups" group-field-charset)))
1558 (when followup-field-charset
1559 (list (cons "Followup-To" followup-field-charset)))
1560 rfc2047-header-encoding-alist)))
1561 (mail-encode-encoded-word-buffer)))
1562 (goto-char (point-min))
1563 (when (re-search-forward
1564 (concat "^" (regexp-quote mail-header-separator) "$")
1566 (replace-match "" t t ))
1567 (unless (setq group-art
1568 (gnus-request-accept-article group method t t))
1569 (gnus-message 1 "Couldn't store article in group %s: %s"
1570 group (gnus-status-message method))
1572 (when (and group-art
1573 (or gnus-gcc-mark-as-read
1574 gnus-inews-mark-gcc-as-read))
1575 (gnus-group-mark-article-read group (cdr group-art)))
1576 (kill-buffer (current-buffer)))))))))
1578 (defun gnus-inews-insert-gcc ()
1579 "Insert Gcc headers based on `gnus-outgoing-message-group'."
1582 (message-narrow-to-headers)
1583 (let* ((group gnus-outgoing-message-group)
1585 ((gnus-functionp group)
1587 ((or (stringp group) (list group))
1591 (if (stringp gcc) gcc
1592 (mapconcat 'identity gcc " "))
1595 (defun gnus-inews-insert-archive-gcc (&optional group)
1596 "Insert the Gcc to say where the article is to be archived."
1597 (let* ((var gnus-message-archive-group)
1598 (group (or group gnus-newsgroup-name ""))
1600 (and gnus-newsgroup-name
1601 (not (equal gnus-newsgroup-name ""))
1602 (gnus-group-find-parameter
1603 gnus-newsgroup-name 'gcc-self)))
1607 ((null gnus-message-archive-method)
1611 ;; Just a single group.
1614 ;; We don't want this.
1616 ((and (listp var) (stringp (car var)))
1617 ;; A list of groups.
1619 ((gnus-functionp var)
1621 (funcall var group))
1623 ;; An alist of regexps/functions/forms.
1628 ((stringp (caar var))
1630 (when (string-match (caar var) group)
1632 ((gnus-functionp (car var))
1634 (funcall (car var) group))
1636 (eval (car var)))))))
1637 (setq var (cdr var)))
1640 (when (or groups gcc-self-val)
1641 (when (stringp groups)
1642 (setq groups (list groups)))
1645 (message-narrow-to-headers)
1646 (goto-char (point-max))
1649 ;; Use the `gcc-self' param value instead.
1652 (if (stringp gcc-self-val)
1655 (if (not (eq gcc-self-val 'none))
1660 ;; Use the list of groups.
1661 (while (setq name (pop groups))
1662 (insert (if (string-match ":" name)
1664 (gnus-group-prefixed-name
1665 name gnus-message-archive-method)))
1672 (defun gnus-configure-posting-styles (&optional group-name)
1673 "Configure posting styles according to `gnus-posting-styles'."
1674 (unless gnus-inhibit-posting-styles
1675 (let ((group (or group-name gnus-newsgroup-name ""))
1676 (styles gnus-posting-styles)
1677 style match variable attribute value v results
1678 filep name address element)
1679 ;; If the group has a posting-style parameter, add it at the end with a
1680 ;; regexp matching everything, to be sure it takes precedence over all
1682 (when gnus-newsgroup-name
1683 (let ((tmp-style (gnus-group-find-parameter group 'posting-style t)))
1685 (setq styles (append styles (list (cons ".*" tmp-style)))))))
1686 ;; Go through all styles and look for matches.
1687 (dolist (style styles)
1688 (setq match (pop style))
1689 (goto-char (point-min))
1692 ;; Regexp string match on the group name.
1693 (string-match match group))
1695 ;; Obsolete format of header match.
1696 (and (gnus-buffer-live-p gnus-article-copy)
1697 (with-current-buffer gnus-article-copy
1698 (let ((header (message-fetch-field (pop style))))
1700 (string-match (pop style) header))))))
1701 ((or (symbolp match)
1702 (gnus-functionp match))
1704 ((gnus-functionp match)
1705 ;; Function to be called.
1708 ;; Variable to be checked.
1709 (symbol-value match))))
1712 ((eq (car match) 'header)
1713 ;; New format of header match.
1714 (and (gnus-buffer-live-p gnus-article-copy)
1715 (with-current-buffer gnus-article-copy
1716 (let ((header (message-fetch-field (nth 1 match))))
1718 (string-match (nth 2 match) header))))))
1720 ;; This is a form to be evaled.
1722 ;; We have a match, so we set the variables.
1723 (dolist (attribute style)
1724 (setq element (pop attribute)
1729 ((eq (car attribute) :file)
1732 ((eq (car attribute) :value)
1736 ;; We get the value.
1741 ((or (symbolp value)
1742 (gnus-functionp value))
1743 (cond ((gnus-functionp value)
1746 (symbol-value value))))
1749 ;; Translate obsolescent value.
1751 ((eq element 'signature-file)
1752 (setq element 'signature
1754 ((eq element 'x-face-file)
1755 (setq element 'x-face
1757 ;; Get the contents of file elems.
1759 (setq v (with-temp-buffer
1760 (insert-file-contents v)
1761 (goto-char (point-max))
1765 (setq results (delq (assoc element results) results))
1766 (push (cons element v) results))))
1767 ;; Now we have all the styles, so we insert them.
1768 (setq name (assq 'name results)
1769 address (assq 'address results))
1770 (setq results (delq name (delq address results)))
1771 ;; make-local-hook is not obsolete in Emacs 20 or XEmacs.
1772 (make-local-hook 'message-setup-hook)
1773 (dolist (result results)
1774 (add-hook 'message-setup-hook
1776 ((eq 'eval (car result))
1778 ((eq 'body (car result))
1782 (insert ,(cdr result)))))
1783 ((eq 'signature (car result))
1784 (set (make-local-variable 'message-signature) nil)
1785 (set (make-local-variable 'message-signature-file) nil)
1786 (if (not (cdr result))
1790 (let ((message-signature ,(cdr result)))
1791 (when message-signature
1792 (message-insert-signature)))))))
1795 (if (symbolp (car result))
1796 (capitalize (symbol-name (car result)))
1800 (message-remove-header ,header)
1801 (let ((value ,(cdr result)))
1804 (insert ,header ": " value "\n"))))))))
1806 (when (or name address)
1807 (add-hook 'message-setup-hook
1809 (set (make-local-variable 'user-mail-address)
1810 ,(or (cdr address) user-mail-address))
1811 (let ((user-full-name ,(or (cdr name) (user-full-name)))
1813 ,(or (cdr address) user-mail-address)))
1815 (message-remove-header "From")
1817 (insert "From: " (message-make-from) "\n"))))
1820 ;;; Allow redefinition of functions.
1826 ;;; gnus-msg.el ends here