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 (buffer (current-buffer)))
496 (setq gnus-newsgroup-name
498 (if (= 1 (prefix-numeric-value arg))
499 (completing-read "Use posting style of group: "
500 gnus-active-hashtb nil
501 (gnus-read-active-file-p))
502 (gnus-group-group-name))
504 ;; #### see comment in gnus-setup-message -- drv
505 (gnus-setup-message 'message (message-mail)))
508 (setq gnus-newsgroup-name group)))))
510 (defun gnus-group-news (&optional arg)
511 "Start composing a news.
512 If ARG, post to group under point.
513 If ARG is 1, prompt for group name to post to.
515 This function prepares a news even when using mail groups. This is useful
516 for posting messages to mail groups without actually sending them over the
517 network. The corresponding backend must have a 'request-post method."
519 ;; We can't `let' gnus-newsgroup-name here, since that leads
520 ;; to local variables leaking.
521 (let ((group gnus-newsgroup-name)
522 (buffer (current-buffer)))
525 (setq gnus-newsgroup-name
527 (if (= 1 (prefix-numeric-value arg))
528 (completing-read "Use group: "
529 gnus-active-hashtb nil
530 (gnus-read-active-file-p))
531 (gnus-group-group-name))
533 ;; #### see comment in gnus-setup-message -- drv
534 (gnus-setup-message 'message
535 (message-news (gnus-group-real-name gnus-newsgroup-name))))
538 (setq gnus-newsgroup-name group)))))
540 (defun gnus-group-post-news (&optional arg)
541 "Start composing a message (a news by default).
542 If ARG, post to group under point. If ARG is 1, prompt for group name.
543 Depending on the selected group, the message might be either a mail or
546 ;; Bind this variable here to make message mode hooks work ok.
547 (let ((gnus-newsgroup-name
549 (if (= 1 (prefix-numeric-value arg))
550 (completing-read "Newsgroup: " gnus-active-hashtb nil
551 (gnus-read-active-file-p))
552 (gnus-group-group-name))
554 (gnus-post-news 'post gnus-newsgroup-name)))
556 (defun gnus-summary-mail-other-window (&optional arg)
557 "Start composing a mail in another window.
558 Use the posting of the current group by default.
559 If ARG, don't do that. If ARG is 1, prompt for group name to find the
562 ;; We can't `let' gnus-newsgroup-name here, since that leads
563 ;; to local variables leaking.
564 (let ((group gnus-newsgroup-name)
565 (buffer (current-buffer)))
568 (setq gnus-newsgroup-name
570 (if (= 1 (prefix-numeric-value arg))
571 (completing-read "Use group: "
572 gnus-active-hashtb nil
573 (gnus-read-active-file-p))
575 gnus-newsgroup-name))
576 ;; #### see comment in gnus-setup-message -- drv
577 (gnus-setup-message 'message (message-mail)))
580 (setq gnus-newsgroup-name group)))))
582 (defun gnus-summary-news-other-window (&optional arg)
583 "Start composing a news in another window.
584 Post to the current group by default.
585 If ARG, don't do that. If ARG is 1, prompt for group name to post to.
587 This function prepares a news even when using mail groups. This is useful
588 for posting messages to mail groups without actually sending them over the
589 network. The corresponding backend must have a 'request-post method."
591 ;; We can't `let' gnus-newsgroup-name here, since that leads
592 ;; to local variables leaking.
593 (let ((group gnus-newsgroup-name)
594 (buffer (current-buffer)))
597 (setq gnus-newsgroup-name
599 (if (= 1 (prefix-numeric-value arg))
600 (completing-read "Use group: "
601 gnus-active-hashtb nil
602 (gnus-read-active-file-p))
604 gnus-newsgroup-name))
605 ;; #### see comment in gnus-setup-message -- drv
606 (gnus-setup-message 'message
607 (message-news (gnus-group-real-name gnus-newsgroup-name))))
610 (setq gnus-newsgroup-name group)))))
612 (defun gnus-summary-post-news (&optional arg)
613 "Start composing a message. Post to the current group by default.
614 If ARG, don't do that. If ARG is 1, prompt for a group name to post to.
615 Depending on the selected group, the message might be either a mail or
618 ;; Bind this variable here to make message mode hooks work ok.
619 (let ((gnus-newsgroup-name
621 (if (= 1 (prefix-numeric-value arg))
622 (completing-read "Newsgroup: " gnus-active-hashtb nil
623 (gnus-read-active-file-p))
625 gnus-newsgroup-name)))
626 (gnus-post-news 'post gnus-newsgroup-name)))
629 (defun gnus-summary-followup (yank &optional force-news)
630 "Compose a followup to an article.
631 If prefix argument YANK is non-nil, the original article is yanked
633 YANK is a list of elements, where the car of each element is the
634 article number, and the two following numbers is the region to be
637 (list (and current-prefix-arg
638 (gnus-summary-work-articles 1))))
640 (gnus-summary-goto-subject
641 (if (listp (car yank))
644 (save-window-excursion
645 (gnus-summary-select-article))
646 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
647 (gnus-newsgroup-name gnus-newsgroup-name))
649 (gnus-post-news nil gnus-newsgroup-name
650 headers gnus-article-buffer
651 yank nil force-news)))
653 (defun gnus-summary-followup-with-original (n &optional force-news)
654 "Compose a followup to an article and include the original article."
656 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
658 (defun gnus-summary-followup-to-mail (&optional arg)
659 "Followup to the current mail message via news."
661 (list (and current-prefix-arg
662 (gnus-summary-work-articles 1))))
663 (gnus-summary-followup arg t))
665 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
666 "Followup to the current mail message via news."
668 (gnus-summary-followup (gnus-summary-work-articles arg) t))
670 (defun gnus-inews-yank-articles (articles)
671 (let (beg article yank-string)
673 (while (setq article (pop articles))
674 (when (listp article)
675 (setq yank-string (nth 1 article)
676 article (nth 0 article)))
677 (save-window-excursion
678 (set-buffer gnus-summary-buffer)
679 (gnus-summary-select-article nil nil nil article)
680 (gnus-summary-remove-process-mark article))
681 (gnus-copy-article-buffer nil yank-string)
682 (let ((message-reply-buffer gnus-article-copy)
683 (message-reply-headers
684 ;; The headers are decoded.
685 (with-current-buffer gnus-article-copy
686 (nnheader-fold-continuation-lines)
687 (nnheader-parse-head t))))
688 (message-yank-original)
689 (setq beg (or beg (mark t))))
695 (defun gnus-summary-cancel-article (&optional n symp)
696 "Cancel an article you posted.
697 Uses the process-prefix convention. If given the symbolic
698 prefix `a', cancel using the standard posting method; if not
699 post using the current select method."
700 (interactive (gnus-interactive "P\ny"))
701 (let ((articles (gnus-summary-work-articles n))
704 (gnus-post-method (eq ',symp 'a) ,gnus-newsgroup-name)))
706 (while (setq article (pop articles))
707 (when (gnus-summary-select-article t nil nil article)
708 (when (gnus-eval-in-buffer-window gnus-original-article-buffer
709 (message-cancel-news))
710 (gnus-summary-mark-as-read article gnus-canceled-mark)
711 (gnus-cache-remove-article 1))
712 (gnus-article-hide-headers-if-wanted))
713 (gnus-summary-remove-process-mark article))))
715 (defun gnus-summary-supersede-article ()
716 "Compose an article that will supersede a previous article.
717 This is done simply by taking the old article and adding a Supersedes
718 header line with the old Message-ID."
720 (let ((article (gnus-summary-article-number)))
721 (gnus-setup-message 'reply-yank
722 (gnus-summary-select-article t)
723 (set-buffer gnus-original-article-buffer)
727 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
729 (set-buffer ,gnus-summary-buffer)
730 (gnus-cache-possibly-remove-article ,article nil nil nil t)
731 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
732 message-send-actions))))
736 (defun gnus-copy-article-buffer (&optional article-buffer yank-string)
737 ;; make a copy of the article buffer with all text properties removed
738 ;; this copy is in the buffer gnus-article-copy.
739 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
740 ;; this buffer should be passed to all mail/news reply/post routines.
741 (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
743 (set-buffer gnus-article-copy)
744 (mm-enable-multibyte))
745 (let ((article-buffer (or article-buffer gnus-article-buffer))
747 (if (not (and (get-buffer article-buffer)
748 (gnus-buffer-exists-p article-buffer)))
749 (error "Can't find any article buffer")
751 (set-buffer article-buffer)
752 (let ((gnus-newsgroup-charset (or gnus-article-charset
753 gnus-newsgroup-charset))
754 (gnus-newsgroup-ignored-charsets
755 (or gnus-article-ignored-charsets
756 gnus-newsgroup-ignored-charsets)))
758 ;; Copy over the (displayed) article buffer, delete
759 ;; hidden text and remove text properties.
761 (copy-to-buffer gnus-article-copy (point-min) (point-max))
762 (set-buffer gnus-article-copy)
765 (delete-region (point) (point-max))
766 (insert yank-string))
767 (gnus-article-delete-text-of-type 'annotation)
768 (gnus-remove-text-with-property 'gnus-prev)
769 (gnus-remove-text-with-property 'gnus-next)
770 (gnus-remove-text-with-property 'gnus-decoration)
773 (buffer-substring-no-properties (point-min) (point-max))
775 ;; Find the original headers.
776 (set-buffer gnus-original-article-buffer)
777 (goto-char (point-min))
778 (while (looking-at message-unix-mail-delimiter)
781 end (or (message-goto-body) beg))
782 ;; Delete the headers from the displayed articles.
783 (set-buffer gnus-article-copy)
784 (delete-region (goto-char (point-min))
785 (or (message-goto-body) (point-max)))
786 ;; Insert the original article headers.
787 (insert-buffer-substring gnus-original-article-buffer beg end)
789 (let ((gnus-article-decode-hook
790 (delq 'article-decode-charset
791 (copy-sequence gnus-article-decode-hook))))
792 (run-hooks 'gnus-article-decode-hook)))))
795 (defun gnus-post-news (post &optional group header article-buffer yank subject
798 (gnus-copy-article-buffer))
799 (let ((gnus-article-reply (and article-buffer (gnus-summary-article-number)))
800 (add-to-list gnus-add-to-list))
801 (gnus-setup-message (cond (yank 'reply-yank)
802 (article-buffer 'reply)
804 (let* ((group (or group gnus-newsgroup-name))
805 (charset (gnus-group-name-charset nil group))
807 to-address to-group mailing-list to-list
810 (setq to-address (gnus-parameter-to-address group)
811 to-group (gnus-group-find-parameter group 'to-group)
812 to-list (gnus-parameter-to-list group)
813 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
814 mailing-list (when gnus-mailing-list-groups
815 (string-match gnus-mailing-list-groups group))
816 group (gnus-group-name-decode (gnus-group-real-name group)
818 (if (or (and to-group
819 (gnus-news-group-p to-group))
822 (and (gnus-news-group-p
823 (or pgroup gnus-newsgroup-name)
824 (or header gnus-current-article))
830 (message-news (or to-group group))
831 (set-buffer gnus-article-copy)
832 (gnus-msg-treat-broken-reply-to)
833 (message-followup (if (or newsgroup-p force-news)
834 (if (save-restriction
835 (article-narrow-to-head)
836 (message-fetch-field "newsgroups"))
843 (message-mail (or to-address to-list))
844 ;; Arrange for mail groups that have no `to-address' to
845 ;; get that when the user sends off the mail.
846 (when (and (not to-list)
849 (push (list 'gnus-inews-add-to-address pgroup)
850 message-send-actions)))
851 (set-buffer gnus-article-copy)
852 (gnus-msg-treat-broken-reply-to)
853 (message-wide-reply to-address)))
855 (gnus-inews-yank-articles yank))))))
857 (defun gnus-msg-treat-broken-reply-to (&optional force)
858 "Remove the Reply-to header iff broken-reply-to."
860 (gnus-group-find-parameter
861 gnus-newsgroup-name 'broken-reply-to))
863 (message-narrow-to-head)
864 (message-remove-header "reply-to"))))
866 (defun gnus-post-method (arg group &optional silent)
867 "Return the posting method based on GROUP and ARG.
868 If SILENT, don't prompt the user."
869 (let ((gnus-post-method (or (gnus-parameter-post-method group)
871 (group-method (gnus-find-method-for-group group)))
873 ;; If the group-method is nil (which shouldn't happen) we use
874 ;; the default method.
876 (or (and (listp gnus-post-method) ;If not current/native/nil
877 (not (listp (car gnus-post-method))) ; and not a list of methods
878 gnus-post-method) ;then use it.
880 message-post-method))
881 ;; We want the inverse of the default
882 ((and arg (not (eq arg 0)))
883 (if (eq gnus-post-method 'current)
886 ;; We query the user for a post method.
888 (and (listp gnus-post-method)
889 (listp (car gnus-post-method))))
891 ;; Collect all methods we know about.
893 (when (listp gnus-post-method)
894 (if (listp (car gnus-post-method))
896 (list gnus-post-method)))
897 gnus-secondary-select-methods
898 (mapcar 'cdr gnus-server-alist)
899 (mapcar 'car gnus-opened-servers)
900 (list gnus-select-method)
901 (list group-method)))
902 method-alist post-methods method)
903 ;; Weed out all mail methods.
905 (setq method (gnus-server-get-method "" (pop methods)))
906 (when (and (or (gnus-method-option-p method 'post)
907 (gnus-method-option-p method 'post-mail))
908 (not (member method post-methods)))
909 (push method post-methods)))
910 ;; Create a name-method alist.
914 (if (equal (cadr m) "")
915 (list (symbol-name (car m)) m)
916 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m)))
921 (setq gnus-last-posting-server
923 gnus-last-posting-server)
924 ;; Just use the last value.
925 gnus-last-posting-server
927 "Posting method: " method-alist nil t
928 (cons (or gnus-last-posting-server "") 0))))
930 ;; Override normal method.
931 ((and (eq gnus-post-method 'current)
932 (not (memq (car group-method) gnus-discouraged-post-methods))
933 (gnus-get-function group-method 'request-post t))
936 ;; Use gnus-post-method.
937 ((listp gnus-post-method) ;A method...
938 (assert (not (listp (car gnus-post-method)))) ;... not a list of methods.
940 ;; Use the normal select method (nil or native).
941 (t gnus-select-method))))
945 ;; Dummies to avoid byte-compile warning.
947 (defvar nnspool-rejected-article-hook)
948 (defvar xemacs-codename))
950 (defun gnus-extended-version ()
951 "Stringified Gnus version and Emacs version."
954 "Gnus/" (prin1-to-string (gnus-continuum-version gnus-version) t)
955 " (" gnus-version ")"
958 ((string-match "^\\(\\([.0-9]+\\)*\\)\\.[0-9]+$" emacs-version)
959 (concat "Emacs/" (match-string 1 emacs-version)
960 " (" system-configuration ")"))
961 ((string-match "\\([A-Z]*[Mm][Aa][Cc][Ss]\\)[^(]*\\(\\((beta.*)\\|'\\)\\)?"
963 (concat (match-string 1 emacs-version)
964 (format "/%d.%d" emacs-major-version emacs-minor-version)
965 (if (match-beginning 3)
966 (match-string 3 emacs-version)
968 (if (boundp 'xemacs-codename)
969 (concat " (" xemacs-codename ", " system-configuration ")")
975 ;;; Gnus Mail Functions
978 ;;; Mail reply commands of Gnus summary mode
980 (defun gnus-summary-reply (&optional yank wide very-wide)
981 "Start composing a mail reply to the current message.
982 If prefix argument YANK is non-nil, the original article is yanked
984 If WIDE, make a wide reply.
985 If VERY-WIDE, make a very wide reply."
987 (list (and current-prefix-arg
988 (gnus-summary-work-articles 1))))
989 ;; Allow user to require confirmation before replying by mail to the
990 ;; author of a news article.
991 (when (or (not (gnus-news-group-p gnus-newsgroup-name))
992 (not gnus-confirm-mail-reply-to-news)
993 (y-or-n-p "Really reply by mail to article author? "))
995 (if (listp (car yank))
998 (gnus-article-reply (or article (gnus-summary-article-number)))
1000 ;; Stripping headers should be specified with mail-yank-ignored-headers.
1002 (gnus-summary-goto-subject article))
1003 (gnus-setup-message (if yank 'reply-yank 'reply)
1005 (gnus-summary-select-article)
1006 (dolist (article very-wide)
1007 (gnus-summary-select-article nil nil nil article)
1009 (set-buffer (gnus-copy-article-buffer))
1010 (gnus-msg-treat-broken-reply-to)
1012 (message-narrow-to-head)
1013 (setq headers (concat headers (buffer-string)))))))
1014 (set-buffer (gnus-copy-article-buffer))
1015 (gnus-msg-treat-broken-reply-to gnus-msg-force-broken-reply-to)
1017 (message-narrow-to-head)
1021 (goto-char (point-max)))
1022 (mml-quote-region (point) (point-max))
1023 (message-reply nil wide)
1025 (gnus-inews-yank-articles yank))
1026 (when (or gnus-message-replysign gnus-message-replyencrypt)
1027 (let (signed encrypted)
1029 (set-buffer gnus-article-buffer)
1030 (setq signed (memq 'signed gnus-article-wash-types))
1031 (setq encrypted (memq 'encrypted gnus-article-wash-types)))
1032 (cond ((and gnus-message-replysign signed)
1033 (mml-secure-message mml-default-sign-method 'sign))
1034 ((and gnus-message-replyencrypt encrypted)
1035 (mml-secure-message mml-default-encrypt-method
1036 (if gnus-message-replysignencrypted
1040 (defun gnus-summary-reply-with-original (n &optional wide)
1041 "Start composing a reply mail to the current message.
1042 The original article will be yanked."
1044 (gnus-summary-reply (gnus-summary-work-articles n) wide))
1046 (defun gnus-summary-reply-broken-reply-to (&optional yank wide very-wide)
1047 "Like `gnus-summary-reply' except removing reply-to field.
1048 If prefix argument YANK is non-nil, the original article is yanked
1050 If WIDE, make a wide reply.
1051 If VERY-WIDE, make a very wide reply."
1053 (list (and current-prefix-arg
1054 (gnus-summary-work-articles 1))))
1055 (let ((gnus-msg-force-broken-reply-to t))
1056 (gnus-summary-reply yank wide very-wide)))
1058 (defun gnus-summary-reply-broken-reply-to-with-original (n &optional wide)
1059 "Like `gnus-summary-reply-with-original' except removing reply-to field.
1060 The original article will be yanked."
1062 (gnus-summary-reply-broken-reply-to (gnus-summary-work-articles n) wide))
1064 (defun gnus-summary-wide-reply (&optional yank)
1065 "Start composing a wide reply mail to the current message.
1066 If prefix argument YANK is non-nil, the original article is yanked
1069 (list (and current-prefix-arg
1070 (gnus-summary-work-articles 1))))
1071 (gnus-summary-reply yank t))
1073 (defun gnus-summary-wide-reply-with-original (n)
1074 "Start composing a wide reply mail to the current message.
1075 The original article will be yanked."
1077 (gnus-summary-reply-with-original n t))
1079 (defun gnus-summary-very-wide-reply (&optional yank)
1080 "Start composing a very wide reply mail to the current message.
1081 If prefix argument YANK is non-nil, the original article is yanked
1084 (list (and current-prefix-arg
1085 (gnus-summary-work-articles 1))))
1086 (gnus-summary-reply yank t (gnus-summary-work-articles yank)))
1088 (defun gnus-summary-very-wide-reply-with-original (n)
1089 "Start composing a very wide reply mail to the current message.
1090 The original article will be yanked."
1093 (gnus-summary-work-articles n) t (gnus-summary-work-articles n)))
1095 (defun gnus-summary-mail-forward (&optional arg post)
1096 "Forward the current message(s) to another user.
1097 If process marks exist, forward all marked messages;
1098 if ARG is nil, see `message-forward-as-mime' and `message-forward-show-mml';
1099 if ARG is 1, decode the message and forward directly inline;
1100 if ARG is 2, forward message as an rfc822 MIME section;
1101 if ARG is 3, decode message and forward as an rfc822 MIME section;
1102 if ARG is 4, forward message directly inline;
1103 otherwise, use flipped `message-forward-as-mime'.
1104 If POST, post instead of mail.
1105 For the `inline' alternatives, also see the variable
1106 `message-forward-ignored-headers'."
1108 (if (null (cdr (gnus-summary-work-articles nil)))
1109 (let ((message-forward-as-mime message-forward-as-mime)
1110 (message-forward-show-mml message-forward-show-mml))
1114 (setq message-forward-as-mime nil
1115 message-forward-show-mml t))
1117 (setq message-forward-as-mime t
1118 message-forward-show-mml nil))
1120 (setq message-forward-as-mime t
1121 message-forward-show-mml t))
1123 (setq message-forward-as-mime nil
1124 message-forward-show-mml nil))
1126 (setq message-forward-as-mime (not message-forward-as-mime))))
1127 (let ((gnus-article-reply (gnus-summary-article-number)))
1128 (gnus-setup-message 'forward
1129 (gnus-summary-select-article)
1130 (let ((mail-parse-charset
1131 (or (and (gnus-buffer-live-p gnus-article-buffer)
1132 (with-current-buffer gnus-article-buffer
1133 gnus-article-charset))
1134 gnus-newsgroup-charset))
1135 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
1136 (set-buffer gnus-original-article-buffer)
1137 (message-forward post)))))
1138 (gnus-uu-digest-mail-forward arg post)))
1140 (defun gnus-summary-resend-message (address n)
1141 "Resend the current article to ADDRESS."
1143 (list (message-read-from-minibuffer
1144 "Resend message(s) to: "
1145 (when (gnus-buffer-live-p gnus-original-article-buffer)
1146 ;; If some other article is currently selected, the
1147 ;; initial-contents is wrong. Whatever, it is just the
1148 ;; initial-contents.
1149 (with-current-buffer gnus-original-article-buffer
1150 (nnmail-fetch-field "to"))))
1151 current-prefix-arg))
1152 (let ((articles (gnus-summary-work-articles n))
1154 (while (setq article (pop articles))
1155 (gnus-summary-select-article nil nil nil article)
1157 (set-buffer gnus-original-article-buffer)
1158 (message-resend address))
1159 (gnus-summary-mark-article-as-forwarded article))))
1161 ;; From: Matthieu Moy <Matthieu.Moy@imag.fr>
1162 (defun gnus-summary-resend-message-edit ()
1163 "Resend an article that has already been sent.
1164 A new buffer will be created to allow the user to modify body and
1165 contents of the message, and then, everything will happen as when
1166 composing a new message."
1168 (let ((article (gnus-summary-article-number)))
1169 (gnus-setup-message 'reply-yank
1170 (gnus-summary-select-article t)
1171 (set-buffer gnus-original-article-buffer)
1172 (let ((cur (current-buffer))
1173 (to (message-fetch-field "to")))
1174 ;; Get a normal message buffer.
1175 (message-pop-to-buffer (message-buffer-name "Resend" to))
1176 (insert-buffer-substring cur)
1178 (message-narrow-to-head-1)
1179 ;; Gnus will generate a new one when sending.
1180 (message-remove-header "Message-ID")
1181 (message-remove-header message-ignored-resent-headers t)
1182 ;; Remove unwanted headers.
1183 (goto-char (point-max))
1184 (insert mail-header-separator)
1185 (goto-char (point-min))
1186 (re-search-forward "^To:\\|^Newsgroups:" nil 'move)
1190 (defun gnus-summary-post-forward (&optional arg)
1191 "Forward the current article to a newsgroup.
1192 See `gnus-summary-mail-forward' for ARG."
1194 (gnus-summary-mail-forward arg t))
1196 (defvar gnus-nastygram-message
1197 "The following article was inappropriately posted to %s.\n\n"
1198 "Format string to insert in nastygrams.
1199 The current group name will be inserted at \"%s\".")
1201 (defun gnus-summary-mail-nastygram (n)
1202 "Send a nastygram to the author of the current article."
1204 (when (or gnus-expert-user
1206 "Really send a nastygram to the author of the current article? "))
1207 (let ((group gnus-newsgroup-name))
1208 (gnus-summary-reply-with-original n)
1209 (set-buffer gnus-message-buffer)
1211 (insert (format gnus-nastygram-message group))
1212 (message-send-and-exit))))
1214 (defun gnus-summary-mail-crosspost-complaint (n)
1215 "Send a complaint about crossposting to the current article(s)."
1217 (let ((articles (gnus-summary-work-articles n))
1219 (while (setq article (pop articles))
1220 (set-buffer gnus-summary-buffer)
1221 (gnus-summary-goto-subject article)
1222 (let ((group (gnus-group-real-name gnus-newsgroup-name))
1223 newsgroups followup-to)
1224 (gnus-summary-select-article)
1225 (set-buffer gnus-original-article-buffer)
1226 (if (and (<= (length (message-tokenize-header
1228 (mail-fetch-field "newsgroups"))
1231 (or (not (setq followup-to (mail-fetch-field "followup-to")))
1232 (not (member group (message-tokenize-header
1233 followup-to ", ")))))
1235 (gnus-message 1 "Followup-to restricted")
1236 (gnus-message 1 "Not a crossposted article"))
1237 (set-buffer gnus-summary-buffer)
1238 (gnus-summary-reply-with-original 1)
1239 (set-buffer gnus-message-buffer)
1241 (insert (format gnus-crosspost-complaint newsgroups group))
1242 (message-goto-subject)
1243 (re-search-forward " *$")
1244 (replace-match " (crosspost notification)" t t)
1245 (gnus-deactivate-mark)
1246 (when (gnus-y-or-n-p "Send this complaint? ")
1247 (message-send-and-exit)))))))
1249 (defun gnus-mail-parse-comma-list ()
1252 (skip-chars-forward " ")
1255 (skip-chars-forward "^,")
1260 (narrow-to-region beg (point))
1263 (while (search-forward "\"" nil t)
1267 (skip-chars-forward ",")
1268 (skip-chars-forward "^,"))
1269 (skip-chars-backward " ")
1270 (push (buffer-substring beg (point))
1272 (skip-chars-forward "^,")
1273 (skip-chars-forward ", "))
1276 (defun gnus-inews-add-to-address (group)
1277 (let ((to-address (mail-fetch-field "to")))
1278 (when (and to-address
1280 ;; This mail group doesn't have a `to-list', so we add one
1282 (when (gnus-y-or-n-p
1283 (format "Do you want to add this as `to-list': %s " to-address))
1284 (gnus-group-add-parameter group (cons 'to-list to-address))))))
1286 (defun gnus-put-message ()
1287 "Put the current message in some group and return to Gnus."
1289 (let ((reply gnus-article-reply)
1290 (winconf gnus-prev-winconf)
1291 (group gnus-newsgroup-name))
1293 (not (gnus-group-read-only-p group)))
1294 (setq group (read-string "Put in group: " nil (gnus-writable-groups))))
1296 (when (gnus-gethash group gnus-newsrc-hashtb)
1297 (error "No such group: %s" group))
1301 (message-narrow-to-headers)
1302 (let ((gnus-deletable-headers nil))
1303 (message-generate-headers
1304 (if (message-news-p)
1305 message-required-news-headers
1306 message-required-mail-headers)))
1307 (goto-char (point-max))
1308 (insert "Gcc: " group "\n")
1311 (when (and (get-buffer gnus-group-buffer)
1312 (gnus-buffer-exists-p (car-safe reply))
1314 (set-buffer (car reply))
1315 (gnus-summary-mark-article-as-replied (cdr reply)))
1317 (set-window-configuration winconf))))
1319 (defun gnus-article-mail (yank)
1320 "Send a reply to the address near point.
1321 If YANK is non-nil, include the original article."
1325 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
1326 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
1328 (gnus-msg-mail address)
1330 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
1332 (defvar nntp-server-type)
1334 "Send a bug report to the Gnus maintainers."
1336 (unless (gnus-alive-p)
1337 (error "Gnus has been shut down"))
1338 (gnus-setup-message (if (message-mail-user-agent) 'message 'bug)
1339 (unless (message-mail-user-agent)
1340 (delete-other-windows)
1341 (when gnus-bug-create-help-buffer
1342 (switch-to-buffer "*Gnus Help Bug*")
1344 (insert gnus-bug-message)
1345 (goto-char (point-min)))
1346 (message-pop-to-buffer "*Gnus Bug*"))
1347 (let ((message-this-is-mail t))
1348 (message-setup `((To . ,gnus-maintainer) (Subject . ""))))
1349 (when gnus-bug-create-help-buffer
1350 (push `(gnus-bug-kill-buffer) message-send-actions))
1351 (goto-char (point-min))
1352 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
1354 (insert (gnus-version) "\n"
1355 (emacs-version) "\n")
1356 (when (and (boundp 'nntp-server-type)
1357 (stringp nntp-server-type))
1358 (insert nntp-server-type))
1359 (insert "\n\n\n\n\n")
1362 (set-buffer (gnus-get-buffer-create " *gnus environment info*"))
1365 (setq text (buffer-string)))
1366 (insert "<#part type=application/emacs-lisp disposition=inline description=\"User settings\">\n" text "\n<#/part>"))
1367 (goto-char (point-min))
1368 (search-forward "Subject: " nil t)
1371 (defun gnus-bug-kill-buffer ()
1372 (when (get-buffer "*Gnus Help Bug*")
1373 (kill-buffer "*Gnus Help Bug*")))
1375 (defun gnus-summary-yank-message (buffer n)
1376 "Yank the current article into a composed message."
1378 (list (completing-read "Buffer: " (mapcar 'list (message-buffers)) nil t)
1379 current-prefix-arg))
1380 (gnus-summary-iterate n
1381 (let ((gnus-display-mime-function nil)
1382 (gnus-inhibit-treatment t))
1383 (gnus-summary-select-article))
1386 (message-yank-buffer gnus-article-buffer))))
1388 (defun gnus-debug ()
1389 "Attempts to go through the Gnus source file and report what variables have been changed.
1390 The source file has to be in the Emacs load path."
1392 (let ((files gnus-debug-files)
1394 file expr olist sym)
1395 (gnus-message 4 "Please wait while we snoop your variables...")
1397 ;; Go through all the files looking for non-default values for variables.
1399 (set-buffer (gnus-get-buffer-create " *gnus bug info*"))
1402 (when (and (setq file (locate-library (pop files)))
1403 (file-exists-p file))
1404 (insert-file-contents file)
1405 (goto-char (point-min))
1406 (if (not (re-search-forward "^;;* *Internal variables" nil t))
1407 (gnus-message 4 "Malformed sources in file %s" file)
1408 (narrow-to-region (point-min) (point))
1409 (goto-char (point-min))
1410 (while (setq expr (ignore-errors (read (current-buffer))))
1412 (and (or (eq (car expr) 'defvar)
1413 (eq (car expr) 'defcustom))
1414 (stringp (nth 3 expr))
1415 (not (memq (nth 1 expr) gnus-debug-exclude-variables))
1416 (or (not (boundp (nth 1 expr)))
1417 (not (equal (eval (nth 2 expr))
1418 (symbol-value (nth 1 expr)))))
1419 (push (nth 1 expr) olist)))))))
1420 (kill-buffer (current-buffer)))
1421 (when (setq olist (nreverse olist))
1422 (insert "------------------ Environment follows ------------------\n\n"))
1424 (if (boundp (car olist))
1426 (pp `(setq ,(car olist)
1427 ,(if (or (consp (setq sym (symbol-value (car olist))))
1429 (not (or (eq sym nil)
1431 (list 'quote (symbol-value (car olist)))
1432 (symbol-value (car olist))))
1435 (format "(setq %s 'whatever)\n" (car olist))))
1436 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
1437 (setq olist (cdr olist)))
1439 ;; Remove any control chars - they seem to cause trouble for some
1440 ;; mailers. (Byte-compiled output from the stuff above.)
1442 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
1443 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
1446 ;;; Treatment of rejected articles.
1449 (defun gnus-summary-resend-bounced-mail (&optional fetch)
1450 "Re-mail the current message.
1451 This only makes sense if the current message is a bounce message than
1452 contains some mail you have written which has been bounced back to
1454 If FETCH, try to fetch the article that this is a reply to, if indeed
1457 (gnus-summary-select-article t)
1458 (set-buffer gnus-original-article-buffer)
1459 (gnus-setup-message 'compose-bounce
1460 (let* ((references (mail-fetch-field "references"))
1461 (parent (and references (gnus-parent-id references))))
1463 ;; If there are references, we fetch the article we answered to.
1465 (gnus-summary-refer-article parent)
1466 (gnus-summary-show-all-headers)))))
1470 (defun gnus-inews-group-method (group)
1472 ;; If the group doesn't exist, we assume
1473 ;; it's an archive group...
1474 ((and (null (gnus-get-info group))
1475 (eq (car (gnus-server-to-method gnus-message-archive-method))
1476 (car (gnus-server-to-method (gnus-group-method group)))))
1477 gnus-message-archive-method)
1479 ((gnus-info-method (gnus-get-info group))
1480 (gnus-info-method (gnus-get-info group)))
1482 (t (gnus-server-to-method (gnus-group-method group)))))
1484 ;; Do Gcc handling, which copied the message over to some group.
1485 (defun gnus-inews-do-gcc (&optional gcc)
1489 (message-narrow-to-headers)
1490 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
1491 (cur (current-buffer))
1492 groups group method group-art
1493 mml-externalize-attachments)
1495 (message-remove-header "gcc")
1497 (setq groups (message-unquote-tokens
1498 (message-tokenize-header gcc " ,")))
1499 ;; Copy the article over to some group(s).
1500 (while (setq group (pop groups))
1501 (unless (gnus-check-server
1502 (setq method (gnus-inews-group-method group)))
1503 (error "Can't open server %s" (if (stringp method) method
1505 (unless (gnus-request-group group nil method)
1506 (gnus-request-create-group group method))
1507 (setq mml-externalize-attachments
1508 (if (stringp gnus-gcc-externalize-attachments)
1509 (string-match gnus-gcc-externalize-attachments group)
1510 gnus-gcc-externalize-attachments))
1512 (nnheader-set-temp-buffer " *acc*")
1513 (insert-buffer-substring cur)
1514 (message-encode-message-body)
1516 (message-narrow-to-headers)
1517 (let* ((mail-parse-charset message-default-charset)
1518 (newsgroups-field (save-restriction
1519 (message-narrow-to-headers-or-head)
1520 (message-fetch-field "Newsgroups")))
1521 (followup-field (save-restriction
1522 (message-narrow-to-headers-or-head)
1523 (message-fetch-field "Followup-To")))
1524 ;; BUG: We really need to get the charset for
1525 ;; each name in the Newsgroups and Followup-To
1526 ;; lines to allow crossposting between group
1527 ;; namess with incompatible character sets.
1528 ;; -- Per Abrahamsen <abraham@dina.kvl.dk> 2001-10-08.
1529 (group-field-charset
1530 (gnus-group-name-charset
1531 method (or newsgroups-field "")))
1532 (followup-field-charset
1533 (gnus-group-name-charset
1534 method (or followup-field "")))
1535 (rfc2047-header-encoding-alist
1537 (when group-field-charset
1538 (list (cons "Newsgroups" group-field-charset)))
1539 (when followup-field-charset
1540 (list (cons "Followup-To" followup-field-charset)))
1541 rfc2047-header-encoding-alist)))
1542 (mail-encode-encoded-word-buffer)))
1543 (goto-char (point-min))
1544 (when (re-search-forward
1545 (concat "^" (regexp-quote mail-header-separator) "$")
1547 (replace-match "" t t ))
1548 (unless (setq group-art
1549 (gnus-request-accept-article group method t t))
1550 (gnus-message 1 "Couldn't store article in group %s: %s"
1551 group (gnus-status-message method))
1553 (when (and group-art
1554 (or gnus-gcc-mark-as-read
1555 gnus-inews-mark-gcc-as-read))
1556 (gnus-group-mark-article-read group (cdr group-art)))
1557 (kill-buffer (current-buffer)))))))))
1559 (defun gnus-inews-insert-gcc ()
1560 "Insert Gcc headers based on `gnus-outgoing-message-group'."
1563 (message-narrow-to-headers)
1564 (let* ((group gnus-outgoing-message-group)
1566 ((gnus-functionp group)
1568 ((or (stringp group) (list group))
1572 (if (stringp gcc) gcc
1573 (mapconcat 'identity gcc " "))
1576 (defun gnus-inews-insert-archive-gcc (&optional group)
1577 "Insert the Gcc to say where the article is to be archived."
1578 (let* ((var gnus-message-archive-group)
1579 (group (or group gnus-newsgroup-name ""))
1581 (and gnus-newsgroup-name
1582 (not (equal gnus-newsgroup-name ""))
1583 (gnus-group-find-parameter
1584 gnus-newsgroup-name 'gcc-self)))
1588 ((null gnus-message-archive-method)
1592 ;; Just a single group.
1595 ;; We don't want this.
1597 ((and (listp var) (stringp (car var)))
1598 ;; A list of groups.
1600 ((gnus-functionp var)
1602 (funcall var group))
1604 ;; An alist of regexps/functions/forms.
1609 ((stringp (caar var))
1611 (when (string-match (caar var) group)
1613 ((gnus-functionp (car var))
1615 (funcall (car var) group))
1617 (eval (car var)))))))
1618 (setq var (cdr var)))
1621 (when (or groups gcc-self-val)
1622 (when (stringp groups)
1623 (setq groups (list groups)))
1626 (message-narrow-to-headers)
1627 (goto-char (point-max))
1630 ;; Use the `gcc-self' param value instead.
1633 (if (stringp gcc-self-val)
1636 (if (not (eq gcc-self-val 'none))
1641 ;; Use the list of groups.
1642 (while (setq name (pop groups))
1643 (insert (if (string-match ":" name)
1645 (gnus-group-prefixed-name
1646 name gnus-message-archive-method)))
1653 (defun gnus-configure-posting-styles (&optional group-name)
1654 "Configure posting styles according to `gnus-posting-styles'."
1655 (unless gnus-inhibit-posting-styles
1656 (let ((group (or group-name gnus-newsgroup-name ""))
1657 (styles gnus-posting-styles)
1658 style match variable attribute value v results
1659 filep name address element)
1660 ;; If the group has a posting-style parameter, add it at the end with a
1661 ;; regexp matching everything, to be sure it takes precedence over all
1663 (when gnus-newsgroup-name
1664 (let ((tmp-style (gnus-group-find-parameter group 'posting-style t)))
1666 (setq styles (append styles (list (cons ".*" tmp-style)))))))
1667 ;; Go through all styles and look for matches.
1668 (dolist (style styles)
1669 (setq match (pop style))
1670 (goto-char (point-min))
1673 ;; Regexp string match on the group name.
1674 (string-match match group))
1676 ;; Obsolete format of header match.
1677 (and (gnus-buffer-live-p gnus-article-copy)
1678 (with-current-buffer gnus-article-copy
1679 (let ((header (message-fetch-field (pop style))))
1681 (string-match (pop style) header))))))
1682 ((or (symbolp match)
1683 (gnus-functionp match))
1685 ((gnus-functionp match)
1686 ;; Function to be called.
1689 ;; Variable to be checked.
1690 (symbol-value match))))
1693 ((eq (car match) 'header)
1694 ;; New format of header match.
1695 (and (gnus-buffer-live-p gnus-article-copy)
1696 (with-current-buffer gnus-article-copy
1697 (let ((header (message-fetch-field (nth 1 match))))
1699 (string-match (nth 2 match) header))))))
1701 ;; This is a form to be evaled.
1703 ;; We have a match, so we set the variables.
1704 (dolist (attribute style)
1705 (setq element (pop attribute)
1710 ((eq (car attribute) :file)
1713 ((eq (car attribute) :value)
1717 ;; We get the value.
1722 ((or (symbolp value)
1723 (gnus-functionp value))
1724 (cond ((gnus-functionp value)
1727 (symbol-value value))))
1730 ;; Translate obsolescent value.
1732 ((eq element 'signature-file)
1733 (setq element 'signature
1735 ((eq element 'x-face-file)
1736 (setq element 'x-face
1738 ;; Get the contents of file elems.
1740 (setq v (with-temp-buffer
1741 (insert-file-contents v)
1742 (goto-char (point-max))
1746 (setq results (delq (assoc element results) results))
1747 (push (cons element v) results))))
1748 ;; Now we have all the styles, so we insert them.
1749 (setq name (assq 'name results)
1750 address (assq 'address results))
1751 (setq results (delq name (delq address results)))
1752 ;; make-local-hook is not obsolete in Emacs 20 or XEmacs.
1753 (make-local-hook 'message-setup-hook)
1754 (dolist (result results)
1755 (add-hook 'message-setup-hook
1757 ((eq 'eval (car result))
1759 ((eq 'body (car result))
1763 (insert ,(cdr result)))))
1764 ((eq 'signature (car result))
1765 (set (make-local-variable 'message-signature) nil)
1766 (set (make-local-variable 'message-signature-file) nil)
1767 (if (not (cdr result))
1771 (let ((message-signature ,(cdr result)))
1772 (when message-signature
1773 (message-insert-signature)))))))
1776 (if (symbolp (car result))
1777 (capitalize (symbol-name (car result)))
1781 (message-remove-header ,header)
1782 (let ((value ,(cdr result)))
1785 (insert ,header ": " value "\n"))))))))
1787 (when (or name address)
1788 (add-hook 'message-setup-hook
1790 (set (make-local-variable 'user-mail-address)
1791 ,(or (cdr address) user-mail-address))
1792 (let ((user-full-name ,(or (cdr name) (user-full-name)))
1794 ,(or (cdr address) user-mail-address)))
1796 (message-remove-header "From")
1798 (insert "From: " (message-make-from) "\n"))))
1801 ;;; Allow redefinition of functions.
1807 ;;; gnus-msg.el ends here