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 ;; Added by Sudish Joseph <joseph@cis.ohio-state.edu>.
37 (defvar gnus-post-method nil
38 "*Preferred method for posting USENET news.
39 If this variable is nil, Gnus will use the current method to decide
40 which method to use when posting. If it is non-nil, it will override
41 the current method. This method will not be used in mail groups and
42 the like, only in \"real\" newsgroups.
44 The value must be a valid method as discussed in the documentation of
45 `gnus-select-method'. It can also be a list of methods. If that is
46 the case, the user will be queried for what select method to use when
49 (defvar gnus-outgoing-message-group nil
50 "*All outgoing messages will be put in this group.
51 If you want to store all your outgoing mail and articles in the group
52 \"nnml:archive\", you set this variable to that value. This variable
53 can also be a list of group names.
55 If you want to have greater control over what group to put each
56 message in, you can set this variable to a function that checks the
57 current newsgroup name and then returns a suitable group name (or list
60 (defvar gnus-mailing-list-groups nil
61 "*Regexp matching groups that are really mailing lists.
62 This is useful when you're reading a mailing list that has been
63 gatewayed to a newsgroup, and you want to followup to an article in
66 (defvar gnus-add-to-list nil
67 "*If non-nil, add a `to-list' parameter automatically.")
69 (defvar gnus-crosspost-complaint
72 You posted the article below with the following Newsgroups header:
76 The %s group, at least, was an inappropriate recipient
77 of this message. Please trim your Newsgroups header to exclude this
78 group before posting in the future.
83 "Format string to be inserted when complaining about crossposts.
84 The first %s will be replaced by the Newsgroups header;
85 the second with the current group name.")
87 (defvar gnus-message-setup-hook nil
88 "Hook run after setting up a message buffer.")
90 ;;; Internal variables.
92 (defvar gnus-message-buffer "*Mail Gnus*")
93 (defvar gnus-article-copy nil)
94 (defvar gnus-last-posting-server nil)
95 (defvar gnus-message-group-art nil)
97 (defconst gnus-bug-message
98 "Sending a bug report to the Gnus Towers.
99 ========================================
101 The buffer below is a mail buffer. When you press `C-c C-c', it will
102 be sent to the Gnus Bug Exterminators.
104 At the bottom of the buffer you'll see lots of variable settings.
105 Please do not delete those. They will tell the Bug People what your
106 environment is, so that it will be easier to locate the bugs.
108 If you have found a bug that makes Emacs go \"beep\", set
109 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
110 and include the backtrace in your bug report.
112 Please describe the bug in annoying, painstaking detail.
114 Thank you for your help in stamping out bugs.
118 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
119 (autoload 'news-setup "rnewspost")
120 (autoload 'news-reply-mode "rnewspost")
121 (autoload 'rmail-dont-reply-to "mail-utils")
122 (autoload 'rmail-output "rmailout"))
126 ;;; Gnus Posting Functions
129 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
130 "p" gnus-summary-post-news
131 "f" gnus-summary-followup
132 "F" gnus-summary-followup-with-original
133 "c" gnus-summary-cancel-article
134 "s" gnus-summary-supersede-article
135 "r" gnus-summary-reply
136 "R" gnus-summary-reply-with-original
137 "w" gnus-summary-wide-reply
138 "W" gnus-summary-wide-reply-with-original
139 "n" gnus-summary-followup-to-mail
140 "N" gnus-summary-followup-to-mail-with-original
141 "m" gnus-summary-mail-other-window
142 "u" gnus-uu-post-news
143 "\M-c" gnus-summary-mail-crosspost-complaint
144 "om" gnus-summary-mail-forward
145 "op" gnus-summary-post-forward
146 "Om" gnus-uu-digest-mail-forward
147 "Op" gnus-uu-digest-post-forward)
149 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
150 "b" gnus-summary-resend-bounced-mail
151 ;; "c" gnus-summary-send-draft
152 "r" gnus-summary-resend-message)
154 ;;; Internal functions.
156 (defvar gnus-article-reply nil)
157 (defmacro gnus-setup-message (config &rest forms)
158 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
159 (buffer (make-symbol "gnus-setup-message-buffer"))
160 (article (make-symbol "gnus-setup-message-article"))
161 (group (make-symbol "gnus-setup-message-group")))
162 `(let ((,winconf (current-window-configuration))
163 (,buffer (buffer-name (current-buffer)))
164 (,article (and gnus-article-reply (gnus-summary-article-number)))
165 (,group gnus-newsgroup-name)
166 (message-header-setup-hook
167 (copy-sequence message-header-setup-hook)))
168 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
169 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
173 (gnus-inews-add-send-actions ,winconf ,buffer ,article)
174 (setq gnus-message-buffer (current-buffer))
175 (set (make-local-variable 'gnus-message-group-art)
176 (cons ,group ,article))
177 (make-local-variable 'gnus-newsgroup-name)
178 (gnus-run-hooks 'gnus-message-setup-hook))
179 (gnus-configure-windows ,config t)
180 (set-buffer-modified-p nil))))
182 (defun gnus-inews-add-send-actions (winconf buffer article)
183 (make-local-hook 'message-sent-hook)
184 (add-hook 'message-sent-hook 'gnus-inews-do-gcc nil t)
185 (setq message-post-method
187 (gnus-post-method arg ,gnus-newsgroup-name)))
188 (setq message-newsreader (setq message-mailer (gnus-extended-version)))
190 `(set-window-configuration ,winconf) 'exit 'postpone 'kill)
192 `(when (buffer-name (get-buffer ,buffer))
194 (set-buffer (get-buffer ,buffer))
196 `(gnus-summary-mark-article-as-replied ,article))))
199 (put 'gnus-setup-message 'lisp-indent-function 1)
200 (put 'gnus-setup-message 'edebug-form-spec '(form body))
202 ;;; Post news commands of Gnus group mode and summary mode
204 (defun gnus-group-mail ()
205 "Start composing a mail."
207 (gnus-setup-message 'message
210 (defun gnus-group-post-news (&optional arg)
211 "Start composing a news message.
212 If ARG, post to the group under point.
213 If ARG is 1, prompt for a group name."
215 ;; Bind this variable here to make message mode hooks work ok.
216 (let ((gnus-newsgroup-name
218 (if (= 1 (prefix-numeric-value arg))
219 (completing-read "Newsgroup: " gnus-active-hashtb nil
220 (gnus-read-active-file-p))
221 (gnus-group-group-name))
223 (gnus-post-news 'post gnus-newsgroup-name)))
225 (defun gnus-summary-post-news ()
226 "Start composing a news message."
228 (gnus-post-news 'post gnus-newsgroup-name))
230 (defun gnus-summary-followup (yank &optional force-news)
231 "Compose a followup to an article.
232 If prefix argument YANK is non-nil, original article is yanked automatically."
234 (list (and current-prefix-arg
235 (gnus-summary-work-articles 1))))
237 (gnus-summary-goto-subject (car yank)))
238 (save-window-excursion
239 (gnus-summary-select-article))
240 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
241 (gnus-newsgroup-name gnus-newsgroup-name))
243 (gnus-post-news nil gnus-newsgroup-name
244 headers gnus-article-buffer
245 yank nil force-news)))
247 (defun gnus-summary-followup-with-original (n &optional force-news)
248 "Compose a followup to an article and include the original article."
250 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
252 (defun gnus-summary-followup-to-mail (&optional arg)
253 "Followup to the current mail message via news."
255 (list (and current-prefix-arg
256 (gnus-summary-work-articles 1))))
257 (gnus-summary-followup arg t))
259 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
260 "Followup to the current mail message via news."
262 (gnus-summary-followup (gnus-summary-work-articles arg) t))
264 (defun gnus-inews-yank-articles (articles)
267 (while (setq article (pop articles))
268 (save-window-excursion
269 (set-buffer gnus-summary-buffer)
270 (gnus-summary-select-article nil nil nil article)
271 (gnus-summary-remove-process-mark article))
272 (gnus-copy-article-buffer)
273 (let ((message-reply-buffer gnus-article-copy)
274 (message-reply-headers gnus-current-headers))
275 (message-yank-original)
276 (setq beg (or beg (mark t))))
282 (defun gnus-summary-cancel-article (&optional n symp)
283 "Cancel an article you posted.
284 Uses the process-prefix convention. If given the symbolic
285 prefix `a', cancel using the standard posting method; if not
286 post using the current select method."
287 (interactive (gnus-interactive "P\ny"))
288 (let ((articles (gnus-summary-work-articles n))
291 (gnus-post-method (not (eq symp 'a)) ,gnus-newsgroup-name)))
293 (while (setq article (pop articles))
294 (when (gnus-summary-select-article t nil nil article)
295 (when (gnus-eval-in-buffer-window gnus-original-article-buffer
296 (message-cancel-news))
297 (gnus-summary-mark-as-read article gnus-canceled-mark)
298 (gnus-cache-remove-article 1))
299 (gnus-article-hide-headers-if-wanted))
300 (gnus-summary-remove-process-mark article))))
302 (defun gnus-summary-supersede-article ()
303 "Compose an article that will supersede a previous article.
304 This is done simply by taking the old article and adding a Supersedes
305 header line with the old Message-ID."
307 (let ((article (gnus-summary-article-number)))
308 (gnus-setup-message 'reply-yank
309 (gnus-summary-select-article t)
310 (set-buffer gnus-original-article-buffer)
314 (when (buffer-name (get-buffer ,gnus-summary-buffer))
316 (set-buffer (get-buffer ,gnus-summary-buffer))
317 (gnus-cache-possibly-remove-article ,article nil nil nil t)
318 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
319 message-send-actions))))
323 (defun gnus-copy-article-buffer (&optional article-buffer)
324 ;; make a copy of the article buffer with all text properties removed
325 ;; this copy is in the buffer gnus-article-copy.
326 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
327 ;; this buffer should be passed to all mail/news reply/post routines.
328 (setq gnus-article-copy (get-buffer-create " *gnus article copy*"))
329 (buffer-disable-undo gnus-article-copy)
330 (or (memq gnus-article-copy gnus-buffer-list)
331 (push gnus-article-copy gnus-buffer-list))
332 (let ((article-buffer (or article-buffer gnus-article-buffer))
334 (if (not (and (get-buffer article-buffer)
335 (buffer-name (get-buffer article-buffer))))
336 (error "Can't find any article buffer")
338 (set-buffer article-buffer)
340 ;; Copy over the (displayed) article buffer, delete
341 ;; hidden text and remove text properties.
343 (copy-to-buffer gnus-article-copy (point-min) (point-max))
344 (set-buffer gnus-article-copy)
345 (gnus-article-delete-text-of-type 'annotation)
346 (gnus-remove-text-with-property 'gnus-prev)
347 (gnus-remove-text-with-property 'gnus-next)
350 (format "%s" (buffer-string))
352 ;; Find the original headers.
353 (set-buffer gnus-original-article-buffer)
354 (goto-char (point-min))
355 (while (looking-at message-unix-mail-delimiter)
358 (setq end (or (search-forward "\n\n" nil t) (point)))
359 ;; Delete the headers from the displayed articles.
360 (set-buffer gnus-article-copy)
361 (delete-region (goto-char (point-min))
362 (or (search-forward "\n\n" nil t) (point)))
363 ;; Insert the original article headers.
364 (insert-buffer-substring gnus-original-article-buffer beg end)
365 (gnus-article-decode-rfc1522)))
368 (defun gnus-post-news (post &optional group header article-buffer yank subject
371 (gnus-copy-article-buffer))
372 (let ((gnus-article-reply article-buffer)
373 (add-to-list gnus-add-to-list))
374 (gnus-setup-message (cond (yank 'reply-yank)
375 (article-buffer 'reply)
377 (let* ((group (or group gnus-newsgroup-name))
379 to-address to-group mailing-list to-list
382 (setq to-address (gnus-group-find-parameter group 'to-address)
383 to-group (gnus-group-find-parameter group 'to-group)
384 to-list (gnus-group-find-parameter group 'to-list)
385 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
386 mailing-list (when gnus-mailing-list-groups
387 (string-match gnus-mailing-list-groups group))
388 group (gnus-group-real-name group)))
389 (if (or (and to-group
390 (gnus-news-group-p to-group))
393 (and (gnus-news-group-p
394 (or pgroup gnus-newsgroup-name)
395 (if header (mail-header-number header)
396 gnus-current-article))
402 (message-news (or to-group group))
403 (set-buffer gnus-article-copy)
404 (message-followup (if (or newsgroup-p force-news) nil to-group)))
408 (message-mail (or to-address to-list))
409 ;; Arrange for mail groups that have no `to-address' to
410 ;; get that when the user sends off the mail.
411 (when (and (not to-list)
414 (push (list 'gnus-inews-add-to-address pgroup)
415 message-send-actions)))
416 (set-buffer gnus-article-copy)
417 (message-wide-reply to-address
418 (gnus-group-find-parameter
419 gnus-newsgroup-name 'broken-reply-to))))
421 (gnus-inews-yank-articles yank))))))
423 (defun gnus-post-method (arg group &optional silent)
424 "Return the posting method based on GROUP and ARG.
425 If SILENT, don't prompt the user."
426 (let ((group-method (gnus-find-method-for-group group)))
428 ;; If the group-method is nil (which shouldn't happen) we use
429 ;; the default method.
431 (or gnus-post-method gnus-select-method message-post-method))
432 ;; We want this group's method.
433 ((and arg (not (eq arg 0)))
435 ;; We query the user for a post method.
437 (and gnus-post-method
438 (listp (car gnus-post-method))))
440 ;; Collect all methods we know about.
442 (when gnus-post-method
443 (if (listp (car gnus-post-method))
445 (list gnus-post-method)))
446 gnus-secondary-select-methods
447 (list gnus-select-method)
448 (list group-method)))
449 method-alist post-methods method)
450 ;; Weed out all mail methods.
452 (setq method (gnus-server-get-method "" (pop methods)))
453 (when (or (gnus-method-option-p method 'post)
454 (gnus-method-option-p method 'post-mail))
455 (push method post-methods)))
456 ;; Create a name-method alist.
460 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m))
465 (setq gnus-last-posting-server
467 gnus-last-posting-server)
468 ;; Just use the last value.
469 gnus-last-posting-server
471 "Posting method: " method-alist nil t
472 (cons (or gnus-last-posting-server "") 0))))
474 ;; Override normal method.
477 ;; Use the normal select method.
478 (t gnus-select-method))))
482 ;; Dummy to avoid byte-compile warning.
483 (defvar nnspool-rejected-article-hook)
484 (defvar xemacs-codename)
486 ;;; Since the X-Newsreader/X-Mailer are ``vanity'' headers, they might
487 ;;; as well include the Emacs version as well.
488 ;;; The following function works with later GNU Emacs, and XEmacs.
489 (defun gnus-extended-version ()
490 "Stringified Gnus version and Emacs version"
496 ((string-match "^\\([0-9]+\\.[0-9]+\\)\\.[.0-9]+$" emacs-version)
497 (concat "Emacs " (substring emacs-version
500 ((string-match "\\([A-Z]*[Mm][Aa][Cc][Ss]\\)[^(]*\\(\\((beta.*)\\|'\\)\\)?"
502 (concat (substring emacs-version
505 (format " %d.%d" emacs-major-version emacs-minor-version)
506 (if (match-beginning 3)
507 (substring emacs-version
511 (if (boundp 'xemacs-codename)
512 (concat " - \"" xemacs-codename "\""))))
515 ;; Written by "Mr. Per Persson" <pp@gnu.ai.mit.edu>.
516 (defun gnus-inews-insert-mime-headers ()
517 "Insert MIME headers.
518 Assumes ISO-Latin-1 is used iff 8-bit characters are present."
519 (goto-char (point-min))
520 (let ((mail-header-separator
522 (goto-char (point-min))
523 (if (and (search-forward (concat "\n" mail-header-separator "\n")
525 (not (search-backward "\n\n" nil t)))
526 mail-header-separator
528 (or (mail-position-on-field "Mime-Version")
530 (cond ((save-restriction
532 (goto-char (point-min))
533 (re-search-forward "[^\000-\177]" nil t))
534 (or (mail-position-on-field "Content-Type")
535 (insert "text/plain; charset=ISO-8859-1"))
536 (or (mail-position-on-field "Content-Transfer-Encoding")
538 (t (or (mail-position-on-field "Content-Type")
539 (insert "text/plain; charset=US-ASCII"))
540 (or (mail-position-on-field "Content-Transfer-Encoding")
541 (insert "7bit")))))))
543 (custom-add-option 'message-header-hook 'gnus-inews-insert-mime-headers)
547 ;;; Gnus Mail Functions
550 ;;; Mail reply commands of Gnus summary mode
552 (defun gnus-summary-reply (&optional yank wide)
553 "Start composing a reply mail to the current message.
554 If prefix argument YANK is non-nil, the original article is yanked
557 (list (and current-prefix-arg
558 (gnus-summary-work-articles 1))))
559 ;; Stripping headers should be specified with mail-yank-ignored-headers.
561 (gnus-summary-goto-subject (car yank)))
562 (let ((gnus-article-reply t))
563 (gnus-setup-message (if yank 'reply-yank 'reply)
564 (gnus-summary-select-article)
565 (set-buffer (gnus-copy-article-buffer))
566 (message-reply nil wide (gnus-group-find-parameter
567 gnus-newsgroup-name 'broken-reply-to))
569 (gnus-inews-yank-articles yank)))))
571 (defun gnus-summary-reply-with-original (n &optional wide)
572 "Start composing a reply mail to the current message.
573 The original article will be yanked."
575 (gnus-summary-reply (gnus-summary-work-articles n) wide))
577 (defun gnus-summary-wide-reply (&optional yank)
578 "Start composing a wide reply mail to the current message.
579 If prefix argument YANK is non-nil, the original article is yanked
582 (list (and current-prefix-arg
583 (gnus-summary-work-articles 1))))
584 (gnus-summary-reply yank t))
586 (defun gnus-summary-wide-reply-with-original (n)
587 "Start composing a wide reply mail to the current message.
588 The original article will be yanked."
590 (gnus-summary-reply-with-original n t))
592 (defun gnus-summary-mail-forward (&optional full-headers post)
593 "Forward the current message to another user.
594 If FULL-HEADERS (the prefix), include full headers when forwarding."
596 (gnus-setup-message 'forward
597 (gnus-summary-select-article)
598 (set-buffer gnus-original-article-buffer)
599 (let ((message-included-forward-headers
600 (if full-headers "" message-included-forward-headers)))
601 (message-forward post))))
603 (defun gnus-summary-resend-message (address n)
604 "Resend the current article to ADDRESS."
605 (interactive "sResend message(s) to: \nP")
606 (let ((articles (gnus-summary-work-articles n))
608 (while (setq article (pop articles))
609 (gnus-summary-select-article nil nil nil article)
611 (set-buffer gnus-original-article-buffer)
612 (message-resend address)))))
614 (defun gnus-summary-post-forward (&optional full-headers)
615 "Forward the current article to a newsgroup.
616 If FULL-HEADERS (the prefix), include full headers when forwarding."
618 (gnus-summary-mail-forward full-headers t))
620 (defvar gnus-nastygram-message
621 "The following article was inappropriately posted to %s.\n\n"
622 "Format string to insert in nastygrams.
623 The current group name will be inserted at \"%s\".")
625 (defun gnus-summary-mail-nastygram (n)
626 "Send a nastygram to the author of the current article."
628 (when (or gnus-expert-user
630 "Really send a nastygram to the author of the current article? "))
631 (let ((group gnus-newsgroup-name))
632 (gnus-summary-reply-with-original n)
633 (set-buffer gnus-message-buffer)
635 (insert (format gnus-nastygram-message group))
636 (message-send-and-exit))))
638 (defun gnus-summary-mail-crosspost-complaint (n)
639 "Send a complaint about crossposting to the current article(s)."
641 (let ((articles (gnus-summary-work-articles n))
643 (while (setq article (pop articles))
644 (set-buffer gnus-summary-buffer)
645 (gnus-summary-goto-subject article)
646 (let ((group (gnus-group-real-name gnus-newsgroup-name))
647 newsgroups followup-to)
648 (gnus-summary-select-article)
649 (set-buffer gnus-original-article-buffer)
650 (if (and (<= (length (message-tokenize-header
651 (setq newsgroups (mail-fetch-field "newsgroups"))
654 (or (not (setq followup-to (mail-fetch-field "followup-to")))
655 (not (member group (message-tokenize-header
656 followup-to ", ")))))
658 (gnus-message 1 "Followup-to restricted")
659 (gnus-message 1 "Not a crossposted article"))
660 (set-buffer gnus-summary-buffer)
661 (gnus-summary-reply-with-original 1)
662 (set-buffer gnus-message-buffer)
664 (insert (format gnus-crosspost-complaint newsgroups group))
665 (message-goto-subject)
666 (re-search-forward " *$")
667 (replace-match " (crosspost notification)" t t)
668 (gnus-deactivate-mark)
669 (when (gnus-y-or-n-p "Send this complaint? ")
670 (message-send-and-exit)))))))
672 (defun gnus-summary-mail-other-window ()
673 "Compose mail in other window."
675 (gnus-setup-message 'message
678 (defun gnus-mail-parse-comma-list ()
681 (skip-chars-forward " ")
684 (skip-chars-forward "^,")
689 (narrow-to-region beg (point))
692 (while (search-forward "\"" nil t)
696 (skip-chars-forward ",")
697 (skip-chars-forward "^,"))
698 (skip-chars-backward " ")
699 (push (buffer-substring beg (point))
701 (skip-chars-forward "^,")
702 (skip-chars-forward ", "))
705 (defun gnus-inews-add-to-address (group)
706 (let ((to-address (mail-fetch-field "to")))
707 (when (and to-address
709 ;; This mail group doesn't have a `to-list', so we add one
712 (format "Do you want to add this as `to-list': %s " to-address))
713 (gnus-group-add-parameter group (cons 'to-list to-address))))))
715 (defun gnus-put-message ()
716 "Put the current message in some group and return to Gnus."
718 (let ((reply gnus-article-reply)
719 (winconf gnus-prev-winconf)
720 (group gnus-newsgroup-name))
722 (or (and group (not (gnus-group-read-only-p group)))
723 (setq group (read-string "Put in group: " nil
724 (gnus-writable-groups))))
725 (when (gnus-gethash group gnus-newsrc-hashtb)
726 (error "No such group: %s" group))
731 (message-narrow-to-headers)
732 (let (gnus-deletable-headers)
734 (message-generate-headers message-required-news-headers)
735 (message-generate-headers message-required-mail-headers)))
736 (goto-char (point-max))
737 (insert "Gcc: " group "\n")
742 (when (get-buffer gnus-group-buffer)
743 (when (gnus-buffer-exists-p (car-safe reply))
744 (set-buffer (car reply))
746 (gnus-summary-mark-article-as-replied
749 (set-window-configuration winconf)))))
751 (defun gnus-article-mail (yank)
752 "Send a reply to the address near point.
753 If YANK is non-nil, include the original article."
757 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
758 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
760 (message-reply address)
762 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
764 (defvar nntp-server-type)
766 "Send a bug report to the Gnus maintainers."
768 (unless (gnus-alive-p)
769 (error "Gnus has been shut down"))
770 (gnus-setup-message 'bug
771 (delete-other-windows)
772 (switch-to-buffer (get-buffer-create "*Gnus Help Bug*"))
774 (insert gnus-bug-message)
775 (goto-char (point-min))
776 (message-pop-to-buffer "*Gnus Bug*")
777 (message-setup `((To . ,gnus-maintainer) (Subject . "")))
778 (push `(gnus-bug-kill-buffer) message-send-actions)
779 (goto-char (point-min))
780 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
782 (insert (gnus-version) "\n")
783 (insert (emacs-version) "\n")
784 (when (and (boundp 'nntp-server-type)
785 (stringp nntp-server-type))
786 (insert nntp-server-type))
787 (insert "\n\n\n\n\n")
789 (goto-char (point-min))
790 (search-forward "Subject: " nil t)
793 (defun gnus-bug-kill-buffer ()
794 (when (get-buffer "*Gnus Help Bug*")
795 (kill-buffer "*Gnus Help Bug*")))
798 "Attempts to go through the Gnus source file and report what variables have been changed.
799 The source file has to be in the Emacs load path."
801 (let ((files '("gnus.el" "gnus-sum.el" "gnus-group.el"
802 "gnus-art.el" "gnus-start.el" "gnus-async.el"
803 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
804 "nnmail.el" "message.el"))
807 (gnus-message 4 "Please wait while we snoop your variables...")
809 ;; Go through all the files looking for non-default values for variables.
811 (set-buffer (get-buffer-create " *gnus bug info*"))
812 (buffer-disable-undo (current-buffer))
815 (when (and (setq file (locate-library (pop files)))
816 (file-exists-p file))
817 (insert-file-contents file)
818 (goto-char (point-min))
819 (if (not (re-search-forward "^;;* *Internal variables" nil t))
820 (gnus-message 4 "Malformed sources in file %s" file)
821 (narrow-to-region (point-min) (point))
822 (goto-char (point-min))
823 (while (setq expr (ignore-errors (read (current-buffer))))
825 (and (or (eq (car expr) 'defvar)
826 (eq (car expr) 'defcustom))
827 (stringp (nth 3 expr))
828 (or (not (boundp (nth 1 expr)))
829 (not (equal (eval (nth 2 expr))
830 (symbol-value (nth 1 expr)))))
831 (push (nth 1 expr) olist)))))))
832 (kill-buffer (current-buffer)))
833 (when (setq olist (nreverse olist))
834 (insert "------------------ Environment follows ------------------\n\n"))
836 (if (boundp (car olist))
838 (pp `(setq ,(car olist)
839 ,(if (or (consp (setq sym (symbol-value (car olist))))
841 (not (or (eq sym nil)
843 (list 'quote (symbol-value (car olist)))
844 (symbol-value (car olist))))
847 (format "(setq %s 'whatever)\n" (car olist))))
848 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
849 (setq olist (cdr olist)))
851 ;; Remove any control chars - they seem to cause trouble for some
852 ;; mailers. (Byte-compiled output from the stuff above.)
854 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
855 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
858 ;;; Treatment of rejected articles.
861 (defun gnus-summary-resend-bounced-mail (&optional fetch)
862 "Re-mail the current message.
863 This only makes sense if the current message is a bounce message than
864 contains some mail you have written which has been bounced back to
866 If FETCH, try to fetch the article that this is a reply to, if indeed
869 (gnus-summary-select-article t)
870 (set-buffer gnus-original-article-buffer)
871 (gnus-setup-message 'compose-bounce
872 (let* ((references (mail-fetch-field "references"))
873 (parent (and references (gnus-parent-id references))))
875 ;; If there are references, we fetch the article we answered to.
877 (gnus-summary-refer-article parent)
878 (gnus-summary-show-all-headers)))))
882 ;; Do Gcc handling, which copied the message over to some group.
883 (defun gnus-inews-do-gcc (&optional gcc)
888 (message-narrow-to-headers)
889 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
890 (cur (current-buffer))
893 (message-remove-header "gcc")
895 (setq groups (message-tokenize-header gcc " ,"))
896 ;; Copy the article over to some group(s).
897 (while (setq group (pop groups))
900 (cond ((and (null (gnus-get-info group))
901 (eq (car gnus-message-archive-method)
903 (gnus-server-to-method
904 (gnus-group-method group)))))
905 ;; If the group doesn't exist, we assume
906 ;; it's an archive group...
907 gnus-message-archive-method)
909 ((gnus-info-method (gnus-get-info group))
910 (gnus-info-method (gnus-get-info group)))
912 (t (gnus-group-method group)))))
913 (gnus-check-server method)
914 (unless (gnus-request-group group t method)
915 (gnus-request-create-group group method))
917 (nnheader-set-temp-buffer " *acc*")
918 (insert-buffer-substring cur)
919 (goto-char (point-min))
920 (when (re-search-forward
921 (concat "^" (regexp-quote mail-header-separator) "$")
923 (replace-match "" t t ))
924 (unless (gnus-request-accept-article group method t)
925 (gnus-message 1 "Couldn't store article in group %s: %s"
926 group (gnus-status-message method))
928 (kill-buffer (current-buffer))))))))))
930 (defun gnus-inews-insert-gcc ()
931 "Insert Gcc headers based on `gnus-outgoing-message-group'."
934 (message-narrow-to-headers)
935 (let* ((group gnus-outgoing-message-group)
937 ((gnus-functionp group)
939 ((or (stringp group) (list group))
943 (if (stringp gcc) gcc
944 (mapconcat 'identity gcc " "))
947 (defun gnus-inews-insert-archive-gcc (&optional group)
948 "Insert the Gcc to say where the article is to be archived."
949 (let* ((var gnus-message-archive-group)
950 (group (or group gnus-newsgroup-name ""))
952 (and gnus-newsgroup-name
953 (gnus-group-find-parameter
954 gnus-newsgroup-name 'gcc-self)))
958 ((null gnus-message-archive-method)
962 ;; Just a single group.
965 ;; We don't want this.
967 ((and (listp var) (stringp (car var)))
970 ((gnus-functionp var)
974 ;; An alist of regexps/functions/forms.
979 ((stringp (caar var))
981 (when (string-match (caar var) group)
983 ((gnus-functionp (car var))
985 (funcall (car var) group))
987 (eval (car var)))))))
988 (setq var (cdr var)))
991 (when (or groups gcc-self-val)
992 (when (stringp groups)
993 (setq groups (list groups)))
996 (message-narrow-to-headers)
997 (goto-char (point-max))
1000 ;; Use the `gcc-self' param value instead.
1003 (if (stringp gcc-self-val)
1006 (if (not (eq gcc-self-val 'none))
1011 ;; Use the list of groups.
1012 (while (setq name (pop groups))
1013 (insert (if (string-match ":" name)
1015 (gnus-group-prefixed-name
1016 name gnus-message-archive-method)))
1021 ;;; Allow redefinition of functions.
1027 ;;; gnus-msg.el ends here