1 ;;; gnus-msg.el --- mail and post interface for Gnus
2 ;; Copyright (C) 1995,96 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.
34 ;; Added by Sudish Joseph <joseph@cis.ohio-state.edu>.
35 (defvar gnus-post-method nil
36 "*Preferred method for posting USENET news.
37 If this variable is nil, Gnus will use the current method to decide
38 which method to use when posting. If it is non-nil, it will override
39 the current method. This method will not be used in mail groups and
40 the like, only in \"real\" newsgroups.
42 The value must be a valid method as discussed in the documentation of
43 `gnus-select-method'. It can also be a list of methods. If that is
44 the case, the user will be queried for what select method to use when
47 (defvar gnus-outgoing-message-group nil
48 "*All outgoing messages will be put in this group.
49 If you want to store all your outgoing mail and articles in the group
50 \"nnml:archive\", you set this variable to that value. This variable
51 can also be a list of group names.
53 If you want to have greater control over what group to put each
54 message in, you can set this variable to a function that checks the
55 current newsgroup name and then returns a suitable group name (or list
58 (defvar gnus-mailing-list-groups nil
59 "*Regexp matching groups that are really mailing lists.
60 This is useful when you're reading a mailing list that has been
61 gatewayed to a newsgroup, and you want to followup to an article in
64 (defvar gnus-sent-message-ids-file
65 (nnheader-concat gnus-directory "Sent-Message-IDs")
66 "File where Gnus saves a cache of sent message ids.")
68 (defvar gnus-sent-message-ids-length 1000
69 "The number of sent Message-IDs to save.")
71 (defvar gnus-crosspost-complaint
74 You posted the article below with the following Newsgroups header:
78 The %s group, at least, was an inappropriate recipient
79 of this message. Please trim your Newsgroups header to exclude this
80 group before posting in the future.
85 "Format string to be inserted when complaining about crossposts.
86 The first %s will be replaced by the Newsgroups header;
87 the second with the current group name.")
89 ;;; Internal variables.
91 (defvar gnus-message-buffer "*Mail Gnus*")
92 (defvar gnus-article-copy nil)
93 (defvar gnus-last-posting-server nil)
95 (defconst gnus-bug-message
96 "Sending a bug report to the Gnus Towers.
97 ========================================
99 The buffer below is a mail buffer. When you press `C-c C-c', it will
100 be sent to the Gnus Bug Exterminators.
102 At the bottom of the buffer you'll see lots of variable settings.
103 Please do not delete those. They will tell the Bug People what your
104 environment is, so that it will be easier to locate the bugs.
106 If you have found a bug that makes Emacs go \"beep\", set
107 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
108 and include the backtrace in your bug report.
110 Please describe the bug in annoying, painstaking detail.
112 Thank you for your help in stamping out bugs.
116 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
117 (autoload 'news-setup "rnewspost")
118 (autoload 'news-reply-mode "rnewspost")
119 (autoload 'rmail-dont-reply-to "mail-utils")
120 (autoload 'rmail-output "rmailout"))
124 ;;; Gnus Posting Functions
127 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
128 "p" gnus-summary-post-news
129 "f" gnus-summary-followup
130 "F" gnus-summary-followup-with-original
131 "c" gnus-summary-cancel-article
132 "s" gnus-summary-supersede-article
133 "r" gnus-summary-reply
134 "R" gnus-summary-reply-with-original
135 "n" gnus-summary-followup-to-mail
136 "N" gnus-summary-followup-to-mail-with-original
137 "m" gnus-summary-mail-other-window
138 "u" gnus-uu-post-news
139 "\M-c" gnus-summary-mail-crosspost-complaint
140 "om" gnus-summary-mail-forward
141 "op" gnus-summary-post-forward
142 "Om" gnus-uu-digest-mail-forward
143 "Op" gnus-uu-digest-post-forward)
145 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
146 "b" gnus-summary-resend-bounced-mail
147 ;; "c" gnus-summary-send-draft
148 "r" gnus-summary-resend-message)
150 ;;; Internal functions.
152 (defvar gnus-article-reply nil)
153 (defmacro gnus-setup-message (config &rest forms)
154 (let ((winconf (make-symbol "winconf"))
155 (buffer (make-symbol "buffer"))
156 (article (make-symbol "article")))
157 `(let ((,winconf (current-window-configuration))
158 (,buffer (current-buffer))
159 (,article (and gnus-article-reply (gnus-summary-article-number)))
160 (message-header-setup-hook
161 (copy-sequence message-header-setup-hook)))
162 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
163 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
165 (gnus-inews-add-send-actions ,winconf ,buffer ,article)
166 (setq gnus-message-buffer (current-buffer))
167 (make-local-variable 'gnus-newsgroup-name)
168 (gnus-configure-windows ,config t))))
170 (defun gnus-inews-add-send-actions (winconf buffer article)
171 (gnus-make-local-hook 'message-sent-hook)
172 (gnus-add-hook 'message-sent-hook 'gnus-inews-do-gcc nil t)
173 (setq message-post-method
175 (gnus-post-method arg ,gnus-newsgroup-name)))
176 (setq message-newsreader (setq message-mailer (gnus-extended-version)))
178 `(set-window-configuration ,winconf) 'exit 'postpone 'kill)
180 `(when (buffer-name ,buffer)
184 `(gnus-summary-mark-article-as-replied ,article))))
187 (put 'gnus-setup-message 'lisp-indent-function 1)
188 (put 'gnus-setup-message 'edebug-form-spec '(form body))
190 ;;; Post news commands of Gnus group mode and summary mode
192 (defun gnus-group-mail ()
193 "Start composing a mail."
195 (gnus-setup-message 'message
198 (defun gnus-group-post-news (&optional arg)
199 "Start composing a news message.
200 If ARG, post to the group under point.
201 If ARG is 1, prompt for a group name."
203 ;; Bind this variable here to make message mode hooks
205 (let ((gnus-newsgroup-name
207 (if (= 1 (prefix-numeric-value arg))
208 (completing-read "Newsgroup: " gnus-active-hashtb nil
209 (gnus-read-active-file-p))
210 (gnus-group-group-name))
212 (gnus-post-news 'post gnus-newsgroup-name)))
214 (defun gnus-summary-post-news ()
215 "Start composing a news message."
217 (gnus-set-global-variables)
218 (gnus-post-news 'post gnus-newsgroup-name))
220 (defun gnus-summary-followup (yank &optional force-news)
221 "Compose a followup to an article.
222 If prefix argument YANK is non-nil, original article is yanked automatically."
224 (list (and current-prefix-arg
225 (gnus-summary-work-articles 1))))
226 (gnus-set-global-variables)
228 (gnus-summary-goto-subject (car yank)))
229 (save-window-excursion
230 (gnus-summary-select-article))
231 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
232 (gnus-newsgroup-name gnus-newsgroup-name))
234 (gnus-post-news nil gnus-newsgroup-name
235 headers gnus-article-buffer
236 yank nil force-news)))
238 (defun gnus-summary-followup-with-original (n &optional force-news)
239 "Compose a followup to an article and include the original article."
241 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
243 (defun gnus-summary-followup-to-mail (&optional arg)
244 "Followup to the current mail message via news."
246 (list (and current-prefix-arg
247 (gnus-summary-work-articles 1))))
248 (gnus-summary-followup arg t))
250 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
251 "Followup to the current mail message via news."
253 (gnus-summary-followup (gnus-summary-work-articles arg) t))
255 (defun gnus-inews-yank-articles (articles)
258 (while (setq article (pop articles))
259 (save-window-excursion
260 (set-buffer gnus-summary-buffer)
261 (gnus-summary-select-article nil nil nil article)
262 (gnus-summary-remove-process-mark article))
263 (gnus-copy-article-buffer)
264 (let ((message-reply-buffer gnus-article-copy)
265 (message-reply-headers gnus-current-headers))
266 (message-yank-original)
267 (setq beg (or beg (mark t))))
273 (defun gnus-summary-cancel-article (n)
274 "Cancel an article you posted."
276 (gnus-set-global-variables)
277 (let ((articles (gnus-summary-work-articles n))
280 (gnus-post-method nil ,gnus-newsgroup-name)))
282 (while (setq article (pop articles))
283 (when (gnus-summary-select-article t nil nil article)
284 (when (gnus-eval-in-buffer-window gnus-original-article-buffer
285 (message-cancel-news))
286 (gnus-summary-mark-as-read article gnus-canceled-mark)
287 (gnus-cache-remove-article 1))
288 (gnus-article-hide-headers-if-wanted))
289 (gnus-summary-remove-process-mark article))))
291 (defun gnus-summary-supersede-article ()
292 "Compose an article that will supersede a previous article.
293 This is done simply by taking the old article and adding a Supersedes
294 header line with the old Message-ID."
296 (gnus-set-global-variables)
297 (let ((article (gnus-summary-article-number)))
298 (gnus-setup-message 'reply-yank
299 (gnus-summary-select-article t)
300 (set-buffer gnus-original-article-buffer)
304 (gnus-cache-possibly-remove-article ,article nil nil nil t)))
305 message-send-actions))))
309 (defun gnus-copy-article-buffer (&optional article-buffer)
310 ;; make a copy of the article buffer with all text properties removed
311 ;; this copy is in the buffer gnus-article-copy.
312 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
313 ;; this buffer should be passed to all mail/news reply/post routines.
314 (setq gnus-article-copy (get-buffer-create " *gnus article copy*"))
315 (buffer-disable-undo gnus-article-copy)
316 (or (memq gnus-article-copy gnus-buffer-list)
317 (push gnus-article-copy gnus-buffer-list))
318 (let ((article-buffer (or article-buffer gnus-article-buffer))
320 (when (and (get-buffer article-buffer)
321 (buffer-name (get-buffer article-buffer)))
323 (set-buffer article-buffer)
325 ;; Copy over the (displayed) article buffer, delete
326 ;; hidden text and remove text properties.
328 (copy-to-buffer gnus-article-copy (point-min) (point-max))
329 (set-buffer gnus-article-copy)
330 (article-delete-text-of-type 'annotation)
333 (format "%s" (buffer-string))
335 ;; Find the original headers.
336 (set-buffer gnus-original-article-buffer)
337 (goto-char (point-min))
338 (while (looking-at message-unix-mail-delimiter)
341 (setq end (or (search-forward "\n\n" nil t) (point)))
342 ;; Delete the headers from the displayed articles.
343 (set-buffer gnus-article-copy)
344 (delete-region (goto-char (point-min))
345 (or (search-forward "\n\n" nil t) (point)))
346 ;; Insert the original article headers.
347 (insert-buffer-substring gnus-original-article-buffer beg end)
348 (article-decode-rfc1522)))
351 (defun gnus-post-news (post &optional group header article-buffer yank subject
354 (gnus-copy-article-buffer))
355 (let ((gnus-article-reply article-buffer))
356 (gnus-setup-message (cond (yank 'reply-yank)
357 (article-buffer 'reply)
359 (let* ((group (or group gnus-newsgroup-name))
361 to-address to-group mailing-list to-list
364 (setq to-address (gnus-group-find-parameter group 'to-address)
365 to-group (gnus-group-find-parameter group 'to-group)
366 to-list (gnus-group-find-parameter group 'to-list)
367 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
368 mailing-list (when gnus-mailing-list-groups
369 (string-match gnus-mailing-list-groups group))
370 group (gnus-group-real-name group)))
371 (if (or (and to-group
372 (gnus-news-group-p to-group))
375 (and (gnus-news-group-p
376 (or pgroup gnus-newsgroup-name)
377 (if header (mail-header-number header)
378 gnus-current-article))
384 (message-news (or to-group group))
385 (set-buffer gnus-article-copy)
386 (message-followup (if (or newsgroup-p force-news) nil to-group)))
390 (message-mail (or to-address to-list))
391 ;; Arrange for mail groups that have no `to-address' to
392 ;; get that when the user sends off the mail.
393 (push (list 'gnus-inews-add-to-address group)
394 message-send-actions))
395 (set-buffer gnus-article-copy)
396 (message-wide-reply to-address)))
398 (gnus-inews-yank-articles yank))))))
400 (defun gnus-post-method (arg group &optional silent)
401 "Return the posting method based on GROUP and ARG.
402 If SILENT, don't prompt the user."
403 (let ((group-method (gnus-find-method-for-group group)))
405 ;; If the group-method is nil (which shouldn't happen) we use
406 ;; the default method.
408 (or gnus-post-method gnus-select-method message-post-method))
409 ;; We want this group's method.
410 ((and arg (not (eq arg 0)))
412 ;; We query the user for a post method.
414 (and gnus-post-method
415 (listp (car gnus-post-method))))
417 ;; Collect all methods we know about.
419 (when gnus-post-method
420 (if (listp (car gnus-post-method))
422 (list gnus-post-method)))
423 gnus-secondary-select-methods
424 (list gnus-select-method)
425 (list group-method)))
426 method-alist post-methods method)
427 ;; Weed out all mail methods.
429 (setq method (gnus-server-get-method "" (pop methods)))
430 (when (or (gnus-method-option-p method 'post)
431 (gnus-method-option-p method 'post-mail))
432 (push method post-methods)))
433 ;; Create a name-method alist.
437 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m))
442 (setq gnus-last-posting-server
444 gnus-last-posting-server)
445 ;; Just use the last value.
446 gnus-last-posting-server
448 "Posting method: " method-alist nil t
449 (cons (or gnus-last-posting-server "") 0))))
451 ;; Override normal method.
454 ;; Use the normal select method.
455 (t gnus-select-method))))
457 (defun gnus-inews-narrow-to-headers ()
460 (goto-char (point-min))
461 (or (and (re-search-forward
462 (concat "^" (regexp-quote mail-header-separator) "$") nil t)
465 (goto-char (point-min)))
468 ;;; Check whether the message has been sent already.
471 (defvar gnus-inews-sent-ids nil)
473 (defun gnus-inews-reject-message ()
474 "Check whether this message has already been sent."
475 (when gnus-sent-message-ids-file
476 (let ((message-id (save-restriction (gnus-inews-narrow-to-headers)
477 (mail-fetch-field "message-id")))
480 (unless gnus-inews-sent-ids
483 (if (member message-id gnus-inews-sent-ids)
484 ;; Reject this message.
485 (not (gnus-yes-or-no-p
486 (format "Message %s already sent. Send anyway? "
488 (push message-id gnus-inews-sent-ids)
489 ;; Chop off the last Message-IDs.
490 (when (setq end (nthcdr gnus-sent-message-ids-length
491 gnus-inews-sent-ids))
493 (nnheader-temp-write gnus-sent-message-ids-file
494 (gnus-prin1 `(setq gnus-inews-sent-ids ',gnus-inews-sent-ids)))
499 ;; Dummy to avoid byte-compile warning.
500 (defvar nnspool-rejected-article-hook)
502 ;;; Since the X-Newsreader/X-Mailer are ``vanity'' headers, they might
503 ;;; as well include the Emacs version as well.
504 ;;; The following function works with later GNU Emacs, and XEmacs.
505 (defun gnus-extended-version ()
506 "Stringified Gnus version and Emacs version"
512 ((string-match "^\\([0-9]+\\.[0-9]+\\)\\.[.0-9]+$" emacs-version)
513 (concat "Emacs " (substring emacs-version
516 ((string-match "\\([A-Z]*[Mm][Aa][Cc][Ss]\\)" emacs-version)
517 (concat (substring emacs-version
520 (format " %d.%d" emacs-major-version emacs-minor-version)))
523 ;; Written by "Mr. Per Persson" <pp@gnu.ai.mit.edu>.
524 (defun gnus-inews-insert-mime-headers ()
525 (goto-char (point-min))
526 (let ((mail-header-separator
528 (goto-char (point-min))
529 (if (and (search-forward (concat "\n" mail-header-separator "\n")
531 (not (search-backward "\n\n" nil t)))
532 mail-header-separator
534 (or (mail-position-on-field "Mime-Version")
536 (cond ((save-restriction
538 (goto-char (point-min))
539 (re-search-forward "[\200-\377]" nil t))
540 (or (mail-position-on-field "Content-Type")
541 (insert "text/plain; charset=ISO-8859-1"))
542 (or (mail-position-on-field "Content-Transfer-Encoding")
544 (t (or (mail-position-on-field "Content-Type")
545 (insert "text/plain; charset=US-ASCII"))
546 (or (mail-position-on-field "Content-Transfer-Encoding")
547 (insert "7bit")))))))
551 ;;; Gnus Mail Functions
554 ;;; Mail reply commands of Gnus summary mode
556 (defun gnus-summary-reply (&optional yank)
557 "Reply mail to news author.
558 If prefix argument YANK is non-nil, original article is yanked automatically."
560 (list (and current-prefix-arg
561 (gnus-summary-work-articles 1))))
562 ;; Bug fix by jbw@bigbird.bu.edu (Joe Wells)
563 ;; Stripping headers should be specified with mail-yank-ignored-headers.
564 (gnus-set-global-variables)
566 (gnus-summary-goto-subject (car yank)))
567 (let ((gnus-article-reply t))
568 (gnus-setup-message (if yank 'reply-yank 'reply)
569 (gnus-summary-select-article)
570 (set-buffer (gnus-copy-article-buffer))
571 (message-reply nil nil (gnus-group-find-parameter
572 gnus-newsgroup-name 'broken-reply-to))
574 (gnus-inews-yank-articles yank)))))
576 (defun gnus-summary-reply-with-original (n)
577 "Reply mail to news author with original article."
579 (gnus-summary-reply (gnus-summary-work-articles n)))
581 (defun gnus-summary-mail-forward (&optional full-headers post)
582 "Forward the current message to another user.
583 If FULL-HEADERS (the prefix), include full headers when forwarding."
585 (gnus-set-global-variables)
586 (gnus-setup-message 'forward
587 (gnus-summary-select-article)
588 (set-buffer gnus-original-article-buffer)
589 (let ((message-included-forward-headers
590 (if full-headers "" message-included-forward-headers)))
591 (message-forward post))))
593 (defun gnus-summary-resend-message (address)
594 "Resend the current article to ADDRESS."
595 (interactive "sResend message to: ")
596 (gnus-summary-select-article)
598 (set-buffer gnus-original-article-buffer)
599 (message-resend address)))
601 (defun gnus-summary-post-forward (&optional full-headers)
602 "Forward the current article to a newsgroup.
603 If FULL-HEADERS (the prefix), include full headers when forwarding."
605 (gnus-summary-mail-forward full-headers t))
607 (defvar gnus-nastygram-message
608 "The following article was inappropriately posted to %s.\n\n"
609 "Format string to insert in nastygrams.
610 The current group name will be inserted at \"%s\".")
612 (defun gnus-summary-mail-nastygram (n)
613 "Send a nastygram to the author of the current article."
615 (when (or gnus-expert-user
617 "Really send a nastygram to the author of the current article? "))
618 (let ((group gnus-newsgroup-name))
619 (gnus-summary-reply-with-original n)
620 (set-buffer gnus-message-buffer)
622 (insert (format gnus-nastygram-message group))
623 (message-send-and-exit))))
625 (defun gnus-summary-mail-crosspost-complaint (n)
626 "Send a complaint about crossposting to the current article(s)."
628 (let ((articles (gnus-summary-work-articles n))
630 (while (setq article (pop articles))
631 (set-buffer gnus-summary-buffer)
632 (gnus-summary-goto-subject article)
633 (let ((group (gnus-group-real-name gnus-newsgroup-name))
634 newsgroups followup-to)
635 (gnus-summary-select-article)
636 (set-buffer gnus-original-article-buffer)
637 (if (and (<= (length (message-tokenize-header
638 (setq newsgroups (mail-fetch-field "newsgroups"))
641 (or (not (setq followup-to (mail-fetch-field "followup-to")))
642 (not (member group (message-tokenize-header
643 followup-to ", ")))))
645 (gnus-message 1 "Followup-to restricted")
646 (gnus-message 1 "Not a crossposted article"))
647 (set-buffer gnus-summary-buffer)
648 (gnus-summary-reply-with-original 1)
649 (set-buffer gnus-message-buffer)
651 (insert (format gnus-crosspost-complaint newsgroups group))
652 (message-goto-subject)
653 (re-search-forward " *$")
654 (replace-match " (crosspost notification)" t t)
655 (when (gnus-y-or-n-p "Send this complaint? ")
656 (message-send-and-exit)))))))
658 (defun gnus-summary-mail-other-window ()
659 "Compose mail in other window."
661 (gnus-setup-message 'message
664 (defun gnus-mail-parse-comma-list ()
667 (skip-chars-forward " ")
670 (skip-chars-forward "^,")
675 (narrow-to-region beg (point))
678 (while (search-forward "\"" nil t)
682 (skip-chars-forward ",")
683 (skip-chars-forward "^,"))
684 (skip-chars-backward " ")
685 (push (buffer-substring beg (point))
687 (skip-chars-forward "^,")
688 (skip-chars-forward ", "))
691 (defun gnus-inews-add-to-address (group)
692 (let ((to-address (mail-fetch-field "to")))
693 (when (and to-address
695 ;; This mail group doesn't have a `to-list', so we add one
697 (gnus-group-add-parameter group (cons 'to-list to-address)))))
699 (defun gnus-put-message ()
700 "Put the current message in some group and return to Gnus."
702 (let ((reply gnus-article-reply)
703 (winconf gnus-prev-winconf)
704 (group gnus-newsgroup-name))
706 (or (and group (not (gnus-group-read-only-p group)))
707 (setq group (read-string "Put in group: " nil
708 (gnus-writable-groups))))
709 (when (gnus-gethash group gnus-newsrc-hashtb)
710 (error "No such group: %s" group))
715 (gnus-inews-narrow-to-headers)
716 (let (gnus-deletable-headers)
718 (message-generate-headers message-required-news-headers)
719 (message-generate-headers message-required-mail-headers)))
720 (goto-char (point-max))
721 (insert "Gcc: " group "\n")
726 (when (get-buffer gnus-group-buffer)
727 (when (gnus-buffer-exists-p (car-safe reply))
728 (set-buffer (car reply))
730 (gnus-summary-mark-article-as-replied
733 (set-window-configuration winconf)))))
735 (defun gnus-article-mail (yank)
736 "Send a reply to the address near point.
737 If YANK is non-nil, include the original article."
741 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
742 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
744 (message-reply address)
746 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
749 "Send a bug report to the Gnus maintainers."
751 (unless (gnus-alive-p)
752 (error "Gnus has been shut down"))
753 (gnus-setup-message 'bug
754 (delete-other-windows)
755 (switch-to-buffer "*Gnus Help Bug*")
757 (insert gnus-bug-message)
758 (goto-char (point-min))
759 (message-pop-to-buffer "*Gnus Bug*")
760 (message-setup `((To . ,gnus-maintainer) (Subject . "")))
761 (push `(gnus-bug-kill-buffer) message-send-actions)
762 (goto-char (point-min))
763 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
765 (insert (gnus-version) "\n")
766 (insert (emacs-version))
767 (insert "\n\n\n\n\n")
769 (goto-char (point-min))
770 (search-forward "Subject: " nil t)
773 (defun gnus-bug-kill-buffer ()
774 (when (get-buffer "*Gnus Help Bug*")
775 (kill-buffer "*Gnus Help Bug*")))
778 "Attempts to go through the Gnus source file and report what variables have been changed.
779 The source file has to be in the Emacs load path."
781 (let ((files '("gnus.el" "gnus-sum.el" "gnus-group.el"
782 "gnus-art.el" "gnus-start.el"
783 "gnus-msg.el" "gnus-score.el" "gnus-win.el"
784 "nnmail.el" "message.el"))
786 (gnus-message 4 "Please wait while we snoop your variables...")
788 ;; Go through all the files looking for non-default values for variables.
790 (set-buffer (get-buffer-create " *gnus bug info*"))
791 (buffer-disable-undo (current-buffer))
794 (when (and (setq file (locate-library (pop files)))
795 (file-exists-p file))
796 (insert-file-contents file)
797 (goto-char (point-min))
798 (if (not (re-search-forward "^;;* *Internal variables" nil t))
799 (gnus-message 4 "Malformed sources in file %s" file)
800 (narrow-to-region (point-min) (point))
801 (goto-char (point-min))
802 (while (setq expr (ignore-errors (read (current-buffer))))
804 (and (or (eq (car expr) 'defvar)
805 (eq (car expr) 'defcustom))
806 (stringp (nth 3 expr))
807 (or (not (boundp (nth 1 expr)))
808 (not (equal (eval (nth 2 expr))
809 (symbol-value (nth 1 expr)))))
810 (push (nth 1 expr) olist)))))))
811 (kill-buffer (current-buffer)))
812 (when (setq olist (nreverse olist))
813 (insert "------------------ Environment follows ------------------\n\n"))
815 (if (boundp (car olist))
817 (pp `(setq ,(car olist)
818 ,(if (or (consp (setq sym (symbol-value (car olist))))
820 (not (or (eq sym nil)
822 (list 'quote (symbol-value (car olist)))
823 (symbol-value (car olist))))
826 (format "(setq %s 'whatever)\n" (car olist))))
827 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
828 (setq olist (cdr olist)))
830 ;; Remove any null chars - they seem to cause trouble for some
831 ;; mailers. (Byte-compiled output from the stuff above.)
832 (goto-char (point-min))
833 (while (re-search-forward "[\000\200]" nil t)
834 (replace-match "" t t))))
836 ;;; Treatment of rejected articles.
839 (defun gnus-summary-resend-bounced-mail (&optional fetch)
840 "Re-mail the current message.
841 This only makes sense if the current message is a bounce message than
842 contains some mail you have written which has been bounced back to
844 If FETCH, try to fetch the article that this is a reply to, if indeed
847 (gnus-summary-select-article t)
848 (set-buffer gnus-original-article-buffer)
849 (gnus-setup-message 'compose-bounce
850 (let* ((references (mail-fetch-field "references"))
851 (parent (and references (gnus-parent-id references))))
853 ;; If there are references, we fetch the article we answered to.
855 (gnus-summary-refer-article parent)
856 (gnus-summary-show-all-headers)))))
860 ;; Do Gcc handling, which copied the message over to some group.
861 (defun gnus-inews-do-gcc (&optional gcc)
865 (message-narrow-to-headers)
866 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
867 (cur (current-buffer))
870 (message-remove-header "gcc")
872 (setq groups (message-tokenize-header gcc " ,"))
873 ;; Copy the article over to some group(s).
874 (while (setq group (pop groups))
877 (cond ((and (null (gnus-get-info group))
878 (eq (car gnus-message-archive-method)
880 (gnus-server-to-method
881 (gnus-group-method group)))))
882 ;; If the group doesn't exist, we assume
883 ;; it's an archive group...
884 gnus-message-archive-method)
886 ((gnus-info-method (gnus-get-info group))
887 (gnus-info-method (gnus-get-info group)))
889 (t (gnus-group-method group)))))
890 (gnus-check-server method)
891 (unless (gnus-request-group group t method)
892 (gnus-request-create-group group method))
894 (nnheader-set-temp-buffer " *acc*")
895 (insert-buffer-substring cur)
896 (goto-char (point-min))
897 (when (re-search-forward
898 (concat "^" (regexp-quote mail-header-separator) "$")
900 (replace-match "" t t ))
901 (unless (gnus-request-accept-article group method t)
902 (gnus-message 1 "Couldn't store article in group %s: %s"
903 group (gnus-status-message method))
905 (kill-buffer (current-buffer))))))))))
907 (defun gnus-inews-insert-gcc ()
908 "Insert Gcc headers based on `gnus-outgoing-message-group'."
911 (gnus-inews-narrow-to-headers)
912 (let* ((group gnus-outgoing-message-group)
914 ((gnus-functionp group)
916 ((or (stringp group) (list group))
920 (if (stringp gcc) gcc
921 (mapconcat 'identity gcc " "))
924 (defun gnus-inews-insert-archive-gcc (&optional group)
925 "Insert the Gcc to say where the article is to be archived."
926 (let* ((var gnus-message-archive-group)
927 (group (or group gnus-newsgroup-name ""))
932 ((null gnus-message-archive-method)
936 ;; Just a single group.
939 ;; We don't want this.
941 ((and (listp var) (stringp (car var)))
944 ((gnus-functionp var)
948 ;; An alist of regexps/functions/forms.
953 ((stringp (caar var))
955 (when (string-match (caar var) group)
957 ((gnus-functionp (car var))
959 (funcall (car var) group))
961 (eval (car var)))))))
962 (setq var (cdr var)))
966 (when (stringp groups)
967 (setq groups (list groups)))
970 (gnus-inews-narrow-to-headers)
971 (goto-char (point-max))
973 (if (and gnus-newsgroup-name
975 (gnus-group-find-parameter
976 gnus-newsgroup-name 'gcc-self)))
979 (if (stringp gcc-self-val)
982 (if (not (eq gcc-self-val 'none))
987 (while (setq name (pop groups))
988 (insert (if (string-match ":" name)
990 (gnus-group-prefixed-name
991 name gnus-message-archive-method)))
996 (defun gnus-summary-send-draft ()
997 "Enter a mail/post buffer to edit and send the draft."
999 (gnus-set-global-variables)
1001 (if (not (setq buf (gnus-request-restore-buffer
1002 (gnus-summary-article-number) gnus-newsgroup-name)))
1003 (error "Couldn't restore the article")
1004 (switch-to-buffer buf)
1005 (when (eq major-mode 'news-reply-mode)
1006 (local-set-key "\C-c\C-c" 'gnus-inews-news))
1007 ;; Insert the separator.
1008 (goto-char (point-min))
1009 (search-forward "\n\n")
1011 (insert mail-header-separator)
1012 ;; Configure windows.
1013 (let ((gnus-draft-buffer (current-buffer)))
1014 (gnus-configure-windows 'draft t)
1015 (goto-char (point))))))
1017 (gnus-add-shutdown 'gnus-inews-close 'gnus)
1019 (defun gnus-inews-close ()
1020 (setq gnus-inews-sent-ids nil))
1022 ;;; Allow redefinition of functions.
1028 ;;; gnus-msg.el ends here