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 and Emacs version."
197 gnus-product-name "/" gnus-version-number
199 (if (featurep 'xemacs)
202 (format " XEmacs/%d.%d%s" emacs-major-version emacs-minor-version
203 (if (and (boundp 'xemacs-betaname) xemacs-betaname)
204 (if (string-match "\\`(\\(.*\\))\\'" xemacs-betaname)
205 (match-string 1 xemacs-betaname)
208 (if (boundp 'xemacs-codename)
209 (concat " (" xemacs-codename ")")
214 (format " Emacs/%d.%d" emacs-major-version emacs-minor-version)
215 (if (and (boundp 'enable-multibyte-characters)
216 enable-multibyte-characters)
217 ;; Should return " (multibyte)" ?
223 (if (and (boundp 'mule-version) mule-version)
224 (concat " MULE/" mule-version)
225 " MULE") ; no mule-version
228 (if (featurep 'meadow)
229 (let ((version (Meadow-version)))
230 (if (string-match "\\`Meadow.\\([^ ]*\\)\\( (.*)\\)\\'" version)
232 (match-string 1 version)
233 (match-string 2 version)
235 "Meadow")) ; unknown format
239 (defvar gnus-article-reply nil)
240 (defmacro gnus-setup-message (config &rest forms)
241 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
242 (buffer (make-symbol "gnus-setup-message-buffer"))
243 (article (make-symbol "gnus-setup-message-article"))
244 (group (make-symbol "gnus-setup-message-group")))
245 `(let ((,winconf (current-window-configuration))
246 (,buffer (buffer-name (current-buffer)))
247 (,article (and gnus-article-reply (gnus-summary-article-number)))
248 (,group gnus-newsgroup-name)
249 (message-header-setup-hook
250 (copy-sequence message-header-setup-hook))
251 (message-mode-hook (copy-sequence message-mode-hook)))
252 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
253 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
254 (add-hook 'message-mode-hook 'gnus-configure-posting-styles)
255 (add-hook 'message-mode-hook
257 (setq message-user-agent (gnus-extended-version))))
261 (gnus-inews-add-send-actions ,winconf ,buffer ,article)
262 (setq gnus-message-buffer (current-buffer))
263 (set (make-local-variable 'gnus-message-group-art)
264 (cons ,group ,article))
265 (make-local-variable 'gnus-newsgroup-name)
266 (gnus-run-hooks 'gnus-message-setup-hook))
268 (gnus-configure-windows ,config t)
269 (set-buffer-modified-p nil))))
271 (defun gnus-inews-add-send-actions (winconf buffer article)
272 (make-local-hook 'message-sent-hook)
273 (add-hook 'message-sent-hook 'gnus-inews-do-gcc nil t)
274 (setq message-post-method
276 (gnus-post-method arg ,gnus-newsgroup-name)))
278 `(set-window-configuration ,winconf) 'exit 'postpone 'kill)
280 `(when (gnus-buffer-exists-p ,buffer)
284 `(gnus-summary-mark-article-as-replied ,article))))
287 (put 'gnus-setup-message 'lisp-indent-function 1)
288 (put 'gnus-setup-message 'edebug-form-spec '(form body))
290 ;;; Post news commands of Gnus group mode and summary mode
292 (defun gnus-group-mail ()
293 "Start composing a mail."
295 (gnus-setup-message 'message
298 (defun gnus-group-post-news (&optional arg)
299 "Start composing a news message.
300 If ARG, post to the group under point.
301 If ARG is 1, prompt for a group name."
303 ;; Bind this variable here to make message mode hooks work ok.
304 (let ((gnus-newsgroup-name
306 (if (= 1 (prefix-numeric-value arg))
307 (completing-read "Newsgroup: " gnus-active-hashtb nil
308 (gnus-read-active-file-p))
309 (gnus-group-group-name))
311 (gnus-post-news 'post gnus-newsgroup-name)))
313 (defun gnus-summary-post-news ()
314 "Start composing a news message."
316 (gnus-post-news 'post gnus-newsgroup-name))
318 (defun gnus-summary-followup (yank &optional force-news)
319 "Compose a followup to an article.
320 If prefix argument YANK is non-nil, original article is yanked automatically."
322 (list (and current-prefix-arg
323 (gnus-summary-work-articles 1))))
325 (gnus-summary-goto-subject (car yank)))
326 (save-window-excursion
327 (gnus-summary-select-article))
328 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
329 (gnus-newsgroup-name gnus-newsgroup-name))
331 (gnus-post-news nil gnus-newsgroup-name
332 headers gnus-article-buffer
333 yank nil force-news)))
335 (defun gnus-summary-followup-with-original (n &optional force-news)
336 "Compose a followup to an article and include the original article."
338 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
340 (defun gnus-summary-followup-to-mail (&optional arg)
341 "Followup to the current mail message via news."
343 (list (and current-prefix-arg
344 (gnus-summary-work-articles 1))))
345 (gnus-summary-followup arg t))
347 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
348 "Followup to the current mail message via news."
350 (gnus-summary-followup (gnus-summary-work-articles arg) t))
352 (defun gnus-inews-yank-articles (articles)
355 (while (setq article (pop articles))
356 (save-window-excursion
357 (set-buffer gnus-summary-buffer)
358 (gnus-summary-select-article nil nil nil article)
359 (gnus-summary-remove-process-mark article))
360 (gnus-copy-article-buffer)
361 (let ((message-reply-buffer gnus-article-copy)
362 (message-reply-headers gnus-current-headers))
363 (message-yank-original)
364 (setq beg (or beg (mark t))))
370 (defun gnus-summary-cancel-article (&optional n symp)
371 "Cancel an article you posted.
372 Uses the process-prefix convention. If given the symbolic
373 prefix `a', cancel using the standard posting method; if not
374 post using the current select method."
375 (interactive (gnus-interactive "P\ny"))
376 (let ((articles (gnus-summary-work-articles n))
379 (gnus-post-method (not (eq symp 'a)) ,gnus-newsgroup-name)))
381 (while (setq article (pop articles))
382 (when (gnus-summary-select-article t nil nil article)
383 (when (gnus-eval-in-buffer-window gnus-article-buffer
385 (set-buffer gnus-original-article-buffer)
386 (message-cancel-news)))
387 (gnus-summary-mark-as-read article gnus-canceled-mark)
388 (gnus-cache-remove-article 1))
389 (gnus-article-hide-headers-if-wanted))
390 (gnus-summary-remove-process-mark article))))
392 (defun gnus-summary-supersede-article ()
393 "Compose an article that will supersede a previous article.
394 This is done simply by taking the old article and adding a Supersedes
395 header line with the old Message-ID."
397 (let ((article (gnus-summary-article-number)))
398 (gnus-setup-message 'reply-yank
399 (gnus-summary-select-article t)
400 (set-buffer gnus-original-article-buffer)
404 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
406 (set-buffer ,gnus-summary-buffer)
407 (gnus-cache-possibly-remove-article ,article nil nil nil t)
408 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
409 message-send-actions))))
413 (defun gnus-copy-article-buffer (&optional article-buffer)
414 ;; make a copy of the article buffer with all text properties removed
415 ;; this copy is in the buffer gnus-article-copy.
416 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
417 ;; this buffer should be passed to all mail/news reply/post routines.
418 (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
419 (buffer-disable-undo gnus-article-copy)
420 (let ((article-buffer (or article-buffer gnus-article-buffer))
422 (if (not (and (get-buffer article-buffer)
423 (gnus-buffer-exists-p article-buffer)))
424 (error "Can't find any article buffer")
426 (set-buffer article-buffer)
428 ;; Copy over the (displayed) article buffer, delete
429 ;; hidden text and remove text properties.
431 (copy-to-buffer gnus-article-copy (point-min) (point-max))
432 (set-buffer gnus-article-copy)
433 (gnus-article-delete-text-of-type 'annotation)
434 (gnus-remove-text-with-property 'gnus-prev)
435 (gnus-remove-text-with-property 'gnus-next)
438 (format "%s" (buffer-string))
440 ;; Find the original headers.
441 (set-buffer gnus-original-article-buffer)
442 (goto-char (point-min))
443 (while (looking-at message-unix-mail-delimiter)
446 (setq end (or (search-forward "\n\n" nil t) (point)))
447 ;; Delete the headers from the displayed articles.
448 (set-buffer gnus-article-copy)
449 (delete-region (goto-char (point-min))
450 (or (search-forward "\n\n" nil t) (point)))
451 ;; Insert the original article headers.
452 (insert-buffer-substring gnus-original-article-buffer beg end)
453 (gnus-article-decode-rfc1522)))
456 (defun gnus-post-news (post &optional group header article-buffer yank subject
459 (gnus-copy-article-buffer))
460 (let ((gnus-article-reply article-buffer)
461 (add-to-list gnus-add-to-list))
462 (gnus-setup-message (cond (yank 'reply-yank)
463 (article-buffer 'reply)
465 (let* ((group (or group gnus-newsgroup-name))
467 to-address to-group mailing-list to-list
470 (setq to-address (gnus-group-find-parameter group 'to-address)
471 to-group (gnus-group-find-parameter group 'to-group)
472 to-list (gnus-group-find-parameter group 'to-list)
473 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
474 mailing-list (when gnus-mailing-list-groups
475 (string-match gnus-mailing-list-groups group))
476 group (gnus-group-real-name group)))
477 (if (or (and to-group
478 (gnus-news-group-p to-group))
481 (and (gnus-news-group-p
482 (or pgroup gnus-newsgroup-name)
483 (if header (mail-header-number header)
484 gnus-current-article))
490 (message-news (or to-group group))
491 (set-buffer gnus-article-copy)
492 (gnus-msg-treat-broken-reply-to)
493 (message-followup (if (or newsgroup-p force-news) nil to-group)))
497 (message-mail (or to-address to-list))
498 ;; Arrange for mail groups that have no `to-address' to
499 ;; get that when the user sends off the mail.
500 (when (and (not to-list)
503 (push (list 'gnus-inews-add-to-address pgroup)
504 message-send-actions)))
505 (set-buffer gnus-article-copy)
506 (gnus-msg-treat-broken-reply-to)
507 (message-wide-reply to-address)))
509 (gnus-inews-yank-articles yank))))))
511 (defun gnus-msg-treat-broken-reply-to ()
512 "Remove the Reply-to header iff broken-reply-to."
513 (when (gnus-group-find-parameter
514 gnus-newsgroup-name 'broken-reply-to)
516 (message-narrow-to-head)
517 (message-remove-header "reply-to"))))
519 (defun gnus-post-method (arg group &optional silent)
520 "Return the posting method based on GROUP and ARG.
521 If SILENT, don't prompt the user."
522 (let ((group-method (gnus-find-method-for-group group)))
524 ;; If the group-method is nil (which shouldn't happen) we use
525 ;; the default method.
527 (or (and (null (eq gnus-post-method 'active)) gnus-post-method)
528 gnus-select-method message-post-method))
529 ;; We want the inverse of the default
530 ((and arg (not (eq arg 0)))
531 (if (eq gnus-post-method 'active)
534 ;; We query the user for a post method.
536 (and gnus-post-method
537 (not (eq gnus-post-method 'current))
538 (listp (car gnus-post-method))))
540 ;; Collect all methods we know about.
542 (when (and gnus-post-method
543 (not (eq gnus-post-method 'current)))
544 (if (listp (car gnus-post-method))
546 (list gnus-post-method)))
547 gnus-secondary-select-methods
548 (mapcar 'cdr gnus-server-alist)
549 (list gnus-select-method)
550 (list group-method)))
551 method-alist post-methods method)
552 ;; Weed out all mail methods.
554 (setq method (gnus-server-get-method "" (pop methods)))
555 (when (or (gnus-method-option-p method 'post)
556 (gnus-method-option-p method 'post-mail))
557 (push method post-methods)))
558 ;; Create a name-method alist.
562 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m))
567 (setq gnus-last-posting-server
569 gnus-last-posting-server)
570 ;; Just use the last value.
571 gnus-last-posting-server
573 "Posting method: " method-alist nil t
574 (cons (or gnus-last-posting-server "") 0))))
576 ;; Override normal method.
577 ((and (eq gnus-post-method 'current)
578 (not (eq (car group-method) 'nndraft))
581 ((and gnus-post-method
582 (not (eq gnus-post-method 'current)))
584 ;; Use the normal select method.
585 (t gnus-select-method))))
589 ;;; Gnus Mail Functions
592 ;;; Mail reply commands of Gnus summary mode
594 (defun gnus-summary-reply (&optional yank wide)
595 "Start composing a reply mail to the current message.
596 If prefix argument YANK is non-nil, the original article is yanked
599 (list (and current-prefix-arg
600 (gnus-summary-work-articles 1))))
601 ;; Stripping headers should be specified with mail-yank-ignored-headers.
603 (gnus-summary-goto-subject (car yank)))
604 (let ((gnus-article-reply t)
605 (gnus-inhibit-posting-styles t))
606 (gnus-setup-message (if yank 'reply-yank 'reply)
607 (gnus-summary-select-article)
608 (set-buffer (gnus-copy-article-buffer))
609 (gnus-msg-treat-broken-reply-to)
610 (message-reply nil wide)
612 (gnus-inews-yank-articles yank)))))
614 (defun gnus-summary-reply-with-original (n &optional wide)
615 "Start composing a reply mail to the current message.
616 The original article will be yanked."
618 (gnus-summary-reply (gnus-summary-work-articles n) wide))
620 (defun gnus-summary-wide-reply (&optional yank)
621 "Start composing a wide reply mail to the current message.
622 If prefix argument YANK is non-nil, the original article is yanked
625 (list (and current-prefix-arg
626 (gnus-summary-work-articles 1))))
627 (gnus-summary-reply yank t))
629 (defun gnus-summary-wide-reply-with-original (n)
630 "Start composing a wide reply mail to the current message.
631 The original article will be yanked."
633 (gnus-summary-reply-with-original n t))
635 (defun gnus-summary-mail-forward (&optional full-headers post)
636 "Forward the current message to another user.
637 If FULL-HEADERS (the prefix), include full headers when forwarding."
639 (gnus-setup-message 'forward
640 (gnus-summary-select-article)
641 (let ((charset default-mime-charset))
642 (set-buffer gnus-original-article-buffer)
643 (make-local-variable 'default-mime-charset)
644 (setq default-mime-charset charset)
646 (let ((message-included-forward-headers
647 (if full-headers "" message-included-forward-headers)))
648 (message-forward post))))
650 (defun gnus-summary-post-forward (&optional full-headers)
651 "Forward the current article to a newsgroup.
652 If FULL-HEADERS (the prefix), include full headers when forwarding."
654 (gnus-summary-mail-forward full-headers t))
656 ;;; XXX: generate Subject and ``Topics''?
657 (defun gnus-summary-mail-digest (&optional n post)
658 "Digests and forwards all articles in this series."
660 (let ((subject "Digested Articles")
661 (articles (gnus-summary-work-articles n))
663 (gnus-setup-message 'forward
664 (gnus-summary-select-article)
665 (if post (message-news nil subject) (message-mail nil subject))
667 (while (setq article (pop articles))
668 (save-window-excursion
669 (set-buffer gnus-summary-buffer)
670 (gnus-summary-select-article nil nil nil article)
671 (gnus-summary-remove-process-mark article))
672 (insert (mime-make-tag "message" "rfc822") "\n")
673 (insert-buffer-substring gnus-original-article-buffer))
676 (mime-edit-enclose-digest-region (point)(mark t)))))
678 (defun gnus-summary-post-digest (&optional n)
679 "Digest and forwards all articles in this series to a newsgroup."
681 (gnus-summary-mail-digest n t))
683 (defun gnus-summary-resend-message (address n)
684 "Resend the current article to ADDRESS."
685 (interactive "sResend message(s) to: \nP")
686 (let ((articles (gnus-summary-work-articles n))
688 (while (setq article (pop articles))
689 (gnus-summary-select-article nil nil nil article)
691 (set-buffer gnus-original-article-buffer)
692 (message-resend address)))))
694 (defvar gnus-nastygram-message
695 "The following article was inappropriately posted to %s.\n\n"
696 "Format string to insert in nastygrams.
697 The current group name will be inserted at \"%s\".")
699 (defun gnus-summary-mail-nastygram (n)
700 "Send a nastygram to the author of the current article."
702 (when (or gnus-expert-user
704 "Really send a nastygram to the author of the current article? "))
705 (let ((group gnus-newsgroup-name))
706 (gnus-summary-reply-with-original n)
707 (set-buffer gnus-message-buffer)
709 (insert (format gnus-nastygram-message group))
710 (message-send-and-exit))))
712 (defun gnus-summary-mail-crosspost-complaint (n)
713 "Send a complaint about crossposting to the current article(s)."
715 (let ((articles (gnus-summary-work-articles n))
717 (while (setq article (pop articles))
718 (set-buffer gnus-summary-buffer)
719 (gnus-summary-goto-subject article)
720 (let ((group (gnus-group-real-name gnus-newsgroup-name))
721 newsgroups followup-to)
722 (gnus-summary-select-article)
723 (set-buffer gnus-original-article-buffer)
724 (if (and (<= (length (message-tokenize-header
725 (setq newsgroups (mail-fetch-field "newsgroups"))
728 (or (not (setq followup-to (mail-fetch-field "followup-to")))
729 (not (member group (message-tokenize-header
730 followup-to ", ")))))
732 (gnus-message 1 "Followup-to restricted")
733 (gnus-message 1 "Not a crossposted article"))
734 (set-buffer gnus-summary-buffer)
735 (gnus-summary-reply-with-original 1)
736 (set-buffer gnus-message-buffer)
738 (insert (format gnus-crosspost-complaint newsgroups group))
739 (message-goto-subject)
740 (re-search-forward " *$")
741 (replace-match " (crosspost notification)" t t)
742 (gnus-deactivate-mark)
743 (when (gnus-y-or-n-p "Send this complaint? ")
744 (message-send-and-exit)))))))
746 (defun gnus-summary-mail-other-window ()
747 "Compose mail in other window."
749 (gnus-setup-message 'message
752 (defun gnus-mail-parse-comma-list ()
755 (skip-chars-forward " ")
758 (skip-chars-forward "^,")
763 (narrow-to-region beg (point))
766 (while (search-forward "\"" nil t)
770 (skip-chars-forward ",")
771 (skip-chars-forward "^,"))
772 (skip-chars-backward " ")
773 (push (buffer-substring beg (point))
775 (skip-chars-forward "^,")
776 (skip-chars-forward ", "))
779 (defun gnus-inews-add-to-address (group)
780 (let ((to-address (mail-fetch-field "to")))
781 (when (and to-address
783 ;; This mail group doesn't have a `to-list', so we add one
786 (format "Do you want to add this as `to-list': %s " to-address))
787 (gnus-group-add-parameter group (cons 'to-list to-address))))))
789 (defun gnus-put-message ()
790 "Put the current message in some group and return to Gnus."
792 (let ((reply gnus-article-reply)
793 (winconf gnus-prev-winconf)
794 (group gnus-newsgroup-name))
796 (or (and group (not (gnus-group-read-only-p group)))
797 (setq group (read-string "Put in group: " nil
798 (gnus-writable-groups))))
799 (when (gnus-gethash group gnus-newsrc-hashtb)
800 (error "No such group: %s" group))
805 (message-narrow-to-headers)
806 (let (gnus-deletable-headers)
808 (message-generate-headers message-required-news-headers)
809 (message-generate-headers message-required-mail-headers)))
810 (goto-char (point-max))
811 (insert "Gcc: " group "\n")
816 (when (get-buffer gnus-group-buffer)
817 (when (gnus-buffer-exists-p (car-safe reply))
818 (set-buffer (car reply))
820 (gnus-summary-mark-article-as-replied
823 (set-window-configuration winconf)))))
825 (defun gnus-article-mail (yank)
826 "Send a reply to the address near point.
827 If YANK is non-nil, include the original article."
831 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
832 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
834 (message-reply address)
836 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
838 (defvar nntp-server-type)
840 "Send a bug report to the Gnus maintainers."
842 (unless (gnus-alive-p)
843 (error "Gnus has been shut down"))
844 (gnus-setup-message 'bug
845 (delete-other-windows)
846 (when gnus-bug-create-help-buffer
847 (switch-to-buffer "*Gnus Help Bug*")
849 (insert gnus-bug-message)
850 (goto-char (point-min)))
851 (message-pop-to-buffer "*Gnus Bug*")
853 `((To . ,gnus-maintainer) (Cc . ,semi-gnus-developers) (Subject . "")))
854 (when gnus-bug-create-help-buffer
855 (push `(gnus-bug-kill-buffer) message-send-actions))
856 (goto-char (point-min))
857 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
859 (insert (gnus-version) "\n"
860 (emacs-version) "\n")
861 (when (and (boundp 'nntp-server-type)
862 (stringp nntp-server-type))
863 (insert nntp-server-type))
864 (insert "\n\n\n\n\n")
866 (goto-char (point-min))
867 (search-forward "Subject: " nil t)
870 (defun gnus-bug-kill-buffer ()
871 (when (get-buffer "*Gnus Help Bug*")
872 (kill-buffer "*Gnus Help Bug*")))
875 "Attempts to go through the Gnus source file and report what variables have been changed.
876 The source file has to be in the Emacs load path."
878 (let ((files '("gnus.el" "gnus-sum.el" "gnus-group.el"
879 "gnus-art.el" "gnus-start.el" "gnus-async.el"
880 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
881 "nnmail.el" "message.el"))
884 (gnus-message 4 "Please wait while we snoop your variables...")
886 ;; Go through all the files looking for non-default values for variables.
888 (set-buffer (gnus-get-buffer-create " *gnus bug info*"))
889 (buffer-disable-undo (current-buffer))
892 (when (and (setq file (locate-library (pop files)))
893 (file-exists-p file))
894 (insert-file-contents file)
895 (goto-char (point-min))
896 (if (not (re-search-forward "^;;* *Internal variables" nil t))
897 (gnus-message 4 "Malformed sources in file %s" file)
898 (narrow-to-region (point-min) (point))
899 (goto-char (point-min))
900 (while (setq expr (ignore-errors (read (current-buffer))))
902 (and (or (eq (car expr) 'defvar)
903 (eq (car expr) 'defcustom))
904 (stringp (nth 3 expr))
905 (or (not (boundp (nth 1 expr)))
906 (not (equal (eval (nth 2 expr))
907 (symbol-value (nth 1 expr)))))
908 (push (nth 1 expr) olist)))))))
909 (kill-buffer (current-buffer)))
910 (when (setq olist (nreverse olist))
911 (insert "------------------ Environment follows ------------------\n\n"))
913 (if (boundp (car olist))
915 (pp `(setq ,(car olist)
916 ,(if (or (consp (setq sym (symbol-value (car olist))))
918 (not (or (eq sym nil)
920 (list 'quote (symbol-value (car olist)))
921 (symbol-value (car olist))))
924 (format "(setq %s 'whatever)\n" (car olist))))
925 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
926 (setq olist (cdr olist)))
928 ;; Remove any control chars - they seem to cause trouble for some
929 ;; mailers. (Byte-compiled output from the stuff above.)
931 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
932 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
935 ;;; Treatment of rejected articles.
938 (defun gnus-summary-resend-bounced-mail (&optional fetch)
939 "Re-mail the current message.
940 This only makes sense if the current message is a bounce message than
941 contains some mail you have written which has been bounced back to
943 If FETCH, try to fetch the article that this is a reply to, if indeed
946 (gnus-summary-select-article t)
947 (set-buffer gnus-original-article-buffer)
948 (gnus-setup-message 'compose-bounce
949 (let* ((references (mail-fetch-field "references"))
950 (parent (and references (gnus-parent-id references))))
952 ;; If there are references, we fetch the article we answered to.
954 (gnus-summary-refer-article parent)
955 (gnus-summary-show-all-headers)))))
959 ;; Do Gcc handling, which copied the message over to some group.
960 (defun gnus-inews-do-gcc (&optional gcc)
965 (message-narrow-to-headers)
966 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
967 (coding-system-for-write 'raw-text)
970 (message-remove-header "gcc")
972 (setq groups (message-tokenize-header gcc " ,"))
973 ;; Copy the article over to some group(s).
974 (while (setq group (pop groups))
977 (cond ((and (null (gnus-get-info group))
978 (eq (car gnus-message-archive-method)
980 (gnus-server-to-method
981 (gnus-group-method group)))))
982 ;; If the group doesn't exist, we assume
983 ;; it's an archive group...
984 gnus-message-archive-method)
986 ((gnus-info-method (gnus-get-info group))
987 (gnus-info-method (gnus-get-info group)))
989 (t (gnus-group-method group)))))
990 (gnus-check-server method)
991 (unless (gnus-request-group group t method)
992 (gnus-request-create-group group method))
994 (nnheader-set-temp-buffer " *acc*")
995 (insert-buffer-substring message-encoding-buffer)
996 (gnus-run-hooks 'gnus-before-do-gcc-hook)
997 (goto-char (point-min))
998 (when (re-search-forward
999 (concat "^" (regexp-quote mail-header-separator) "$")
1001 (replace-match "" t t ))
1002 (unless (gnus-request-accept-article group method t)
1003 (gnus-message 1 "Couldn't store article in group %s: %s"
1004 group (gnus-status-message method))
1006 (kill-buffer (current-buffer))))))))))
1008 (defun gnus-inews-insert-gcc ()
1009 "Insert Gcc headers based on `gnus-outgoing-message-group'."
1012 (message-narrow-to-headers)
1013 (let* ((group gnus-outgoing-message-group)
1015 ((gnus-functionp group)
1017 ((or (stringp group) (list group))
1021 (if (stringp gcc) gcc
1022 (mapconcat 'identity gcc " "))
1025 (defun gnus-inews-insert-archive-gcc (&optional group)
1026 "Insert the Gcc to say where the article is to be archived."
1027 (let* ((var gnus-message-archive-group)
1028 (group (or group gnus-newsgroup-name ""))
1030 (and gnus-newsgroup-name
1031 (gnus-group-find-parameter
1032 gnus-newsgroup-name 'gcc-self)))
1036 ((null gnus-message-archive-method)
1040 ;; Just a single group.
1043 ;; We don't want this.
1045 ((and (listp var) (stringp (car var)))
1046 ;; A list of groups.
1048 ((gnus-functionp var)
1050 (funcall var group))
1052 ;; An alist of regexps/functions/forms.
1057 ((stringp (caar var))
1059 (when (string-match (caar var) group)
1061 ((gnus-functionp (car var))
1063 (funcall (car var) group))
1065 (eval (car var)))))))
1066 (setq var (cdr var)))
1069 (when (or groups gcc-self-val)
1070 (when (stringp groups)
1071 (setq groups (list groups)))
1074 (message-narrow-to-headers)
1075 (goto-char (point-max))
1078 ;; Use the `gcc-self' param value instead.
1081 (if (stringp gcc-self-val)
1084 (if (not (eq gcc-self-val 'none))
1089 ;; Use the list of groups.
1090 (while (setq name (pop groups))
1091 (insert (if (string-match ":" name)
1093 (gnus-group-prefixed-name
1094 name gnus-message-archive-method)))
1101 (defvar gnus-message-style-insertions nil)
1103 (defun gnus-configure-posting-styles ()
1104 "Configure posting styles according to `gnus-posting-styles'."
1105 (unless gnus-inhibit-posting-styles
1106 (let ((styles gnus-posting-styles)
1107 (gnus-newsgroup-name (or gnus-newsgroup-name ""))
1108 style match variable attribute value value-value)
1109 (make-local-variable 'gnus-message-style-insertions)
1110 ;; Go through all styles and look for matches.
1112 (setq style (pop styles)
1114 (when (cond ((stringp match)
1115 ;; Regexp string match on the group name.
1116 (string-match match gnus-newsgroup-name))
1117 ((or (symbolp match)
1118 (gnus-functionp match))
1119 (cond ((gnus-functionp match)
1120 ;; Function to be called.
1123 ;; Variable to be checked.
1124 (symbol-value match))))
1126 ;; This is a form to be evaled.
1128 ;; We have a match, so we set the variables.
1130 (setq attribute (pop style)
1131 value (cadr attribute)
1133 ;; We find the variable that is to be modified.
1134 (if (and (not (stringp (car attribute)))
1135 (not (eq 'body (car attribute)))
1137 (cdr (assq (car attribute)
1138 gnus-posting-style-alist)))))
1139 (message "Couldn't find attribute %s" (car attribute))
1140 ;; We get the value.
1142 (cond ((stringp value)
1144 ((or (symbolp value)
1145 (gnus-functionp value))
1146 (cond ((gnus-functionp value)
1149 (symbol-value value))))
1153 ;; This is an ordinary variable.
1154 (set (make-local-variable variable) value-value)
1155 ;; This is either a body or a header to be inserted in the
1158 (let ((attr (car attribute)))
1159 (make-local-variable 'message-setup-hook)
1161 (add-hook 'message-setup-hook
1165 (insert ,value-value))))
1166 (add-hook 'message-setup-hook
1167 'gnus-message-insert-stylings)
1168 (push (cons (if (stringp attr) attr
1171 gnus-message-style-insertions))))))))))))
1173 (defun gnus-message-insert-stylings ()
1177 (while (setq val (pop gnus-message-style-insertions))
1179 (insert (car val) ": " (cdr val) "\n"))
1180 (gnus-pull (car val) gnus-message-style-insertions)))))
1182 ;;; Allow redefinition of functions.
1188 ;;; gnus-msg.el ends here