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 (defcustom gnus-post-method nil
38 "*Preferred method for posting USENET news.
40 If this variable is `current', Gnus will use the \"current\" select
41 method when posting. If it is nil (which is the default), Gnus will
42 use the native posting method of the server.
44 This method will not be used in mail groups and the like, only in
47 If not nil nor `native', 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 :type `(choice (const nil)
55 (sexp :tag "Methods" ,gnus-select-method)))
57 (defvar 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 (defvar gnus-mailing-list-groups nil
69 "*Regexp matching groups that are really mailing lists.
70 This is useful when you're reading a mailing list that has been
71 gatewayed to a newsgroup, and you want to followup to an article in
74 (defvar gnus-add-to-list nil
75 "*If non-nil, add a `to-list' parameter automatically.")
77 (defvar gnus-crosspost-complaint
80 You posted the article below with the following Newsgroups header:
84 The %s group, at least, was an inappropriate recipient
85 of this message. Please trim your Newsgroups header to exclude this
86 group before posting in the future.
91 "Format string to be inserted when complaining about crossposts.
92 The first %s will be replaced by the Newsgroups header;
93 the second with the current group name.")
95 (defvar gnus-message-setup-hook nil
96 "Hook run after setting up a message buffer.")
98 ;;; Internal variables.
100 (defvar gnus-message-buffer "*Mail Gnus*")
101 (defvar gnus-article-copy nil)
102 (defvar gnus-last-posting-server nil)
103 (defvar gnus-message-group-art nil)
105 (defconst gnus-bug-message
106 "Sending a bug report to the Gnus Towers.
107 ========================================
109 The buffer below is a mail buffer. When you press `C-c C-c', it will
110 be sent to the Gnus Bug Exterminators.
112 At the bottom of the buffer you'll see lots of variable settings.
113 Please do not delete those. They will tell the Bug People what your
114 environment is, so that it will be easier to locate the bugs.
116 If you have found a bug that makes Emacs go \"beep\", set
117 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
118 and include the backtrace in your bug report.
120 Please describe the bug in annoying, painstaking detail.
122 Thank you for your help in stamping out bugs.
126 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
127 (autoload 'news-setup "rnewspost")
128 (autoload 'news-reply-mode "rnewspost")
129 (autoload 'rmail-dont-reply-to "mail-utils")
130 (autoload 'rmail-output "rmailout"))
134 ;;; Gnus Posting Functions
137 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
138 "p" gnus-summary-post-news
139 "f" gnus-summary-followup
140 "F" gnus-summary-followup-with-original
141 "c" gnus-summary-cancel-article
142 "s" gnus-summary-supersede-article
143 "r" gnus-summary-reply
144 "R" gnus-summary-reply-with-original
145 "w" gnus-summary-wide-reply
146 "W" gnus-summary-wide-reply-with-original
147 "n" gnus-summary-followup-to-mail
148 "N" gnus-summary-followup-to-mail-with-original
149 "m" gnus-summary-mail-other-window
150 "u" gnus-uu-post-news
151 "\M-c" gnus-summary-mail-crosspost-complaint
152 "om" gnus-summary-mail-forward
153 "op" gnus-summary-post-forward
154 "Om" gnus-uu-digest-mail-forward
155 "Op" gnus-uu-digest-post-forward)
157 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
158 "b" gnus-summary-resend-bounced-mail
159 ;; "c" gnus-summary-send-draft
160 "r" gnus-summary-resend-message)
162 ;;; Internal functions.
164 (defvar gnus-article-reply nil)
165 (defmacro gnus-setup-message (config &rest forms)
166 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
167 (buffer (make-symbol "gnus-setup-message-buffer"))
168 (article (make-symbol "gnus-setup-message-article"))
169 (group (make-symbol "gnus-setup-message-group")))
170 `(let ((,winconf (current-window-configuration))
171 (,buffer (buffer-name (current-buffer)))
172 (,article (and gnus-article-reply (gnus-summary-article-number)))
173 (,group gnus-newsgroup-name)
174 (message-header-setup-hook
175 (copy-sequence message-header-setup-hook)))
176 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
177 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
181 (gnus-inews-add-send-actions ,winconf ,buffer ,article)
182 (setq gnus-message-buffer (current-buffer))
183 (set (make-local-variable 'gnus-message-group-art)
184 (cons ,group ,article))
185 (make-local-variable 'gnus-newsgroup-name)
186 (gnus-run-hooks 'gnus-message-setup-hook))
187 (gnus-configure-windows ,config t)
188 (set-buffer-modified-p nil))))
190 (defun gnus-inews-add-send-actions (winconf buffer article)
191 (make-local-hook 'message-sent-hook)
192 (add-hook 'message-sent-hook 'gnus-inews-do-gcc nil t)
193 (setq message-post-method
195 (gnus-post-method arg ,gnus-newsgroup-name)))
196 (setq message-newsreader (setq message-mailer (gnus-extended-version)))
198 `(set-window-configuration ,winconf) 'exit 'postpone 'kill)
200 `(when (gnus-buffer-exists-p ,buffer)
204 `(gnus-summary-mark-article-as-replied ,article))))
207 (put 'gnus-setup-message 'lisp-indent-function 1)
208 (put 'gnus-setup-message 'edebug-form-spec '(form body))
210 ;;; Post news commands of Gnus group mode and summary mode
212 (defun gnus-group-mail ()
213 "Start composing a mail."
215 (gnus-setup-message 'message
218 (defun gnus-group-post-news (&optional arg)
219 "Start composing a news message.
220 If ARG, post to the group under point.
221 If ARG is 1, prompt for a group name."
223 ;; Bind this variable here to make message mode hooks work ok.
224 (let ((gnus-newsgroup-name
226 (if (= 1 (prefix-numeric-value arg))
227 (completing-read "Newsgroup: " gnus-active-hashtb nil
228 (gnus-read-active-file-p))
229 (gnus-group-group-name))
231 (gnus-post-news 'post gnus-newsgroup-name)))
233 (defun gnus-summary-post-news ()
234 "Start composing a news message."
236 (gnus-post-news 'post gnus-newsgroup-name))
238 (defun gnus-summary-followup (yank &optional force-news)
239 "Compose a followup to an article.
240 If prefix argument YANK is non-nil, original article is yanked automatically."
242 (list (and current-prefix-arg
243 (gnus-summary-work-articles 1))))
245 (gnus-summary-goto-subject (car yank)))
246 (save-window-excursion
247 (gnus-summary-select-article))
248 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
249 (gnus-newsgroup-name gnus-newsgroup-name))
251 (gnus-post-news nil gnus-newsgroup-name
252 headers gnus-article-buffer
253 yank nil force-news)))
255 (defun gnus-summary-followup-with-original (n &optional force-news)
256 "Compose a followup to an article and include the original article."
258 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
260 (defun gnus-summary-followup-to-mail (&optional arg)
261 "Followup to the current mail message via news."
263 (list (and current-prefix-arg
264 (gnus-summary-work-articles 1))))
265 (gnus-summary-followup arg t))
267 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
268 "Followup to the current mail message via news."
270 (gnus-summary-followup (gnus-summary-work-articles arg) t))
272 (defun gnus-inews-yank-articles (articles)
275 (while (setq article (pop articles))
276 (save-window-excursion
277 (set-buffer gnus-summary-buffer)
278 (gnus-summary-select-article nil nil nil article)
279 (gnus-summary-remove-process-mark article))
280 (gnus-copy-article-buffer)
281 (let ((message-reply-buffer gnus-article-copy)
282 (message-reply-headers gnus-current-headers))
283 (message-yank-original)
284 (setq beg (or beg (mark t))))
290 (defun gnus-summary-cancel-article (&optional n symp)
291 "Cancel an article you posted.
292 Uses the process-prefix convention. If given the symbolic
293 prefix `a', cancel using the standard posting method; if not
294 post using the current select method."
295 (interactive (gnus-interactive "P\ny"))
296 (let ((articles (gnus-summary-work-articles n))
299 (gnus-post-method (not (eq symp 'a)) ,gnus-newsgroup-name)))
301 (while (setq article (pop articles))
302 (when (gnus-summary-select-article t nil nil article)
303 (when (gnus-eval-in-buffer-window gnus-article-buffer
305 (set-buffer gnus-original-article-buffer)
306 (message-cancel-news)))
307 (gnus-summary-mark-as-read article gnus-canceled-mark)
308 (gnus-cache-remove-article 1))
309 (gnus-article-hide-headers-if-wanted))
310 (gnus-summary-remove-process-mark article))))
312 (defun gnus-summary-supersede-article ()
313 "Compose an article that will supersede a previous article.
314 This is done simply by taking the old article and adding a Supersedes
315 header line with the old Message-ID."
317 (let ((article (gnus-summary-article-number)))
318 (gnus-setup-message 'reply-yank
319 (gnus-summary-select-article t)
320 (set-buffer gnus-original-article-buffer)
324 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
326 (set-buffer ,gnus-summary-buffer)
327 (gnus-cache-possibly-remove-article ,article nil nil nil t)
328 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
329 message-send-actions))))
333 (defun gnus-copy-article-buffer (&optional article-buffer)
334 ;; make a copy of the article buffer with all text properties removed
335 ;; this copy is in the buffer gnus-article-copy.
336 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
337 ;; this buffer should be passed to all mail/news reply/post routines.
338 (setq gnus-article-copy (get-buffer-create " *gnus article copy*"))
339 (buffer-disable-undo gnus-article-copy)
340 (or (memq gnus-article-copy gnus-buffer-list)
341 (push gnus-article-copy gnus-buffer-list))
342 (let ((article-buffer (or article-buffer gnus-article-buffer))
344 (if (not (and (get-buffer article-buffer)
345 (gnus-buffer-exists-p article-buffer)))
346 (error "Can't find any article buffer")
348 (set-buffer article-buffer)
350 ;; Copy over the (displayed) article buffer, delete
351 ;; hidden text and remove text properties.
353 (copy-to-buffer gnus-article-copy (point-min) (point-max))
354 (set-buffer gnus-article-copy)
355 (gnus-article-delete-text-of-type 'annotation)
356 (gnus-remove-text-with-property 'gnus-prev)
357 (gnus-remove-text-with-property 'gnus-next)
360 (format "%s" (buffer-string))
362 ;; Find the original headers.
363 (set-buffer gnus-original-article-buffer)
364 (goto-char (point-min))
365 (while (looking-at message-unix-mail-delimiter)
368 (setq end (or (search-forward "\n\n" nil t) (point)))
369 ;; Delete the headers from the displayed articles.
370 (set-buffer gnus-article-copy)
371 (delete-region (goto-char (point-min))
372 (or (search-forward "\n\n" nil t) (point)))
373 ;; Insert the original article headers.
374 (insert-buffer-substring gnus-original-article-buffer beg end)
375 (gnus-article-decode-rfc1522)))
378 (defun gnus-post-news (post &optional group header article-buffer yank subject
381 (gnus-copy-article-buffer))
382 (let ((gnus-article-reply article-buffer)
383 (add-to-list gnus-add-to-list))
384 (gnus-setup-message (cond (yank 'reply-yank)
385 (article-buffer 'reply)
387 (let* ((group (or group gnus-newsgroup-name))
389 to-address to-group mailing-list to-list
392 (setq to-address (gnus-group-find-parameter group 'to-address)
393 to-group (gnus-group-find-parameter group 'to-group)
394 to-list (gnus-group-find-parameter group 'to-list)
395 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
396 mailing-list (when gnus-mailing-list-groups
397 (string-match gnus-mailing-list-groups group))
398 group (gnus-group-real-name group)))
399 (if (or (and to-group
400 (gnus-news-group-p to-group))
403 (and (gnus-news-group-p
404 (or pgroup gnus-newsgroup-name)
405 (if header (mail-header-number header)
406 gnus-current-article))
412 (message-news (or to-group group))
413 (set-buffer gnus-article-copy)
414 (message-followup (if (or newsgroup-p force-news) nil to-group)))
418 (message-mail (or to-address to-list))
419 ;; Arrange for mail groups that have no `to-address' to
420 ;; get that when the user sends off the mail.
421 (when (and (not to-list)
424 (push (list 'gnus-inews-add-to-address pgroup)
425 message-send-actions)))
426 (set-buffer gnus-article-copy)
427 (message-wide-reply to-address
428 (gnus-group-find-parameter
429 gnus-newsgroup-name 'broken-reply-to))))
431 (gnus-inews-yank-articles yank))))))
433 (defun gnus-post-method (arg group &optional silent)
434 "Return the posting method based on GROUP and ARG.
435 If SILENT, don't prompt the user."
436 (let ((group-method (gnus-find-method-for-group group)))
438 ;; If the group-method is nil (which shouldn't happen) we use
439 ;; the default method.
441 (or (and (null (eq gnus-post-method 'active)) gnus-post-method)
442 gnus-select-method message-post-method))
443 ;; We want the inverse of the default
444 ((and arg (not (eq arg 0)))
445 (if (eq gnus-post-method 'active)
448 ;; We query the user for a post method.
450 (and gnus-post-method
451 (not (eq gnus-post-method 'current))
452 (listp (car gnus-post-method))))
454 ;; Collect all methods we know about.
456 (when (and gnus-post-method
457 (not (eq gnus-post-method 'current)))
458 (if (listp (car gnus-post-method))
460 (list gnus-post-method)))
461 gnus-secondary-select-methods
462 (list gnus-select-method)
463 (list group-method)))
464 method-alist post-methods method)
465 ;; Weed out all mail methods.
467 (setq method (gnus-server-get-method "" (pop methods)))
468 (when (or (gnus-method-option-p method 'post)
469 (gnus-method-option-p method 'post-mail))
470 (push method post-methods)))
471 ;; Create a name-method alist.
475 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m))
480 (setq gnus-last-posting-server
482 gnus-last-posting-server)
483 ;; Just use the last value.
484 gnus-last-posting-server
486 "Posting method: " method-alist nil t
487 (cons (or gnus-last-posting-server "") 0))))
489 ;; Override normal method.
490 ((eq gnus-post-method 'current)
494 ;; Use the normal select method.
495 (t gnus-select-method))))
499 ;; Dummy to avoid byte-compile warning.
500 (defvar nnspool-rejected-article-hook)
501 (defvar xemacs-codename)
503 ;;; Since the X-Newsreader/X-Mailer are ``vanity'' headers, they might
504 ;;; as well include the Emacs version as well.
505 ;;; The following function works with later GNU Emacs, and XEmacs.
506 (defun gnus-extended-version ()
507 "Stringified Gnus version"
513 ;;; Gnus Mail Functions
516 ;;; Mail reply commands of Gnus summary mode
518 (defun gnus-summary-reply (&optional yank wide)
519 "Start composing a reply mail to the current message.
520 If prefix argument YANK is non-nil, the original article is yanked
523 (list (and current-prefix-arg
524 (gnus-summary-work-articles 1))))
525 ;; Stripping headers should be specified with mail-yank-ignored-headers.
527 (gnus-summary-goto-subject (car yank)))
528 (let ((gnus-article-reply t))
529 (gnus-setup-message (if yank 'reply-yank 'reply)
530 (gnus-summary-select-article)
531 (set-buffer (gnus-copy-article-buffer))
532 (message-reply nil wide (gnus-group-find-parameter
533 gnus-newsgroup-name 'broken-reply-to))
535 (gnus-inews-yank-articles yank)))))
537 (defun gnus-summary-reply-with-original (n &optional wide)
538 "Start composing a reply mail to the current message.
539 The original article will be yanked."
541 (gnus-summary-reply (gnus-summary-work-articles n) wide))
543 (defun gnus-summary-wide-reply (&optional yank)
544 "Start composing a wide reply mail to the current message.
545 If prefix argument YANK is non-nil, the original article is yanked
548 (list (and current-prefix-arg
549 (gnus-summary-work-articles 1))))
550 (gnus-summary-reply yank t))
552 (defun gnus-summary-wide-reply-with-original (n)
553 "Start composing a wide reply mail to the current message.
554 The original article will be yanked."
556 (gnus-summary-reply-with-original n t))
558 (defun gnus-summary-mail-forward (&optional full-headers post)
559 "Forward the current message to another user.
560 If FULL-HEADERS (the prefix), include full headers when forwarding."
562 (gnus-setup-message 'forward
563 (gnus-summary-select-article)
564 (let ((charset default-mime-charset))
565 (set-buffer gnus-original-article-buffer)
566 (make-local-variable 'default-mime-charset)
567 (setq default-mime-charset charset)
569 (let ((message-included-forward-headers
570 (if full-headers "" message-included-forward-headers)))
571 (message-forward post))))
573 (defun gnus-summary-resend-message (address n)
574 "Resend the current article to ADDRESS."
575 (interactive "sResend message(s) to: \nP")
576 (let ((articles (gnus-summary-work-articles n))
578 (while (setq article (pop articles))
579 (gnus-summary-select-article nil nil nil article)
581 (set-buffer gnus-original-article-buffer)
582 (message-resend address)))))
584 (defun gnus-summary-post-forward (&optional full-headers)
585 "Forward the current article to a newsgroup.
586 If FULL-HEADERS (the prefix), include full headers when forwarding."
588 (gnus-summary-mail-forward full-headers t))
590 (defvar gnus-nastygram-message
591 "The following article was inappropriately posted to %s.\n\n"
592 "Format string to insert in nastygrams.
593 The current group name will be inserted at \"%s\".")
595 (defun gnus-summary-mail-nastygram (n)
596 "Send a nastygram to the author of the current article."
598 (when (or gnus-expert-user
600 "Really send a nastygram to the author of the current article? "))
601 (let ((group gnus-newsgroup-name))
602 (gnus-summary-reply-with-original n)
603 (set-buffer gnus-message-buffer)
605 (insert (format gnus-nastygram-message group))
606 (message-send-and-exit))))
608 (defun gnus-summary-mail-crosspost-complaint (n)
609 "Send a complaint about crossposting to the current article(s)."
611 (let ((articles (gnus-summary-work-articles n))
613 (while (setq article (pop articles))
614 (set-buffer gnus-summary-buffer)
615 (gnus-summary-goto-subject article)
616 (let ((group (gnus-group-real-name gnus-newsgroup-name))
617 newsgroups followup-to)
618 (gnus-summary-select-article)
619 (set-buffer gnus-original-article-buffer)
620 (if (and (<= (length (message-tokenize-header
621 (setq newsgroups (mail-fetch-field "newsgroups"))
624 (or (not (setq followup-to (mail-fetch-field "followup-to")))
625 (not (member group (message-tokenize-header
626 followup-to ", ")))))
628 (gnus-message 1 "Followup-to restricted")
629 (gnus-message 1 "Not a crossposted article"))
630 (set-buffer gnus-summary-buffer)
631 (gnus-summary-reply-with-original 1)
632 (set-buffer gnus-message-buffer)
634 (insert (format gnus-crosspost-complaint newsgroups group))
635 (message-goto-subject)
636 (re-search-forward " *$")
637 (replace-match " (crosspost notification)" t t)
638 (gnus-deactivate-mark)
639 (when (gnus-y-or-n-p "Send this complaint? ")
640 (message-send-and-exit)))))))
642 (defun gnus-summary-mail-other-window ()
643 "Compose mail in other window."
645 (gnus-setup-message 'message
648 (defun gnus-mail-parse-comma-list ()
651 (skip-chars-forward " ")
654 (skip-chars-forward "^,")
659 (narrow-to-region beg (point))
662 (while (search-forward "\"" nil t)
666 (skip-chars-forward ",")
667 (skip-chars-forward "^,"))
668 (skip-chars-backward " ")
669 (push (buffer-substring beg (point))
671 (skip-chars-forward "^,")
672 (skip-chars-forward ", "))
675 (defun gnus-inews-add-to-address (group)
676 (let ((to-address (mail-fetch-field "to")))
677 (when (and to-address
679 ;; This mail group doesn't have a `to-list', so we add one
682 (format "Do you want to add this as `to-list': %s " to-address))
683 (gnus-group-add-parameter group (cons 'to-list to-address))))))
685 (defun gnus-put-message ()
686 "Put the current message in some group and return to Gnus."
688 (let ((reply gnus-article-reply)
689 (winconf gnus-prev-winconf)
690 (group gnus-newsgroup-name))
692 (or (and group (not (gnus-group-read-only-p group)))
693 (setq group (read-string "Put in group: " nil
694 (gnus-writable-groups))))
695 (when (gnus-gethash group gnus-newsrc-hashtb)
696 (error "No such group: %s" group))
701 (message-narrow-to-headers)
702 (let (gnus-deletable-headers)
704 (message-generate-headers message-required-news-headers)
705 (message-generate-headers message-required-mail-headers)))
706 (goto-char (point-max))
707 (insert "Gcc: " group "\n")
712 (when (get-buffer gnus-group-buffer)
713 (when (gnus-buffer-exists-p (car-safe reply))
714 (set-buffer (car reply))
716 (gnus-summary-mark-article-as-replied
719 (set-window-configuration winconf)))))
721 (defun gnus-article-mail (yank)
722 "Send a reply to the address near point.
723 If YANK is non-nil, include the original article."
727 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
728 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
730 (message-reply address)
732 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
734 (defvar nntp-server-type)
736 "Send a bug report to the Gnus maintainers."
738 (unless (gnus-alive-p)
739 (error "Gnus has been shut down"))
740 (gnus-setup-message 'bug
741 (delete-other-windows)
742 (switch-to-buffer (get-buffer-create "*Gnus Help Bug*"))
744 (insert gnus-bug-message)
745 (goto-char (point-min))
746 (message-pop-to-buffer "*Gnus Bug*")
747 (message-setup `((To . ,gnus-maintainer) (Subject . "")))
748 (push `(gnus-bug-kill-buffer) message-send-actions)
749 (goto-char (point-min))
750 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
752 (insert (gnus-version) "\n")
753 (insert (emacs-version) "\n")
754 (when (and (boundp 'nntp-server-type)
755 (stringp nntp-server-type))
756 (insert nntp-server-type))
757 (insert "\n\n\n\n\n")
759 (goto-char (point-min))
760 (search-forward "Subject: " nil t)
763 (defun gnus-bug-kill-buffer ()
764 (when (get-buffer "*Gnus Help Bug*")
765 (kill-buffer "*Gnus Help Bug*")))
768 "Attempts to go through the Gnus source file and report what variables have been changed.
769 The source file has to be in the Emacs load path."
771 (let ((files '("gnus.el" "gnus-sum.el" "gnus-group.el"
772 "gnus-art.el" "gnus-start.el" "gnus-async.el"
773 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
774 "nnmail.el" "message.el"))
777 (gnus-message 4 "Please wait while we snoop your variables...")
779 ;; Go through all the files looking for non-default values for variables.
781 (set-buffer (get-buffer-create " *gnus bug info*"))
782 (buffer-disable-undo (current-buffer))
785 (when (and (setq file (locate-library (pop files)))
786 (file-exists-p file))
787 (insert-file-contents file)
788 (goto-char (point-min))
789 (if (not (re-search-forward "^;;* *Internal variables" nil t))
790 (gnus-message 4 "Malformed sources in file %s" file)
791 (narrow-to-region (point-min) (point))
792 (goto-char (point-min))
793 (while (setq expr (ignore-errors (read (current-buffer))))
795 (and (or (eq (car expr) 'defvar)
796 (eq (car expr) 'defcustom))
797 (stringp (nth 3 expr))
798 (or (not (boundp (nth 1 expr)))
799 (not (equal (eval (nth 2 expr))
800 (symbol-value (nth 1 expr)))))
801 (push (nth 1 expr) olist)))))))
802 (kill-buffer (current-buffer)))
803 (when (setq olist (nreverse olist))
804 (insert "------------------ Environment follows ------------------\n\n"))
806 (if (boundp (car olist))
808 (pp `(setq ,(car olist)
809 ,(if (or (consp (setq sym (symbol-value (car olist))))
811 (not (or (eq sym nil)
813 (list 'quote (symbol-value (car olist)))
814 (symbol-value (car olist))))
817 (format "(setq %s 'whatever)\n" (car olist))))
818 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
819 (setq olist (cdr olist)))
821 ;; Remove any control chars - they seem to cause trouble for some
822 ;; mailers. (Byte-compiled output from the stuff above.)
824 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
825 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
828 ;;; Treatment of rejected articles.
831 (defun gnus-summary-resend-bounced-mail (&optional fetch)
832 "Re-mail the current message.
833 This only makes sense if the current message is a bounce message than
834 contains some mail you have written which has been bounced back to
836 If FETCH, try to fetch the article that this is a reply to, if indeed
839 (gnus-summary-select-article t)
840 (set-buffer gnus-original-article-buffer)
841 (gnus-setup-message 'compose-bounce
842 (let* ((references (mail-fetch-field "references"))
843 (parent (and references (gnus-parent-id references))))
845 ;; If there are references, we fetch the article we answered to.
847 (gnus-summary-refer-article parent)
848 (gnus-summary-show-all-headers)))))
852 ;; Do Gcc handling, which copied the message over to some group.
853 (defun gnus-inews-do-gcc (&optional gcc)
858 (message-narrow-to-headers)
859 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
860 (coding-system-for-write 'raw-text)
863 (message-remove-header "gcc")
865 (setq groups (message-tokenize-header gcc " ,"))
866 ;; Copy the article over to some group(s).
867 (while (setq group (pop groups))
870 (cond ((and (null (gnus-get-info group))
871 (eq (car gnus-message-archive-method)
873 (gnus-server-to-method
874 (gnus-group-method group)))))
875 ;; If the group doesn't exist, we assume
876 ;; it's an archive group...
877 gnus-message-archive-method)
879 ((gnus-info-method (gnus-get-info group))
880 (gnus-info-method (gnus-get-info group)))
882 (t (gnus-group-method group)))))
883 (gnus-check-server method)
884 (unless (gnus-request-group group t method)
885 (gnus-request-create-group group method))
887 (nnheader-set-temp-buffer " *acc*")
888 (insert-buffer-substring message-encoding-buffer)
889 (gnus-run-hooks 'gnus-before-do-gcc-hook)
890 (goto-char (point-min))
891 (when (re-search-forward
892 (concat "^" (regexp-quote mail-header-separator) "$")
894 (replace-match "" t t ))
895 (unless (gnus-request-accept-article group method t)
896 (gnus-message 1 "Couldn't store article in group %s: %s"
897 group (gnus-status-message method))
899 (kill-buffer (current-buffer))))))))))
901 (defun gnus-inews-insert-gcc ()
902 "Insert Gcc headers based on `gnus-outgoing-message-group'."
905 (message-narrow-to-headers)
906 (let* ((group gnus-outgoing-message-group)
908 ((gnus-functionp group)
910 ((or (stringp group) (list group))
914 (if (stringp gcc) gcc
915 (mapconcat 'identity gcc " "))
918 (defun gnus-inews-insert-archive-gcc (&optional group)
919 "Insert the Gcc to say where the article is to be archived."
920 (let* ((var gnus-message-archive-group)
921 (group (or group gnus-newsgroup-name ""))
923 (and gnus-newsgroup-name
924 (gnus-group-find-parameter
925 gnus-newsgroup-name 'gcc-self)))
929 ((null gnus-message-archive-method)
933 ;; Just a single group.
936 ;; We don't want this.
938 ((and (listp var) (stringp (car var)))
941 ((gnus-functionp var)
945 ;; An alist of regexps/functions/forms.
950 ((stringp (caar var))
952 (when (string-match (caar var) group)
954 ((gnus-functionp (car var))
956 (funcall (car var) group))
958 (eval (car var)))))))
959 (setq var (cdr var)))
962 (when (or groups gcc-self-val)
963 (when (stringp groups)
964 (setq groups (list groups)))
967 (message-narrow-to-headers)
968 (goto-char (point-max))
971 ;; Use the `gcc-self' param value instead.
974 (if (stringp gcc-self-val)
977 (if (not (eq gcc-self-val 'none))
982 ;; Use the list of groups.
983 (while (setq name (pop groups))
984 (insert (if (string-match ":" name)
986 (gnus-group-prefixed-name
987 name gnus-message-archive-method)))
992 ;;; Allow redefinition of functions.
998 ;;; gnus-msg.el ends here