1 ;;; gnus-msg.el --- mail and post interface for 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>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
36 (defcustom gnus-post-method nil
37 "*Preferred method for posting USENET news.
39 If this variable is `current', Gnus will use the \"current\" select
40 method when posting. If it is nil (which is the default), Gnus will
41 use the native posting method of the server.
43 This method will not be used in mail groups and the like, only in
46 If not nil nor `native', the value must be a valid method as discussed
47 in the documentation of `gnus-select-method'. It can also be a list of
48 methods. If that is the case, the user will be queried for what select
49 method to use when posting."
50 :group 'gnus-group-foreign
51 :type `(choice (const nil)
53 (sexp :tag "Methods" ,gnus-select-method)))
55 (defvar gnus-outgoing-message-group nil
56 "*All outgoing messages will be put in this group.
57 If you want to store all your outgoing mail and articles in the group
58 \"nnml:archive\", you set this variable to that value. This variable
59 can also be a list of group names.
61 If you want to have greater control over what group to put each
62 message in, you can set this variable to a function that checks the
63 current newsgroup name and then returns a suitable group name (or list
66 (defvar gnus-mailing-list-groups nil
67 "*Regexp matching groups that are really mailing lists.
68 This is useful when you're reading a mailing list that has been
69 gatewayed to a newsgroup, and you want to followup to an article in
72 (defvar gnus-add-to-list nil
73 "*If non-nil, add a `to-list' parameter automatically.")
75 (defvar gnus-crosspost-complaint
78 You posted the article below with the following Newsgroups header:
82 The %s group, at least, was an inappropriate recipient
83 of this message. Please trim your Newsgroups header to exclude this
84 group before posting in the future.
89 "Format string to be inserted when complaining about crossposts.
90 The first %s will be replaced by the Newsgroups header;
91 the second with the current group name.")
93 (defvar gnus-message-setup-hook nil
94 "Hook run after setting up a message buffer.")
96 ;;; Internal variables.
98 (defvar gnus-message-buffer "*Mail Gnus*")
99 (defvar gnus-article-copy nil)
100 (defvar gnus-last-posting-server nil)
101 (defvar gnus-message-group-art nil)
103 (defconst gnus-bug-message
104 "Sending a bug report to the Gnus Towers.
105 ========================================
107 The buffer below is a mail buffer. When you press `C-c C-c', it will
108 be sent to the Gnus Bug Exterminators.
110 At the bottom of the buffer you'll see lots of variable settings.
111 Please do not delete those. They will tell the Bug People what your
112 environment is, so that it will be easier to locate the bugs.
114 If you have found a bug that makes Emacs go \"beep\", set
115 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
116 and include the backtrace in your bug report.
118 Please describe the bug in annoying, painstaking detail.
120 Thank you for your help in stamping out bugs.
124 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
125 (autoload 'news-setup "rnewspost")
126 (autoload 'news-reply-mode "rnewspost")
127 (autoload 'rmail-dont-reply-to "mail-utils")
128 (autoload 'rmail-output "rmailout"))
132 ;;; Gnus Posting Functions
135 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
136 "p" gnus-summary-post-news
137 "f" gnus-summary-followup
138 "F" gnus-summary-followup-with-original
139 "c" gnus-summary-cancel-article
140 "s" gnus-summary-supersede-article
141 "r" gnus-summary-reply
142 "R" gnus-summary-reply-with-original
143 "w" gnus-summary-wide-reply
144 "W" gnus-summary-wide-reply-with-original
145 "n" gnus-summary-followup-to-mail
146 "N" gnus-summary-followup-to-mail-with-original
147 "m" gnus-summary-mail-other-window
148 "u" gnus-uu-post-news
149 "\M-c" gnus-summary-mail-crosspost-complaint
150 "om" gnus-summary-mail-forward
151 "op" gnus-summary-post-forward
152 "Om" gnus-uu-digest-mail-forward
153 "Op" gnus-uu-digest-post-forward)
155 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
156 "b" gnus-summary-resend-bounced-mail
157 ;; "c" gnus-summary-send-draft
158 "r" gnus-summary-resend-message)
160 ;;; Internal functions.
162 (defvar gnus-article-reply nil)
163 (defmacro gnus-setup-message (config &rest forms)
164 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
165 (buffer (make-symbol "gnus-setup-message-buffer"))
166 (article (make-symbol "gnus-setup-message-article"))
167 (group (make-symbol "gnus-setup-message-group")))
168 `(let ((,winconf (current-window-configuration))
169 (,buffer (buffer-name (current-buffer)))
170 (,article (and gnus-article-reply (gnus-summary-article-number)))
171 (,group gnus-newsgroup-name)
172 (message-header-setup-hook
173 (copy-sequence message-header-setup-hook)))
174 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
175 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
179 (gnus-inews-add-send-actions ,winconf ,buffer ,article)
180 (setq gnus-message-buffer (current-buffer))
181 (set (make-local-variable 'gnus-message-group-art)
182 (cons ,group ,article))
183 (make-local-variable 'gnus-newsgroup-name)
184 (gnus-run-hooks 'gnus-message-setup-hook))
185 (gnus-configure-windows ,config t)
186 (set-buffer-modified-p nil))))
188 (defun gnus-inews-add-send-actions (winconf buffer article)
189 (make-local-hook 'message-sent-hook)
190 (add-hook 'message-sent-hook 'gnus-inews-do-gcc nil t)
191 (setq message-post-method
193 (gnus-post-method arg ,gnus-newsgroup-name)))
194 (setq message-newsreader (setq message-mailer (gnus-extended-version)))
196 `(set-window-configuration ,winconf) 'exit 'postpone 'kill)
198 `(when (gnus-buffer-exists-p ,buffer)
202 `(gnus-summary-mark-article-as-replied ,article))))
205 (put 'gnus-setup-message 'lisp-indent-function 1)
206 (put 'gnus-setup-message 'edebug-form-spec '(form body))
208 ;;; Post news commands of Gnus group mode and summary mode
210 (defun gnus-group-mail ()
211 "Start composing a mail."
213 (gnus-setup-message 'message
216 (defun gnus-group-post-news (&optional arg)
217 "Start composing a news message.
218 If ARG, post to the group under point.
219 If ARG is 1, prompt for a group name."
221 ;; Bind this variable here to make message mode hooks work ok.
222 (let ((gnus-newsgroup-name
224 (if (= 1 (prefix-numeric-value arg))
225 (completing-read "Newsgroup: " gnus-active-hashtb nil
226 (gnus-read-active-file-p))
227 (gnus-group-group-name))
229 (gnus-post-news 'post gnus-newsgroup-name)))
231 (defun gnus-summary-post-news ()
232 "Start composing a news message."
234 (gnus-post-news 'post gnus-newsgroup-name))
236 (defun gnus-summary-followup (yank &optional force-news)
237 "Compose a followup to an article.
238 If prefix argument YANK is non-nil, original article is yanked automatically."
240 (list (and current-prefix-arg
241 (gnus-summary-work-articles 1))))
243 (gnus-summary-goto-subject (car yank)))
244 (save-window-excursion
245 (gnus-summary-select-article))
246 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
247 (gnus-newsgroup-name gnus-newsgroup-name))
249 (gnus-post-news nil gnus-newsgroup-name
250 headers gnus-article-buffer
251 yank nil force-news)))
253 (defun gnus-summary-followup-with-original (n &optional force-news)
254 "Compose a followup to an article and include the original article."
256 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
258 (defun gnus-summary-followup-to-mail (&optional arg)
259 "Followup to the current mail message via news."
261 (list (and current-prefix-arg
262 (gnus-summary-work-articles 1))))
263 (gnus-summary-followup arg t))
265 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
266 "Followup to the current mail message via news."
268 (gnus-summary-followup (gnus-summary-work-articles arg) t))
270 (defun gnus-inews-yank-articles (articles)
273 (while (setq article (pop articles))
274 (save-window-excursion
275 (set-buffer gnus-summary-buffer)
276 (gnus-summary-select-article nil nil nil article)
277 (gnus-summary-remove-process-mark article))
278 (gnus-copy-article-buffer)
279 (let ((message-reply-buffer gnus-article-copy)
280 (message-reply-headers gnus-current-headers))
281 (message-yank-original)
282 (setq beg (or beg (mark t))))
288 (defun gnus-summary-cancel-article (&optional n symp)
289 "Cancel an article you posted.
290 Uses the process-prefix convention. If given the symbolic
291 prefix `a', cancel using the standard posting method; if not
292 post using the current select method."
293 (interactive (gnus-interactive "P\ny"))
294 (let ((articles (gnus-summary-work-articles n))
297 (gnus-post-method (not (eq symp 'a)) ,gnus-newsgroup-name)))
299 (while (setq article (pop articles))
300 (when (gnus-summary-select-article t nil nil article)
301 (when (gnus-eval-in-buffer-window gnus-original-article-buffer
302 (message-cancel-news))
303 (gnus-summary-mark-as-read article gnus-canceled-mark)
304 (gnus-cache-remove-article 1))
305 (gnus-article-hide-headers-if-wanted))
306 (gnus-summary-remove-process-mark article))))
308 (defun gnus-summary-supersede-article ()
309 "Compose an article that will supersede a previous article.
310 This is done simply by taking the old article and adding a Supersedes
311 header line with the old Message-ID."
313 (let ((article (gnus-summary-article-number)))
314 (gnus-setup-message 'reply-yank
315 (gnus-summary-select-article t)
316 (set-buffer gnus-original-article-buffer)
320 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
322 (set-buffer ,gnus-summary-buffer)
323 (gnus-cache-possibly-remove-article ,article nil nil nil t)
324 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
325 message-send-actions))))
329 (defun gnus-copy-article-buffer (&optional article-buffer)
330 ;; make a copy of the article buffer with all text properties removed
331 ;; this copy is in the buffer gnus-article-copy.
332 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
333 ;; this buffer should be passed to all mail/news reply/post routines.
334 (setq gnus-article-copy (get-buffer-create " *gnus article copy*"))
335 (buffer-disable-undo gnus-article-copy)
336 (or (memq gnus-article-copy gnus-buffer-list)
337 (push gnus-article-copy gnus-buffer-list))
338 (let ((article-buffer (or article-buffer gnus-article-buffer))
340 (if (not (and (get-buffer article-buffer)
341 (gnus-buffer-exists-p article-buffer)))
342 (error "Can't find any article buffer")
344 (set-buffer article-buffer)
346 ;; Copy over the (displayed) article buffer, delete
347 ;; hidden text and remove text properties.
349 (copy-to-buffer gnus-article-copy (point-min) (point-max))
350 (set-buffer gnus-article-copy)
351 (gnus-article-delete-text-of-type 'annotation)
352 (gnus-remove-text-with-property 'gnus-prev)
353 (gnus-remove-text-with-property 'gnus-next)
356 (format "%s" (buffer-string))
358 ;; Find the original headers.
359 (set-buffer gnus-original-article-buffer)
360 (goto-char (point-min))
361 (while (looking-at message-unix-mail-delimiter)
364 (setq end (or (search-forward "\n\n" nil t) (point)))
365 ;; Delete the headers from the displayed articles.
366 (set-buffer gnus-article-copy)
367 (delete-region (goto-char (point-min))
368 (or (search-forward "\n\n" nil t) (point)))
369 ;; Insert the original article headers.
370 (insert-buffer-substring gnus-original-article-buffer beg end)
371 (gnus-article-decode-rfc1522)))
374 (defun gnus-post-news (post &optional group header article-buffer yank subject
377 (gnus-copy-article-buffer))
378 (let ((gnus-article-reply article-buffer)
379 (add-to-list gnus-add-to-list))
380 (gnus-setup-message (cond (yank 'reply-yank)
381 (article-buffer 'reply)
383 (let* ((group (or group gnus-newsgroup-name))
385 to-address to-group mailing-list to-list
388 (setq to-address (gnus-group-find-parameter group 'to-address)
389 to-group (gnus-group-find-parameter group 'to-group)
390 to-list (gnus-group-find-parameter group 'to-list)
391 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
392 mailing-list (when gnus-mailing-list-groups
393 (string-match gnus-mailing-list-groups group))
394 group (gnus-group-real-name group)))
395 (if (or (and to-group
396 (gnus-news-group-p to-group))
399 (and (gnus-news-group-p
400 (or pgroup gnus-newsgroup-name)
401 (if header (mail-header-number header)
402 gnus-current-article))
408 (message-news (or to-group group))
409 (set-buffer gnus-article-copy)
410 (message-followup (if (or newsgroup-p force-news) nil to-group)))
414 (message-mail (or to-address to-list))
415 ;; Arrange for mail groups that have no `to-address' to
416 ;; get that when the user sends off the mail.
417 (when (and (not to-list)
420 (push (list 'gnus-inews-add-to-address pgroup)
421 message-send-actions)))
422 (set-buffer gnus-article-copy)
423 (message-wide-reply to-address
424 (gnus-group-find-parameter
425 gnus-newsgroup-name 'broken-reply-to))))
427 (gnus-inews-yank-articles yank))))))
429 (defun gnus-post-method (arg group &optional silent)
430 "Return the posting method based on GROUP and ARG.
431 If SILENT, don't prompt the user."
432 (let ((group-method (gnus-find-method-for-group group)))
434 ;; If the group-method is nil (which shouldn't happen) we use
435 ;; the default method.
437 (or (and (null (eq gnus-post-method 'active)) gnus-post-method)
438 gnus-select-method message-post-method))
439 ;; We want the inverse of the default
440 ((and arg (not (eq arg 0)))
441 (if (eq gnus-post-method 'active)
444 ;; We query the user for a post method.
446 (and gnus-post-method
447 (not (eq gnus-post-method 'current))
448 (listp (car gnus-post-method))))
450 ;; Collect all methods we know about.
452 (when (and gnus-post-method
453 (not (eq gnus-post-method 'current)))
454 (if (listp (car gnus-post-method))
456 (list gnus-post-method)))
457 gnus-secondary-select-methods
458 (list gnus-select-method)
459 (list group-method)))
460 method-alist post-methods method)
461 ;; Weed out all mail methods.
463 (setq method (gnus-server-get-method "" (pop methods)))
464 (when (or (gnus-method-option-p method 'post)
465 (gnus-method-option-p method 'post-mail))
466 (push method post-methods)))
467 ;; Create a name-method alist.
471 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m))
476 (setq gnus-last-posting-server
478 gnus-last-posting-server)
479 ;; Just use the last value.
480 gnus-last-posting-server
482 "Posting method: " method-alist nil t
483 (cons (or gnus-last-posting-server "") 0))))
485 ;; Override normal method.
486 ((eq gnus-post-method 'current)
490 ;; Use the normal select method.
491 (t gnus-select-method))))
495 ;; Dummy to avoid byte-compile warning.
496 (defvar nnspool-rejected-article-hook)
497 (defvar xemacs-codename)
499 ;;; Since the X-Newsreader/X-Mailer are ``vanity'' headers, they might
500 ;;; as well include the Emacs version as well.
501 ;;; The following function works with later GNU Emacs, and XEmacs.
502 (defun gnus-extended-version ()
503 "Stringified Gnus version and Emacs version"
509 ((string-match "^\\([0-9]+\\.[0-9]+\\)\\.[.0-9]+$" emacs-version)
510 (concat "Emacs " (substring emacs-version
513 ((string-match "\\([A-Z]*[Mm][Aa][Cc][Ss]\\)[^(]*\\(\\((beta.*)\\|'\\)\\)?"
515 (concat (substring emacs-version
518 (format " %d.%d" emacs-major-version emacs-minor-version)
519 (if (match-beginning 3)
520 (substring emacs-version
524 (if (boundp 'xemacs-codename)
525 (concat " - \"" xemacs-codename "\""))))
528 ;; Written by "Mr. Per Persson" <pp@gnu.ai.mit.edu>.
529 (defun gnus-inews-insert-mime-headers ()
530 "Insert MIME headers.
531 Assumes ISO-Latin-1 is used iff 8-bit characters are present."
532 (goto-char (point-min))
533 (let ((mail-header-separator
535 (goto-char (point-min))
536 (if (and (search-forward (concat "\n" mail-header-separator "\n")
538 (not (search-backward "\n\n" nil t)))
539 mail-header-separator
541 (or (mail-position-on-field "Mime-Version")
543 (cond ((save-restriction
545 (goto-char (point-min))
546 (re-search-forward "[^\000-\177]" nil t))
547 (or (mail-position-on-field "Content-Type")
548 (insert "text/plain; charset=ISO-8859-1"))
549 (or (mail-position-on-field "Content-Transfer-Encoding")
551 (t (or (mail-position-on-field "Content-Type")
552 (insert "text/plain; charset=US-ASCII"))
553 (or (mail-position-on-field "Content-Transfer-Encoding")
554 (insert "7bit")))))))
556 (custom-add-option 'message-header-hook 'gnus-inews-insert-mime-headers)
560 ;;; Gnus Mail Functions
563 ;;; Mail reply commands of Gnus summary mode
565 (defun gnus-summary-reply (&optional yank wide)
566 "Start composing a reply mail to the current message.
567 If prefix argument YANK is non-nil, the original article is yanked
570 (list (and current-prefix-arg
571 (gnus-summary-work-articles 1))))
572 ;; Stripping headers should be specified with mail-yank-ignored-headers.
574 (gnus-summary-goto-subject (car yank)))
575 (let ((gnus-article-reply t))
576 (gnus-setup-message (if yank 'reply-yank 'reply)
577 (gnus-summary-select-article)
578 (set-buffer (gnus-copy-article-buffer))
579 (message-reply nil wide (gnus-group-find-parameter
580 gnus-newsgroup-name 'broken-reply-to))
582 (gnus-inews-yank-articles yank)))))
584 (defun gnus-summary-reply-with-original (n &optional wide)
585 "Start composing a reply mail to the current message.
586 The original article will be yanked."
588 (gnus-summary-reply (gnus-summary-work-articles n) wide))
590 (defun gnus-summary-wide-reply (&optional yank)
591 "Start composing a wide reply mail to the current message.
592 If prefix argument YANK is non-nil, the original article is yanked
595 (list (and current-prefix-arg
596 (gnus-summary-work-articles 1))))
597 (gnus-summary-reply yank t))
599 (defun gnus-summary-wide-reply-with-original (n)
600 "Start composing a wide reply mail to the current message.
601 The original article will be yanked."
603 (gnus-summary-reply-with-original n t))
605 (defun gnus-summary-mail-forward (&optional full-headers post)
606 "Forward the current message to another user.
607 If FULL-HEADERS (the prefix), include full headers when forwarding."
609 (gnus-setup-message 'forward
610 (gnus-summary-select-article)
611 (set-buffer gnus-original-article-buffer)
612 (let ((message-included-forward-headers
613 (if full-headers "" message-included-forward-headers)))
614 (message-forward post))))
616 (defun gnus-summary-resend-message (address n)
617 "Resend the current article to ADDRESS."
618 (interactive "sResend message(s) to: \nP")
619 (let ((articles (gnus-summary-work-articles n))
621 (while (setq article (pop articles))
622 (gnus-summary-select-article nil nil nil article)
624 (set-buffer gnus-original-article-buffer)
625 (message-resend address)))))
627 (defun gnus-summary-post-forward (&optional full-headers)
628 "Forward the current article to a newsgroup.
629 If FULL-HEADERS (the prefix), include full headers when forwarding."
631 (gnus-summary-mail-forward full-headers t))
633 (defvar gnus-nastygram-message
634 "The following article was inappropriately posted to %s.\n\n"
635 "Format string to insert in nastygrams.
636 The current group name will be inserted at \"%s\".")
638 (defun gnus-summary-mail-nastygram (n)
639 "Send a nastygram to the author of the current article."
641 (when (or gnus-expert-user
643 "Really send a nastygram to the author of the current article? "))
644 (let ((group gnus-newsgroup-name))
645 (gnus-summary-reply-with-original n)
646 (set-buffer gnus-message-buffer)
648 (insert (format gnus-nastygram-message group))
649 (message-send-and-exit))))
651 (defun gnus-summary-mail-crosspost-complaint (n)
652 "Send a complaint about crossposting to the current article(s)."
654 (let ((articles (gnus-summary-work-articles n))
656 (while (setq article (pop articles))
657 (set-buffer gnus-summary-buffer)
658 (gnus-summary-goto-subject article)
659 (let ((group (gnus-group-real-name gnus-newsgroup-name))
660 newsgroups followup-to)
661 (gnus-summary-select-article)
662 (set-buffer gnus-original-article-buffer)
663 (if (and (<= (length (message-tokenize-header
664 (setq newsgroups (mail-fetch-field "newsgroups"))
667 (or (not (setq followup-to (mail-fetch-field "followup-to")))
668 (not (member group (message-tokenize-header
669 followup-to ", ")))))
671 (gnus-message 1 "Followup-to restricted")
672 (gnus-message 1 "Not a crossposted article"))
673 (set-buffer gnus-summary-buffer)
674 (gnus-summary-reply-with-original 1)
675 (set-buffer gnus-message-buffer)
677 (insert (format gnus-crosspost-complaint newsgroups group))
678 (message-goto-subject)
679 (re-search-forward " *$")
680 (replace-match " (crosspost notification)" t t)
681 (gnus-deactivate-mark)
682 (when (gnus-y-or-n-p "Send this complaint? ")
683 (message-send-and-exit)))))))
685 (defun gnus-summary-mail-other-window ()
686 "Compose mail in other window."
688 (gnus-setup-message 'message
691 (defun gnus-mail-parse-comma-list ()
694 (skip-chars-forward " ")
697 (skip-chars-forward "^,")
702 (narrow-to-region beg (point))
705 (while (search-forward "\"" nil t)
709 (skip-chars-forward ",")
710 (skip-chars-forward "^,"))
711 (skip-chars-backward " ")
712 (push (buffer-substring beg (point))
714 (skip-chars-forward "^,")
715 (skip-chars-forward ", "))
718 (defun gnus-inews-add-to-address (group)
719 (let ((to-address (mail-fetch-field "to")))
720 (when (and to-address
722 ;; This mail group doesn't have a `to-list', so we add one
725 (format "Do you want to add this as `to-list': %s " to-address))
726 (gnus-group-add-parameter group (cons 'to-list to-address))))))
728 (defun gnus-put-message ()
729 "Put the current message in some group and return to Gnus."
731 (let ((reply gnus-article-reply)
732 (winconf gnus-prev-winconf)
733 (group gnus-newsgroup-name))
735 (or (and group (not (gnus-group-read-only-p group)))
736 (setq group (read-string "Put in group: " nil
737 (gnus-writable-groups))))
738 (when (gnus-gethash group gnus-newsrc-hashtb)
739 (error "No such group: %s" group))
744 (message-narrow-to-headers)
745 (let (gnus-deletable-headers)
747 (message-generate-headers message-required-news-headers)
748 (message-generate-headers message-required-mail-headers)))
749 (goto-char (point-max))
750 (insert "Gcc: " group "\n")
755 (when (get-buffer gnus-group-buffer)
756 (when (gnus-buffer-exists-p (car-safe reply))
757 (set-buffer (car reply))
759 (gnus-summary-mark-article-as-replied
762 (set-window-configuration winconf)))))
764 (defun gnus-article-mail (yank)
765 "Send a reply to the address near point.
766 If YANK is non-nil, include the original article."
770 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
771 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
773 (message-reply address)
775 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
777 (defvar nntp-server-type)
779 "Send a bug report to the Gnus maintainers."
781 (unless (gnus-alive-p)
782 (error "Gnus has been shut down"))
783 (gnus-setup-message 'bug
784 (delete-other-windows)
785 (switch-to-buffer (get-buffer-create "*Gnus Help Bug*"))
787 (insert gnus-bug-message)
788 (goto-char (point-min))
789 (message-pop-to-buffer "*Gnus Bug*")
790 (message-setup `((To . ,gnus-maintainer) (Subject . "")))
791 (push `(gnus-bug-kill-buffer) message-send-actions)
792 (goto-char (point-min))
793 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
795 (insert (gnus-version) "\n")
796 (insert (emacs-version) "\n")
797 (when (and (boundp 'nntp-server-type)
798 (stringp nntp-server-type))
799 (insert nntp-server-type))
800 (insert "\n\n\n\n\n")
802 (goto-char (point-min))
803 (search-forward "Subject: " nil t)
806 (defun gnus-bug-kill-buffer ()
807 (when (get-buffer "*Gnus Help Bug*")
808 (kill-buffer "*Gnus Help Bug*")))
811 "Attempts to go through the Gnus source file and report what variables have been changed.
812 The source file has to be in the Emacs load path."
814 (let ((files '("gnus.el" "gnus-sum.el" "gnus-group.el"
815 "gnus-art.el" "gnus-start.el" "gnus-async.el"
816 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
817 "nnmail.el" "message.el"))
820 (gnus-message 4 "Please wait while we snoop your variables...")
822 ;; Go through all the files looking for non-default values for variables.
824 (set-buffer (get-buffer-create " *gnus bug info*"))
825 (buffer-disable-undo (current-buffer))
828 (when (and (setq file (locate-library (pop files)))
829 (file-exists-p file))
830 (insert-file-contents file)
831 (goto-char (point-min))
832 (if (not (re-search-forward "^;;* *Internal variables" nil t))
833 (gnus-message 4 "Malformed sources in file %s" file)
834 (narrow-to-region (point-min) (point))
835 (goto-char (point-min))
836 (while (setq expr (ignore-errors (read (current-buffer))))
838 (and (or (eq (car expr) 'defvar)
839 (eq (car expr) 'defcustom))
840 (stringp (nth 3 expr))
841 (or (not (boundp (nth 1 expr)))
842 (not (equal (eval (nth 2 expr))
843 (symbol-value (nth 1 expr)))))
844 (push (nth 1 expr) olist)))))))
845 (kill-buffer (current-buffer)))
846 (when (setq olist (nreverse olist))
847 (insert "------------------ Environment follows ------------------\n\n"))
849 (if (boundp (car olist))
851 (pp `(setq ,(car olist)
852 ,(if (or (consp (setq sym (symbol-value (car olist))))
854 (not (or (eq sym nil)
856 (list 'quote (symbol-value (car olist)))
857 (symbol-value (car olist))))
860 (format "(setq %s 'whatever)\n" (car olist))))
861 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
862 (setq olist (cdr olist)))
864 ;; Remove any control chars - they seem to cause trouble for some
865 ;; mailers. (Byte-compiled output from the stuff above.)
867 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
868 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
871 ;;; Treatment of rejected articles.
874 (defun gnus-summary-resend-bounced-mail (&optional fetch)
875 "Re-mail the current message.
876 This only makes sense if the current message is a bounce message than
877 contains some mail you have written which has been bounced back to
879 If FETCH, try to fetch the article that this is a reply to, if indeed
882 (gnus-summary-select-article t)
883 (set-buffer gnus-original-article-buffer)
884 (gnus-setup-message 'compose-bounce
885 (let* ((references (mail-fetch-field "references"))
886 (parent (and references (gnus-parent-id references))))
888 ;; If there are references, we fetch the article we answered to.
890 (gnus-summary-refer-article parent)
891 (gnus-summary-show-all-headers)))))
895 ;; Do Gcc handling, which copied the message over to some group.
896 (defun gnus-inews-do-gcc (&optional gcc)
901 (message-narrow-to-headers)
902 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
903 (cur (current-buffer))
906 (message-remove-header "gcc")
908 (setq groups (message-tokenize-header gcc " ,"))
909 ;; Copy the article over to some group(s).
910 (while (setq group (pop groups))
913 (cond ((and (null (gnus-get-info group))
914 (eq (car gnus-message-archive-method)
916 (gnus-server-to-method
917 (gnus-group-method group)))))
918 ;; If the group doesn't exist, we assume
919 ;; it's an archive group...
920 gnus-message-archive-method)
922 ((gnus-info-method (gnus-get-info group))
923 (gnus-info-method (gnus-get-info group)))
925 (t (gnus-group-method group)))))
926 (gnus-check-server method)
927 (unless (gnus-request-group group t method)
928 (gnus-request-create-group group method))
930 (nnheader-set-temp-buffer " *acc*")
931 (insert-buffer-substring cur)
932 (goto-char (point-min))
933 (when (re-search-forward
934 (concat "^" (regexp-quote mail-header-separator) "$")
936 (replace-match "" t t ))
937 (unless (gnus-request-accept-article group method t)
938 (gnus-message 1 "Couldn't store article in group %s: %s"
939 group (gnus-status-message method))
941 (kill-buffer (current-buffer))))))))))
943 (defun gnus-inews-insert-gcc ()
944 "Insert Gcc headers based on `gnus-outgoing-message-group'."
947 (message-narrow-to-headers)
948 (let* ((group gnus-outgoing-message-group)
950 ((gnus-functionp group)
952 ((or (stringp group) (list group))
956 (if (stringp gcc) gcc
957 (mapconcat 'identity gcc " "))
960 (defun gnus-inews-insert-archive-gcc (&optional group)
961 "Insert the Gcc to say where the article is to be archived."
962 (let* ((var gnus-message-archive-group)
963 (group (or group gnus-newsgroup-name ""))
965 (and gnus-newsgroup-name
966 (gnus-group-find-parameter
967 gnus-newsgroup-name 'gcc-self)))
971 ((null gnus-message-archive-method)
975 ;; Just a single group.
978 ;; We don't want this.
980 ((and (listp var) (stringp (car var)))
983 ((gnus-functionp var)
987 ;; An alist of regexps/functions/forms.
992 ((stringp (caar var))
994 (when (string-match (caar var) group)
996 ((gnus-functionp (car var))
998 (funcall (car var) group))
1000 (eval (car var)))))))
1001 (setq var (cdr var)))
1004 (when (or groups gcc-self-val)
1005 (when (stringp groups)
1006 (setq groups (list groups)))
1009 (message-narrow-to-headers)
1010 (goto-char (point-max))
1013 ;; Use the `gcc-self' param value instead.
1016 (if (stringp gcc-self-val)
1019 (if (not (eq gcc-self-val 'none))
1024 ;; Use the list of groups.
1025 (while (setq name (pop groups))
1026 (insert (if (string-match ":" name)
1028 (gnus-group-prefixed-name
1029 name gnus-message-archive-method)))
1034 ;;; Allow redefinition of functions.
1040 ;;; gnus-msg.el ends here