1 ;;; gnus-msg.el --- mail and post interface for Semi-gnus
2 ;; Copyright (C) 1995,96,97,98 Free Software Foundation, Inc.
4 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
5 ;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Keywords: mail, news, MIME
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 ;; Added by Sudish Joseph <joseph@cis.ohio-state.edu>.
38 (defvar gnus-post-method nil
39 "*Preferred method for posting USENET news.
40 If this variable is nil, Gnus will use the current method to decide
41 which method to use when posting. If it is non-nil, it will override
42 the current method. This method will not be used in mail groups and
43 the like, only in \"real\" newsgroups.
45 The value must be a valid method as discussed in the documentation of
46 `gnus-select-method'. It can also be a list of methods. If that is
47 the case, the user will be queried for what select method to use when
50 (defvar gnus-outgoing-message-group nil
51 "*All outgoing messages will be put in this group.
52 If you want to store all your outgoing mail and articles in the group
53 \"nnml:archive\", you set this variable to that value. This variable
54 can also be a list of group names.
56 If you want to have greater control over what group to put each
57 message in, you can set this variable to a function that checks the
58 current newsgroup name and then returns a suitable group name (or list
61 (defvar gnus-mailing-list-groups nil
62 "*Regexp matching groups that are really mailing lists.
63 This is useful when you're reading a mailing list that has been
64 gatewayed to a newsgroup, and you want to followup to an article in
67 (defvar gnus-add-to-list nil
68 "*If non-nil, add a `to-list' parameter automatically.")
70 (defvar gnus-crosspost-complaint
73 You posted the article below with the following Newsgroups header:
77 The %s group, at least, was an inappropriate recipient
78 of this message. Please trim your Newsgroups header to exclude this
79 group before posting in the future.
84 "Format string to be inserted when complaining about crossposts.
85 The first %s will be replaced by the Newsgroups header;
86 the second with the current group name.")
88 (defvar gnus-message-setup-hook nil
89 "Hook run after setting up a message buffer.")
91 ;;; Internal variables.
93 (defvar gnus-message-buffer "*Mail Gnus*")
94 (defvar gnus-article-copy nil)
95 (defvar gnus-last-posting-server nil)
96 (defvar gnus-message-group-art nil)
98 (defconst gnus-bug-message
99 "Sending a bug report to the Gnus Towers.
100 ========================================
102 The buffer below is a mail buffer. When you press `C-c C-c', it will
103 be sent to the Gnus Bug Exterminators.
105 At the bottom of the buffer you'll see lots of variable settings.
106 Please do not delete those. They will tell the Bug People what your
107 environment is, so that it will be easier to locate the bugs.
109 If you have found a bug that makes Emacs go \"beep\", set
110 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
111 and include the backtrace in your bug report.
113 Please describe the bug in annoying, painstaking detail.
115 Thank you for your help in stamping out bugs.
119 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
120 (autoload 'news-setup "rnewspost")
121 (autoload 'news-reply-mode "rnewspost")
122 (autoload 'rmail-dont-reply-to "mail-utils")
123 (autoload 'rmail-output "rmailout"))
127 ;;; Gnus Posting Functions
130 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
131 "p" gnus-summary-post-news
132 "f" gnus-summary-followup
133 "F" gnus-summary-followup-with-original
134 "c" gnus-summary-cancel-article
135 "s" gnus-summary-supersede-article
136 "r" gnus-summary-reply
137 "R" gnus-summary-reply-with-original
138 "w" gnus-summary-wide-reply
139 "W" gnus-summary-wide-reply-with-original
140 "n" gnus-summary-followup-to-mail
141 "N" gnus-summary-followup-to-mail-with-original
142 "m" gnus-summary-mail-other-window
143 "u" gnus-uu-post-news
144 "\M-c" gnus-summary-mail-crosspost-complaint
145 "om" gnus-summary-mail-forward
146 "op" gnus-summary-post-forward
147 "Om" gnus-uu-digest-mail-forward
148 "Op" gnus-uu-digest-post-forward)
150 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
151 "b" gnus-summary-resend-bounced-mail
152 ;; "c" gnus-summary-send-draft
153 "r" gnus-summary-resend-message)
155 ;;; Internal functions.
157 (defvar gnus-article-reply nil)
158 (defmacro gnus-setup-message (config &rest forms)
159 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
160 (buffer (make-symbol "gnus-setup-message-buffer"))
161 (article (make-symbol "gnus-setup-message-article"))
162 (group (make-symbol "gnus-setup-message-group")))
163 `(let ((,winconf (current-window-configuration))
164 (,buffer (buffer-name (current-buffer)))
165 (,article (and gnus-article-reply (gnus-summary-article-number)))
166 (,group gnus-newsgroup-name)
167 (message-header-setup-hook
168 (copy-sequence message-header-setup-hook)))
169 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
170 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
174 (gnus-inews-add-send-actions ,winconf ,buffer ,article)
175 (setq gnus-message-buffer (current-buffer))
176 (set (make-local-variable 'gnus-message-group-art)
177 (cons ,group ,article))
178 (make-local-variable 'gnus-newsgroup-name)
179 (gnus-run-hooks 'gnus-message-setup-hook))
180 (gnus-configure-windows ,config t)
181 (set-buffer-modified-p nil))))
183 (defun gnus-inews-add-send-actions (winconf buffer article)
184 (make-local-hook 'message-sent-hook)
185 (add-hook 'message-sent-hook 'gnus-inews-do-gcc nil t)
186 (setq message-post-method
188 (gnus-post-method arg ,gnus-newsgroup-name)))
189 (setq message-newsreader (setq message-mailer (gnus-extended-version)))
191 `(set-window-configuration ,winconf) 'exit 'postpone 'kill)
193 `(when (buffer-name (get-buffer ,buffer))
195 (set-buffer (get-buffer ,buffer))
197 `(gnus-summary-mark-article-as-replied ,article))))
200 (put 'gnus-setup-message 'lisp-indent-function 1)
201 (put 'gnus-setup-message 'edebug-form-spec '(form body))
203 ;;; Post news commands of Gnus group mode and summary mode
205 (defun gnus-group-mail ()
206 "Start composing a mail."
208 (gnus-setup-message 'message
211 (defun gnus-group-post-news (&optional arg)
212 "Start composing a news message.
213 If ARG, post to the group under point.
214 If ARG is 1, prompt for a group name."
216 ;; Bind this variable here to make message mode hooks work ok.
217 (let ((gnus-newsgroup-name
219 (if (= 1 (prefix-numeric-value arg))
220 (completing-read "Newsgroup: " gnus-active-hashtb nil
221 (gnus-read-active-file-p))
222 (gnus-group-group-name))
224 (gnus-post-news 'post gnus-newsgroup-name)))
226 (defun gnus-summary-post-news ()
227 "Start composing a news message."
229 (gnus-post-news 'post gnus-newsgroup-name))
231 (defun gnus-summary-followup (yank &optional force-news)
232 "Compose a followup to an article.
233 If prefix argument YANK is non-nil, original article is yanked automatically."
235 (list (and current-prefix-arg
236 (gnus-summary-work-articles 1))))
238 (gnus-summary-goto-subject (car yank)))
239 (save-window-excursion
240 (gnus-summary-select-article))
241 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
242 (gnus-newsgroup-name gnus-newsgroup-name))
244 (gnus-post-news nil gnus-newsgroup-name
245 headers gnus-article-buffer
246 yank nil force-news)))
248 (defun gnus-summary-followup-with-original (n &optional force-news)
249 "Compose a followup to an article and include the original article."
251 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
253 (defun gnus-summary-followup-to-mail (&optional arg)
254 "Followup to the current mail message via news."
256 (list (and current-prefix-arg
257 (gnus-summary-work-articles 1))))
258 (gnus-summary-followup arg t))
260 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
261 "Followup to the current mail message via news."
263 (gnus-summary-followup (gnus-summary-work-articles arg) t))
265 (defun gnus-inews-yank-articles (articles)
268 (while (setq article (pop articles))
269 (save-window-excursion
270 (set-buffer gnus-summary-buffer)
271 (gnus-summary-select-article nil nil nil article)
272 (gnus-summary-remove-process-mark article))
273 (gnus-copy-article-buffer)
274 (let ((message-reply-buffer gnus-article-copy)
275 (message-reply-headers gnus-current-headers))
276 (message-yank-original)
277 (setq beg (or beg (mark t))))
283 (defun gnus-summary-cancel-article (&optional n symp)
284 "Cancel an article you posted.
285 Uses the process-prefix convention. If given the symbolic
286 prefix `a', cancel using the standard posting method; if not
287 post using the current select method."
288 (interactive (gnus-interactive "P\ny"))
289 (let ((articles (gnus-summary-work-articles n))
292 (gnus-post-method (not (eq symp 'a)) ,gnus-newsgroup-name)))
294 (while (setq article (pop articles))
295 (when (gnus-summary-select-article t nil nil article)
296 (when (gnus-eval-in-buffer-window gnus-article-buffer
298 (set-buffer gnus-original-article-buffer)
299 (message-cancel-news)))
300 (gnus-summary-mark-as-read article gnus-canceled-mark)
301 (gnus-cache-remove-article 1))
302 (gnus-article-hide-headers-if-wanted))
303 (gnus-summary-remove-process-mark article))))
305 (defun gnus-summary-supersede-article ()
306 "Compose an article that will supersede a previous article.
307 This is done simply by taking the old article and adding a Supersedes
308 header line with the old Message-ID."
310 (let ((article (gnus-summary-article-number)))
311 (gnus-setup-message 'reply-yank
312 (gnus-summary-select-article t)
313 (set-buffer gnus-original-article-buffer)
317 (when (buffer-name (get-buffer ,gnus-summary-buffer))
319 (set-buffer (get-buffer ,gnus-summary-buffer))
320 (gnus-cache-possibly-remove-article ,article nil nil nil t)
321 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
322 message-send-actions))))
326 (defun gnus-copy-article-buffer (&optional article-buffer)
327 ;; make a copy of the article buffer with all text properties removed
328 ;; this copy is in the buffer gnus-article-copy.
329 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
330 ;; this buffer should be passed to all mail/news reply/post routines.
331 (setq gnus-article-copy (get-buffer-create " *gnus article copy*"))
332 (buffer-disable-undo gnus-article-copy)
333 (or (memq gnus-article-copy gnus-buffer-list)
334 (push gnus-article-copy gnus-buffer-list))
335 (let ((article-buffer (or article-buffer gnus-article-buffer))
337 (if (not (and (get-buffer article-buffer)
338 (buffer-name (get-buffer article-buffer))))
339 (error "Can't find any article buffer")
341 (set-buffer article-buffer)
343 ;; Copy over the (displayed) article buffer, delete
344 ;; hidden text and remove text properties.
346 (copy-to-buffer gnus-article-copy (point-min) (point-max))
347 (set-buffer gnus-article-copy)
348 (gnus-article-delete-text-of-type 'annotation)
349 (gnus-remove-text-with-property 'gnus-prev)
350 (gnus-remove-text-with-property 'gnus-next)
353 (format "%s" (buffer-string))
355 ;; Find the original headers.
356 (set-buffer gnus-original-article-buffer)
357 (goto-char (point-min))
358 (while (looking-at message-unix-mail-delimiter)
361 (setq end (or (search-forward "\n\n" nil t) (point)))
362 ;; Delete the headers from the displayed articles.
363 (set-buffer gnus-article-copy)
364 (delete-region (goto-char (point-min))
365 (or (search-forward "\n\n" nil t) (point)))
366 ;; Insert the original article headers.
367 (insert-buffer-substring gnus-original-article-buffer beg end)
368 (gnus-article-decode-rfc1522)))
371 (defun gnus-post-news (post &optional group header article-buffer yank subject
374 (gnus-copy-article-buffer))
375 (let ((gnus-article-reply article-buffer)
376 (add-to-list gnus-add-to-list))
377 (gnus-setup-message (cond (yank 'reply-yank)
378 (article-buffer 'reply)
380 (let* ((group (or group gnus-newsgroup-name))
382 to-address to-group mailing-list to-list
385 (setq to-address (gnus-group-find-parameter group 'to-address)
386 to-group (gnus-group-find-parameter group 'to-group)
387 to-list (gnus-group-find-parameter group 'to-list)
388 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
389 mailing-list (when gnus-mailing-list-groups
390 (string-match gnus-mailing-list-groups group))
391 group (gnus-group-real-name group)))
392 (if (or (and to-group
393 (gnus-news-group-p to-group))
396 (and (gnus-news-group-p
397 (or pgroup gnus-newsgroup-name)
398 (if header (mail-header-number header)
399 gnus-current-article))
405 (message-news (or to-group group))
406 (set-buffer gnus-article-copy)
407 (message-followup (if (or newsgroup-p force-news) nil to-group)))
411 (message-mail (or to-address to-list))
412 ;; Arrange for mail groups that have no `to-address' to
413 ;; get that when the user sends off the mail.
414 (when (and (not to-list)
417 (push (list 'gnus-inews-add-to-address pgroup)
418 message-send-actions)))
419 (set-buffer gnus-article-copy)
420 (message-wide-reply to-address
421 (gnus-group-find-parameter
422 gnus-newsgroup-name 'broken-reply-to))))
424 (gnus-inews-yank-articles yank))))))
426 (defun gnus-post-method (arg group &optional silent)
427 "Return the posting method based on GROUP and ARG.
428 If SILENT, don't prompt the user."
429 (let ((group-method (gnus-find-method-for-group group)))
431 ;; If the group-method is nil (which shouldn't happen) we use
432 ;; the default method.
434 (or gnus-post-method gnus-select-method message-post-method))
435 ;; We want this group's method.
436 ((and arg (not (eq arg 0)))
438 ;; We query the user for a post method.
440 (and gnus-post-method
441 (listp (car gnus-post-method))))
443 ;; Collect all methods we know about.
445 (when gnus-post-method
446 (if (listp (car gnus-post-method))
448 (list gnus-post-method)))
449 gnus-secondary-select-methods
450 (list gnus-select-method)
451 (list group-method)))
452 method-alist post-methods method)
453 ;; Weed out all mail methods.
455 (setq method (gnus-server-get-method "" (pop methods)))
456 (when (or (gnus-method-option-p method 'post)
457 (gnus-method-option-p method 'post-mail))
458 (push method post-methods)))
459 ;; Create a name-method alist.
463 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m))
468 (setq gnus-last-posting-server
470 gnus-last-posting-server)
471 ;; Just use the last value.
472 gnus-last-posting-server
474 "Posting method: " method-alist nil t
475 (cons (or gnus-last-posting-server "") 0))))
477 ;; Override normal method.
480 ;; Use the normal select method.
481 (t gnus-select-method))))
485 ;; Dummy to avoid byte-compile warning.
486 (defvar nnspool-rejected-article-hook)
487 (defvar xemacs-codename)
489 ;;; Since the X-Newsreader/X-Mailer are ``vanity'' headers, they might
490 ;;; as well include the Emacs version as well.
491 ;;; The following function works with later GNU Emacs, and XEmacs.
492 (defun gnus-extended-version ()
493 "Stringified Gnus version"
499 ;;; Gnus Mail Functions
502 ;;; Mail reply commands of Gnus summary mode
504 (defun gnus-summary-reply (&optional yank wide)
505 "Start composing a reply mail to the current message.
506 If prefix argument YANK is non-nil, the original article is yanked
509 (list (and current-prefix-arg
510 (gnus-summary-work-articles 1))))
511 ;; Stripping headers should be specified with mail-yank-ignored-headers.
513 (gnus-summary-goto-subject (car yank)))
514 (let ((gnus-article-reply t))
515 (gnus-setup-message (if yank 'reply-yank 'reply)
516 (gnus-summary-select-article)
517 (set-buffer (gnus-copy-article-buffer))
518 (message-reply nil wide (gnus-group-find-parameter
519 gnus-newsgroup-name 'broken-reply-to))
521 (gnus-inews-yank-articles yank)))))
523 (defun gnus-summary-reply-with-original (n &optional wide)
524 "Start composing a reply mail to the current message.
525 The original article will be yanked."
527 (gnus-summary-reply (gnus-summary-work-articles n) wide))
529 (defun gnus-summary-wide-reply (&optional yank)
530 "Start composing a wide reply mail to the current message.
531 If prefix argument YANK is non-nil, the original article is yanked
534 (list (and current-prefix-arg
535 (gnus-summary-work-articles 1))))
536 (gnus-summary-reply yank t))
538 (defun gnus-summary-wide-reply-with-original (n)
539 "Start composing a wide reply mail to the current message.
540 The original article will be yanked."
542 (gnus-summary-reply-with-original n t))
544 (defun gnus-summary-mail-forward (&optional full-headers post)
545 "Forward the current message to another user.
546 If FULL-HEADERS (the prefix), include full headers when forwarding."
548 (gnus-setup-message 'forward
549 (gnus-summary-select-article)
550 (set-buffer gnus-original-article-buffer)
551 (let ((message-included-forward-headers
552 (if full-headers "" message-included-forward-headers)))
553 (message-forward post))))
555 (defun gnus-summary-resend-message (address n)
556 "Resend the current article to ADDRESS."
557 (interactive "sResend message(s) to: \nP")
558 (let ((articles (gnus-summary-work-articles n))
560 (while (setq article (pop articles))
561 (gnus-summary-select-article nil nil nil article)
563 (set-buffer gnus-original-article-buffer)
564 (message-resend address)))))
566 (defun gnus-summary-post-forward (&optional full-headers)
567 "Forward the current article to a newsgroup.
568 If FULL-HEADERS (the prefix), include full headers when forwarding."
570 (gnus-summary-mail-forward full-headers t))
572 (defvar gnus-nastygram-message
573 "The following article was inappropriately posted to %s.\n\n"
574 "Format string to insert in nastygrams.
575 The current group name will be inserted at \"%s\".")
577 (defun gnus-summary-mail-nastygram (n)
578 "Send a nastygram to the author of the current article."
580 (when (or gnus-expert-user
582 "Really send a nastygram to the author of the current article? "))
583 (let ((group gnus-newsgroup-name))
584 (gnus-summary-reply-with-original n)
585 (set-buffer gnus-message-buffer)
587 (insert (format gnus-nastygram-message group))
588 (message-send-and-exit))))
590 (defun gnus-summary-mail-crosspost-complaint (n)
591 "Send a complaint about crossposting to the current article(s)."
593 (let ((articles (gnus-summary-work-articles n))
595 (while (setq article (pop articles))
596 (set-buffer gnus-summary-buffer)
597 (gnus-summary-goto-subject article)
598 (let ((group (gnus-group-real-name gnus-newsgroup-name))
599 newsgroups followup-to)
600 (gnus-summary-select-article)
601 (set-buffer gnus-original-article-buffer)
602 (if (and (<= (length (message-tokenize-header
603 (setq newsgroups (mail-fetch-field "newsgroups"))
606 (or (not (setq followup-to (mail-fetch-field "followup-to")))
607 (not (member group (message-tokenize-header
608 followup-to ", ")))))
610 (gnus-message 1 "Followup-to restricted")
611 (gnus-message 1 "Not a crossposted article"))
612 (set-buffer gnus-summary-buffer)
613 (gnus-summary-reply-with-original 1)
614 (set-buffer gnus-message-buffer)
616 (insert (format gnus-crosspost-complaint newsgroups group))
617 (message-goto-subject)
618 (re-search-forward " *$")
619 (replace-match " (crosspost notification)" t t)
620 (gnus-deactivate-mark)
621 (when (gnus-y-or-n-p "Send this complaint? ")
622 (message-send-and-exit)))))))
624 (defun gnus-summary-mail-other-window ()
625 "Compose mail in other window."
627 (gnus-setup-message 'message
630 (defun gnus-mail-parse-comma-list ()
633 (skip-chars-forward " ")
636 (skip-chars-forward "^,")
641 (narrow-to-region beg (point))
644 (while (search-forward "\"" nil t)
648 (skip-chars-forward ",")
649 (skip-chars-forward "^,"))
650 (skip-chars-backward " ")
651 (push (buffer-substring beg (point))
653 (skip-chars-forward "^,")
654 (skip-chars-forward ", "))
657 (defun gnus-inews-add-to-address (group)
658 (let ((to-address (mail-fetch-field "to")))
659 (when (and to-address
661 ;; This mail group doesn't have a `to-list', so we add one
664 (format "Do you want to add this as `to-list': %s " to-address))
665 (gnus-group-add-parameter group (cons 'to-list to-address))))))
667 (defun gnus-put-message ()
668 "Put the current message in some group and return to Gnus."
670 (let ((reply gnus-article-reply)
671 (winconf gnus-prev-winconf)
672 (group gnus-newsgroup-name))
674 (or (and group (not (gnus-group-read-only-p group)))
675 (setq group (read-string "Put in group: " nil
676 (gnus-writable-groups))))
677 (when (gnus-gethash group gnus-newsrc-hashtb)
678 (error "No such group: %s" group))
683 (message-narrow-to-headers)
684 (let (gnus-deletable-headers)
686 (message-generate-headers message-required-news-headers)
687 (message-generate-headers message-required-mail-headers)))
688 (goto-char (point-max))
689 (insert "Gcc: " group "\n")
694 (when (get-buffer gnus-group-buffer)
695 (when (gnus-buffer-exists-p (car-safe reply))
696 (set-buffer (car reply))
698 (gnus-summary-mark-article-as-replied
701 (set-window-configuration winconf)))))
703 (defun gnus-article-mail (yank)
704 "Send a reply to the address near point.
705 If YANK is non-nil, include the original article."
709 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
710 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
712 (message-reply address)
714 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
716 (defvar nntp-server-type)
718 "Send a bug report to the Gnus maintainers."
720 (unless (gnus-alive-p)
721 (error "Gnus has been shut down"))
722 (gnus-setup-message 'bug
723 (delete-other-windows)
724 (switch-to-buffer (get-buffer-create "*Gnus Help Bug*"))
726 (insert gnus-bug-message)
727 (goto-char (point-min))
728 (message-pop-to-buffer "*Gnus Bug*")
729 (message-setup `((To . ,gnus-maintainer) (Subject . "")))
730 (push `(gnus-bug-kill-buffer) message-send-actions)
731 (goto-char (point-min))
732 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
734 (insert (gnus-version) "\n")
735 (insert (emacs-version) "\n")
736 (when (and (boundp 'nntp-server-type)
737 (stringp nntp-server-type))
738 (insert nntp-server-type))
739 (insert "\n\n\n\n\n")
741 (goto-char (point-min))
742 (search-forward "Subject: " nil t)
745 (defun gnus-bug-kill-buffer ()
746 (when (get-buffer "*Gnus Help Bug*")
747 (kill-buffer "*Gnus Help Bug*")))
750 "Attempts to go through the Gnus source file and report what variables have been changed.
751 The source file has to be in the Emacs load path."
753 (let ((files '("gnus.el" "gnus-sum.el" "gnus-group.el"
754 "gnus-art.el" "gnus-start.el" "gnus-async.el"
755 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
756 "nnmail.el" "message.el"))
759 (gnus-message 4 "Please wait while we snoop your variables...")
761 ;; Go through all the files looking for non-default values for variables.
763 (set-buffer (get-buffer-create " *gnus bug info*"))
764 (buffer-disable-undo (current-buffer))
767 (when (and (setq file (locate-library (pop files)))
768 (file-exists-p file))
769 (insert-file-contents file)
770 (goto-char (point-min))
771 (if (not (re-search-forward "^;;* *Internal variables" nil t))
772 (gnus-message 4 "Malformed sources in file %s" file)
773 (narrow-to-region (point-min) (point))
774 (goto-char (point-min))
775 (while (setq expr (ignore-errors (read (current-buffer))))
777 (and (or (eq (car expr) 'defvar)
778 (eq (car expr) 'defcustom))
779 (stringp (nth 3 expr))
780 (or (not (boundp (nth 1 expr)))
781 (not (equal (eval (nth 2 expr))
782 (symbol-value (nth 1 expr)))))
783 (push (nth 1 expr) olist)))))))
784 (kill-buffer (current-buffer)))
785 (when (setq olist (nreverse olist))
786 (insert "------------------ Environment follows ------------------\n\n"))
788 (if (boundp (car olist))
790 (pp `(setq ,(car olist)
791 ,(if (or (consp (setq sym (symbol-value (car olist))))
793 (not (or (eq sym nil)
795 (list 'quote (symbol-value (car olist)))
796 (symbol-value (car olist))))
799 (format "(setq %s 'whatever)\n" (car olist))))
800 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
801 (setq olist (cdr olist)))
803 ;; Remove any control chars - they seem to cause trouble for some
804 ;; mailers. (Byte-compiled output from the stuff above.)
806 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
807 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
810 ;;; Treatment of rejected articles.
813 (defun gnus-summary-resend-bounced-mail (&optional fetch)
814 "Re-mail the current message.
815 This only makes sense if the current message is a bounce message than
816 contains some mail you have written which has been bounced back to
818 If FETCH, try to fetch the article that this is a reply to, if indeed
821 (gnus-summary-select-article t)
822 (set-buffer gnus-original-article-buffer)
823 (gnus-setup-message 'compose-bounce
824 (let* ((references (mail-fetch-field "references"))
825 (parent (and references (gnus-parent-id references))))
827 ;; If there are references, we fetch the article we answered to.
829 (gnus-summary-refer-article parent)
830 (gnus-summary-show-all-headers)))))
834 ;; Do Gcc handling, which copied the message over to some group.
835 (defun gnus-inews-do-gcc (&optional gcc)
840 (message-narrow-to-headers)
841 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
842 (coding-system-for-write 'raw-text)
845 (message-remove-header "gcc")
847 (setq groups (message-tokenize-header gcc " ,"))
848 ;; Copy the article over to some group(s).
849 (while (setq group (pop groups))
852 (cond ((and (null (gnus-get-info group))
853 (eq (car gnus-message-archive-method)
855 (gnus-server-to-method
856 (gnus-group-method group)))))
857 ;; If the group doesn't exist, we assume
858 ;; it's an archive group...
859 gnus-message-archive-method)
861 ((gnus-info-method (gnus-get-info group))
862 (gnus-info-method (gnus-get-info group)))
864 (t (gnus-group-method group)))))
865 (gnus-check-server method)
866 (unless (gnus-request-group group t method)
867 (gnus-request-create-group group method))
869 (nnheader-set-temp-buffer " *acc*")
870 (insert-buffer-substring message-encoding-buffer)
871 (gnus-run-hooks 'gnus-before-do-gcc-hook)
872 (goto-char (point-min))
873 (when (re-search-forward
874 (concat "^" (regexp-quote mail-header-separator) "$")
876 (replace-match "" t t ))
877 (unless (gnus-request-accept-article group method t)
878 (gnus-message 1 "Couldn't store article in group %s: %s"
879 group (gnus-status-message method))
881 (kill-buffer (current-buffer))))))))))
883 (defun gnus-inews-insert-gcc ()
884 "Insert Gcc headers based on `gnus-outgoing-message-group'."
887 (message-narrow-to-headers)
888 (let* ((group gnus-outgoing-message-group)
890 ((gnus-functionp group)
892 ((or (stringp group) (list group))
896 (if (stringp gcc) gcc
897 (mapconcat 'identity gcc " "))
900 (defun gnus-inews-insert-archive-gcc (&optional group)
901 "Insert the Gcc to say where the article is to be archived."
902 (let* ((var gnus-message-archive-group)
903 (group (or group gnus-newsgroup-name ""))
905 (and gnus-newsgroup-name
906 (gnus-group-find-parameter
907 gnus-newsgroup-name 'gcc-self)))
911 ((null gnus-message-archive-method)
915 ;; Just a single group.
918 ;; We don't want this.
920 ((and (listp var) (stringp (car var)))
923 ((gnus-functionp var)
927 ;; An alist of regexps/functions/forms.
932 ((stringp (caar var))
934 (when (string-match (caar var) group)
936 ((gnus-functionp (car var))
938 (funcall (car var) group))
940 (eval (car var)))))))
941 (setq var (cdr var)))
944 (when (or groups gcc-self-val)
945 (when (stringp groups)
946 (setq groups (list groups)))
949 (message-narrow-to-headers)
950 (goto-char (point-max))
953 ;; Use the `gcc-self' param value instead.
956 (if (stringp gcc-self-val)
959 (if (not (eq gcc-self-val 'none))
964 ;; Use the list of groups.
965 (while (setq name (pop groups))
966 (insert (if (string-match ":" name)
968 (gnus-group-prefixed-name
969 name gnus-message-archive-method)))
974 ;;; Allow redefinition of functions.
980 ;;; gnus-msg.el ends here