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 ;; Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp>
8 ;; Keywords: mail, news, MIME
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
31 (eval-when-compile (require 'cl))
38 (defcustom gnus-post-method nil
39 "*Preferred method for posting USENET news.
41 If this variable is `current', Gnus will use the \"current\" select
42 method when posting. If it is nil (which is the default), Gnus will
43 use the native posting method of the server.
45 This method will not be used in mail groups and the like, only in
48 If not nil nor `native', the value must be a valid method as discussed
49 in the documentation of `gnus-select-method'. It can also be a list of
50 methods. If that is the case, the user will be queried for what select
51 method to use when posting."
52 :group 'gnus-group-foreign
53 :type `(choice (const nil)
56 (sexp :tag "Methods" ,gnus-select-method)))
58 (defvar gnus-outgoing-message-group nil
59 "*All outgoing messages will be put in this group.
60 If you want to store all your outgoing mail and articles in the group
61 \"nnml:archive\", you set this variable to that value. This variable
62 can also be a list of group names.
64 If you want to have greater control over what group to put each
65 message in, you can set this variable to a function that checks the
66 current newsgroup name and then returns a suitable group name (or list
69 (defvar gnus-mailing-list-groups nil
70 "*Regexp matching groups that are really mailing lists.
71 This is useful when you're reading a mailing list that has been
72 gatewayed to a newsgroup, and you want to followup to an article in
75 (defvar gnus-add-to-list nil
76 "*If non-nil, add a `to-list' parameter automatically.")
78 (defvar gnus-crosspost-complaint
81 You posted the article below with the following Newsgroups header:
85 The %s group, at least, was an inappropriate recipient
86 of this message. Please trim your Newsgroups header to exclude this
87 group before posting in the future.
92 "Format string to be inserted when complaining about crossposts.
93 The first %s will be replaced by the Newsgroups header;
94 the second with the current group name.")
96 (defvar gnus-message-setup-hook nil
97 "Hook run after setting up a message buffer.")
99 (defvar gnus-bug-create-help-buffer t
100 "*Should we create the *Gnus Help Bug* buffer?")
102 (defvar gnus-posting-styles nil
103 "*Alist of styles to use when posting.")
105 (defvar gnus-posting-style-alist
106 '((organization . message-user-organization)
107 (signature . message-signature)
108 (signature-file . message-signature-file)
109 (address . user-mail-address)
110 (name . user-full-name))
111 "*Mapping from style parameters to variables.")
113 ;;; Internal variables.
115 (defvar gnus-inhibit-posting-styles nil
116 "Inhibit the use of posting styles.")
118 (defvar gnus-message-buffer "*Mail Gnus*")
119 (defvar gnus-article-copy nil)
120 (defvar gnus-last-posting-server nil)
121 (defvar gnus-message-group-art nil)
123 (defconst gnus-bug-message
124 (format "Sending a bug report to the Gnus Towers.
125 ========================================
127 This gnus is the %s%s.
128 If you think the bug is a Semi-gnus bug, send a bug report to Semi-gnus
129 Developers. (the addresses below are mailing list addresses)
131 ========================================
133 The buffer below is a mail buffer. When you press `C-c C-c', it will
134 be sent to the Gnus Bug Exterminators.
136 At the bottom of the buffer you'll see lots of variable settings.
137 Please do not delete those. They will tell the Bug People what your
138 environment is, so that it will be easier to locate the bugs.
140 If you have found a bug that makes Emacs go \"beep\", set
141 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
142 and include the backtrace in your bug report.
144 Please describe the bug in annoying, painstaking detail.
146 Thank you for your help in stamping out bugs.
149 (if (string= gnus-product-name "Semi-gnus")
151 ", a modified version of Semi-gnus")))
154 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
155 (autoload 'news-setup "rnewspost")
156 (autoload 'news-reply-mode "rnewspost")
157 (autoload 'rmail-dont-reply-to "mail-utils")
158 (autoload 'rmail-output "rmailout"))
162 ;;; Gnus Posting Functions
165 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
166 "p" gnus-summary-post-news
167 "f" gnus-summary-followup
168 "F" gnus-summary-followup-with-original
169 "c" gnus-summary-cancel-article
170 "s" gnus-summary-supersede-article
171 "r" gnus-summary-reply
172 "R" gnus-summary-reply-with-original
173 "w" gnus-summary-wide-reply
174 "W" gnus-summary-wide-reply-with-original
175 "n" gnus-summary-followup-to-mail
176 "N" gnus-summary-followup-to-mail-with-original
177 "m" gnus-summary-mail-other-window
178 "u" gnus-uu-post-news
179 "\M-c" gnus-summary-mail-crosspost-complaint
180 "om" gnus-summary-mail-forward
181 "op" gnus-summary-post-forward
182 "Om" gnus-summary-mail-digest
183 "Op" gnus-summary-post-digest)
185 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
186 "b" gnus-summary-resend-bounced-mail
187 ;; "c" gnus-summary-send-draft
188 "r" gnus-summary-resend-message)
190 ;;; Internal functions.
192 (defun gnus-extended-version ()
193 "Stringified gnus version."
195 (concat gnus-product-name "/" gnus-version-number))
197 (defvar gnus-article-reply nil)
198 (defmacro gnus-setup-message (config &rest forms)
199 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
200 (buffer (make-symbol "gnus-setup-message-buffer"))
201 (article (make-symbol "gnus-setup-message-article"))
202 (group (make-symbol "gnus-setup-message-group")))
203 `(let ((,winconf (current-window-configuration))
204 (,buffer (buffer-name (current-buffer)))
205 (,article (and gnus-article-reply (gnus-summary-article-number)))
206 (,group gnus-newsgroup-name)
207 (message-header-setup-hook
208 (copy-sequence message-header-setup-hook))
209 (message-mode-hook (copy-sequence message-mode-hook)))
210 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
211 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
212 (add-hook 'message-mode-hook 'gnus-configure-posting-styles)
213 (add-hook 'message-mode-hook
215 (setq message-user-agent (gnus-extended-version))))
219 (gnus-inews-add-send-actions ,winconf ,buffer ,article)
220 (setq gnus-message-buffer (current-buffer))
221 (set (make-local-variable 'gnus-message-group-art)
222 (cons ,group ,article))
223 (make-local-variable 'gnus-newsgroup-name)
224 (gnus-run-hooks 'gnus-message-setup-hook))
226 (gnus-configure-windows ,config t)
227 (set-buffer-modified-p nil))))
229 (defun gnus-inews-add-send-actions (winconf buffer article)
230 (make-local-hook 'message-sent-hook)
231 (add-hook 'message-sent-hook 'gnus-inews-do-gcc nil t)
232 (setq message-post-method
234 (gnus-post-method arg ,gnus-newsgroup-name)))
236 `(set-window-configuration ,winconf) 'exit 'postpone 'kill)
238 `(when (gnus-buffer-exists-p ,buffer)
242 `(gnus-summary-mark-article-as-replied ,article))))
245 (put 'gnus-setup-message 'lisp-indent-function 1)
246 (put 'gnus-setup-message 'edebug-form-spec '(form body))
248 ;;; Post news commands of Gnus group mode and summary mode
250 (defun gnus-group-mail ()
251 "Start composing a mail."
253 (gnus-setup-message 'message
256 (defun gnus-group-post-news (&optional arg)
257 "Start composing a news message.
258 If ARG, post to the group under point.
259 If ARG is 1, prompt for a group name."
261 ;; Bind this variable here to make message mode hooks work ok.
262 (let ((gnus-newsgroup-name
264 (if (= 1 (prefix-numeric-value arg))
265 (completing-read "Newsgroup: " gnus-active-hashtb nil
266 (gnus-read-active-file-p))
267 (gnus-group-group-name))
269 (gnus-post-news 'post gnus-newsgroup-name)))
271 (defun gnus-summary-post-news ()
272 "Start composing a news message."
274 (gnus-post-news 'post gnus-newsgroup-name))
276 (defun gnus-summary-followup (yank &optional force-news)
277 "Compose a followup to an article.
278 If prefix argument YANK is non-nil, original article is yanked automatically."
280 (list (and current-prefix-arg
281 (gnus-summary-work-articles 1))))
283 (gnus-summary-goto-subject (car yank)))
284 (save-window-excursion
285 (gnus-summary-select-article))
286 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
287 (gnus-newsgroup-name gnus-newsgroup-name))
289 (gnus-post-news nil gnus-newsgroup-name
290 headers gnus-article-buffer
291 yank nil force-news)))
293 (defun gnus-summary-followup-with-original (n &optional force-news)
294 "Compose a followup to an article and include the original article."
296 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
298 (defun gnus-summary-followup-to-mail (&optional arg)
299 "Followup to the current mail message via news."
301 (list (and current-prefix-arg
302 (gnus-summary-work-articles 1))))
303 (gnus-summary-followup arg t))
305 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
306 "Followup to the current mail message via news."
308 (gnus-summary-followup (gnus-summary-work-articles arg) t))
310 (defun gnus-inews-yank-articles (articles)
313 (while (setq article (pop articles))
314 (save-window-excursion
315 (set-buffer gnus-summary-buffer)
316 (gnus-summary-select-article nil nil nil article)
317 (gnus-summary-remove-process-mark article))
318 (gnus-copy-article-buffer)
319 (let ((message-reply-buffer gnus-article-copy)
320 (message-reply-headers gnus-current-headers))
321 (message-yank-original)
322 (setq beg (or beg (mark t))))
328 (defun gnus-summary-cancel-article (&optional n symp)
329 "Cancel an article you posted.
330 Uses the process-prefix convention. If given the symbolic
331 prefix `a', cancel using the standard posting method; if not
332 post using the current select method."
333 (interactive (gnus-interactive "P\ny"))
334 (let ((articles (gnus-summary-work-articles n))
337 (gnus-post-method (not (eq symp 'a)) ,gnus-newsgroup-name)))
339 (while (setq article (pop articles))
340 (when (gnus-summary-select-article t nil nil article)
341 (when (gnus-eval-in-buffer-window gnus-article-buffer
343 (set-buffer gnus-original-article-buffer)
344 (message-cancel-news)))
345 (gnus-summary-mark-as-read article gnus-canceled-mark)
346 (gnus-cache-remove-article 1))
347 (gnus-article-hide-headers-if-wanted))
348 (gnus-summary-remove-process-mark article))))
350 (defun gnus-summary-supersede-article ()
351 "Compose an article that will supersede a previous article.
352 This is done simply by taking the old article and adding a Supersedes
353 header line with the old Message-ID."
355 (let ((article (gnus-summary-article-number)))
356 (gnus-setup-message 'reply-yank
357 (gnus-summary-select-article t)
358 (set-buffer gnus-original-article-buffer)
362 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
364 (set-buffer ,gnus-summary-buffer)
365 (gnus-cache-possibly-remove-article ,article nil nil nil t)
366 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
367 message-send-actions))))
371 (defun gnus-copy-article-buffer (&optional article-buffer)
372 ;; make a copy of the article buffer with all text properties removed
373 ;; this copy is in the buffer gnus-article-copy.
374 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
375 ;; this buffer should be passed to all mail/news reply/post routines.
376 (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
377 (buffer-disable-undo gnus-article-copy)
378 (let ((article-buffer (or article-buffer gnus-article-buffer))
380 (if (not (and (get-buffer article-buffer)
381 (gnus-buffer-exists-p article-buffer)))
382 (error "Can't find any article buffer")
384 (set-buffer article-buffer)
386 ;; Copy over the (displayed) article buffer, delete
387 ;; hidden text and remove text properties.
389 (copy-to-buffer gnus-article-copy (point-min) (point-max))
390 (set-buffer gnus-article-copy)
391 (gnus-article-delete-text-of-type 'annotation)
392 (gnus-remove-text-with-property 'gnus-prev)
393 (gnus-remove-text-with-property 'gnus-next)
396 (format "%s" (buffer-string))
398 ;; Find the original headers.
399 (set-buffer gnus-original-article-buffer)
400 (goto-char (point-min))
401 (while (looking-at message-unix-mail-delimiter)
404 (setq end (or (search-forward "\n\n" nil t) (point)))
405 ;; Delete the headers from the displayed articles.
406 (set-buffer gnus-article-copy)
407 (delete-region (goto-char (point-min))
408 (or (search-forward "\n\n" nil t) (point)))
409 ;; Insert the original article headers.
410 (insert-buffer-substring gnus-original-article-buffer beg end)
411 (gnus-article-decode-rfc1522)))
414 (defun gnus-post-news (post &optional group header article-buffer yank subject
417 (gnus-copy-article-buffer))
418 (let ((gnus-article-reply article-buffer)
419 (add-to-list gnus-add-to-list))
420 (gnus-setup-message (cond (yank 'reply-yank)
421 (article-buffer 'reply)
423 (let* ((group (or group gnus-newsgroup-name))
425 to-address to-group mailing-list to-list
428 (setq to-address (gnus-group-find-parameter group 'to-address)
429 to-group (gnus-group-find-parameter group 'to-group)
430 to-list (gnus-group-find-parameter group 'to-list)
431 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
432 mailing-list (when gnus-mailing-list-groups
433 (string-match gnus-mailing-list-groups group))
434 group (gnus-group-real-name group)))
435 (if (or (and to-group
436 (gnus-news-group-p to-group))
439 (and (gnus-news-group-p
440 (or pgroup gnus-newsgroup-name)
441 (if header (mail-header-number header)
442 gnus-current-article))
448 (message-news (or to-group group))
449 (set-buffer gnus-article-copy)
450 (gnus-msg-treat-broken-reply-to)
451 (message-followup (if (or newsgroup-p force-news) nil to-group)))
455 (message-mail (or to-address to-list))
456 ;; Arrange for mail groups that have no `to-address' to
457 ;; get that when the user sends off the mail.
458 (when (and (not to-list)
461 (push (list 'gnus-inews-add-to-address pgroup)
462 message-send-actions)))
463 (set-buffer gnus-article-copy)
464 (gnus-msg-treat-broken-reply-to)
465 (message-wide-reply to-address)))
467 (gnus-inews-yank-articles yank))))))
469 (defun gnus-msg-treat-broken-reply-to ()
470 "Remove the Reply-to header iff broken-reply-to."
471 (when (gnus-group-find-parameter
472 gnus-newsgroup-name 'broken-reply-to)
474 (message-narrow-to-head)
475 (message-remove-header "reply-to"))))
477 (defun gnus-post-method (arg group &optional silent)
478 "Return the posting method based on GROUP and ARG.
479 If SILENT, don't prompt the user."
480 (let ((group-method (gnus-find-method-for-group group)))
482 ;; If the group-method is nil (which shouldn't happen) we use
483 ;; the default method.
485 (or (and (null (eq gnus-post-method 'active)) gnus-post-method)
486 gnus-select-method message-post-method))
487 ;; We want the inverse of the default
488 ((and arg (not (eq arg 0)))
489 (if (eq gnus-post-method 'active)
492 ;; We query the user for a post method.
494 (and gnus-post-method
495 (not (eq gnus-post-method 'current))
496 (listp (car gnus-post-method))))
498 ;; Collect all methods we know about.
500 (when (and gnus-post-method
501 (not (eq gnus-post-method 'current)))
502 (if (listp (car gnus-post-method))
504 (list gnus-post-method)))
505 gnus-secondary-select-methods
506 (mapcar 'cdr gnus-server-alist)
507 (list gnus-select-method)
508 (list group-method)))
509 method-alist post-methods method)
510 ;; Weed out all mail methods.
512 (setq method (gnus-server-get-method "" (pop methods)))
513 (when (or (gnus-method-option-p method 'post)
514 (gnus-method-option-p method 'post-mail))
515 (push method post-methods)))
516 ;; Create a name-method alist.
520 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m))
525 (setq gnus-last-posting-server
527 gnus-last-posting-server)
528 ;; Just use the last value.
529 gnus-last-posting-server
531 "Posting method: " method-alist nil t
532 (cons (or gnus-last-posting-server "") 0))))
534 ;; Override normal method.
535 ((and (eq gnus-post-method 'current)
536 (not (eq (car group-method) 'nndraft))
539 ((and gnus-post-method
540 (not (eq gnus-post-method 'current)))
542 ;; Use the normal select method.
543 (t gnus-select-method))))
547 ;;; Gnus Mail Functions
550 ;;; Mail reply commands of Gnus summary mode
552 (defun gnus-summary-reply (&optional yank wide)
553 "Start composing a reply mail to the current message.
554 If prefix argument YANK is non-nil, the original article is yanked
557 (list (and current-prefix-arg
558 (gnus-summary-work-articles 1))))
559 ;; Stripping headers should be specified with mail-yank-ignored-headers.
561 (gnus-summary-goto-subject (car yank)))
562 (let ((gnus-article-reply t)
563 (gnus-inhibit-posting-styles t))
564 (gnus-setup-message (if yank 'reply-yank 'reply)
565 (gnus-summary-select-article)
566 (set-buffer (gnus-copy-article-buffer))
567 (gnus-msg-treat-broken-reply-to)
568 (message-reply nil wide)
570 (gnus-inews-yank-articles yank)))))
572 (defun gnus-summary-reply-with-original (n &optional wide)
573 "Start composing a reply mail to the current message.
574 The original article will be yanked."
576 (gnus-summary-reply (gnus-summary-work-articles n) wide))
578 (defun gnus-summary-wide-reply (&optional yank)
579 "Start composing a wide reply mail to the current message.
580 If prefix argument YANK is non-nil, the original article is yanked
583 (list (and current-prefix-arg
584 (gnus-summary-work-articles 1))))
585 (gnus-summary-reply yank t))
587 (defun gnus-summary-wide-reply-with-original (n)
588 "Start composing a wide reply mail to the current message.
589 The original article will be yanked."
591 (gnus-summary-reply-with-original n t))
593 (defun gnus-summary-mail-forward (&optional full-headers post)
594 "Forward the current message to another user.
595 If FULL-HEADERS (the prefix), include full headers when forwarding."
597 (gnus-setup-message 'forward
598 (gnus-summary-select-article)
599 (let ((charset default-mime-charset))
600 (set-buffer gnus-original-article-buffer)
601 (make-local-variable 'default-mime-charset)
602 (setq default-mime-charset charset)
604 (let ((message-included-forward-headers
605 (if full-headers "" message-included-forward-headers)))
606 (message-forward post))))
608 (defun gnus-summary-post-forward (&optional full-headers)
609 "Forward the current article to a newsgroup.
610 If FULL-HEADERS (the prefix), include full headers when forwarding."
612 (gnus-summary-mail-forward full-headers t))
614 ;;; XXX: generate Subject and ``Topics''?
615 (defun gnus-summary-mail-digest (&optional n post)
616 "Digests and forwards all articles in this series."
618 (let ((subject "Digested Articles")
619 (articles (gnus-summary-work-articles n))
621 (gnus-setup-message 'forward
622 (gnus-summary-select-article)
623 (if post (message-news nil subject) (message-mail nil subject))
625 (while (setq article (pop articles))
626 (save-window-excursion
627 (set-buffer gnus-summary-buffer)
628 (gnus-summary-select-article nil nil nil article)
629 (gnus-summary-remove-process-mark article))
630 (insert (mime-make-tag "message" "rfc822") "\n")
631 (insert-buffer-substring gnus-original-article-buffer))
634 (mime-edit-enclose-digest-region (point)(mark t)))))
636 (defun gnus-summary-post-digest (&optional n)
637 "Digest and forwards all articles in this series to a newsgroup."
639 (gnus-summary-mail-digest n t))
641 (defun gnus-summary-resend-message (address n)
642 "Resend the current article to ADDRESS."
643 (interactive "sResend message(s) to: \nP")
644 (let ((articles (gnus-summary-work-articles n))
646 (while (setq article (pop articles))
647 (gnus-summary-select-article nil nil nil article)
649 (set-buffer gnus-original-article-buffer)
650 (message-resend address)))))
652 (defvar gnus-nastygram-message
653 "The following article was inappropriately posted to %s.\n\n"
654 "Format string to insert in nastygrams.
655 The current group name will be inserted at \"%s\".")
657 (defun gnus-summary-mail-nastygram (n)
658 "Send a nastygram to the author of the current article."
660 (when (or gnus-expert-user
662 "Really send a nastygram to the author of the current article? "))
663 (let ((group gnus-newsgroup-name))
664 (gnus-summary-reply-with-original n)
665 (set-buffer gnus-message-buffer)
667 (insert (format gnus-nastygram-message group))
668 (message-send-and-exit))))
670 (defun gnus-summary-mail-crosspost-complaint (n)
671 "Send a complaint about crossposting to the current article(s)."
673 (let ((articles (gnus-summary-work-articles n))
675 (while (setq article (pop articles))
676 (set-buffer gnus-summary-buffer)
677 (gnus-summary-goto-subject article)
678 (let ((group (gnus-group-real-name gnus-newsgroup-name))
679 newsgroups followup-to)
680 (gnus-summary-select-article)
681 (set-buffer gnus-original-article-buffer)
682 (if (and (<= (length (message-tokenize-header
683 (setq newsgroups (mail-fetch-field "newsgroups"))
686 (or (not (setq followup-to (mail-fetch-field "followup-to")))
687 (not (member group (message-tokenize-header
688 followup-to ", ")))))
690 (gnus-message 1 "Followup-to restricted")
691 (gnus-message 1 "Not a crossposted article"))
692 (set-buffer gnus-summary-buffer)
693 (gnus-summary-reply-with-original 1)
694 (set-buffer gnus-message-buffer)
696 (insert (format gnus-crosspost-complaint newsgroups group))
697 (message-goto-subject)
698 (re-search-forward " *$")
699 (replace-match " (crosspost notification)" t t)
700 (gnus-deactivate-mark)
701 (when (gnus-y-or-n-p "Send this complaint? ")
702 (message-send-and-exit)))))))
704 (defun gnus-summary-mail-other-window ()
705 "Compose mail in other window."
707 (gnus-setup-message 'message
710 (defun gnus-mail-parse-comma-list ()
713 (skip-chars-forward " ")
716 (skip-chars-forward "^,")
721 (narrow-to-region beg (point))
724 (while (search-forward "\"" nil t)
728 (skip-chars-forward ",")
729 (skip-chars-forward "^,"))
730 (skip-chars-backward " ")
731 (push (buffer-substring beg (point))
733 (skip-chars-forward "^,")
734 (skip-chars-forward ", "))
737 (defun gnus-inews-add-to-address (group)
738 (let ((to-address (mail-fetch-field "to")))
739 (when (and to-address
741 ;; This mail group doesn't have a `to-list', so we add one
744 (format "Do you want to add this as `to-list': %s " to-address))
745 (gnus-group-add-parameter group (cons 'to-list to-address))))))
747 (defun gnus-put-message ()
748 "Put the current message in some group and return to Gnus."
750 (let ((reply gnus-article-reply)
751 (winconf gnus-prev-winconf)
752 (group gnus-newsgroup-name))
754 (or (and group (not (gnus-group-read-only-p group)))
755 (setq group (read-string "Put in group: " nil
756 (gnus-writable-groups))))
757 (when (gnus-gethash group gnus-newsrc-hashtb)
758 (error "No such group: %s" group))
763 (message-narrow-to-headers)
764 (let (gnus-deletable-headers)
766 (message-generate-headers message-required-news-headers)
767 (message-generate-headers message-required-mail-headers)))
768 (goto-char (point-max))
769 (insert "Gcc: " group "\n")
774 (when (get-buffer gnus-group-buffer)
775 (when (gnus-buffer-exists-p (car-safe reply))
776 (set-buffer (car reply))
778 (gnus-summary-mark-article-as-replied
781 (set-window-configuration winconf)))))
783 (defun gnus-article-mail (yank)
784 "Send a reply to the address near point.
785 If YANK is non-nil, include the original article."
789 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
790 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
792 (message-reply address)
794 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
796 (defvar nntp-server-type)
798 "Send a bug report to the Gnus maintainers."
800 (unless (gnus-alive-p)
801 (error "Gnus has been shut down"))
802 (gnus-setup-message 'bug
803 (delete-other-windows)
804 (when gnus-bug-create-help-buffer
805 (switch-to-buffer "*Gnus Help Bug*")
807 (insert gnus-bug-message)
808 (goto-char (point-min)))
809 (message-pop-to-buffer "*Gnus Bug*")
811 `((To . ,gnus-maintainer) (Cc . ,semi-gnus-developers) (Subject . "")))
812 (when gnus-bug-create-help-buffer
813 (push `(gnus-bug-kill-buffer) message-send-actions))
814 (goto-char (point-min))
815 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
817 (insert (gnus-version) "\n"
818 (emacs-version) "\n")
819 (when (and (boundp 'nntp-server-type)
820 (stringp nntp-server-type))
821 (insert nntp-server-type))
822 (insert "\n\n\n\n\n")
824 (goto-char (point-min))
825 (search-forward "Subject: " nil t)
828 (defun gnus-bug-kill-buffer ()
829 (when (get-buffer "*Gnus Help Bug*")
830 (kill-buffer "*Gnus Help Bug*")))
833 "Attempts to go through the Gnus source file and report what variables have been changed.
834 The source file has to be in the Emacs load path."
836 (let ((files '("gnus.el" "gnus-sum.el" "gnus-group.el"
837 "gnus-art.el" "gnus-start.el" "gnus-async.el"
838 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
839 "nnmail.el" "message.el"))
842 (gnus-message 4 "Please wait while we snoop your variables...")
844 ;; Go through all the files looking for non-default values for variables.
846 (set-buffer (gnus-get-buffer-create " *gnus bug info*"))
847 (buffer-disable-undo (current-buffer))
850 (when (and (setq file (locate-library (pop files)))
851 (file-exists-p file))
852 (insert-file-contents file)
853 (goto-char (point-min))
854 (if (not (re-search-forward "^;;* *Internal variables" nil t))
855 (gnus-message 4 "Malformed sources in file %s" file)
856 (narrow-to-region (point-min) (point))
857 (goto-char (point-min))
858 (while (setq expr (ignore-errors (read (current-buffer))))
860 (and (or (eq (car expr) 'defvar)
861 (eq (car expr) 'defcustom))
862 (stringp (nth 3 expr))
863 (or (not (boundp (nth 1 expr)))
864 (not (equal (eval (nth 2 expr))
865 (symbol-value (nth 1 expr)))))
866 (push (nth 1 expr) olist)))))))
867 (kill-buffer (current-buffer)))
868 (when (setq olist (nreverse olist))
869 (insert "------------------ Environment follows ------------------\n\n"))
871 (if (boundp (car olist))
873 (pp `(setq ,(car olist)
874 ,(if (or (consp (setq sym (symbol-value (car olist))))
876 (not (or (eq sym nil)
878 (list 'quote (symbol-value (car olist)))
879 (symbol-value (car olist))))
882 (format "(setq %s 'whatever)\n" (car olist))))
883 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
884 (setq olist (cdr olist)))
886 ;; Remove any control chars - they seem to cause trouble for some
887 ;; mailers. (Byte-compiled output from the stuff above.)
889 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
890 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
893 ;;; Treatment of rejected articles.
896 (defun gnus-summary-resend-bounced-mail (&optional fetch)
897 "Re-mail the current message.
898 This only makes sense if the current message is a bounce message than
899 contains some mail you have written which has been bounced back to
901 If FETCH, try to fetch the article that this is a reply to, if indeed
904 (gnus-summary-select-article t)
905 (set-buffer gnus-original-article-buffer)
906 (gnus-setup-message 'compose-bounce
907 (let* ((references (mail-fetch-field "references"))
908 (parent (and references (gnus-parent-id references))))
910 ;; If there are references, we fetch the article we answered to.
912 (gnus-summary-refer-article parent)
913 (gnus-summary-show-all-headers)))))
917 ;; Do Gcc handling, which copied the message over to some group.
918 (defun gnus-inews-do-gcc (&optional gcc)
923 (message-narrow-to-headers)
924 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
925 (coding-system-for-write 'raw-text)
928 (message-remove-header "gcc")
930 (setq groups (message-tokenize-header gcc " ,"))
931 ;; Copy the article over to some group(s).
932 (while (setq group (pop groups))
935 (cond ((and (null (gnus-get-info group))
936 (eq (car gnus-message-archive-method)
938 (gnus-server-to-method
939 (gnus-group-method group)))))
940 ;; If the group doesn't exist, we assume
941 ;; it's an archive group...
942 gnus-message-archive-method)
944 ((gnus-info-method (gnus-get-info group))
945 (gnus-info-method (gnus-get-info group)))
947 (t (gnus-group-method group)))))
948 (gnus-check-server method)
949 (unless (gnus-request-group group t method)
950 (gnus-request-create-group group method))
952 (nnheader-set-temp-buffer " *acc*")
953 (insert-buffer-substring message-encoding-buffer)
954 (gnus-run-hooks 'gnus-before-do-gcc-hook)
955 (goto-char (point-min))
956 (when (re-search-forward
957 (concat "^" (regexp-quote mail-header-separator) "$")
959 (replace-match "" t t ))
960 (unless (gnus-request-accept-article group method t)
961 (gnus-message 1 "Couldn't store article in group %s: %s"
962 group (gnus-status-message method))
964 (kill-buffer (current-buffer))))))))))
966 (defun gnus-inews-insert-gcc ()
967 "Insert Gcc headers based on `gnus-outgoing-message-group'."
970 (message-narrow-to-headers)
971 (let* ((group gnus-outgoing-message-group)
973 ((gnus-functionp group)
975 ((or (stringp group) (list group))
979 (if (stringp gcc) gcc
980 (mapconcat 'identity gcc " "))
983 (defun gnus-inews-insert-archive-gcc (&optional group)
984 "Insert the Gcc to say where the article is to be archived."
985 (let* ((var gnus-message-archive-group)
986 (group (or group gnus-newsgroup-name ""))
988 (and gnus-newsgroup-name
989 (gnus-group-find-parameter
990 gnus-newsgroup-name 'gcc-self)))
994 ((null gnus-message-archive-method)
998 ;; Just a single group.
1001 ;; We don't want this.
1003 ((and (listp var) (stringp (car var)))
1004 ;; A list of groups.
1006 ((gnus-functionp var)
1008 (funcall var group))
1010 ;; An alist of regexps/functions/forms.
1015 ((stringp (caar var))
1017 (when (string-match (caar var) group)
1019 ((gnus-functionp (car var))
1021 (funcall (car var) group))
1023 (eval (car var)))))))
1024 (setq var (cdr var)))
1027 (when (or groups gcc-self-val)
1028 (when (stringp groups)
1029 (setq groups (list groups)))
1032 (message-narrow-to-headers)
1033 (goto-char (point-max))
1036 ;; Use the `gcc-self' param value instead.
1039 (if (stringp gcc-self-val)
1042 (if (not (eq gcc-self-val 'none))
1047 ;; Use the list of groups.
1048 (while (setq name (pop groups))
1049 (insert (if (string-match ":" name)
1051 (gnus-group-prefixed-name
1052 name gnus-message-archive-method)))
1059 (defvar gnus-message-style-insertions nil)
1061 (defun gnus-configure-posting-styles ()
1062 "Configure posting styles according to `gnus-posting-styles'."
1063 (unless gnus-inhibit-posting-styles
1064 (let ((styles gnus-posting-styles)
1065 (gnus-newsgroup-name (or gnus-newsgroup-name ""))
1066 style match variable attribute value value-value)
1067 (make-local-variable 'gnus-message-style-insertions)
1068 ;; Go through all styles and look for matches.
1070 (setq style (pop styles)
1072 (when (cond ((stringp match)
1073 ;; Regexp string match on the group name.
1074 (string-match match gnus-newsgroup-name))
1075 ((or (symbolp match)
1076 (gnus-functionp match))
1077 (cond ((gnus-functionp match)
1078 ;; Function to be called.
1081 ;; Variable to be checked.
1082 (symbol-value match))))
1084 ;; This is a form to be evaled.
1086 ;; We have a match, so we set the variables.
1088 (setq attribute (pop style)
1089 value (cadr attribute)
1091 ;; We find the variable that is to be modified.
1092 (if (and (not (stringp (car attribute)))
1093 (not (eq 'body (car attribute)))
1095 (cdr (assq (car attribute)
1096 gnus-posting-style-alist)))))
1097 (message "Couldn't find attribute %s" (car attribute))
1098 ;; We get the value.
1100 (cond ((stringp value)
1102 ((or (symbolp value)
1103 (gnus-functionp value))
1104 (cond ((gnus-functionp value)
1107 (symbol-value value))))
1111 ;; This is an ordinary variable.
1112 (set (make-local-variable variable) value-value)
1113 ;; This is either a body or a header to be inserted in the
1116 (let ((attr (car attribute)))
1117 (make-local-variable 'message-setup-hook)
1119 (add-hook 'message-setup-hook
1123 (insert ,value-value))))
1124 (add-hook 'message-setup-hook
1125 'gnus-message-insert-stylings)
1126 (push (cons (if (stringp attr) attr
1129 gnus-message-style-insertions))))))))))))
1131 (defun gnus-message-insert-stylings ()
1135 (while (setq val (pop gnus-message-style-insertions))
1137 (insert (car val) ": " (cdr val) "\n"))
1138 (gnus-pull (car val) gnus-message-style-insertions)))))
1140 ;;; Allow redefinition of functions.
1146 ;;; gnus-msg.el ends here