1 ;;; gnus-msg.el --- mail and post interface for Gnus
2 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000
3 ;; Free Software Foundation, Inc.
5 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
6 ;; Lars Magne Ingebrigtsen <larsi@gnus.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
30 (eval-when-compile (require 'cl))
37 (defcustom gnus-post-method 'current
38 "*Preferred method for posting USENET news.
40 If this variable is `current', Gnus will use the \"current\" select
41 method when posting. If it is nil (which is the default), Gnus will
42 use the native select method when posting.
44 This method will not be used in mail groups and the like, only in
47 If not nil nor `native', the value must be a valid method as discussed
48 in the documentation of `gnus-select-method'. It can also be a list of
49 methods. If that is the case, the user will be queried for what select
50 method to use when posting."
51 :group 'gnus-group-foreign
52 :type `(choice (const nil)
55 (sexp :tag "Methods" ,gnus-select-method)))
57 (defvar gnus-outgoing-message-group nil
58 "*All outgoing messages will be put in this group.
59 If you want to store all your outgoing mail and articles in the group
60 \"nnml:archive\", you set this variable to that value. This variable
61 can also be a list of group names.
63 If you want to have greater control over what group to put each
64 message in, you can set this variable to a function that checks the
65 current newsgroup name and then returns a suitable group name (or list
68 (defvar gnus-mailing-list-groups nil
69 "*Regexp matching groups that are really mailing lists.
70 This is useful when you're reading a mailing list that has been
71 gatewayed to a newsgroup, and you want to followup to an article in
74 (defvar gnus-add-to-list nil
75 "*If non-nil, add a `to-list' parameter automatically.")
77 (defvar gnus-crosspost-complaint
80 You posted the article below with the following Newsgroups header:
84 The %s group, at least, was an inappropriate recipient
85 of this message. Please trim your Newsgroups header to exclude this
86 group before posting in the future.
91 "Format string to be inserted when complaining about crossposts.
92 The first %s will be replaced by the Newsgroups header;
93 the second with the current group name.")
95 (defvar gnus-message-setup-hook nil
96 "Hook run after setting up a message buffer.")
98 (defvar gnus-bug-create-help-buffer t
99 "*Should we create the *Gnus Help Bug* buffer?")
101 (defvar gnus-posting-styles nil
102 "*Alist of styles to use when posting.")
104 ;;; Internal variables.
106 (defvar gnus-inhibit-posting-styles nil
107 "Inhibit the use of posting styles.")
109 (defvar gnus-message-buffer "*Mail Gnus*")
110 (defvar gnus-article-copy nil)
111 (defvar gnus-last-posting-server nil)
112 (defvar gnus-message-group-art nil)
114 (defconst gnus-bug-message
115 "Sending a bug report to the Gnus Towers.
116 ========================================
118 The buffer below is a mail buffer. When you press `C-c C-c', it will
119 be sent to the Gnus Bug Exterminators.
121 The thing near the bottom of the buffer is how the environment
122 settings will be included in the mail. Please do not delete that.
123 They will tell the Bug People what your environment is, so that it
124 will be easier to locate the bugs.
126 If you have found a bug that makes Emacs go \"beep\", set
127 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
128 and include the backtrace in your bug report.
130 Please describe the bug in annoying, painstaking detail.
132 Thank you for your help in stamping out bugs.
136 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
137 (autoload 'news-setup "rnewspost")
138 (autoload 'news-reply-mode "rnewspost")
139 (autoload 'rmail-dont-reply-to "mail-utils")
140 (autoload 'rmail-output "rmailout"))
144 ;;; Gnus Posting Functions
147 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
148 "p" gnus-summary-post-news
149 "f" gnus-summary-followup
150 "F" gnus-summary-followup-with-original
151 "c" gnus-summary-cancel-article
152 "s" gnus-summary-supersede-article
153 "r" gnus-summary-reply
154 "y" gnus-summary-yank-message
155 "R" gnus-summary-reply-with-original
156 "w" gnus-summary-wide-reply
157 "W" gnus-summary-wide-reply-with-original
158 "n" gnus-summary-followup-to-mail
159 "N" gnus-summary-followup-to-mail-with-original
160 "m" gnus-summary-mail-other-window
161 "u" gnus-uu-post-news
162 "\M-c" gnus-summary-mail-crosspost-complaint
163 "om" gnus-summary-mail-forward
164 "op" gnus-summary-post-forward
165 "Om" gnus-uu-digest-mail-forward
166 "Op" gnus-uu-digest-post-forward)
168 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
169 "b" gnus-summary-resend-bounced-mail
170 ;; "c" gnus-summary-send-draft
171 "r" gnus-summary-resend-message)
173 ;;; Internal functions.
175 (defvar gnus-article-reply nil)
176 (defmacro gnus-setup-message (config &rest forms)
177 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
178 (buffer (make-symbol "gnus-setup-message-buffer"))
179 (article (make-symbol "gnus-setup-message-article"))
180 (group (make-symbol "gnus-setup-message-group")))
181 `(let ((,winconf (current-window-configuration))
182 (,buffer (buffer-name (current-buffer)))
183 (,article (and gnus-article-reply (gnus-summary-article-number)))
184 (,group gnus-newsgroup-name)
185 (message-header-setup-hook
186 (copy-sequence message-header-setup-hook))
187 (message-mode-hook (copy-sequence message-mode-hook))
188 (message-startup-parameter-alist
189 '((reply-buffer . gnus-copy-article-buffer)
190 (original-buffer . gnus-original-article-buffer)
191 (user-agent . Gnus))))
192 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
193 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
194 (add-hook 'message-mode-hook 'gnus-configure-posting-styles)
198 (gnus-inews-add-send-actions ,winconf ,buffer ,article)
199 (setq gnus-message-buffer (current-buffer))
200 (set (make-local-variable 'gnus-message-group-art)
201 (cons ,group ,article))
202 (set (make-local-variable 'gnus-newsgroup-name) ,group)
203 (gnus-run-hooks 'gnus-message-setup-hook))
205 (gnus-configure-windows ,config t)
206 (set-buffer-modified-p nil))))
208 (defun gnus-inews-add-send-actions (winconf buffer article)
209 (make-local-hook 'message-sent-hook)
210 (add-hook 'message-sent-hook 'gnus-inews-do-gcc nil t)
211 (setq message-post-method
213 (gnus-post-method arg ,gnus-newsgroup-name)))
214 (setq message-user-agent (product-string 'gnus))
215 (unless message-use-multi-frames
217 `(set-window-configuration ,winconf) 'exit 'postpone 'kill))
219 `(when (gnus-buffer-exists-p ,buffer)
223 `(gnus-summary-mark-article-as-replied ,article))))
226 (put 'gnus-setup-message 'lisp-indent-function 1)
227 (put 'gnus-setup-message 'edebug-form-spec '(form body))
229 ;;; Post news commands of Gnus group mode and summary mode
231 (defun gnus-group-mail (&optional arg)
232 "Start composing a mail.
233 If ARG, use the group under the point to find a posting style.
234 If ARG is 1, prompt for a group name to find the posting style."
236 ;; We can't `let' gnus-newsgroup-name here, since that leads
237 ;; to local variables leaking.
238 (let ((group gnus-newsgroup-name)
239 (buffer (current-buffer)))
242 (setq gnus-newsgroup-name
244 (if (= 1 (prefix-numeric-value arg))
245 (completing-read "Use posting style of group: "
246 gnus-active-hashtb nil
247 (gnus-read-active-file-p))
248 (gnus-group-group-name))
250 (gnus-setup-message 'message (message-mail)))
253 (setq gnus-newsgroup-name group)))))
255 (defun gnus-group-post-news (&optional arg)
256 "Start composing a news message.
257 If ARG, post to the group under point.
258 If ARG is 1, prompt for a group name."
260 ;; Bind this variable here to make message mode hooks work ok.
261 (let ((gnus-newsgroup-name
263 (if (= 1 (prefix-numeric-value arg))
264 (completing-read "Newsgroup: " gnus-active-hashtb nil
265 (gnus-read-active-file-p))
266 (gnus-group-group-name))
268 (gnus-post-news 'post gnus-newsgroup-name)))
270 (defun gnus-summary-post-news ()
271 "Start composing a news message."
273 (gnus-post-news 'post gnus-newsgroup-name))
275 (defun gnus-summary-followup (yank &optional force-news)
276 "Compose a followup to an article.
277 If prefix argument YANK is non-nil, original article is yanked automatically."
279 (list (and current-prefix-arg
280 (gnus-summary-work-articles 1))))
282 (gnus-summary-goto-subject (car yank)))
283 (save-window-excursion
284 (gnus-summary-select-article))
285 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
286 (gnus-newsgroup-name gnus-newsgroup-name))
288 (gnus-post-news nil gnus-newsgroup-name
289 headers gnus-article-buffer
290 yank nil force-news)))
292 (defun gnus-summary-followup-with-original (n &optional force-news)
293 "Compose a followup to an article and include the original article."
295 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
297 (defun gnus-summary-followup-to-mail (&optional arg)
298 "Followup to the current mail message via news."
300 (list (and current-prefix-arg
301 (gnus-summary-work-articles 1))))
302 (gnus-summary-followup arg t))
304 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
305 "Followup to the current mail message via news."
307 (gnus-summary-followup (gnus-summary-work-articles arg) t))
309 (defun gnus-inews-yank-articles (articles)
310 (let* ((more-than-one (cdr articles))
311 (frame (when (and message-use-multi-frames more-than-one)
312 (window-frame (get-buffer-window (current-buffer)))))
315 (while (setq article (pop articles))
316 (save-window-excursion
317 (set-buffer gnus-summary-buffer)
318 (gnus-summary-select-article nil nil nil article)
319 (gnus-summary-remove-process-mark article))
321 (select-frame frame))
322 ;; Gathering references.
324 (setq refs (message-list-references
326 (mail-header-references gnus-current-headers)
327 (mail-header-message-id gnus-current-headers))))
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))))
336 ;; Replace with the gathered references.
340 (message-narrow-to-headers)
341 (let ((case-fold-search t))
342 (if (re-search-forward "^References:\\([\t ]+.+\n\\)+" nil t)
344 (goto-char (point-max))))
346 (list (or (assq 'References message-header-format-alist)
347 '(References . message-fill-references)))
348 (list (cons 'References
349 (mapconcat 'identity (nreverse refs) " "))))
350 (backward-delete-char 1))
355 (defun gnus-summary-cancel-article (&optional n symp)
356 "Cancel an article you posted.
357 Uses the process-prefix convention. If given the symbolic
358 prefix `a', cancel using the standard posting method; if not
359 post using the current select method."
360 (interactive (gnus-interactive "P\ny"))
361 (let ((articles (gnus-summary-work-articles n))
364 (gnus-post-method (not (eq symp 'a)) ,gnus-newsgroup-name)))
366 (while (setq article (pop articles))
367 (when (gnus-summary-select-article t nil nil article)
368 (when (gnus-eval-in-buffer-window gnus-original-article-buffer
369 (message-cancel-news))
370 (gnus-summary-mark-as-read article gnus-canceled-mark)
371 (gnus-cache-remove-article 1))
372 (gnus-article-hide-headers-if-wanted))
373 (gnus-summary-remove-process-mark article))))
375 (defun gnus-summary-supersede-article ()
376 "Compose an article that will supersede a previous article.
377 This is done simply by taking the old article and adding a Supersedes
378 header line with the old Message-ID."
380 (let ((article (gnus-summary-article-number)))
381 (gnus-setup-message 'reply-yank
382 (gnus-summary-select-article t)
383 (set-buffer gnus-original-article-buffer)
387 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
389 (set-buffer ,gnus-summary-buffer)
390 (gnus-cache-possibly-remove-article ,article nil nil nil t)
391 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
392 message-send-actions))))
396 (defun gnus-copy-article-buffer (&optional article-buffer)
397 ;; make a copy of the article buffer with all text properties removed
398 ;; this copy is in the buffer gnus-article-copy.
399 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
400 ;; this buffer should be passed to all mail/news reply/post routines.
401 (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
403 (set-buffer gnus-article-copy)
404 (mm-enable-multibyte))
405 (let ((article-buffer (or article-buffer gnus-article-buffer))
407 (if (not (and (get-buffer article-buffer)
408 (gnus-buffer-exists-p article-buffer)))
409 (error "Can't find any article buffer")
411 (set-buffer article-buffer)
413 ;; Copy over the (displayed) article buffer, delete
414 ;; hidden text and remove text properties.
416 (copy-to-buffer gnus-article-copy (point-min) (point-max))
417 (set-buffer gnus-article-copy)
418 (gnus-article-delete-text-of-type 'annotation)
419 (gnus-remove-text-with-property 'gnus-prev)
420 (gnus-remove-text-with-property 'gnus-next)
423 (format "%s" (buffer-string))
425 ;; Find the original headers.
426 (set-buffer gnus-original-article-buffer)
428 (goto-char (point-min))
429 (while (looking-at message-unix-mail-delimiter)
432 (setq end (or (search-forward "\n\n" nil t) (point)))
433 ;; Delete the headers from the displayed articles.
434 (set-buffer gnus-article-copy)
435 (delete-region (goto-char (point-min))
436 (or (search-forward "\n\n" nil t) (point-max)))
437 ;; Insert the original article headers.
438 (insert-buffer-substring gnus-original-article-buffer beg end)
439 (article-decode-encoded-words)))
442 (defun gnus-post-news (post &optional group header article-buffer yank subject
445 (gnus-copy-article-buffer))
446 (let ((gnus-article-reply article-buffer)
447 (add-to-list gnus-add-to-list))
448 (gnus-setup-message (cond (yank 'reply-yank)
449 (article-buffer 'reply)
451 (let* ((group (or group gnus-newsgroup-name))
453 to-address to-group mailing-list to-list
456 (setq to-address (gnus-group-find-parameter group 'to-address)
457 to-group (gnus-group-find-parameter group 'to-group)
458 to-list (gnus-group-find-parameter group 'to-list)
459 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
460 mailing-list (when gnus-mailing-list-groups
461 (string-match gnus-mailing-list-groups group))
462 group (gnus-group-real-name group)))
463 (if (or (and to-group
464 (gnus-news-group-p to-group))
467 (and (gnus-news-group-p
468 (or pgroup gnus-newsgroup-name)
469 (if header (mail-header-number header)
470 gnus-current-article))
476 (message-news (or to-group group))
477 (set-buffer gnus-article-copy)
478 (gnus-msg-treat-broken-reply-to)
479 (message-followup (if (or newsgroup-p force-news) nil to-group)))
483 (message-mail (or to-address to-list))
484 ;; Arrange for mail groups that have no `to-address' to
485 ;; get that when the user sends off the mail.
486 (when (and (not to-list)
489 (push (list 'gnus-inews-add-to-address pgroup)
490 message-send-actions)))
491 (set-buffer gnus-article-copy)
492 (gnus-msg-treat-broken-reply-to)
493 (message-wide-reply to-address)))
495 (gnus-inews-yank-articles yank))))))
497 (defun gnus-msg-treat-broken-reply-to ()
498 "Remove the Reply-to header iff broken-reply-to."
499 (when (gnus-group-find-parameter
500 gnus-newsgroup-name 'broken-reply-to)
502 (message-narrow-to-head)
503 (message-remove-header "reply-to"))))
505 (defun gnus-post-method (arg group &optional silent)
506 "Return the posting method based on GROUP and ARG.
507 If SILENT, don't prompt the user."
508 (let ((group-method (gnus-find-method-for-group group)))
510 ;; If the group-method is nil (which shouldn't happen) we use
511 ;; the default method.
513 (or (and (null (eq gnus-post-method 'active)) gnus-post-method)
514 gnus-select-method message-post-method))
515 ;; We want the inverse of the default
516 ((and arg (not (eq arg 0)))
517 (if (eq gnus-post-method 'active)
520 ;; We query the user for a post method.
522 (and gnus-post-method
523 (not (eq gnus-post-method 'current))
524 (listp (car gnus-post-method))))
526 ;; Collect all methods we know about.
528 (when (and gnus-post-method
529 (not (eq gnus-post-method 'current)))
530 (if (listp (car gnus-post-method))
532 (list gnus-post-method)))
533 gnus-secondary-select-methods
534 (mapcar 'cdr gnus-server-alist)
535 (list gnus-select-method)
536 (list group-method)))
537 method-alist post-methods method)
538 ;; Weed out all mail methods.
540 (setq method (gnus-server-get-method "" (pop methods)))
541 (when (and (or (gnus-method-option-p method 'post)
542 (gnus-method-option-p method 'post-mail))
543 (not (member method post-methods)))
544 (push method post-methods)))
545 ;; Create a name-method alist.
549 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m))
554 (setq gnus-last-posting-server
556 gnus-last-posting-server)
557 ;; Just use the last value.
558 gnus-last-posting-server
560 "Posting method: " method-alist nil t
561 (cons (or gnus-last-posting-server "") 0))))
563 ;; Override normal method.
564 ((and (eq gnus-post-method 'current)
565 (not (eq (car group-method) 'nndraft))
566 (gnus-get-function group-method 'request-post t)
569 ((and gnus-post-method
570 (not (eq gnus-post-method 'current)))
572 ;; Use the normal select method.
573 (t gnus-select-method))))
577 ;;; Gnus Mail Functions
580 ;;; Mail reply commands of Gnus summary mode
582 (defun gnus-summary-reply (&optional yank wide)
583 "Start composing a reply mail to the current message.
584 If prefix argument YANK is non-nil, the original article is yanked
587 (list (and current-prefix-arg
588 (gnus-summary-work-articles 1))))
589 ;; Stripping headers should be specified with mail-yank-ignored-headers.
591 (gnus-summary-goto-subject (car yank)))
592 (let ((gnus-article-reply t))
593 (gnus-setup-message (if yank 'reply-yank 'reply)
594 (gnus-summary-select-article)
595 (set-buffer (gnus-copy-article-buffer))
596 (gnus-msg-treat-broken-reply-to)
597 (message-reply nil wide)
599 (gnus-inews-yank-articles yank)))))
601 (defun gnus-summary-reply-with-original (n &optional wide)
602 "Start composing a reply mail to the current message.
603 The original article will be yanked."
605 (gnus-summary-reply (gnus-summary-work-articles n) wide))
607 (defun gnus-summary-wide-reply (&optional yank)
608 "Start composing a wide reply mail to the current message.
609 If prefix argument YANK is non-nil, the original article is yanked
612 (list (and current-prefix-arg
613 (gnus-summary-work-articles 1))))
614 (gnus-summary-reply yank t))
616 (defun gnus-summary-wide-reply-with-original (n)
617 "Start composing a wide reply mail to the current message.
618 The original article will be yanked."
620 (gnus-summary-reply-with-original n t))
622 (defun gnus-summary-mail-forward (&optional not-used post)
623 "Forward the current message to another user.
624 If POST, post instead of mail."
626 (gnus-setup-message 'forward
627 (gnus-summary-select-article)
630 (set-buffer gnus-original-article-buffer)
631 (setq text (buffer-string)))
632 (set-buffer (gnus-get-buffer-create
633 (generate-new-buffer-name " *Gnus forward*")))
636 (goto-char (point-min))
637 (when (looking-at "From ")
638 (replace-match "X-From-Line: ") )
639 (run-hooks 'gnus-article-decode-hook)
640 (message-forward post))))
642 ;;; XXX: generate Subject and ``Topics''?
643 (defun gnus-summary-mail-digest (&optional n post)
644 "Digests and forwards all articles in this series."
646 (let ((subject "Digested Articles")
647 (articles (gnus-summary-work-articles n))
649 (gnus-setup-message 'forward
650 (gnus-summary-select-article)
651 (if post (message-news nil subject) (message-mail nil subject))
652 (when (and message-use-multi-frames (cdr articles))
653 (setq frame (window-frame (get-buffer-window (current-buffer)))))
655 (while (setq article (pop articles))
656 (save-window-excursion
657 (set-buffer gnus-summary-buffer)
658 (gnus-summary-select-article nil nil nil article)
659 (gnus-summary-remove-process-mark article))
661 (select-frame frame))
662 (insert (mime-make-tag "message" "rfc822") "\n")
663 (insert-buffer-substring gnus-original-article-buffer))
666 (mime-edit-enclose-digest-region (point)(mark t)))))
668 (defun gnus-summary-post-digest (&optional n)
669 "Digest and forwards all articles in this series to a newsgroup."
671 (gnus-summary-mail-digest n t))
673 (defun gnus-summary-resend-message (address n)
674 "Resend the current article to ADDRESS."
675 (interactive "sResend message(s) to: \nP")
676 (let ((articles (gnus-summary-work-articles n))
678 (while (setq article (pop articles))
679 (gnus-summary-select-article nil nil nil article)
681 (set-buffer gnus-original-article-buffer)
682 (message-resend address)))))
684 (defun gnus-summary-post-forward (&optional full-headers)
685 "Forward the current article to a newsgroup.
686 If FULL-HEADERS (the prefix), include full headers when forwarding."
688 (gnus-summary-mail-forward full-headers t))
690 (defvar gnus-nastygram-message
691 "The following article was inappropriately posted to %s.\n\n"
692 "Format string to insert in nastygrams.
693 The current group name will be inserted at \"%s\".")
695 (defun gnus-summary-mail-nastygram (n)
696 "Send a nastygram to the author of the current article."
698 (when (or gnus-expert-user
700 "Really send a nastygram to the author of the current article? "))
701 (let ((group gnus-newsgroup-name))
702 (gnus-summary-reply-with-original n)
703 (set-buffer gnus-message-buffer)
705 (insert (format gnus-nastygram-message group))
706 (message-send-and-exit))))
708 (defun gnus-summary-mail-crosspost-complaint (n)
709 "Send a complaint about crossposting to the current article(s)."
711 (let ((articles (gnus-summary-work-articles n))
713 (while (setq article (pop articles))
714 (set-buffer gnus-summary-buffer)
715 (gnus-summary-goto-subject article)
716 (let ((group (gnus-group-real-name gnus-newsgroup-name))
717 newsgroups followup-to)
718 (gnus-summary-select-article)
719 (set-buffer gnus-original-article-buffer)
720 (if (and (<= (length (message-tokenize-header
722 (mail-fetch-field "newsgroups"))
725 (or (not (setq followup-to (mail-fetch-field "followup-to")))
726 (not (member group (message-tokenize-header
727 followup-to ", ")))))
729 (gnus-message 1 "Followup-to restricted")
730 (gnus-message 1 "Not a crossposted article"))
731 (set-buffer gnus-summary-buffer)
732 (gnus-summary-reply-with-original 1)
733 (set-buffer gnus-message-buffer)
735 (insert (format gnus-crosspost-complaint newsgroups group))
736 (message-goto-subject)
737 (re-search-forward " *$")
738 (replace-match " (crosspost notification)" t t)
739 (gnus-deactivate-mark)
740 (when (gnus-y-or-n-p "Send this complaint? ")
741 (message-send-and-exit)))))))
743 (defun gnus-summary-mail-other-window ()
744 "Compose mail in other window."
746 (gnus-setup-message 'message
749 (defun gnus-mail-parse-comma-list ()
752 (skip-chars-forward " ")
755 (skip-chars-forward "^,")
760 (narrow-to-region beg (point))
763 (while (search-forward "\"" nil t)
767 (skip-chars-forward ",")
768 (skip-chars-forward "^,"))
769 (skip-chars-backward " ")
770 (push (buffer-substring beg (point))
772 (skip-chars-forward "^,")
773 (skip-chars-forward ", "))
776 (defun gnus-inews-add-to-address (group)
777 (let ((to-address (mail-fetch-field "to")))
778 (when (and to-address
780 ;; This mail group doesn't have a `to-list', so we add one
783 (format "Do you want to add this as `to-list': %s " to-address))
784 (gnus-group-add-parameter group (cons 'to-list to-address))))))
786 (defun gnus-put-message ()
787 "Put the current message in some group and return to Gnus."
789 (let ((reply gnus-article-reply)
790 (winconf gnus-prev-winconf)
791 (group gnus-newsgroup-name))
793 (or (and group (not (gnus-group-read-only-p group)))
794 (setq group (read-string "Put in group: " nil
795 (gnus-writable-groups))))
796 (when (gnus-gethash group gnus-newsrc-hashtb)
797 (error "No such group: %s" group))
802 (message-narrow-to-headers)
803 (let (gnus-deletable-headers)
805 (message-generate-headers message-required-news-headers)
806 (message-generate-headers message-required-mail-headers)))
807 (goto-char (point-max))
808 (insert "Gcc: " group "\n")
813 (when (get-buffer gnus-group-buffer)
814 (when (gnus-buffer-exists-p (car-safe reply))
815 (set-buffer (car reply))
817 (gnus-summary-mark-article-as-replied
820 (set-window-configuration winconf)))))
822 (defun gnus-article-mail (yank)
823 "Send a reply to the address near point.
824 If YANK is non-nil, include the original article."
828 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
829 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
831 (message-reply address)
833 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
835 (defvar nntp-server-type)
837 "Send a bug report to the Gnus maintainers."
839 (unless (gnus-alive-p)
840 (error "Gnus has been shut down"))
841 (gnus-setup-message 'bug
842 (delete-other-windows)
843 (when gnus-bug-create-help-buffer
844 (switch-to-buffer "*Gnus Help Bug*")
846 (insert gnus-bug-message)
847 (goto-char (point-min)))
848 (message-pop-to-buffer "*Gnus Bug*")
850 `((To . ,semi-gnus-developers) (Subject . "")))
851 (when gnus-bug-create-help-buffer
852 (push `(gnus-bug-kill-buffer) message-send-actions))
853 (goto-char (point-min))
854 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
856 (insert (gnus-version) "\n"
857 (emacs-version) "\n")
858 (when (and (boundp 'nntp-server-type)
859 (stringp nntp-server-type))
860 (insert nntp-server-type))
861 (insert "\n\n\n\n\n")
862 (insert (mime-make-tag "text" "plane") "\n")
864 (insert (mime-make-tag "text" "plane") "\n")
865 (goto-char (point-min))
866 (search-forward "Subject: " nil t)
869 (defun gnus-bug-kill-buffer ()
870 (when (get-buffer "*Gnus Help Bug*")
871 (kill-buffer "*Gnus Help Bug*")))
873 (defun gnus-summary-yank-message (buffer n)
874 "Yank the current article into a composed message."
876 (list (completing-read "Buffer: " (mapcar 'list (message-buffers)) nil t)
878 (gnus-summary-iterate n
879 (let ((gnus-display-mime-function nil)
880 (gnus-inhibit-treatment t))
881 (gnus-summary-select-article))
884 (message-yank-buffer gnus-article-buffer))))
887 "Attempts to go through the Gnus source file and report what variables have been changed.
888 The source file has to be in the Emacs load path."
890 (let ((files '("gnus.el" "gnus-sum.el" "gnus-group.el"
891 "gnus-art.el" "gnus-start.el" "gnus-async.el"
892 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
893 "nnmail.el" "message.el"))
896 (gnus-message 4 "Please wait while we snoop your variables...")
898 ;; Go through all the files looking for non-default values for variables.
900 (set-buffer (gnus-get-buffer-create " *gnus bug info*"))
903 (when (and (setq file (locate-library (pop files)))
904 (file-exists-p file))
905 (insert-file-contents file)
906 (goto-char (point-min))
907 (if (not (re-search-forward "^;;* *Internal variables" nil t))
908 (gnus-message 4 "Malformed sources in file %s" file)
909 (narrow-to-region (point-min) (point))
910 (goto-char (point-min))
911 (while (setq expr (ignore-errors (read (current-buffer))))
913 (and (or (eq (car expr) 'defvar)
914 (eq (car expr) 'defcustom))
915 (stringp (nth 3 expr))
916 (or (not (boundp (nth 1 expr)))
917 (not (equal (eval (nth 2 expr))
918 (symbol-value (nth 1 expr)))))
919 (push (nth 1 expr) olist)))))))
920 (kill-buffer (current-buffer)))
921 (when (setq olist (nreverse olist))
922 (insert "------------------ Environment follows ------------------\n\n"))
924 (if (boundp (car olist))
926 (pp `(setq ,(car olist)
927 ,(if (or (consp (setq sym (symbol-value (car olist))))
929 (not (or (eq sym nil)
931 (list 'quote (symbol-value (car olist)))
932 (symbol-value (car olist))))
935 (format "(setq %s 'whatever)\n" (car olist))))
936 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
937 (setq olist (cdr olist)))
939 ;; Remove any control chars - they seem to cause trouble for some
940 ;; mailers. (Byte-compiled output from the stuff above.)
942 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
943 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
946 ;;; Treatment of rejected articles.
949 (defun gnus-summary-resend-bounced-mail (&optional fetch)
950 "Re-mail the current message.
951 This only makes sense if the current message is a bounce message than
952 contains some mail you have written which has been bounced back to
954 If FETCH, try to fetch the article that this is a reply to, if indeed
957 (gnus-summary-select-article t)
958 (set-buffer gnus-original-article-buffer)
959 (gnus-setup-message 'compose-bounce
960 (let* ((references (mail-fetch-field "references"))
961 (parent (and references (gnus-parent-id references))))
963 ;; If there are references, we fetch the article we answered to.
965 (gnus-summary-refer-article parent)
966 (gnus-summary-show-all-headers)))))
970 ;; Do Gcc handling, which copied the message over to some group.
971 (defun gnus-inews-do-gcc (&optional gcc)
976 (message-narrow-to-headers)
977 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
980 (message-remove-header "gcc")
982 (setq groups (message-tokenize-header gcc " ,"))
983 ;; Copy the article over to some group(s).
984 (while (setq group (pop groups))
987 (cond ((and (null (gnus-get-info group))
988 (eq (car gnus-message-archive-method)
990 (gnus-server-to-method
991 (gnus-group-method group)))))
992 ;; If the group doesn't exist, we assume
993 ;; it's an archive group...
994 gnus-message-archive-method)
996 ((gnus-info-method (gnus-get-info group))
997 (gnus-info-method (gnus-get-info group)))
999 (t (gnus-group-method group)))))
1000 (gnus-check-server method)
1001 (unless (gnus-request-group group t method)
1002 (gnus-request-create-group group method))
1004 (nnheader-set-temp-buffer " *acc*")
1005 (insert-buffer-substring message-encoding-buffer)
1006 (goto-char (point-min))
1007 (when (re-search-forward
1008 (concat "^" (regexp-quote mail-header-separator) "$")
1010 (replace-match "" t t ))
1011 (unless (gnus-request-accept-article group method t t)
1012 (gnus-message 1 "Couldn't store article in group %s: %s"
1013 group (gnus-status-message method))
1015 (kill-buffer (current-buffer))))))))))
1017 (defun gnus-inews-insert-gcc ()
1018 "Insert Gcc headers based on `gnus-outgoing-message-group'."
1021 (message-narrow-to-headers)
1022 (let* ((group gnus-outgoing-message-group)
1024 ((gnus-functionp group)
1026 ((or (stringp group) (list group))
1030 (if (stringp gcc) gcc
1031 (mapconcat 'identity gcc " "))
1034 (defun gnus-inews-insert-archive-gcc (&optional group)
1035 "Insert the Gcc to say where the article is to be archived."
1036 (let* ((var gnus-message-archive-group)
1037 (group (or group gnus-newsgroup-name ""))
1039 (and gnus-newsgroup-name
1040 (not (equal gnus-newsgroup-name ""))
1041 (gnus-group-find-parameter
1042 gnus-newsgroup-name 'gcc-self)))
1046 ((null gnus-message-archive-method)
1050 ;; Just a single group.
1053 ;; We don't want this.
1055 ((and (listp var) (stringp (car var)))
1056 ;; A list of groups.
1058 ((gnus-functionp var)
1060 (funcall var group))
1062 ;; An alist of regexps/functions/forms.
1067 ((stringp (caar var))
1069 (when (string-match (caar var) group)
1071 ((gnus-functionp (car var))
1073 (funcall (car var) group))
1075 (eval (car var)))))))
1076 (setq var (cdr var)))
1079 (when (or groups gcc-self-val)
1080 (when (stringp groups)
1081 (setq groups (list groups)))
1084 (message-narrow-to-headers)
1085 (goto-char (point-max))
1088 ;; Use the `gcc-self' param value instead.
1091 (if (stringp gcc-self-val)
1094 (if (not (eq gcc-self-val 'none))
1099 ;; Use the list of groups.
1100 (while (setq name (pop groups))
1101 (insert (if (string-match ":" name)
1103 (gnus-group-prefixed-name
1104 name gnus-message-archive-method)))
1111 (defun gnus-configure-posting-styles ()
1112 "Configure posting styles according to `gnus-posting-styles'."
1113 (unless gnus-inhibit-posting-styles
1114 (let ((group (or gnus-newsgroup-name ""))
1115 (styles gnus-posting-styles)
1116 style match variable attribute value v results
1117 filep name address element)
1118 ;; If the group has a posting-style parameter, add it at the end with a
1119 ;; regexp matching everything, to be sure it takes precedence over all
1121 (when gnus-newsgroup-name
1122 (let ((tmp-style (gnus-group-find-parameter group 'posting-style t)))
1124 (setq styles (append styles (list (cons ".*" tmp-style)))))))
1125 ;; Go through all styles and look for matches.
1126 (dolist (style styles)
1127 (setq match (pop style))
1128 (goto-char (point-min))
1131 ;; Regexp string match on the group name.
1132 (string-match match group))
1134 (let ((header (message-fetch-field (pop style))))
1136 (string-match (pop style) header))))
1137 ((or (symbolp match)
1138 (gnus-functionp match))
1140 ((gnus-functionp match)
1141 ;; Function to be called.
1144 ;; Variable to be checked.
1145 (symbol-value match))))
1147 ;; This is a form to be evaled.
1149 ;; We have a match, so we set the variables.
1150 (dolist (attribute style)
1151 (setq element (pop attribute)
1156 ((eq (car attribute) :file)
1159 ((eq (car attribute) :value)
1163 ;; We get the value.
1168 ((or (symbolp value)
1169 (gnus-functionp value))
1170 (cond ((gnus-functionp value)
1173 (symbol-value value))))
1176 ;; Translate obsolescent value.
1177 (when (eq element 'signature-file)
1178 (setq element 'signature
1180 ;; Get the contents of file elems.
1182 (setq v (with-temp-buffer
1183 (insert-file-contents v)
1185 (setq results (delq (assoc element results) results))
1186 (push (cons element v) results))))
1187 ;; Now we have all the styles, so we insert them.
1188 (setq name (assq 'name results)
1189 address (assq 'address results))
1190 (setq results (delq name (delq address results)))
1191 (make-local-variable 'message-setup-hook)
1192 (dolist (result results)
1193 (add-hook 'message-setup-hook
1195 ((eq 'eval (car result))
1197 ((eq 'body (car result))
1201 (insert ,(cdr result)))))
1202 ((eq 'signature (car result))
1203 (set (make-local-variable 'message-signature) nil)
1204 (set (make-local-variable 'message-signature-file) nil)
1205 (if (not (cdr result))
1209 (let ((message-signature ,(cdr result)))
1210 (when message-signature
1211 (message-insert-signature)))))))
1214 (if (symbolp (car result))
1215 (capitalize (symbol-name (car result)))
1219 (message-remove-header ,header)
1221 (insert ,header ": " ,(cdr result) "\n"))))))))
1222 (when (or name address)
1223 (add-hook 'message-setup-hook
1225 (set (make-local-variable 'user-mail-address)
1226 ,(or (cdr address) user-mail-address))
1227 (let ((user-full-name ,(or (cdr name) (user-full-name)))
1229 ,(or (cdr address) user-mail-address)))
1231 (message-remove-header "From")
1233 (insert "From: " (message-make-from) "\n")))))))))
1235 ;;; Allow redefinition of functions.
1241 ;;; gnus-msg.el ends here