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 (gnus-define-group-parameter
164 posting-charset-alist
167 "Return the permitted unencoded charsets for posting of GROUP."
168 :variable gnus-group-posting-charset-alist
170 '(("^\\(no\\|fr\\)\\.[^,]*\\(,[ \t\n]*\\(no\\|fr\\)\\.[^,]*\\)*$" iso-8859-1 (iso-8859-1))
171 ("^\\(fido7\\|relcom\\)\\.[^,]*\\(,[ \t\n]*\\(fido7\\|relcom\\)\\.[^,]*\\)*$" koi8-r (koi8-r))
172 (message-this-is-mail nil nil)
173 (message-this-is-news nil t))
175 "Alist of regexps and permitted unencoded charsets for posting.
176 Each element of the alist has the form (TEST HEADER BODY-LIST), where
177 TEST is either a regular expression matching the newsgroup header or a
179 HEADER is the charset which may be left unencoded in the header (nil
180 means encode all charsets),
181 BODY-LIST is a list of charsets which may be encoded using 8bit
182 content-transfer encoding in the body, or one of the special values
183 nil (always encode using quoted-printable) or t (always use 8bit).
185 Note that any value other than nil for HEADER infringes some RFCs, so
186 use this option with care."
187 :variable-group gnus-charset
189 '(repeat (list :tag "Permitted unencoded charsets"
191 (regexp :tag "Group")
192 (const :tag "Mail message" :value message-this-is-mail)
193 (const :tag "News article" :value message-this-is-news))
194 (choice :tag "Header"
195 (const :tag "None" nil)
196 (symbol :tag "Charset"))
198 (const :tag "Any" :value t)
199 (const :tag "None" :value nil)
200 (repeat :tag "Charsets"
201 (symbol :tag "Charset")))))
202 :parameter-type '(choice :tag "Permitted unencoded charsets"
205 :parameter-document "\
206 List of charsets that are permitted to be unencoded.")
208 (defcustom gnus-debug-files
209 '("gnus.el" "gnus-sum.el" "gnus-group.el"
210 "gnus-art.el" "gnus-start.el" "gnus-async.el"
211 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
212 "gnus-agent.el" "gnus-cache.el" "gnus-srvr.el"
213 "mm-util.el" "mm-decode.el" "nnmail.el" "message.el")
214 "Files whose variables will be reported in `gnus-bug'."
217 :type '(repeat (string :tag "File")))
219 (defcustom gnus-debug-exclude-variables
220 '(mm-mime-mule-charset-alist
221 nnmail-split-fancy message-minibuffer-local-map)
222 "Variables that should not be reported in `gnus-bug'."
225 :type '(repeat (symbol :tag "Variable")))
227 (defcustom gnus-discouraged-post-methods
228 '(nndraft nnml nnimap nnmaildir nnmh nnfolder nndir)
229 "A list of back ends that are not used in \"real\" newsgroups.
230 This variable is used only when `gnus-post-method' is `current'."
232 :group 'gnus-group-foreign
233 :type '(repeat (symbol :tag "Back end")))
235 (defcustom gnus-message-replysign
237 "Automatically sign replys to signed messages.
238 See also the `mml-default-sign-method' variable."
242 (defcustom gnus-message-replyencrypt
244 "Automatically encrypt replys to encrypted messages.
245 See also the `mml-default-encrypt-method' variable."
249 (defcustom gnus-message-replysignencrypted
251 "Setting this causes automatically encryped messages to also be signed."
255 (defcustom gnus-confirm-mail-reply-to-news nil
256 "If non-nil, Gnus requests confirmation when replying to news.
257 This is done because new users often reply by mistake when reading
262 (defcustom gnus-summary-resend-default-address t
263 "If non-nil, Gnus tries to suggest a default address to resend to.
264 If nil, the address field will always be empty after invoking
265 `gnus-summary-resend-message'."
269 ;;; Internal variables.
271 (defvar gnus-inhibit-posting-styles nil
272 "Inhibit the use of posting styles.")
274 (defvar gnus-message-buffer "*Mail Gnus*")
275 (defvar gnus-article-copy nil)
276 (defvar gnus-check-before-posting nil)
277 (defvar gnus-last-posting-server nil)
278 (defvar gnus-message-group-art nil)
280 (defvar gnus-msg-force-broken-reply-to nil)
282 (defconst gnus-bug-message
283 "Sending a bug report to the Gnus Towers.
284 ========================================
286 The buffer below is a mail buffer. When you press `C-c C-c', it will
287 be sent to the Gnus Bug Exterminators.
289 The thing near the bottom of the buffer is how the environment
290 settings will be included in the mail. Please do not delete that.
291 They will tell the Bug People what your environment is, so that it
292 will be easier to locate the bugs.
294 If you have found a bug that makes Emacs go \"beep\", set
295 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
296 and include the backtrace in your bug report.
298 Please describe the bug in annoying, painstaking detail.
300 Thank you for your help in stamping out bugs.
304 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
305 (autoload 'news-setup "rnewspost")
306 (autoload 'news-reply-mode "rnewspost")
307 (autoload 'rmail-dont-reply-to "mail-utils")
308 (autoload 'rmail-output "rmailout"))
312 ;;; Gnus Posting Functions
315 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
316 "p" gnus-summary-post-news
317 "i" gnus-summary-news-other-window
318 "f" gnus-summary-followup
319 "F" gnus-summary-followup-with-original
320 "c" gnus-summary-cancel-article
321 "s" gnus-summary-supersede-article
322 "r" gnus-summary-reply
323 "y" gnus-summary-yank-message
324 "R" gnus-summary-reply-with-original
325 "w" gnus-summary-wide-reply
326 "W" gnus-summary-wide-reply-with-original
327 "v" gnus-summary-very-wide-reply
328 "V" gnus-summary-very-wide-reply-with-original
329 "n" gnus-summary-followup-to-mail
330 "N" gnus-summary-followup-to-mail-with-original
331 "m" gnus-summary-mail-other-window
332 "u" gnus-uu-post-news
333 "\M-c" gnus-summary-mail-crosspost-complaint
334 "Br" gnus-summary-reply-broken-reply-to
335 "BR" gnus-summary-reply-broken-reply-to-with-original
336 "om" gnus-summary-mail-forward
337 "op" gnus-summary-post-forward
338 "Om" gnus-uu-digest-mail-forward
339 "Op" gnus-uu-digest-post-forward)
341 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
342 "b" gnus-summary-resend-bounced-mail
343 ;; "c" gnus-summary-send-draft
344 "r" gnus-summary-resend-message
345 "e" gnus-summary-resend-message-edit)
347 ;;; Internal functions.
349 (defvar gnus-article-reply nil)
350 (defmacro gnus-setup-message (config &rest forms)
351 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
352 (buffer (make-symbol "gnus-setup-message-buffer"))
353 (article (make-symbol "gnus-setup-message-article"))
354 (group (make-symbol "gnus-setup-message-group")))
355 `(let ((,winconf (current-window-configuration))
356 (,buffer (buffer-name (current-buffer)))
357 (,article gnus-article-reply)
358 (,group gnus-newsgroup-name)
359 (message-header-setup-hook
360 (copy-sequence message-header-setup-hook))
361 (mbl mml-buffer-list)
362 (message-mode-hook (copy-sequence message-mode-hook)))
363 (setq mml-buffer-list nil)
364 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
365 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
366 ;; #### FIXME: for a reason that I did not manage to identify yet,
367 ;; the variable `gnus-newsgroup-name' does not honor a dynamically
368 ;; scoped or setq'ed value from a caller like `C-u gnus-summary-mail'.
369 ;; After evaluation of @forms below, it gets the value we actually want
370 ;; to override, and the posting styles are used. For that reason, I've
371 ;; added an optional argument to `gnus-configure-posting-styles' to
372 ;; make sure that the correct value for the group name is used. -- drv
373 (add-hook 'message-mode-hook
375 (gnus-configure-posting-styles ,group)))
379 (gnus-inews-add-send-actions ,winconf ,buffer ,article ,config)
380 (gnus-inews-insert-draft-meta-information ,group ,article)
381 (setq gnus-message-buffer (current-buffer))
382 (set (make-local-variable 'gnus-message-group-art)
383 (cons ,group ,article))
384 (set (make-local-variable 'gnus-newsgroup-name) ,group)
385 (gnus-run-hooks 'gnus-message-setup-hook)
386 (if (eq major-mode 'message-mode)
387 (let ((mbl1 mml-buffer-list))
388 (setq mml-buffer-list mbl) ;; Global value
389 (set (make-local-variable 'mml-buffer-list) mbl1);; Local value
390 ;; LOCAL argument of add-hook differs between GNU Emacs
391 ;; and XEmacs. make-local-hook makes sure they are local.
392 (make-local-hook 'kill-buffer-hook)
393 (make-local-hook 'change-major-mode-hook)
394 (add-hook 'change-major-mode-hook 'mml-destroy-buffers nil t)
395 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))
396 (mml-destroy-buffers)
397 (setq mml-buffer-list mbl)))
399 (gnus-configure-windows ,config t)
400 (run-hooks 'post-command-hook)
401 (set-buffer-modified-p nil))))
403 (defun gnus-inews-insert-draft-meta-information (group article)
406 (not (string= group ""))
407 (not (message-fetch-field gnus-draft-meta-information-header)))
408 (goto-char (point-min))
409 (insert gnus-draft-meta-information-header ": (\"" group "\" "
410 (if article (number-to-string
417 (defun gnus-msg-mail (&optional to subject other-headers continue
418 switch-action yank-action send-actions)
419 "Start editing a mail message to be sent.
420 Like `message-mail', but with Gnus paraphernalia, particularly the
421 Gcc: header for archiving purposes."
423 (let ((buf (current-buffer))
425 (gnus-setup-message 'message
426 (message-mail to subject other-headers continue
427 nil yank-action send-actions))
429 (setq mail-buf (current-buffer))
430 (switch-to-buffer buf)
431 (apply switch-action mail-buf nil)))
432 ;; COMPOSEFUNC should return t if succeed. Undocumented ???
435 (defvar save-selected-window-window)
438 (defun gnus-button-mailto (address)
440 (set-buffer (gnus-copy-article-buffer))
441 (gnus-setup-message 'message
442 (message-reply address))
443 (and (boundp 'save-selected-window-window)
444 (not (window-live-p save-selected-window-window))
445 (setq save-selected-window-window (selected-window))))
448 (defun gnus-button-reply (&optional to-address wide)
449 "Like `message-reply'."
451 (gnus-setup-message 'message
452 (message-reply to-address wide))
453 (and (boundp 'save-selected-window-window)
454 (not (window-live-p save-selected-window-window))
455 (setq save-selected-window-window (selected-window))))
458 (define-mail-user-agent 'gnus-user-agent
459 'gnus-msg-mail 'message-send-and-exit
460 'message-kill-buffer 'message-send-hook)
462 (defun gnus-setup-posting-charset (group)
463 (let ((alist gnus-group-posting-charset-alist)
464 (group (or group ""))
468 (while (setq elem (pop alist))
469 (when (or (and (stringp (car elem))
470 (string-match (car elem) group))
471 (and (gnus-functionp (car elem))
472 (funcall (car elem) group))
473 (and (symbolp (car elem))
474 (symbol-value (car elem))))
475 (throw 'found (cons (cadr elem) (caddr elem)))))))))
477 (defun gnus-inews-add-send-actions (winconf buffer article &optional config)
478 (make-local-hook 'message-sent-hook)
479 (add-hook 'message-sent-hook (if gnus-agent 'gnus-agent-possibly-do-gcc
480 'gnus-inews-do-gcc) nil t)
482 (make-local-hook 'message-header-hook)
483 (add-hook 'message-header-hook 'gnus-agent-possibly-save-gcc nil t))
484 (setq message-post-method
486 (gnus-post-method arg ,gnus-newsgroup-name)))
487 (setq message-newsreader (setq message-mailer (gnus-extended-version)))
489 `(set-window-configuration ,winconf) 'exit 'postpone 'kill)
491 `(when (gnus-buffer-exists-p ,buffer)
495 (if (eq config 'forward)
496 `(gnus-summary-mark-article-as-forwarded ',article)
497 `(gnus-summary-mark-article-as-replied ',article)))))
500 (put 'gnus-setup-message 'lisp-indent-function 1)
501 (put 'gnus-setup-message 'edebug-form-spec '(form body))
503 ;;; Post news commands of Gnus group mode and summary mode
505 (defun gnus-group-mail (&optional arg)
506 "Start composing a mail.
507 If ARG, use the group under the point to find a posting style.
508 If ARG is 1, prompt for a group name to find the posting style."
510 ;; We can't `let' gnus-newsgroup-name here, since that leads
511 ;; to local variables leaking.
512 (let ((group gnus-newsgroup-name)
513 ;; make sure last viewed article doesn't affect posting styles:
515 (buffer (current-buffer)))
518 (setq gnus-newsgroup-name
520 (if (= 1 (prefix-numeric-value arg))
521 (completing-read "Use posting style of group: "
522 gnus-active-hashtb nil
523 (gnus-read-active-file-p))
524 (gnus-group-group-name))
526 ;; #### see comment in gnus-setup-message -- drv
527 (gnus-setup-message 'message (message-mail)))
530 (setq gnus-newsgroup-name group)))))
532 (defun gnus-group-news (&optional arg)
533 "Start composing a news.
534 If ARG, post to group under point.
535 If ARG is 1, prompt for group name to post to.
537 This function prepares a news even when using mail groups. This is useful
538 for posting messages to mail groups without actually sending them over the
539 network. The corresponding backend must have a 'request-post method."
541 ;; We can't `let' gnus-newsgroup-name here, since that leads
542 ;; to local variables leaking.
543 (let ((group gnus-newsgroup-name)
544 ;; make sure last viewed article doesn't affect posting styles:
546 (buffer (current-buffer)))
549 (setq gnus-newsgroup-name
551 (if (= 1 (prefix-numeric-value arg))
552 (completing-read "Use group: "
553 gnus-active-hashtb nil
554 (gnus-read-active-file-p))
555 (gnus-group-group-name))
557 ;; #### see comment in gnus-setup-message -- drv
558 (gnus-setup-message 'message
559 (message-news (gnus-group-real-name gnus-newsgroup-name))))
562 (setq gnus-newsgroup-name group)))))
564 (defun gnus-group-post-news (&optional arg)
565 "Start composing a message (a news by default).
566 If ARG, post to group under point. If ARG is 1, prompt for group name.
567 Depending on the selected group, the message might be either a mail or
570 ;; Bind this variable here to make message mode hooks work ok.
571 (let ((gnus-newsgroup-name
573 (if (= 1 (prefix-numeric-value arg))
574 (completing-read "Newsgroup: " gnus-active-hashtb nil
575 (gnus-read-active-file-p))
576 (gnus-group-group-name))
578 ;; make sure last viewed article doesn't affect posting styles:
580 (gnus-post-news 'post gnus-newsgroup-name)))
582 (defun gnus-summary-mail-other-window (&optional arg)
583 "Start composing a mail in another window.
584 Use the posting of the current group by default.
585 If ARG, don't do that. If ARG is 1, prompt for group name to find the
588 ;; We can't `let' gnus-newsgroup-name here, since that leads
589 ;; to local variables leaking.
590 (let ((group gnus-newsgroup-name)
591 ;; make sure last viewed article doesn't affect posting styles:
593 (buffer (current-buffer)))
596 (setq gnus-newsgroup-name
598 (if (= 1 (prefix-numeric-value arg))
599 (completing-read "Use group: "
600 gnus-active-hashtb nil
601 (gnus-read-active-file-p))
603 gnus-newsgroup-name))
604 ;; #### see comment in gnus-setup-message -- drv
605 (gnus-setup-message 'message (message-mail)))
608 (setq gnus-newsgroup-name group)))))
610 (defun gnus-summary-news-other-window (&optional arg)
611 "Start composing a news in another window.
612 Post to the current group by default.
613 If ARG, don't do that. If ARG is 1, prompt for group name to post to.
615 This function prepares a news even when using mail groups. This is useful
616 for posting messages to mail groups without actually sending them over the
617 network. The corresponding backend must have a 'request-post method."
619 ;; We can't `let' gnus-newsgroup-name here, since that leads
620 ;; to local variables leaking.
621 (let ((group gnus-newsgroup-name)
622 ;; make sure last viewed article doesn't affect posting styles:
624 (buffer (current-buffer)))
627 (setq gnus-newsgroup-name
629 (if (= 1 (prefix-numeric-value arg))
630 (completing-read "Use group: "
631 gnus-active-hashtb nil
632 (gnus-read-active-file-p))
634 gnus-newsgroup-name))
635 ;; #### see comment in gnus-setup-message -- drv
636 (gnus-setup-message 'message
637 (message-news (gnus-group-real-name gnus-newsgroup-name))))
640 (setq gnus-newsgroup-name group)))))
642 (defun gnus-summary-post-news (&optional arg)
643 "Start composing a message. Post to the current group by default.
644 If ARG, don't do that. If ARG is 1, prompt for a group name to post to.
645 Depending on the selected group, the message might be either a mail or
648 ;; Bind this variable here to make message mode hooks work ok.
649 (let ((gnus-newsgroup-name
651 (if (= 1 (prefix-numeric-value arg))
652 (completing-read "Newsgroup: " gnus-active-hashtb nil
653 (gnus-read-active-file-p))
655 gnus-newsgroup-name))
656 ;; make sure last viewed article doesn't affect posting styles:
658 (gnus-post-news 'post gnus-newsgroup-name)))
661 (defun gnus-summary-followup (yank &optional force-news)
662 "Compose a followup to an article.
663 If prefix argument YANK is non-nil, the original article is yanked
665 YANK is a list of elements, where the car of each element is the
666 article number, and the two following numbers is the region to be
669 (list (and current-prefix-arg
670 (gnus-summary-work-articles 1))))
672 (gnus-summary-goto-subject
673 (if (listp (car yank))
676 (save-window-excursion
677 (gnus-summary-select-article))
678 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
679 (gnus-newsgroup-name gnus-newsgroup-name))
681 (gnus-post-news nil gnus-newsgroup-name
682 headers gnus-article-buffer
684 (gnus-summary-handle-replysign)))
686 (defun gnus-summary-followup-with-original (n &optional force-news)
687 "Compose a followup to an article and include the original article."
689 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
691 (defun gnus-summary-followup-to-mail (&optional arg)
692 "Followup to the current mail message via news."
694 (list (and current-prefix-arg
695 (gnus-summary-work-articles 1))))
696 (gnus-summary-followup arg t))
698 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
699 "Followup to the current mail message via news."
701 (gnus-summary-followup (gnus-summary-work-articles arg) t))
703 (defun gnus-inews-yank-articles (articles)
704 (let (beg article yank-string)
706 (while (setq article (pop articles))
707 (when (listp article)
708 (setq yank-string (nth 1 article)
709 article (nth 0 article)))
710 (save-window-excursion
711 (set-buffer gnus-summary-buffer)
712 (gnus-summary-select-article nil nil nil article)
713 (gnus-summary-remove-process-mark article))
714 (gnus-copy-article-buffer nil yank-string)
715 (let ((message-reply-buffer gnus-article-copy)
716 (message-reply-headers
717 ;; The headers are decoded.
718 (with-current-buffer gnus-article-copy
720 (nnheader-narrow-to-headers)
721 (ietf-drums-unfold-fws)
722 (nnheader-parse-head t)))))
723 (message-yank-original)
724 (setq beg (or beg (mark t))))
730 (defun gnus-summary-cancel-article (&optional n symp)
731 "Cancel an article you posted.
732 Uses the process-prefix convention. If given the symbolic
733 prefix `a', cancel using the standard posting method; if not
734 post using the current select method."
735 (interactive (gnus-interactive "P\ny"))
736 (let ((articles (gnus-summary-work-articles n))
739 (gnus-post-method (eq ',symp 'a) ,gnus-newsgroup-name)))
741 (while (setq article (pop articles))
742 (when (gnus-summary-select-article t nil nil article)
743 (when (gnus-eval-in-buffer-window gnus-original-article-buffer
744 (message-cancel-news))
745 (gnus-summary-mark-as-read article gnus-canceled-mark)
746 (gnus-cache-remove-article 1))
747 (gnus-article-hide-headers-if-wanted))
748 (gnus-summary-remove-process-mark article))))
750 (defun gnus-summary-supersede-article ()
751 "Compose an article that will supersede a previous article.
752 This is done simply by taking the old article and adding a Supersedes
753 header line with the old Message-ID."
755 (let ((article (gnus-summary-article-number)))
756 (gnus-setup-message 'reply-yank
757 (gnus-summary-select-article t)
758 (set-buffer gnus-original-article-buffer)
762 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
764 (set-buffer ,gnus-summary-buffer)
765 (gnus-cache-possibly-remove-article ,article nil nil nil t)
766 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
767 message-send-actions))))
771 (defun gnus-copy-article-buffer (&optional article-buffer yank-string)
772 ;; make a copy of the article buffer with all text properties removed
773 ;; this copy is in the buffer gnus-article-copy.
774 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
775 ;; this buffer should be passed to all mail/news reply/post routines.
776 (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
778 (set-buffer gnus-article-copy)
779 (mm-enable-multibyte))
780 (let ((article-buffer (or article-buffer gnus-article-buffer))
782 (if (not (and (get-buffer article-buffer)
783 (gnus-buffer-exists-p article-buffer)))
784 (error "Can't find any article buffer")
786 (set-buffer article-buffer)
787 (let ((gnus-newsgroup-charset (or gnus-article-charset
788 gnus-newsgroup-charset))
789 (gnus-newsgroup-ignored-charsets
790 (or gnus-article-ignored-charsets
791 gnus-newsgroup-ignored-charsets)))
793 ;; Copy over the (displayed) article buffer, delete
794 ;; hidden text and remove text properties.
796 (copy-to-buffer gnus-article-copy (point-min) (point-max))
797 (set-buffer gnus-article-copy)
800 (delete-region (point) (point-max))
801 (insert yank-string))
802 (gnus-article-delete-text-of-type 'annotation)
803 (gnus-remove-text-with-property 'gnus-prev)
804 (gnus-remove-text-with-property 'gnus-next)
805 (gnus-remove-text-with-property 'gnus-decoration)
808 (buffer-substring-no-properties (point-min) (point-max))
810 ;; Find the original headers.
811 (set-buffer gnus-original-article-buffer)
812 (goto-char (point-min))
813 (while (looking-at message-unix-mail-delimiter)
816 end (or (message-goto-body) beg))
817 ;; Delete the headers from the displayed articles.
818 (set-buffer gnus-article-copy)
819 (delete-region (goto-char (point-min))
820 (or (message-goto-body) (point-max)))
821 ;; Insert the original article headers.
822 (insert-buffer-substring gnus-original-article-buffer beg end)
824 (let ((gnus-article-decode-hook
825 (delq 'article-decode-charset
826 (copy-sequence gnus-article-decode-hook))))
827 (run-hooks 'gnus-article-decode-hook)))))
830 (defun gnus-post-news (post &optional group header article-buffer yank subject
833 (gnus-copy-article-buffer))
834 (let ((gnus-article-reply (and article-buffer (gnus-summary-article-number)))
835 (add-to-list gnus-add-to-list))
836 (gnus-setup-message (cond (yank 'reply-yank)
837 (article-buffer 'reply)
839 (let* ((group (or group gnus-newsgroup-name))
840 (charset (gnus-group-name-charset nil group))
842 to-address to-group mailing-list to-list
845 (setq to-address (gnus-parameter-to-address group)
846 to-group (gnus-group-find-parameter group 'to-group)
847 to-list (gnus-parameter-to-list group)
848 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
849 mailing-list (when gnus-mailing-list-groups
850 (string-match gnus-mailing-list-groups group))
851 group (gnus-group-name-decode (gnus-group-real-name group)
853 (if (or (and to-group
854 (gnus-news-group-p to-group))
857 (and (gnus-news-group-p
858 (or pgroup gnus-newsgroup-name)
859 (or header gnus-current-article))
865 (message-news (or to-group group))
866 (set-buffer gnus-article-copy)
867 (gnus-msg-treat-broken-reply-to)
868 (message-followup (if (or newsgroup-p force-news)
869 (if (save-restriction
870 (article-narrow-to-head)
871 (message-fetch-field "newsgroups"))
878 (message-mail (or to-address to-list))
879 ;; Arrange for mail groups that have no `to-address' to
880 ;; get that when the user sends off the mail.
881 (when (and (not to-list)
884 (push (list 'gnus-inews-add-to-address pgroup)
885 message-send-actions)))
886 (set-buffer gnus-article-copy)
887 (gnus-msg-treat-broken-reply-to)
888 (message-wide-reply to-address)))
890 (gnus-inews-yank-articles yank))))))
892 (defun gnus-msg-treat-broken-reply-to (&optional force)
893 "Remove the Reply-to header iff broken-reply-to."
895 (gnus-group-find-parameter
896 gnus-newsgroup-name 'broken-reply-to))
898 (message-narrow-to-head)
899 (message-remove-header "reply-to"))))
901 (defun gnus-post-method (arg group &optional silent)
902 "Return the posting method based on GROUP and ARG.
903 If SILENT, don't prompt the user."
904 (let ((gnus-post-method (or (gnus-parameter-post-method group)
906 (group-method (gnus-find-method-for-group group)))
908 ;; If the group-method is nil (which shouldn't happen) we use
909 ;; the default method.
911 (or (and (listp gnus-post-method) ;If not current/native/nil
912 (not (listp (car gnus-post-method))) ; and not a list of methods
913 gnus-post-method) ;then use it.
915 message-post-method))
916 ;; We want the inverse of the default
917 ((and arg (not (eq arg 0)))
918 (if (eq gnus-post-method 'current)
921 ;; We query the user for a post method.
923 (and (listp gnus-post-method)
924 (listp (car gnus-post-method))))
926 ;; Collect all methods we know about.
928 (when (listp gnus-post-method)
929 (if (listp (car gnus-post-method))
931 (list gnus-post-method)))
932 gnus-secondary-select-methods
933 (mapcar 'cdr gnus-server-alist)
934 (mapcar 'car gnus-opened-servers)
935 (list gnus-select-method)
936 (list group-method)))
937 method-alist post-methods method)
938 ;; Weed out all mail methods.
940 (setq method (gnus-server-get-method "" (pop methods)))
941 (when (and (or (gnus-method-option-p method 'post)
942 (gnus-method-option-p method 'post-mail))
943 (not (member method post-methods)))
944 (push method post-methods)))
945 ;; Create a name-method alist.
949 (if (equal (cadr m) "")
950 (list (symbol-name (car m)) m)
951 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m)))
956 (setq gnus-last-posting-server
958 gnus-last-posting-server)
959 ;; Just use the last value.
960 gnus-last-posting-server
962 "Posting method: " method-alist nil t
963 (cons (or gnus-last-posting-server "") 0))))
965 ;; Override normal method.
966 ((and (eq gnus-post-method 'current)
967 (not (memq (car group-method) gnus-discouraged-post-methods))
968 (gnus-get-function group-method 'request-post t))
971 ;; Use gnus-post-method.
972 ((listp gnus-post-method) ;A method...
973 (assert (not (listp (car gnus-post-method)))) ;... not a list of methods.
975 ;; Use the normal select method (nil or native).
976 (t gnus-select-method))))
980 ;; Dummies to avoid byte-compile warning.
982 (defvar nnspool-rejected-article-hook)
983 (defvar xemacs-codename))
985 (defun gnus-extended-version ()
986 "Stringified Gnus version and Emacs version."
989 "Gnus/" (prin1-to-string (gnus-continuum-version gnus-version) t)
990 " (" gnus-version ")"
993 ((string-match "^\\(\\([.0-9]+\\)*\\)\\.[0-9]+$" emacs-version)
994 (concat "Emacs/" (match-string 1 emacs-version)
995 " (" system-configuration ")"))
996 ((string-match "\\([A-Z]*[Mm][Aa][Cc][Ss]\\)[^(]*\\(\\((beta.*)\\|'\\)\\)?"
998 (concat (match-string 1 emacs-version)
999 (format "/%d.%d" emacs-major-version emacs-minor-version)
1000 (if (match-beginning 3)
1001 (match-string 3 emacs-version)
1003 (if (boundp 'xemacs-codename)
1004 (concat " (" xemacs-codename ", " system-configuration ")")
1006 (t emacs-version))))
1010 ;;; Gnus Mail Functions
1013 ;;; Mail reply commands of Gnus summary mode
1015 (defun gnus-summary-reply (&optional yank wide very-wide)
1016 "Start composing a mail reply to the current message.
1017 If prefix argument YANK is non-nil, the original article is yanked
1019 If WIDE, make a wide reply.
1020 If VERY-WIDE, make a very wide reply."
1022 (list (and current-prefix-arg
1023 (gnus-summary-work-articles 1))))
1024 ;; Allow user to require confirmation before replying by mail to the
1025 ;; author of a news article.
1026 (when (or (not (gnus-news-group-p gnus-newsgroup-name))
1027 (not gnus-confirm-mail-reply-to-news)
1028 (y-or-n-p "Really reply by mail to article author? "))
1030 (if (listp (car yank))
1033 (gnus-article-reply (or article (gnus-summary-article-number)))
1035 ;; Stripping headers should be specified with mail-yank-ignored-headers.
1037 (gnus-summary-goto-subject article))
1038 (gnus-setup-message (if yank 'reply-yank 'reply)
1040 (gnus-summary-select-article)
1041 (dolist (article very-wide)
1042 (gnus-summary-select-article nil nil nil article)
1044 (set-buffer (gnus-copy-article-buffer))
1045 (gnus-msg-treat-broken-reply-to)
1047 (message-narrow-to-head)
1048 (setq headers (concat headers (buffer-string)))))))
1049 (set-buffer (gnus-copy-article-buffer))
1050 (gnus-msg-treat-broken-reply-to gnus-msg-force-broken-reply-to)
1052 (message-narrow-to-head)
1056 (goto-char (point-max)))
1057 (mml-quote-region (point) (point-max))
1058 (message-reply nil wide)
1060 (gnus-inews-yank-articles yank))
1061 (gnus-summary-handle-replysign)))))
1063 (defun gnus-summary-handle-replysign ()
1064 "Check the various replysign variables and take action accordingly."
1065 (when (or gnus-message-replysign gnus-message-replyencrypt)
1066 (let (signed encrypted)
1068 (set-buffer gnus-article-buffer)
1069 (setq signed (memq 'signed gnus-article-wash-types))
1070 (setq encrypted (memq 'encrypted gnus-article-wash-types)))
1071 (cond ((and gnus-message-replysign signed)
1072 (mml-secure-message mml-default-sign-method 'sign))
1073 ((and gnus-message-replyencrypt encrypted)
1074 (mml-secure-message mml-default-encrypt-method
1075 (if gnus-message-replysignencrypted
1079 (defun gnus-summary-reply-with-original (n &optional wide)
1080 "Start composing a reply mail to the current message.
1081 The original article will be yanked."
1083 (gnus-summary-reply (gnus-summary-work-articles n) wide))
1085 (defun gnus-summary-reply-broken-reply-to (&optional yank wide very-wide)
1086 "Like `gnus-summary-reply' except removing reply-to field.
1087 If prefix argument YANK is non-nil, the original article is yanked
1089 If WIDE, make a wide reply.
1090 If VERY-WIDE, make a very wide reply."
1092 (list (and current-prefix-arg
1093 (gnus-summary-work-articles 1))))
1094 (let ((gnus-msg-force-broken-reply-to t))
1095 (gnus-summary-reply yank wide very-wide)))
1097 (defun gnus-summary-reply-broken-reply-to-with-original (n &optional wide)
1098 "Like `gnus-summary-reply-with-original' except removing reply-to field.
1099 The original article will be yanked."
1101 (gnus-summary-reply-broken-reply-to (gnus-summary-work-articles n) wide))
1103 (defun gnus-summary-wide-reply (&optional yank)
1104 "Start composing a wide reply mail to the current message.
1105 If prefix argument YANK is non-nil, the original article is yanked
1108 (list (and current-prefix-arg
1109 (gnus-summary-work-articles 1))))
1110 (gnus-summary-reply yank t))
1112 (defun gnus-summary-wide-reply-with-original (n)
1113 "Start composing a wide reply mail to the current message.
1114 The original article will be yanked."
1116 (gnus-summary-reply-with-original n t))
1118 (defun gnus-summary-very-wide-reply (&optional yank)
1119 "Start composing a very wide reply mail to the current message.
1120 If prefix argument YANK is non-nil, the original article is yanked
1123 (list (and current-prefix-arg
1124 (gnus-summary-work-articles 1))))
1125 (gnus-summary-reply yank t (gnus-summary-work-articles yank)))
1127 (defun gnus-summary-very-wide-reply-with-original (n)
1128 "Start composing a very wide reply mail to the current message.
1129 The original article will be yanked."
1132 (gnus-summary-work-articles n) t (gnus-summary-work-articles n)))
1134 (defun gnus-summary-mail-forward (&optional arg post)
1135 "Forward the current message(s) to another user.
1136 If process marks exist, forward all marked messages;
1137 if ARG is nil, see `message-forward-as-mime' and `message-forward-show-mml';
1138 if ARG is 1, decode the message and forward directly inline;
1139 if ARG is 2, forward message as an rfc822 MIME section;
1140 if ARG is 3, decode message and forward as an rfc822 MIME section;
1141 if ARG is 4, forward message directly inline;
1142 otherwise, use flipped `message-forward-as-mime'.
1143 If POST, post instead of mail.
1144 For the `inline' alternatives, also see the variable
1145 `message-forward-ignored-headers'."
1147 (if (null (cdr (gnus-summary-work-articles nil)))
1148 (let ((message-forward-as-mime message-forward-as-mime)
1149 (message-forward-show-mml message-forward-show-mml))
1153 (setq message-forward-as-mime nil
1154 message-forward-show-mml t))
1156 (setq message-forward-as-mime t
1157 message-forward-show-mml nil))
1159 (setq message-forward-as-mime t
1160 message-forward-show-mml t))
1162 (setq message-forward-as-mime nil
1163 message-forward-show-mml nil))
1165 (setq message-forward-as-mime (not message-forward-as-mime))))
1166 (let ((gnus-article-reply (gnus-summary-article-number)))
1167 (gnus-setup-message 'forward
1168 (gnus-summary-select-article)
1169 (let ((mail-parse-charset
1170 (or (and (gnus-buffer-live-p gnus-article-buffer)
1171 (with-current-buffer gnus-article-buffer
1172 gnus-article-charset))
1173 gnus-newsgroup-charset))
1174 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
1175 (set-buffer gnus-original-article-buffer)
1176 (message-forward post)))))
1177 (gnus-uu-digest-mail-forward arg post)))
1179 (defun gnus-summary-resend-message (address n)
1180 "Resend the current article to ADDRESS."
1182 (list (message-read-from-minibuffer
1183 "Resend message(s) to: "
1184 (when (and gnus-summary-resend-default-address
1185 (gnus-buffer-live-p gnus-original-article-buffer))
1186 ;; If some other article is currently selected, the
1187 ;; initial-contents is wrong. Whatever, it is just the
1188 ;; initial-contents.
1189 (with-current-buffer gnus-original-article-buffer
1190 (nnmail-fetch-field "to"))))
1191 current-prefix-arg))
1192 (let ((articles (gnus-summary-work-articles n))
1194 (while (setq article (pop articles))
1195 (gnus-summary-select-article nil nil nil article)
1197 (set-buffer gnus-original-article-buffer)
1198 (message-resend address))
1199 (gnus-summary-mark-article-as-forwarded article))))
1201 ;; From: Matthieu Moy <Matthieu.Moy@imag.fr>
1202 (defun gnus-summary-resend-message-edit ()
1203 "Resend an article that has already been sent.
1204 A new buffer will be created to allow the user to modify body and
1205 contents of the message, and then, everything will happen as when
1206 composing a new message."
1208 (let ((article (gnus-summary-article-number)))
1209 (gnus-setup-message 'reply-yank
1210 (gnus-summary-select-article t)
1211 (set-buffer gnus-original-article-buffer)
1212 (let ((cur (current-buffer))
1213 (to (message-fetch-field "to")))
1214 ;; Get a normal message buffer.
1215 (message-pop-to-buffer (message-buffer-name "Resend" to))
1216 (insert-buffer-substring cur)
1218 (message-narrow-to-head-1)
1219 ;; Gnus will generate a new one when sending.
1220 (message-remove-header "Message-ID")
1221 (message-remove-header message-ignored-resent-headers t)
1222 ;; Remove unwanted headers.
1223 (goto-char (point-max))
1224 (insert mail-header-separator)
1225 (goto-char (point-min))
1226 (re-search-forward "^To:\\|^Newsgroups:" nil 'move)
1230 (defun gnus-summary-post-forward (&optional arg)
1231 "Forward the current article to a newsgroup.
1232 See `gnus-summary-mail-forward' for ARG."
1234 (gnus-summary-mail-forward arg t))
1236 (defvar gnus-nastygram-message
1237 "The following article was inappropriately posted to %s.\n\n"
1238 "Format string to insert in nastygrams.
1239 The current group name will be inserted at \"%s\".")
1241 (defun gnus-summary-mail-nastygram (n)
1242 "Send a nastygram to the author of the current article."
1244 (when (or gnus-expert-user
1246 "Really send a nastygram to the author of the current article? "))
1247 (let ((group gnus-newsgroup-name))
1248 (gnus-summary-reply-with-original n)
1249 (set-buffer gnus-message-buffer)
1251 (insert (format gnus-nastygram-message group))
1252 (message-send-and-exit))))
1254 (defun gnus-summary-mail-crosspost-complaint (n)
1255 "Send a complaint about crossposting to the current article(s)."
1257 (let ((articles (gnus-summary-work-articles n))
1259 (while (setq article (pop articles))
1260 (set-buffer gnus-summary-buffer)
1261 (gnus-summary-goto-subject article)
1262 (let ((group (gnus-group-real-name gnus-newsgroup-name))
1263 newsgroups followup-to)
1264 (gnus-summary-select-article)
1265 (set-buffer gnus-original-article-buffer)
1266 (if (and (<= (length (message-tokenize-header
1268 (mail-fetch-field "newsgroups"))
1271 (or (not (setq followup-to (mail-fetch-field "followup-to")))
1272 (not (member group (message-tokenize-header
1273 followup-to ", ")))))
1275 (gnus-message 1 "Followup-to restricted")
1276 (gnus-message 1 "Not a crossposted article"))
1277 (set-buffer gnus-summary-buffer)
1278 (gnus-summary-reply-with-original 1)
1279 (set-buffer gnus-message-buffer)
1281 (insert (format gnus-crosspost-complaint newsgroups group))
1282 (message-goto-subject)
1283 (re-search-forward " *$")
1284 (replace-match " (crosspost notification)" t t)
1285 (gnus-deactivate-mark)
1286 (when (gnus-y-or-n-p "Send this complaint? ")
1287 (message-send-and-exit)))))))
1289 (defun gnus-mail-parse-comma-list ()
1292 (skip-chars-forward " ")
1295 (skip-chars-forward "^,")
1300 (narrow-to-region beg (point))
1303 (while (search-forward "\"" nil t)
1307 (skip-chars-forward ",")
1308 (skip-chars-forward "^,"))
1309 (skip-chars-backward " ")
1310 (push (buffer-substring beg (point))
1312 (skip-chars-forward "^,")
1313 (skip-chars-forward ", "))
1316 (defun gnus-inews-add-to-address (group)
1317 (let ((to-address (mail-fetch-field "to")))
1318 (when (and to-address
1320 ;; This mail group doesn't have a `to-list', so we add one
1322 (when (gnus-y-or-n-p
1323 (format "Do you want to add this as `to-list': %s " to-address))
1324 (gnus-group-add-parameter group (cons 'to-list to-address))))))
1326 (defun gnus-put-message ()
1327 "Put the current message in some group and return to Gnus."
1329 (let ((reply gnus-article-reply)
1330 (winconf gnus-prev-winconf)
1331 (group gnus-newsgroup-name))
1333 (not (gnus-group-read-only-p group)))
1334 (setq group (read-string "Put in group: " nil (gnus-writable-groups))))
1336 (when (gnus-gethash group gnus-newsrc-hashtb)
1337 (error "No such group: %s" group))
1341 (message-narrow-to-headers)
1342 (let ((gnus-deletable-headers nil))
1343 (message-generate-headers
1344 (if (message-news-p)
1345 message-required-news-headers
1346 message-required-mail-headers)))
1347 (goto-char (point-max))
1348 (if (string-match " " group)
1349 (insert "Gcc: \"" group "\"\n")
1350 (insert "Gcc: " group "\n"))
1353 (when (and (get-buffer gnus-group-buffer)
1354 (gnus-buffer-exists-p (car-safe reply))
1356 (set-buffer (car reply))
1357 (gnus-summary-mark-article-as-replied (cdr reply)))
1359 (set-window-configuration winconf))))
1361 (defun gnus-article-mail (yank)
1362 "Send a reply to the address near point.
1363 If YANK is non-nil, include the original article."
1367 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
1368 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
1370 (gnus-msg-mail address)
1372 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
1374 (defvar nntp-server-type)
1376 "Send a bug report to the Gnus maintainers."
1378 (unless (gnus-alive-p)
1379 (error "Gnus has been shut down"))
1380 (gnus-setup-message (if (message-mail-user-agent) 'message 'bug)
1381 (unless (message-mail-user-agent)
1382 (delete-other-windows)
1383 (when gnus-bug-create-help-buffer
1384 (switch-to-buffer "*Gnus Help Bug*")
1386 (insert gnus-bug-message)
1387 (goto-char (point-min)))
1388 (message-pop-to-buffer "*Gnus Bug*"))
1389 (let ((message-this-is-mail t))
1390 (message-setup `((To . ,gnus-maintainer) (Subject . ""))))
1391 (when gnus-bug-create-help-buffer
1392 (push `(gnus-bug-kill-buffer) message-send-actions))
1393 (goto-char (point-min))
1394 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
1396 (insert (gnus-version) "\n"
1397 (emacs-version) "\n")
1398 (when (and (boundp 'nntp-server-type)
1399 (stringp nntp-server-type))
1400 (insert nntp-server-type))
1401 (insert "\n\n\n\n\n")
1404 (set-buffer (gnus-get-buffer-create " *gnus environment info*"))
1407 (setq text (buffer-string)))
1408 (insert "<#part type=application/emacs-lisp disposition=inline description=\"User settings\">\n" text "\n<#/part>"))
1409 (goto-char (point-min))
1410 (search-forward "Subject: " nil t)
1413 (defun gnus-bug-kill-buffer ()
1414 (when (get-buffer "*Gnus Help Bug*")
1415 (kill-buffer "*Gnus Help Bug*")))
1417 (defun gnus-summary-yank-message (buffer n)
1418 "Yank the current article into a composed message."
1420 (list (completing-read "Buffer: " (mapcar 'list (message-buffers)) nil t)
1421 current-prefix-arg))
1422 (gnus-summary-iterate n
1423 (let ((gnus-display-mime-function nil)
1424 (gnus-inhibit-treatment t))
1425 (gnus-summary-select-article))
1428 (message-yank-buffer gnus-article-buffer))))
1430 (defun gnus-debug ()
1431 "Attempts to go through the Gnus source file and report what variables have been changed.
1432 The source file has to be in the Emacs load path."
1434 (let ((files gnus-debug-files)
1436 file expr olist sym)
1437 (gnus-message 4 "Please wait while we snoop your variables...")
1439 ;; Go through all the files looking for non-default values for variables.
1441 (set-buffer (gnus-get-buffer-create " *gnus bug info*"))
1444 (when (and (setq file (locate-library (pop files)))
1445 (file-exists-p file))
1446 (insert-file-contents file)
1447 (goto-char (point-min))
1448 (if (not (re-search-forward "^;;* *Internal variables" nil t))
1449 (gnus-message 4 "Malformed sources in file %s" file)
1450 (narrow-to-region (point-min) (point))
1451 (goto-char (point-min))
1452 (while (setq expr (ignore-errors (read (current-buffer))))
1454 (and (or (eq (car expr) 'defvar)
1455 (eq (car expr) 'defcustom))
1456 (stringp (nth 3 expr))
1457 (not (memq (nth 1 expr) gnus-debug-exclude-variables))
1458 (or (not (boundp (nth 1 expr)))
1459 (not (equal (eval (nth 2 expr))
1460 (symbol-value (nth 1 expr)))))
1461 (push (nth 1 expr) olist)))))))
1462 (kill-buffer (current-buffer)))
1463 (when (setq olist (nreverse olist))
1464 (insert "------------------ Environment follows ------------------\n\n"))
1466 (if (boundp (car olist))
1468 (pp `(setq ,(car olist)
1469 ,(if (or (consp (setq sym (symbol-value (car olist))))
1471 (not (or (eq sym nil)
1473 (list 'quote (symbol-value (car olist)))
1474 (symbol-value (car olist))))
1477 (format "(setq %s 'whatever)\n" (car olist))))
1478 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
1479 (setq olist (cdr olist)))
1481 ;; Remove any control chars - they seem to cause trouble for some
1482 ;; mailers. (Byte-compiled output from the stuff above.)
1484 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
1485 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
1488 ;;; Treatment of rejected articles.
1491 (defun gnus-summary-resend-bounced-mail (&optional fetch)
1492 "Re-mail the current message.
1493 This only makes sense if the current message is a bounce message than
1494 contains some mail you have written which has been bounced back to
1496 If FETCH, try to fetch the article that this is a reply to, if indeed
1499 (gnus-summary-select-article t)
1500 (set-buffer gnus-original-article-buffer)
1501 (gnus-setup-message 'compose-bounce
1502 (let* ((references (mail-fetch-field "references"))
1503 (parent (and references (gnus-parent-id references))))
1505 ;; If there are references, we fetch the article we answered to.
1507 (gnus-summary-refer-article parent)
1508 (gnus-summary-show-all-headers)))))
1512 (defun gnus-inews-group-method (group)
1514 ;; If the group doesn't exist, we assume
1515 ;; it's an archive group...
1516 ((and (null (gnus-get-info group))
1517 (eq (car (gnus-server-to-method gnus-message-archive-method))
1518 (car (gnus-server-to-method (gnus-group-method group)))))
1519 gnus-message-archive-method)
1521 ((gnus-info-method (gnus-get-info group))
1522 (gnus-info-method (gnus-get-info group)))
1524 (t (gnus-server-to-method (gnus-group-method group)))))
1526 ;; Do Gcc handling, which copied the message over to some group.
1527 (defun gnus-inews-do-gcc (&optional gcc)
1531 (message-narrow-to-headers)
1532 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
1533 (cur (current-buffer))
1534 groups group method group-art
1535 mml-externalize-attachments)
1537 (message-remove-header "gcc")
1539 (setq groups (message-unquote-tokens
1540 (message-tokenize-header gcc " ,")))
1541 ;; Copy the article over to some group(s).
1542 (while (setq group (pop groups))
1543 (unless (gnus-check-server
1544 (setq method (gnus-inews-group-method group)))
1545 (error "Can't open server %s" (if (stringp method) method
1547 (unless (gnus-request-group group nil method)
1548 (gnus-request-create-group group method))
1549 (setq mml-externalize-attachments
1550 (if (stringp gnus-gcc-externalize-attachments)
1551 (string-match gnus-gcc-externalize-attachments group)
1552 gnus-gcc-externalize-attachments))
1554 (nnheader-set-temp-buffer " *acc*")
1555 (insert-buffer-substring cur)
1556 (message-encode-message-body)
1558 (message-narrow-to-headers)
1559 (let* ((mail-parse-charset message-default-charset)
1560 (newsgroups-field (save-restriction
1561 (message-narrow-to-headers-or-head)
1562 (message-fetch-field "Newsgroups")))
1563 (followup-field (save-restriction
1564 (message-narrow-to-headers-or-head)
1565 (message-fetch-field "Followup-To")))
1566 ;; BUG: We really need to get the charset for
1567 ;; each name in the Newsgroups and Followup-To
1568 ;; lines to allow crossposting between group
1569 ;; namess with incompatible character sets.
1570 ;; -- Per Abrahamsen <abraham@dina.kvl.dk> 2001-10-08.
1571 (group-field-charset
1572 (gnus-group-name-charset
1573 method (or newsgroups-field "")))
1574 (followup-field-charset
1575 (gnus-group-name-charset
1576 method (or followup-field "")))
1577 (rfc2047-header-encoding-alist
1579 (when group-field-charset
1580 (list (cons "Newsgroups" group-field-charset)))
1581 (when followup-field-charset
1582 (list (cons "Followup-To" followup-field-charset)))
1583 rfc2047-header-encoding-alist)))
1584 (mail-encode-encoded-word-buffer)))
1585 (goto-char (point-min))
1586 (when (re-search-forward
1587 (concat "^" (regexp-quote mail-header-separator) "$")
1589 (replace-match "" t t ))
1590 (unless (setq group-art
1591 (gnus-request-accept-article group method t t))
1592 (gnus-message 1 "Couldn't store article in group %s: %s"
1593 group (gnus-status-message method))
1595 (when (and group-art
1596 (or gnus-gcc-mark-as-read
1597 gnus-inews-mark-gcc-as-read))
1598 (gnus-group-mark-article-read group (cdr group-art)))
1599 (kill-buffer (current-buffer)))))))))
1601 (defun gnus-inews-insert-gcc ()
1602 "Insert Gcc headers based on `gnus-outgoing-message-group'."
1605 (message-narrow-to-headers)
1606 (let* ((group gnus-outgoing-message-group)
1608 ((gnus-functionp group)
1610 ((or (stringp group) (list group))
1615 (if (string-match " " gcc)
1616 (concat "\"" gcc "\"")
1618 (mapconcat (lambda (group)
1619 (if (string-match " " group)
1620 (concat "\"" group "\"")
1625 (defun gnus-inews-insert-archive-gcc (&optional group)
1626 "Insert the Gcc to say where the article is to be archived."
1627 (let* ((var gnus-message-archive-group)
1628 (group (or group gnus-newsgroup-name ""))
1630 (and gnus-newsgroup-name
1631 (not (equal gnus-newsgroup-name ""))
1632 (gnus-group-find-parameter
1633 gnus-newsgroup-name 'gcc-self)))
1637 ((null gnus-message-archive-method)
1641 ;; Just a single group.
1644 ;; We don't want this.
1646 ((and (listp var) (stringp (car var)))
1647 ;; A list of groups.
1649 ((gnus-functionp var)
1651 (funcall var group))
1653 ;; An alist of regexps/functions/forms.
1658 ((stringp (caar var))
1660 (when (string-match (caar var) group)
1662 ((gnus-functionp (car var))
1664 (funcall (car var) group))
1666 (eval (car var)))))))
1667 (setq var (cdr var)))
1670 (when (or groups gcc-self-val)
1671 (when (stringp groups)
1672 (setq groups (list groups)))
1675 (message-narrow-to-headers)
1676 (goto-char (point-max))
1679 ;; Use the `gcc-self' param value instead.
1682 (if (stringp gcc-self-val)
1683 (if (string-match " " gcc-self-val)
1684 (concat "\"" gcc-self-val "\"")
1686 (if (string-match " " group)
1687 (concat "\"" group "\"")
1689 (if (not (eq gcc-self-val 'none))
1694 ;; Use the list of groups.
1695 (while (setq name (pop groups))
1696 (let ((str (if (string-match ":" name)
1698 (gnus-group-prefixed-name
1699 name gnus-message-archive-method))))
1700 (insert (if (string-match " " str)
1701 (concat "\"" str "\"")
1709 (defun gnus-configure-posting-styles (&optional group-name)
1710 "Configure posting styles according to `gnus-posting-styles'."
1711 (unless gnus-inhibit-posting-styles
1712 (let ((group (or group-name gnus-newsgroup-name ""))
1713 (styles gnus-posting-styles)
1714 style match variable attribute value v results
1715 filep name address element)
1716 ;; If the group has a posting-style parameter, add it at the end with a
1717 ;; regexp matching everything, to be sure it takes precedence over all
1719 (when gnus-newsgroup-name
1720 (let ((tmp-style (gnus-group-find-parameter group 'posting-style t)))
1722 (setq styles (append styles (list (cons ".*" tmp-style)))))))
1723 ;; Go through all styles and look for matches.
1724 (dolist (style styles)
1725 (setq match (pop style))
1726 (goto-char (point-min))
1729 ;; Regexp string match on the group name.
1730 (string-match match group))
1732 ;; Obsolete format of header match.
1733 (and (gnus-buffer-live-p gnus-article-copy)
1734 (with-current-buffer gnus-article-copy
1735 (let ((header (message-fetch-field (pop style))))
1737 (string-match (pop style) header))))))
1738 ((or (symbolp match)
1739 (gnus-functionp match))
1741 ((gnus-functionp match)
1742 ;; Function to be called.
1745 ;; Variable to be checked.
1746 (symbol-value match))))
1749 ((eq (car match) 'header)
1750 ;; New format of header match.
1751 (and (gnus-buffer-live-p gnus-article-copy)
1752 (with-current-buffer gnus-article-copy
1753 (let ((header (message-fetch-field (nth 1 match))))
1755 (string-match (nth 2 match) header))))))
1757 ;; This is a form to be evaled.
1759 ;; We have a match, so we set the variables.
1760 (dolist (attribute style)
1761 (setq element (pop attribute)
1766 ((eq (car attribute) :file)
1769 ((eq (car attribute) :value)
1773 ;; We get the value.
1778 ((or (symbolp value)
1779 (gnus-functionp value))
1780 (cond ((gnus-functionp value)
1783 (symbol-value value))))
1786 ;; Translate obsolescent value.
1788 ((eq element 'signature-file)
1789 (setq element 'signature
1791 ((eq element 'x-face-file)
1792 (setq element 'x-face
1794 ;; Get the contents of file elems.
1796 (setq v (with-temp-buffer
1797 (insert-file-contents v)
1798 (goto-char (point-max))
1802 (setq results (delq (assoc element results) results))
1803 (push (cons element v) results))))
1804 ;; Now we have all the styles, so we insert them.
1805 (setq name (assq 'name results)
1806 address (assq 'address results))
1807 (setq results (delq name (delq address results)))
1808 ;; make-local-hook is not obsolete in Emacs 20 or XEmacs.
1809 (make-local-hook 'message-setup-hook)
1810 (dolist (result results)
1811 (add-hook 'message-setup-hook
1813 ((eq 'eval (car result))
1815 ((eq 'body (car result))
1819 (insert ,(cdr result)))))
1820 ((eq 'signature (car result))
1821 (set (make-local-variable 'message-signature) nil)
1822 (set (make-local-variable 'message-signature-file) nil)
1823 (if (not (cdr result))
1827 (let ((message-signature ,(cdr result)))
1828 (when message-signature
1829 (message-insert-signature)))))))
1832 (if (symbolp (car result))
1833 (capitalize (symbol-name (car result)))
1837 (message-remove-header ,header)
1838 (let ((value ,(cdr result)))
1841 (insert ,header ": " value "\n"))))))))
1843 (when (or name address)
1844 (add-hook 'message-setup-hook
1846 (set (make-local-variable 'user-mail-address)
1847 ,(or (cdr address) user-mail-address))
1848 (let ((user-full-name ,(or (cdr name) (user-full-name)))
1850 ,(or (cdr address) user-mail-address)))
1852 (message-remove-header "From")
1854 (insert "From: " (message-make-from) "\n"))))
1857 ;;; Allow redefinition of functions.
1863 ;;; gnus-msg.el ends here