1 ;;; gnus-msg.el --- mail and post interface for 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>
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-sent-message-ids-file
70 (nnheader-concat gnus-directory "Sent-Message-IDs")
71 "File where Gnus saves a cache of sent message ids.")
73 (defvar gnus-sent-message-ids-length 1000
74 "The number of sent Message-IDs to save.")
76 (defvar gnus-crosspost-complaint
79 You posted the article below with the following Newsgroups header:
83 The %s group, at least, was an inappropriate recipient
84 of this message. Please trim your Newsgroups header to exclude this
85 group before posting in the future.
90 "Format string to be inserted when complaining about crossposts.
91 The first %s will be replaced by the Newsgroups header;
92 the second with the current group name.")
94 (defvar gnus-message-setup-hook nil
95 "Hook run after setting up a message buffer.")
97 ;;; Internal variables.
99 (defvar gnus-message-buffer "*Mail Gnus*")
100 (defvar gnus-article-copy nil)
101 (defvar gnus-last-posting-server nil)
102 (defvar gnus-message-group-art nil)
104 (defconst gnus-bug-message
105 "Sending a bug report to the Gnus Towers.
106 ========================================
108 The buffer below is a mail buffer. When you press `C-c C-c', it will
109 be sent to the Gnus Bug Exterminators.
111 At the bottom of the buffer you'll see lots of variable settings.
112 Please do not delete those. They will tell the Bug People what your
113 environment is, so that it will be easier to locate the bugs.
115 If you have found a bug that makes Emacs go \"beep\", set
116 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
117 and include the backtrace in your bug report.
119 Please describe the bug in annoying, painstaking detail.
121 Thank you for your help in stamping out bugs.
125 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
126 (autoload 'news-setup "rnewspost")
127 (autoload 'news-reply-mode "rnewspost")
128 (autoload 'rmail-dont-reply-to "mail-utils")
129 (autoload 'rmail-output "rmailout"))
133 ;;; Gnus Posting Functions
136 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
137 "p" gnus-summary-post-news
138 "f" gnus-summary-followup
139 "F" gnus-summary-followup-with-original
140 "c" gnus-summary-cancel-article
141 "s" gnus-summary-supersede-article
142 "r" gnus-summary-reply
143 "R" gnus-summary-reply-with-original
144 "w" gnus-summary-wide-reply
145 "W" gnus-summary-wide-reply-with-original
146 "n" gnus-summary-followup-to-mail
147 "N" gnus-summary-followup-to-mail-with-original
148 "m" gnus-summary-mail-other-window
149 "u" gnus-uu-post-news
150 "\M-c" gnus-summary-mail-crosspost-complaint
151 "om" gnus-summary-mail-forward
152 "op" gnus-summary-post-forward
153 "Om" gnus-uu-digest-mail-forward
154 "Op" gnus-uu-digest-post-forward)
156 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
157 "b" gnus-summary-resend-bounced-mail
158 ;; "c" gnus-summary-send-draft
159 "r" gnus-summary-resend-message)
161 ;;; Internal functions.
163 (defvar gnus-article-reply nil)
164 (defmacro gnus-setup-message (config &rest forms)
165 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
166 (buffer (make-symbol "gnus-setup-message-buffer"))
167 (article (make-symbol "gnus-setup-message-article")))
168 `(let ((,winconf (current-window-configuration))
169 (,buffer (buffer-name (current-buffer)))
170 (,article (and gnus-article-reply (gnus-summary-article-number)))
171 (message-header-setup-hook
172 (copy-sequence message-header-setup-hook)))
173 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
174 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
178 (gnus-inews-add-send-actions ,winconf ,buffer ,article)
179 (setq gnus-message-buffer (current-buffer))
180 (set (make-local-variable 'gnus-message-group-art)
181 (cons ,gnus-newsgroup-name ,article))
182 (make-local-variable 'gnus-newsgroup-name)
183 (run-hooks 'gnus-message-setup-hook))
184 (gnus-configure-windows ,config t)
185 (set-buffer-modified-p nil))))
187 (defun gnus-inews-add-send-actions (winconf buffer article)
188 (make-local-hook 'message-sent-hook)
189 (add-hook 'message-sent-hook 'gnus-inews-do-gcc nil t)
190 (setq message-post-method
192 (gnus-post-method arg ,gnus-newsgroup-name)))
193 (setq message-newsreader (setq message-mailer (gnus-extended-version)))
195 `(set-window-configuration ,winconf) 'exit 'postpone 'kill)
197 `(when (buffer-name (get-buffer ,buffer))
199 (set-buffer (get-buffer ,buffer))
201 `(gnus-summary-mark-article-as-replied ,article))))
204 (put 'gnus-setup-message 'lisp-indent-function 1)
205 (put 'gnus-setup-message 'edebug-form-spec '(form body))
207 ;;; Post news commands of Gnus group mode and summary mode
209 (defun gnus-group-mail ()
210 "Start composing a mail."
212 (gnus-setup-message 'message
215 (defun gnus-group-post-news (&optional arg)
216 "Start composing a news message.
217 If ARG, post to the group under point.
218 If ARG is 1, prompt for a group name."
220 ;; Bind this variable here to make message mode hooks
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-set-global-variables)
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))))
243 (gnus-set-global-variables)
245 (gnus-summary-goto-subject (car yank)))
246 (save-window-excursion
247 (gnus-summary-select-article))
248 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
249 (gnus-newsgroup-name gnus-newsgroup-name))
251 (gnus-post-news nil gnus-newsgroup-name
252 headers gnus-article-buffer
253 yank nil force-news)))
255 (defun gnus-summary-followup-with-original (n &optional force-news)
256 "Compose a followup to an article and include the original article."
258 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
260 (defun gnus-summary-followup-to-mail (&optional arg)
261 "Followup to the current mail message via news."
263 (list (and current-prefix-arg
264 (gnus-summary-work-articles 1))))
265 (gnus-summary-followup arg t))
267 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
268 "Followup to the current mail message via news."
270 (gnus-summary-followup (gnus-summary-work-articles arg) t))
272 (defun gnus-inews-yank-articles (articles)
275 (while (setq article (pop articles))
276 (save-window-excursion
277 (set-buffer gnus-summary-buffer)
278 (gnus-summary-select-article nil nil nil article)
279 (gnus-summary-remove-process-mark article))
280 (gnus-copy-article-buffer)
281 (let ((message-reply-buffer gnus-article-copy)
282 (message-reply-headers gnus-current-headers))
283 (message-yank-original)
284 (setq beg (or beg (mark t))))
290 (defun gnus-summary-cancel-article (&optional n symp)
291 "Cancel an article you posted.
292 Uses the process-prefix convention. If given the symbolic
293 prefix `a', cancel using the standard posting method; if not
294 post using the current select method."
295 (interactive (gnus-interactive "P\ny"))
296 (gnus-set-global-variables)
297 (let ((articles (gnus-summary-work-articles n))
300 (gnus-post-method (not (eq symp 'a)) ,gnus-newsgroup-name)))
302 (while (setq article (pop articles))
303 (when (gnus-summary-select-article t nil nil article)
304 (when (gnus-eval-in-buffer-window 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 (gnus-set-global-variables)
317 (let ((article (gnus-summary-article-number)))
318 (gnus-setup-message 'reply-yank
319 (gnus-summary-select-article t)
320 (set-buffer gnus-original-article-buffer)
324 (when (buffer-name (get-buffer ,gnus-summary-buffer))
326 (set-buffer (get-buffer ,gnus-summary-buffer))
327 (gnus-cache-possibly-remove-article ,article nil nil nil t)
328 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
329 message-send-actions))))
333 (defun gnus-copy-article-buffer (&optional article-buffer)
334 ;; make a copy of the article buffer with all text properties removed
335 ;; this copy is in the buffer gnus-article-copy.
336 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
337 ;; this buffer should be passed to all mail/news reply/post routines.
338 (setq gnus-article-copy (get-buffer-create " *gnus article copy*"))
339 (buffer-disable-undo gnus-article-copy)
340 (or (memq gnus-article-copy gnus-buffer-list)
341 (push gnus-article-copy gnus-buffer-list))
342 (let ((article-buffer (or article-buffer gnus-article-buffer))
344 (if (not (and (get-buffer article-buffer)
345 (buffer-name (get-buffer article-buffer))))
346 (error "Can't find any article buffer")
348 (set-buffer article-buffer)
350 ;; Copy over the (displayed) article buffer, delete
351 ;; hidden text and remove text properties.
353 (copy-to-buffer gnus-article-copy (point-min) (point-max))
354 (set-buffer gnus-article-copy)
355 (gnus-article-delete-text-of-type 'annotation)
356 (gnus-remove-text-with-property 'gnus-prev)
357 (gnus-remove-text-with-property 'gnus-next)
360 (format "%s" (buffer-string))
362 ;; Find the original headers.
363 (set-buffer gnus-original-article-buffer)
364 (goto-char (point-min))
365 (while (looking-at message-unix-mail-delimiter)
368 (setq end (or (search-forward "\n\n" nil t) (point)))
369 ;; Delete the headers from the displayed articles.
370 (set-buffer gnus-article-copy)
371 (delete-region (goto-char (point-min))
372 (or (search-forward "\n\n" nil t) (point)))
373 ;; Insert the original article headers.
374 (insert-buffer-substring gnus-original-article-buffer beg end)
375 (gnus-article-decode-rfc1522)))
378 (defun gnus-post-news (post &optional group header article-buffer yank subject
381 (gnus-copy-article-buffer))
382 (let ((gnus-article-reply article-buffer)
383 (add-to-list gnus-add-to-list))
384 (gnus-setup-message (cond (yank 'reply-yank)
385 (article-buffer 'reply)
387 (let* ((group (or group gnus-newsgroup-name))
389 to-address to-group mailing-list to-list
392 (setq to-address (gnus-group-find-parameter group 'to-address)
393 to-group (gnus-group-find-parameter group 'to-group)
394 to-list (gnus-group-find-parameter group 'to-list)
395 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
396 mailing-list (when gnus-mailing-list-groups
397 (string-match gnus-mailing-list-groups group))
398 group (gnus-group-real-name group)))
399 (if (or (and to-group
400 (gnus-news-group-p to-group))
403 (and (gnus-news-group-p
404 (or pgroup gnus-newsgroup-name)
405 (if header (mail-header-number header)
406 gnus-current-article))
412 (message-news (or to-group group))
413 (set-buffer gnus-article-copy)
414 (message-followup (if (or newsgroup-p force-news) nil to-group)))
418 (message-mail (or to-address to-list))
419 ;; Arrange for mail groups that have no `to-address' to
420 ;; get that when the user sends off the mail.
421 (when (and (not to-list)
424 (push (list 'gnus-inews-add-to-address pgroup)
425 message-send-actions)))
426 (set-buffer gnus-article-copy)
427 (message-wide-reply to-address
428 (gnus-group-find-parameter
429 gnus-newsgroup-name 'broken-reply-to))))
431 (gnus-inews-yank-articles yank))))))
433 (defun gnus-post-method (arg group &optional silent)
434 "Return the posting method based on GROUP and ARG.
435 If SILENT, don't prompt the user."
436 (let ((group-method (gnus-find-method-for-group group)))
438 ;; If the group-method is nil (which shouldn't happen) we use
439 ;; the default method.
441 (or gnus-post-method gnus-select-method message-post-method))
442 ;; We want this group's method.
443 ((and arg (not (eq arg 0)))
445 ;; We query the user for a post method.
447 (and gnus-post-method
448 (listp (car gnus-post-method))))
450 ;; Collect all methods we know about.
452 (when gnus-post-method
453 (if (listp (car gnus-post-method))
455 (list gnus-post-method)))
456 gnus-secondary-select-methods
457 (list gnus-select-method)
458 (list group-method)))
459 method-alist post-methods method)
460 ;; Weed out all mail methods.
462 (setq method (gnus-server-get-method "" (pop methods)))
463 (when (or (gnus-method-option-p method 'post)
464 (gnus-method-option-p method 'post-mail))
465 (push method post-methods)))
466 ;; Create a name-method alist.
470 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m))
475 (setq gnus-last-posting-server
477 gnus-last-posting-server)
478 ;; Just use the last value.
479 gnus-last-posting-server
481 "Posting method: " method-alist nil t
482 (cons (or gnus-last-posting-server "") 0))))
484 ;; Override normal method.
487 ;; Use the normal select method.
488 (t gnus-select-method))))
491 ;;; Check whether the message has been sent already.
494 (defvar gnus-inews-sent-ids nil)
496 (defun gnus-inews-reject-message ()
497 "Check whether this message has already been sent."
498 (when gnus-sent-message-ids-file
499 (let ((message-id (save-restriction (message-narrow-to-headers)
500 (mail-fetch-field "message-id")))
503 (unless gnus-inews-sent-ids
506 (if (member message-id gnus-inews-sent-ids)
507 ;; Reject this message.
508 (not (gnus-yes-or-no-p
509 (format "Message %s already sent. Send anyway? "
511 (push message-id gnus-inews-sent-ids)
512 ;; Chop off the last Message-IDs.
513 (when (setq end (nthcdr gnus-sent-message-ids-length
514 gnus-inews-sent-ids))
516 (nnheader-temp-write gnus-sent-message-ids-file
517 (gnus-prin1 `(setq gnus-inews-sent-ids ',gnus-inews-sent-ids)))
522 ;; Dummy to avoid byte-compile warning.
523 (defvar nnspool-rejected-article-hook)
524 (defvar xemacs-codename)
526 ;;; Since the X-Newsreader/X-Mailer are ``vanity'' headers, they might
527 ;;; as well include the Emacs version as well.
528 ;;; The following function works with later GNU Emacs, and XEmacs.
529 (defun gnus-extended-version ()
530 "Stringified Gnus version and Emacs version"
536 ((string-match "^\\([0-9]+\\.[0-9]+\\)\\.[.0-9]+$" emacs-version)
537 (concat "Emacs " (substring emacs-version
540 ((string-match "\\([A-Z]*[Mm][Aa][Cc][Ss]\\)[^(]*\\(\\((beta.*)\\|'\\)\\)?"
542 (concat (substring emacs-version
545 (format " %d.%d" emacs-major-version emacs-minor-version)
546 (if (match-beginning 3)
547 (substring emacs-version
551 (if (boundp 'xemacs-codename)
552 (concat " - \"" xemacs-codename "\""))))
555 ;; Written by "Mr. Per Persson" <pp@gnu.ai.mit.edu>.
556 (defun gnus-inews-insert-mime-headers ()
557 (goto-char (point-min))
558 (let ((mail-header-separator
560 (goto-char (point-min))
561 (if (and (search-forward (concat "\n" mail-header-separator "\n")
563 (not (search-backward "\n\n" nil t)))
564 mail-header-separator
566 (or (mail-position-on-field "Mime-Version")
568 (cond ((save-restriction
570 (goto-char (point-min))
571 (re-search-forward "[\200-\377]" nil t))
572 (or (mail-position-on-field "Content-Type")
573 (insert "text/plain; charset=ISO-8859-1"))
574 (or (mail-position-on-field "Content-Transfer-Encoding")
576 (t (or (mail-position-on-field "Content-Type")
577 (insert "text/plain; charset=US-ASCII"))
578 (or (mail-position-on-field "Content-Transfer-Encoding")
579 (insert "7bit")))))))
583 ;;; Gnus Mail Functions
586 ;;; Mail reply commands of Gnus summary mode
588 (defun gnus-summary-reply (&optional yank wide)
589 "Start composing a reply mail to the current message.
590 If prefix argument YANK is non-nil, the original article is yanked
593 (list (and current-prefix-arg
594 (gnus-summary-work-articles 1))))
595 ;; Stripping headers should be specified with mail-yank-ignored-headers.
596 (gnus-set-global-variables)
598 (gnus-summary-goto-subject (car yank)))
599 (let ((gnus-article-reply t))
600 (gnus-setup-message (if yank 'reply-yank 'reply)
601 (gnus-summary-select-article)
602 (set-buffer (gnus-copy-article-buffer))
603 (message-reply nil wide (gnus-group-find-parameter
604 gnus-newsgroup-name 'broken-reply-to))
606 (gnus-inews-yank-articles yank)))))
608 (defun gnus-summary-reply-with-original (n &optional wide)
609 "Start composing a reply mail to the current message.
610 The original article will be yanked."
612 (gnus-summary-reply (gnus-summary-work-articles n) wide))
614 (defun gnus-summary-wide-reply (&optional yank)
615 "Start composing a wide reply mail to the current message.
616 If prefix argument YANK is non-nil, the original article is yanked
619 (list (and current-prefix-arg
620 (gnus-summary-work-articles 1))))
621 (gnus-summary-reply yank t))
623 (defun gnus-summary-wide-reply-with-original (n)
624 "Start composing a wide reply mail to the current message.
625 The original article will be yanked."
627 (gnus-summary-reply-with-original n t))
629 (defun gnus-summary-mail-forward (&optional full-headers post)
630 "Forward the current message to another user.
631 If FULL-HEADERS (the prefix), include full headers when forwarding."
633 (gnus-set-global-variables)
634 (gnus-setup-message 'forward
635 (gnus-summary-select-article)
636 (set-buffer gnus-original-article-buffer)
637 (let ((message-included-forward-headers
638 (if full-headers "" message-included-forward-headers)))
639 (message-forward post))))
641 (defun gnus-summary-resend-message (address n)
642 "Resend the current article to ADDRESS."
643 (interactive "sResend message(s) to: \nP")
644 (let ((articles (gnus-summary-work-articles n))
646 (while (setq article (pop articles))
647 (gnus-summary-select-article nil nil nil article)
649 (set-buffer gnus-original-article-buffer)
650 (message-resend address)))))
652 (defun gnus-summary-post-forward (&optional full-headers)
653 "Forward the current article to a newsgroup.
654 If FULL-HEADERS (the prefix), include full headers when forwarding."
656 (gnus-summary-mail-forward full-headers t))
658 (defvar gnus-nastygram-message
659 "The following article was inappropriately posted to %s.\n\n"
660 "Format string to insert in nastygrams.
661 The current group name will be inserted at \"%s\".")
663 (defun gnus-summary-mail-nastygram (n)
664 "Send a nastygram to the author of the current article."
666 (when (or gnus-expert-user
668 "Really send a nastygram to the author of the current article? "))
669 (let ((group gnus-newsgroup-name))
670 (gnus-summary-reply-with-original n)
671 (set-buffer gnus-message-buffer)
673 (insert (format gnus-nastygram-message group))
674 (message-send-and-exit))))
676 (defun gnus-summary-mail-crosspost-complaint (n)
677 "Send a complaint about crossposting to the current article(s)."
679 (let ((articles (gnus-summary-work-articles n))
681 (while (setq article (pop articles))
682 (set-buffer gnus-summary-buffer)
683 (gnus-summary-goto-subject article)
684 (let ((group (gnus-group-real-name gnus-newsgroup-name))
685 newsgroups followup-to)
686 (gnus-summary-select-article)
687 (set-buffer gnus-original-article-buffer)
688 (if (and (<= (length (message-tokenize-header
689 (setq newsgroups (mail-fetch-field "newsgroups"))
692 (or (not (setq followup-to (mail-fetch-field "followup-to")))
693 (not (member group (message-tokenize-header
694 followup-to ", ")))))
696 (gnus-message 1 "Followup-to restricted")
697 (gnus-message 1 "Not a crossposted article"))
698 (set-buffer gnus-summary-buffer)
699 (gnus-summary-reply-with-original 1)
700 (set-buffer gnus-message-buffer)
702 (insert (format gnus-crosspost-complaint newsgroups group))
703 (message-goto-subject)
704 (re-search-forward " *$")
705 (replace-match " (crosspost notification)" t t)
706 (gnus-deactivate-mark)
707 (when (gnus-y-or-n-p "Send this complaint? ")
708 (message-send-and-exit)))))))
710 (defun gnus-summary-mail-other-window ()
711 "Compose mail in other window."
713 (gnus-setup-message 'message
716 (defun gnus-mail-parse-comma-list ()
719 (skip-chars-forward " ")
722 (skip-chars-forward "^,")
727 (narrow-to-region beg (point))
730 (while (search-forward "\"" nil t)
734 (skip-chars-forward ",")
735 (skip-chars-forward "^,"))
736 (skip-chars-backward " ")
737 (push (buffer-substring beg (point))
739 (skip-chars-forward "^,")
740 (skip-chars-forward ", "))
743 (defun gnus-inews-add-to-address (group)
744 (let ((to-address (mail-fetch-field "to")))
745 (when (and to-address
747 ;; This mail group doesn't have a `to-list', so we add one
750 (format "Do you want to add this as `to-list': %s " to-address))
751 (gnus-group-add-parameter group (cons 'to-list to-address))))))
753 (defun gnus-put-message ()
754 "Put the current message in some group and return to Gnus."
756 (let ((reply gnus-article-reply)
757 (winconf gnus-prev-winconf)
758 (group gnus-newsgroup-name))
760 (or (and group (not (gnus-group-read-only-p group)))
761 (setq group (read-string "Put in group: " nil
762 (gnus-writable-groups))))
763 (when (gnus-gethash group gnus-newsrc-hashtb)
764 (error "No such group: %s" group))
769 (message-narrow-to-headers)
770 (let (gnus-deletable-headers)
772 (message-generate-headers message-required-news-headers)
773 (message-generate-headers message-required-mail-headers)))
774 (goto-char (point-max))
775 (insert "Gcc: " group "\n")
780 (when (get-buffer gnus-group-buffer)
781 (when (gnus-buffer-exists-p (car-safe reply))
782 (set-buffer (car reply))
784 (gnus-summary-mark-article-as-replied
787 (set-window-configuration winconf)))))
789 (defun gnus-article-mail (yank)
790 "Send a reply to the address near point.
791 If YANK is non-nil, include the original article."
795 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
796 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
798 (message-reply address)
800 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
802 (defvar nntp-server-type)
804 "Send a bug report to the Gnus maintainers."
806 (unless (gnus-alive-p)
807 (error "Gnus has been shut down"))
808 (gnus-setup-message 'bug
809 (delete-other-windows)
810 (switch-to-buffer (get-buffer-create "*Gnus Help Bug*"))
812 (insert gnus-bug-message)
813 (goto-char (point-min))
814 (message-pop-to-buffer "*Gnus Bug*")
815 (message-setup `((To . ,gnus-maintainer) (Subject . "")))
816 (push `(gnus-bug-kill-buffer) message-send-actions)
817 (goto-char (point-min))
818 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
820 (insert (gnus-version) "\n")
821 (insert (emacs-version) "\n")
822 (when (and (boundp 'nntp-server-type)
823 (stringp nntp-server-type))
824 (insert nntp-server-type))
825 (insert "\n\n\n\n\n")
827 (goto-char (point-min))
828 (search-forward "Subject: " nil t)
831 (defun gnus-bug-kill-buffer ()
832 (when (get-buffer "*Gnus Help Bug*")
833 (kill-buffer "*Gnus Help Bug*")))
836 "Attempts to go through the Gnus source file and report what variables have been changed.
837 The source file has to be in the Emacs load path."
839 (let ((files '("gnus.el" "gnus-sum.el" "gnus-group.el"
840 "gnus-art.el" "gnus-start.el" "gnus-async.el"
841 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
842 "nnmail.el" "message.el"))
844 (gnus-message 4 "Please wait while we snoop your variables...")
846 ;; Go through all the files looking for non-default values for variables.
848 (set-buffer (get-buffer-create " *gnus bug info*"))
849 (buffer-disable-undo (current-buffer))
852 (when (and (setq file (locate-library (pop files)))
853 (file-exists-p file))
854 (insert-file-contents file)
855 (goto-char (point-min))
856 (if (not (re-search-forward "^;;* *Internal variables" nil t))
857 (gnus-message 4 "Malformed sources in file %s" file)
858 (narrow-to-region (point-min) (point))
859 (goto-char (point-min))
860 (while (setq expr (ignore-errors (read (current-buffer))))
862 (and (or (eq (car expr) 'defvar)
863 (eq (car expr) 'defcustom))
864 (stringp (nth 3 expr))
865 (or (not (boundp (nth 1 expr)))
866 (not (equal (eval (nth 2 expr))
867 (symbol-value (nth 1 expr)))))
868 (push (nth 1 expr) olist)))))))
869 (kill-buffer (current-buffer)))
870 (when (setq olist (nreverse olist))
871 (insert "------------------ Environment follows ------------------\n\n"))
873 (if (boundp (car olist))
875 (pp `(setq ,(car olist)
876 ,(if (or (consp (setq sym (symbol-value (car olist))))
878 (not (or (eq sym nil)
880 (list 'quote (symbol-value (car olist)))
881 (symbol-value (car olist))))
884 (format "(setq %s 'whatever)\n" (car olist))))
885 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
886 (setq olist (cdr olist)))
888 ;; Remove any null chars - they seem to cause trouble for some
889 ;; mailers. (Byte-compiled output from the stuff above.)
890 (goto-char (point-min))
891 (while (re-search-forward "[\000\200]" nil t)
892 (replace-match "" t t))))
894 ;;; Treatment of rejected articles.
897 (defun gnus-summary-resend-bounced-mail (&optional fetch)
898 "Re-mail the current message.
899 This only makes sense if the current message is a bounce message than
900 contains some mail you have written which has been bounced back to
902 If FETCH, try to fetch the article that this is a reply to, if indeed
905 (gnus-summary-select-article t)
906 (set-buffer gnus-original-article-buffer)
907 (gnus-setup-message 'compose-bounce
908 (let* ((references (mail-fetch-field "references"))
909 (parent (and references (gnus-parent-id references))))
911 ;; If there are references, we fetch the article we answered to.
913 (gnus-summary-refer-article parent)
914 (gnus-summary-show-all-headers)))))
918 ;; Do Gcc handling, which copied the message over to some group.
919 (defun gnus-inews-do-gcc (&optional gcc)
924 (message-narrow-to-headers)
925 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
926 (cur (current-buffer))
929 (message-remove-header "gcc")
931 (setq groups (message-tokenize-header gcc " ,"))
932 ;; Copy the article over to some group(s).
933 (while (setq group (pop groups))
936 (cond ((and (null (gnus-get-info group))
937 (eq (car gnus-message-archive-method)
939 (gnus-server-to-method
940 (gnus-group-method group)))))
941 ;; If the group doesn't exist, we assume
942 ;; it's an archive group...
943 gnus-message-archive-method)
945 ((gnus-info-method (gnus-get-info group))
946 (gnus-info-method (gnus-get-info group)))
948 (t (gnus-group-method group)))))
949 (gnus-check-server method)
950 (unless (gnus-request-group group t method)
951 (gnus-request-create-group group method))
953 (nnheader-set-temp-buffer " *acc*")
954 (insert-buffer-substring cur)
955 (goto-char (point-min))
956 (when (re-search-forward
957 (concat "^" (regexp-quote mail-header-separator) "$")
959 (replace-match "" t t ))
960 (unless (gnus-request-accept-article group method t)
961 (gnus-message 1 "Couldn't store article in group %s: %s"
962 group (gnus-status-message method))
964 (kill-buffer (current-buffer))))))))))
966 (defun gnus-inews-insert-gcc ()
967 "Insert Gcc headers based on `gnus-outgoing-message-group'."
970 (message-narrow-to-headers)
971 (let* ((group gnus-outgoing-message-group)
973 ((gnus-functionp group)
975 ((or (stringp group) (list group))
979 (if (stringp gcc) gcc
980 (mapconcat 'identity gcc " "))
983 (defun gnus-inews-insert-archive-gcc (&optional group)
984 "Insert the Gcc to say where the article is to be archived."
985 (let* ((var gnus-message-archive-group)
986 (group (or group gnus-newsgroup-name ""))
988 (and gnus-newsgroup-name
989 (gnus-group-find-parameter
990 gnus-newsgroup-name 'gcc-self)))
994 ((null gnus-message-archive-method)
998 ;; Just a single group.
1001 ;; We don't want this.
1003 ((and (listp var) (stringp (car var)))
1004 ;; A list of groups.
1006 ((gnus-functionp var)
1008 (funcall var group))
1010 ;; An alist of regexps/functions/forms.
1015 ((stringp (caar var))
1017 (when (string-match (caar var) group)
1019 ((gnus-functionp (car var))
1021 (funcall (car var) group))
1023 (eval (car var)))))))
1024 (setq var (cdr var)))
1027 (when (or groups gcc-self-val)
1028 (when (stringp groups)
1029 (setq groups (list groups)))
1032 (message-narrow-to-headers)
1033 (goto-char (point-max))
1036 ;; Use the `gcc-self' param value instead.
1039 (if (stringp gcc-self-val)
1042 (if (not (eq gcc-self-val 'none))
1047 ;; Use the list of groups.
1048 (while (setq name (pop groups))
1049 (insert (if (string-match ":" name)
1051 (gnus-group-prefixed-name
1052 name gnus-message-archive-method)))
1057 (gnus-add-shutdown 'gnus-inews-close 'gnus)
1059 (defun gnus-inews-close ()
1060 (setq gnus-inews-sent-ids nil))
1062 ;;; Allow redefinition of functions.
1068 ;;; gnus-msg.el ends here