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 " (based on "
196 gnus-original-product-name " " gnus-original-version-number ") "))
198 (defvar gnus-article-reply nil)
199 (defmacro gnus-setup-message (config &rest forms)
200 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
201 (buffer (make-symbol "gnus-setup-message-buffer"))
202 (article (make-symbol "gnus-setup-message-article"))
203 (group (make-symbol "gnus-setup-message-group")))
204 `(let ((,winconf (current-window-configuration))
205 (,buffer (buffer-name (current-buffer)))
206 (,article (and gnus-article-reply (gnus-summary-article-number)))
207 (,group gnus-newsgroup-name)
208 (message-header-setup-hook
209 (copy-sequence message-header-setup-hook))
210 (message-mode-hook (copy-sequence message-mode-hook)))
211 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
212 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
213 (add-hook 'message-mode-hook 'gnus-configure-posting-styles)
214 (add-hook 'message-mode-hook
216 (setq message-user-agent (gnus-extended-version))))
220 (gnus-inews-add-send-actions ,winconf ,buffer ,article)
221 (setq gnus-message-buffer (current-buffer))
222 (set (make-local-variable 'gnus-message-group-art)
223 (cons ,group ,article))
224 (make-local-variable 'gnus-newsgroup-name)
225 (gnus-run-hooks 'gnus-message-setup-hook))
227 (gnus-configure-windows ,config t)
228 (set-buffer-modified-p nil))))
230 (defun gnus-inews-add-send-actions (winconf buffer article)
231 (make-local-hook 'message-sent-hook)
232 (add-hook 'message-sent-hook 'gnus-inews-do-gcc nil t)
233 (setq message-post-method
235 (gnus-post-method arg ,gnus-newsgroup-name)))
237 `(set-window-configuration ,winconf) 'exit 'postpone 'kill)
239 `(when (gnus-buffer-exists-p ,buffer)
243 `(gnus-summary-mark-article-as-replied ,article))))
246 (put 'gnus-setup-message 'lisp-indent-function 1)
247 (put 'gnus-setup-message 'edebug-form-spec '(form body))
249 ;;; Post news commands of Gnus group mode and summary mode
251 (defun gnus-group-mail (&optional arg)
252 "Start composing a mail.
253 If ARG, use the group under the point to find a posting style.
254 If ARG is 1, prompt for a group name to find the posting style."
256 (let ((gnus-newsgroup-name
258 (if (= 1 (prefix-numeric-value arg))
259 (completing-read "Use style of group: " gnus-active-hashtb nil
260 (gnus-read-active-file-p))
261 (gnus-group-group-name))
263 (gnus-setup-message 'message (message-mail))
266 (defun gnus-group-post-news (&optional arg)
267 "Start composing a news message.
268 If ARG, post to the group under point.
269 If ARG is 1, prompt for a group name."
271 ;; Bind this variable here to make message mode hooks work ok.
272 (let ((gnus-newsgroup-name
274 (if (= 1 (prefix-numeric-value arg))
275 (completing-read "Newsgroup: " gnus-active-hashtb nil
276 (gnus-read-active-file-p))
277 (gnus-group-group-name))
279 (gnus-post-news 'post gnus-newsgroup-name)))
281 (defun gnus-summary-post-news ()
282 "Start composing a news message."
284 (gnus-post-news 'post gnus-newsgroup-name))
286 (defun gnus-summary-followup (yank &optional force-news)
287 "Compose a followup to an article.
288 If prefix argument YANK is non-nil, original article is yanked automatically."
290 (list (and current-prefix-arg
291 (gnus-summary-work-articles 1))))
293 (gnus-summary-goto-subject (car yank)))
294 (save-window-excursion
295 (gnus-summary-select-article))
296 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
297 (gnus-newsgroup-name gnus-newsgroup-name))
299 (gnus-post-news nil gnus-newsgroup-name
300 headers gnus-article-buffer
301 yank nil force-news)))
303 (defun gnus-summary-followup-with-original (n &optional force-news)
304 "Compose a followup to an article and include the original article."
306 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
308 (defun gnus-summary-followup-to-mail (&optional arg)
309 "Followup to the current mail message via news."
311 (list (and current-prefix-arg
312 (gnus-summary-work-articles 1))))
313 (gnus-summary-followup arg t))
315 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
316 "Followup to the current mail message via news."
318 (gnus-summary-followup (gnus-summary-work-articles arg) t))
320 (defun gnus-inews-yank-articles (articles)
323 (while (setq article (pop articles))
324 (save-window-excursion
325 (set-buffer gnus-summary-buffer)
326 (gnus-summary-select-article nil nil nil article)
327 (gnus-summary-remove-process-mark article))
328 (gnus-copy-article-buffer)
329 (let ((message-reply-buffer gnus-article-copy)
330 (message-reply-headers gnus-current-headers))
331 (message-yank-original)
332 (setq beg (or beg (mark t))))
338 (defun gnus-summary-cancel-article (&optional n symp)
339 "Cancel an article you posted.
340 Uses the process-prefix convention. If given the symbolic
341 prefix `a', cancel using the standard posting method; if not
342 post using the current select method."
343 (interactive (gnus-interactive "P\ny"))
344 (let ((articles (gnus-summary-work-articles n))
347 (gnus-post-method (not (eq symp 'a)) ,gnus-newsgroup-name)))
349 (while (setq article (pop articles))
350 (when (gnus-summary-select-article t nil nil article)
351 (when (gnus-eval-in-buffer-window gnus-article-buffer
353 (set-buffer gnus-original-article-buffer)
354 (message-cancel-news)))
355 (gnus-summary-mark-as-read article gnus-canceled-mark)
356 (gnus-cache-remove-article 1))
357 (gnus-article-hide-headers-if-wanted))
358 (gnus-summary-remove-process-mark article))))
360 (defun gnus-summary-supersede-article ()
361 "Compose an article that will supersede a previous article.
362 This is done simply by taking the old article and adding a Supersedes
363 header line with the old Message-ID."
365 (let ((article (gnus-summary-article-number)))
366 (gnus-setup-message 'reply-yank
367 (gnus-summary-select-article t)
368 (set-buffer gnus-original-article-buffer)
372 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
374 (set-buffer ,gnus-summary-buffer)
375 (gnus-cache-possibly-remove-article ,article nil nil nil t)
376 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
377 message-send-actions))))
381 (defun gnus-copy-article-buffer (&optional article-buffer)
382 ;; make a copy of the article buffer with all text properties removed
383 ;; this copy is in the buffer gnus-article-copy.
384 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
385 ;; this buffer should be passed to all mail/news reply/post routines.
386 (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
387 (buffer-disable-undo gnus-article-copy)
388 (let ((article-buffer (or article-buffer gnus-article-buffer))
390 (if (not (and (get-buffer article-buffer)
391 (gnus-buffer-exists-p article-buffer)))
392 (error "Can't find any article buffer")
394 (set-buffer article-buffer)
396 ;; Copy over the (displayed) article buffer, delete
397 ;; hidden text and remove text properties.
399 (copy-to-buffer gnus-article-copy (point-min) (point-max))
400 (set-buffer gnus-article-copy)
401 (gnus-article-delete-text-of-type 'annotation)
402 (gnus-remove-text-with-property 'gnus-prev)
403 (gnus-remove-text-with-property 'gnus-next)
406 (format "%s" (buffer-string))
408 ;; Find the original headers.
409 (set-buffer gnus-original-article-buffer)
410 (goto-char (point-min))
411 (while (looking-at message-unix-mail-delimiter)
414 (setq end (or (search-forward "\n\n" nil t) (point)))
415 ;; Delete the headers from the displayed articles.
416 (set-buffer gnus-article-copy)
417 (delete-region (goto-char (point-min))
418 (or (search-forward "\n\n" nil t) (point)))
419 ;; Insert the original article headers.
420 (insert-buffer-substring gnus-original-article-buffer beg end)
421 (gnus-article-decode-rfc1522)))
424 (defun gnus-post-news (post &optional group header article-buffer yank subject
427 (gnus-copy-article-buffer))
428 (let ((gnus-article-reply article-buffer)
429 (add-to-list gnus-add-to-list))
430 (gnus-setup-message (cond (yank 'reply-yank)
431 (article-buffer 'reply)
433 (let* ((group (or group gnus-newsgroup-name))
435 to-address to-group mailing-list to-list
438 (setq to-address (gnus-group-find-parameter group 'to-address)
439 to-group (gnus-group-find-parameter group 'to-group)
440 to-list (gnus-group-find-parameter group 'to-list)
441 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
442 mailing-list (when gnus-mailing-list-groups
443 (string-match gnus-mailing-list-groups group))
444 group (gnus-group-real-name group)))
445 (if (or (and to-group
446 (gnus-news-group-p to-group))
449 (and (gnus-news-group-p
450 (or pgroup gnus-newsgroup-name)
451 (if header (mail-header-number header)
452 gnus-current-article))
458 (message-news (or to-group group))
459 (set-buffer gnus-article-copy)
460 (gnus-msg-treat-broken-reply-to)
461 (message-followup (if (or newsgroup-p force-news) nil to-group)))
465 (message-mail (or to-address to-list))
466 ;; Arrange for mail groups that have no `to-address' to
467 ;; get that when the user sends off the mail.
468 (when (and (not to-list)
471 (push (list 'gnus-inews-add-to-address pgroup)
472 message-send-actions)))
473 (set-buffer gnus-article-copy)
474 (gnus-msg-treat-broken-reply-to)
475 (message-wide-reply to-address)))
477 (gnus-inews-yank-articles yank))))))
479 (defun gnus-msg-treat-broken-reply-to ()
480 "Remove the Reply-to header iff broken-reply-to."
481 (when (gnus-group-find-parameter
482 gnus-newsgroup-name 'broken-reply-to)
484 (message-narrow-to-head)
485 (message-remove-header "reply-to"))))
487 (defun gnus-post-method (arg group &optional silent)
488 "Return the posting method based on GROUP and ARG.
489 If SILENT, don't prompt the user."
490 (let ((group-method (gnus-find-method-for-group group)))
492 ;; If the group-method is nil (which shouldn't happen) we use
493 ;; the default method.
495 (or (and (null (eq gnus-post-method 'active)) gnus-post-method)
496 gnus-select-method message-post-method))
497 ;; We want the inverse of the default
498 ((and arg (not (eq arg 0)))
499 (if (eq gnus-post-method 'active)
502 ;; We query the user for a post method.
504 (and gnus-post-method
505 (not (eq gnus-post-method 'current))
506 (listp (car gnus-post-method))))
508 ;; Collect all methods we know about.
510 (when (and gnus-post-method
511 (not (eq gnus-post-method 'current)))
512 (if (listp (car gnus-post-method))
514 (list gnus-post-method)))
515 gnus-secondary-select-methods
516 (mapcar 'cdr gnus-server-alist)
517 (mapcar 'car gnus-opened-servers)
518 (list gnus-select-method)
519 (list group-method)))
520 method-alist post-methods method)
521 ;; Weed out all mail methods.
523 (setq method (gnus-server-get-method "" (pop methods)))
524 (when (and (or (gnus-method-option-p method 'post)
525 (gnus-method-option-p method 'post-mail))
526 (not (member method post-methods)))
527 (push method post-methods)))
528 ;; Create a name-method alist.
532 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m))
537 (setq gnus-last-posting-server
539 gnus-last-posting-server)
540 ;; Just use the last value.
541 gnus-last-posting-server
543 "Posting method: " method-alist nil t
544 (cons (or gnus-last-posting-server "") 0))))
546 ;; Override normal method.
547 ((and (eq gnus-post-method 'current)
548 (not (eq (car group-method) 'nndraft))
551 ((and gnus-post-method
552 (not (eq gnus-post-method 'current)))
554 ;; Use the normal select method.
555 (t gnus-select-method))))
559 ;;; Gnus Mail Functions
562 ;;; Mail reply commands of Gnus summary mode
564 (defun gnus-summary-reply (&optional yank wide)
565 "Start composing a reply mail to the current message.
566 If prefix argument YANK is non-nil, the original article is yanked
569 (list (and current-prefix-arg
570 (gnus-summary-work-articles 1))))
571 ;; Stripping headers should be specified with mail-yank-ignored-headers.
573 (gnus-summary-goto-subject (car yank)))
574 (let ((gnus-article-reply t))
575 (gnus-setup-message (if yank 'reply-yank 'reply)
576 (gnus-summary-select-article)
577 (set-buffer (gnus-copy-article-buffer))
578 (gnus-msg-treat-broken-reply-to)
579 (message-reply nil wide)
581 (gnus-inews-yank-articles yank)))))
583 (defun gnus-summary-reply-with-original (n &optional wide)
584 "Start composing a reply mail to the current message.
585 The original article will be yanked."
587 (gnus-summary-reply (gnus-summary-work-articles n) wide))
589 (defun gnus-summary-wide-reply (&optional yank)
590 "Start composing a wide 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 (gnus-summary-reply yank t))
598 (defun gnus-summary-wide-reply-with-original (n)
599 "Start composing a wide reply mail to the current message.
600 The original article will be yanked."
602 (gnus-summary-reply-with-original n t))
604 (defun gnus-summary-mail-forward (&optional full-headers post)
605 "Forward the current message to another user.
606 If FULL-HEADERS (the prefix), include full headers when forwarding."
608 (gnus-setup-message 'forward
609 (gnus-summary-select-article)
610 (let ((charset default-mime-charset))
611 (set-buffer gnus-original-article-buffer)
612 (make-local-variable 'default-mime-charset)
613 (setq default-mime-charset charset)
615 (let ((message-included-forward-headers
616 (if full-headers "" message-included-forward-headers)))
617 (message-forward post))))
619 (defun gnus-summary-post-forward (&optional full-headers)
620 "Forward the current article to a newsgroup.
621 If FULL-HEADERS (the prefix), include full headers when forwarding."
623 (gnus-summary-mail-forward full-headers t))
625 ;;; XXX: generate Subject and ``Topics''?
626 (defun gnus-summary-mail-digest (&optional n post)
627 "Digests and forwards all articles in this series."
629 (let ((subject "Digested Articles")
630 (articles (gnus-summary-work-articles n))
632 (gnus-setup-message 'forward
633 (gnus-summary-select-article)
634 (if post (message-news nil subject) (message-mail nil subject))
636 (while (setq article (pop articles))
637 (save-window-excursion
638 (set-buffer gnus-summary-buffer)
639 (gnus-summary-select-article nil nil nil article)
640 (gnus-summary-remove-process-mark article))
641 (insert (mime-make-tag "message" "rfc822") "\n")
642 (insert-buffer-substring gnus-original-article-buffer))
645 (mime-edit-enclose-digest-region (point)(mark t)))))
647 (defun gnus-summary-post-digest (&optional n)
648 "Digest and forwards all articles in this series to a newsgroup."
650 (gnus-summary-mail-digest n t))
652 (defun gnus-summary-resend-message (address n)
653 "Resend the current article to ADDRESS."
654 (interactive "sResend message(s) to: \nP")
655 (let ((articles (gnus-summary-work-articles n))
657 (while (setq article (pop articles))
658 (gnus-summary-select-article nil nil nil article)
660 (set-buffer gnus-original-article-buffer)
661 (message-resend address)))))
663 (defvar gnus-nastygram-message
664 "The following article was inappropriately posted to %s.\n\n"
665 "Format string to insert in nastygrams.
666 The current group name will be inserted at \"%s\".")
668 (defun gnus-summary-mail-nastygram (n)
669 "Send a nastygram to the author of the current article."
671 (when (or gnus-expert-user
673 "Really send a nastygram to the author of the current article? "))
674 (let ((group gnus-newsgroup-name))
675 (gnus-summary-reply-with-original n)
676 (set-buffer gnus-message-buffer)
678 (insert (format gnus-nastygram-message group))
679 (message-send-and-exit))))
681 (defun gnus-summary-mail-crosspost-complaint (n)
682 "Send a complaint about crossposting to the current article(s)."
684 (let ((articles (gnus-summary-work-articles n))
686 (while (setq article (pop articles))
687 (set-buffer gnus-summary-buffer)
688 (gnus-summary-goto-subject article)
689 (let ((group (gnus-group-real-name gnus-newsgroup-name))
690 newsgroups followup-to)
691 (gnus-summary-select-article)
692 (set-buffer gnus-original-article-buffer)
693 (if (and (<= (length (message-tokenize-header
694 (setq newsgroups (mail-fetch-field "newsgroups"))
697 (or (not (setq followup-to (mail-fetch-field "followup-to")))
698 (not (member group (message-tokenize-header
699 followup-to ", ")))))
701 (gnus-message 1 "Followup-to restricted")
702 (gnus-message 1 "Not a crossposted article"))
703 (set-buffer gnus-summary-buffer)
704 (gnus-summary-reply-with-original 1)
705 (set-buffer gnus-message-buffer)
707 (insert (format gnus-crosspost-complaint newsgroups group))
708 (message-goto-subject)
709 (re-search-forward " *$")
710 (replace-match " (crosspost notification)" t t)
711 (gnus-deactivate-mark)
712 (when (gnus-y-or-n-p "Send this complaint? ")
713 (message-send-and-exit)))))))
715 (defun gnus-summary-mail-other-window ()
716 "Compose mail in other window."
718 (gnus-setup-message 'message
721 (defun gnus-mail-parse-comma-list ()
724 (skip-chars-forward " ")
727 (skip-chars-forward "^,")
732 (narrow-to-region beg (point))
735 (while (search-forward "\"" nil t)
739 (skip-chars-forward ",")
740 (skip-chars-forward "^,"))
741 (skip-chars-backward " ")
742 (push (buffer-substring beg (point))
744 (skip-chars-forward "^,")
745 (skip-chars-forward ", "))
748 (defun gnus-inews-add-to-address (group)
749 (let ((to-address (mail-fetch-field "to")))
750 (when (and to-address
752 ;; This mail group doesn't have a `to-list', so we add one
755 (format "Do you want to add this as `to-list': %s " to-address))
756 (gnus-group-add-parameter group (cons 'to-list to-address))))))
758 (defun gnus-put-message ()
759 "Put the current message in some group and return to Gnus."
761 (let ((reply gnus-article-reply)
762 (winconf gnus-prev-winconf)
763 (group gnus-newsgroup-name))
765 (or (and group (not (gnus-group-read-only-p group)))
766 (setq group (read-string "Put in group: " nil
767 (gnus-writable-groups))))
768 (when (gnus-gethash group gnus-newsrc-hashtb)
769 (error "No such group: %s" group))
774 (message-narrow-to-headers)
775 (let (gnus-deletable-headers)
777 (message-generate-headers message-required-news-headers)
778 (message-generate-headers message-required-mail-headers)))
779 (goto-char (point-max))
780 (insert "Gcc: " group "\n")
785 (when (get-buffer gnus-group-buffer)
786 (when (gnus-buffer-exists-p (car-safe reply))
787 (set-buffer (car reply))
789 (gnus-summary-mark-article-as-replied
792 (set-window-configuration winconf)))))
794 (defun gnus-article-mail (yank)
795 "Send a reply to the address near point.
796 If YANK is non-nil, include the original article."
800 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
801 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
803 (message-reply address)
805 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
807 (defvar nntp-server-type)
809 "Send a bug report to the Gnus maintainers."
811 (unless (gnus-alive-p)
812 (error "Gnus has been shut down"))
813 (gnus-setup-message 'bug
814 (delete-other-windows)
815 (when gnus-bug-create-help-buffer
816 (switch-to-buffer "*Gnus Help Bug*")
818 (insert gnus-bug-message)
819 (goto-char (point-min)))
820 (message-pop-to-buffer "*Gnus Bug*")
822 `((To . ,gnus-maintainer) (Cc . ,semi-gnus-developers) (Subject . "")))
823 (when gnus-bug-create-help-buffer
824 (push `(gnus-bug-kill-buffer) message-send-actions))
825 (goto-char (point-min))
826 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
828 (insert (gnus-version) "\n"
829 (emacs-version) "\n")
830 (when (and (boundp 'nntp-server-type)
831 (stringp nntp-server-type))
832 (insert nntp-server-type))
833 (insert "\n\n\n\n\n")
835 (goto-char (point-min))
836 (search-forward "Subject: " nil t)
839 (defun gnus-bug-kill-buffer ()
840 (when (get-buffer "*Gnus Help Bug*")
841 (kill-buffer "*Gnus Help Bug*")))
844 "Attempts to go through the Gnus source file and report what variables have been changed.
845 The source file has to be in the Emacs load path."
847 (let ((files '("gnus.el" "gnus-sum.el" "gnus-group.el"
848 "gnus-art.el" "gnus-start.el" "gnus-async.el"
849 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
850 "nnmail.el" "message.el"))
853 (gnus-message 4 "Please wait while we snoop your variables...")
855 ;; Go through all the files looking for non-default values for variables.
857 (set-buffer (gnus-get-buffer-create " *gnus bug info*"))
858 (buffer-disable-undo (current-buffer))
861 (when (and (setq file (locate-library (pop files)))
862 (file-exists-p file))
863 (insert-file-contents file)
864 (goto-char (point-min))
865 (if (not (re-search-forward "^;;* *Internal variables" nil t))
866 (gnus-message 4 "Malformed sources in file %s" file)
867 (narrow-to-region (point-min) (point))
868 (goto-char (point-min))
869 (while (setq expr (ignore-errors (read (current-buffer))))
871 (and (or (eq (car expr) 'defvar)
872 (eq (car expr) 'defcustom))
873 (stringp (nth 3 expr))
874 (or (not (boundp (nth 1 expr)))
875 (not (equal (eval (nth 2 expr))
876 (symbol-value (nth 1 expr)))))
877 (push (nth 1 expr) olist)))))))
878 (kill-buffer (current-buffer)))
879 (when (setq olist (nreverse olist))
880 (insert "------------------ Environment follows ------------------\n\n"))
882 (if (boundp (car olist))
884 (pp `(setq ,(car olist)
885 ,(if (or (consp (setq sym (symbol-value (car olist))))
887 (not (or (eq sym nil)
889 (list 'quote (symbol-value (car olist)))
890 (symbol-value (car olist))))
893 (format "(setq %s 'whatever)\n" (car olist))))
894 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
895 (setq olist (cdr olist)))
897 ;; Remove any control chars - they seem to cause trouble for some
898 ;; mailers. (Byte-compiled output from the stuff above.)
900 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
901 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
904 ;;; Treatment of rejected articles.
907 (defun gnus-summary-resend-bounced-mail (&optional fetch)
908 "Re-mail the current message.
909 This only makes sense if the current message is a bounce message than
910 contains some mail you have written which has been bounced back to
912 If FETCH, try to fetch the article that this is a reply to, if indeed
915 (gnus-summary-select-article t)
916 (set-buffer gnus-original-article-buffer)
917 (gnus-setup-message 'compose-bounce
918 (let* ((references (mail-fetch-field "references"))
919 (parent (and references (gnus-parent-id references))))
921 ;; If there are references, we fetch the article we answered to.
923 (gnus-summary-refer-article parent)
924 (gnus-summary-show-all-headers)))))
928 ;; Do Gcc handling, which copied the message over to some group.
929 (defun gnus-inews-do-gcc (&optional gcc)
934 (message-narrow-to-headers)
935 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
936 (coding-system-for-write 'raw-text)
939 (message-remove-header "gcc")
941 (setq groups (message-tokenize-header gcc " ,"))
942 ;; Copy the article over to some group(s).
943 (while (setq group (pop groups))
946 (cond ((and (null (gnus-get-info group))
947 (eq (car gnus-message-archive-method)
949 (gnus-server-to-method
950 (gnus-group-method group)))))
951 ;; If the group doesn't exist, we assume
952 ;; it's an archive group...
953 gnus-message-archive-method)
955 ((gnus-info-method (gnus-get-info group))
956 (gnus-info-method (gnus-get-info group)))
958 (t (gnus-group-method group)))))
959 (gnus-check-server method)
960 (unless (gnus-request-group group t method)
961 (gnus-request-create-group group method))
963 (nnheader-set-temp-buffer " *acc*")
964 (insert-buffer-substring message-encoding-buffer)
965 (gnus-run-hooks 'gnus-before-do-gcc-hook)
966 (goto-char (point-min))
967 (when (re-search-forward
968 (concat "^" (regexp-quote mail-header-separator) "$")
970 (replace-match "" t t ))
971 (unless (gnus-request-accept-article group method t)
972 (gnus-message 1 "Couldn't store article in group %s: %s"
973 group (gnus-status-message method))
975 (kill-buffer (current-buffer))))))))))
977 (defun gnus-inews-insert-gcc ()
978 "Insert Gcc headers based on `gnus-outgoing-message-group'."
981 (message-narrow-to-headers)
982 (let* ((group gnus-outgoing-message-group)
984 ((gnus-functionp group)
986 ((or (stringp group) (list group))
990 (if (stringp gcc) gcc
991 (mapconcat 'identity gcc " "))
994 (defun gnus-inews-insert-archive-gcc (&optional group)
995 "Insert the Gcc to say where the article is to be archived."
996 (let* ((var gnus-message-archive-group)
997 (group (or group gnus-newsgroup-name ""))
999 (and gnus-newsgroup-name
1000 (gnus-group-find-parameter
1001 gnus-newsgroup-name 'gcc-self)))
1005 ((null gnus-message-archive-method)
1009 ;; Just a single group.
1012 ;; We don't want this.
1014 ((and (listp var) (stringp (car var)))
1015 ;; A list of groups.
1017 ((gnus-functionp var)
1019 (funcall var group))
1021 ;; An alist of regexps/functions/forms.
1026 ((stringp (caar var))
1028 (when (string-match (caar var) group)
1030 ((gnus-functionp (car var))
1032 (funcall (car var) group))
1034 (eval (car var)))))))
1035 (setq var (cdr var)))
1038 (when (or groups gcc-self-val)
1039 (when (stringp groups)
1040 (setq groups (list groups)))
1043 (message-narrow-to-headers)
1044 (goto-char (point-max))
1047 ;; Use the `gcc-self' param value instead.
1050 (if (stringp gcc-self-val)
1053 (if (not (eq gcc-self-val 'none))
1058 ;; Use the list of groups.
1059 (while (setq name (pop groups))
1060 (insert (if (string-match ":" name)
1062 (gnus-group-prefixed-name
1063 name gnus-message-archive-method)))
1070 (defvar gnus-message-style-insertions nil)
1072 (defun gnus-configure-posting-styles ()
1073 "Configure posting styles according to `gnus-posting-styles'."
1074 (unless gnus-inhibit-posting-styles
1075 (let ((styles gnus-posting-styles)
1076 (gnus-newsgroup-name (or gnus-newsgroup-name ""))
1077 style match variable attribute value value-value)
1078 (make-local-variable 'gnus-message-style-insertions)
1079 ;; Go through all styles and look for matches.
1081 (setq style (pop styles)
1083 (when (cond ((stringp match)
1084 ;; Regexp string match on the group name.
1085 (string-match match gnus-newsgroup-name))
1086 ((or (symbolp match)
1087 (gnus-functionp match))
1088 (cond ((gnus-functionp match)
1089 ;; Function to be called.
1092 ;; Variable to be checked.
1093 (symbol-value match))))
1095 ;; This is a form to be evaled.
1097 ;; We have a match, so we set the variables.
1099 (setq attribute (pop style)
1100 value (cadr attribute)
1102 ;; We find the variable that is to be modified.
1103 (if (and (not (stringp (car attribute)))
1104 (not (eq 'body (car attribute)))
1106 (cdr (assq (car attribute)
1107 gnus-posting-style-alist)))))
1108 (message "Couldn't find attribute %s" (car attribute))
1109 ;; We get the value.
1111 (cond ((stringp value)
1113 ((or (symbolp value)
1114 (gnus-functionp value))
1115 (cond ((gnus-functionp value)
1118 (symbol-value value))))
1122 ;; This is an ordinary variable.
1123 (set (make-local-variable variable) value-value)
1124 ;; This is either a body or a header to be inserted in the
1127 (let ((attr (car attribute)))
1128 (make-local-variable 'message-setup-hook)
1130 (add-hook 'message-setup-hook
1134 (insert ,value-value))))
1135 (add-hook 'message-setup-hook
1136 'gnus-message-insert-stylings)
1137 (push (cons (if (stringp attr) attr
1140 gnus-message-style-insertions))))))))))))
1142 (defun gnus-message-insert-stylings ()
1146 (while (setq val (pop gnus-message-style-insertions))
1148 (insert (car val) ": " (cdr val) "\n"))
1149 (gnus-pull (car val) gnus-message-style-insertions)))))
1151 ;;; Allow redefinition of functions.
1157 ;;; gnus-msg.el ends here