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 (defvar gnus-posting-styles nil
102 "*Alist of styles to use when posting.")
104 (defvar gnus-posting-style-alist
105 '((organization . message-user-organization)
106 (signature . message-signature)
107 (signature-file . message-signature-file)
108 (address . user-mail-address)
109 (name . user-full-name))
110 "*Mapping from style parameters to variables.")
112 ;;; Internal variables.
114 (defvar gnus-inhibit-posting-styles nil
115 "Inhibit the use of posting styles.")
117 (defvar gnus-message-buffer "*Mail Gnus*")
118 (defvar gnus-article-copy nil)
119 (defvar gnus-last-posting-server nil)
120 (defvar gnus-message-group-art nil)
122 (defconst gnus-bug-message
123 "Sending a bug report to the Gnus Towers.
124 ========================================
126 The buffer below is a mail buffer. When you press `C-c C-c', it will
127 be sent to the Gnus Bug Exterminators.
129 At the bottom of the buffer you'll see lots of variable settings.
130 Please do not delete those. They will tell the Bug People what your
131 environment is, so that it will be easier to locate the bugs.
133 If you have found a bug that makes Emacs go \"beep\", set
134 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
135 and include the backtrace in your bug report.
137 Please describe the bug in annoying, painstaking detail.
139 Thank you for your help in stamping out bugs.
143 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
144 (autoload 'news-setup "rnewspost")
145 (autoload 'news-reply-mode "rnewspost")
146 (autoload 'rmail-dont-reply-to "mail-utils")
147 (autoload 'rmail-output "rmailout"))
151 ;;; Gnus Posting Functions
154 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
155 "p" gnus-summary-post-news
156 "f" gnus-summary-followup
157 "F" gnus-summary-followup-with-original
158 "c" gnus-summary-cancel-article
159 "s" gnus-summary-supersede-article
160 "r" gnus-summary-reply
161 "R" gnus-summary-reply-with-original
162 "w" gnus-summary-wide-reply
163 "W" gnus-summary-wide-reply-with-original
164 "n" gnus-summary-followup-to-mail
165 "N" gnus-summary-followup-to-mail-with-original
166 "m" gnus-summary-mail-other-window
167 "u" gnus-uu-post-news
168 "\M-c" gnus-summary-mail-crosspost-complaint
169 "om" gnus-summary-mail-forward
170 "op" gnus-summary-post-forward
171 "Om" gnus-uu-digest-mail-forward
172 "Op" gnus-uu-digest-post-forward)
174 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
175 "b" gnus-summary-resend-bounced-mail
176 ;; "c" gnus-summary-send-draft
177 "r" gnus-summary-resend-message)
179 ;;; Internal functions.
181 (defvar gnus-article-reply nil)
182 (defmacro gnus-setup-message (config &rest forms)
183 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
184 (buffer (make-symbol "gnus-setup-message-buffer"))
185 (article (make-symbol "gnus-setup-message-article"))
186 (group (make-symbol "gnus-setup-message-group")))
187 `(let ((,winconf (current-window-configuration))
188 (,buffer (buffer-name (current-buffer)))
189 (,article (and gnus-article-reply (gnus-summary-article-number)))
190 (,group gnus-newsgroup-name)
191 (message-header-setup-hook
192 (copy-sequence message-header-setup-hook))
193 (message-mode-hook (copy-sequence message-mode-hook)))
194 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
195 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
196 (add-hook 'message-mode-hook 'gnus-configure-posting-styles)
200 (gnus-inews-add-send-actions ,winconf ,buffer ,article)
201 (setq gnus-message-buffer (current-buffer))
202 (set (make-local-variable 'gnus-message-group-art)
203 (cons ,group ,article))
204 (make-local-variable 'gnus-newsgroup-name)
205 (gnus-run-hooks 'gnus-message-setup-hook))
207 (gnus-configure-windows ,config t)
208 (set-buffer-modified-p nil))))
210 (defun gnus-inews-add-send-actions (winconf buffer article)
211 (make-local-hook 'message-sent-hook)
212 (add-hook 'message-sent-hook 'gnus-inews-do-gcc nil t)
213 (setq message-post-method
215 (gnus-post-method arg ,gnus-newsgroup-name)))
216 (setq message-user-agent (gnus-extended-version))
218 `(set-window-configuration ,winconf) 'exit 'postpone 'kill)
220 `(when (gnus-buffer-exists-p ,buffer)
224 `(gnus-summary-mark-article-as-replied ,article))))
227 (put 'gnus-setup-message 'lisp-indent-function 1)
228 (put 'gnus-setup-message 'edebug-form-spec '(form body))
230 ;;; Post news commands of Gnus group mode and summary mode
232 (defun gnus-group-mail ()
233 "Start composing a mail."
235 (gnus-setup-message 'message
238 (defun gnus-group-post-news (&optional arg)
239 "Start composing a news message.
240 If ARG, post to the group under point.
241 If ARG is 1, prompt for a group name."
243 ;; Bind this variable here to make message mode hooks work ok.
244 (let ((gnus-newsgroup-name
246 (if (= 1 (prefix-numeric-value arg))
247 (completing-read "Newsgroup: " gnus-active-hashtb nil
248 (gnus-read-active-file-p))
249 (gnus-group-group-name))
251 (gnus-post-news 'post gnus-newsgroup-name)))
253 (defun gnus-summary-post-news ()
254 "Start composing a news message."
256 (gnus-post-news 'post gnus-newsgroup-name))
258 (defun gnus-summary-followup (yank &optional force-news)
259 "Compose a followup to an article.
260 If prefix argument YANK is non-nil, original article is yanked automatically."
262 (list (and current-prefix-arg
263 (gnus-summary-work-articles 1))))
265 (gnus-summary-goto-subject (car yank)))
266 (save-window-excursion
267 (gnus-summary-select-article))
268 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
269 (gnus-newsgroup-name gnus-newsgroup-name))
271 (gnus-post-news nil gnus-newsgroup-name
272 headers gnus-article-buffer
273 yank nil force-news)))
275 (defun gnus-summary-followup-with-original (n &optional force-news)
276 "Compose a followup to an article and include the original article."
278 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
280 (defun gnus-summary-followup-to-mail (&optional arg)
281 "Followup to the current mail message via news."
283 (list (and current-prefix-arg
284 (gnus-summary-work-articles 1))))
285 (gnus-summary-followup arg t))
287 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
288 "Followup to the current mail message via news."
290 (gnus-summary-followup (gnus-summary-work-articles arg) t))
292 (defun gnus-inews-yank-articles (articles)
295 (while (setq article (pop articles))
296 (save-window-excursion
297 (set-buffer gnus-summary-buffer)
298 (gnus-summary-select-article nil nil nil article)
299 (gnus-summary-remove-process-mark article))
300 (gnus-copy-article-buffer)
301 (let ((message-reply-buffer gnus-article-copy)
302 (message-reply-headers gnus-current-headers))
303 (message-yank-original)
304 (setq beg (or beg (mark t))))
310 (defun gnus-summary-cancel-article (&optional n symp)
311 "Cancel an article you posted.
312 Uses the process-prefix convention. If given the symbolic
313 prefix `a', cancel using the standard posting method; if not
314 post using the current select method."
315 (interactive (gnus-interactive "P\ny"))
316 (let ((articles (gnus-summary-work-articles n))
319 (gnus-post-method (not (eq symp 'a)) ,gnus-newsgroup-name)))
321 (while (setq article (pop articles))
322 (when (gnus-summary-select-article t nil nil article)
323 (when (gnus-eval-in-buffer-window gnus-article-buffer
325 (set-buffer gnus-original-article-buffer)
326 (message-cancel-news)))
327 (gnus-summary-mark-as-read article gnus-canceled-mark)
328 (gnus-cache-remove-article 1))
329 (gnus-article-hide-headers-if-wanted))
330 (gnus-summary-remove-process-mark article))))
332 (defun gnus-summary-supersede-article ()
333 "Compose an article that will supersede a previous article.
334 This is done simply by taking the old article and adding a Supersedes
335 header line with the old Message-ID."
337 (let ((article (gnus-summary-article-number)))
338 (gnus-setup-message 'reply-yank
339 (gnus-summary-select-article t)
340 (set-buffer gnus-original-article-buffer)
344 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
346 (set-buffer ,gnus-summary-buffer)
347 (gnus-cache-possibly-remove-article ,article nil nil nil t)
348 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
349 message-send-actions))))
353 (defun gnus-copy-article-buffer (&optional article-buffer)
354 ;; make a copy of the article buffer with all text properties removed
355 ;; this copy is in the buffer gnus-article-copy.
356 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
357 ;; this buffer should be passed to all mail/news reply/post routines.
358 (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
359 (buffer-disable-undo gnus-article-copy)
360 (let ((article-buffer (or article-buffer gnus-article-buffer))
362 (if (not (and (get-buffer article-buffer)
363 (gnus-buffer-exists-p article-buffer)))
364 (error "Can't find any article buffer")
366 (set-buffer article-buffer)
368 ;; Copy over the (displayed) article buffer, delete
369 ;; hidden text and remove text properties.
371 (copy-to-buffer gnus-article-copy (point-min) (point-max))
372 (set-buffer gnus-article-copy)
373 (gnus-article-delete-text-of-type 'annotation)
374 (gnus-remove-text-with-property 'gnus-prev)
375 (gnus-remove-text-with-property 'gnus-next)
378 (format "%s" (buffer-string))
380 ;; Find the original headers.
381 (set-buffer gnus-original-article-buffer)
382 (goto-char (point-min))
383 (while (looking-at message-unix-mail-delimiter)
386 (setq end (or (search-forward "\n\n" nil t) (point)))
387 ;; Delete the headers from the displayed articles.
388 (set-buffer gnus-article-copy)
389 (delete-region (goto-char (point-min))
390 (or (search-forward "\n\n" nil t) (point)))
391 ;; Insert the original article headers.
392 (insert-buffer-substring gnus-original-article-buffer beg end)
393 (gnus-article-decode-rfc1522)))
396 (defun gnus-post-news (post &optional group header article-buffer yank subject
399 (gnus-copy-article-buffer))
400 (let ((gnus-article-reply article-buffer)
401 (add-to-list gnus-add-to-list))
402 (gnus-setup-message (cond (yank 'reply-yank)
403 (article-buffer 'reply)
405 (let* ((group (or group gnus-newsgroup-name))
407 to-address to-group mailing-list to-list
410 (setq to-address (gnus-group-find-parameter group 'to-address)
411 to-group (gnus-group-find-parameter group 'to-group)
412 to-list (gnus-group-find-parameter group 'to-list)
413 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
414 mailing-list (when gnus-mailing-list-groups
415 (string-match gnus-mailing-list-groups group))
416 group (gnus-group-real-name group)))
417 (if (or (and to-group
418 (gnus-news-group-p to-group))
421 (and (gnus-news-group-p
422 (or pgroup gnus-newsgroup-name)
423 (if header (mail-header-number header)
424 gnus-current-article))
430 (message-news (or to-group group))
431 (set-buffer gnus-article-copy)
432 (gnus-msg-treat-broken-reply-to)
433 (message-followup (if (or newsgroup-p force-news) nil to-group)))
437 (message-mail (or to-address to-list))
438 ;; Arrange for mail groups that have no `to-address' to
439 ;; get that when the user sends off the mail.
440 (when (and (not to-list)
443 (push (list 'gnus-inews-add-to-address pgroup)
444 message-send-actions)))
445 (set-buffer gnus-article-copy)
446 (gnus-msg-treat-broken-reply-to)
447 (message-wide-reply to-address)))
449 (gnus-inews-yank-articles yank))))))
451 (defun gnus-msg-treat-broken-reply-to ()
452 "Remove the Reply-to header iff broken-reply-to."
453 (when (gnus-group-find-parameter
454 gnus-newsgroup-name 'broken-reply-to)
456 (message-narrow-to-head)
457 (message-remove-header "reply-to"))))
459 (defun gnus-post-method (arg group &optional silent)
460 "Return the posting method based on GROUP and ARG.
461 If SILENT, don't prompt the user."
462 (let ((group-method (gnus-find-method-for-group group)))
464 ;; If the group-method is nil (which shouldn't happen) we use
465 ;; the default method.
467 (or (and (null (eq gnus-post-method 'active)) gnus-post-method)
468 gnus-select-method message-post-method))
469 ;; We want the inverse of the default
470 ((and arg (not (eq arg 0)))
471 (if (eq gnus-post-method 'active)
474 ;; We query the user for a post method.
476 (and gnus-post-method
477 (not (eq gnus-post-method 'current))
478 (listp (car gnus-post-method))))
480 ;; Collect all methods we know about.
482 (when (and gnus-post-method
483 (not (eq gnus-post-method 'current)))
484 (if (listp (car gnus-post-method))
486 (list gnus-post-method)))
487 gnus-secondary-select-methods
488 (mapcar 'cdr gnus-server-alist)
489 (list gnus-select-method)
490 (list group-method)))
491 method-alist post-methods method)
492 ;; Weed out all mail methods.
494 (setq method (gnus-server-get-method "" (pop methods)))
495 (when (or (gnus-method-option-p method 'post)
496 (gnus-method-option-p method 'post-mail))
497 (push method post-methods)))
498 ;; Create a name-method alist.
502 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m))
507 (setq gnus-last-posting-server
509 gnus-last-posting-server)
510 ;; Just use the last value.
511 gnus-last-posting-server
513 "Posting method: " method-alist nil t
514 (cons (or gnus-last-posting-server "") 0))))
516 ;; Override normal method.
517 ((and (eq gnus-post-method 'current)
518 (not (eq (car group-method) 'nndraft))
521 ((and gnus-post-method
522 (not (eq gnus-post-method 'current)))
524 ;; Use the normal select method.
525 (t gnus-select-method))))
529 ;; Dummy to avoid byte-compile warning.
530 (defvar nnspool-rejected-article-hook)
531 (defvar mule-version)
532 (defvar xemacs-betaname)
533 (defvar xemacs-codename)
535 (defun gnus-extended-version ()
536 "Stringified Gnus version and Emacs version."
540 gnus-product-name "/" gnus-version-number
542 (if (featurep 'xemacs)
545 (format " XEmacs/%d.%d%s" emacs-major-version emacs-minor-version
546 (if (and (boundp 'xemacs-betaname) xemacs-betaname)
547 (if (string-match "\\`(\\(.*\\))\\'" xemacs-betaname)
548 (match-string 1 xemacs-betaname)
551 (if (boundp 'xemacs-codename)
552 (concat " (" xemacs-codename ")")
557 (format " Emacs/%d.%d" emacs-major-version emacs-minor-version)
558 (if (and (boundp 'enable-multibyte-characters)
559 enable-multibyte-characters)
560 ;; Should return " (multibyte)" ?
566 (if (and (boundp 'mule-version) mule-version)
567 (concat " MULE/" mule-version)
568 " MULE") ; no mule-version
571 (if (featurep 'meadow)
572 (let ((version (Meadow-version)))
573 (if (string-match "\\`Meadow.\\([^ ]*\\)\\( (.*)\\)\\'" version)
575 (match-string 1 version)
576 (match-string 2 version)
578 "Meadow")) ; unknown format
584 ;;; Gnus Mail Functions
587 ;;; Mail reply commands of Gnus summary mode
589 (defun gnus-summary-reply (&optional yank wide)
590 "Start composing a reply mail to the current message.
591 If prefix argument YANK is non-nil, the original article is yanked
594 (list (and current-prefix-arg
595 (gnus-summary-work-articles 1))))
596 ;; Stripping headers should be specified with mail-yank-ignored-headers.
598 (gnus-summary-goto-subject (car yank)))
599 (let ((gnus-article-reply t)
600 (gnus-inhibit-posting-styles t))
601 (gnus-setup-message (if yank 'reply-yank 'reply)
602 (gnus-summary-select-article)
603 (set-buffer (gnus-copy-article-buffer))
604 (gnus-msg-treat-broken-reply-to)
605 (message-reply nil wide)
607 (gnus-inews-yank-articles yank)))))
609 (defun gnus-summary-reply-with-original (n &optional wide)
610 "Start composing a reply mail to the current message.
611 The original article will be yanked."
613 (gnus-summary-reply (gnus-summary-work-articles n) wide))
615 (defun gnus-summary-wide-reply (&optional yank)
616 "Start composing a wide reply mail to the current message.
617 If prefix argument YANK is non-nil, the original article is yanked
620 (list (and current-prefix-arg
621 (gnus-summary-work-articles 1))))
622 (gnus-summary-reply yank t))
624 (defun gnus-summary-wide-reply-with-original (n)
625 "Start composing a wide reply mail to the current message.
626 The original article will be yanked."
628 (gnus-summary-reply-with-original n t))
630 (defun gnus-summary-mail-forward (&optional full-headers post)
631 "Forward the current message to another user.
632 If FULL-HEADERS (the prefix), include full headers when forwarding."
634 (gnus-setup-message 'forward
635 (gnus-summary-select-article)
636 (let ((charset default-mime-charset))
637 (set-buffer gnus-original-article-buffer)
638 (make-local-variable 'default-mime-charset)
639 (setq default-mime-charset charset)
641 (let ((message-included-forward-headers
642 (if full-headers "" message-included-forward-headers)))
643 (message-forward post))))
645 (defun gnus-summary-resend-message (address n)
646 "Resend the current article to ADDRESS."
647 (interactive "sResend message(s) to: \nP")
648 (let ((articles (gnus-summary-work-articles n))
650 (while (setq article (pop articles))
651 (gnus-summary-select-article nil nil nil article)
653 (set-buffer gnus-original-article-buffer)
654 (message-resend address)))))
656 (defun gnus-summary-post-forward (&optional full-headers)
657 "Forward the current article to a newsgroup.
658 If FULL-HEADERS (the prefix), include full headers when forwarding."
660 (gnus-summary-mail-forward full-headers t))
662 (defvar gnus-nastygram-message
663 "The following article was inappropriately posted to %s.\n\n"
664 "Format string to insert in nastygrams.
665 The current group name will be inserted at \"%s\".")
667 (defun gnus-summary-mail-nastygram (n)
668 "Send a nastygram to the author of the current article."
670 (when (or gnus-expert-user
672 "Really send a nastygram to the author of the current article? "))
673 (let ((group gnus-newsgroup-name))
674 (gnus-summary-reply-with-original n)
675 (set-buffer gnus-message-buffer)
677 (insert (format gnus-nastygram-message group))
678 (message-send-and-exit))))
680 (defun gnus-summary-mail-crosspost-complaint (n)
681 "Send a complaint about crossposting to the current article(s)."
683 (let ((articles (gnus-summary-work-articles n))
685 (while (setq article (pop articles))
686 (set-buffer gnus-summary-buffer)
687 (gnus-summary-goto-subject article)
688 (let ((group (gnus-group-real-name gnus-newsgroup-name))
689 newsgroups followup-to)
690 (gnus-summary-select-article)
691 (set-buffer gnus-original-article-buffer)
692 (if (and (<= (length (message-tokenize-header
693 (setq newsgroups (mail-fetch-field "newsgroups"))
696 (or (not (setq followup-to (mail-fetch-field "followup-to")))
697 (not (member group (message-tokenize-header
698 followup-to ", ")))))
700 (gnus-message 1 "Followup-to restricted")
701 (gnus-message 1 "Not a crossposted article"))
702 (set-buffer gnus-summary-buffer)
703 (gnus-summary-reply-with-original 1)
704 (set-buffer gnus-message-buffer)
706 (insert (format gnus-crosspost-complaint newsgroups group))
707 (message-goto-subject)
708 (re-search-forward " *$")
709 (replace-match " (crosspost notification)" t t)
710 (gnus-deactivate-mark)
711 (when (gnus-y-or-n-p "Send this complaint? ")
712 (message-send-and-exit)))))))
714 (defun gnus-summary-mail-other-window ()
715 "Compose mail in other window."
717 (gnus-setup-message 'message
720 (defun gnus-mail-parse-comma-list ()
723 (skip-chars-forward " ")
726 (skip-chars-forward "^,")
731 (narrow-to-region beg (point))
734 (while (search-forward "\"" nil t)
738 (skip-chars-forward ",")
739 (skip-chars-forward "^,"))
740 (skip-chars-backward " ")
741 (push (buffer-substring beg (point))
743 (skip-chars-forward "^,")
744 (skip-chars-forward ", "))
747 (defun gnus-inews-add-to-address (group)
748 (let ((to-address (mail-fetch-field "to")))
749 (when (and to-address
751 ;; This mail group doesn't have a `to-list', so we add one
754 (format "Do you want to add this as `to-list': %s " to-address))
755 (gnus-group-add-parameter group (cons 'to-list to-address))))))
757 (defun gnus-put-message ()
758 "Put the current message in some group and return to Gnus."
760 (let ((reply gnus-article-reply)
761 (winconf gnus-prev-winconf)
762 (group gnus-newsgroup-name))
764 (or (and group (not (gnus-group-read-only-p group)))
765 (setq group (read-string "Put in group: " nil
766 (gnus-writable-groups))))
767 (when (gnus-gethash group gnus-newsrc-hashtb)
768 (error "No such group: %s" group))
773 (message-narrow-to-headers)
774 (let (gnus-deletable-headers)
776 (message-generate-headers message-required-news-headers)
777 (message-generate-headers message-required-mail-headers)))
778 (goto-char (point-max))
779 (insert "Gcc: " group "\n")
784 (when (get-buffer gnus-group-buffer)
785 (when (gnus-buffer-exists-p (car-safe reply))
786 (set-buffer (car reply))
788 (gnus-summary-mark-article-as-replied
791 (set-window-configuration winconf)))))
793 (defun gnus-article-mail (yank)
794 "Send a reply to the address near point.
795 If YANK is non-nil, include the original article."
799 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
800 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
802 (message-reply address)
804 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
806 (defvar nntp-server-type)
808 "Send a bug report to the Gnus maintainers."
810 (unless (gnus-alive-p)
811 (error "Gnus has been shut down"))
812 (gnus-setup-message 'bug
813 (delete-other-windows)
814 (when gnus-bug-create-help-buffer
815 (switch-to-buffer "*Gnus Help Bug*")
817 (insert gnus-bug-message)
818 (goto-char (point-min)))
819 (message-pop-to-buffer "*Gnus Bug*")
820 (message-setup `((To . ,gnus-maintainer) (Subject . "")))
821 (when gnus-bug-create-help-buffer
822 (push `(gnus-bug-kill-buffer) message-send-actions))
823 (goto-char (point-min))
824 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
826 (insert (gnus-version) "\n"
827 (emacs-version) "\n")
828 (when (and (boundp 'nntp-server-type)
829 (stringp nntp-server-type))
830 (insert nntp-server-type))
831 (insert "\n\n\n\n\n")
833 (goto-char (point-min))
834 (search-forward "Subject: " nil t)
837 (defun gnus-bug-kill-buffer ()
838 (when (get-buffer "*Gnus Help Bug*")
839 (kill-buffer "*Gnus Help Bug*")))
842 "Attempts to go through the Gnus source file and report what variables have been changed.
843 The source file has to be in the Emacs load path."
845 (let ((files '("gnus.el" "gnus-sum.el" "gnus-group.el"
846 "gnus-art.el" "gnus-start.el" "gnus-async.el"
847 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
848 "nnmail.el" "message.el"))
851 (gnus-message 4 "Please wait while we snoop your variables...")
853 ;; Go through all the files looking for non-default values for variables.
855 (set-buffer (gnus-get-buffer-create " *gnus bug info*"))
856 (buffer-disable-undo (current-buffer))
859 (when (and (setq file (locate-library (pop files)))
860 (file-exists-p file))
861 (insert-file-contents file)
862 (goto-char (point-min))
863 (if (not (re-search-forward "^;;* *Internal variables" nil t))
864 (gnus-message 4 "Malformed sources in file %s" file)
865 (narrow-to-region (point-min) (point))
866 (goto-char (point-min))
867 (while (setq expr (ignore-errors (read (current-buffer))))
869 (and (or (eq (car expr) 'defvar)
870 (eq (car expr) 'defcustom))
871 (stringp (nth 3 expr))
872 (or (not (boundp (nth 1 expr)))
873 (not (equal (eval (nth 2 expr))
874 (symbol-value (nth 1 expr)))))
875 (push (nth 1 expr) olist)))))))
876 (kill-buffer (current-buffer)))
877 (when (setq olist (nreverse olist))
878 (insert "------------------ Environment follows ------------------\n\n"))
880 (if (boundp (car olist))
882 (pp `(setq ,(car olist)
883 ,(if (or (consp (setq sym (symbol-value (car olist))))
885 (not (or (eq sym nil)
887 (list 'quote (symbol-value (car olist)))
888 (symbol-value (car olist))))
891 (format "(setq %s 'whatever)\n" (car olist))))
892 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
893 (setq olist (cdr olist)))
895 ;; Remove any control chars - they seem to cause trouble for some
896 ;; mailers. (Byte-compiled output from the stuff above.)
898 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
899 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
902 ;;; Treatment of rejected articles.
905 (defun gnus-summary-resend-bounced-mail (&optional fetch)
906 "Re-mail the current message.
907 This only makes sense if the current message is a bounce message than
908 contains some mail you have written which has been bounced back to
910 If FETCH, try to fetch the article that this is a reply to, if indeed
913 (gnus-summary-select-article t)
914 (set-buffer gnus-original-article-buffer)
915 (gnus-setup-message 'compose-bounce
916 (let* ((references (mail-fetch-field "references"))
917 (parent (and references (gnus-parent-id references))))
919 ;; If there are references, we fetch the article we answered to.
921 (gnus-summary-refer-article parent)
922 (gnus-summary-show-all-headers)))))
926 ;; Do Gcc handling, which copied the message over to some group.
927 (defun gnus-inews-do-gcc (&optional gcc)
932 (message-narrow-to-headers)
933 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
934 (coding-system-for-write 'raw-text)
937 (message-remove-header "gcc")
939 (setq groups (message-tokenize-header gcc " ,"))
940 ;; Copy the article over to some group(s).
941 (while (setq group (pop groups))
944 (cond ((and (null (gnus-get-info group))
945 (eq (car gnus-message-archive-method)
947 (gnus-server-to-method
948 (gnus-group-method group)))))
949 ;; If the group doesn't exist, we assume
950 ;; it's an archive group...
951 gnus-message-archive-method)
953 ((gnus-info-method (gnus-get-info group))
954 (gnus-info-method (gnus-get-info group)))
956 (t (gnus-group-method group)))))
957 (gnus-check-server method)
958 (unless (gnus-request-group group t method)
959 (gnus-request-create-group group method))
961 (nnheader-set-temp-buffer " *acc*")
962 (insert-buffer-substring message-encoding-buffer)
963 (gnus-run-hooks 'gnus-before-do-gcc-hook)
964 (goto-char (point-min))
965 (when (re-search-forward
966 (concat "^" (regexp-quote mail-header-separator) "$")
968 (replace-match "" t t ))
969 (unless (gnus-request-accept-article group method t)
970 (gnus-message 1 "Couldn't store article in group %s: %s"
971 group (gnus-status-message method))
973 (kill-buffer (current-buffer))))))))))
975 (defun gnus-inews-insert-gcc ()
976 "Insert Gcc headers based on `gnus-outgoing-message-group'."
979 (message-narrow-to-headers)
980 (let* ((group gnus-outgoing-message-group)
982 ((gnus-functionp group)
984 ((or (stringp group) (list group))
988 (if (stringp gcc) gcc
989 (mapconcat 'identity gcc " "))
992 (defun gnus-inews-insert-archive-gcc (&optional group)
993 "Insert the Gcc to say where the article is to be archived."
994 (let* ((var gnus-message-archive-group)
995 (group (or group gnus-newsgroup-name ""))
997 (and gnus-newsgroup-name
998 (gnus-group-find-parameter
999 gnus-newsgroup-name 'gcc-self)))
1003 ((null gnus-message-archive-method)
1007 ;; Just a single group.
1010 ;; We don't want this.
1012 ((and (listp var) (stringp (car var)))
1013 ;; A list of groups.
1015 ((gnus-functionp var)
1017 (funcall var group))
1019 ;; An alist of regexps/functions/forms.
1024 ((stringp (caar var))
1026 (when (string-match (caar var) group)
1028 ((gnus-functionp (car var))
1030 (funcall (car var) group))
1032 (eval (car var)))))))
1033 (setq var (cdr var)))
1036 (when (or groups gcc-self-val)
1037 (when (stringp groups)
1038 (setq groups (list groups)))
1041 (message-narrow-to-headers)
1042 (goto-char (point-max))
1045 ;; Use the `gcc-self' param value instead.
1048 (if (stringp gcc-self-val)
1051 (if (not (eq gcc-self-val 'none))
1056 ;; Use the list of groups.
1057 (while (setq name (pop groups))
1058 (insert (if (string-match ":" name)
1060 (gnus-group-prefixed-name
1061 name gnus-message-archive-method)))
1068 (defvar gnus-message-style-insertions nil)
1070 (defun gnus-configure-posting-styles ()
1071 "Configure posting styles according to `gnus-posting-styles'."
1072 (unless gnus-inhibit-posting-styles
1073 (let ((styles gnus-posting-styles)
1074 (gnus-newsgroup-name (or gnus-newsgroup-name ""))
1075 style match variable attribute value value-value)
1076 (make-local-variable 'gnus-message-style-insertions)
1077 ;; Go through all styles and look for matches.
1079 (setq style (pop styles)
1081 (when (cond ((stringp match)
1082 ;; Regexp string match on the group name.
1083 (string-match match gnus-newsgroup-name))
1084 ((or (symbolp match)
1085 (gnus-functionp match))
1086 (cond ((gnus-functionp match)
1087 ;; Function to be called.
1090 ;; Variable to be checked.
1091 (symbol-value match))))
1093 ;; This is a form to be evaled.
1095 ;; We have a match, so we set the variables.
1097 (setq attribute (pop style)
1098 value (cadr attribute)
1100 ;; We find the variable that is to be modified.
1101 (if (and (not (stringp (car attribute)))
1102 (not (eq 'body (car attribute)))
1104 (cdr (assq (car attribute)
1105 gnus-posting-style-alist)))))
1106 (message "Couldn't find attribute %s" (car attribute))
1107 ;; We get the value.
1109 (cond ((stringp value)
1111 ((or (symbolp value)
1112 (gnus-functionp value))
1113 (cond ((gnus-functionp value)
1116 (symbol-value value))))
1120 ;; This is an ordinary variable.
1121 (set (make-local-variable variable) value-value)
1122 ;; This is either a body or a header to be inserted in the
1125 (let ((attr (car attribute)))
1126 (make-local-variable 'message-setup-hook)
1128 (add-hook 'message-setup-hook
1132 (insert ,value-value))))
1133 (add-hook 'message-setup-hook
1134 'gnus-message-insert-stylings)
1135 (push (cons (if (stringp attr) attr
1138 gnus-message-style-insertions))))))))))))
1140 (defun gnus-message-insert-stylings ()
1144 (while (setq val (pop gnus-message-style-insertions))
1146 (insert (car val) ": " (cdr val) "\n"))
1147 (gnus-pull (car val) gnus-message-style-insertions)))))
1149 ;;; Allow redefinition of functions.
1155 ;;; gnus-msg.el ends here