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 :link '(custom-manual "(gnus)Posting Styles")
119 :type '(repeat (cons (choice (regexp)
122 (string :tag "Header")
123 (regexp :tag "Regexp"))
127 (choice (const signature)
128 (const signature-file)
135 (string :tag "Header"))
141 (defcustom gnus-gcc-mark-as-read nil
142 "If non-nil, automatically mark Gcc articles as read."
147 (defvar gnus-inews-mark-gcc-as-read nil
148 "Obsolete variable. Use `gnus-gcc-mark-as-read' instead.")
150 (make-obsolete-variable 'gnus-inews-mark-gcc-as-read
151 'gnus-gcc-mark-as-read)
153 (defcustom gnus-gcc-externalize-attachments nil
154 "Should local-file attachments be included as external parts in Gcc copies?
155 If it is `all', attach files as external parts;
156 if a regexp and matches the Gcc group name, attach files as external parts;
157 If nil, attach files as normal parts."
160 :type '(choice (const nil :tag "None")
161 (const all :tag "Any")
162 (string :tag "Regexp")))
164 (gnus-define-group-parameter
165 posting-charset-alist
168 "Return the permitted unencoded charsets for posting of GROUP."
169 :variable gnus-group-posting-charset-alist
171 '(("^\\(no\\|fr\\)\\.[^,]*\\(,[ \t\n]*\\(no\\|fr\\)\\.[^,]*\\)*$" iso-8859-1 (iso-8859-1))
172 ("^\\(fido7\\|relcom\\)\\.[^,]*\\(,[ \t\n]*\\(fido7\\|relcom\\)\\.[^,]*\\)*$" koi8-r (koi8-r))
173 (message-this-is-mail nil nil)
174 (message-this-is-news nil t))
176 "Alist of regexps and permitted unencoded charsets for posting.
177 Each element of the alist has the form (TEST HEADER BODY-LIST), where
178 TEST is either a regular expression matching the newsgroup header or a
180 HEADER is the charset which may be left unencoded in the header (nil
181 means encode all charsets),
182 BODY-LIST is a list of charsets which may be encoded using 8bit
183 content-transfer encoding in the body, or one of the special values
184 nil (always encode using quoted-printable) or t (always use 8bit).
186 Note that any value other than nil for HEADER infringes some RFCs, so
187 use this option with care."
188 :variable-group gnus-charset
190 '(repeat (list :tag "Permitted unencoded charsets"
192 (regexp :tag "Group")
193 (const :tag "Mail message" :value message-this-is-mail)
194 (const :tag "News article" :value message-this-is-news))
195 (choice :tag "Header"
196 (const :tag "None" nil)
197 (symbol :tag "Charset"))
199 (const :tag "Any" :value t)
200 (const :tag "None" :value nil)
201 (repeat :tag "Charsets"
202 (symbol :tag "Charset")))))
203 :parameter-type '(choice :tag "Permitted unencoded charsets"
206 :parameter-document "\
207 List of charsets that are permitted to be unencoded.")
209 (defcustom gnus-debug-files
210 '("gnus.el" "gnus-sum.el" "gnus-group.el"
211 "gnus-art.el" "gnus-start.el" "gnus-async.el"
212 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
213 "gnus-agent.el" "gnus-cache.el" "gnus-srvr.el"
214 "mm-util.el" "mm-decode.el" "nnmail.el" "message.el")
215 "Files whose variables will be reported in `gnus-bug'."
218 :type '(repeat (string :tag "File")))
220 (defcustom gnus-debug-exclude-variables
221 '(mm-mime-mule-charset-alist
222 nnmail-split-fancy message-minibuffer-local-map)
223 "Variables that should not be reported in `gnus-bug'."
226 :type '(repeat (symbol :tag "Variable")))
228 (defcustom gnus-discouraged-post-methods
229 '(nndraft nnml nnimap nnmaildir nnmh nnfolder nndir)
230 "A list of back ends that are not used in \"real\" newsgroups.
231 This variable is used only when `gnus-post-method' is `current'."
233 :group 'gnus-group-foreign
234 :type '(repeat (symbol :tag "Back end")))
236 (defcustom gnus-message-replysign
238 "Automatically sign replys to signed messages.
239 See also the `mml-default-sign-method' variable."
243 (defcustom gnus-message-replyencrypt
245 "Automatically encrypt replys to encrypted messages.
246 See also the `mml-default-encrypt-method' variable."
250 (defcustom gnus-message-replysignencrypted
252 "Setting this causes automatically encryped messages to also be signed."
256 (defcustom gnus-confirm-mail-reply-to-news nil
257 "If non-nil, Gnus requests confirmation when replying to news.
258 This is done because new users often reply by mistake when reading
263 (defcustom gnus-summary-resend-default-address t
264 "If non-nil, Gnus tries to suggest a default address to resend to.
265 If nil, the address field will always be empty after invoking
266 `gnus-summary-resend-message'."
270 ;;; Internal variables.
272 (defvar gnus-inhibit-posting-styles nil
273 "Inhibit the use of posting styles.")
275 (defvar gnus-message-buffer "*Mail Gnus*")
276 (defvar gnus-article-copy nil)
277 (defvar gnus-check-before-posting nil)
278 (defvar gnus-last-posting-server nil)
279 (defvar gnus-message-group-art nil)
281 (defvar gnus-msg-force-broken-reply-to nil)
283 (defconst gnus-bug-message
284 "Sending a bug report to the Gnus Towers.
285 ========================================
287 The buffer below is a mail buffer. When you press `C-c C-c', it will
288 be sent to the Gnus Bug Exterminators.
290 The thing near the bottom of the buffer is how the environment
291 settings will be included in the mail. Please do not delete that.
292 They will tell the Bug People what your environment is, so that it
293 will be easier to locate the bugs.
295 If you have found a bug that makes Emacs go \"beep\", set
296 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
297 and include the backtrace in your bug report.
299 Please describe the bug in annoying, painstaking detail.
301 Thank you for your help in stamping out bugs.
305 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
306 (autoload 'news-setup "rnewspost")
307 (autoload 'news-reply-mode "rnewspost")
308 (autoload 'rmail-dont-reply-to "mail-utils")
309 (autoload 'rmail-output "rmailout"))
313 ;;; Gnus Posting Functions
316 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
317 "p" gnus-summary-post-news
318 "i" gnus-summary-news-other-window
319 "f" gnus-summary-followup
320 "F" gnus-summary-followup-with-original
321 "c" gnus-summary-cancel-article
322 "s" gnus-summary-supersede-article
323 "r" gnus-summary-reply
324 "y" gnus-summary-yank-message
325 "R" gnus-summary-reply-with-original
326 "w" gnus-summary-wide-reply
327 "W" gnus-summary-wide-reply-with-original
328 "v" gnus-summary-very-wide-reply
329 "V" gnus-summary-very-wide-reply-with-original
330 "n" gnus-summary-followup-to-mail
331 "N" gnus-summary-followup-to-mail-with-original
332 "m" gnus-summary-mail-other-window
333 "u" gnus-uu-post-news
334 "\M-c" gnus-summary-mail-crosspost-complaint
335 "Br" gnus-summary-reply-broken-reply-to
336 "BR" gnus-summary-reply-broken-reply-to-with-original
337 "om" gnus-summary-mail-forward
338 "op" gnus-summary-post-forward
339 "Om" gnus-uu-digest-mail-forward
340 "Op" gnus-uu-digest-post-forward)
342 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
343 "b" gnus-summary-resend-bounced-mail
344 ;; "c" gnus-summary-send-draft
345 "r" gnus-summary-resend-message
346 "e" gnus-summary-resend-message-edit)
348 ;;; Internal functions.
350 (defvar gnus-article-reply nil)
351 (defmacro gnus-setup-message (config &rest forms)
352 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
353 (buffer (make-symbol "gnus-setup-message-buffer"))
354 (article (make-symbol "gnus-setup-message-article"))
355 (group (make-symbol "gnus-setup-message-group")))
356 `(let ((,winconf (current-window-configuration))
357 (,buffer (buffer-name (current-buffer)))
358 (,article gnus-article-reply)
359 (,group gnus-newsgroup-name)
360 (message-header-setup-hook
361 (copy-sequence message-header-setup-hook))
362 (mbl mml-buffer-list)
363 (message-mode-hook (copy-sequence message-mode-hook)))
364 (setq mml-buffer-list nil)
365 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
366 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
367 ;; #### FIXME: for a reason that I did not manage to identify yet,
368 ;; the variable `gnus-newsgroup-name' does not honor a dynamically
369 ;; scoped or setq'ed value from a caller like `C-u gnus-summary-mail'.
370 ;; After evaluation of @forms below, it gets the value we actually want
371 ;; to override, and the posting styles are used. For that reason, I've
372 ;; added an optional argument to `gnus-configure-posting-styles' to
373 ;; make sure that the correct value for the group name is used. -- drv
374 (add-hook 'message-mode-hook
376 (gnus-configure-posting-styles ,group)))
380 (gnus-inews-add-send-actions ,winconf ,buffer ,article ,config)
381 (gnus-inews-insert-draft-meta-information ,group ,article)
382 (setq gnus-message-buffer (current-buffer))
383 (set (make-local-variable 'gnus-message-group-art)
384 (cons ,group ,article))
385 (set (make-local-variable 'gnus-newsgroup-name) ,group)
386 (gnus-run-hooks 'gnus-message-setup-hook)
387 (if (eq major-mode 'message-mode)
388 (let ((mbl1 mml-buffer-list))
389 (setq mml-buffer-list mbl) ;; Global value
390 (set (make-local-variable 'mml-buffer-list) mbl1);; Local value
391 ;; LOCAL argument of add-hook differs between GNU Emacs
392 ;; and XEmacs. make-local-hook makes sure they are local.
393 (make-local-hook 'kill-buffer-hook)
394 (make-local-hook 'change-major-mode-hook)
395 (add-hook 'change-major-mode-hook 'mml-destroy-buffers nil t)
396 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))
397 (mml-destroy-buffers)
398 (setq mml-buffer-list mbl)))
400 (gnus-configure-windows ,config t)
401 (run-hooks 'post-command-hook)
402 (set-buffer-modified-p nil))))
404 (defun gnus-inews-insert-draft-meta-information (group article)
407 (not (string= group ""))
408 (not (message-fetch-field gnus-draft-meta-information-header)))
409 (goto-char (point-min))
410 (insert gnus-draft-meta-information-header ": (\"" group "\" "
411 (if article (number-to-string
418 (defun gnus-msg-mail (&optional to subject other-headers continue
419 switch-action yank-action send-actions)
420 "Start editing a mail message to be sent.
421 Like `message-mail', but with Gnus paraphernalia, particularly the
422 Gcc: header for archiving purposes."
424 (let ((buf (current-buffer))
426 (gnus-setup-message 'message
427 (message-mail to subject other-headers continue
428 nil yank-action send-actions))
430 (setq mail-buf (current-buffer))
431 (switch-to-buffer buf)
432 (apply switch-action mail-buf nil)))
433 ;; COMPOSEFUNC should return t if succeed. Undocumented ???
436 (defvar save-selected-window-window)
439 (defun gnus-button-mailto (address)
441 (set-buffer (gnus-copy-article-buffer))
442 (gnus-setup-message 'message
443 (message-reply address))
444 (and (boundp 'save-selected-window-window)
445 (not (window-live-p save-selected-window-window))
446 (setq save-selected-window-window (selected-window))))
449 (defun gnus-button-reply (&optional to-address wide)
450 "Like `message-reply'."
452 (gnus-setup-message 'message
453 (message-reply to-address wide))
454 (and (boundp 'save-selected-window-window)
455 (not (window-live-p save-selected-window-window))
456 (setq save-selected-window-window (selected-window))))
459 (define-mail-user-agent 'gnus-user-agent
460 'gnus-msg-mail 'message-send-and-exit
461 'message-kill-buffer 'message-send-hook)
463 (defun gnus-setup-posting-charset (group)
464 (let ((alist gnus-group-posting-charset-alist)
465 (group (or group ""))
469 (while (setq elem (pop alist))
470 (when (or (and (stringp (car elem))
471 (string-match (car elem) group))
472 (and (gnus-functionp (car elem))
473 (funcall (car elem) group))
474 (and (symbolp (car elem))
475 (symbol-value (car elem))))
476 (throw 'found (cons (cadr elem) (caddr elem)))))))))
478 (defun gnus-inews-add-send-actions (winconf buffer article &optional config)
479 (make-local-hook 'message-sent-hook)
480 (add-hook 'message-sent-hook (if gnus-agent 'gnus-agent-possibly-do-gcc
481 'gnus-inews-do-gcc) nil t)
483 (make-local-hook 'message-header-hook)
484 (add-hook 'message-header-hook 'gnus-agent-possibly-save-gcc nil t))
485 (setq message-post-method
487 (gnus-post-method arg ,gnus-newsgroup-name)))
488 (setq message-newsreader (setq message-mailer (gnus-extended-version)))
490 `(set-window-configuration ,winconf) 'exit 'postpone 'kill)
492 `(when (gnus-buffer-exists-p ,buffer)
496 (if (eq config 'forward)
497 `(gnus-summary-mark-article-as-forwarded ',article)
498 `(gnus-summary-mark-article-as-replied ',article)))))
501 (put 'gnus-setup-message 'lisp-indent-function 1)
502 (put 'gnus-setup-message 'edebug-form-spec '(form body))
504 ;;; Post news commands of Gnus group mode and summary mode
506 (defun gnus-group-mail (&optional arg)
507 "Start composing a mail.
508 If ARG, use the group under the point to find a posting style.
509 If ARG is 1, prompt for a group name to find the posting style."
511 ;; We can't `let' gnus-newsgroup-name here, since that leads
512 ;; to local variables leaking.
513 (let ((group gnus-newsgroup-name)
514 ;; make sure last viewed article doesn't affect posting styles:
516 (buffer (current-buffer)))
519 (setq gnus-newsgroup-name
521 (if (= 1 (prefix-numeric-value arg))
522 (completing-read "Use posting style of group: "
523 gnus-active-hashtb nil
524 (gnus-read-active-file-p))
525 (gnus-group-group-name))
527 ;; #### see comment in gnus-setup-message -- drv
528 (gnus-setup-message 'message (message-mail)))
531 (setq gnus-newsgroup-name group)))))
533 (defun gnus-group-news (&optional arg)
534 "Start composing a news.
535 If ARG, post to group under point.
536 If ARG is 1, prompt for group name to post to.
538 This function prepares a news even when using mail groups. This is useful
539 for posting messages to mail groups without actually sending them over the
540 network. The corresponding backend must have a 'request-post method."
542 ;; We can't `let' gnus-newsgroup-name here, since that leads
543 ;; to local variables leaking.
544 (let ((group gnus-newsgroup-name)
545 ;; make sure last viewed article doesn't affect posting styles:
547 (buffer (current-buffer)))
550 (setq gnus-newsgroup-name
552 (if (= 1 (prefix-numeric-value arg))
553 (completing-read "Use group: "
554 gnus-active-hashtb nil
555 (gnus-read-active-file-p))
556 (gnus-group-group-name))
558 ;; #### see comment in gnus-setup-message -- drv
559 (gnus-setup-message 'message
560 (message-news (gnus-group-real-name gnus-newsgroup-name))))
563 (setq gnus-newsgroup-name group)))))
565 (defun gnus-group-post-news (&optional arg)
566 "Start composing a message (a news by default).
567 If ARG, post to group under point. If ARG is 1, prompt for group name.
568 Depending on the selected group, the message might be either a mail or
571 ;; Bind this variable here to make message mode hooks work ok.
572 (let ((gnus-newsgroup-name
574 (if (= 1 (prefix-numeric-value arg))
575 (completing-read "Newsgroup: " gnus-active-hashtb nil
576 (gnus-read-active-file-p))
577 (gnus-group-group-name))
579 ;; make sure last viewed article doesn't affect posting styles:
581 (gnus-post-news 'post gnus-newsgroup-name)))
583 (defun gnus-summary-mail-other-window (&optional arg)
584 "Start composing a mail in another window.
585 Use the posting of the current group by default.
586 If ARG, don't do that. If ARG is 1, prompt for group name to find the
589 ;; We can't `let' gnus-newsgroup-name here, since that leads
590 ;; to local variables leaking.
591 (let ((group gnus-newsgroup-name)
592 ;; make sure last viewed article doesn't affect posting styles:
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 (message-mail)))
609 (setq gnus-newsgroup-name group)))))
611 (defun gnus-summary-news-other-window (&optional arg)
612 "Start composing a news in another window.
613 Post to the current group by default.
614 If ARG, don't do that. If ARG is 1, prompt for group name to post to.
616 This function prepares a news even when using mail groups. This is useful
617 for posting messages to mail groups without actually sending them over the
618 network. The corresponding backend must have a 'request-post method."
620 ;; We can't `let' gnus-newsgroup-name here, since that leads
621 ;; to local variables leaking.
622 (let ((group gnus-newsgroup-name)
623 ;; make sure last viewed article doesn't affect posting styles:
625 (buffer (current-buffer)))
628 (setq gnus-newsgroup-name
630 (if (= 1 (prefix-numeric-value arg))
631 (completing-read "Use group: "
632 gnus-active-hashtb nil
633 (gnus-read-active-file-p))
635 gnus-newsgroup-name))
636 ;; #### see comment in gnus-setup-message -- drv
637 (gnus-setup-message 'message
638 (message-news (gnus-group-real-name gnus-newsgroup-name))))
641 (setq gnus-newsgroup-name group)))))
643 (defun gnus-summary-post-news (&optional arg)
644 "Start composing a message. Post to the current group by default.
645 If ARG, don't do that. If ARG is 1, prompt for a group name to post to.
646 Depending on the selected group, the message might be either a mail or
649 ;; Bind this variable here to make message mode hooks work ok.
650 (let ((gnus-newsgroup-name
652 (if (= 1 (prefix-numeric-value arg))
653 (completing-read "Newsgroup: " gnus-active-hashtb nil
654 (gnus-read-active-file-p))
656 gnus-newsgroup-name))
657 ;; make sure last viewed article doesn't affect posting styles:
659 (gnus-post-news 'post gnus-newsgroup-name)))
662 (defun gnus-summary-followup (yank &optional force-news)
663 "Compose a followup to an article.
664 If prefix argument YANK is non-nil, the original article is yanked
666 YANK is a list of elements, where the car of each element is the
667 article number, and the two following numbers is the region to be
670 (list (and current-prefix-arg
671 (gnus-summary-work-articles 1))))
673 (gnus-summary-goto-subject
674 (if (listp (car yank))
677 (save-window-excursion
678 (gnus-summary-select-article))
679 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
680 (gnus-newsgroup-name gnus-newsgroup-name))
682 (gnus-post-news nil gnus-newsgroup-name
683 headers gnus-article-buffer
685 (gnus-summary-handle-replysign)))
687 (defun gnus-summary-followup-with-original (n &optional force-news)
688 "Compose a followup to an article and include the original article."
690 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
692 (defun gnus-summary-followup-to-mail (&optional arg)
693 "Followup to the current mail message via news."
695 (list (and current-prefix-arg
696 (gnus-summary-work-articles 1))))
697 (gnus-summary-followup arg t))
699 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
700 "Followup to the current mail message via news."
702 (gnus-summary-followup (gnus-summary-work-articles arg) t))
704 (defun gnus-inews-yank-articles (articles)
705 (let (beg article yank-string)
707 (while (setq article (pop articles))
708 (when (listp article)
709 (setq yank-string (nth 1 article)
710 article (nth 0 article)))
711 (save-window-excursion
712 (set-buffer gnus-summary-buffer)
713 (gnus-summary-select-article nil nil nil article)
714 (gnus-summary-remove-process-mark article))
715 (gnus-copy-article-buffer nil yank-string)
716 (let ((message-reply-buffer gnus-article-copy)
717 (message-reply-headers
718 ;; The headers are decoded.
719 (with-current-buffer gnus-article-copy
721 (nnheader-narrow-to-headers)
722 (nnheader-parse-naked-head)))))
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)
815 (let ((mail-header-separator ""))
817 end (or (message-goto-body) beg)))
818 ;; Delete the headers from the displayed articles.
819 (set-buffer gnus-article-copy)
820 (let ((mail-header-separator ""))
821 (delete-region (goto-char (point-min))
822 (or (message-goto-body) (point-max))))
823 ;; Insert the original article headers.
824 (insert-buffer-substring gnus-original-article-buffer beg end)
826 (let ((gnus-article-decode-hook
827 (delq 'article-decode-charset
828 (copy-sequence gnus-article-decode-hook))))
829 (run-hooks 'gnus-article-decode-hook)))))
832 (defun gnus-post-news (post &optional group header article-buffer yank subject
835 (gnus-copy-article-buffer))
836 (let ((gnus-article-reply (and article-buffer (gnus-summary-article-number)))
837 (add-to-list gnus-add-to-list))
838 (gnus-setup-message (cond (yank 'reply-yank)
839 (article-buffer 'reply)
841 (let* ((group (or group gnus-newsgroup-name))
842 (charset (gnus-group-name-charset nil group))
844 to-address to-group mailing-list to-list
847 (setq to-address (gnus-parameter-to-address group)
848 to-group (gnus-group-find-parameter group 'to-group)
849 to-list (gnus-parameter-to-list group)
850 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
851 mailing-list (when gnus-mailing-list-groups
852 (string-match gnus-mailing-list-groups group))
853 group (gnus-group-name-decode (gnus-group-real-name group)
855 (if (or (and to-group
856 (gnus-news-group-p to-group))
859 (and (gnus-news-group-p
860 (or pgroup gnus-newsgroup-name)
861 (or header gnus-current-article))
867 (message-news (or to-group group))
868 (set-buffer gnus-article-copy)
869 (gnus-msg-treat-broken-reply-to)
870 (message-followup (if (or newsgroup-p force-news)
871 (if (save-restriction
872 (article-narrow-to-head)
873 (message-fetch-field "newsgroups"))
880 (message-mail (or to-address to-list))
881 ;; Arrange for mail groups that have no `to-address' to
882 ;; get that when the user sends off the mail.
883 (when (and (not to-list)
886 (push (list 'gnus-inews-add-to-address pgroup)
887 message-send-actions)))
888 (set-buffer gnus-article-copy)
889 (gnus-msg-treat-broken-reply-to)
890 (message-wide-reply to-address)))
892 (gnus-inews-yank-articles yank))))))
894 (defun gnus-msg-treat-broken-reply-to (&optional force)
895 "Remove the Reply-to header if broken-reply-to."
897 (gnus-group-find-parameter
898 gnus-newsgroup-name 'broken-reply-to))
900 (message-narrow-to-head)
901 (message-remove-header "reply-to"))))
903 (defun gnus-post-method (arg group &optional silent)
904 "Return the posting method based on GROUP and ARG.
905 If SILENT, don't prompt the user."
906 (let ((gnus-post-method (or (gnus-parameter-post-method group)
908 (group-method (gnus-find-method-for-group group)))
910 ;; If the group-method is nil (which shouldn't happen) we use
911 ;; the default method.
913 (or (and (listp gnus-post-method) ;If not current/native/nil
914 (not (listp (car gnus-post-method))) ; and not a list of methods
915 gnus-post-method) ;then use it.
917 message-post-method))
918 ;; We want the inverse of the default
919 ((and arg (not (eq arg 0)))
920 (if (eq gnus-post-method 'current)
923 ;; We query the user for a post method.
925 (and (listp gnus-post-method)
926 (listp (car gnus-post-method))))
928 ;; Collect all methods we know about.
930 (when (listp gnus-post-method)
931 (if (listp (car gnus-post-method))
933 (list gnus-post-method)))
934 gnus-secondary-select-methods
935 (mapcar 'cdr gnus-server-alist)
936 (mapcar 'car gnus-opened-servers)
937 (list gnus-select-method)
938 (list group-method)))
939 method-alist post-methods method)
940 ;; Weed out all mail methods.
942 (setq method (gnus-server-get-method "" (pop methods)))
943 (when (and (or (gnus-method-option-p method 'post)
944 (gnus-method-option-p method 'post-mail))
945 (not (member method post-methods)))
946 (push method post-methods)))
947 ;; Create a name-method alist.
951 (if (equal (cadr m) "")
952 (list (symbol-name (car m)) m)
953 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m)))
958 (setq gnus-last-posting-server
960 gnus-last-posting-server)
961 ;; Just use the last value.
962 gnus-last-posting-server
964 "Posting method: " method-alist nil t
965 (cons (or gnus-last-posting-server "") 0))))
967 ;; Override normal method.
968 ((and (eq gnus-post-method 'current)
969 (not (memq (car group-method) gnus-discouraged-post-methods))
970 (gnus-get-function group-method 'request-post t))
973 ;; Use gnus-post-method.
974 ((listp gnus-post-method) ;A method...
975 (assert (not (listp (car gnus-post-method)))) ;... not a list of methods.
977 ;; Use the normal select method (nil or native).
978 (t gnus-select-method))))
982 ;; Dummies to avoid byte-compile warning.
984 (defvar nnspool-rejected-article-hook)
985 (defvar xemacs-codename))
987 (defun gnus-extended-version ()
988 "Stringified Gnus version and Emacs version."
991 "Gnus/" (prin1-to-string (gnus-continuum-version gnus-version) t)
992 " (" gnus-version ")"
995 ((string-match "^\\(\\([.0-9]+\\)*\\)\\.[0-9]+$" emacs-version)
996 (concat "Emacs/" (match-string 1 emacs-version)
997 " (" system-configuration ")"))
998 ((string-match "\\([A-Z]*[Mm][Aa][Cc][Ss]\\)[^(]*\\(\\((beta.*)\\|'\\)\\)?"
1000 (concat (match-string 1 emacs-version)
1001 (format "/%d.%d" emacs-major-version emacs-minor-version)
1002 (if (match-beginning 3)
1003 (match-string 3 emacs-version)
1005 (if (boundp 'xemacs-codename)
1006 (concat " (" xemacs-codename ", " system-configuration ")")
1008 (t emacs-version))))
1012 ;;; Gnus Mail Functions
1015 ;;; Mail reply commands of Gnus summary mode
1017 (defun gnus-summary-reply (&optional yank wide very-wide)
1018 "Start composing a mail reply to the current message.
1019 If prefix argument YANK is non-nil, the original article is yanked
1021 If WIDE, make a wide reply.
1022 If VERY-WIDE, make a very wide reply."
1024 (list (and current-prefix-arg
1025 (gnus-summary-work-articles 1))))
1026 ;; Allow user to require confirmation before replying by mail to the
1027 ;; author of a news article.
1028 (when (or (not (gnus-news-group-p gnus-newsgroup-name))
1029 (not gnus-confirm-mail-reply-to-news)
1030 (y-or-n-p "Really reply by mail to article author? "))
1032 (if (listp (car yank))
1035 (gnus-article-reply (or article (gnus-summary-article-number)))
1037 ;; Stripping headers should be specified with mail-yank-ignored-headers.
1039 (gnus-summary-goto-subject article))
1040 (gnus-setup-message (if yank 'reply-yank 'reply)
1042 (gnus-summary-select-article)
1043 (dolist (article very-wide)
1044 (gnus-summary-select-article nil nil nil article)
1046 (set-buffer (gnus-copy-article-buffer))
1047 (gnus-msg-treat-broken-reply-to)
1049 (message-narrow-to-head)
1050 (setq headers (concat headers (buffer-string)))))))
1051 (set-buffer (gnus-copy-article-buffer))
1052 (gnus-msg-treat-broken-reply-to gnus-msg-force-broken-reply-to)
1054 (message-narrow-to-head)
1058 (goto-char (point-max)))
1059 (mml-quote-region (point) (point-max))
1060 (message-reply nil wide)
1062 (gnus-inews-yank-articles yank))
1063 (gnus-summary-handle-replysign)))))
1065 (defun gnus-summary-handle-replysign ()
1066 "Check the various replysign variables and take action accordingly."
1067 (when (or gnus-message-replysign gnus-message-replyencrypt)
1068 (let (signed encrypted)
1070 (set-buffer gnus-article-buffer)
1071 (setq signed (memq 'signed gnus-article-wash-types))
1072 (setq encrypted (memq 'encrypted gnus-article-wash-types)))
1073 (cond ((and gnus-message-replyencrypt encrypted)
1074 (mml-secure-message mml-default-encrypt-method
1075 (if gnus-message-replysignencrypted
1078 ((and gnus-message-replysign signed)
1079 (mml-secure-message mml-default-sign-method 'sign))))))
1081 (defun gnus-summary-reply-with-original (n &optional wide)
1082 "Start composing a reply mail to the current message.
1083 The original article will be yanked."
1085 (gnus-summary-reply (gnus-summary-work-articles n) wide))
1087 (defun gnus-summary-reply-broken-reply-to (&optional yank wide very-wide)
1088 "Like `gnus-summary-reply' except removing reply-to field.
1089 If prefix argument YANK is non-nil, the original article is yanked
1091 If WIDE, make a wide reply.
1092 If VERY-WIDE, make a very wide reply."
1094 (list (and current-prefix-arg
1095 (gnus-summary-work-articles 1))))
1096 (let ((gnus-msg-force-broken-reply-to t))
1097 (gnus-summary-reply yank wide very-wide)))
1099 (defun gnus-summary-reply-broken-reply-to-with-original (n &optional wide)
1100 "Like `gnus-summary-reply-with-original' except removing reply-to field.
1101 The original article will be yanked."
1103 (gnus-summary-reply-broken-reply-to (gnus-summary-work-articles n) wide))
1105 (defun gnus-summary-wide-reply (&optional yank)
1106 "Start composing a wide reply mail to the current message.
1107 If prefix argument YANK is non-nil, the original article is yanked
1110 (list (and current-prefix-arg
1111 (gnus-summary-work-articles 1))))
1112 (gnus-summary-reply yank t))
1114 (defun gnus-summary-wide-reply-with-original (n)
1115 "Start composing a wide reply mail to the current message.
1116 The original article will be yanked."
1118 (gnus-summary-reply-with-original n t))
1120 (defun gnus-summary-very-wide-reply (&optional yank)
1121 "Start composing a very wide reply mail to the current message.
1122 If prefix argument YANK is non-nil, the original article is yanked
1125 (list (and current-prefix-arg
1126 (gnus-summary-work-articles 1))))
1127 (gnus-summary-reply yank t (gnus-summary-work-articles yank)))
1129 (defun gnus-summary-very-wide-reply-with-original (n)
1130 "Start composing a very wide reply mail to the current message.
1131 The original article will be yanked."
1134 (gnus-summary-work-articles n) t (gnus-summary-work-articles n)))
1136 (defun gnus-summary-mail-forward (&optional arg post)
1137 "Forward the current message(s) to another user.
1138 If process marks exist, forward all marked messages;
1139 if ARG is nil, see `message-forward-as-mime' and `message-forward-show-mml';
1140 if ARG is 1, decode the message and forward directly inline;
1141 if ARG is 2, forward message as an rfc822 MIME section;
1142 if ARG is 3, decode message and forward as an rfc822 MIME section;
1143 if ARG is 4, forward message directly inline;
1144 otherwise, use flipped `message-forward-as-mime'.
1145 If POST, post instead of mail.
1146 For the `inline' alternatives, also see the variable
1147 `message-forward-ignored-headers'."
1149 (if (null (cdr (gnus-summary-work-articles nil)))
1150 (let ((message-forward-as-mime message-forward-as-mime)
1151 (message-forward-show-mml message-forward-show-mml))
1155 (setq message-forward-as-mime nil
1156 message-forward-show-mml t))
1158 (setq message-forward-as-mime t
1159 message-forward-show-mml nil))
1161 (setq message-forward-as-mime t
1162 message-forward-show-mml t))
1164 (setq message-forward-as-mime nil
1165 message-forward-show-mml nil))
1167 (setq message-forward-as-mime (not message-forward-as-mime))))
1168 (let ((gnus-article-reply (gnus-summary-article-number)))
1169 (gnus-setup-message 'forward
1170 (gnus-summary-select-article)
1171 (let ((mail-parse-charset
1172 (or (and (gnus-buffer-live-p gnus-article-buffer)
1173 (with-current-buffer gnus-article-buffer
1174 gnus-article-charset))
1175 gnus-newsgroup-charset))
1176 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
1177 (set-buffer gnus-original-article-buffer)
1178 (message-forward post)))))
1179 (gnus-uu-digest-mail-forward arg post)))
1181 (defun gnus-summary-resend-message (address n)
1182 "Resend the current article to ADDRESS."
1184 (list (message-read-from-minibuffer
1185 "Resend message(s) to: "
1186 (when (and gnus-summary-resend-default-address
1187 (gnus-buffer-live-p gnus-original-article-buffer))
1188 ;; If some other article is currently selected, the
1189 ;; initial-contents is wrong. Whatever, it is just the
1190 ;; initial-contents.
1191 (with-current-buffer gnus-original-article-buffer
1192 (nnmail-fetch-field "to"))))
1193 current-prefix-arg))
1194 (let ((articles (gnus-summary-work-articles n))
1196 (while (setq article (pop articles))
1197 (gnus-summary-select-article nil nil nil article)
1199 (set-buffer gnus-original-article-buffer)
1200 (message-resend address))
1201 (gnus-summary-mark-article-as-forwarded article))))
1203 ;; From: Matthieu Moy <Matthieu.Moy@imag.fr>
1204 (defun gnus-summary-resend-message-edit ()
1205 "Resend an article that has already been sent.
1206 A new buffer will be created to allow the user to modify body and
1207 contents of the message, and then, everything will happen as when
1208 composing a new message."
1210 (let ((article (gnus-summary-article-number)))
1211 (gnus-setup-message 'reply-yank
1212 (gnus-summary-select-article t)
1213 (set-buffer gnus-original-article-buffer)
1214 (let ((cur (current-buffer))
1215 (to (message-fetch-field "to")))
1216 ;; Get a normal message buffer.
1217 (message-pop-to-buffer (message-buffer-name "Resend" to))
1218 (insert-buffer-substring cur)
1220 (message-narrow-to-head-1)
1221 ;; Gnus will generate a new one when sending.
1222 (message-remove-header "Message-ID")
1223 (message-remove-header message-ignored-resent-headers t)
1224 ;; Remove unwanted headers.
1225 (goto-char (point-max))
1226 (insert mail-header-separator)
1227 (goto-char (point-min))
1228 (re-search-forward "^To:\\|^Newsgroups:" nil 'move)
1232 (defun gnus-summary-post-forward (&optional arg)
1233 "Forward the current article to a newsgroup.
1234 See `gnus-summary-mail-forward' for ARG."
1236 (gnus-summary-mail-forward arg t))
1238 (defvar gnus-nastygram-message
1239 "The following article was inappropriately posted to %s.\n\n"
1240 "Format string to insert in nastygrams.
1241 The current group name will be inserted at \"%s\".")
1243 (defun gnus-summary-mail-nastygram (n)
1244 "Send a nastygram to the author of the current article."
1246 (when (or gnus-expert-user
1248 "Really send a nastygram to the author of the current article? "))
1249 (let ((group gnus-newsgroup-name))
1250 (gnus-summary-reply-with-original n)
1251 (set-buffer gnus-message-buffer)
1253 (insert (format gnus-nastygram-message group))
1254 (message-send-and-exit))))
1256 (defun gnus-summary-mail-crosspost-complaint (n)
1257 "Send a complaint about crossposting to the current article(s)."
1259 (let ((articles (gnus-summary-work-articles n))
1261 (while (setq article (pop articles))
1262 (set-buffer gnus-summary-buffer)
1263 (gnus-summary-goto-subject article)
1264 (let ((group (gnus-group-real-name gnus-newsgroup-name))
1265 newsgroups followup-to)
1266 (gnus-summary-select-article)
1267 (set-buffer gnus-original-article-buffer)
1268 (if (and (<= (length (message-tokenize-header
1270 (mail-fetch-field "newsgroups"))
1273 (or (not (setq followup-to (mail-fetch-field "followup-to")))
1274 (not (member group (message-tokenize-header
1275 followup-to ", ")))))
1277 (gnus-message 1 "Followup-to restricted")
1278 (gnus-message 1 "Not a crossposted article"))
1279 (set-buffer gnus-summary-buffer)
1280 (gnus-summary-reply-with-original 1)
1281 (set-buffer gnus-message-buffer)
1283 (insert (format gnus-crosspost-complaint newsgroups group))
1284 (message-goto-subject)
1285 (re-search-forward " *$")
1286 (replace-match " (crosspost notification)" t t)
1287 (gnus-deactivate-mark)
1288 (when (gnus-y-or-n-p "Send this complaint? ")
1289 (message-send-and-exit)))))))
1291 (defun gnus-mail-parse-comma-list ()
1294 (skip-chars-forward " ")
1297 (skip-chars-forward "^,")
1302 (narrow-to-region beg (point))
1305 (while (search-forward "\"" nil t)
1309 (skip-chars-forward ",")
1310 (skip-chars-forward "^,"))
1311 (skip-chars-backward " ")
1312 (push (buffer-substring beg (point))
1314 (skip-chars-forward "^,")
1315 (skip-chars-forward ", "))
1318 (defun gnus-inews-add-to-address (group)
1319 (let ((to-address (mail-fetch-field "to")))
1320 (when (and to-address
1322 ;; This mail group doesn't have a `to-list', so we add one
1324 (when (gnus-y-or-n-p
1325 (format "Do you want to add this as `to-list': %s " to-address))
1326 (gnus-group-add-parameter group (cons 'to-list to-address))))))
1328 (defun gnus-put-message ()
1329 "Put the current message in some group and return to Gnus."
1331 (let ((reply gnus-article-reply)
1332 (winconf gnus-prev-winconf)
1333 (group gnus-newsgroup-name))
1335 (not (gnus-group-read-only-p group)))
1336 (setq group (read-string "Put in group: " nil (gnus-writable-groups))))
1338 (when (gnus-gethash group gnus-newsrc-hashtb)
1339 (error "No such group: %s" group))
1343 (message-narrow-to-headers)
1344 (let ((gnus-deletable-headers nil))
1345 (message-generate-headers
1346 (if (message-news-p)
1347 message-required-news-headers
1348 message-required-mail-headers)))
1349 (goto-char (point-max))
1350 (if (string-match " " group)
1351 (insert "Gcc: \"" group "\"\n")
1352 (insert "Gcc: " group "\n"))
1355 (when (and (get-buffer gnus-group-buffer)
1356 (gnus-buffer-exists-p (car-safe reply))
1358 (set-buffer (car reply))
1359 (gnus-summary-mark-article-as-replied (cdr reply)))
1361 (set-window-configuration winconf))))
1363 (defun gnus-article-mail (yank)
1364 "Send a reply to the address near point.
1365 If YANK is non-nil, include the original article."
1369 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
1370 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
1372 (gnus-msg-mail address)
1374 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
1376 (defvar nntp-server-type)
1378 "Send a bug report to the Gnus maintainers."
1380 (unless (gnus-alive-p)
1381 (error "Gnus has been shut down"))
1382 (gnus-setup-message (if (message-mail-user-agent) 'message 'bug)
1383 (unless (message-mail-user-agent)
1384 (delete-other-windows)
1385 (when gnus-bug-create-help-buffer
1386 (switch-to-buffer "*Gnus Help Bug*")
1388 (insert gnus-bug-message)
1389 (goto-char (point-min)))
1390 (message-pop-to-buffer "*Gnus Bug*"))
1391 (let ((message-this-is-mail t))
1392 (message-setup `((To . ,gnus-maintainer) (Subject . ""))))
1393 (when gnus-bug-create-help-buffer
1394 (push `(gnus-bug-kill-buffer) message-send-actions))
1395 (goto-char (point-min))
1396 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
1398 (insert (gnus-version) "\n"
1399 (emacs-version) "\n")
1400 (when (and (boundp 'nntp-server-type)
1401 (stringp nntp-server-type))
1402 (insert nntp-server-type))
1403 (insert "\n\n\n\n\n")
1406 (set-buffer (gnus-get-buffer-create " *gnus environment info*"))
1409 (setq text (buffer-string)))
1410 (insert "<#part type=application/emacs-lisp disposition=inline description=\"User settings\">\n" text "\n<#/part>"))
1411 (goto-char (point-min))
1412 (search-forward "Subject: " nil t)
1415 (defun gnus-bug-kill-buffer ()
1416 (when (get-buffer "*Gnus Help Bug*")
1417 (kill-buffer "*Gnus Help Bug*")))
1419 (defun gnus-summary-yank-message (buffer n)
1420 "Yank the current article into a composed message."
1422 (list (completing-read "Buffer: " (mapcar 'list (message-buffers)) nil t)
1423 current-prefix-arg))
1424 (gnus-summary-iterate n
1425 (let ((gnus-display-mime-function nil)
1426 (gnus-inhibit-treatment t))
1427 (gnus-summary-select-article))
1430 (message-yank-buffer gnus-article-buffer))))
1432 (defun gnus-debug ()
1433 "Attempts to go through the Gnus source file and report what variables have been changed.
1434 The source file has to be in the Emacs load path."
1436 (let ((files gnus-debug-files)
1438 file expr olist sym)
1439 (gnus-message 4 "Please wait while we snoop your variables...")
1441 ;; Go through all the files looking for non-default values for variables.
1443 (set-buffer (gnus-get-buffer-create " *gnus bug info*"))
1446 (when (and (setq file (locate-library (pop files)))
1447 (file-exists-p file))
1448 (insert-file-contents file)
1449 (goto-char (point-min))
1450 (if (not (re-search-forward "^;;* *Internal variables" nil t))
1451 (gnus-message 4 "Malformed sources in file %s" file)
1452 (narrow-to-region (point-min) (point))
1453 (goto-char (point-min))
1454 (while (setq expr (ignore-errors (read (current-buffer))))
1456 (and (or (eq (car expr) 'defvar)
1457 (eq (car expr) 'defcustom))
1458 (stringp (nth 3 expr))
1459 (not (memq (nth 1 expr) gnus-debug-exclude-variables))
1460 (or (not (boundp (nth 1 expr)))
1461 (not (equal (eval (nth 2 expr))
1462 (symbol-value (nth 1 expr)))))
1463 (push (nth 1 expr) olist)))))))
1464 (kill-buffer (current-buffer)))
1465 (when (setq olist (nreverse olist))
1466 (insert "------------------ Environment follows ------------------\n\n"))
1468 (if (boundp (car olist))
1470 (pp `(setq ,(car olist)
1471 ,(if (or (consp (setq sym (symbol-value (car olist))))
1473 (not (or (eq sym nil)
1475 (list 'quote (symbol-value (car olist)))
1476 (symbol-value (car olist))))
1479 (format "(setq %s 'whatever)\n" (car olist))))
1480 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
1481 (setq olist (cdr olist)))
1483 ;; Remove any control chars - they seem to cause trouble for some
1484 ;; mailers. (Byte-compiled output from the stuff above.)
1486 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
1487 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
1490 ;;; Treatment of rejected articles.
1493 (defun gnus-summary-resend-bounced-mail (&optional fetch)
1494 "Re-mail the current message.
1495 This only makes sense if the current message is a bounce message than
1496 contains some mail you have written which has been bounced back to
1498 If FETCH, try to fetch the article that this is a reply to, if indeed
1501 (gnus-summary-select-article t)
1502 (set-buffer gnus-original-article-buffer)
1503 (gnus-setup-message 'compose-bounce
1504 (let* ((references (mail-fetch-field "references"))
1505 (parent (and references (gnus-parent-id references))))
1507 ;; If there are references, we fetch the article we answered to.
1509 (gnus-summary-refer-article parent)
1510 (gnus-summary-show-all-headers)))))
1514 (defun gnus-inews-group-method (group)
1516 ;; If the group doesn't exist, we assume
1517 ;; it's an archive group...
1518 ((and (null (gnus-get-info group))
1519 (eq (car (gnus-server-to-method gnus-message-archive-method))
1520 (car (gnus-server-to-method (gnus-group-method group)))))
1521 gnus-message-archive-method)
1523 ((gnus-info-method (gnus-get-info group))
1524 (gnus-info-method (gnus-get-info group)))
1526 (t (gnus-server-to-method (gnus-group-method group)))))
1528 ;; Do Gcc handling, which copied the message over to some group.
1529 (defun gnus-inews-do-gcc (&optional gcc)
1533 (message-narrow-to-headers)
1534 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
1535 (cur (current-buffer))
1536 groups group method group-art
1537 mml-externalize-attachments)
1539 (message-remove-header "gcc")
1541 (setq groups (message-unquote-tokens
1542 (message-tokenize-header gcc " ,")))
1543 ;; Copy the article over to some group(s).
1544 (while (setq group (pop groups))
1545 (unless (gnus-check-server
1546 (setq method (gnus-inews-group-method group)))
1547 (error "Can't open server %s" (if (stringp method) method
1549 (unless (gnus-request-group group nil method)
1550 (gnus-request-create-group group method))
1551 (setq mml-externalize-attachments
1552 (if (stringp gnus-gcc-externalize-attachments)
1553 (string-match gnus-gcc-externalize-attachments group)
1554 gnus-gcc-externalize-attachments))
1556 (nnheader-set-temp-buffer " *acc*")
1557 (insert-buffer-substring cur)
1558 (message-encode-message-body)
1560 (message-narrow-to-headers)
1561 (let* ((mail-parse-charset message-default-charset)
1562 (newsgroups-field (save-restriction
1563 (message-narrow-to-headers-or-head)
1564 (message-fetch-field "Newsgroups")))
1565 (followup-field (save-restriction
1566 (message-narrow-to-headers-or-head)
1567 (message-fetch-field "Followup-To")))
1568 ;; BUG: We really need to get the charset for
1569 ;; each name in the Newsgroups and Followup-To
1570 ;; lines to allow crossposting between group
1571 ;; namess with incompatible character sets.
1572 ;; -- Per Abrahamsen <abraham@dina.kvl.dk> 2001-10-08.
1573 (group-field-charset
1574 (gnus-group-name-charset
1575 method (or newsgroups-field "")))
1576 (followup-field-charset
1577 (gnus-group-name-charset
1578 method (or followup-field "")))
1579 (rfc2047-header-encoding-alist
1581 (when group-field-charset
1582 (list (cons "Newsgroups" group-field-charset)))
1583 (when followup-field-charset
1584 (list (cons "Followup-To" followup-field-charset)))
1585 rfc2047-header-encoding-alist)))
1586 (mail-encode-encoded-word-buffer)))
1587 (goto-char (point-min))
1588 (when (re-search-forward
1589 (concat "^" (regexp-quote mail-header-separator) "$")
1591 (replace-match "" t t ))
1592 (unless (setq group-art
1593 (gnus-request-accept-article group method t t))
1594 (gnus-message 1 "Couldn't store article in group %s: %s"
1595 group (gnus-status-message method))
1597 (when (and group-art
1598 (or gnus-gcc-mark-as-read
1599 gnus-inews-mark-gcc-as-read))
1600 (gnus-group-mark-article-read group (cdr group-art)))
1601 (kill-buffer (current-buffer)))))))))
1603 (defun gnus-inews-insert-gcc ()
1604 "Insert Gcc headers based on `gnus-outgoing-message-group'."
1607 (message-narrow-to-headers)
1608 (let* ((group gnus-outgoing-message-group)
1610 ((gnus-functionp group)
1612 ((or (stringp group) (list group))
1617 (if (string-match " " gcc)
1618 (concat "\"" gcc "\"")
1620 (mapconcat (lambda (group)
1621 (if (string-match " " group)
1622 (concat "\"" group "\"")
1627 (defun gnus-inews-insert-archive-gcc (&optional group)
1628 "Insert the Gcc to say where the article is to be archived."
1629 (let* ((var gnus-message-archive-group)
1630 (group (or group gnus-newsgroup-name ""))
1632 (and gnus-newsgroup-name
1633 (not (equal gnus-newsgroup-name ""))
1634 (gnus-group-find-parameter
1635 gnus-newsgroup-name 'gcc-self)))
1639 ((null gnus-message-archive-method)
1643 ;; Just a single group.
1646 ;; We don't want this.
1648 ((and (listp var) (stringp (car var)))
1649 ;; A list of groups.
1651 ((gnus-functionp var)
1653 (funcall var group))
1655 ;; An alist of regexps/functions/forms.
1660 ((stringp (caar var))
1662 (when (string-match (caar var) group)
1664 ((gnus-functionp (car var))
1666 (funcall (car var) group))
1668 (eval (car var)))))))
1669 (setq var (cdr var)))
1672 (when (or groups gcc-self-val)
1673 (when (stringp groups)
1674 (setq groups (list groups)))
1677 (message-narrow-to-headers)
1678 (goto-char (point-max))
1681 ;; Use the `gcc-self' param value instead.
1684 (if (stringp gcc-self-val)
1685 (if (string-match " " gcc-self-val)
1686 (concat "\"" gcc-self-val "\"")
1688 (if (string-match " " group)
1689 (concat "\"" group "\"")
1691 (if (not (eq gcc-self-val 'none))
1696 ;; Use the list of groups.
1697 (while (setq name (pop groups))
1698 (let ((str (if (string-match ":" name)
1700 (gnus-group-prefixed-name
1701 name gnus-message-archive-method))))
1702 (insert (if (string-match " " str)
1703 (concat "\"" str "\"")
1711 (defun gnus-configure-posting-styles (&optional group-name)
1712 "Configure posting styles according to `gnus-posting-styles'."
1713 (unless gnus-inhibit-posting-styles
1714 (let ((group (or group-name gnus-newsgroup-name ""))
1715 (styles gnus-posting-styles)
1716 style match variable attribute value v results
1717 filep name address element)
1718 ;; If the group has a posting-style parameter, add it at the end with a
1719 ;; regexp matching everything, to be sure it takes precedence over all
1721 (when gnus-newsgroup-name
1722 (let ((tmp-style (gnus-group-find-parameter group 'posting-style t)))
1724 (setq styles (append styles (list (cons ".*" tmp-style)))))))
1725 ;; Go through all styles and look for matches.
1726 (dolist (style styles)
1727 (setq match (pop style))
1728 (goto-char (point-min))
1731 ;; Regexp string match on the group name.
1732 (string-match match group))
1734 ;; Obsolete format of header match.
1735 (and (gnus-buffer-live-p gnus-article-copy)
1736 (with-current-buffer gnus-article-copy
1737 (let ((header (message-fetch-field (pop style))))
1739 (string-match (pop style) header))))))
1740 ((or (symbolp match)
1741 (gnus-functionp match))
1743 ((gnus-functionp match)
1744 ;; Function to be called.
1747 ;; Variable to be checked.
1748 (symbol-value match))))
1751 ((eq (car match) 'header)
1752 ;; New format of header match.
1753 (and (gnus-buffer-live-p gnus-article-copy)
1754 (with-current-buffer gnus-article-copy
1755 (let ((header (message-fetch-field (nth 1 match))))
1757 (string-match (nth 2 match) header))))))
1759 ;; This is a form to be evaled.
1761 ;; We have a match, so we set the variables.
1762 (dolist (attribute style)
1763 (setq element (pop attribute)
1768 ((eq (car attribute) :file)
1771 ((eq (car attribute) :value)
1775 ;; We get the value.
1780 ((or (symbolp value)
1781 (gnus-functionp value))
1782 (cond ((gnus-functionp value)
1785 (symbol-value value))))
1788 ;; Translate obsolescent value.
1790 ((eq element 'signature-file)
1791 (setq element 'signature
1793 ((eq element 'x-face-file)
1794 (setq element 'x-face
1796 ;; Get the contents of file elems.
1798 (setq v (with-temp-buffer
1799 (insert-file-contents v)
1800 (goto-char (point-max))
1804 (setq results (delq (assoc element results) results))
1805 (push (cons element v) results))))
1806 ;; Now we have all the styles, so we insert them.
1807 (setq name (assq 'name results)
1808 address (assq 'address results))
1809 (setq results (delq name (delq address results)))
1810 ;; make-local-hook is not obsolete in Emacs 20 or XEmacs.
1811 (make-local-hook 'message-setup-hook)
1812 (setq results (sort results (lambda (x y)
1813 (string-lessp (car x) (car y)))))
1814 (dolist (result results)
1815 (add-hook 'message-setup-hook
1817 ((eq 'eval (car result))
1819 ((eq 'body (car result))
1823 (insert ,(cdr result)))))
1824 ((eq 'signature (car result))
1825 (set (make-local-variable 'message-signature) nil)
1826 (set (make-local-variable 'message-signature-file) nil)
1827 (if (not (cdr result))
1831 (let ((message-signature ,(cdr result)))
1832 (when message-signature
1833 (message-insert-signature)))))))
1836 (if (symbolp (car result))
1837 (capitalize (symbol-name (car result)))
1841 (message-remove-header ,header)
1842 (let ((value ,(cdr result)))
1845 (insert ,header ": " value "\n"))))))))
1847 (when (or name address)
1848 (add-hook 'message-setup-hook
1850 (set (make-local-variable 'user-mail-address)
1851 ,(or (cdr address) user-mail-address))
1852 (let ((user-full-name ,(or (cdr name) (user-full-name)))
1854 ,(or (cdr address) user-mail-address)))
1856 (message-remove-header "From")
1858 (insert "From: " (message-make-from) "\n"))))
1861 ;;; Allow redefinition of functions.
1867 ;;; gnus-msg.el ends here