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 "Sending a bug report to the Gnus Towers.
125 ========================================
127 The buffer below is a mail buffer. When you press `C-c C-c', it will
128 be sent to the Gnus Bug Exterminators.
130 At the bottom of the buffer you'll see lots of variable settings.
131 Please do not delete those. They will tell the Bug People what your
132 environment is, so that it will be easier to locate the bugs.
134 If you have found a bug that makes Emacs go \"beep\", set
135 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
136 and include the backtrace in your bug report.
138 Please describe the bug in annoying, painstaking detail.
140 Thank you for your help in stamping out bugs.
144 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
145 (autoload 'news-setup "rnewspost")
146 (autoload 'news-reply-mode "rnewspost")
147 (autoload 'rmail-dont-reply-to "mail-utils")
148 (autoload 'rmail-output "rmailout"))
152 ;;; Gnus Posting Functions
155 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
156 "p" gnus-summary-post-news
157 "f" gnus-summary-followup
158 "F" gnus-summary-followup-with-original
159 "c" gnus-summary-cancel-article
160 "s" gnus-summary-supersede-article
161 "r" gnus-summary-reply
162 "R" gnus-summary-reply-with-original
163 "w" gnus-summary-wide-reply
164 "W" gnus-summary-wide-reply-with-original
165 "n" gnus-summary-followup-to-mail
166 "N" gnus-summary-followup-to-mail-with-original
167 "m" gnus-summary-mail-other-window
168 "u" gnus-uu-post-news
169 "\M-c" gnus-summary-mail-crosspost-complaint
170 "om" gnus-summary-mail-forward
171 "op" gnus-summary-post-forward
172 "Om" gnus-summary-mail-digest
173 "Op" gnus-summary-post-digest)
175 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
176 "b" gnus-summary-resend-bounced-mail
177 ;; "c" gnus-summary-send-draft
178 "r" gnus-summary-resend-message)
180 ;;; Internal functions.
182 (defvar gnus-article-reply nil)
183 (defmacro gnus-setup-message (config &rest forms)
184 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
185 (buffer (make-symbol "gnus-setup-message-buffer"))
186 (article (make-symbol "gnus-setup-message-article"))
187 (group (make-symbol "gnus-setup-message-group")))
188 `(let ((,winconf (current-window-configuration))
189 (,buffer (buffer-name (current-buffer)))
190 (,article (and gnus-article-reply (gnus-summary-article-number)))
191 (,group gnus-newsgroup-name)
192 (message-header-setup-hook
193 (copy-sequence message-header-setup-hook))
194 (message-mode-hook (copy-sequence message-mode-hook)))
195 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
196 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
197 (add-hook 'message-mode-hook 'gnus-configure-posting-styles)
201 (gnus-inews-add-send-actions ,winconf ,buffer ,article)
202 (setq gnus-message-buffer (current-buffer))
203 (set (make-local-variable 'gnus-message-group-art)
204 (cons ,group ,article))
205 (make-local-variable 'gnus-newsgroup-name)
206 (gnus-run-hooks 'gnus-message-setup-hook))
208 (gnus-configure-windows ,config t)
209 (set-buffer-modified-p nil))))
211 (defun gnus-inews-add-send-actions (winconf buffer article)
212 (make-local-hook 'message-sent-hook)
213 (add-hook 'message-sent-hook 'gnus-inews-do-gcc nil t)
214 (setq message-post-method
216 (gnus-post-method arg ,gnus-newsgroup-name)))
217 (setq message-newsreader (setq message-mailer (gnus-extended-version)))
219 `(set-window-configuration ,winconf) 'exit 'postpone 'kill)
221 `(when (gnus-buffer-exists-p ,buffer)
225 `(gnus-summary-mark-article-as-replied ,article))))
228 (put 'gnus-setup-message 'lisp-indent-function 1)
229 (put 'gnus-setup-message 'edebug-form-spec '(form body))
231 ;;; Post news commands of Gnus group mode and summary mode
233 (defun gnus-group-mail ()
234 "Start composing a mail."
236 (gnus-setup-message 'message
239 (defun gnus-group-post-news (&optional arg)
240 "Start composing a news message.
241 If ARG, post to the group under point.
242 If ARG is 1, prompt for a group name."
244 ;; Bind this variable here to make message mode hooks work ok.
245 (let ((gnus-newsgroup-name
247 (if (= 1 (prefix-numeric-value arg))
248 (completing-read "Newsgroup: " gnus-active-hashtb nil
249 (gnus-read-active-file-p))
250 (gnus-group-group-name))
252 (gnus-post-news 'post gnus-newsgroup-name)))
254 (defun gnus-summary-post-news ()
255 "Start composing a news message."
257 (gnus-post-news 'post gnus-newsgroup-name))
259 (defun gnus-summary-followup (yank &optional force-news)
260 "Compose a followup to an article.
261 If prefix argument YANK is non-nil, original article is yanked automatically."
263 (list (and current-prefix-arg
264 (gnus-summary-work-articles 1))))
266 (gnus-summary-goto-subject (car yank)))
267 (save-window-excursion
268 (gnus-summary-select-article))
269 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
270 (gnus-newsgroup-name gnus-newsgroup-name))
272 (gnus-post-news nil gnus-newsgroup-name
273 headers gnus-article-buffer
274 yank nil force-news)))
276 (defun gnus-summary-followup-with-original (n &optional force-news)
277 "Compose a followup to an article and include the original article."
279 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
281 (defun gnus-summary-followup-to-mail (&optional arg)
282 "Followup to the current mail message via news."
284 (list (and current-prefix-arg
285 (gnus-summary-work-articles 1))))
286 (gnus-summary-followup arg t))
288 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
289 "Followup to the current mail message via news."
291 (gnus-summary-followup (gnus-summary-work-articles arg) t))
293 (defun gnus-inews-yank-articles (articles)
296 (while (setq article (pop articles))
297 (save-window-excursion
298 (set-buffer gnus-summary-buffer)
299 (gnus-summary-select-article nil nil nil article)
300 (gnus-summary-remove-process-mark article))
301 (gnus-copy-article-buffer)
302 (let ((message-reply-buffer gnus-article-copy)
303 (message-reply-headers gnus-current-headers))
304 (message-yank-original)
305 (setq beg (or beg (mark t))))
311 (defun gnus-summary-cancel-article (&optional n symp)
312 "Cancel an article you posted.
313 Uses the process-prefix convention. If given the symbolic
314 prefix `a', cancel using the standard posting method; if not
315 post using the current select method."
316 (interactive (gnus-interactive "P\ny"))
317 (let ((articles (gnus-summary-work-articles n))
320 (gnus-post-method (not (eq symp 'a)) ,gnus-newsgroup-name)))
322 (while (setq article (pop articles))
323 (when (gnus-summary-select-article t nil nil article)
324 (when (gnus-eval-in-buffer-window gnus-article-buffer
326 (set-buffer gnus-original-article-buffer)
327 (message-cancel-news)))
328 (gnus-summary-mark-as-read article gnus-canceled-mark)
329 (gnus-cache-remove-article 1))
330 (gnus-article-hide-headers-if-wanted))
331 (gnus-summary-remove-process-mark article))))
333 (defun gnus-summary-supersede-article ()
334 "Compose an article that will supersede a previous article.
335 This is done simply by taking the old article and adding a Supersedes
336 header line with the old Message-ID."
338 (let ((article (gnus-summary-article-number)))
339 (gnus-setup-message 'reply-yank
340 (gnus-summary-select-article t)
341 (set-buffer gnus-original-article-buffer)
345 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
347 (set-buffer ,gnus-summary-buffer)
348 (gnus-cache-possibly-remove-article ,article nil nil nil t)
349 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
350 message-send-actions))))
354 (defun gnus-copy-article-buffer (&optional article-buffer)
355 ;; make a copy of the article buffer with all text properties removed
356 ;; this copy is in the buffer gnus-article-copy.
357 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
358 ;; this buffer should be passed to all mail/news reply/post routines.
359 (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
360 (buffer-disable-undo gnus-article-copy)
361 (let ((article-buffer (or article-buffer gnus-article-buffer))
363 (if (not (and (get-buffer article-buffer)
364 (gnus-buffer-exists-p article-buffer)))
365 (error "Can't find any article buffer")
367 (set-buffer article-buffer)
369 ;; Copy over the (displayed) article buffer, delete
370 ;; hidden text and remove text properties.
372 (copy-to-buffer gnus-article-copy (point-min) (point-max))
373 (set-buffer gnus-article-copy)
374 (gnus-article-delete-text-of-type 'annotation)
375 (gnus-remove-text-with-property 'gnus-prev)
376 (gnus-remove-text-with-property 'gnus-next)
379 (format "%s" (buffer-string))
381 ;; Find the original headers.
382 (set-buffer gnus-original-article-buffer)
383 (goto-char (point-min))
384 (while (looking-at message-unix-mail-delimiter)
387 (setq end (or (search-forward "\n\n" nil t) (point)))
388 ;; Delete the headers from the displayed articles.
389 (set-buffer gnus-article-copy)
390 (delete-region (goto-char (point-min))
391 (or (search-forward "\n\n" nil t) (point)))
392 ;; Insert the original article headers.
393 (insert-buffer-substring gnus-original-article-buffer beg end)
394 (gnus-article-decode-rfc1522)))
397 (defun gnus-post-news (post &optional group header article-buffer yank subject
400 (gnus-copy-article-buffer))
401 (let ((gnus-article-reply article-buffer)
402 (add-to-list gnus-add-to-list))
403 (gnus-setup-message (cond (yank 'reply-yank)
404 (article-buffer 'reply)
406 (let* ((group (or group gnus-newsgroup-name))
408 to-address to-group mailing-list to-list
411 (setq to-address (gnus-group-find-parameter group 'to-address)
412 to-group (gnus-group-find-parameter group 'to-group)
413 to-list (gnus-group-find-parameter group 'to-list)
414 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
415 mailing-list (when gnus-mailing-list-groups
416 (string-match gnus-mailing-list-groups group))
417 group (gnus-group-real-name group)))
418 (if (or (and to-group
419 (gnus-news-group-p to-group))
422 (and (gnus-news-group-p
423 (or pgroup gnus-newsgroup-name)
424 (if header (mail-header-number header)
425 gnus-current-article))
431 (message-news (or to-group group))
432 (set-buffer gnus-article-copy)
433 (gnus-msg-treat-broken-reply-to)
434 (message-followup (if (or newsgroup-p force-news) nil to-group)))
438 (message-mail (or to-address to-list))
439 ;; Arrange for mail groups that have no `to-address' to
440 ;; get that when the user sends off the mail.
441 (when (and (not to-list)
444 (push (list 'gnus-inews-add-to-address pgroup)
445 message-send-actions)))
446 (set-buffer gnus-article-copy)
447 (gnus-msg-treat-broken-reply-to)
448 (message-wide-reply to-address)))
450 (gnus-inews-yank-articles yank))))))
452 (defun gnus-msg-treat-broken-reply-to ()
453 "Remove the Reply-to header iff broken-reply-to."
454 (when (gnus-group-find-parameter
455 gnus-newsgroup-name 'broken-reply-to)
457 (message-narrow-to-head)
458 (message-remove-header "reply-to"))))
460 (defun gnus-post-method (arg group &optional silent)
461 "Return the posting method based on GROUP and ARG.
462 If SILENT, don't prompt the user."
463 (let ((group-method (gnus-find-method-for-group group)))
465 ;; If the group-method is nil (which shouldn't happen) we use
466 ;; the default method.
468 (or (and (null (eq gnus-post-method 'active)) gnus-post-method)
469 gnus-select-method message-post-method))
470 ;; We want the inverse of the default
471 ((and arg (not (eq arg 0)))
472 (if (eq gnus-post-method 'active)
475 ;; We query the user for a post method.
477 (and gnus-post-method
478 (not (eq gnus-post-method 'current))
479 (listp (car gnus-post-method))))
481 ;; Collect all methods we know about.
483 (when (and gnus-post-method
484 (not (eq gnus-post-method 'current)))
485 (if (listp (car gnus-post-method))
487 (list gnus-post-method)))
488 gnus-secondary-select-methods
489 (mapcar 'cdr gnus-server-alist)
490 (list gnus-select-method)
491 (list group-method)))
492 method-alist post-methods method)
493 ;; Weed out all mail methods.
495 (setq method (gnus-server-get-method "" (pop methods)))
496 (when (or (gnus-method-option-p method 'post)
497 (gnus-method-option-p method 'post-mail))
498 (push method post-methods)))
499 ;; Create a name-method alist.
503 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m))
508 (setq gnus-last-posting-server
510 gnus-last-posting-server)
511 ;; Just use the last value.
512 gnus-last-posting-server
514 "Posting method: " method-alist nil t
515 (cons (or gnus-last-posting-server "") 0))))
517 ;; Override normal method.
518 ((and (eq gnus-post-method 'current)
519 (not (eq (car group-method) 'nndraft))
522 ((and gnus-post-method
523 (not (eq gnus-post-method 'current)))
525 ;; Use the normal select method.
526 (t gnus-select-method))))
530 ;; Dummy to avoid byte-compile warning.
531 (defvar nnspool-rejected-article-hook)
532 (defvar xemacs-codename)
534 ;;; Since the X-Newsreader/X-Mailer are ``vanity'' headers, they might
535 ;;; as well include the Emacs version as well.
536 ;;; The following function works with later GNU Emacs, and XEmacs.
537 (defun gnus-extended-version ()
538 "Stringified gnus version."
544 ;;; Gnus Mail Functions
547 ;;; Mail reply commands of Gnus summary mode
549 (defun gnus-summary-reply (&optional yank wide)
550 "Start composing a reply mail to the current message.
551 If prefix argument YANK is non-nil, the original article is yanked
554 (list (and current-prefix-arg
555 (gnus-summary-work-articles 1))))
556 ;; Stripping headers should be specified with mail-yank-ignored-headers.
558 (gnus-summary-goto-subject (car yank)))
559 (let ((gnus-article-reply t))
560 (gnus-setup-message (if yank 'reply-yank 'reply)
561 (gnus-summary-select-article)
562 (set-buffer (gnus-copy-article-buffer))
563 (gnus-msg-treat-broken-reply-to)
564 (message-reply nil wide)
566 (gnus-inews-yank-articles yank)))))
568 (defun gnus-summary-reply-with-original (n &optional wide)
569 "Start composing a reply mail to the current message.
570 The original article will be yanked."
572 (gnus-summary-reply (gnus-summary-work-articles n) wide))
574 (defun gnus-summary-wide-reply (&optional yank)
575 "Start composing a wide reply mail to the current message.
576 If prefix argument YANK is non-nil, the original article is yanked
579 (list (and current-prefix-arg
580 (gnus-summary-work-articles 1))))
581 (gnus-summary-reply yank t))
583 (defun gnus-summary-wide-reply-with-original (n)
584 "Start composing a wide reply mail to the current message.
585 The original article will be yanked."
587 (gnus-summary-reply-with-original n t))
589 (defun gnus-summary-mail-forward (&optional full-headers post)
590 "Forward the current message to another user.
591 If FULL-HEADERS (the prefix), include full headers when forwarding."
593 (gnus-setup-message 'forward
594 (gnus-summary-select-article)
595 (let ((charset default-mime-charset))
596 (set-buffer gnus-original-article-buffer)
597 (make-local-variable 'default-mime-charset)
598 (setq default-mime-charset charset)
600 (let ((message-included-forward-headers
601 (if full-headers "" message-included-forward-headers)))
602 (message-forward post))))
604 (defun gnus-summary-post-forward (&optional full-headers)
605 "Forward the current article to a newsgroup.
606 If FULL-HEADERS (the prefix), include full headers when forwarding."
608 (gnus-summary-mail-forward full-headers t))
610 ;;; XXX: generate Subject and ``Topics''?
611 (defun gnus-summary-mail-digest (&optional n post)
612 "Digests and forwards all articles in this series."
614 (let ((subject "Digested Articles")
615 (articles (gnus-summary-work-articles n))
617 (gnus-setup-message 'forward
618 (gnus-summary-select-article)
619 (if post (message-news nil subject) (message-mail nil subject))
621 (while (setq article (pop articles))
622 (save-window-excursion
623 (set-buffer gnus-summary-buffer)
624 (gnus-summary-select-article nil nil nil article)
625 (gnus-summary-remove-process-mark article))
626 (insert (mime-make-tag "message" "rfc822") "\n")
627 (insert-buffer-substring gnus-original-article-buffer))
630 (mime-edit-enclose-digest-region (point)(mark t)))))
632 (defun gnus-summary-post-digest (&optional n)
633 "Digest and forwards all articles in this series to a newsgroup."
635 (gnus-summary-mail-digest n t))
637 (defun gnus-summary-resend-message (address n)
638 "Resend the current article to ADDRESS."
639 (interactive "sResend message(s) to: \nP")
640 (let ((articles (gnus-summary-work-articles n))
642 (while (setq article (pop articles))
643 (gnus-summary-select-article nil nil nil article)
645 (set-buffer gnus-original-article-buffer)
646 (message-resend address)))))
648 (defvar gnus-nastygram-message
649 "The following article was inappropriately posted to %s.\n\n"
650 "Format string to insert in nastygrams.
651 The current group name will be inserted at \"%s\".")
653 (defun gnus-summary-mail-nastygram (n)
654 "Send a nastygram to the author of the current article."
656 (when (or gnus-expert-user
658 "Really send a nastygram to the author of the current article? "))
659 (let ((group gnus-newsgroup-name))
660 (gnus-summary-reply-with-original n)
661 (set-buffer gnus-message-buffer)
663 (insert (format gnus-nastygram-message group))
664 (message-send-and-exit))))
666 (defun gnus-summary-mail-crosspost-complaint (n)
667 "Send a complaint about crossposting to the current article(s)."
669 (let ((articles (gnus-summary-work-articles n))
671 (while (setq article (pop articles))
672 (set-buffer gnus-summary-buffer)
673 (gnus-summary-goto-subject article)
674 (let ((group (gnus-group-real-name gnus-newsgroup-name))
675 newsgroups followup-to)
676 (gnus-summary-select-article)
677 (set-buffer gnus-original-article-buffer)
678 (if (and (<= (length (message-tokenize-header
679 (setq newsgroups (mail-fetch-field "newsgroups"))
682 (or (not (setq followup-to (mail-fetch-field "followup-to")))
683 (not (member group (message-tokenize-header
684 followup-to ", ")))))
686 (gnus-message 1 "Followup-to restricted")
687 (gnus-message 1 "Not a crossposted article"))
688 (set-buffer gnus-summary-buffer)
689 (gnus-summary-reply-with-original 1)
690 (set-buffer gnus-message-buffer)
692 (insert (format gnus-crosspost-complaint newsgroups group))
693 (message-goto-subject)
694 (re-search-forward " *$")
695 (replace-match " (crosspost notification)" t t)
696 (gnus-deactivate-mark)
697 (when (gnus-y-or-n-p "Send this complaint? ")
698 (message-send-and-exit)))))))
700 (defun gnus-summary-mail-other-window ()
701 "Compose mail in other window."
703 (gnus-setup-message 'message
706 (defun gnus-mail-parse-comma-list ()
709 (skip-chars-forward " ")
712 (skip-chars-forward "^,")
717 (narrow-to-region beg (point))
720 (while (search-forward "\"" nil t)
724 (skip-chars-forward ",")
725 (skip-chars-forward "^,"))
726 (skip-chars-backward " ")
727 (push (buffer-substring beg (point))
729 (skip-chars-forward "^,")
730 (skip-chars-forward ", "))
733 (defun gnus-inews-add-to-address (group)
734 (let ((to-address (mail-fetch-field "to")))
735 (when (and to-address
737 ;; This mail group doesn't have a `to-list', so we add one
740 (format "Do you want to add this as `to-list': %s " to-address))
741 (gnus-group-add-parameter group (cons 'to-list to-address))))))
743 (defun gnus-put-message ()
744 "Put the current message in some group and return to Gnus."
746 (let ((reply gnus-article-reply)
747 (winconf gnus-prev-winconf)
748 (group gnus-newsgroup-name))
750 (or (and group (not (gnus-group-read-only-p group)))
751 (setq group (read-string "Put in group: " nil
752 (gnus-writable-groups))))
753 (when (gnus-gethash group gnus-newsrc-hashtb)
754 (error "No such group: %s" group))
759 (message-narrow-to-headers)
760 (let (gnus-deletable-headers)
762 (message-generate-headers message-required-news-headers)
763 (message-generate-headers message-required-mail-headers)))
764 (goto-char (point-max))
765 (insert "Gcc: " group "\n")
770 (when (get-buffer gnus-group-buffer)
771 (when (gnus-buffer-exists-p (car-safe reply))
772 (set-buffer (car reply))
774 (gnus-summary-mark-article-as-replied
777 (set-window-configuration winconf)))))
779 (defun gnus-article-mail (yank)
780 "Send a reply to the address near point.
781 If YANK is non-nil, include the original article."
785 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
786 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
788 (message-reply address)
790 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
792 (defvar nntp-server-type)
794 "Send a bug report to the Gnus maintainers."
796 (unless (gnus-alive-p)
797 (error "Gnus has been shut down"))
798 (gnus-setup-message 'bug
799 (delete-other-windows)
800 (when gnus-bug-create-help-buffer
801 (switch-to-buffer "*Gnus Help Bug*")
803 (insert gnus-bug-message)
804 (goto-char (point-min)))
805 (message-pop-to-buffer "*Gnus Bug*")
806 (message-setup `((To . ,gnus-maintainer) (Subject . "")))
807 (when gnus-bug-create-help-buffer
808 (push `(gnus-bug-kill-buffer) message-send-actions))
809 (goto-char (point-min))
810 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
812 (insert (gnus-version) "\n"
813 (emacs-version) "\n")
814 (when (and (boundp 'nntp-server-type)
815 (stringp nntp-server-type))
816 (insert nntp-server-type))
817 (insert "\n\n\n\n\n")
819 (goto-char (point-min))
820 (search-forward "Subject: " nil t)
823 (defun gnus-bug-kill-buffer ()
824 (when (get-buffer "*Gnus Help Bug*")
825 (kill-buffer "*Gnus Help Bug*")))
828 "Attempts to go through the Gnus source file and report what variables have been changed.
829 The source file has to be in the Emacs load path."
831 (let ((files '("gnus.el" "gnus-sum.el" "gnus-group.el"
832 "gnus-art.el" "gnus-start.el" "gnus-async.el"
833 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
834 "nnmail.el" "message.el"))
837 (gnus-message 4 "Please wait while we snoop your variables...")
839 ;; Go through all the files looking for non-default values for variables.
841 (set-buffer (gnus-get-buffer-create " *gnus bug info*"))
842 (buffer-disable-undo (current-buffer))
845 (when (and (setq file (locate-library (pop files)))
846 (file-exists-p file))
847 (insert-file-contents file)
848 (goto-char (point-min))
849 (if (not (re-search-forward "^;;* *Internal variables" nil t))
850 (gnus-message 4 "Malformed sources in file %s" file)
851 (narrow-to-region (point-min) (point))
852 (goto-char (point-min))
853 (while (setq expr (ignore-errors (read (current-buffer))))
855 (and (or (eq (car expr) 'defvar)
856 (eq (car expr) 'defcustom))
857 (stringp (nth 3 expr))
858 (or (not (boundp (nth 1 expr)))
859 (not (equal (eval (nth 2 expr))
860 (symbol-value (nth 1 expr)))))
861 (push (nth 1 expr) olist)))))))
862 (kill-buffer (current-buffer)))
863 (when (setq olist (nreverse olist))
864 (insert "------------------ Environment follows ------------------\n\n"))
866 (if (boundp (car olist))
868 (pp `(setq ,(car olist)
869 ,(if (or (consp (setq sym (symbol-value (car olist))))
871 (not (or (eq sym nil)
873 (list 'quote (symbol-value (car olist)))
874 (symbol-value (car olist))))
877 (format "(setq %s 'whatever)\n" (car olist))))
878 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
879 (setq olist (cdr olist)))
881 ;; Remove any control chars - they seem to cause trouble for some
882 ;; mailers. (Byte-compiled output from the stuff above.)
884 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
885 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
888 ;;; Treatment of rejected articles.
891 (defun gnus-summary-resend-bounced-mail (&optional fetch)
892 "Re-mail the current message.
893 This only makes sense if the current message is a bounce message than
894 contains some mail you have written which has been bounced back to
896 If FETCH, try to fetch the article that this is a reply to, if indeed
899 (gnus-summary-select-article t)
900 (set-buffer gnus-original-article-buffer)
901 (gnus-setup-message 'compose-bounce
902 (let* ((references (mail-fetch-field "references"))
903 (parent (and references (gnus-parent-id references))))
905 ;; If there are references, we fetch the article we answered to.
907 (gnus-summary-refer-article parent)
908 (gnus-summary-show-all-headers)))))
912 ;; Do Gcc handling, which copied the message over to some group.
913 (defun gnus-inews-do-gcc (&optional gcc)
918 (message-narrow-to-headers)
919 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
920 (coding-system-for-write 'raw-text)
923 (message-remove-header "gcc")
925 (setq groups (message-tokenize-header gcc " ,"))
926 ;; Copy the article over to some group(s).
927 (while (setq group (pop groups))
930 (cond ((and (null (gnus-get-info group))
931 (eq (car gnus-message-archive-method)
933 (gnus-server-to-method
934 (gnus-group-method group)))))
935 ;; If the group doesn't exist, we assume
936 ;; it's an archive group...
937 gnus-message-archive-method)
939 ((gnus-info-method (gnus-get-info group))
940 (gnus-info-method (gnus-get-info group)))
942 (t (gnus-group-method group)))))
943 (gnus-check-server method)
944 (unless (gnus-request-group group t method)
945 (gnus-request-create-group group method))
947 (nnheader-set-temp-buffer " *acc*")
948 (insert-buffer-substring message-encoding-buffer)
949 (gnus-run-hooks 'gnus-before-do-gcc-hook)
950 (goto-char (point-min))
951 (when (re-search-forward
952 (concat "^" (regexp-quote mail-header-separator) "$")
954 (replace-match "" t t ))
955 (unless (gnus-request-accept-article group method t)
956 (gnus-message 1 "Couldn't store article in group %s: %s"
957 group (gnus-status-message method))
959 (kill-buffer (current-buffer))))))))))
961 (defun gnus-inews-insert-gcc ()
962 "Insert Gcc headers based on `gnus-outgoing-message-group'."
965 (message-narrow-to-headers)
966 (let* ((group gnus-outgoing-message-group)
968 ((gnus-functionp group)
970 ((or (stringp group) (list group))
974 (if (stringp gcc) gcc
975 (mapconcat 'identity gcc " "))
978 (defun gnus-inews-insert-archive-gcc (&optional group)
979 "Insert the Gcc to say where the article is to be archived."
980 (let* ((var gnus-message-archive-group)
981 (group (or group gnus-newsgroup-name ""))
983 (and gnus-newsgroup-name
984 (gnus-group-find-parameter
985 gnus-newsgroup-name 'gcc-self)))
989 ((null gnus-message-archive-method)
993 ;; Just a single group.
996 ;; We don't want this.
998 ((and (listp var) (stringp (car var)))
1001 ((gnus-functionp var)
1003 (funcall var group))
1005 ;; An alist of regexps/functions/forms.
1010 ((stringp (caar var))
1012 (when (string-match (caar var) group)
1014 ((gnus-functionp (car var))
1016 (funcall (car var) group))
1018 (eval (car var)))))))
1019 (setq var (cdr var)))
1022 (when (or groups gcc-self-val)
1023 (when (stringp groups)
1024 (setq groups (list groups)))
1027 (message-narrow-to-headers)
1028 (goto-char (point-max))
1031 ;; Use the `gcc-self' param value instead.
1034 (if (stringp gcc-self-val)
1037 (if (not (eq gcc-self-val 'none))
1042 ;; Use the list of groups.
1043 (while (setq name (pop groups))
1044 (insert (if (string-match ":" name)
1046 (gnus-group-prefixed-name
1047 name gnus-message-archive-method)))
1054 (defvar gnus-message-style-insertions nil)
1056 (defun gnus-configure-posting-styles ()
1057 "Configure posting styles according to `gnus-posting-styles'."
1058 (unless gnus-inhibit-posting-styles
1059 (let ((styles gnus-posting-styles)
1060 (gnus-newsgroup-name (or gnus-newsgroup-name ""))
1061 style match variable attribute value value-value)
1062 (make-local-variable 'gnus-message-style-insertions)
1063 ;; Go through all styles and look for matches.
1065 (setq style (pop styles)
1067 (when (cond ((stringp match)
1068 ;; Regexp string match on the group name.
1069 (string-match match gnus-newsgroup-name))
1070 ((or (symbolp match)
1071 (gnus-functionp match))
1072 (cond ((gnus-functionp match)
1073 ;; Function to be called.
1076 ;; Variable to be checked.
1077 (symbol-value match))))
1079 ;; This is a form to be evaled.
1081 ;; We have a match, so we set the variables.
1083 (setq attribute (pop style)
1084 value (cadr attribute)
1086 ;; We find the variable that is to be modified.
1087 (if (and (not (stringp (car attribute)))
1088 (not (eq 'body (car attribute)))
1090 (cdr (assq (car attribute)
1091 gnus-posting-style-alist)))))
1092 (message "Couldn't find attribute %s" (car attribute))
1093 ;; We get the value.
1095 (cond ((stringp value)
1097 ((or (symbolp value)
1098 (gnus-functionp value))
1099 (cond ((gnus-functionp value)
1102 (symbol-value value))))
1106 ;; This is an ordinary variable.
1107 (set (make-local-variable variable) value-value)
1108 ;; This is either a body or a header to be inserted in the
1111 (let ((attr (car attribute)))
1112 (make-local-variable 'message-setup-hook)
1114 (add-hook 'message-setup-hook
1118 (insert ,value-value))))
1119 (add-hook 'message-setup-hook
1120 'gnus-message-insert-stylings)
1121 (push (cons (if (stringp attr) attr
1124 gnus-message-style-insertions))))))))))))
1126 (defun gnus-message-insert-stylings ()
1130 (while (setq val (pop gnus-message-style-insertions))
1132 (insert (car val) ": " (cdr val) "\n"))
1133 (gnus-pull (car val) gnus-message-style-insertions)))))
1135 ;;; Allow redefinition of functions.
1141 ;;; gnus-msg.el ends here