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 ;; Katsumi Yamaoka <yamaoka@jpl.org>
9 ;; Kiyokazu SUTO <suto@merry.xmath.ous.ac.jp>
10 ;; Keywords: mail, news, MIME
12 ;; This file is part of GNU Emacs.
14 ;; GNU Emacs is free software; you can redistribute it and/or modify
15 ;; it under the terms of the GNU General Public License as published by
16 ;; the Free Software Foundation; either version 2, or (at your option)
19 ;; GNU Emacs is distributed in the hope that it will be useful,
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;; GNU General Public License for more details.
24 ;; You should have received a copy of the GNU General Public License
25 ;; along with GNU Emacs; see the file COPYING. If not, write to the
26 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
27 ;; Boston, MA 02111-1307, USA.
33 (eval-when-compile (require 'cl))
40 (defcustom gnus-post-method nil
41 "*Preferred method for posting USENET news.
43 If this variable is `current', Gnus will use the \"current\" select
44 method when posting. If it is nil (which is the default), Gnus will
45 use the native posting method of the server.
47 This method will not be used in mail groups and the like, only in
50 If not nil nor `native', the value must be a valid method as discussed
51 in the documentation of `gnus-select-method'. It can also be a list of
52 methods. If that is the case, the user will be queried for what select
53 method to use when posting."
54 :group 'gnus-group-foreign
55 :type `(choice (const nil)
58 (sexp :tag "Methods" ,gnus-select-method)))
60 (defvar gnus-outgoing-message-group nil
61 "*All outgoing messages will be put in this group.
62 If you want to store all your outgoing mail and articles in the group
63 \"nnml:archive\", you set this variable to that value. This variable
64 can also be a list of group names.
66 If you want to have greater control over what group to put each
67 message in, you can set this variable to a function that checks the
68 current newsgroup name and then returns a suitable group name (or list
71 (defvar gnus-mailing-list-groups nil
72 "*Regexp matching groups that are really mailing lists.
73 This is useful when you're reading a mailing list that has been
74 gatewayed to a newsgroup, and you want to followup to an article in
77 (defvar gnus-add-to-list nil
78 "*If non-nil, add a `to-list' parameter automatically.")
80 (defvar gnus-crosspost-complaint
83 You posted the article below with the following Newsgroups header:
87 The %s group, at least, was an inappropriate recipient
88 of this message. Please trim your Newsgroups header to exclude this
89 group before posting in the future.
94 "Format string to be inserted when complaining about crossposts.
95 The first %s will be replaced by the Newsgroups header;
96 the second with the current group name.")
98 (defvar gnus-message-setup-hook '(gnus-maybe-setup-default-charset)
99 "Hook run after setting up a message buffer.")
101 (defvar gnus-bug-create-help-buffer t
102 "*Should we create the *Gnus Help Bug* buffer?")
104 (defvar gnus-posting-styles nil
105 "*Alist of styles to use when posting.")
107 (defvar gnus-posting-style-alist
108 '((organization . message-user-organization)
109 (signature . message-signature)
110 (signature-file . message-signature-file)
111 (address . user-mail-address)
112 (name . user-full-name))
113 "*Mapping from style parameters to variables.")
115 ;;; Internal variables.
117 (defvar gnus-inhibit-posting-styles nil
118 "Inhibit the use of posting styles.")
120 (defvar gnus-message-buffer "*Mail Gnus*")
121 (defvar gnus-article-copy nil)
122 (defvar gnus-last-posting-server nil)
123 (defvar gnus-message-group-art nil)
125 (defconst gnus-bug-message
126 (format "Sending a bug report to the Gnus Towers.
127 ========================================
129 This gnus is the %s%s.
130 If you think the bug is a Semi-gnus bug, send a bug report to Semi-gnus
131 Developers. (the addresses below are mailing list addresses)
133 ========================================
135 The buffer below is a mail buffer. When you press `C-c C-c', it will
136 be sent to the Gnus Bug Exterminators.
138 At the bottom of the buffer you'll see lots of variable settings.
139 Please do not delete those. They will tell the Bug People what your
140 environment is, so that it will be easier to locate the bugs.
142 If you have found a bug that makes Emacs go \"beep\", set
143 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
144 and include the backtrace in your bug report.
146 Please describe the bug in annoying, painstaking detail.
148 Thank you for your help in stamping out bugs.
151 (if (string= gnus-product-name "Semi-gnus")
153 ", a modified version of Semi-gnus")))
156 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
157 (autoload 'news-setup "rnewspost")
158 (autoload 'news-reply-mode "rnewspost")
159 (autoload 'rmail-dont-reply-to "mail-utils")
160 (autoload 'rmail-output "rmailout"))
164 ;;; Gnus Posting Functions
167 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
168 "p" gnus-summary-post-news
169 "f" gnus-summary-followup
170 "F" gnus-summary-followup-with-original
171 "c" gnus-summary-cancel-article
172 "s" gnus-summary-supersede-article
173 "r" gnus-summary-reply
174 "R" gnus-summary-reply-with-original
175 "w" gnus-summary-wide-reply
176 "W" gnus-summary-wide-reply-with-original
177 "n" gnus-summary-followup-to-mail
178 "N" gnus-summary-followup-to-mail-with-original
179 "m" gnus-summary-mail-other-window
180 "u" gnus-uu-post-news
181 "\M-c" gnus-summary-mail-crosspost-complaint
182 "om" gnus-summary-mail-forward
183 "op" gnus-summary-post-forward
184 "Om" gnus-summary-mail-digest
185 "Op" gnus-summary-post-digest)
187 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
188 "b" gnus-summary-resend-bounced-mail
189 ;; "c" gnus-summary-send-draft
190 "r" gnus-summary-resend-message)
192 ;;; Internal functions.
194 (defvar gnus-article-reply nil)
195 (defmacro gnus-setup-message (config &rest forms)
196 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
197 (buffer (make-symbol "gnus-setup-message-buffer"))
198 (article (make-symbol "gnus-setup-message-article"))
199 (group (make-symbol "gnus-setup-message-group")))
200 `(let ((,winconf (current-window-configuration))
201 (,buffer (buffer-name (current-buffer)))
202 (,article (and gnus-article-reply (gnus-summary-article-number)))
203 (,group gnus-newsgroup-name)
204 (message-header-setup-hook
205 (copy-sequence message-header-setup-hook))
206 (message-mode-hook (copy-sequence message-mode-hook))
207 (message-startup-parameter-alist
208 '((reply-buffer . gnus-copy-article-buffer)
209 (original-buffer . gnus-original-article-buffer)
210 (user-agent . Gnus))))
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)
217 (gnus-inews-add-send-actions ,winconf ,buffer ,article)
218 (setq gnus-message-buffer (current-buffer))
219 (set (make-local-variable 'gnus-message-group-art)
220 (cons ,group ,article))
221 (make-local-variable 'gnus-newsgroup-name)
222 (gnus-run-hooks 'gnus-message-setup-hook))
224 (gnus-configure-windows ,config t)
225 (set-buffer-modified-p nil))))
227 (defun gnus-inews-add-send-actions (winconf buffer article)
228 (make-local-hook 'message-sent-hook)
229 (add-hook 'message-sent-hook 'gnus-inews-do-gcc nil t)
230 (setq message-post-method
232 (gnus-post-method arg ,gnus-newsgroup-name)))
233 (setq message-user-agent (gnus-extended-version))
234 (when (not message-use-multi-frames)
236 `(set-window-configuration ,winconf) 'exit 'postpone 'kill))
238 `(when (gnus-buffer-exists-p ,buffer)
242 `(gnus-summary-mark-article-as-replied ,article))))
245 (put 'gnus-setup-message 'lisp-indent-function 1)
246 (put 'gnus-setup-message 'edebug-form-spec '(form body))
248 ;;; Post news commands of Gnus group mode and summary mode
250 (defun gnus-group-mail ()
251 "Start composing a mail."
253 (gnus-setup-message 'message
256 (defun gnus-group-post-news (&optional arg)
257 "Start composing a news message.
258 If ARG, post to the group under point.
259 If ARG is 1, prompt for a group name."
261 ;; Bind this variable here to make message mode hooks work ok.
262 (let ((gnus-newsgroup-name
264 (if (= 1 (prefix-numeric-value arg))
265 (completing-read "Newsgroup: " gnus-active-hashtb nil
266 (gnus-read-active-file-p))
267 (gnus-group-group-name))
269 (gnus-post-news 'post gnus-newsgroup-name)))
271 (defun gnus-summary-post-news ()
272 "Start composing a news message."
274 (gnus-post-news 'post gnus-newsgroup-name))
276 (defun gnus-summary-followup (yank &optional force-news)
277 "Compose a followup to an article.
278 If prefix argument YANK is non-nil, original article is yanked automatically."
280 (list (and current-prefix-arg
281 (gnus-summary-work-articles 1))))
283 (gnus-summary-goto-subject (car yank)))
284 (save-window-excursion
285 (gnus-summary-select-article))
286 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
287 (gnus-newsgroup-name gnus-newsgroup-name))
289 (gnus-post-news nil gnus-newsgroup-name
290 headers gnus-article-buffer
291 yank nil force-news)))
293 (defun gnus-summary-followup-with-original (n &optional force-news)
294 "Compose a followup to an article and include the original article."
296 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
298 (defun gnus-summary-followup-to-mail (&optional arg)
299 "Followup to the current mail message via news."
301 (list (and current-prefix-arg
302 (gnus-summary-work-articles 1))))
303 (gnus-summary-followup arg t))
305 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
306 "Followup to the current mail message via news."
308 (gnus-summary-followup (gnus-summary-work-articles arg) t))
310 (defun gnus-inews-yank-articles (articles)
311 (let* ((more-than-one (cdr articles))
312 (frame (when (and message-use-multi-frames more-than-one)
313 (window-frame (get-buffer-window (current-buffer)))))
316 (while (setq article (pop articles))
317 (save-window-excursion
318 (set-buffer gnus-summary-buffer)
319 (gnus-summary-select-article nil nil nil article)
320 (gnus-summary-remove-process-mark article))
322 (select-frame frame))
324 ;; Gathering references.
326 (setq refs (message-list-references
328 (mail-header-references gnus-current-headers)
329 (mail-header-message-id gnus-current-headers))))
331 (gnus-copy-article-buffer)
332 (let ((message-reply-buffer gnus-article-copy)
333 (message-reply-headers gnus-current-headers))
334 (message-yank-original)
335 (setq beg (or beg (mark t))))
340 ;; Replace with the gathered references.
344 (message-narrow-to-headers)
345 (let ((case-fold-search t))
346 (if (re-search-forward "^References:\\([\t ]+.+\n\\)+" nil t)
348 (goto-char (point-max))))
350 (list (or (assq 'References message-header-format-alist)
351 '(References . message-fill-references)))
352 (list (cons 'References
353 (mapconcat 'identity (nreverse refs) " "))))
354 (backward-delete-char 1))
360 (defun gnus-summary-cancel-article (&optional n symp)
361 "Cancel an article you posted.
362 Uses the process-prefix convention. If given the symbolic
363 prefix `a', cancel using the standard posting method; if not
364 post using the current select method."
365 (interactive (gnus-interactive "P\ny"))
366 (let ((articles (gnus-summary-work-articles n))
369 (gnus-post-method (not (eq symp 'a)) ,gnus-newsgroup-name)))
371 (while (setq article (pop articles))
372 (when (gnus-summary-select-article t nil nil article)
373 (when (gnus-eval-in-buffer-window gnus-article-buffer
375 (set-buffer gnus-original-article-buffer)
376 (message-cancel-news)))
377 (gnus-summary-mark-as-read article gnus-canceled-mark)
378 (gnus-cache-remove-article 1))
379 (gnus-article-hide-headers-if-wanted))
380 (gnus-summary-remove-process-mark article))))
382 (defun gnus-summary-supersede-article ()
383 "Compose an article that will supersede a previous article.
384 This is done simply by taking the old article and adding a Supersedes
385 header line with the old Message-ID."
387 (let ((article (gnus-summary-article-number))
388 (gnus-message-setup-hook '(gnus-maybe-setup-default-charset)))
389 (gnus-setup-message 'reply-yank
390 (gnus-summary-select-article t)
391 (set-buffer gnus-original-article-buffer)
395 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
397 (set-buffer ,gnus-summary-buffer)
398 (gnus-cache-possibly-remove-article ,article nil nil nil t)
399 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
400 message-send-actions))))
404 (defun gnus-copy-article-buffer (&optional article-buffer)
405 ;; make a copy of the article buffer with all text properties removed
406 ;; this copy is in the buffer gnus-article-copy.
407 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
408 ;; this buffer should be passed to all mail/news reply/post routines.
409 (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
410 (buffer-disable-undo gnus-article-copy)
411 (let ((article-buffer (or article-buffer gnus-article-buffer))
413 (if (not (and (get-buffer article-buffer)
414 (gnus-buffer-exists-p article-buffer)))
415 (error "Can't find any article buffer")
417 (set-buffer article-buffer)
419 ;; Copy over the (displayed) article buffer, delete
420 ;; hidden text and remove text properties.
422 (copy-to-buffer gnus-article-copy (point-min) (point-max))
423 (set-buffer gnus-article-copy)
424 (gnus-article-delete-text-of-type 'annotation)
425 (gnus-remove-text-with-property 'gnus-prev)
426 (gnus-remove-text-with-property 'gnus-next)
429 (format "%s" (buffer-string))
431 ;; Find the original headers.
432 (set-buffer gnus-original-article-buffer)
433 (goto-char (point-min))
434 (while (looking-at message-unix-mail-delimiter)
437 (setq end (or (search-forward "\n\n" nil t) (point)))
438 ;; Delete the headers from the displayed articles.
439 (set-buffer gnus-article-copy)
440 (delete-region (goto-char (point-min))
441 (or (search-forward "\n\n" nil t) (point)))
442 ;; Insert the original article headers.
443 (insert-buffer-substring gnus-original-article-buffer beg end)
444 (gnus-article-decode-rfc1522)))
447 (defun gnus-post-news (post &optional group header article-buffer yank subject
450 (gnus-copy-article-buffer))
451 (let ((gnus-article-reply article-buffer)
452 (add-to-list gnus-add-to-list))
453 (gnus-setup-message (cond (yank 'reply-yank)
454 (article-buffer 'reply)
456 (let* ((group (or group gnus-newsgroup-name))
458 to-address to-group mailing-list to-list
461 (setq to-address (gnus-group-find-parameter group 'to-address)
462 to-group (gnus-group-find-parameter group 'to-group)
463 to-list (gnus-group-find-parameter group 'to-list)
464 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
465 mailing-list (when gnus-mailing-list-groups
466 (string-match gnus-mailing-list-groups group))
467 group (gnus-group-real-name group)))
468 (if (or (and to-group
469 (gnus-news-group-p to-group))
472 (and (gnus-news-group-p
473 (or pgroup gnus-newsgroup-name)
474 (if header (mail-header-number header)
475 gnus-current-article))
481 (message-news (or to-group group))
482 (set-buffer gnus-article-copy)
483 (gnus-msg-treat-broken-reply-to)
484 (message-followup (if (or newsgroup-p force-news) nil to-group)))
488 (message-mail (or to-address to-list))
489 ;; Arrange for mail groups that have no `to-address' to
490 ;; get that when the user sends off the mail.
491 (when (and (not to-list)
494 (push (list 'gnus-inews-add-to-address pgroup)
495 message-send-actions)))
496 (set-buffer gnus-article-copy)
497 (gnus-msg-treat-broken-reply-to)
498 (message-wide-reply to-address)))
500 (gnus-inews-yank-articles yank))))))
502 (defun gnus-msg-treat-broken-reply-to ()
503 "Remove the Reply-to header iff broken-reply-to."
504 (when (gnus-group-find-parameter
505 gnus-newsgroup-name 'broken-reply-to)
507 (message-narrow-to-head)
508 (message-remove-header "reply-to"))))
510 (defun gnus-post-method (arg group &optional silent)
511 "Return the posting method based on GROUP and ARG.
512 If SILENT, don't prompt the user."
513 (let ((group-method (gnus-find-method-for-group group)))
515 ;; If the group-method is nil (which shouldn't happen) we use
516 ;; the default method.
518 (or (and (null (eq gnus-post-method 'active)) gnus-post-method)
519 gnus-select-method message-post-method))
520 ;; We want the inverse of the default
521 ((and arg (not (eq arg 0)))
522 (if (eq gnus-post-method 'active)
525 ;; We query the user for a post method.
527 (and gnus-post-method
528 (not (eq gnus-post-method 'current))
529 (listp (car gnus-post-method))))
531 ;; Collect all methods we know about.
533 (when (and gnus-post-method
534 (not (eq gnus-post-method 'current)))
535 (if (listp (car gnus-post-method))
537 (list gnus-post-method)))
538 gnus-secondary-select-methods
539 (mapcar 'cdr gnus-server-alist)
540 (list gnus-select-method)
541 (list group-method)))
542 method-alist post-methods method)
543 ;; Weed out all mail methods.
545 (setq method (gnus-server-get-method "" (pop methods)))
546 (when (or (gnus-method-option-p method 'post)
547 (gnus-method-option-p method 'post-mail))
548 (push method post-methods)))
549 ;; Create a name-method alist.
553 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m))
558 (setq gnus-last-posting-server
560 gnus-last-posting-server)
561 ;; Just use the last value.
562 gnus-last-posting-server
564 "Posting method: " method-alist nil t
565 (cons (or gnus-last-posting-server "") 0))))
567 ;; Override normal method.
568 ((and (eq gnus-post-method 'current)
569 (not (eq (car group-method) 'nndraft))
572 ((and gnus-post-method
573 (not (eq gnus-post-method 'current)))
575 ;; Use the normal select method.
576 (t gnus-select-method))))
580 (defun gnus-extended-version ()
581 "Stringified gnus version."
583 (concat gnus-product-name "/" gnus-version-number))
585 (defun gnus-message-make-user-agent (&optional include-mime-info max-column)
586 "Return user-agent info.
587 INCLUDE-MIME-INFO the optional first argument if it is non-nil and the variable
588 `mime-edit-user-agent-value' exists, the return value will include it.
589 MAX-COLUMN the optional second argument if it is specified, the return value
590 will be folded up in the proper way."
591 (let ((user-agent (if (and include-mime-info
592 (boundp 'mime-edit-user-agent-value))
593 (concat (gnus-extended-version)
595 mime-edit-user-agent-value)
596 (gnus-extended-version))))
599 (unless (natnump max-column) (setq max-column 76))
601 (insert " " user-agent)
603 (while (re-search-forward "[\n\t ]+" nil t)
606 (while (re-search-forward "[^ ()/]+\\(/[^ ()/]+\\)? ?" nil t)
607 (while (eq ?\( (char-after (point)))
609 (skip-chars-forward " "))
610 (skip-chars-backward " ")
611 (if (> (current-column) max-column)
613 (if (or (not boundary) (eq ?\n (char-after boundary)))
615 (setq boundary (point))
622 (setq boundary (point))))
623 (buffer-substring 13 (point-max))))
628 ;;; Gnus Mail Functions
631 ;;; Mail reply commands of Gnus summary mode
633 (defun gnus-summary-reply (&optional yank wide)
634 "Start composing a reply mail to the current message.
635 If prefix argument YANK is non-nil, the original article is yanked
638 (list (and current-prefix-arg
639 (gnus-summary-work-articles 1))))
640 ;; Stripping headers should be specified with mail-yank-ignored-headers.
642 (gnus-summary-goto-subject (car yank)))
643 (let ((gnus-article-reply t))
644 (gnus-setup-message (if yank 'reply-yank 'reply)
645 (gnus-summary-select-article)
646 (set-buffer (gnus-copy-article-buffer))
647 (gnus-msg-treat-broken-reply-to)
648 (message-reply nil wide)
650 (gnus-inews-yank-articles yank)))))
652 (defun gnus-summary-reply-with-original (n &optional wide)
653 "Start composing a reply mail to the current message.
654 The original article will be yanked."
656 (gnus-summary-reply (gnus-summary-work-articles n) wide))
658 (defun gnus-summary-wide-reply (&optional yank)
659 "Start composing a wide reply mail to the current message.
660 If prefix argument YANK is non-nil, the original article is yanked
663 (list (and current-prefix-arg
664 (gnus-summary-work-articles 1))))
665 (gnus-summary-reply yank t))
667 (defun gnus-summary-wide-reply-with-original (n)
668 "Start composing a wide reply mail to the current message.
669 The original article will be yanked."
671 (gnus-summary-reply-with-original n t))
673 (defun gnus-summary-mail-forward (&optional full-headers post)
674 "Forward the current message to another user.
675 If FULL-HEADERS (the prefix), include full headers when forwarding."
677 (gnus-setup-message 'forward
678 (gnus-summary-select-article)
679 (let ((charset default-mime-charset))
680 (set-buffer gnus-original-article-buffer)
681 (make-local-variable 'default-mime-charset)
682 (setq default-mime-charset charset)
684 (let ((message-included-forward-headers
685 (if full-headers "" message-included-forward-headers)))
686 (message-forward post))))
688 (defun gnus-summary-post-forward (&optional full-headers)
689 "Forward the current article to a newsgroup.
690 If FULL-HEADERS (the prefix), include full headers when forwarding."
692 (gnus-summary-mail-forward full-headers t))
694 ;;; XXX: generate Subject and ``Topics''?
695 (defun gnus-summary-mail-digest (&optional n post)
696 "Digests and forwards all articles in this series."
698 (let ((subject "Digested Articles")
699 (articles (gnus-summary-work-articles n))
701 (gnus-setup-message 'forward
702 (gnus-summary-select-article)
703 (if post (message-news nil subject) (message-mail nil subject))
704 (when (and message-use-multi-frames (cdr articles))
705 (setq frame (window-frame (get-buffer-window (current-buffer)))))
707 (while (setq article (pop articles))
708 (save-window-excursion
709 (set-buffer gnus-summary-buffer)
710 (gnus-summary-select-article nil nil nil article)
711 (gnus-summary-remove-process-mark article))
713 (select-frame frame))
714 (insert (mime-make-tag "message" "rfc822") "\n")
715 (insert-buffer-substring gnus-original-article-buffer))
718 (mime-edit-enclose-digest-region (point)(mark t)))))
720 (defun gnus-summary-post-digest (&optional n)
721 "Digest and forwards all articles in this series to a newsgroup."
723 (gnus-summary-mail-digest n t))
725 (defun gnus-summary-resend-message (address n)
726 "Resend the current article to ADDRESS."
727 (interactive "sResend message(s) to: \nP")
728 (let ((articles (gnus-summary-work-articles n))
730 (while (setq article (pop articles))
731 (gnus-summary-select-article nil nil nil article)
733 (set-buffer gnus-original-article-buffer)
734 (message-resend address)))))
736 (defvar gnus-nastygram-message
737 "The following article was inappropriately posted to %s.\n\n"
738 "Format string to insert in nastygrams.
739 The current group name will be inserted at \"%s\".")
741 (defun gnus-summary-mail-nastygram (n)
742 "Send a nastygram to the author of the current article."
744 (when (or gnus-expert-user
746 "Really send a nastygram to the author of the current article? "))
747 (let ((group gnus-newsgroup-name))
748 (gnus-summary-reply-with-original n)
749 (set-buffer gnus-message-buffer)
751 (insert (format gnus-nastygram-message group))
752 (message-send-and-exit))))
754 (defun gnus-summary-mail-crosspost-complaint (n)
755 "Send a complaint about crossposting to the current article(s)."
757 (let ((articles (gnus-summary-work-articles n))
759 (while (setq article (pop articles))
760 (set-buffer gnus-summary-buffer)
761 (gnus-summary-goto-subject article)
762 (let ((group (gnus-group-real-name gnus-newsgroup-name))
763 newsgroups followup-to)
764 (gnus-summary-select-article)
765 (set-buffer gnus-original-article-buffer)
766 (if (and (<= (length (message-tokenize-header
767 (setq newsgroups (mail-fetch-field "newsgroups"))
770 (or (not (setq followup-to (mail-fetch-field "followup-to")))
771 (not (member group (message-tokenize-header
772 followup-to ", ")))))
774 (gnus-message 1 "Followup-to restricted")
775 (gnus-message 1 "Not a crossposted article"))
776 (set-buffer gnus-summary-buffer)
777 (gnus-summary-reply-with-original 1)
778 (set-buffer gnus-message-buffer)
780 (insert (format gnus-crosspost-complaint newsgroups group))
781 (message-goto-subject)
782 (re-search-forward " *$")
783 (replace-match " (crosspost notification)" t t)
784 (gnus-deactivate-mark)
785 (when (gnus-y-or-n-p "Send this complaint? ")
786 (message-send-and-exit)))))))
788 (defun gnus-summary-mail-other-window ()
789 "Compose mail in other window."
791 (gnus-setup-message 'message
794 (defun gnus-mail-parse-comma-list ()
797 (skip-chars-forward " ")
800 (skip-chars-forward "^,")
805 (narrow-to-region beg (point))
808 (while (search-forward "\"" nil t)
812 (skip-chars-forward ",")
813 (skip-chars-forward "^,"))
814 (skip-chars-backward " ")
815 (push (buffer-substring beg (point))
817 (skip-chars-forward "^,")
818 (skip-chars-forward ", "))
821 (defun gnus-inews-add-to-address (group)
822 (let ((to-address (mail-fetch-field "to")))
823 (when (and to-address
825 ;; This mail group doesn't have a `to-list', so we add one
828 (format "Do you want to add this as `to-list': %s " to-address))
829 (gnus-group-add-parameter group (cons 'to-list to-address))))))
831 (defun gnus-put-message ()
832 "Put the current message in some group and return to Gnus."
834 (let ((reply gnus-article-reply)
835 (winconf gnus-prev-winconf)
836 (group gnus-newsgroup-name))
838 (or (and group (not (gnus-group-read-only-p group)))
839 (setq group (read-string "Put in group: " nil
840 (gnus-writable-groups))))
841 (when (gnus-gethash group gnus-newsrc-hashtb)
842 (error "No such group: %s" group))
847 (message-narrow-to-headers)
848 (let (gnus-deletable-headers)
850 (message-generate-headers message-required-news-headers)
851 (message-generate-headers message-required-mail-headers)))
852 (goto-char (point-max))
853 (insert "Gcc: " group "\n")
858 (when (get-buffer gnus-group-buffer)
859 (when (gnus-buffer-exists-p (car-safe reply))
860 (set-buffer (car reply))
862 (gnus-summary-mark-article-as-replied
865 (set-window-configuration winconf)))))
867 (defun gnus-article-mail (yank)
868 "Send a reply to the address near point.
869 If YANK is non-nil, include the original article."
873 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
874 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
876 (message-reply address)
878 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
880 (defvar nntp-server-type)
882 "Send a bug report to the Gnus maintainers."
884 (unless (gnus-alive-p)
885 (error "Gnus has been shut down"))
886 (gnus-setup-message 'bug
887 (delete-other-windows)
888 (when gnus-bug-create-help-buffer
889 (switch-to-buffer "*Gnus Help Bug*")
891 (insert gnus-bug-message)
892 (goto-char (point-min)))
893 (message-pop-to-buffer "*Gnus Bug*")
895 `((To . ,gnus-maintainer) (Cc . ,semi-gnus-developers) (Subject . "")))
896 (when gnus-bug-create-help-buffer
897 (push `(gnus-bug-kill-buffer) message-send-actions))
898 (goto-char (point-min))
899 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
901 (insert (gnus-version) "\n"
902 (emacs-version) "\n")
903 (when (and (boundp 'nntp-server-type)
904 (stringp nntp-server-type))
905 (insert nntp-server-type))
906 (insert "\n\n\n\n\n")
908 (goto-char (point-min))
909 (search-forward "Subject: " nil t)
912 (defun gnus-bug-kill-buffer ()
913 (when (get-buffer "*Gnus Help Bug*")
914 (kill-buffer "*Gnus Help Bug*")))
917 "Attempts to go through the Gnus source file and report what variables have been changed.
918 The source file has to be in the Emacs load path."
920 (let ((files '("gnus.el" "gnus-sum.el" "gnus-group.el"
921 "gnus-art.el" "gnus-start.el" "gnus-async.el"
922 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
923 "nnmail.el" "message.el"))
926 (gnus-message 4 "Please wait while we snoop your variables...")
928 ;; Go through all the files looking for non-default values for variables.
930 (set-buffer (gnus-get-buffer-create " *gnus bug info*"))
931 (buffer-disable-undo (current-buffer))
934 (when (and (setq file (locate-library (pop files)))
935 (file-exists-p file))
936 (insert-file-contents file)
937 (goto-char (point-min))
938 (if (not (re-search-forward "^;;* *Internal variables" nil t))
939 (gnus-message 4 "Malformed sources in file %s" file)
940 (narrow-to-region (point-min) (point))
941 (goto-char (point-min))
942 (while (setq expr (ignore-errors (read (current-buffer))))
944 (and (or (eq (car expr) 'defvar)
945 (eq (car expr) 'defcustom))
946 (stringp (nth 3 expr))
947 (or (not (boundp (nth 1 expr)))
948 (not (equal (eval (nth 2 expr))
949 (symbol-value (nth 1 expr)))))
950 (push (nth 1 expr) olist)))))))
951 (kill-buffer (current-buffer)))
952 (when (setq olist (nreverse olist))
953 (insert "------------------ Environment follows ------------------\n\n"))
955 (if (boundp (car olist))
957 (pp `(setq ,(car olist)
958 ,(if (or (consp (setq sym (symbol-value (car olist))))
960 (not (or (eq sym nil)
962 (list 'quote (symbol-value (car olist)))
963 (symbol-value (car olist))))
966 (format "(setq %s 'whatever)\n" (car olist))))
967 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
968 (setq olist (cdr olist)))
970 ;; Remove any control chars - they seem to cause trouble for some
971 ;; mailers. (Byte-compiled output from the stuff above.)
973 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
974 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
977 ;;; Treatment of rejected articles.
980 (defun gnus-summary-resend-bounced-mail (&optional fetch)
981 "Re-mail the current message.
982 This only makes sense if the current message is a bounce message than
983 contains some mail you have written which has been bounced back to
985 If FETCH, try to fetch the article that this is a reply to, if indeed
988 (gnus-summary-select-article t)
989 (set-buffer gnus-original-article-buffer)
990 (let ((gnus-message-setup-hook '(gnus-maybe-setup-default-charset)))
991 (gnus-setup-message 'compose-bounce
992 (let* ((references (mail-fetch-field "references"))
993 (parent (and references (gnus-parent-id references))))
995 ;; If there are references, we fetch the article we answered to.
997 (gnus-summary-refer-article parent)
998 (gnus-summary-show-all-headers))))))
1002 ;; Do Gcc handling, which copied the message over to some group.
1003 (defun gnus-inews-do-gcc (&optional gcc)
1005 (when (gnus-alive-p)
1008 (message-narrow-to-headers)
1009 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
1010 (coding-system-for-write 'raw-text)
1011 groups group method)
1013 (message-remove-header "gcc")
1015 (setq groups (message-tokenize-header gcc " ,"))
1016 ;; Copy the article over to some group(s).
1017 (while (setq group (pop groups))
1020 (cond ((and (null (gnus-get-info group))
1021 (eq (car gnus-message-archive-method)
1023 (gnus-server-to-method
1024 (gnus-group-method group)))))
1025 ;; If the group doesn't exist, we assume
1026 ;; it's an archive group...
1027 gnus-message-archive-method)
1029 ((gnus-info-method (gnus-get-info group))
1030 (gnus-info-method (gnus-get-info group)))
1032 (t (gnus-group-method group)))))
1033 (gnus-check-server method)
1034 (unless (gnus-request-group group t method)
1035 (gnus-request-create-group group method))
1037 (nnheader-set-temp-buffer " *acc*")
1038 (insert-buffer-substring message-encoding-buffer)
1039 (gnus-run-hooks 'gnus-before-do-gcc-hook)
1040 (goto-char (point-min))
1041 (when (re-search-forward
1042 (concat "^" (regexp-quote mail-header-separator) "$")
1044 (replace-match "" t t ))
1045 (unless (gnus-request-accept-article group method t)
1046 (gnus-message 1 "Couldn't store article in group %s: %s"
1047 group (gnus-status-message method))
1049 (kill-buffer (current-buffer))))))))))
1051 (defun gnus-inews-insert-gcc ()
1052 "Insert Gcc headers based on `gnus-outgoing-message-group'."
1055 (message-narrow-to-headers)
1056 (let* ((group gnus-outgoing-message-group)
1058 ((gnus-functionp group)
1060 ((or (stringp group) (list group))
1064 (if (stringp gcc) gcc
1065 (mapconcat 'identity gcc " "))
1068 (defun gnus-inews-insert-archive-gcc (&optional group)
1069 "Insert the Gcc to say where the article is to be archived."
1070 (let* ((var gnus-message-archive-group)
1071 (group (or group gnus-newsgroup-name ""))
1073 (and gnus-newsgroup-name
1074 (gnus-group-find-parameter
1075 gnus-newsgroup-name 'gcc-self)))
1079 ((null gnus-message-archive-method)
1083 ;; Just a single group.
1086 ;; We don't want this.
1088 ((and (listp var) (stringp (car var)))
1089 ;; A list of groups.
1091 ((gnus-functionp var)
1093 (funcall var group))
1095 ;; An alist of regexps/functions/forms.
1100 ((stringp (caar var))
1102 (when (string-match (caar var) group)
1104 ((gnus-functionp (car var))
1106 (funcall (car var) group))
1108 (eval (car var)))))))
1109 (setq var (cdr var)))
1112 (when (or groups gcc-self-val)
1113 (when (stringp groups)
1114 (setq groups (list groups)))
1117 (message-narrow-to-headers)
1118 (goto-char (point-max))
1121 ;; Use the `gcc-self' param value instead.
1124 (if (stringp gcc-self-val)
1127 (if (not (eq gcc-self-val 'none))
1132 ;; Use the list of groups.
1133 (while (setq name (pop groups))
1134 (insert (if (string-match ":" name)
1136 (gnus-group-prefixed-name
1137 name gnus-message-archive-method)))
1144 (defvar gnus-message-style-insertions nil)
1146 (defun gnus-configure-posting-styles ()
1147 "Configure posting styles according to `gnus-posting-styles'."
1148 (unless gnus-inhibit-posting-styles
1149 (let ((styles gnus-posting-styles)
1150 (gnus-newsgroup-name (or gnus-newsgroup-name ""))
1151 style match variable attribute value value-value)
1152 (make-local-variable 'gnus-message-style-insertions)
1153 ;; Go through all styles and look for matches.
1155 (setq style (pop styles)
1157 (when (cond ((stringp match)
1158 ;; Regexp string match on the group name.
1159 (string-match match gnus-newsgroup-name))
1160 ((or (symbolp match)
1161 (gnus-functionp match))
1162 (cond ((gnus-functionp match)
1163 ;; Function to be called.
1166 ;; Variable to be checked.
1167 (symbol-value match))))
1169 ;; This is a form to be evaled.
1171 ;; We have a match, so we set the variables.
1173 (setq attribute (pop style)
1174 value (cadr attribute)
1176 ;; We find the variable that is to be modified.
1177 (if (and (not (stringp (car attribute)))
1178 (not (eq 'body (car attribute)))
1180 (cdr (assq (car attribute)
1181 gnus-posting-style-alist)))))
1182 (message "Couldn't find attribute %s" (car attribute))
1183 ;; We get the value.
1185 (cond ((stringp value)
1187 ((or (symbolp value)
1188 (gnus-functionp value))
1189 (cond ((gnus-functionp value)
1192 (symbol-value value))))
1196 ;; This is an ordinary variable.
1197 (set (make-local-variable variable) value-value)
1198 ;; This is either a body or a header to be inserted in the
1201 (let ((attr (car attribute)))
1202 (make-local-variable 'message-setup-hook)
1204 (add-hook 'message-setup-hook
1208 (insert ,value-value))))
1209 (add-hook 'message-setup-hook
1210 'gnus-message-insert-stylings)
1211 (push (cons (if (stringp attr) attr
1214 gnus-message-style-insertions))))))))))))
1216 (defun gnus-message-insert-stylings ()
1220 (while (setq val (pop gnus-message-style-insertions))
1222 (insert (car val) ": " (cdr val) "\n"))
1223 (gnus-pull (car val) gnus-message-style-insertions)))))
1226 ;;; @ for MIME Edit mode
1229 (defun gnus-maybe-setup-default-charset ()
1231 (and (boundp 'gnus-summary-buffer)
1232 (buffer-live-p gnus-summary-buffer)
1234 (set-buffer gnus-summary-buffer)
1235 default-mime-charset))))
1238 (make-local-variable 'default-mime-charset)
1239 (setq default-mime-charset charset)
1243 ;;; Allow redefinition of functions.
1249 ;;; gnus-msg.el ends here