1 ;;; gnus-msg.el --- mail and post interface for Semi-gnus
2 ;; Copyright (C) 1995,96,97 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 `(let ((,winconf (current-window-configuration))
163 (,buffer (buffer-name (current-buffer)))
164 (,article (and gnus-article-reply (gnus-summary-article-number)))
165 (message-header-setup-hook
166 (copy-sequence message-header-setup-hook)))
167 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
168 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
172 (gnus-inews-add-send-actions ,winconf ,buffer ,article)
173 (setq gnus-message-buffer (current-buffer))
174 (set (make-local-variable 'gnus-message-group-art)
175 (cons ,gnus-newsgroup-name ,article))
176 (make-local-variable 'gnus-newsgroup-name)
177 (run-hooks 'gnus-message-setup-hook))
178 (gnus-configure-windows ,config t)
179 (set-buffer-modified-p nil))))
181 (defun gnus-inews-add-send-actions (winconf buffer article)
182 (make-local-hook 'message-sent-hook)
183 (add-hook 'message-sent-hook 'gnus-inews-do-gcc nil t)
184 (setq message-post-method
186 (gnus-post-method arg ,gnus-newsgroup-name)))
187 (setq message-newsreader (setq message-mailer (gnus-extended-version)))
189 `(set-window-configuration ,winconf) 'exit 'postpone 'kill)
191 `(when (buffer-name (get-buffer ,buffer))
193 (set-buffer (get-buffer ,buffer))
195 `(gnus-summary-mark-article-as-replied ,article))))
198 (put 'gnus-setup-message 'lisp-indent-function 1)
199 (put 'gnus-setup-message 'edebug-form-spec '(form body))
201 ;;; Post news commands of Gnus group mode and summary mode
203 (defun gnus-group-mail ()
204 "Start composing a mail."
206 (gnus-setup-message 'message
209 (defun gnus-group-post-news (&optional arg)
210 "Start composing a news message.
211 If ARG, post to the group under point.
212 If ARG is 1, prompt for a group name."
214 ;; Bind this variable here to make message mode hooks work ok.
215 (let ((gnus-newsgroup-name
217 (if (= 1 (prefix-numeric-value arg))
218 (completing-read "Newsgroup: " gnus-active-hashtb nil
219 (gnus-read-active-file-p))
220 (gnus-group-group-name))
222 (gnus-post-news 'post gnus-newsgroup-name)))
224 (defun gnus-summary-post-news ()
225 "Start composing a news message."
227 (gnus-post-news 'post gnus-newsgroup-name))
229 (defun gnus-summary-followup (yank &optional force-news)
230 "Compose a followup to an article.
231 If prefix argument YANK is non-nil, original article is yanked automatically."
233 (list (and current-prefix-arg
234 (gnus-summary-work-articles 1))))
236 (gnus-summary-goto-subject (car yank)))
237 (save-window-excursion
238 (gnus-summary-select-article))
239 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
240 (gnus-newsgroup-name gnus-newsgroup-name))
242 (gnus-post-news nil gnus-newsgroup-name
243 headers gnus-article-buffer
244 yank nil force-news)))
246 (defun gnus-summary-followup-with-original (n &optional force-news)
247 "Compose a followup to an article and include the original article."
249 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
251 (defun gnus-summary-followup-to-mail (&optional arg)
252 "Followup to the current mail message via news."
254 (list (and current-prefix-arg
255 (gnus-summary-work-articles 1))))
256 (gnus-summary-followup arg t))
258 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
259 "Followup to the current mail message via news."
261 (gnus-summary-followup (gnus-summary-work-articles arg) t))
263 (defun gnus-inews-yank-articles (articles)
266 (while (setq article (pop articles))
267 (save-window-excursion
268 (set-buffer gnus-summary-buffer)
269 (gnus-summary-select-article nil nil nil article)
270 (gnus-summary-remove-process-mark article))
271 (gnus-copy-article-buffer)
272 (let ((message-reply-buffer gnus-article-copy)
273 (message-reply-headers gnus-current-headers))
274 (message-yank-original)
275 (setq beg (or beg (mark t))))
281 (defun gnus-summary-cancel-article (&optional n symp)
282 "Cancel an article you posted.
283 Uses the process-prefix convention. If given the symbolic
284 prefix `a', cancel using the standard posting method; if not
285 post using the current select method."
286 (interactive (gnus-interactive "P\ny"))
287 (let ((articles (gnus-summary-work-articles n))
290 (gnus-post-method (not (eq symp 'a)) ,gnus-newsgroup-name)))
292 (while (setq article (pop articles))
293 (when (gnus-summary-select-article t nil nil article)
294 (when (gnus-eval-in-buffer-window gnus-article-buffer
296 (set-buffer gnus-original-article-buffer)
297 (message-cancel-news)))
298 (gnus-summary-mark-as-read article gnus-canceled-mark)
299 (gnus-cache-remove-article 1))
300 (gnus-article-hide-headers-if-wanted))
301 (gnus-summary-remove-process-mark article))))
303 (defun gnus-summary-supersede-article ()
304 "Compose an article that will supersede a previous article.
305 This is done simply by taking the old article and adding a Supersedes
306 header line with the old Message-ID."
308 (let ((article (gnus-summary-article-number)))
309 (gnus-setup-message 'reply-yank
310 (gnus-summary-select-article t)
311 (set-buffer gnus-original-article-buffer)
315 (when (buffer-name (get-buffer ,gnus-summary-buffer))
317 (set-buffer (get-buffer ,gnus-summary-buffer))
318 (gnus-cache-possibly-remove-article ,article nil nil nil t)
319 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
320 message-send-actions))))
324 (defun gnus-copy-article-buffer (&optional article-buffer)
325 ;; make a copy of the article buffer with all text properties removed
326 ;; this copy is in the buffer gnus-article-copy.
327 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
328 ;; this buffer should be passed to all mail/news reply/post routines.
329 (setq gnus-article-copy (get-buffer-create " *gnus article copy*"))
330 (buffer-disable-undo gnus-article-copy)
331 (or (memq gnus-article-copy gnus-buffer-list)
332 (push gnus-article-copy gnus-buffer-list))
333 (let ((article-buffer (or article-buffer gnus-article-buffer))
335 (if (not (and (get-buffer article-buffer)
336 (buffer-name (get-buffer article-buffer))))
337 (error "Can't find any article buffer")
339 (set-buffer article-buffer)
341 ;; Copy over the (displayed) article buffer, delete
342 ;; hidden text and remove text properties.
344 (copy-to-buffer gnus-article-copy (point-min) (point-max))
345 (set-buffer gnus-article-copy)
346 (gnus-article-delete-text-of-type 'annotation)
347 (gnus-remove-text-with-property 'gnus-prev)
348 (gnus-remove-text-with-property 'gnus-next)
351 (format "%s" (buffer-string))
353 ;; Find the original headers.
354 (set-buffer gnus-original-article-buffer)
355 (goto-char (point-min))
356 (while (looking-at message-unix-mail-delimiter)
359 (setq end (or (search-forward "\n\n" nil t) (point)))
360 ;; Delete the headers from the displayed articles.
361 (set-buffer gnus-article-copy)
362 (delete-region (goto-char (point-min))
363 (or (search-forward "\n\n" nil t) (point)))
364 ;; Insert the original article headers.
365 (insert-buffer-substring gnus-original-article-buffer beg end)
366 (gnus-article-decode-rfc1522)))
369 (defun gnus-post-news (post &optional group header article-buffer yank subject
372 (gnus-copy-article-buffer))
373 (let ((gnus-article-reply article-buffer)
374 (add-to-list gnus-add-to-list))
375 (gnus-setup-message (cond (yank 'reply-yank)
376 (article-buffer 'reply)
378 (let* ((group (or group gnus-newsgroup-name))
380 to-address to-group mailing-list to-list
383 (setq to-address (gnus-group-find-parameter group 'to-address)
384 to-group (gnus-group-find-parameter group 'to-group)
385 to-list (gnus-group-find-parameter group 'to-list)
386 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
387 mailing-list (when gnus-mailing-list-groups
388 (string-match gnus-mailing-list-groups group))
389 group (gnus-group-real-name group)))
390 (if (or (and to-group
391 (gnus-news-group-p to-group))
394 (and (gnus-news-group-p
395 (or pgroup gnus-newsgroup-name)
396 (if header (mail-header-number header)
397 gnus-current-article))
403 (message-news (or to-group group))
404 (set-buffer gnus-article-copy)
405 (message-followup (if (or newsgroup-p force-news) nil to-group)))
409 (message-mail (or to-address to-list))
410 ;; Arrange for mail groups that have no `to-address' to
411 ;; get that when the user sends off the mail.
412 (when (and (not to-list)
415 (push (list 'gnus-inews-add-to-address pgroup)
416 message-send-actions)))
417 (set-buffer gnus-article-copy)
418 (message-wide-reply to-address
419 (gnus-group-find-parameter
420 gnus-newsgroup-name 'broken-reply-to))))
422 (gnus-inews-yank-articles yank))))))
424 (defun gnus-post-method (arg group &optional silent)
425 "Return the posting method based on GROUP and ARG.
426 If SILENT, don't prompt the user."
427 (let ((group-method (gnus-find-method-for-group group)))
429 ;; If the group-method is nil (which shouldn't happen) we use
430 ;; the default method.
432 (or gnus-post-method gnus-select-method message-post-method))
433 ;; We want this group's method.
434 ((and arg (not (eq arg 0)))
436 ;; We query the user for a post method.
438 (and gnus-post-method
439 (listp (car gnus-post-method))))
441 ;; Collect all methods we know about.
443 (when gnus-post-method
444 (if (listp (car gnus-post-method))
446 (list gnus-post-method)))
447 gnus-secondary-select-methods
448 (list gnus-select-method)
449 (list group-method)))
450 method-alist post-methods method)
451 ;; Weed out all mail methods.
453 (setq method (gnus-server-get-method "" (pop methods)))
454 (when (or (gnus-method-option-p method 'post)
455 (gnus-method-option-p method 'post-mail))
456 (push method post-methods)))
457 ;; Create a name-method alist.
461 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m))
466 (setq gnus-last-posting-server
468 gnus-last-posting-server)
469 ;; Just use the last value.
470 gnus-last-posting-server
472 "Posting method: " method-alist nil t
473 (cons (or gnus-last-posting-server "") 0))))
475 ;; Override normal method.
478 ;; Use the normal select method.
479 (t gnus-select-method))))
483 ;; Dummy to avoid byte-compile warning.
484 (defvar nnspool-rejected-article-hook)
485 (defvar xemacs-codename)
487 ;;; Since the X-Newsreader/X-Mailer are ``vanity'' headers, they might
488 ;;; as well include the Emacs version as well.
489 ;;; The following function works with later GNU Emacs, and XEmacs.
490 (defun gnus-extended-version ()
491 "Stringified Gnus version"
495 ;; Written by "Mr. Per Persson" <pp@gnu.ai.mit.edu>.
496 ;; (defun gnus-inews-insert-mime-headers ()
497 ;; "Insert MIME headers.
498 ;; Assumes ISO-Latin-1 is used iff 8-bit characters are present."
499 ;; (goto-char (point-min))
500 ;; (let ((mail-header-separator
502 ;; (goto-char (point-min))
503 ;; (if (and (search-forward (concat "\n" mail-header-separator "\n")
505 ;; (not (search-backward "\n\n" nil t)))
506 ;; mail-header-separator
508 ;; (or (mail-position-on-field "Mime-Version")
510 ;; (cond ((save-restriction
512 ;; (goto-char (point-min))
513 ;; (re-search-forward "[^\000-\177]" nil t))
514 ;; (or (mail-position-on-field "Content-Type")
515 ;; (insert "text/plain; charset=ISO-8859-1"))
516 ;; (or (mail-position-on-field "Content-Transfer-Encoding")
518 ;; (t (or (mail-position-on-field "Content-Type")
519 ;; (insert "text/plain; charset=US-ASCII"))
520 ;; (or (mail-position-on-field "Content-Transfer-Encoding")
521 ;; (insert "7bit")))))))
523 ;; (custom-add-option 'message-header-hook 'gnus-inews-insert-mime-headers)
527 ;;; Gnus Mail Functions
530 ;;; Mail reply commands of Gnus summary mode
532 (defun gnus-summary-reply (&optional yank wide)
533 "Start composing a reply mail to the current message.
534 If prefix argument YANK is non-nil, the original article is yanked
537 (list (and current-prefix-arg
538 (gnus-summary-work-articles 1))))
539 ;; Stripping headers should be specified with mail-yank-ignored-headers.
541 (gnus-summary-goto-subject (car yank)))
542 (let ((gnus-article-reply t))
543 (gnus-setup-message (if yank 'reply-yank 'reply)
544 (gnus-summary-select-article)
545 (set-buffer (gnus-copy-article-buffer))
546 (message-reply nil wide (gnus-group-find-parameter
547 gnus-newsgroup-name 'broken-reply-to))
549 (gnus-inews-yank-articles yank)))))
551 (defun gnus-summary-reply-with-original (n &optional wide)
552 "Start composing a reply mail to the current message.
553 The original article will be yanked."
555 (gnus-summary-reply (gnus-summary-work-articles n) wide))
557 (defun gnus-summary-wide-reply (&optional yank)
558 "Start composing a wide reply mail to the current message.
559 If prefix argument YANK is non-nil, the original article is yanked
562 (list (and current-prefix-arg
563 (gnus-summary-work-articles 1))))
564 (gnus-summary-reply yank t))
566 (defun gnus-summary-wide-reply-with-original (n)
567 "Start composing a wide reply mail to the current message.
568 The original article will be yanked."
570 (gnus-summary-reply-with-original n t))
572 (defun gnus-summary-mail-forward (&optional full-headers post)
573 "Forward the current message to another user.
574 If FULL-HEADERS (the prefix), include full headers when forwarding."
576 (gnus-setup-message 'forward
577 (gnus-summary-select-article)
578 (set-buffer gnus-original-article-buffer)
579 (let ((message-included-forward-headers
580 (if full-headers "" message-included-forward-headers)))
581 (message-forward post))))
583 (defun gnus-summary-resend-message (address n)
584 "Resend the current article to ADDRESS."
585 (interactive "sResend message(s) to: \nP")
586 (let ((articles (gnus-summary-work-articles n))
588 (while (setq article (pop articles))
589 (gnus-summary-select-article nil nil nil article)
591 (set-buffer gnus-original-article-buffer)
592 (message-resend address)))))
594 (defun gnus-summary-post-forward (&optional full-headers)
595 "Forward the current article to a newsgroup.
596 If FULL-HEADERS (the prefix), include full headers when forwarding."
598 (gnus-summary-mail-forward full-headers t))
600 (defvar gnus-nastygram-message
601 "The following article was inappropriately posted to %s.\n\n"
602 "Format string to insert in nastygrams.
603 The current group name will be inserted at \"%s\".")
605 (defun gnus-summary-mail-nastygram (n)
606 "Send a nastygram to the author of the current article."
608 (when (or gnus-expert-user
610 "Really send a nastygram to the author of the current article? "))
611 (let ((group gnus-newsgroup-name))
612 (gnus-summary-reply-with-original n)
613 (set-buffer gnus-message-buffer)
615 (insert (format gnus-nastygram-message group))
616 (message-send-and-exit))))
618 (defun gnus-summary-mail-crosspost-complaint (n)
619 "Send a complaint about crossposting to the current article(s)."
621 (let ((articles (gnus-summary-work-articles n))
623 (while (setq article (pop articles))
624 (set-buffer gnus-summary-buffer)
625 (gnus-summary-goto-subject article)
626 (let ((group (gnus-group-real-name gnus-newsgroup-name))
627 newsgroups followup-to)
628 (gnus-summary-select-article)
629 (set-buffer gnus-original-article-buffer)
630 (if (and (<= (length (message-tokenize-header
631 (setq newsgroups (mail-fetch-field "newsgroups"))
634 (or (not (setq followup-to (mail-fetch-field "followup-to")))
635 (not (member group (message-tokenize-header
636 followup-to ", ")))))
638 (gnus-message 1 "Followup-to restricted")
639 (gnus-message 1 "Not a crossposted article"))
640 (set-buffer gnus-summary-buffer)
641 (gnus-summary-reply-with-original 1)
642 (set-buffer gnus-message-buffer)
644 (insert (format gnus-crosspost-complaint newsgroups group))
645 (message-goto-subject)
646 (re-search-forward " *$")
647 (replace-match " (crosspost notification)" t t)
648 (gnus-deactivate-mark)
649 (when (gnus-y-or-n-p "Send this complaint? ")
650 (message-send-and-exit)))))))
652 (defun gnus-summary-mail-other-window ()
653 "Compose mail in other window."
655 (gnus-setup-message 'message
658 (defun gnus-mail-parse-comma-list ()
661 (skip-chars-forward " ")
664 (skip-chars-forward "^,")
669 (narrow-to-region beg (point))
672 (while (search-forward "\"" nil t)
676 (skip-chars-forward ",")
677 (skip-chars-forward "^,"))
678 (skip-chars-backward " ")
679 (push (buffer-substring beg (point))
681 (skip-chars-forward "^,")
682 (skip-chars-forward ", "))
685 (defun gnus-inews-add-to-address (group)
686 (let ((to-address (mail-fetch-field "to")))
687 (when (and to-address
689 ;; This mail group doesn't have a `to-list', so we add one
692 (format "Do you want to add this as `to-list': %s " to-address))
693 (gnus-group-add-parameter group (cons 'to-list to-address))))))
695 (defun gnus-put-message ()
696 "Put the current message in some group and return to Gnus."
698 (let ((reply gnus-article-reply)
699 (winconf gnus-prev-winconf)
700 (group gnus-newsgroup-name))
702 (or (and group (not (gnus-group-read-only-p group)))
703 (setq group (read-string "Put in group: " nil
704 (gnus-writable-groups))))
705 (when (gnus-gethash group gnus-newsrc-hashtb)
706 (error "No such group: %s" group))
711 (message-narrow-to-headers)
712 (let (gnus-deletable-headers)
714 (message-generate-headers message-required-news-headers)
715 (message-generate-headers message-required-mail-headers)))
716 (goto-char (point-max))
717 (insert "Gcc: " group "\n")
722 (when (get-buffer gnus-group-buffer)
723 (when (gnus-buffer-exists-p (car-safe reply))
724 (set-buffer (car reply))
726 (gnus-summary-mark-article-as-replied
729 (set-window-configuration winconf)))))
731 (defun gnus-article-mail (yank)
732 "Send a reply to the address near point.
733 If YANK is non-nil, include the original article."
737 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
738 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
740 (message-reply address)
742 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
744 (defvar nntp-server-type)
746 "Send a bug report to the Gnus maintainers."
748 (unless (gnus-alive-p)
749 (error "Gnus has been shut down"))
750 (gnus-setup-message 'bug
751 (delete-other-windows)
752 (switch-to-buffer (get-buffer-create "*Gnus Help Bug*"))
754 (insert gnus-bug-message)
755 (goto-char (point-min))
756 (message-pop-to-buffer "*Gnus Bug*")
757 (message-setup `((To . ,gnus-maintainer) (Subject . "")))
758 (push `(gnus-bug-kill-buffer) message-send-actions)
759 (goto-char (point-min))
760 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
762 (insert (gnus-version) "\n")
763 (insert (emacs-version) "\n")
764 (when (and (boundp 'nntp-server-type)
765 (stringp nntp-server-type))
766 (insert nntp-server-type))
767 (insert "\n\n\n\n\n")
769 (goto-char (point-min))
770 (search-forward "Subject: " nil t)
773 (defun gnus-bug-kill-buffer ()
774 (when (get-buffer "*Gnus Help Bug*")
775 (kill-buffer "*Gnus Help Bug*")))
778 "Attempts to go through the Gnus source file and report what variables have been changed.
779 The source file has to be in the Emacs load path."
781 (let ((files '("gnus.el" "gnus-sum.el" "gnus-group.el"
782 "gnus-art.el" "gnus-start.el" "gnus-async.el"
783 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
784 "nnmail.el" "message.el"))
787 (gnus-message 4 "Please wait while we snoop your variables...")
789 ;; Go through all the files looking for non-default values for variables.
791 (set-buffer (get-buffer-create " *gnus bug info*"))
792 (buffer-disable-undo (current-buffer))
795 (when (and (setq file (locate-library (pop files)))
796 (file-exists-p file))
797 (insert-file-contents file)
798 (goto-char (point-min))
799 (if (not (re-search-forward "^;;* *Internal variables" nil t))
800 (gnus-message 4 "Malformed sources in file %s" file)
801 (narrow-to-region (point-min) (point))
802 (goto-char (point-min))
803 (while (setq expr (ignore-errors (read (current-buffer))))
805 (and (or (eq (car expr) 'defvar)
806 (eq (car expr) 'defcustom))
807 (stringp (nth 3 expr))
808 (or (not (boundp (nth 1 expr)))
809 (not (equal (eval (nth 2 expr))
810 (symbol-value (nth 1 expr)))))
811 (push (nth 1 expr) olist)))))))
812 (kill-buffer (current-buffer)))
813 (when (setq olist (nreverse olist))
814 (insert "------------------ Environment follows ------------------\n\n"))
816 (if (boundp (car olist))
818 (pp `(setq ,(car olist)
819 ,(if (or (consp (setq sym (symbol-value (car olist))))
821 (not (or (eq sym nil)
823 (list 'quote (symbol-value (car olist)))
824 (symbol-value (car olist))))
827 (format "(setq %s 'whatever)\n" (car olist))))
828 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
829 (setq olist (cdr olist)))
831 ;; Remove any control chars - they seem to cause trouble for some
832 ;; mailers. (Byte-compiled output from the stuff above.)
834 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
835 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
838 ;;; Treatment of rejected articles.
841 (defun gnus-summary-resend-bounced-mail (&optional fetch)
842 "Re-mail the current message.
843 This only makes sense if the current message is a bounce message than
844 contains some mail you have written which has been bounced back to
846 If FETCH, try to fetch the article that this is a reply to, if indeed
849 (gnus-summary-select-article t)
850 (set-buffer gnus-original-article-buffer)
851 (gnus-setup-message 'compose-bounce
852 (let* ((references (mail-fetch-field "references"))
853 (parent (and references (gnus-parent-id references))))
855 ;; If there are references, we fetch the article we answered to.
857 (gnus-summary-refer-article parent)
858 (gnus-summary-show-all-headers)))))
862 ;; Do Gcc handling, which copied the message over to some group.
863 (defun gnus-inews-do-gcc (&optional gcc)
868 (message-narrow-to-headers)
869 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
870 (coding-system-for-write 'raw-text)
873 (message-remove-header "gcc")
875 (setq groups (message-tokenize-header gcc " ,"))
876 ;; Copy the article over to some group(s).
877 (while (setq group (pop groups))
880 (cond ((and (null (gnus-get-info group))
881 (eq (car gnus-message-archive-method)
883 (gnus-server-to-method
884 (gnus-group-method group)))))
885 ;; If the group doesn't exist, we assume
886 ;; it's an archive group...
887 gnus-message-archive-method)
889 ((gnus-info-method (gnus-get-info group))
890 (gnus-info-method (gnus-get-info group)))
892 (t (gnus-group-method group)))))
893 (gnus-check-server method)
894 (unless (gnus-request-group group t method)
895 (gnus-request-create-group group method))
897 (nnheader-set-temp-buffer " *acc*")
898 (insert-buffer-substring message-encoding-buffer)
899 (run-hooks 'gnus-before-do-gcc-hook)
900 (goto-char (point-min))
901 (when (re-search-forward
902 (concat "^" (regexp-quote mail-header-separator) "$")
904 (replace-match "" t t ))
905 (unless (gnus-request-accept-article group method t)
906 (gnus-message 1 "Couldn't store article in group %s: %s"
907 group (gnus-status-message method))
909 (kill-buffer (current-buffer))))))))))
911 (defun gnus-inews-insert-gcc ()
912 "Insert Gcc headers based on `gnus-outgoing-message-group'."
915 (message-narrow-to-headers)
916 (let* ((group gnus-outgoing-message-group)
918 ((gnus-functionp group)
920 ((or (stringp group) (list group))
924 (if (stringp gcc) gcc
925 (mapconcat 'identity gcc " "))
928 (defun gnus-inews-insert-archive-gcc (&optional group)
929 "Insert the Gcc to say where the article is to be archived."
930 (let* ((var gnus-message-archive-group)
931 (group (or group gnus-newsgroup-name ""))
933 (and gnus-newsgroup-name
934 (gnus-group-find-parameter
935 gnus-newsgroup-name 'gcc-self)))
939 ((null gnus-message-archive-method)
943 ;; Just a single group.
946 ;; We don't want this.
948 ((and (listp var) (stringp (car var)))
951 ((gnus-functionp var)
955 ;; An alist of regexps/functions/forms.
960 ((stringp (caar var))
962 (when (string-match (caar var) group)
964 ((gnus-functionp (car var))
966 (funcall (car var) group))
968 (eval (car var)))))))
969 (setq var (cdr var)))
972 (when (or groups gcc-self-val)
973 (when (stringp groups)
974 (setq groups (list groups)))
977 (message-narrow-to-headers)
978 (goto-char (point-max))
981 ;; Use the `gcc-self' param value instead.
984 (if (stringp gcc-self-val)
987 (if (not (eq gcc-self-val 'none))
992 ;; Use the list of groups.
993 (while (setq name (pop groups))
994 (insert (if (string-match ":" name)
996 (gnus-group-prefixed-name
997 name gnus-message-archive-method)))
1002 ;;; Allow redefinition of functions.
1008 ;;; gnus-msg.el ends here