1 ;;; gnus-msg.el --- mail and post interface for Semi-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>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Keywords: mail, news, MIME
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
30 (eval-when-compile (require 'cl))
37 (defcustom gnus-post-method nil
38 "*Preferred method for posting USENET news.
40 If this variable is `current', Gnus will use the \"current\" select
41 method when posting. If it is nil (which is the default), Gnus will
42 use the native posting method of the server.
44 This method will not be used in mail groups and the like, only in
47 If not nil nor `native', the value must be a valid method as discussed
48 in the documentation of `gnus-select-method'. It can also be a list of
49 methods. If that is the case, the user will be queried for what select
50 method to use when posting."
51 :group 'gnus-group-foreign
52 :type `(choice (const nil)
55 (sexp :tag "Methods" ,gnus-select-method)))
57 (defvar gnus-outgoing-message-group nil
58 "*All outgoing messages will be put in this group.
59 If you want to store all your outgoing mail and articles in the group
60 \"nnml:archive\", you set this variable to that value. This variable
61 can also be a list of group names.
63 If you want to have greater control over what group to put each
64 message in, you can set this variable to a function that checks the
65 current newsgroup name and then returns a suitable group name (or list
68 (defvar gnus-mailing-list-groups nil
69 "*Regexp matching groups that are really mailing lists.
70 This is useful when you're reading a mailing list that has been
71 gatewayed to a newsgroup, and you want to followup to an article in
74 (defvar gnus-add-to-list nil
75 "*If non-nil, add a `to-list' parameter automatically.")
77 (defvar gnus-crosspost-complaint
80 You posted the article below with the following Newsgroups header:
84 The %s group, at least, was an inappropriate recipient
85 of this message. Please trim your Newsgroups header to exclude this
86 group before posting in the future.
91 "Format string to be inserted when complaining about crossposts.
92 The first %s will be replaced by the Newsgroups header;
93 the second with the current group name.")
95 (defvar gnus-message-setup-hook nil
96 "Hook run after setting up a message buffer.")
98 (defvar gnus-bug-create-help-buffer t
99 "*Should we create the *Gnus Help Bug* buffer?")
101 ;;; Internal variables.
103 (defvar gnus-message-buffer "*Mail Gnus*")
104 (defvar gnus-article-copy nil)
105 (defvar gnus-last-posting-server nil)
106 (defvar gnus-message-group-art nil)
108 (defconst gnus-bug-message
109 "Sending a bug report to the Gnus Towers.
110 ========================================
112 The buffer below is a mail buffer. When you press `C-c C-c', it will
113 be sent to the Gnus Bug Exterminators.
115 At the bottom of the buffer you'll see lots of variable settings.
116 Please do not delete those. They will tell the Bug People what your
117 environment is, so that it will be easier to locate the bugs.
119 If you have found a bug that makes Emacs go \"beep\", set
120 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
121 and include the backtrace in your bug report.
123 Please describe the bug in annoying, painstaking detail.
125 Thank you for your help in stamping out bugs.
129 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
130 (autoload 'news-setup "rnewspost")
131 (autoload 'news-reply-mode "rnewspost")
132 (autoload 'rmail-dont-reply-to "mail-utils")
133 (autoload 'rmail-output "rmailout"))
137 ;;; Gnus Posting Functions
140 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
141 "p" gnus-summary-post-news
142 "f" gnus-summary-followup
143 "F" gnus-summary-followup-with-original
144 "c" gnus-summary-cancel-article
145 "s" gnus-summary-supersede-article
146 "r" gnus-summary-reply
147 "R" gnus-summary-reply-with-original
148 "w" gnus-summary-wide-reply
149 "W" gnus-summary-wide-reply-with-original
150 "n" gnus-summary-followup-to-mail
151 "N" gnus-summary-followup-to-mail-with-original
152 "m" gnus-summary-mail-other-window
153 "u" gnus-uu-post-news
154 "\M-c" gnus-summary-mail-crosspost-complaint
155 "om" gnus-summary-mail-forward
156 "op" gnus-summary-post-forward
157 "Om" gnus-uu-digest-mail-forward
158 "Op" gnus-uu-digest-post-forward)
160 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
161 "b" gnus-summary-resend-bounced-mail
162 ;; "c" gnus-summary-send-draft
163 "r" gnus-summary-resend-message)
165 ;;; Internal functions.
167 (defvar gnus-article-reply nil)
168 (defmacro gnus-setup-message (config &rest forms)
169 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
170 (buffer (make-symbol "gnus-setup-message-buffer"))
171 (article (make-symbol "gnus-setup-message-article"))
172 (group (make-symbol "gnus-setup-message-group")))
173 `(let ((,winconf (current-window-configuration))
174 (,buffer (buffer-name (current-buffer)))
175 (,article (and gnus-article-reply (gnus-summary-article-number)))
176 (,group gnus-newsgroup-name)
177 (message-header-setup-hook
178 (copy-sequence message-header-setup-hook)))
179 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
180 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
184 (gnus-inews-add-send-actions ,winconf ,buffer ,article)
185 (setq gnus-message-buffer (current-buffer))
186 (set (make-local-variable 'gnus-message-group-art)
187 (cons ,group ,article))
188 (make-local-variable 'gnus-newsgroup-name)
189 (gnus-run-hooks 'gnus-message-setup-hook))
190 (gnus-configure-windows ,config t)
191 (set-buffer-modified-p nil))))
193 (defun gnus-inews-add-send-actions (winconf buffer article)
194 (make-local-hook 'message-sent-hook)
195 (add-hook 'message-sent-hook 'gnus-inews-do-gcc nil t)
196 (setq message-post-method
198 (gnus-post-method arg ,gnus-newsgroup-name)))
199 (setq message-newsreader (setq message-mailer (gnus-extended-version)))
201 `(set-window-configuration ,winconf) 'exit 'postpone 'kill)
203 `(when (gnus-buffer-exists-p ,buffer)
207 `(gnus-summary-mark-article-as-replied ,article))))
210 (put 'gnus-setup-message 'lisp-indent-function 1)
211 (put 'gnus-setup-message 'edebug-form-spec '(form body))
213 ;;; Post news commands of Gnus group mode and summary mode
215 (defun gnus-group-mail ()
216 "Start composing a mail."
218 (gnus-setup-message 'message
221 (defun gnus-group-post-news (&optional arg)
222 "Start composing a news message.
223 If ARG, post to the group under point.
224 If ARG is 1, prompt for a group name."
226 ;; Bind this variable here to make message mode hooks work ok.
227 (let ((gnus-newsgroup-name
229 (if (= 1 (prefix-numeric-value arg))
230 (completing-read "Newsgroup: " gnus-active-hashtb nil
231 (gnus-read-active-file-p))
232 (gnus-group-group-name))
234 (gnus-post-news 'post gnus-newsgroup-name)))
236 (defun gnus-summary-post-news ()
237 "Start composing a news message."
239 (gnus-post-news 'post gnus-newsgroup-name))
241 (defun gnus-summary-followup (yank &optional force-news)
242 "Compose a followup to an article.
243 If prefix argument YANK is non-nil, original article is yanked automatically."
245 (list (and current-prefix-arg
246 (gnus-summary-work-articles 1))))
248 (gnus-summary-goto-subject (car yank)))
249 (save-window-excursion
250 (gnus-summary-select-article))
251 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
252 (gnus-newsgroup-name gnus-newsgroup-name))
254 (gnus-post-news nil gnus-newsgroup-name
255 headers gnus-article-buffer
256 yank nil force-news)))
258 (defun gnus-summary-followup-with-original (n &optional force-news)
259 "Compose a followup to an article and include the original article."
261 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
263 (defun gnus-summary-followup-to-mail (&optional arg)
264 "Followup to the current mail message via news."
266 (list (and current-prefix-arg
267 (gnus-summary-work-articles 1))))
268 (gnus-summary-followup arg t))
270 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
271 "Followup to the current mail message via news."
273 (gnus-summary-followup (gnus-summary-work-articles arg) t))
275 (defun gnus-inews-yank-articles (articles)
278 (while (setq article (pop articles))
279 (save-window-excursion
280 (set-buffer gnus-summary-buffer)
281 (gnus-summary-select-article nil nil nil article)
282 (gnus-summary-remove-process-mark article))
283 (gnus-copy-article-buffer)
284 (let ((message-reply-buffer gnus-article-copy)
285 (message-reply-headers gnus-current-headers))
286 (message-yank-original)
287 (setq beg (or beg (mark t))))
293 (defun gnus-summary-cancel-article (&optional n symp)
294 "Cancel an article you posted.
295 Uses the process-prefix convention. If given the symbolic
296 prefix `a', cancel using the standard posting method; if not
297 post using the current select method."
298 (interactive (gnus-interactive "P\ny"))
299 (let ((articles (gnus-summary-work-articles n))
302 (gnus-post-method (not (eq symp 'a)) ,gnus-newsgroup-name)))
304 (while (setq article (pop articles))
305 (when (gnus-summary-select-article t nil nil article)
306 (when (gnus-eval-in-buffer-window gnus-article-buffer
308 (set-buffer gnus-original-article-buffer)
309 (message-cancel-news)))
310 (gnus-summary-mark-as-read article gnus-canceled-mark)
311 (gnus-cache-remove-article 1))
312 (gnus-article-hide-headers-if-wanted))
313 (gnus-summary-remove-process-mark article))))
315 (defun gnus-summary-supersede-article ()
316 "Compose an article that will supersede a previous article.
317 This is done simply by taking the old article and adding a Supersedes
318 header line with the old Message-ID."
320 (let ((article (gnus-summary-article-number)))
321 (gnus-setup-message 'reply-yank
322 (gnus-summary-select-article t)
323 (set-buffer gnus-original-article-buffer)
327 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
329 (set-buffer ,gnus-summary-buffer)
330 (gnus-cache-possibly-remove-article ,article nil nil nil t)
331 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
332 message-send-actions))))
336 (defun gnus-copy-article-buffer (&optional article-buffer)
337 ;; make a copy of the article buffer with all text properties removed
338 ;; this copy is in the buffer gnus-article-copy.
339 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
340 ;; this buffer should be passed to all mail/news reply/post routines.
341 (setq gnus-article-copy (get-buffer-create " *gnus article copy*"))
342 (buffer-disable-undo gnus-article-copy)
343 (or (memq gnus-article-copy gnus-buffer-list)
344 (push gnus-article-copy gnus-buffer-list))
345 (let ((article-buffer (or article-buffer gnus-article-buffer))
347 (if (not (and (get-buffer article-buffer)
348 (gnus-buffer-exists-p article-buffer)))
349 (error "Can't find any article buffer")
351 (set-buffer article-buffer)
353 ;; Copy over the (displayed) article buffer, delete
354 ;; hidden text and remove text properties.
356 (copy-to-buffer gnus-article-copy (point-min) (point-max))
357 (set-buffer gnus-article-copy)
358 (gnus-article-delete-text-of-type 'annotation)
359 (gnus-remove-text-with-property 'gnus-prev)
360 (gnus-remove-text-with-property 'gnus-next)
363 (format "%s" (buffer-string))
365 ;; Find the original headers.
366 (set-buffer gnus-original-article-buffer)
367 (goto-char (point-min))
368 (while (looking-at message-unix-mail-delimiter)
371 (setq end (or (search-forward "\n\n" nil t) (point)))
372 ;; Delete the headers from the displayed articles.
373 (set-buffer gnus-article-copy)
374 (delete-region (goto-char (point-min))
375 (or (search-forward "\n\n" nil t) (point)))
376 ;; Insert the original article headers.
377 (insert-buffer-substring gnus-original-article-buffer beg end)
378 (gnus-article-decode-rfc1522)))
381 (defun gnus-post-news (post &optional group header article-buffer yank subject
384 (gnus-copy-article-buffer))
385 (let ((gnus-article-reply article-buffer)
386 (add-to-list gnus-add-to-list))
387 (gnus-setup-message (cond (yank 'reply-yank)
388 (article-buffer 'reply)
390 (let* ((group (or group gnus-newsgroup-name))
392 to-address to-group mailing-list to-list
395 (setq to-address (gnus-group-find-parameter group 'to-address)
396 to-group (gnus-group-find-parameter group 'to-group)
397 to-list (gnus-group-find-parameter group 'to-list)
398 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
399 mailing-list (when gnus-mailing-list-groups
400 (string-match gnus-mailing-list-groups group))
401 group (gnus-group-real-name group)))
402 (if (or (and to-group
403 (gnus-news-group-p to-group))
406 (and (gnus-news-group-p
407 (or pgroup gnus-newsgroup-name)
408 (if header (mail-header-number header)
409 gnus-current-article))
415 (message-news (or to-group group))
416 (set-buffer gnus-article-copy)
417 (message-followup (if (or newsgroup-p force-news) nil to-group)))
421 (message-mail (or to-address to-list))
422 ;; Arrange for mail groups that have no `to-address' to
423 ;; get that when the user sends off the mail.
424 (when (and (not to-list)
427 (push (list 'gnus-inews-add-to-address pgroup)
428 message-send-actions)))
429 (set-buffer gnus-article-copy)
430 (gnus-msg-treat-broken-reply-to)
431 (message-wide-reply to-address)))
433 (gnus-inews-yank-articles yank))))))
435 (defun gnus-msg-treat-broken-reply-to ()
436 "Remove the Reply-to header iff broken-reply-to."
437 (when (gnus-group-find-parameter
438 gnus-newsgroup-name 'broken-reply-to)
440 (message-narrow-to-head)
441 (message-remove-header "reply-to"))))
443 (defun gnus-post-method (arg group &optional silent)
444 "Return the posting method based on GROUP and ARG.
445 If SILENT, don't prompt the user."
446 (let ((group-method (gnus-find-method-for-group group)))
448 ;; If the group-method is nil (which shouldn't happen) we use
449 ;; the default method.
451 (or (and (null (eq gnus-post-method 'active)) gnus-post-method)
452 gnus-select-method message-post-method))
453 ;; We want the inverse of the default
454 ((and arg (not (eq arg 0)))
455 (if (eq gnus-post-method 'active)
458 ;; We query the user for a post method.
460 (and gnus-post-method
461 (not (eq gnus-post-method 'current))
462 (listp (car gnus-post-method))))
464 ;; Collect all methods we know about.
466 (when (and gnus-post-method
467 (not (eq gnus-post-method 'current)))
468 (if (listp (car gnus-post-method))
470 (list gnus-post-method)))
471 gnus-secondary-select-methods
472 (mapcar 'cdr gnus-server-alist)
473 (list gnus-select-method)
474 (list group-method)))
475 method-alist post-methods method)
476 ;; Weed out all mail methods.
478 (setq method (gnus-server-get-method "" (pop methods)))
479 (when (or (gnus-method-option-p method 'post)
480 (gnus-method-option-p method 'post-mail))
481 (push method post-methods)))
482 ;; Create a name-method alist.
486 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m))
491 (setq gnus-last-posting-server
493 gnus-last-posting-server)
494 ;; Just use the last value.
495 gnus-last-posting-server
497 "Posting method: " method-alist nil t
498 (cons (or gnus-last-posting-server "") 0))))
500 ;; Override normal method.
501 ((and (eq gnus-post-method 'current)
506 ;; Use the normal select method.
507 (t gnus-select-method))))
511 ;; Dummy to avoid byte-compile warning.
512 (defvar nnspool-rejected-article-hook)
513 (defvar xemacs-codename)
515 ;;; Since the X-Newsreader/X-Mailer are ``vanity'' headers, they might
516 ;;; as well include the Emacs version as well.
517 ;;; The following function works with later GNU Emacs, and XEmacs.
518 (defun gnus-extended-version ()
519 "Stringified gnus version."
525 ;;; Gnus Mail Functions
528 ;;; Mail reply commands of Gnus summary mode
530 (defun gnus-summary-reply (&optional yank wide)
531 "Start composing a reply mail to the current message.
532 If prefix argument YANK is non-nil, the original article is yanked
535 (list (and current-prefix-arg
536 (gnus-summary-work-articles 1))))
537 ;; Stripping headers should be specified with mail-yank-ignored-headers.
539 (gnus-summary-goto-subject (car yank)))
540 (let ((gnus-article-reply t))
541 (gnus-setup-message (if yank 'reply-yank 'reply)
542 (gnus-summary-select-article)
543 (set-buffer (gnus-copy-article-buffer))
544 (gnus-msg-treat-broken-reply-to)
545 (message-reply nil wide)
547 (gnus-inews-yank-articles yank)))))
549 (defun gnus-summary-reply-with-original (n &optional wide)
550 "Start composing a reply mail to the current message.
551 The original article will be yanked."
553 (gnus-summary-reply (gnus-summary-work-articles n) wide))
555 (defun gnus-summary-wide-reply (&optional yank)
556 "Start composing a wide reply mail to the current message.
557 If prefix argument YANK is non-nil, the original article is yanked
560 (list (and current-prefix-arg
561 (gnus-summary-work-articles 1))))
562 (gnus-summary-reply yank t))
564 (defun gnus-summary-wide-reply-with-original (n)
565 "Start composing a wide reply mail to the current message.
566 The original article will be yanked."
568 (gnus-summary-reply-with-original n t))
570 (defun gnus-summary-mail-forward (&optional full-headers post)
571 "Forward the current message to another user.
572 If FULL-HEADERS (the prefix), include full headers when forwarding."
574 (gnus-setup-message 'forward
575 (gnus-summary-select-article)
576 (let ((charset default-mime-charset))
577 (set-buffer gnus-original-article-buffer)
578 (make-local-variable 'default-mime-charset)
579 (setq default-mime-charset charset)
581 (let ((message-included-forward-headers
582 (if full-headers "" message-included-forward-headers)))
583 (message-forward post))))
585 (defun gnus-summary-resend-message (address n)
586 "Resend the current article to ADDRESS."
587 (interactive "sResend message(s) to: \nP")
588 (let ((articles (gnus-summary-work-articles n))
590 (while (setq article (pop articles))
591 (gnus-summary-select-article nil nil nil article)
593 (set-buffer gnus-original-article-buffer)
594 (message-resend address)))))
596 (defun gnus-summary-post-forward (&optional full-headers)
597 "Forward the current article to a newsgroup.
598 If FULL-HEADERS (the prefix), include full headers when forwarding."
600 (gnus-summary-mail-forward full-headers t))
602 (defvar gnus-nastygram-message
603 "The following article was inappropriately posted to %s.\n\n"
604 "Format string to insert in nastygrams.
605 The current group name will be inserted at \"%s\".")
607 (defun gnus-summary-mail-nastygram (n)
608 "Send a nastygram to the author of the current article."
610 (when (or gnus-expert-user
612 "Really send a nastygram to the author of the current article? "))
613 (let ((group gnus-newsgroup-name))
614 (gnus-summary-reply-with-original n)
615 (set-buffer gnus-message-buffer)
617 (insert (format gnus-nastygram-message group))
618 (message-send-and-exit))))
620 (defun gnus-summary-mail-crosspost-complaint (n)
621 "Send a complaint about crossposting to the current article(s)."
623 (let ((articles (gnus-summary-work-articles n))
625 (while (setq article (pop articles))
626 (set-buffer gnus-summary-buffer)
627 (gnus-summary-goto-subject article)
628 (let ((group (gnus-group-real-name gnus-newsgroup-name))
629 newsgroups followup-to)
630 (gnus-summary-select-article)
631 (set-buffer gnus-original-article-buffer)
632 (if (and (<= (length (message-tokenize-header
633 (setq newsgroups (mail-fetch-field "newsgroups"))
636 (or (not (setq followup-to (mail-fetch-field "followup-to")))
637 (not (member group (message-tokenize-header
638 followup-to ", ")))))
640 (gnus-message 1 "Followup-to restricted")
641 (gnus-message 1 "Not a crossposted article"))
642 (set-buffer gnus-summary-buffer)
643 (gnus-summary-reply-with-original 1)
644 (set-buffer gnus-message-buffer)
646 (insert (format gnus-crosspost-complaint newsgroups group))
647 (message-goto-subject)
648 (re-search-forward " *$")
649 (replace-match " (crosspost notification)" t t)
650 (gnus-deactivate-mark)
651 (when (gnus-y-or-n-p "Send this complaint? ")
652 (message-send-and-exit)))))))
654 (defun gnus-summary-mail-other-window ()
655 "Compose mail in other window."
657 (gnus-setup-message 'message
660 (defun gnus-mail-parse-comma-list ()
663 (skip-chars-forward " ")
666 (skip-chars-forward "^,")
671 (narrow-to-region beg (point))
674 (while (search-forward "\"" nil t)
678 (skip-chars-forward ",")
679 (skip-chars-forward "^,"))
680 (skip-chars-backward " ")
681 (push (buffer-substring beg (point))
683 (skip-chars-forward "^,")
684 (skip-chars-forward ", "))
687 (defun gnus-inews-add-to-address (group)
688 (let ((to-address (mail-fetch-field "to")))
689 (when (and to-address
691 ;; This mail group doesn't have a `to-list', so we add one
694 (format "Do you want to add this as `to-list': %s " to-address))
695 (gnus-group-add-parameter group (cons 'to-list to-address))))))
697 (defun gnus-put-message ()
698 "Put the current message in some group and return to Gnus."
700 (let ((reply gnus-article-reply)
701 (winconf gnus-prev-winconf)
702 (group gnus-newsgroup-name))
704 (or (and group (not (gnus-group-read-only-p group)))
705 (setq group (read-string "Put in group: " nil
706 (gnus-writable-groups))))
707 (when (gnus-gethash group gnus-newsrc-hashtb)
708 (error "No such group: %s" group))
713 (message-narrow-to-headers)
714 (let (gnus-deletable-headers)
716 (message-generate-headers message-required-news-headers)
717 (message-generate-headers message-required-mail-headers)))
718 (goto-char (point-max))
719 (insert "Gcc: " group "\n")
724 (when (get-buffer gnus-group-buffer)
725 (when (gnus-buffer-exists-p (car-safe reply))
726 (set-buffer (car reply))
728 (gnus-summary-mark-article-as-replied
731 (set-window-configuration winconf)))))
733 (defun gnus-article-mail (yank)
734 "Send a reply to the address near point.
735 If YANK is non-nil, include the original article."
739 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
740 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
742 (message-reply address)
744 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
746 (defvar nntp-server-type)
748 "Send a bug report to the Gnus maintainers."
750 (unless (gnus-alive-p)
751 (error "Gnus has been shut down"))
752 (gnus-setup-message 'bug
753 (delete-other-windows)
754 (when gnus-bug-create-help-buffer
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 (when gnus-bug-create-help-buffer
762 (push `(gnus-bug-kill-buffer) message-send-actions))
763 (goto-char (point-min))
764 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
766 (insert (gnus-version) "\n"
767 (emacs-version) "\n")
768 (when (and (boundp 'nntp-server-type)
769 (stringp nntp-server-type))
770 (insert nntp-server-type))
771 (insert "\n\n\n\n\n")
773 (goto-char (point-min))
774 (search-forward "Subject: " nil t)
777 (defun gnus-bug-kill-buffer ()
778 (when (get-buffer "*Gnus Help Bug*")
779 (kill-buffer "*Gnus Help Bug*")))
782 "Attempts to go through the Gnus source file and report what variables have been changed.
783 The source file has to be in the Emacs load path."
785 (let ((files '("gnus.el" "gnus-sum.el" "gnus-group.el"
786 "gnus-art.el" "gnus-start.el" "gnus-async.el"
787 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
788 "nnmail.el" "message.el"))
791 (gnus-message 4 "Please wait while we snoop your variables...")
793 ;; Go through all the files looking for non-default values for variables.
795 (set-buffer (get-buffer-create " *gnus bug info*"))
796 (buffer-disable-undo (current-buffer))
799 (when (and (setq file (locate-library (pop files)))
800 (file-exists-p file))
801 (insert-file-contents file)
802 (goto-char (point-min))
803 (if (not (re-search-forward "^;;* *Internal variables" nil t))
804 (gnus-message 4 "Malformed sources in file %s" file)
805 (narrow-to-region (point-min) (point))
806 (goto-char (point-min))
807 (while (setq expr (ignore-errors (read (current-buffer))))
809 (and (or (eq (car expr) 'defvar)
810 (eq (car expr) 'defcustom))
811 (stringp (nth 3 expr))
812 (or (not (boundp (nth 1 expr)))
813 (not (equal (eval (nth 2 expr))
814 (symbol-value (nth 1 expr)))))
815 (push (nth 1 expr) olist)))))))
816 (kill-buffer (current-buffer)))
817 (when (setq olist (nreverse olist))
818 (insert "------------------ Environment follows ------------------\n\n"))
820 (if (boundp (car olist))
822 (pp `(setq ,(car olist)
823 ,(if (or (consp (setq sym (symbol-value (car olist))))
825 (not (or (eq sym nil)
827 (list 'quote (symbol-value (car olist)))
828 (symbol-value (car olist))))
831 (format "(setq %s 'whatever)\n" (car olist))))
832 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
833 (setq olist (cdr olist)))
835 ;; Remove any control chars - they seem to cause trouble for some
836 ;; mailers. (Byte-compiled output from the stuff above.)
838 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
839 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
842 ;;; Treatment of rejected articles.
845 (defun gnus-summary-resend-bounced-mail (&optional fetch)
846 "Re-mail the current message.
847 This only makes sense if the current message is a bounce message than
848 contains some mail you have written which has been bounced back to
850 If FETCH, try to fetch the article that this is a reply to, if indeed
853 (gnus-summary-select-article t)
854 (set-buffer gnus-original-article-buffer)
855 (gnus-setup-message 'compose-bounce
856 (let* ((references (mail-fetch-field "references"))
857 (parent (and references (gnus-parent-id references))))
859 ;; If there are references, we fetch the article we answered to.
861 (gnus-summary-refer-article parent)
862 (gnus-summary-show-all-headers)))))
866 ;; Do Gcc handling, which copied the message over to some group.
867 (defun gnus-inews-do-gcc (&optional gcc)
872 (message-narrow-to-headers)
873 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
874 (coding-system-for-write 'raw-text)
877 (message-remove-header "gcc")
879 (setq groups (message-tokenize-header gcc " ,"))
880 ;; Copy the article over to some group(s).
881 (while (setq group (pop groups))
884 (cond ((and (null (gnus-get-info group))
885 (eq (car gnus-message-archive-method)
887 (gnus-server-to-method
888 (gnus-group-method group)))))
889 ;; If the group doesn't exist, we assume
890 ;; it's an archive group...
891 gnus-message-archive-method)
893 ((gnus-info-method (gnus-get-info group))
894 (gnus-info-method (gnus-get-info group)))
896 (t (gnus-group-method group)))))
897 (gnus-check-server method)
898 (unless (gnus-request-group group t method)
899 (gnus-request-create-group group method))
901 (nnheader-set-temp-buffer " *acc*")
902 (insert-buffer-substring message-encoding-buffer)
903 (gnus-run-hooks 'gnus-before-do-gcc-hook)
904 (goto-char (point-min))
905 (when (re-search-forward
906 (concat "^" (regexp-quote mail-header-separator) "$")
908 (replace-match "" t t ))
909 (unless (gnus-request-accept-article group method t)
910 (gnus-message 1 "Couldn't store article in group %s: %s"
911 group (gnus-status-message method))
913 (kill-buffer (current-buffer))))))))))
915 (defun gnus-inews-insert-gcc ()
916 "Insert Gcc headers based on `gnus-outgoing-message-group'."
919 (message-narrow-to-headers)
920 (let* ((group gnus-outgoing-message-group)
922 ((gnus-functionp group)
924 ((or (stringp group) (list group))
928 (if (stringp gcc) gcc
929 (mapconcat 'identity gcc " "))
932 (defun gnus-inews-insert-archive-gcc (&optional group)
933 "Insert the Gcc to say where the article is to be archived."
934 (let* ((var gnus-message-archive-group)
935 (group (or group gnus-newsgroup-name ""))
937 (and gnus-newsgroup-name
938 (gnus-group-find-parameter
939 gnus-newsgroup-name 'gcc-self)))
943 ((null gnus-message-archive-method)
947 ;; Just a single group.
950 ;; We don't want this.
952 ((and (listp var) (stringp (car var)))
955 ((gnus-functionp var)
959 ;; An alist of regexps/functions/forms.
964 ((stringp (caar var))
966 (when (string-match (caar var) group)
968 ((gnus-functionp (car var))
970 (funcall (car var) group))
972 (eval (car var)))))))
973 (setq var (cdr var)))
976 (when (or groups gcc-self-val)
977 (when (stringp groups)
978 (setq groups (list groups)))
981 (message-narrow-to-headers)
982 (goto-char (point-max))
985 ;; Use the `gcc-self' param value instead.
988 (if (stringp gcc-self-val)
991 (if (not (eq gcc-self-val 'none))
996 ;; Use the list of groups.
997 (while (setq name (pop groups))
998 (insert (if (string-match ":" name)
1000 (gnus-group-prefixed-name
1001 name gnus-message-archive-method)))
1006 ;;; Allow redefinition of functions.
1012 ;;; gnus-msg.el ends here