1 ;;; gnus-msg.el --- mail and post interface for Gnus
2 ;; Copyright (C) 1995,96,97,98 Free Software Foundation, Inc.
4 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
5 ;; Lars Magne Ingebrigtsen <larsi@gnus.org>
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 (defcustom gnus-post-method nil
37 "*Preferred method for posting USENET news.
39 If this variable is `current', Gnus will use the \"current\" select
40 method when posting. If it is nil (which is the default), Gnus will
41 use the native posting method of the server.
43 This method will not be used in mail groups and the like, only in
46 If not nil nor `native', the value must be a valid method as discussed
47 in the documentation of `gnus-select-method'. It can also be a list of
48 methods. If that is the case, the user will be queried for what select
49 method to use when posting."
50 :group 'gnus-group-foreign
51 :type `(choice (const nil)
54 (sexp :tag "Methods" ,gnus-select-method)))
56 (defvar gnus-outgoing-message-group nil
57 "*All outgoing messages will be put in this group.
58 If you want to store all your outgoing mail and articles in the group
59 \"nnml:archive\", you set this variable to that value. This variable
60 can also be a list of group names.
62 If you want to have greater control over what group to put each
63 message in, you can set this variable to a function that checks the
64 current newsgroup name and then returns a suitable group name (or list
67 (defvar gnus-mailing-list-groups nil
68 "*Regexp matching groups that are really mailing lists.
69 This is useful when you're reading a mailing list that has been
70 gatewayed to a newsgroup, and you want to followup to an article in
73 (defvar gnus-add-to-list nil
74 "*If non-nil, add a `to-list' parameter automatically.")
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 (defvar gnus-bug-create-help-buffer t
98 "*Should we create the *Gnus Help Bug* buffer?")
100 ;;; Internal variables.
102 (defvar gnus-message-buffer "*Mail Gnus*")
103 (defvar gnus-article-copy nil)
104 (defvar gnus-last-posting-server nil)
105 (defvar gnus-message-group-art nil)
107 (defconst gnus-bug-message
108 "Sending a bug report to the Gnus Towers.
109 ========================================
111 The buffer below is a mail buffer. When you press `C-c C-c', it will
112 be sent to the Gnus Bug Exterminators.
114 At the bottom of the buffer you'll see lots of variable settings.
115 Please do not delete those. They will tell the Bug People what your
116 environment is, so that it will be easier to locate the bugs.
118 If you have found a bug that makes Emacs go \"beep\", set
119 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
120 and include the backtrace in your bug report.
122 Please describe the bug in annoying, painstaking detail.
124 Thank you for your help in stamping out bugs.
128 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
129 (autoload 'news-setup "rnewspost")
130 (autoload 'news-reply-mode "rnewspost")
131 (autoload 'rmail-dont-reply-to "mail-utils")
132 (autoload 'rmail-output "rmailout"))
136 ;;; Gnus Posting Functions
139 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
140 "p" gnus-summary-post-news
141 "f" gnus-summary-followup
142 "F" gnus-summary-followup-with-original
143 "c" gnus-summary-cancel-article
144 "s" gnus-summary-supersede-article
145 "r" gnus-summary-reply
146 "R" gnus-summary-reply-with-original
147 "w" gnus-summary-wide-reply
148 "W" gnus-summary-wide-reply-with-original
149 "n" gnus-summary-followup-to-mail
150 "N" gnus-summary-followup-to-mail-with-original
151 "m" gnus-summary-mail-other-window
152 "u" gnus-uu-post-news
153 "\M-c" gnus-summary-mail-crosspost-complaint
154 "om" gnus-summary-mail-forward
155 "op" gnus-summary-post-forward
156 "Om" gnus-uu-digest-mail-forward
157 "Op" gnus-uu-digest-post-forward)
159 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
160 "b" gnus-summary-resend-bounced-mail
161 ;; "c" gnus-summary-send-draft
162 "r" gnus-summary-resend-message)
164 ;;; Internal functions.
166 (defvar gnus-article-reply nil)
167 (defmacro gnus-setup-message (config &rest forms)
168 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
169 (buffer (make-symbol "gnus-setup-message-buffer"))
170 (article (make-symbol "gnus-setup-message-article"))
171 (group (make-symbol "gnus-setup-message-group")))
172 `(let ((,winconf (current-window-configuration))
173 (,buffer (buffer-name (current-buffer)))
174 (,article (and gnus-article-reply (gnus-summary-article-number)))
175 (,group gnus-newsgroup-name)
176 (message-header-setup-hook
177 (copy-sequence message-header-setup-hook)))
178 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
179 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
183 (gnus-inews-add-send-actions ,winconf ,buffer ,article)
184 (setq gnus-message-buffer (current-buffer))
185 (set (make-local-variable 'gnus-message-group-art)
186 (cons ,group ,article))
187 (make-local-variable 'gnus-newsgroup-name)
188 (gnus-run-hooks 'gnus-message-setup-hook))
189 (gnus-configure-windows ,config t)
190 (set-buffer-modified-p nil))))
192 (defun gnus-inews-add-send-actions (winconf buffer article)
193 (make-local-hook 'message-sent-hook)
194 (add-hook 'message-sent-hook 'gnus-inews-do-gcc nil t)
195 (setq message-post-method
197 (gnus-post-method arg ,gnus-newsgroup-name)))
198 (setq message-newsreader (setq message-mailer (gnus-extended-version)))
200 `(set-window-configuration ,winconf) 'exit 'postpone 'kill)
202 `(when (gnus-buffer-exists-p ,buffer)
206 `(gnus-summary-mark-article-as-replied ,article))))
209 (put 'gnus-setup-message 'lisp-indent-function 1)
210 (put 'gnus-setup-message 'edebug-form-spec '(form body))
212 ;;; Post news commands of Gnus group mode and summary mode
214 (defun gnus-group-mail ()
215 "Start composing a mail."
217 (gnus-setup-message 'message
220 (defun gnus-group-post-news (&optional arg)
221 "Start composing a news message.
222 If ARG, post to the group under point.
223 If ARG is 1, prompt for a group name."
225 ;; Bind this variable here to make message mode hooks work ok.
226 (let ((gnus-newsgroup-name
228 (if (= 1 (prefix-numeric-value arg))
229 (completing-read "Newsgroup: " gnus-active-hashtb nil
230 (gnus-read-active-file-p))
231 (gnus-group-group-name))
233 (gnus-post-news 'post gnus-newsgroup-name)))
235 (defun gnus-summary-post-news ()
236 "Start composing a news message."
238 (gnus-post-news 'post gnus-newsgroup-name))
240 (defun gnus-summary-followup (yank &optional force-news)
241 "Compose a followup to an article.
242 If prefix argument YANK is non-nil, original article is yanked automatically."
244 (list (and current-prefix-arg
245 (gnus-summary-work-articles 1))))
247 (gnus-summary-goto-subject (car yank)))
248 (save-window-excursion
249 (gnus-summary-select-article))
250 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
251 (gnus-newsgroup-name gnus-newsgroup-name))
253 (gnus-post-news nil gnus-newsgroup-name
254 headers gnus-article-buffer
255 yank nil force-news)))
257 (defun gnus-summary-followup-with-original (n &optional force-news)
258 "Compose a followup to an article and include the original article."
260 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
262 (defun gnus-summary-followup-to-mail (&optional arg)
263 "Followup to the current mail message via news."
265 (list (and current-prefix-arg
266 (gnus-summary-work-articles 1))))
267 (gnus-summary-followup arg t))
269 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
270 "Followup to the current mail message via news."
272 (gnus-summary-followup (gnus-summary-work-articles arg) t))
274 (defun gnus-inews-yank-articles (articles)
277 (while (setq article (pop articles))
278 (save-window-excursion
279 (set-buffer gnus-summary-buffer)
280 (gnus-summary-select-article nil nil nil article)
281 (gnus-summary-remove-process-mark article))
282 (gnus-copy-article-buffer)
283 (let ((message-reply-buffer gnus-article-copy)
284 (message-reply-headers gnus-current-headers))
285 (message-yank-original)
286 (setq beg (or beg (mark t))))
292 (defun gnus-summary-cancel-article (&optional n symp)
293 "Cancel an article you posted.
294 Uses the process-prefix convention. If given the symbolic
295 prefix `a', cancel using the standard posting method; if not
296 post using the current select method."
297 (interactive (gnus-interactive "P\ny"))
298 (let ((articles (gnus-summary-work-articles n))
301 (gnus-post-method (not (eq symp 'a)) ,gnus-newsgroup-name)))
303 (while (setq article (pop articles))
304 (when (gnus-summary-select-article t nil nil article)
305 (when (gnus-eval-in-buffer-window gnus-original-article-buffer
306 (message-cancel-news))
307 (gnus-summary-mark-as-read article gnus-canceled-mark)
308 (gnus-cache-remove-article 1))
309 (gnus-article-hide-headers-if-wanted))
310 (gnus-summary-remove-process-mark article))))
312 (defun gnus-summary-supersede-article ()
313 "Compose an article that will supersede a previous article.
314 This is done simply by taking the old article and adding a Supersedes
315 header line with the old Message-ID."
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 (gnus-buffer-exists-p ,gnus-summary-buffer)
326 (set-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 (gnus-buffer-exists-p 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 (and (null (eq gnus-post-method 'active)) gnus-post-method)
442 gnus-select-method message-post-method))
443 ;; We want the inverse of the default
444 ((and arg (not (eq arg 0)))
445 (if (eq gnus-post-method 'active)
448 ;; We query the user for a post method.
450 (and gnus-post-method
451 (not (eq gnus-post-method 'current))
452 (listp (car gnus-post-method))))
454 ;; Collect all methods we know about.
456 (when (and gnus-post-method
457 (not (eq gnus-post-method 'current)))
458 (if (listp (car gnus-post-method))
460 (list gnus-post-method)))
461 gnus-secondary-select-methods
462 (mapcar 'cdr gnus-server-alist)
463 (list gnus-select-method)
464 (list group-method)))
465 method-alist post-methods method)
466 ;; Weed out all mail methods.
468 (setq method (gnus-server-get-method "" (pop methods)))
469 (when (or (gnus-method-option-p method 'post)
470 (gnus-method-option-p method 'post-mail))
471 (push method post-methods)))
472 ;; Create a name-method alist.
476 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m))
481 (setq gnus-last-posting-server
483 gnus-last-posting-server)
484 ;; Just use the last value.
485 gnus-last-posting-server
487 "Posting method: " method-alist nil t
488 (cons (or gnus-last-posting-server "") 0))))
490 ;; Override normal method.
491 ((and (eq gnus-post-method 'current)
496 ;; Use the normal select method.
497 (t gnus-select-method))))
501 ;; Dummy to avoid byte-compile warning.
502 (defvar nnspool-rejected-article-hook)
503 (defvar xemacs-codename)
505 ;;; Since the X-Newsreader/X-Mailer are ``vanity'' headers, they might
506 ;;; as well include the Emacs version as well.
507 ;;; The following function works with later GNU Emacs, and XEmacs.
508 (defun gnus-extended-version ()
509 "Stringified Gnus version and Emacs version."
515 ((string-match "^\\([0-9]+\\.[0-9]+\\)\\.[.0-9]+$" emacs-version)
516 (concat "Emacs " (substring emacs-version
519 ((string-match "\\([A-Z]*[Mm][Aa][Cc][Ss]\\)[^(]*\\(\\((beta.*)\\|'\\)\\)?"
521 (concat (substring emacs-version
524 (format " %d.%d" emacs-major-version emacs-minor-version)
525 (if (match-beginning 3)
526 (substring emacs-version
530 (if (boundp 'xemacs-codename)
531 (concat " - \"" xemacs-codename "\""))))
534 ;; Written by "Mr. Per Persson" <pp@gnu.ai.mit.edu>.
535 (defun gnus-inews-insert-mime-headers ()
536 "Insert MIME headers.
537 Assumes ISO-Latin-1 is used iff 8-bit characters are present."
538 (goto-char (point-min))
539 (let ((mail-header-separator
541 (goto-char (point-min))
542 (if (and (search-forward (concat "\n" mail-header-separator "\n")
544 (not (search-backward "\n\n" nil t)))
545 mail-header-separator
547 (or (mail-position-on-field "Mime-Version")
549 (cond ((save-restriction
551 (goto-char (point-min))
552 (re-search-forward "[^\000-\177]" nil t))
553 (or (mail-position-on-field "Content-Type")
554 (insert "text/plain; charset=ISO-8859-1"))
555 (or (mail-position-on-field "Content-Transfer-Encoding")
557 (t (or (mail-position-on-field "Content-Type")
558 (insert "text/plain; charset=US-ASCII"))
559 (or (mail-position-on-field "Content-Transfer-Encoding")
560 (insert "7bit")))))))
562 (custom-add-option 'message-header-hook 'gnus-inews-insert-mime-headers)
566 ;;; Gnus Mail Functions
569 ;;; Mail reply commands of Gnus summary mode
571 (defun gnus-summary-reply (&optional yank wide)
572 "Start composing a reply mail to the current message.
573 If prefix argument YANK is non-nil, the original article is yanked
576 (list (and current-prefix-arg
577 (gnus-summary-work-articles 1))))
578 ;; Stripping headers should be specified with mail-yank-ignored-headers.
580 (gnus-summary-goto-subject (car yank)))
581 (let ((gnus-article-reply t))
582 (gnus-setup-message (if yank 'reply-yank 'reply)
583 (gnus-summary-select-article)
584 (set-buffer (gnus-copy-article-buffer))
585 (message-reply nil wide (gnus-group-find-parameter
586 gnus-newsgroup-name 'broken-reply-to))
588 (gnus-inews-yank-articles yank)))))
590 (defun gnus-summary-reply-with-original (n &optional wide)
591 "Start composing a reply mail to the current message.
592 The original article will be yanked."
594 (gnus-summary-reply (gnus-summary-work-articles n) wide))
596 (defun gnus-summary-wide-reply (&optional yank)
597 "Start composing a wide reply mail to the current message.
598 If prefix argument YANK is non-nil, the original article is yanked
601 (list (and current-prefix-arg
602 (gnus-summary-work-articles 1))))
603 (gnus-summary-reply yank t))
605 (defun gnus-summary-wide-reply-with-original (n)
606 "Start composing a wide reply mail to the current message.
607 The original article will be yanked."
609 (gnus-summary-reply-with-original n t))
611 (defun gnus-summary-mail-forward (&optional full-headers post)
612 "Forward the current message to another user.
613 If FULL-HEADERS (the prefix), include full headers when forwarding."
615 (gnus-setup-message 'forward
616 (gnus-summary-select-article)
617 (set-buffer gnus-original-article-buffer)
618 (let ((message-included-forward-headers
619 (if full-headers "" message-included-forward-headers)))
620 (message-forward post))))
622 (defun gnus-summary-resend-message (address n)
623 "Resend the current article to ADDRESS."
624 (interactive "sResend message(s) to: \nP")
625 (let ((articles (gnus-summary-work-articles n))
627 (while (setq article (pop articles))
628 (gnus-summary-select-article nil nil nil article)
630 (set-buffer gnus-original-article-buffer)
631 (message-resend address)))))
633 (defun gnus-summary-post-forward (&optional full-headers)
634 "Forward the current article to a newsgroup.
635 If FULL-HEADERS (the prefix), include full headers when forwarding."
637 (gnus-summary-mail-forward full-headers t))
639 (defvar gnus-nastygram-message
640 "The following article was inappropriately posted to %s.\n\n"
641 "Format string to insert in nastygrams.
642 The current group name will be inserted at \"%s\".")
644 (defun gnus-summary-mail-nastygram (n)
645 "Send a nastygram to the author of the current article."
647 (when (or gnus-expert-user
649 "Really send a nastygram to the author of the current article? "))
650 (let ((group gnus-newsgroup-name))
651 (gnus-summary-reply-with-original n)
652 (set-buffer gnus-message-buffer)
654 (insert (format gnus-nastygram-message group))
655 (message-send-and-exit))))
657 (defun gnus-summary-mail-crosspost-complaint (n)
658 "Send a complaint about crossposting to the current article(s)."
660 (let ((articles (gnus-summary-work-articles n))
662 (while (setq article (pop articles))
663 (set-buffer gnus-summary-buffer)
664 (gnus-summary-goto-subject article)
665 (let ((group (gnus-group-real-name gnus-newsgroup-name))
666 newsgroups followup-to)
667 (gnus-summary-select-article)
668 (set-buffer gnus-original-article-buffer)
669 (if (and (<= (length (message-tokenize-header
670 (setq newsgroups (mail-fetch-field "newsgroups"))
673 (or (not (setq followup-to (mail-fetch-field "followup-to")))
674 (not (member group (message-tokenize-header
675 followup-to ", ")))))
677 (gnus-message 1 "Followup-to restricted")
678 (gnus-message 1 "Not a crossposted article"))
679 (set-buffer gnus-summary-buffer)
680 (gnus-summary-reply-with-original 1)
681 (set-buffer gnus-message-buffer)
683 (insert (format gnus-crosspost-complaint newsgroups group))
684 (message-goto-subject)
685 (re-search-forward " *$")
686 (replace-match " (crosspost notification)" t t)
687 (gnus-deactivate-mark)
688 (when (gnus-y-or-n-p "Send this complaint? ")
689 (message-send-and-exit)))))))
691 (defun gnus-summary-mail-other-window ()
692 "Compose mail in other window."
694 (gnus-setup-message 'message
697 (defun gnus-mail-parse-comma-list ()
700 (skip-chars-forward " ")
703 (skip-chars-forward "^,")
708 (narrow-to-region beg (point))
711 (while (search-forward "\"" nil t)
715 (skip-chars-forward ",")
716 (skip-chars-forward "^,"))
717 (skip-chars-backward " ")
718 (push (buffer-substring beg (point))
720 (skip-chars-forward "^,")
721 (skip-chars-forward ", "))
724 (defun gnus-inews-add-to-address (group)
725 (let ((to-address (mail-fetch-field "to")))
726 (when (and to-address
728 ;; This mail group doesn't have a `to-list', so we add one
731 (format "Do you want to add this as `to-list': %s " to-address))
732 (gnus-group-add-parameter group (cons 'to-list to-address))))))
734 (defun gnus-put-message ()
735 "Put the current message in some group and return to Gnus."
737 (let ((reply gnus-article-reply)
738 (winconf gnus-prev-winconf)
739 (group gnus-newsgroup-name))
741 (or (and group (not (gnus-group-read-only-p group)))
742 (setq group (read-string "Put in group: " nil
743 (gnus-writable-groups))))
744 (when (gnus-gethash group gnus-newsrc-hashtb)
745 (error "No such group: %s" group))
750 (message-narrow-to-headers)
751 (let (gnus-deletable-headers)
753 (message-generate-headers message-required-news-headers)
754 (message-generate-headers message-required-mail-headers)))
755 (goto-char (point-max))
756 (insert "Gcc: " group "\n")
761 (when (get-buffer gnus-group-buffer)
762 (when (gnus-buffer-exists-p (car-safe reply))
763 (set-buffer (car reply))
765 (gnus-summary-mark-article-as-replied
768 (set-window-configuration winconf)))))
770 (defun gnus-article-mail (yank)
771 "Send a reply to the address near point.
772 If YANK is non-nil, include the original article."
776 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
777 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
779 (message-reply address)
781 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
783 (defvar nntp-server-type)
785 "Send a bug report to the Gnus maintainers."
787 (unless (gnus-alive-p)
788 (error "Gnus has been shut down"))
789 (gnus-setup-message 'bug
790 (delete-other-windows)
791 (when gnus-bug-create-help-buffer
792 (switch-to-buffer "*Gnus Help Bug*")
794 (insert gnus-bug-message)
795 (goto-char (point-min)))
796 (message-pop-to-buffer "*Gnus Bug*")
797 (message-setup `((To . ,gnus-maintainer) (Subject . "")))
798 (when gnus-bug-create-help-buffer
799 (push `(gnus-bug-kill-buffer) message-send-actions))
800 (goto-char (point-min))
801 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
803 (insert (gnus-version) "\n"
804 (emacs-version) "\n")
805 (when (and (boundp 'nntp-server-type)
806 (stringp nntp-server-type))
807 (insert nntp-server-type))
808 (insert "\n\n\n\n\n")
810 (goto-char (point-min))
811 (search-forward "Subject: " nil t)
814 (defun gnus-bug-kill-buffer ()
815 (when (get-buffer "*Gnus Help Bug*")
816 (kill-buffer "*Gnus Help Bug*")))
819 "Attempts to go through the Gnus source file and report what variables have been changed.
820 The source file has to be in the Emacs load path."
822 (let ((files '("gnus.el" "gnus-sum.el" "gnus-group.el"
823 "gnus-art.el" "gnus-start.el" "gnus-async.el"
824 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
825 "nnmail.el" "message.el"))
828 (gnus-message 4 "Please wait while we snoop your variables...")
830 ;; Go through all the files looking for non-default values for variables.
832 (set-buffer (get-buffer-create " *gnus bug info*"))
833 (buffer-disable-undo (current-buffer))
836 (when (and (setq file (locate-library (pop files)))
837 (file-exists-p file))
838 (insert-file-contents file)
839 (goto-char (point-min))
840 (if (not (re-search-forward "^;;* *Internal variables" nil t))
841 (gnus-message 4 "Malformed sources in file %s" file)
842 (narrow-to-region (point-min) (point))
843 (goto-char (point-min))
844 (while (setq expr (ignore-errors (read (current-buffer))))
846 (and (or (eq (car expr) 'defvar)
847 (eq (car expr) 'defcustom))
848 (stringp (nth 3 expr))
849 (or (not (boundp (nth 1 expr)))
850 (not (equal (eval (nth 2 expr))
851 (symbol-value (nth 1 expr)))))
852 (push (nth 1 expr) olist)))))))
853 (kill-buffer (current-buffer)))
854 (when (setq olist (nreverse olist))
855 (insert "------------------ Environment follows ------------------\n\n"))
857 (if (boundp (car olist))
859 (pp `(setq ,(car olist)
860 ,(if (or (consp (setq sym (symbol-value (car olist))))
862 (not (or (eq sym nil)
864 (list 'quote (symbol-value (car olist)))
865 (symbol-value (car olist))))
868 (format "(setq %s 'whatever)\n" (car olist))))
869 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
870 (setq olist (cdr olist)))
872 ;; Remove any control chars - they seem to cause trouble for some
873 ;; mailers. (Byte-compiled output from the stuff above.)
875 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
876 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
879 ;;; Treatment of rejected articles.
882 (defun gnus-summary-resend-bounced-mail (&optional fetch)
883 "Re-mail the current message.
884 This only makes sense if the current message is a bounce message than
885 contains some mail you have written which has been bounced back to
887 If FETCH, try to fetch the article that this is a reply to, if indeed
890 (gnus-summary-select-article t)
891 (set-buffer gnus-original-article-buffer)
892 (gnus-setup-message 'compose-bounce
893 (let* ((references (mail-fetch-field "references"))
894 (parent (and references (gnus-parent-id references))))
896 ;; If there are references, we fetch the article we answered to.
898 (gnus-summary-refer-article parent)
899 (gnus-summary-show-all-headers)))))
903 ;; Do Gcc handling, which copied the message over to some group.
904 (defun gnus-inews-do-gcc (&optional gcc)
909 (message-narrow-to-headers)
910 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
911 (cur (current-buffer))
914 (message-remove-header "gcc")
916 (setq groups (message-tokenize-header gcc " ,"))
917 ;; Copy the article over to some group(s).
918 (while (setq group (pop groups))
921 (cond ((and (null (gnus-get-info group))
922 (eq (car gnus-message-archive-method)
924 (gnus-server-to-method
925 (gnus-group-method group)))))
926 ;; If the group doesn't exist, we assume
927 ;; it's an archive group...
928 gnus-message-archive-method)
930 ((gnus-info-method (gnus-get-info group))
931 (gnus-info-method (gnus-get-info group)))
933 (t (gnus-group-method group)))))
934 (gnus-check-server method)
935 (unless (gnus-request-group group t method)
936 (gnus-request-create-group group method))
938 (nnheader-set-temp-buffer " *acc*")
939 (insert-buffer-substring cur)
940 (goto-char (point-min))
941 (when (re-search-forward
942 (concat "^" (regexp-quote mail-header-separator) "$")
944 (replace-match "" t t ))
945 (unless (gnus-request-accept-article group method t)
946 (gnus-message 1 "Couldn't store article in group %s: %s"
947 group (gnus-status-message method))
949 (kill-buffer (current-buffer))))))))))
951 (defun gnus-inews-insert-gcc ()
952 "Insert Gcc headers based on `gnus-outgoing-message-group'."
955 (message-narrow-to-headers)
956 (let* ((group gnus-outgoing-message-group)
958 ((gnus-functionp group)
960 ((or (stringp group) (list group))
964 (if (stringp gcc) gcc
965 (mapconcat 'identity gcc " "))
968 (defun gnus-inews-insert-archive-gcc (&optional group)
969 "Insert the Gcc to say where the article is to be archived."
970 (let* ((var gnus-message-archive-group)
971 (group (or group gnus-newsgroup-name ""))
973 (and gnus-newsgroup-name
974 (gnus-group-find-parameter
975 gnus-newsgroup-name 'gcc-self)))
979 ((null gnus-message-archive-method)
983 ;; Just a single group.
986 ;; We don't want this.
988 ((and (listp var) (stringp (car var)))
991 ((gnus-functionp var)
995 ;; An alist of regexps/functions/forms.
1000 ((stringp (caar var))
1002 (when (string-match (caar var) group)
1004 ((gnus-functionp (car var))
1006 (funcall (car var) group))
1008 (eval (car var)))))))
1009 (setq var (cdr var)))
1012 (when (or groups gcc-self-val)
1013 (when (stringp groups)
1014 (setq groups (list groups)))
1017 (message-narrow-to-headers)
1018 (goto-char (point-max))
1021 ;; Use the `gcc-self' param value instead.
1024 (if (stringp gcc-self-val)
1027 (if (not (eq gcc-self-val 'none))
1032 ;; Use the list of groups.
1033 (while (setq name (pop groups))
1034 (insert (if (string-match ":" name)
1036 (gnus-group-prefixed-name
1037 name gnus-message-archive-method)))
1042 ;;; Allow redefinition of functions.
1048 ;;; gnus-msg.el ends here