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.
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 "w" gnus-summary-wide-reply
136 "W" gnus-summary-wide-reply-with-original
137 "n" gnus-summary-followup-to-mail
138 "N" gnus-summary-followup-to-mail-with-original
139 "m" gnus-summary-mail-other-window
140 "u" gnus-uu-post-news
141 "\M-c" gnus-summary-mail-crosspost-complaint
142 "om" gnus-summary-mail-forward
143 "op" gnus-summary-post-forward
144 "Om" gnus-uu-digest-mail-forward
145 "Op" gnus-uu-digest-post-forward)
147 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
148 "b" gnus-summary-resend-bounced-mail
149 ;; "c" gnus-summary-send-draft
150 "r" gnus-summary-resend-message)
152 ;;; Internal functions.
154 (defvar gnus-article-reply nil)
155 (defmacro gnus-setup-message (config &rest forms)
156 (let ((winconf (make-symbol "winconf"))
157 (buffer (make-symbol "buffer"))
158 (article (make-symbol "article")))
159 `(let ((,winconf (current-window-configuration))
160 (,buffer (buffer-name (current-buffer)))
161 (,article (and gnus-article-reply (gnus-summary-article-number)))
162 (message-header-setup-hook
163 (copy-sequence message-header-setup-hook)))
164 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
165 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
168 (gnus-inews-add-send-actions ,winconf ,buffer ,article)
169 (setq gnus-message-buffer (current-buffer))
170 (make-local-variable 'gnus-newsgroup-name))
171 (gnus-configure-windows ,config t))))
173 (defun gnus-inews-add-send-actions (winconf buffer article)
174 (gnus-make-local-hook 'message-sent-hook)
175 (gnus-add-hook 'message-sent-hook 'gnus-inews-do-gcc nil t)
176 (setq message-post-method
178 (gnus-post-method arg ,gnus-newsgroup-name)))
179 (setq message-newsreader (setq message-mailer (gnus-extended-version)))
181 `(set-window-configuration ,winconf) 'exit 'postpone 'kill)
183 `(when (buffer-name (get-buffer ,buffer))
185 (set-buffer (get-buffer ,buffer))
187 `(gnus-summary-mark-article-as-replied ,article))))
190 (put 'gnus-setup-message 'lisp-indent-function 1)
191 (put 'gnus-setup-message 'edebug-form-spec '(form body))
193 ;;; Post news commands of Gnus group mode and summary mode
195 (defun gnus-group-mail ()
196 "Start composing a mail."
198 (gnus-setup-message 'message
201 (defun gnus-group-post-news (&optional arg)
202 "Start composing a news message.
203 If ARG, post to the group under point.
204 If ARG is 1, prompt for a group name."
206 ;; Bind this variable here to make message mode hooks
208 (let ((gnus-newsgroup-name
210 (if (= 1 (prefix-numeric-value arg))
211 (completing-read "Newsgroup: " gnus-active-hashtb nil
212 (gnus-read-active-file-p))
213 (gnus-group-group-name))
215 (gnus-post-news 'post gnus-newsgroup-name)))
217 (defun gnus-summary-post-news ()
218 "Start composing a news message."
220 (gnus-set-global-variables)
221 (gnus-post-news 'post gnus-newsgroup-name))
223 (defun gnus-summary-followup (yank &optional force-news)
224 "Compose a followup to an article.
225 If prefix argument YANK is non-nil, original article is yanked automatically."
227 (list (and current-prefix-arg
228 (gnus-summary-work-articles 1))))
229 (gnus-set-global-variables)
231 (gnus-summary-goto-subject (car yank)))
232 (save-window-excursion
233 (gnus-summary-select-article))
234 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
235 (gnus-newsgroup-name gnus-newsgroup-name))
237 (gnus-post-news nil gnus-newsgroup-name
238 headers gnus-article-buffer
239 yank nil force-news)))
241 (defun gnus-summary-followup-with-original (n &optional force-news)
242 "Compose a followup to an article and include the original article."
244 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
246 (defun gnus-summary-followup-to-mail (&optional arg)
247 "Followup to the current mail message via news."
249 (list (and current-prefix-arg
250 (gnus-summary-work-articles 1))))
251 (gnus-summary-followup arg t))
253 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
254 "Followup to the current mail message via news."
256 (gnus-summary-followup (gnus-summary-work-articles arg) t))
258 (defun gnus-inews-yank-articles (articles)
261 (while (setq article (pop articles))
262 (save-window-excursion
263 (set-buffer gnus-summary-buffer)
264 (gnus-summary-select-article nil nil nil article)
265 (gnus-summary-remove-process-mark article))
266 (gnus-copy-article-buffer)
267 (let ((message-reply-buffer gnus-article-copy)
268 (message-reply-headers gnus-current-headers))
269 (message-yank-original)
270 (setq beg (or beg (mark t))))
276 (defun gnus-summary-cancel-article (n)
277 "Cancel an article you posted."
279 (gnus-set-global-variables)
280 (let ((articles (gnus-summary-work-articles n))
283 (gnus-post-method nil ,gnus-newsgroup-name)))
285 (while (setq article (pop articles))
286 (when (gnus-summary-select-article t nil nil article)
287 (when (gnus-eval-in-buffer-window gnus-original-article-buffer
288 (message-cancel-news))
289 (gnus-summary-mark-as-read article gnus-canceled-mark)
290 (gnus-cache-remove-article 1))
291 (gnus-article-hide-headers-if-wanted))
292 (gnus-summary-remove-process-mark article))))
294 (defun gnus-summary-supersede-article ()
295 "Compose an article that will supersede a previous article.
296 This is done simply by taking the old article and adding a Supersedes
297 header line with the old Message-ID."
299 (gnus-set-global-variables)
300 (let ((article (gnus-summary-article-number)))
301 (gnus-setup-message 'reply-yank
302 (gnus-summary-select-article t)
303 (set-buffer gnus-original-article-buffer)
307 (gnus-cache-possibly-remove-article ,article nil nil nil t)))
308 message-send-actions))))
312 (defun gnus-copy-article-buffer (&optional article-buffer)
313 ;; make a copy of the article buffer with all text properties removed
314 ;; this copy is in the buffer gnus-article-copy.
315 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
316 ;; this buffer should be passed to all mail/news reply/post routines.
317 (setq gnus-article-copy (get-buffer-create " *gnus article copy*"))
318 (buffer-disable-undo gnus-article-copy)
319 (or (memq gnus-article-copy gnus-buffer-list)
320 (push gnus-article-copy gnus-buffer-list))
321 (let ((article-buffer (or article-buffer gnus-article-buffer))
323 (if (not (and (get-buffer article-buffer)
324 (buffer-name (get-buffer article-buffer))))
325 (error "Can't find any article buffer")
327 (set-buffer article-buffer)
329 ;; Copy over the (displayed) article buffer, delete
330 ;; hidden text and remove text properties.
332 (copy-to-buffer gnus-article-copy (point-min) (point-max))
333 (set-buffer gnus-article-copy)
334 (gnus-article-delete-text-of-type 'annotation)
335 (gnus-remove-text-with-property 'gnus-prev)
336 (gnus-remove-text-with-property 'gnus-next)
339 (format "%s" (buffer-string))
341 ;; Find the original headers.
342 (set-buffer gnus-original-article-buffer)
343 (goto-char (point-min))
344 (while (looking-at message-unix-mail-delimiter)
347 (setq end (or (search-forward "\n\n" nil t) (point)))
348 ;; Delete the headers from the displayed articles.
349 (set-buffer gnus-article-copy)
350 (delete-region (goto-char (point-min))
351 (or (search-forward "\n\n" nil t) (point)))
352 ;; Insert the original article headers.
353 (insert-buffer-substring gnus-original-article-buffer beg end)
354 (gnus-article-decode-rfc1522)))
357 (defun gnus-post-news (post &optional group header article-buffer yank subject
360 (gnus-copy-article-buffer))
361 (let ((gnus-article-reply article-buffer))
362 (gnus-setup-message (cond (yank 'reply-yank)
363 (article-buffer 'reply)
365 (let* ((group (or group gnus-newsgroup-name))
367 to-address to-group mailing-list to-list
370 (setq to-address (gnus-group-find-parameter group 'to-address)
371 to-group (gnus-group-find-parameter group 'to-group)
372 to-list (gnus-group-find-parameter group 'to-list)
373 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
374 mailing-list (when gnus-mailing-list-groups
375 (string-match gnus-mailing-list-groups group))
376 group (gnus-group-real-name group)))
377 (if (or (and to-group
378 (gnus-news-group-p to-group))
381 (and (gnus-news-group-p
382 (or pgroup gnus-newsgroup-name)
383 (if header (mail-header-number header)
384 gnus-current-article))
390 (message-news (or to-group group))
391 (set-buffer gnus-article-copy)
392 (message-followup (if (or newsgroup-p force-news) nil to-group)))
396 (message-mail (or to-address to-list))
397 ;; Arrange for mail groups that have no `to-address' to
398 ;; get that when the user sends off the mail.
399 (push (list 'gnus-inews-add-to-address group)
400 message-send-actions))
401 (set-buffer gnus-article-copy)
402 (message-wide-reply to-address)))
404 (gnus-inews-yank-articles yank))))))
406 (defun gnus-post-method (arg group &optional silent)
407 "Return the posting method based on GROUP and ARG.
408 If SILENT, don't prompt the user."
409 (let ((group-method (gnus-find-method-for-group group)))
411 ;; If the group-method is nil (which shouldn't happen) we use
412 ;; the default method.
414 (or gnus-post-method gnus-select-method message-post-method))
415 ;; We want this group's method.
416 ((and arg (not (eq arg 0)))
418 ;; We query the user for a post method.
420 (and gnus-post-method
421 (listp (car gnus-post-method))))
423 ;; Collect all methods we know about.
425 (when gnus-post-method
426 (if (listp (car gnus-post-method))
428 (list gnus-post-method)))
429 gnus-secondary-select-methods
430 (list gnus-select-method)
431 (list group-method)))
432 method-alist post-methods method)
433 ;; Weed out all mail methods.
435 (setq method (gnus-server-get-method "" (pop methods)))
436 (when (or (gnus-method-option-p method 'post)
437 (gnus-method-option-p method 'post-mail))
438 (push method post-methods)))
439 ;; Create a name-method alist.
443 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m))
448 (setq gnus-last-posting-server
450 gnus-last-posting-server)
451 ;; Just use the last value.
452 gnus-last-posting-server
454 "Posting method: " method-alist nil t
455 (cons (or gnus-last-posting-server "") 0))))
457 ;; Override normal method.
460 ;; Use the normal select method.
461 (t gnus-select-method))))
463 (defun gnus-inews-narrow-to-headers ()
466 (goto-char (point-min))
467 (or (and (re-search-forward
468 (concat "^" (regexp-quote mail-header-separator) "$") nil t)
471 (goto-char (point-min)))
474 ;;; Check whether the message has been sent already.
477 (defvar gnus-inews-sent-ids nil)
479 (defun gnus-inews-reject-message ()
480 "Check whether this message has already been sent."
481 (when gnus-sent-message-ids-file
482 (let ((message-id (save-restriction (gnus-inews-narrow-to-headers)
483 (mail-fetch-field "message-id")))
486 (unless gnus-inews-sent-ids
489 (if (member message-id gnus-inews-sent-ids)
490 ;; Reject this message.
491 (not (gnus-yes-or-no-p
492 (format "Message %s already sent. Send anyway? "
494 (push message-id gnus-inews-sent-ids)
495 ;; Chop off the last Message-IDs.
496 (when (setq end (nthcdr gnus-sent-message-ids-length
497 gnus-inews-sent-ids))
499 (nnheader-temp-write gnus-sent-message-ids-file
500 (gnus-prin1 `(setq gnus-inews-sent-ids ',gnus-inews-sent-ids)))
505 ;; Dummy to avoid byte-compile warning.
506 (defvar nnspool-rejected-article-hook)
508 ;;; Since the X-Newsreader/X-Mailer are ``vanity'' headers, they might
509 ;;; as well include the Emacs version as well.
510 ;;; The following function works with later GNU Emacs, and XEmacs.
511 (defun gnus-extended-version ()
512 "Stringified Gnus version and Emacs version"
518 ((string-match "^\\([0-9]+\\.[0-9]+\\)\\.[.0-9]+$" emacs-version)
519 (concat "Emacs " (substring emacs-version
522 ((string-match "\\([A-Z]*[Mm][Aa][Cc][Ss]\\)" emacs-version)
523 (concat (substring emacs-version
526 (format " %d.%d" emacs-major-version emacs-minor-version)))
529 ;; Written by "Mr. Per Persson" <pp@gnu.ai.mit.edu>.
530 (defun gnus-inews-insert-mime-headers ()
531 (goto-char (point-min))
532 (let ((mail-header-separator
534 (goto-char (point-min))
535 (if (and (search-forward (concat "\n" mail-header-separator "\n")
537 (not (search-backward "\n\n" nil t)))
538 mail-header-separator
540 (or (mail-position-on-field "Mime-Version")
542 (cond ((save-restriction
544 (goto-char (point-min))
545 (re-search-forward "[\200-\377]" nil t))
546 (or (mail-position-on-field "Content-Type")
547 (insert "text/plain; charset=ISO-8859-1"))
548 (or (mail-position-on-field "Content-Transfer-Encoding")
550 (t (or (mail-position-on-field "Content-Type")
551 (insert "text/plain; charset=US-ASCII"))
552 (or (mail-position-on-field "Content-Transfer-Encoding")
553 (insert "7bit")))))))
557 ;;; Gnus Mail Functions
560 ;;; Mail reply commands of Gnus summary mode
562 (defun gnus-summary-reply (&optional yank wide)
563 "Start composing a reply mail to the current message.
564 If prefix argument YANK is non-nil, the original article is yanked
567 (list (and current-prefix-arg
568 (gnus-summary-work-articles 1))))
569 ;; Stripping headers should be specified with mail-yank-ignored-headers.
570 (gnus-set-global-variables)
572 (gnus-summary-goto-subject (car yank)))
573 (let ((gnus-article-reply t))
574 (gnus-setup-message (if yank 'reply-yank 'reply)
575 (gnus-summary-select-article)
576 (set-buffer (gnus-copy-article-buffer))
577 (message-reply nil wide (gnus-group-find-parameter
578 gnus-newsgroup-name 'broken-reply-to))
580 (gnus-inews-yank-articles yank)))))
582 (defun gnus-summary-reply-with-original (n &optional wide)
583 "Start composing a reply mail to the current message.
584 The original article will be yanked."
586 (gnus-summary-reply (gnus-summary-work-articles n)))
588 (defun gnus-summary-wide-reply (&optional yank)
589 "Start composing a wide 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 (gnus-summary-reply yank t))
597 (defun gnus-summary-wide-reply-with-original (n)
598 "Start composing a wide reply mail to the current message.
599 The original article will be yanked."
601 (gnus-summary-reply-with-original n t))
603 (defun gnus-summary-mail-forward (&optional full-headers post)
604 "Forward the current message to another user.
605 If FULL-HEADERS (the prefix), include full headers when forwarding."
607 (gnus-set-global-variables)
608 (gnus-setup-message 'forward
609 (gnus-summary-select-article)
610 (set-buffer gnus-original-article-buffer)
611 (let ((message-included-forward-headers
612 (if full-headers "" message-included-forward-headers)))
613 (message-forward post))))
615 (defun gnus-summary-resend-message (address)
616 "Resend the current article to ADDRESS."
617 (interactive "sResend message to: ")
618 (gnus-summary-select-article)
620 (set-buffer gnus-original-article-buffer)
621 (message-resend address)))
623 (defun gnus-summary-post-forward (&optional full-headers)
624 "Forward the current article to a newsgroup.
625 If FULL-HEADERS (the prefix), include full headers when forwarding."
627 (gnus-summary-mail-forward full-headers t))
629 (defvar gnus-nastygram-message
630 "The following article was inappropriately posted to %s.\n\n"
631 "Format string to insert in nastygrams.
632 The current group name will be inserted at \"%s\".")
634 (defun gnus-summary-mail-nastygram (n)
635 "Send a nastygram to the author of the current article."
637 (when (or gnus-expert-user
639 "Really send a nastygram to the author of the current article? "))
640 (let ((group gnus-newsgroup-name))
641 (gnus-summary-reply-with-original n)
642 (set-buffer gnus-message-buffer)
644 (insert (format gnus-nastygram-message group))
645 (message-send-and-exit))))
647 (defun gnus-summary-mail-crosspost-complaint (n)
648 "Send a complaint about crossposting to the current article(s)."
650 (let ((articles (gnus-summary-work-articles n))
652 (while (setq article (pop articles))
653 (set-buffer gnus-summary-buffer)
654 (gnus-summary-goto-subject article)
655 (let ((group (gnus-group-real-name gnus-newsgroup-name))
656 newsgroups followup-to)
657 (gnus-summary-select-article)
658 (set-buffer gnus-original-article-buffer)
659 (if (and (<= (length (message-tokenize-header
660 (setq newsgroups (mail-fetch-field "newsgroups"))
663 (or (not (setq followup-to (mail-fetch-field "followup-to")))
664 (not (member group (message-tokenize-header
665 followup-to ", ")))))
667 (gnus-message 1 "Followup-to restricted")
668 (gnus-message 1 "Not a crossposted article"))
669 (set-buffer gnus-summary-buffer)
670 (gnus-summary-reply-with-original 1)
671 (set-buffer gnus-message-buffer)
673 (insert (format gnus-crosspost-complaint newsgroups group))
674 (message-goto-subject)
675 (re-search-forward " *$")
676 (replace-match " (crosspost notification)" t t)
677 (when (gnus-y-or-n-p "Send this complaint? ")
678 (message-send-and-exit)))))))
680 (defun gnus-summary-mail-other-window ()
681 "Compose mail in other window."
683 (gnus-setup-message 'message
686 (defun gnus-mail-parse-comma-list ()
689 (skip-chars-forward " ")
692 (skip-chars-forward "^,")
697 (narrow-to-region beg (point))
700 (while (search-forward "\"" nil t)
704 (skip-chars-forward ",")
705 (skip-chars-forward "^,"))
706 (skip-chars-backward " ")
707 (push (buffer-substring beg (point))
709 (skip-chars-forward "^,")
710 (skip-chars-forward ", "))
713 (defun gnus-inews-add-to-address (group)
714 (let ((to-address (mail-fetch-field "to")))
715 (when (and to-address
717 ;; This mail group doesn't have a `to-list', so we add one
719 (gnus-group-add-parameter group (cons 'to-list to-address)))))
721 (defun gnus-put-message ()
722 "Put the current message in some group and return to Gnus."
724 (let ((reply gnus-article-reply)
725 (winconf gnus-prev-winconf)
726 (group gnus-newsgroup-name))
728 (or (and group (not (gnus-group-read-only-p group)))
729 (setq group (read-string "Put in group: " nil
730 (gnus-writable-groups))))
731 (when (gnus-gethash group gnus-newsrc-hashtb)
732 (error "No such group: %s" group))
737 (gnus-inews-narrow-to-headers)
738 (let (gnus-deletable-headers)
740 (message-generate-headers message-required-news-headers)
741 (message-generate-headers message-required-mail-headers)))
742 (goto-char (point-max))
743 (insert "Gcc: " group "\n")
748 (when (get-buffer gnus-group-buffer)
749 (when (gnus-buffer-exists-p (car-safe reply))
750 (set-buffer (car reply))
752 (gnus-summary-mark-article-as-replied
755 (set-window-configuration winconf)))))
757 (defun gnus-article-mail (yank)
758 "Send a reply to the address near point.
759 If YANK is non-nil, include the original article."
763 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
764 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
766 (message-reply address)
768 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
770 (defvar nntp-server-type)
772 "Send a bug report to the Gnus maintainers."
774 (unless (gnus-alive-p)
775 (error "Gnus has been shut down"))
776 (gnus-setup-message 'bug
777 (delete-other-windows)
778 (switch-to-buffer "*Gnus Help Bug*")
780 (insert gnus-bug-message)
781 (goto-char (point-min))
782 (message-pop-to-buffer "*Gnus Bug*")
783 (message-setup `((To . ,gnus-maintainer) (Subject . "")))
784 (push `(gnus-bug-kill-buffer) message-send-actions)
785 (goto-char (point-min))
786 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
788 (insert (gnus-version) "\n")
789 (insert (emacs-version) "\n")
790 (when (and (boundp 'nntp-server-type)
791 (stringp nntp-server-type))
792 (insert nntp-server-type))
793 (insert "\n\n\n\n\n")
795 (goto-char (point-min))
796 (search-forward "Subject: " nil t)
799 (defun gnus-bug-kill-buffer ()
800 (when (get-buffer "*Gnus Help Bug*")
801 (kill-buffer "*Gnus Help Bug*")))
804 "Attempts to go through the Gnus source file and report what variables have been changed.
805 The source file has to be in the Emacs load path."
807 (let ((files '("gnus.el" "gnus-sum.el" "gnus-group.el"
808 "gnus-art.el" "gnus-start.el" "gnus-async.el"
809 "gnus-msg.el" "gnus-score.el" "gnus-win.el"
810 "nnmail.el" "message.el"))
812 (gnus-message 4 "Please wait while we snoop your variables...")
814 ;; Go through all the files looking for non-default values for variables.
816 (set-buffer (get-buffer-create " *gnus bug info*"))
817 (buffer-disable-undo (current-buffer))
820 (when (and (setq file (locate-library (pop files)))
821 (file-exists-p file))
822 (insert-file-contents file)
823 (goto-char (point-min))
824 (if (not (re-search-forward "^;;* *Internal variables" nil t))
825 (gnus-message 4 "Malformed sources in file %s" file)
826 (narrow-to-region (point-min) (point))
827 (goto-char (point-min))
828 (while (setq expr (ignore-errors (read (current-buffer))))
830 (and (or (eq (car expr) 'defvar)
831 (eq (car expr) 'defcustom))
832 (stringp (nth 3 expr))
833 (or (not (boundp (nth 1 expr)))
834 (not (equal (eval (nth 2 expr))
835 (symbol-value (nth 1 expr)))))
836 (push (nth 1 expr) olist)))))))
837 (kill-buffer (current-buffer)))
838 (when (setq olist (nreverse olist))
839 (insert "------------------ Environment follows ------------------\n\n"))
841 (if (boundp (car olist))
843 (pp `(setq ,(car olist)
844 ,(if (or (consp (setq sym (symbol-value (car olist))))
846 (not (or (eq sym nil)
848 (list 'quote (symbol-value (car olist)))
849 (symbol-value (car olist))))
852 (format "(setq %s 'whatever)\n" (car olist))))
853 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
854 (setq olist (cdr olist)))
856 ;; Remove any null chars - they seem to cause trouble for some
857 ;; mailers. (Byte-compiled output from the stuff above.)
858 (goto-char (point-min))
859 (while (re-search-forward "[\000\200]" nil t)
860 (replace-match "" t t))))
862 ;;; Treatment of rejected articles.
865 (defun gnus-summary-resend-bounced-mail (&optional fetch)
866 "Re-mail the current message.
867 This only makes sense if the current message is a bounce message than
868 contains some mail you have written which has been bounced back to
870 If FETCH, try to fetch the article that this is a reply to, if indeed
873 (gnus-summary-select-article t)
874 (set-buffer gnus-original-article-buffer)
875 (gnus-setup-message 'compose-bounce
876 (let* ((references (mail-fetch-field "references"))
877 (parent (and references (gnus-parent-id references))))
879 ;; If there are references, we fetch the article we answered to.
881 (gnus-summary-refer-article parent)
882 (gnus-summary-show-all-headers)))))
886 ;; Do Gcc handling, which copied the message over to some group.
887 (defun gnus-inews-do-gcc (&optional gcc)
891 (message-narrow-to-headers)
892 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
893 (cur (current-buffer))
896 (message-remove-header "gcc")
898 (setq groups (message-tokenize-header gcc " ,"))
899 ;; Copy the article over to some group(s).
900 (while (setq group (pop groups))
903 (cond ((and (null (gnus-get-info group))
904 (eq (car gnus-message-archive-method)
906 (gnus-server-to-method
907 (gnus-group-method group)))))
908 ;; If the group doesn't exist, we assume
909 ;; it's an archive group...
910 gnus-message-archive-method)
912 ((gnus-info-method (gnus-get-info group))
913 (gnus-info-method (gnus-get-info group)))
915 (t (gnus-group-method group)))))
916 (gnus-check-server method)
917 (unless (gnus-request-group group t method)
918 (gnus-request-create-group group method))
920 (nnheader-set-temp-buffer " *acc*")
921 (insert-buffer-substring cur)
922 (goto-char (point-min))
923 (when (re-search-forward
924 (concat "^" (regexp-quote mail-header-separator) "$")
926 (replace-match "" t t ))
927 (unless (gnus-request-accept-article group method t)
928 (gnus-message 1 "Couldn't store article in group %s: %s"
929 group (gnus-status-message method))
931 (kill-buffer (current-buffer))))))))))
933 (defun gnus-inews-insert-gcc ()
934 "Insert Gcc headers based on `gnus-outgoing-message-group'."
937 (gnus-inews-narrow-to-headers)
938 (let* ((group gnus-outgoing-message-group)
940 ((gnus-functionp group)
942 ((or (stringp group) (list group))
946 (if (stringp gcc) gcc
947 (mapconcat 'identity gcc " "))
950 (defun gnus-inews-insert-archive-gcc (&optional group)
951 "Insert the Gcc to say where the article is to be archived."
952 (let* ((var gnus-message-archive-group)
953 (group (or group gnus-newsgroup-name ""))
958 ((null gnus-message-archive-method)
962 ;; Just a single group.
965 ;; We don't want this.
967 ((and (listp var) (stringp (car var)))
970 ((gnus-functionp var)
974 ;; An alist of regexps/functions/forms.
979 ((stringp (caar var))
981 (when (string-match (caar var) group)
983 ((gnus-functionp (car var))
985 (funcall (car var) group))
987 (eval (car var)))))))
988 (setq var (cdr var)))
992 (when (stringp groups)
993 (setq groups (list groups)))
996 (gnus-inews-narrow-to-headers)
997 (goto-char (point-max))
999 (if (and gnus-newsgroup-name
1001 (gnus-group-find-parameter
1002 gnus-newsgroup-name 'gcc-self)))
1005 (if (stringp gcc-self-val)
1008 (if (not (eq gcc-self-val 'none))
1013 (while (setq name (pop groups))
1014 (insert (if (string-match ":" name)
1016 (gnus-group-prefixed-name
1017 name gnus-message-archive-method)))
1022 (defun gnus-summary-send-draft ()
1023 "Enter a mail/post buffer to edit and send the draft."
1025 (gnus-set-global-variables)
1027 (if (not (setq buf (gnus-request-restore-buffer
1028 (gnus-summary-article-number) gnus-newsgroup-name)))
1029 (error "Couldn't restore the article")
1030 (switch-to-buffer buf)
1031 (when (eq major-mode 'news-reply-mode)
1032 (local-set-key "\C-c\C-c" 'gnus-inews-news))
1033 ;; Insert the separator.
1034 (goto-char (point-min))
1035 (search-forward "\n\n")
1037 (insert mail-header-separator)
1038 ;; Configure windows.
1039 (let ((gnus-draft-buffer (current-buffer)))
1040 (gnus-configure-windows 'draft t)
1041 (goto-char (point))))))
1043 (gnus-add-shutdown 'gnus-inews-close 'gnus)
1045 (defun gnus-inews-close ()
1046 (setq gnus-inews-sent-ids nil))
1048 ;;; Allow redefinition of functions.
1054 ;;; gnus-msg.el ends here