1 ;;; gnus-msg.el --- mail and post interface for Open 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-sent-message-ids-file
71 (nnheader-concat gnus-directory "Sent-Message-IDs")
72 "File where Gnus saves a cache of sent message ids.")
74 (defvar gnus-sent-message-ids-length 1000
75 "The number of sent Message-IDs to save.")
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 `(let ((,winconf (current-window-configuration))
170 (,buffer (buffer-name (current-buffer)))
171 (,article (and gnus-article-reply (gnus-summary-article-number)))
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 ,gnus-newsgroup-name ,article))
183 (make-local-variable 'gnus-newsgroup-name)
184 (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 (buffer-name (get-buffer ,buffer))
200 (set-buffer (get-buffer ,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-article-buffer
303 (set-buffer gnus-original-article-buffer)
304 (message-cancel-news)))
305 (gnus-summary-mark-as-read article gnus-canceled-mark)
306 (gnus-cache-remove-article 1))
307 (gnus-article-hide-headers-if-wanted))
308 (gnus-summary-remove-process-mark article))))
310 (defun gnus-summary-supersede-article ()
311 "Compose an article that will supersede a previous article.
312 This is done simply by taking the old article and adding a Supersedes
313 header line with the old Message-ID."
315 (let ((article (gnus-summary-article-number)))
316 (gnus-setup-message 'reply-yank
317 (gnus-summary-select-article t)
318 (set-buffer gnus-original-article-buffer)
322 (when (buffer-name (get-buffer ,gnus-summary-buffer))
324 (set-buffer (get-buffer ,gnus-summary-buffer))
325 (gnus-cache-possibly-remove-article ,article nil nil nil t)
326 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
327 message-send-actions))))
331 (defun gnus-copy-article-buffer (&optional article-buffer)
332 ;; make a copy of the article buffer with all text properties removed
333 ;; this copy is in the buffer gnus-article-copy.
334 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
335 ;; this buffer should be passed to all mail/news reply/post routines.
336 (setq gnus-article-copy (get-buffer-create " *gnus article copy*"))
337 (buffer-disable-undo gnus-article-copy)
338 (or (memq gnus-article-copy gnus-buffer-list)
339 (push gnus-article-copy gnus-buffer-list))
340 (let ((article-buffer (or article-buffer gnus-article-buffer))
342 (if (not (and (get-buffer article-buffer)
343 (buffer-name (get-buffer article-buffer))))
344 (error "Can't find any article buffer")
346 (set-buffer article-buffer)
348 ;; Copy over the (displayed) article buffer, delete
349 ;; hidden text and remove text properties.
351 (copy-to-buffer gnus-article-copy (point-min) (point-max))
352 (set-buffer gnus-article-copy)
353 (gnus-article-delete-text-of-type 'annotation)
354 (gnus-remove-text-with-property 'gnus-prev)
355 (gnus-remove-text-with-property 'gnus-next)
358 (format "%s" (buffer-string))
360 ;; Find the original headers.
361 (set-buffer gnus-original-article-buffer)
362 (goto-char (point-min))
363 (while (looking-at message-unix-mail-delimiter)
366 (setq end (or (search-forward "\n\n" nil t) (point)))
367 ;; Delete the headers from the displayed articles.
368 (set-buffer gnus-article-copy)
369 (delete-region (goto-char (point-min))
370 (or (search-forward "\n\n" nil t) (point)))
371 ;; Insert the original article headers.
372 (insert-buffer-substring gnus-original-article-buffer beg end)
373 (gnus-article-decode-rfc1522)))
376 (defun gnus-post-news (post &optional group header article-buffer yank subject
379 (gnus-copy-article-buffer))
380 (let ((gnus-article-reply article-buffer)
381 (add-to-list gnus-add-to-list))
382 (gnus-setup-message (cond (yank 'reply-yank)
383 (article-buffer 'reply)
385 (let* ((group (or group gnus-newsgroup-name))
387 to-address to-group mailing-list to-list
390 (setq to-address (gnus-group-find-parameter group 'to-address)
391 to-group (gnus-group-find-parameter group 'to-group)
392 to-list (gnus-group-find-parameter group 'to-list)
393 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
394 mailing-list (when gnus-mailing-list-groups
395 (string-match gnus-mailing-list-groups group))
396 group (gnus-group-real-name group)))
397 (if (or (and to-group
398 (gnus-news-group-p to-group))
401 (and (gnus-news-group-p
402 (or pgroup gnus-newsgroup-name)
403 (if header (mail-header-number header)
404 gnus-current-article))
410 (message-news (or to-group group))
411 (set-buffer gnus-article-copy)
412 (message-followup (if (or newsgroup-p force-news) nil to-group)))
416 (message-mail (or to-address to-list))
417 ;; Arrange for mail groups that have no `to-address' to
418 ;; get that when the user sends off the mail.
419 (when (and (not to-list)
422 (push (list 'gnus-inews-add-to-address pgroup)
423 message-send-actions)))
424 (set-buffer gnus-article-copy)
425 (message-wide-reply to-address
426 (gnus-group-find-parameter
427 gnus-newsgroup-name 'broken-reply-to))))
429 (gnus-inews-yank-articles yank))))))
431 (defun gnus-post-method (arg group &optional silent)
432 "Return the posting method based on GROUP and ARG.
433 If SILENT, don't prompt the user."
434 (let ((group-method (gnus-find-method-for-group group)))
436 ;; If the group-method is nil (which shouldn't happen) we use
437 ;; the default method.
439 (or gnus-post-method gnus-select-method message-post-method))
440 ;; We want this group's method.
441 ((and arg (not (eq arg 0)))
443 ;; We query the user for a post method.
445 (and gnus-post-method
446 (listp (car gnus-post-method))))
448 ;; Collect all methods we know about.
450 (when gnus-post-method
451 (if (listp (car gnus-post-method))
453 (list gnus-post-method)))
454 gnus-secondary-select-methods
455 (list gnus-select-method)
456 (list group-method)))
457 method-alist post-methods method)
458 ;; Weed out all mail methods.
460 (setq method (gnus-server-get-method "" (pop methods)))
461 (when (or (gnus-method-option-p method 'post)
462 (gnus-method-option-p method 'post-mail))
463 (push method post-methods)))
464 ;; Create a name-method alist.
468 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m))
473 (setq gnus-last-posting-server
475 gnus-last-posting-server)
476 ;; Just use the last value.
477 gnus-last-posting-server
479 "Posting method: " method-alist nil t
480 (cons (or gnus-last-posting-server "") 0))))
482 ;; Override normal method.
485 ;; Use the normal select method.
486 (t gnus-select-method))))
489 ;;; Check whether the message has been sent already.
492 (defvar gnus-inews-sent-ids nil)
494 (defun gnus-inews-reject-message ()
495 "Check whether this message has already been sent."
496 (when gnus-sent-message-ids-file
497 (let ((message-id (save-restriction (message-narrow-to-headers)
498 (mail-fetch-field "message-id")))
501 (unless gnus-inews-sent-ids
504 (if (member message-id gnus-inews-sent-ids)
505 ;; Reject this message.
506 (not (gnus-yes-or-no-p
507 (format "Message %s already sent. Send anyway? "
509 (push message-id gnus-inews-sent-ids)
510 ;; Chop off the last Message-IDs.
511 (when (setq end (nthcdr gnus-sent-message-ids-length
512 gnus-inews-sent-ids))
514 (nnheader-temp-write gnus-sent-message-ids-file
515 (gnus-prin1 `(setq gnus-inews-sent-ids ',gnus-inews-sent-ids)))
520 ;; Dummy to avoid byte-compile warning.
521 (defvar nnspool-rejected-article-hook)
522 (defvar xemacs-codename)
524 ;;; Since the X-Newsreader/X-Mailer are ``vanity'' headers, they might
525 ;;; as well include the Emacs version as well.
526 ;;; The following function works with later GNU Emacs, and XEmacs.
527 (defun gnus-extended-version ()
528 "Stringified Gnus version"
532 ;; Written by "Mr. Per Persson" <pp@gnu.ai.mit.edu>.
533 (defun gnus-inews-insert-mime-headers ()
534 "Insert MIME headers.
535 Assumes ISO-Latin-1 is used iff 8-bit characters are present."
536 (goto-char (point-min))
537 (let ((mail-header-separator
539 (goto-char (point-min))
540 (if (and (search-forward (concat "\n" mail-header-separator "\n")
542 (not (search-backward "\n\n" nil t)))
543 mail-header-separator
545 (or (mail-position-on-field "Mime-Version")
547 (cond ((save-restriction
549 (goto-char (point-min))
550 (re-search-forward "[^\000-\177]" nil t))
551 (or (mail-position-on-field "Content-Type")
552 (insert "text/plain; charset=ISO-8859-1"))
553 (or (mail-position-on-field "Content-Transfer-Encoding")
555 (t (or (mail-position-on-field "Content-Type")
556 (insert "text/plain; charset=US-ASCII"))
557 (or (mail-position-on-field "Content-Transfer-Encoding")
558 (insert "7bit")))))))
560 (custom-add-option 'message-header-hook 'gnus-inews-insert-mime-headers)
564 ;;; Gnus Mail Functions
567 ;;; Mail reply commands of Gnus summary mode
569 (defun gnus-summary-reply (&optional yank wide)
570 "Start composing a reply mail to the current message.
571 If prefix argument YANK is non-nil, the original article is yanked
574 (list (and current-prefix-arg
575 (gnus-summary-work-articles 1))))
576 ;; Stripping headers should be specified with mail-yank-ignored-headers.
578 (gnus-summary-goto-subject (car yank)))
579 (let ((gnus-article-reply t))
580 (gnus-setup-message (if yank 'reply-yank 'reply)
581 (gnus-summary-select-article)
582 (set-buffer (gnus-copy-article-buffer))
583 (message-reply nil wide (gnus-group-find-parameter
584 gnus-newsgroup-name 'broken-reply-to))
586 (gnus-inews-yank-articles yank)))))
588 (defun gnus-summary-reply-with-original (n &optional wide)
589 "Start composing a reply mail to the current message.
590 The original article will be yanked."
592 (gnus-summary-reply (gnus-summary-work-articles n) wide))
594 (defun gnus-summary-wide-reply (&optional yank)
595 "Start composing a wide reply mail to the current message.
596 If prefix argument YANK is non-nil, the original article is yanked
599 (list (and current-prefix-arg
600 (gnus-summary-work-articles 1))))
601 (gnus-summary-reply yank t))
603 (defun gnus-summary-wide-reply-with-original (n)
604 "Start composing a wide reply mail to the current message.
605 The original article will be yanked."
607 (gnus-summary-reply-with-original n t))
609 (defun gnus-summary-mail-forward (&optional full-headers post)
610 "Forward the current message to another user.
611 If FULL-HEADERS (the prefix), include full headers when forwarding."
613 (gnus-setup-message 'forward
614 (gnus-summary-select-article)
615 (set-buffer gnus-original-article-buffer)
616 (let ((message-included-forward-headers
617 (if full-headers "" message-included-forward-headers)))
618 (message-forward post))))
620 (defun gnus-summary-resend-message (address n)
621 "Resend the current article to ADDRESS."
622 (interactive "sResend message(s) to: \nP")
623 (let ((articles (gnus-summary-work-articles n))
625 (while (setq article (pop articles))
626 (gnus-summary-select-article nil nil nil article)
628 (set-buffer gnus-original-article-buffer)
629 (message-resend address)))))
631 (defun gnus-summary-post-forward (&optional full-headers)
632 "Forward the current article to a newsgroup.
633 If FULL-HEADERS (the prefix), include full headers when forwarding."
635 (gnus-summary-mail-forward full-headers t))
637 (defvar gnus-nastygram-message
638 "The following article was inappropriately posted to %s.\n\n"
639 "Format string to insert in nastygrams.
640 The current group name will be inserted at \"%s\".")
642 (defun gnus-summary-mail-nastygram (n)
643 "Send a nastygram to the author of the current article."
645 (when (or gnus-expert-user
647 "Really send a nastygram to the author of the current article? "))
648 (let ((group gnus-newsgroup-name))
649 (gnus-summary-reply-with-original n)
650 (set-buffer gnus-message-buffer)
652 (insert (format gnus-nastygram-message group))
653 (message-send-and-exit))))
655 (defun gnus-summary-mail-crosspost-complaint (n)
656 "Send a complaint about crossposting to the current article(s)."
658 (let ((articles (gnus-summary-work-articles n))
660 (while (setq article (pop articles))
661 (set-buffer gnus-summary-buffer)
662 (gnus-summary-goto-subject article)
663 (let ((group (gnus-group-real-name gnus-newsgroup-name))
664 newsgroups followup-to)
665 (gnus-summary-select-article)
666 (set-buffer gnus-original-article-buffer)
667 (if (and (<= (length (message-tokenize-header
668 (setq newsgroups (mail-fetch-field "newsgroups"))
671 (or (not (setq followup-to (mail-fetch-field "followup-to")))
672 (not (member group (message-tokenize-header
673 followup-to ", ")))))
675 (gnus-message 1 "Followup-to restricted")
676 (gnus-message 1 "Not a crossposted article"))
677 (set-buffer gnus-summary-buffer)
678 (gnus-summary-reply-with-original 1)
679 (set-buffer gnus-message-buffer)
681 (insert (format gnus-crosspost-complaint newsgroups group))
682 (message-goto-subject)
683 (re-search-forward " *$")
684 (replace-match " (crosspost notification)" t t)
685 (gnus-deactivate-mark)
686 (when (gnus-y-or-n-p "Send this complaint? ")
687 (message-send-and-exit)))))))
689 (defun gnus-summary-mail-other-window ()
690 "Compose mail in other window."
692 (gnus-setup-message 'message
695 (defun gnus-mail-parse-comma-list ()
698 (skip-chars-forward " ")
701 (skip-chars-forward "^,")
706 (narrow-to-region beg (point))
709 (while (search-forward "\"" nil t)
713 (skip-chars-forward ",")
714 (skip-chars-forward "^,"))
715 (skip-chars-backward " ")
716 (push (buffer-substring beg (point))
718 (skip-chars-forward "^,")
719 (skip-chars-forward ", "))
722 (defun gnus-inews-add-to-address (group)
723 (let ((to-address (mail-fetch-field "to")))
724 (when (and to-address
726 ;; This mail group doesn't have a `to-list', so we add one
729 (format "Do you want to add this as `to-list': %s " to-address))
730 (gnus-group-add-parameter group (cons 'to-list to-address))))))
732 (defun gnus-put-message ()
733 "Put the current message in some group and return to Gnus."
735 (let ((reply gnus-article-reply)
736 (winconf gnus-prev-winconf)
737 (group gnus-newsgroup-name))
739 (or (and group (not (gnus-group-read-only-p group)))
740 (setq group (read-string "Put in group: " nil
741 (gnus-writable-groups))))
742 (when (gnus-gethash group gnus-newsrc-hashtb)
743 (error "No such group: %s" group))
748 (message-narrow-to-headers)
749 (let (gnus-deletable-headers)
751 (message-generate-headers message-required-news-headers)
752 (message-generate-headers message-required-mail-headers)))
753 (goto-char (point-max))
754 (insert "Gcc: " group "\n")
759 (when (get-buffer gnus-group-buffer)
760 (when (gnus-buffer-exists-p (car-safe reply))
761 (set-buffer (car reply))
763 (gnus-summary-mark-article-as-replied
766 (set-window-configuration winconf)))))
768 (defun gnus-article-mail (yank)
769 "Send a reply to the address near point.
770 If YANK is non-nil, include the original article."
774 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
775 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
777 (message-reply address)
779 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
781 (defvar nntp-server-type)
783 "Send a bug report to the Gnus maintainers."
785 (unless (gnus-alive-p)
786 (error "Gnus has been shut down"))
787 (gnus-setup-message 'bug
788 (delete-other-windows)
789 (switch-to-buffer (get-buffer-create "*Gnus Help Bug*"))
791 (insert gnus-bug-message)
792 (goto-char (point-min))
793 (message-pop-to-buffer "*Gnus Bug*")
794 (message-setup `((To . ,gnus-maintainer) (Subject . "")))
795 (push `(gnus-bug-kill-buffer) message-send-actions)
796 (goto-char (point-min))
797 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
799 (insert (gnus-version) "\n")
800 (insert (emacs-version) "\n")
801 (when (and (boundp 'nntp-server-type)
802 (stringp nntp-server-type))
803 (insert nntp-server-type))
804 (insert "\n\n\n\n\n")
806 (goto-char (point-min))
807 (search-forward "Subject: " nil t)
810 (defun gnus-bug-kill-buffer ()
811 (when (get-buffer "*Gnus Help Bug*")
812 (kill-buffer "*Gnus Help Bug*")))
815 "Attempts to go through the Gnus source file and report what variables have been changed.
816 The source file has to be in the Emacs load path."
818 (let ((files '("gnus.el" "gnus-sum.el" "gnus-group.el"
819 "gnus-art.el" "gnus-start.el" "gnus-async.el"
820 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
821 "nnmail.el" "message.el"))
824 (gnus-message 4 "Please wait while we snoop your variables...")
826 ;; Go through all the files looking for non-default values for variables.
828 (set-buffer (get-buffer-create " *gnus bug info*"))
829 (buffer-disable-undo (current-buffer))
832 (when (and (setq file (locate-library (pop files)))
833 (file-exists-p file))
834 (insert-file-contents file)
835 (goto-char (point-min))
836 (if (not (re-search-forward "^;;* *Internal variables" nil t))
837 (gnus-message 4 "Malformed sources in file %s" file)
838 (narrow-to-region (point-min) (point))
839 (goto-char (point-min))
840 (while (setq expr (ignore-errors (read (current-buffer))))
842 (and (or (eq (car expr) 'defvar)
843 (eq (car expr) 'defcustom))
844 (stringp (nth 3 expr))
845 (or (not (boundp (nth 1 expr)))
846 (not (equal (eval (nth 2 expr))
847 (symbol-value (nth 1 expr)))))
848 (push (nth 1 expr) olist)))))))
849 (kill-buffer (current-buffer)))
850 (when (setq olist (nreverse olist))
851 (insert "------------------ Environment follows ------------------\n\n"))
853 (if (boundp (car olist))
855 (pp `(setq ,(car olist)
856 ,(if (or (consp (setq sym (symbol-value (car olist))))
858 (not (or (eq sym nil)
860 (list 'quote (symbol-value (car olist)))
861 (symbol-value (car olist))))
864 (format "(setq %s 'whatever)\n" (car olist))))
865 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
866 (setq olist (cdr olist)))
868 ;; Remove any control chars - they seem to cause trouble for some
869 ;; mailers. (Byte-compiled output from the stuff above.)
871 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
872 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
875 ;;; Treatment of rejected articles.
878 (defun gnus-summary-resend-bounced-mail (&optional fetch)
879 "Re-mail the current message.
880 This only makes sense if the current message is a bounce message than
881 contains some mail you have written which has been bounced back to
883 If FETCH, try to fetch the article that this is a reply to, if indeed
886 (gnus-summary-select-article t)
887 (set-buffer gnus-original-article-buffer)
888 (gnus-setup-message 'compose-bounce
889 (let* ((references (mail-fetch-field "references"))
890 (parent (and references (gnus-parent-id references))))
892 ;; If there are references, we fetch the article we answered to.
894 (gnus-summary-refer-article parent)
895 (gnus-summary-show-all-headers)))))
899 ;; Do Gcc handling, which copied the message over to some group.
900 (defun gnus-inews-do-gcc (&optional gcc)
905 (message-narrow-to-headers)
906 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
907 (coding-system-for-write 'raw-text)
910 (message-remove-header "gcc")
912 (setq groups (message-tokenize-header gcc " ,"))
913 ;; Copy the article over to some group(s).
914 (while (setq group (pop groups))
917 (cond ((and (null (gnus-get-info group))
918 (eq (car gnus-message-archive-method)
920 (gnus-server-to-method
921 (gnus-group-method group)))))
922 ;; If the group doesn't exist, we assume
923 ;; it's an archive group...
924 gnus-message-archive-method)
926 ((gnus-info-method (gnus-get-info group))
927 (gnus-info-method (gnus-get-info group)))
929 (t (gnus-group-method group)))))
930 (gnus-check-server method)
931 (unless (gnus-request-group group t method)
932 (gnus-request-create-group group method))
934 (nnheader-set-temp-buffer " *acc*")
935 (insert-buffer-substring message-encoding-buffer)
936 (run-hooks 'gnus-before-do-gcc-hook)
937 (goto-char (point-min))
938 (when (re-search-forward
939 (concat "^" (regexp-quote mail-header-separator) "$")
941 (replace-match "" t t ))
942 (unless (gnus-request-accept-article group method t)
943 (gnus-message 1 "Couldn't store article in group %s: %s"
944 group (gnus-status-message method))
946 (kill-buffer (current-buffer))))))))))
948 (defun gnus-inews-insert-gcc ()
949 "Insert Gcc headers based on `gnus-outgoing-message-group'."
952 (message-narrow-to-headers)
953 (let* ((group gnus-outgoing-message-group)
955 ((gnus-functionp group)
957 ((or (stringp group) (list group))
961 (if (stringp gcc) gcc
962 (mapconcat 'identity gcc " "))
965 (defun gnus-inews-insert-archive-gcc (&optional group)
966 "Insert the Gcc to say where the article is to be archived."
967 (let* ((var gnus-message-archive-group)
968 (group (or group gnus-newsgroup-name ""))
970 (and gnus-newsgroup-name
971 (gnus-group-find-parameter
972 gnus-newsgroup-name 'gcc-self)))
976 ((null gnus-message-archive-method)
980 ;; Just a single group.
983 ;; We don't want this.
985 ((and (listp var) (stringp (car var)))
988 ((gnus-functionp var)
992 ;; An alist of regexps/functions/forms.
997 ((stringp (caar var))
999 (when (string-match (caar var) group)
1001 ((gnus-functionp (car var))
1003 (funcall (car var) group))
1005 (eval (car var)))))))
1006 (setq var (cdr var)))
1009 (when (or groups gcc-self-val)
1010 (when (stringp groups)
1011 (setq groups (list groups)))
1014 (message-narrow-to-headers)
1015 (goto-char (point-max))
1018 ;; Use the `gcc-self' param value instead.
1021 (if (stringp gcc-self-val)
1024 (if (not (eq gcc-self-val 'none))
1029 ;; Use the list of groups.
1030 (while (setq name (pop groups))
1031 (insert (if (string-match ":" name)
1033 (gnus-group-prefixed-name
1034 name gnus-message-archive-method)))
1039 (gnus-add-shutdown 'gnus-inews-close 'gnus)
1041 (defun gnus-inews-close ()
1042 (setq gnus-inews-sent-ids nil))
1044 ;;; Allow redefinition of functions.
1050 ;;; gnus-msg.el ends here