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
223 (let ((gnus-newsgroup-name
225 (if (= 1 (prefix-numeric-value arg))
226 (completing-read "Newsgroup: " gnus-active-hashtb nil
227 (gnus-read-active-file-p))
228 (gnus-group-group-name))
230 (gnus-post-news 'post gnus-newsgroup-name)))
232 (defun gnus-summary-post-news ()
233 "Start composing a news message."
235 (gnus-post-news 'post gnus-newsgroup-name))
237 (defun gnus-summary-followup (yank &optional force-news)
238 "Compose a followup to an article.
239 If prefix argument YANK is non-nil, original article is yanked automatically."
241 (list (and current-prefix-arg
242 (gnus-summary-work-articles 1))))
244 (gnus-summary-goto-subject (car yank)))
245 (save-window-excursion
246 (gnus-summary-select-article))
247 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
248 (gnus-newsgroup-name gnus-newsgroup-name))
250 (gnus-post-news nil gnus-newsgroup-name
251 headers gnus-article-buffer
252 yank nil force-news)))
254 (defun gnus-summary-followup-with-original (n &optional force-news)
255 "Compose a followup to an article and include the original article."
257 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
259 (defun gnus-summary-followup-to-mail (&optional arg)
260 "Followup to the current mail message via news."
262 (list (and current-prefix-arg
263 (gnus-summary-work-articles 1))))
264 (gnus-summary-followup arg t))
266 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
267 "Followup to the current mail message via news."
269 (gnus-summary-followup (gnus-summary-work-articles arg) t))
271 (defun gnus-inews-yank-articles (articles)
274 (while (setq article (pop articles))
275 (save-window-excursion
276 (set-buffer gnus-summary-buffer)
277 (gnus-summary-select-article nil nil nil article)
278 (gnus-summary-remove-process-mark article))
279 (gnus-copy-article-buffer)
280 (let ((message-reply-buffer gnus-article-copy)
281 (message-reply-headers gnus-current-headers))
282 (message-yank-original)
283 (setq beg (or beg (mark t))))
289 (defun gnus-summary-cancel-article (&optional n symp)
290 "Cancel an article you posted.
291 Uses the process-prefix convention. If given the symbolic
292 prefix `a', cancel using the standard posting method; if not
293 post using the current select method."
294 (interactive (gnus-interactive "P\ny"))
295 (let ((articles (gnus-summary-work-articles n))
298 (gnus-post-method (not (eq symp 'a)) ,gnus-newsgroup-name)))
300 (while (setq article (pop articles))
301 (when (gnus-summary-select-article t nil nil article)
302 (when (gnus-eval-in-buffer-window gnus-article-buffer
304 (set-buffer gnus-original-article-buffer)
305 (message-cancel-news)))
306 (gnus-summary-mark-as-read article gnus-canceled-mark)
307 (gnus-cache-remove-article 1))
308 (gnus-article-hide-headers-if-wanted))
309 (gnus-summary-remove-process-mark article))))
311 (defun gnus-summary-supersede-article ()
312 "Compose an article that will supersede a previous article.
313 This is done simply by taking the old article and adding a Supersedes
314 header line with the old Message-ID."
316 (let ((article (gnus-summary-article-number)))
317 (gnus-setup-message 'reply-yank
318 (gnus-summary-select-article t)
319 (set-buffer gnus-original-article-buffer)
323 (when (buffer-name (get-buffer ,gnus-summary-buffer))
325 (set-buffer (get-buffer ,gnus-summary-buffer))
326 (gnus-cache-possibly-remove-article ,article nil nil nil t)
327 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
328 message-send-actions))))
332 (defun gnus-copy-article-buffer (&optional article-buffer)
333 ;; make a copy of the article buffer with all text properties removed
334 ;; this copy is in the buffer gnus-article-copy.
335 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
336 ;; this buffer should be passed to all mail/news reply/post routines.
337 (setq gnus-article-copy (get-buffer-create " *gnus article copy*"))
338 (buffer-disable-undo gnus-article-copy)
339 (or (memq gnus-article-copy gnus-buffer-list)
340 (push gnus-article-copy gnus-buffer-list))
341 (let ((article-buffer (or article-buffer gnus-article-buffer))
343 (if (not (and (get-buffer article-buffer)
344 (buffer-name (get-buffer article-buffer))))
345 (error "Can't find any article buffer")
347 (set-buffer article-buffer)
349 ;; Copy over the (displayed) article buffer, delete
350 ;; hidden text and remove text properties.
352 (copy-to-buffer gnus-article-copy (point-min) (point-max))
353 (set-buffer gnus-article-copy)
354 (gnus-article-delete-text-of-type 'annotation)
355 (gnus-remove-text-with-property 'gnus-prev)
356 (gnus-remove-text-with-property 'gnus-next)
359 (format "%s" (buffer-string))
361 ;; Find the original headers.
362 (set-buffer gnus-original-article-buffer)
363 (goto-char (point-min))
364 (while (looking-at message-unix-mail-delimiter)
367 (setq end (or (search-forward "\n\n" nil t) (point)))
368 ;; Delete the headers from the displayed articles.
369 (set-buffer gnus-article-copy)
370 (delete-region (goto-char (point-min))
371 (or (search-forward "\n\n" nil t) (point)))
372 ;; Insert the original article headers.
373 (insert-buffer-substring gnus-original-article-buffer beg end)
374 (gnus-article-decode-rfc1522)))
377 (defun gnus-post-news (post &optional group header article-buffer yank subject
380 (gnus-copy-article-buffer))
381 (let ((gnus-article-reply article-buffer)
382 (add-to-list gnus-add-to-list))
383 (gnus-setup-message (cond (yank 'reply-yank)
384 (article-buffer 'reply)
386 (let* ((group (or group gnus-newsgroup-name))
388 to-address to-group mailing-list to-list
391 (setq to-address (gnus-group-find-parameter group 'to-address)
392 to-group (gnus-group-find-parameter group 'to-group)
393 to-list (gnus-group-find-parameter group 'to-list)
394 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
395 mailing-list (when gnus-mailing-list-groups
396 (string-match gnus-mailing-list-groups group))
397 group (gnus-group-real-name group)))
398 (if (or (and to-group
399 (gnus-news-group-p to-group))
402 (and (gnus-news-group-p
403 (or pgroup gnus-newsgroup-name)
404 (if header (mail-header-number header)
405 gnus-current-article))
411 (message-news (or to-group group))
412 (set-buffer gnus-article-copy)
413 (message-followup (if (or newsgroup-p force-news) nil to-group)))
417 (message-mail (or to-address to-list))
418 ;; Arrange for mail groups that have no `to-address' to
419 ;; get that when the user sends off the mail.
420 (when (and (not to-list)
423 (push (list 'gnus-inews-add-to-address pgroup)
424 message-send-actions)))
425 (set-buffer gnus-article-copy)
426 (message-wide-reply to-address
427 (gnus-group-find-parameter
428 gnus-newsgroup-name 'broken-reply-to))))
430 (gnus-inews-yank-articles yank))))))
432 (defun gnus-post-method (arg group &optional silent)
433 "Return the posting method based on GROUP and ARG.
434 If SILENT, don't prompt the user."
435 (let ((group-method (gnus-find-method-for-group group)))
437 ;; If the group-method is nil (which shouldn't happen) we use
438 ;; the default method.
440 (or gnus-post-method gnus-select-method message-post-method))
441 ;; We want this group's method.
442 ((and arg (not (eq arg 0)))
444 ;; We query the user for a post method.
446 (and gnus-post-method
447 (listp (car gnus-post-method))))
449 ;; Collect all methods we know about.
451 (when gnus-post-method
452 (if (listp (car gnus-post-method))
454 (list gnus-post-method)))
455 gnus-secondary-select-methods
456 (list gnus-select-method)
457 (list group-method)))
458 method-alist post-methods method)
459 ;; Weed out all mail methods.
461 (setq method (gnus-server-get-method "" (pop methods)))
462 (when (or (gnus-method-option-p method 'post)
463 (gnus-method-option-p method 'post-mail))
464 (push method post-methods)))
465 ;; Create a name-method alist.
469 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m))
474 (setq gnus-last-posting-server
476 gnus-last-posting-server)
477 ;; Just use the last value.
478 gnus-last-posting-server
480 "Posting method: " method-alist nil t
481 (cons (or gnus-last-posting-server "") 0))))
483 ;; Override normal method.
486 ;; Use the normal select method.
487 (t gnus-select-method))))
490 ;;; Check whether the message has been sent already.
493 (defvar gnus-inews-sent-ids nil)
495 (defun gnus-inews-reject-message ()
496 "Check whether this message has already been sent."
497 (when gnus-sent-message-ids-file
498 (let ((message-id (save-restriction (message-narrow-to-headers)
499 (mail-fetch-field "message-id")))
502 (unless gnus-inews-sent-ids
505 (if (member message-id gnus-inews-sent-ids)
506 ;; Reject this message.
507 (not (gnus-yes-or-no-p
508 (format "Message %s already sent. Send anyway? "
510 (push message-id gnus-inews-sent-ids)
511 ;; Chop off the last Message-IDs.
512 (when (setq end (nthcdr gnus-sent-message-ids-length
513 gnus-inews-sent-ids))
515 (nnheader-temp-write gnus-sent-message-ids-file
516 (gnus-prin1 `(setq gnus-inews-sent-ids ',gnus-inews-sent-ids)))
521 ;; Dummy to avoid byte-compile warning.
522 (defvar nnspool-rejected-article-hook)
523 (defvar xemacs-codename)
525 ;;; Since the X-Newsreader/X-Mailer are ``vanity'' headers, they might
526 ;;; as well include the Emacs version as well.
527 ;;; The following function works with later GNU Emacs, and XEmacs.
528 (defun gnus-extended-version ()
529 "Stringified Gnus version"
533 ;; Written by "Mr. Per Persson" <pp@gnu.ai.mit.edu>.
534 (defun gnus-inews-insert-mime-headers ()
535 (goto-char (point-min))
536 (let ((mail-header-separator
538 (goto-char (point-min))
539 (if (and (search-forward (concat "\n" mail-header-separator "\n")
541 (not (search-backward "\n\n" nil t)))
542 mail-header-separator
544 (or (mail-position-on-field "Mime-Version")
546 (cond ((save-restriction
548 (goto-char (point-min))
549 (re-search-forward "[\200-\377]" nil t))
550 (or (mail-position-on-field "Content-Type")
551 (insert "text/plain; charset=ISO-8859-1"))
552 (or (mail-position-on-field "Content-Transfer-Encoding")
554 (t (or (mail-position-on-field "Content-Type")
555 (insert "text/plain; charset=US-ASCII"))
556 (or (mail-position-on-field "Content-Transfer-Encoding")
557 (insert "7bit")))))))
561 ;;; Gnus Mail Functions
564 ;;; Mail reply commands of Gnus summary mode
566 (defun gnus-summary-reply (&optional yank wide)
567 "Start composing a reply mail to the current message.
568 If prefix argument YANK is non-nil, the original article is yanked
571 (list (and current-prefix-arg
572 (gnus-summary-work-articles 1))))
573 ;; Stripping headers should be specified with mail-yank-ignored-headers.
575 (gnus-summary-goto-subject (car yank)))
576 (let ((gnus-article-reply t))
577 (gnus-setup-message (if yank 'reply-yank 'reply)
578 (gnus-summary-select-article)
579 (set-buffer (gnus-copy-article-buffer))
580 (message-reply nil wide (gnus-group-find-parameter
581 gnus-newsgroup-name 'broken-reply-to))
583 (gnus-inews-yank-articles yank)))))
585 (defun gnus-summary-reply-with-original (n &optional wide)
586 "Start composing a reply mail to the current message.
587 The original article will be yanked."
589 (gnus-summary-reply (gnus-summary-work-articles n) wide))
591 (defun gnus-summary-wide-reply (&optional yank)
592 "Start composing a wide reply mail to the current message.
593 If prefix argument YANK is non-nil, the original article is yanked
596 (list (and current-prefix-arg
597 (gnus-summary-work-articles 1))))
598 (gnus-summary-reply yank t))
600 (defun gnus-summary-wide-reply-with-original (n)
601 "Start composing a wide reply mail to the current message.
602 The original article will be yanked."
604 (gnus-summary-reply-with-original n t))
606 (defun gnus-summary-mail-forward (&optional full-headers post)
607 "Forward the current message to another user.
608 If FULL-HEADERS (the prefix), include full headers when forwarding."
610 (gnus-setup-message 'forward
611 (gnus-summary-select-article)
612 (set-buffer gnus-original-article-buffer)
613 (let ((message-included-forward-headers
614 (if full-headers "" message-included-forward-headers)))
615 (message-forward post))))
617 (defun gnus-summary-resend-message (address n)
618 "Resend the current article to ADDRESS."
619 (interactive "sResend message(s) to: \nP")
620 (let ((articles (gnus-summary-work-articles n))
622 (while (setq article (pop articles))
623 (gnus-summary-select-article nil nil nil article)
625 (set-buffer gnus-original-article-buffer)
626 (message-resend address)))))
628 (defun gnus-summary-post-forward (&optional full-headers)
629 "Forward the current article to a newsgroup.
630 If FULL-HEADERS (the prefix), include full headers when forwarding."
632 (gnus-summary-mail-forward full-headers t))
634 (defvar gnus-nastygram-message
635 "The following article was inappropriately posted to %s.\n\n"
636 "Format string to insert in nastygrams.
637 The current group name will be inserted at \"%s\".")
639 (defun gnus-summary-mail-nastygram (n)
640 "Send a nastygram to the author of the current article."
642 (when (or gnus-expert-user
644 "Really send a nastygram to the author of the current article? "))
645 (let ((group gnus-newsgroup-name))
646 (gnus-summary-reply-with-original n)
647 (set-buffer gnus-message-buffer)
649 (insert (format gnus-nastygram-message group))
650 (message-send-and-exit))))
652 (defun gnus-summary-mail-crosspost-complaint (n)
653 "Send a complaint about crossposting to the current article(s)."
655 (let ((articles (gnus-summary-work-articles n))
657 (while (setq article (pop articles))
658 (set-buffer gnus-summary-buffer)
659 (gnus-summary-goto-subject article)
660 (let ((group (gnus-group-real-name gnus-newsgroup-name))
661 newsgroups followup-to)
662 (gnus-summary-select-article)
663 (set-buffer gnus-original-article-buffer)
664 (if (and (<= (length (message-tokenize-header
665 (setq newsgroups (mail-fetch-field "newsgroups"))
668 (or (not (setq followup-to (mail-fetch-field "followup-to")))
669 (not (member group (message-tokenize-header
670 followup-to ", ")))))
672 (gnus-message 1 "Followup-to restricted")
673 (gnus-message 1 "Not a crossposted article"))
674 (set-buffer gnus-summary-buffer)
675 (gnus-summary-reply-with-original 1)
676 (set-buffer gnus-message-buffer)
678 (insert (format gnus-crosspost-complaint newsgroups group))
679 (message-goto-subject)
680 (re-search-forward " *$")
681 (replace-match " (crosspost notification)" t t)
682 (gnus-deactivate-mark)
683 (when (gnus-y-or-n-p "Send this complaint? ")
684 (message-send-and-exit)))))))
686 (defun gnus-summary-mail-other-window ()
687 "Compose mail in other window."
689 (gnus-setup-message 'message
692 (defun gnus-mail-parse-comma-list ()
695 (skip-chars-forward " ")
698 (skip-chars-forward "^,")
703 (narrow-to-region beg (point))
706 (while (search-forward "\"" nil t)
710 (skip-chars-forward ",")
711 (skip-chars-forward "^,"))
712 (skip-chars-backward " ")
713 (push (buffer-substring beg (point))
715 (skip-chars-forward "^,")
716 (skip-chars-forward ", "))
719 (defun gnus-inews-add-to-address (group)
720 (let ((to-address (mail-fetch-field "to")))
721 (when (and to-address
723 ;; This mail group doesn't have a `to-list', so we add one
726 (format "Do you want to add this as `to-list': %s " to-address))
727 (gnus-group-add-parameter group (cons 'to-list to-address))))))
729 (defun gnus-put-message ()
730 "Put the current message in some group and return to Gnus."
732 (let ((reply gnus-article-reply)
733 (winconf gnus-prev-winconf)
734 (group gnus-newsgroup-name))
736 (or (and group (not (gnus-group-read-only-p group)))
737 (setq group (read-string "Put in group: " nil
738 (gnus-writable-groups))))
739 (when (gnus-gethash group gnus-newsrc-hashtb)
740 (error "No such group: %s" group))
745 (message-narrow-to-headers)
746 (let (gnus-deletable-headers)
748 (message-generate-headers message-required-news-headers)
749 (message-generate-headers message-required-mail-headers)))
750 (goto-char (point-max))
751 (insert "Gcc: " group "\n")
756 (when (get-buffer gnus-group-buffer)
757 (when (gnus-buffer-exists-p (car-safe reply))
758 (set-buffer (car reply))
760 (gnus-summary-mark-article-as-replied
763 (set-window-configuration winconf)))))
765 (defun gnus-article-mail (yank)
766 "Send a reply to the address near point.
767 If YANK is non-nil, include the original article."
771 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
772 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
774 (message-reply address)
776 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
778 (defvar nntp-server-type)
780 "Send a bug report to the Gnus maintainers."
782 (unless (gnus-alive-p)
783 (error "Gnus has been shut down"))
784 (gnus-setup-message 'bug
785 (delete-other-windows)
786 (switch-to-buffer (get-buffer-create "*Gnus Help Bug*"))
788 (insert gnus-bug-message)
789 (goto-char (point-min))
790 (message-pop-to-buffer "*Gnus Bug*")
791 (message-setup `((To . ,gnus-maintainer) (Subject . "")))
792 (push `(gnus-bug-kill-buffer) message-send-actions)
793 (goto-char (point-min))
794 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
796 (insert (gnus-version) "\n")
797 (insert (emacs-version) "\n")
798 (when (and (boundp 'nntp-server-type)
799 (stringp nntp-server-type))
800 (insert nntp-server-type))
801 (insert "\n\n\n\n\n")
803 (goto-char (point-min))
804 (search-forward "Subject: " nil t)
807 (defun gnus-bug-kill-buffer ()
808 (when (get-buffer "*Gnus Help Bug*")
809 (kill-buffer "*Gnus Help Bug*")))
812 "Attempts to go through the Gnus source file and report what variables have been changed.
813 The source file has to be in the Emacs load path."
815 (let ((files '("gnus.el" "gnus-sum.el" "gnus-group.el"
816 "gnus-art.el" "gnus-start.el" "gnus-async.el"
817 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
818 "nnmail.el" "message.el"))
821 (gnus-message 4 "Please wait while we snoop your variables...")
823 ;; Go through all the files looking for non-default values for variables.
825 (set-buffer (get-buffer-create " *gnus bug info*"))
826 (buffer-disable-undo (current-buffer))
829 (when (and (setq file (locate-library (pop files)))
830 (file-exists-p file))
831 (insert-file-contents file)
832 (goto-char (point-min))
833 (if (not (re-search-forward "^;;* *Internal variables" nil t))
834 (gnus-message 4 "Malformed sources in file %s" file)
835 (narrow-to-region (point-min) (point))
836 (goto-char (point-min))
837 (while (setq expr (ignore-errors (read (current-buffer))))
839 (and (or (eq (car expr) 'defvar)
840 (eq (car expr) 'defcustom))
841 (stringp (nth 3 expr))
842 (or (not (boundp (nth 1 expr)))
843 (not (equal (eval (nth 2 expr))
844 (symbol-value (nth 1 expr)))))
845 (push (nth 1 expr) olist)))))))
846 (kill-buffer (current-buffer)))
847 (when (setq olist (nreverse olist))
848 (insert "------------------ Environment follows ------------------\n\n"))
850 (if (boundp (car olist))
852 (pp `(setq ,(car olist)
853 ,(if (or (consp (setq sym (symbol-value (car olist))))
855 (not (or (eq sym nil)
857 (list 'quote (symbol-value (car olist)))
858 (symbol-value (car olist))))
861 (format "(setq %s 'whatever)\n" (car olist))))
862 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
863 (setq olist (cdr olist)))
865 ;; Remove any control chars - they seem to cause trouble for some
866 ;; mailers. (Byte-compiled output from the stuff above.)
868 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
869 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
872 ;;; Treatment of rejected articles.
875 (defun gnus-summary-resend-bounced-mail (&optional fetch)
876 "Re-mail the current message.
877 This only makes sense if the current message is a bounce message than
878 contains some mail you have written which has been bounced back to
880 If FETCH, try to fetch the article that this is a reply to, if indeed
883 (gnus-summary-select-article t)
884 (set-buffer gnus-original-article-buffer)
885 (gnus-setup-message 'compose-bounce
886 (let* ((references (mail-fetch-field "references"))
887 (parent (and references (gnus-parent-id references))))
889 ;; If there are references, we fetch the article we answered to.
891 (gnus-summary-refer-article parent)
892 (gnus-summary-show-all-headers)))))
896 ;; Do Gcc handling, which copied the message over to some group.
897 (defun gnus-inews-do-gcc (&optional gcc)
902 (message-narrow-to-headers)
903 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
904 (coding-system-for-write 'raw-text)
907 (message-remove-header "gcc")
909 (setq groups (message-tokenize-header gcc " ,"))
910 ;; Copy the article over to some group(s).
911 (while (setq group (pop groups))
914 (cond ((and (null (gnus-get-info group))
915 (eq (car gnus-message-archive-method)
917 (gnus-server-to-method
918 (gnus-group-method group)))))
919 ;; If the group doesn't exist, we assume
920 ;; it's an archive group...
921 gnus-message-archive-method)
923 ((gnus-info-method (gnus-get-info group))
924 (gnus-info-method (gnus-get-info group)))
926 (t (gnus-group-method group)))))
927 (gnus-check-server method)
928 (unless (gnus-request-group group t method)
929 (gnus-request-create-group group method))
931 (nnheader-set-temp-buffer " *acc*")
932 (insert-buffer-substring message-encoding-buffer)
933 (run-hooks 'gnus-before-do-gcc-hook)
934 (goto-char (point-min))
935 (when (re-search-forward
936 (concat "^" (regexp-quote mail-header-separator) "$")
938 (replace-match "" t t ))
939 (unless (gnus-request-accept-article group method t)
940 (gnus-message 1 "Couldn't store article in group %s: %s"
941 group (gnus-status-message method))
943 (kill-buffer (current-buffer))))))))))
945 (defun gnus-inews-insert-gcc ()
946 "Insert Gcc headers based on `gnus-outgoing-message-group'."
949 (message-narrow-to-headers)
950 (let* ((group gnus-outgoing-message-group)
952 ((gnus-functionp group)
954 ((or (stringp group) (list group))
958 (if (stringp gcc) gcc
959 (mapconcat 'identity gcc " "))
962 (defun gnus-inews-insert-archive-gcc (&optional group)
963 "Insert the Gcc to say where the article is to be archived."
964 (let* ((var gnus-message-archive-group)
965 (group (or group gnus-newsgroup-name ""))
967 (and gnus-newsgroup-name
968 (gnus-group-find-parameter
969 gnus-newsgroup-name 'gcc-self)))
973 ((null gnus-message-archive-method)
977 ;; Just a single group.
980 ;; We don't want this.
982 ((and (listp var) (stringp (car var)))
985 ((gnus-functionp var)
989 ;; An alist of regexps/functions/forms.
994 ((stringp (caar var))
996 (when (string-match (caar var) group)
998 ((gnus-functionp (car var))
1000 (funcall (car var) group))
1002 (eval (car var)))))))
1003 (setq var (cdr var)))
1006 (when (or groups gcc-self-val)
1007 (when (stringp groups)
1008 (setq groups (list groups)))
1011 (message-narrow-to-headers)
1012 (goto-char (point-max))
1015 ;; Use the `gcc-self' param value instead.
1018 (if (stringp gcc-self-val)
1021 (if (not (eq gcc-self-val 'none))
1026 ;; Use the list of groups.
1027 (while (setq name (pop groups))
1028 (insert (if (string-match ":" name)
1030 (gnus-group-prefixed-name
1031 name gnus-message-archive-method)))
1036 (gnus-add-shutdown 'gnus-inews-close 'gnus)
1038 (defun gnus-inews-close ()
1039 (setq gnus-inews-sent-ids nil))
1041 ;;; Allow redefinition of functions.
1047 ;;; gnus-msg.el ends here