1 ;;; gnus-msg.el --- mail and post interface for Semi-gnus
2 ;; Copyright (C) 1995,96,97,98,99 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 (defcustom gnus-group-posting-charset-alist
108 '(("^no\\." iso-8859-1)
109 (message-this-is-mail nil)
111 (message-this-is-news iso-8859-1))
112 "Alist of regexps (to match group names) and default charsets to be unencoded when posting."
113 :type '(repeat (list (regexp :tag "Group")
114 (symbol :tag "Charset")))
115 :group 'gnus-charset)
117 ;;; Internal variables.
119 (defvar gnus-inhibit-posting-styles nil
120 "Inhibit the use of posting styles.")
122 (defvar gnus-message-buffer "*Mail Gnus*")
123 (defvar gnus-article-copy nil)
124 (defvar gnus-last-posting-server nil)
125 (defvar gnus-message-group-art nil)
127 (defconst gnus-bug-message
128 (format "Sending a bug report to the Gnus Towers.
129 ========================================
131 This gnus is the %s%s.
132 If you think the bug is a Semi-gnus bug, send a bug report to Semi-gnus
133 Developers. (the addresses below are mailing list addresses)
135 ========================================
137 The buffer below is a mail buffer. When you press `C-c C-c', it will
138 be sent to the Gnus Bug Exterminators.
140 The thing near the bottom of the buffer is how the environment
141 settings will be included in the mail. Please do not delete that.
142 They will tell the Bug People what your environment is, so that it
143 will be easier to locate the bugs.
145 If you have found a bug that makes Emacs go \"beep\", set
146 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
147 and include the backtrace in your bug report.
149 Please describe the bug in annoying, painstaking detail.
151 Thank you for your help in stamping out bugs.
154 (if (string= gnus-product-name "Semi-gnus")
156 ", a modified version of Semi-gnus")))
159 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
160 (autoload 'news-setup "rnewspost")
161 (autoload 'news-reply-mode "rnewspost")
162 (autoload 'rmail-dont-reply-to "mail-utils")
163 (autoload 'rmail-output "rmailout"))
167 ;;; Gnus Posting Functions
170 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
171 "p" gnus-summary-post-news
172 "f" gnus-summary-followup
173 "F" gnus-summary-followup-with-original
174 "c" gnus-summary-cancel-article
175 "s" gnus-summary-supersede-article
176 "r" gnus-summary-reply
177 "R" gnus-summary-reply-with-original
178 "w" gnus-summary-wide-reply
179 "W" gnus-summary-wide-reply-with-original
180 "n" gnus-summary-followup-to-mail
181 "N" gnus-summary-followup-to-mail-with-original
182 "m" gnus-summary-mail-other-window
183 "u" gnus-uu-post-news
184 "\M-c" gnus-summary-mail-crosspost-complaint
185 "om" gnus-summary-mail-forward
186 "op" gnus-summary-post-forward
187 "Om" gnus-summary-mail-digest
188 "Op" gnus-summary-post-digest)
190 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
191 "b" gnus-summary-resend-bounced-mail
192 ;; "c" gnus-summary-send-draft
193 "r" gnus-summary-resend-message)
195 ;;; Internal functions.
197 (defvar gnus-article-reply nil)
198 (defmacro gnus-setup-message (config &rest forms)
199 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
200 (buffer (make-symbol "gnus-setup-message-buffer"))
201 (article (make-symbol "gnus-setup-message-article"))
202 (group (make-symbol "gnus-setup-message-group")))
203 `(let ((,winconf (current-window-configuration))
204 (,buffer (buffer-name (current-buffer)))
205 (,article (and gnus-article-reply (gnus-summary-article-number)))
206 (,group gnus-newsgroup-name)
207 (message-header-setup-hook
208 (copy-sequence message-header-setup-hook))
209 (message-mode-hook (copy-sequence message-mode-hook))
210 (message-startup-parameter-alist
211 '((reply-buffer . gnus-copy-article-buffer)
212 (original-buffer . gnus-original-article-buffer)
213 (user-agent . Gnus))))
214 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
215 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
216 (add-hook 'message-mode-hook 'gnus-configure-posting-styles)
220 (gnus-inews-add-send-actions ,winconf ,buffer ,article)
221 (setq gnus-message-buffer (current-buffer))
222 (set (make-local-variable 'gnus-message-group-art)
223 (cons ,group ,article))
224 (set (make-local-variable 'gnus-newsgroup-name) ,group)
225 (set (make-local-variable 'message-posting-charset)
226 (gnus-setup-posting-charset ,group))
227 (gnus-run-hooks 'gnus-message-setup-hook))
229 (gnus-configure-windows ,config t)
230 (set-buffer-modified-p nil))))
232 (defun gnus-setup-posting-charset (group)
233 (let ((alist gnus-group-posting-charset-alist)
234 (group (or group ""))
238 (while (setq elem (pop alist))
239 (when (or (and (stringp (car elem))
240 (string-match (car elem) group))
241 (and (gnus-functionp (car elem))
242 (funcall (car elem) group))
243 (and (symbolp (car elem))
244 (symbol-value (car elem))))
245 (throw 'found (cadr elem))))))))
247 (defun gnus-inews-add-send-actions (winconf buffer article)
248 (make-local-hook 'message-sent-hook)
249 (add-hook 'message-sent-hook 'gnus-inews-do-gcc nil t)
250 (setq message-post-method
252 (gnus-post-method arg ,gnus-newsgroup-name)))
253 (setq message-user-agent (gnus-extended-version))
254 (when (not message-use-multi-frames)
256 `(set-window-configuration ,winconf) 'exit 'postpone 'kill))
258 `(when (gnus-buffer-exists-p ,buffer)
262 `(gnus-summary-mark-article-as-replied ,article))))
265 (put 'gnus-setup-message 'lisp-indent-function 1)
266 (put 'gnus-setup-message 'edebug-form-spec '(form body))
268 ;;; Post news commands of Gnus group mode and summary mode
270 (defun gnus-group-mail (&optional arg)
271 "Start composing a mail.
272 If ARG, use the group under the point to find a posting style.
273 If ARG is 1, prompt for a group name to find the posting style."
275 ;; We can't `let' gnus-newsgroup-name here, since that leads
276 ;; to local variables leaking.
277 (let ((group gnus-newsgroup-name)
278 (buffer (current-buffer)))
281 (setq gnus-newsgroup-name
283 (if (= 1 (prefix-numeric-value arg))
284 (completing-read "Use posting style of group: "
285 gnus-active-hashtb nil
286 (gnus-read-active-file-p))
287 (gnus-group-group-name))
289 (gnus-setup-message 'message (message-mail)))
292 (setq gnus-newsgroup-name group)))))
294 (defun gnus-group-post-news (&optional arg)
295 "Start composing a news message.
296 If ARG, post to the group under point.
297 If ARG is 1, prompt for a group name."
299 ;; Bind this variable here to make message mode hooks work ok.
300 (let ((gnus-newsgroup-name
302 (if (= 1 (prefix-numeric-value arg))
303 (completing-read "Newsgroup: " gnus-active-hashtb nil
304 (gnus-read-active-file-p))
305 (gnus-group-group-name))
307 (gnus-post-news 'post gnus-newsgroup-name)))
309 (defun gnus-summary-post-news ()
310 "Start composing a news message."
312 (gnus-post-news 'post gnus-newsgroup-name))
314 (defun gnus-summary-followup (yank &optional force-news)
315 "Compose a followup to an article.
316 If prefix argument YANK is non-nil, original article is yanked automatically."
318 (list (and current-prefix-arg
319 (gnus-summary-work-articles 1))))
321 (gnus-summary-goto-subject (car yank)))
322 (save-window-excursion
323 (gnus-summary-select-article))
324 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
325 (gnus-newsgroup-name gnus-newsgroup-name))
327 (gnus-post-news nil gnus-newsgroup-name
328 headers gnus-article-buffer
329 yank nil force-news)))
331 (defun gnus-summary-followup-with-original (n &optional force-news)
332 "Compose a followup to an article and include the original article."
334 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
336 (defun gnus-summary-followup-to-mail (&optional arg)
337 "Followup to the current mail message via news."
339 (list (and current-prefix-arg
340 (gnus-summary-work-articles 1))))
341 (gnus-summary-followup arg t))
343 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
344 "Followup to the current mail message via news."
346 (gnus-summary-followup (gnus-summary-work-articles arg) t))
348 (defun gnus-inews-yank-articles (articles)
349 (let* ((more-than-one (cdr articles))
350 (frame (when (and message-use-multi-frames more-than-one)
351 (window-frame (get-buffer-window (current-buffer)))))
354 (while (setq article (pop articles))
355 (save-window-excursion
356 (set-buffer gnus-summary-buffer)
357 (gnus-summary-select-article nil nil nil article)
358 (gnus-summary-remove-process-mark article))
360 (select-frame frame))
362 ;; Gathering references.
364 (setq refs (message-list-references
366 (mail-header-references gnus-current-headers)
367 (mail-header-message-id gnus-current-headers))))
369 (gnus-copy-article-buffer)
370 (let ((message-reply-buffer gnus-article-copy)
371 (message-reply-headers gnus-current-headers))
372 (message-yank-original)
373 (setq beg (or beg (mark t))))
378 ;; Replace with the gathered references.
382 (message-narrow-to-headers)
383 (let ((case-fold-search t))
384 (if (re-search-forward "^References:\\([\t ]+.+\n\\)+" nil t)
386 (goto-char (point-max))))
388 (list (or (assq 'References message-header-format-alist)
389 '(References . message-shorten-references)))
390 (list (cons 'References
391 (mapconcat 'identity (nreverse refs) " "))))
392 (backward-delete-char 1))
398 (defun gnus-summary-cancel-article (&optional n symp)
399 "Cancel an article you posted.
400 Uses the process-prefix convention. If given the symbolic
401 prefix `a', cancel using the standard posting method; if not
402 post using the current select method."
403 (interactive (gnus-interactive "P\ny"))
404 (let ((articles (gnus-summary-work-articles n))
407 (gnus-post-method (not (eq symp 'a)) ,gnus-newsgroup-name)))
409 (while (setq article (pop articles))
410 (when (gnus-summary-select-article t nil nil article)
411 (when (gnus-eval-in-buffer-window gnus-article-buffer
413 (set-buffer gnus-original-article-buffer)
414 (message-cancel-news)))
415 (gnus-summary-mark-as-read article gnus-canceled-mark)
416 (gnus-cache-remove-article 1))
417 (gnus-article-hide-headers-if-wanted))
418 (gnus-summary-remove-process-mark article))))
420 (defun gnus-summary-supersede-article ()
421 "Compose an article that will supersede a previous article.
422 This is done simply by taking the old article and adding a Supersedes
423 header line with the old Message-ID."
425 (let ((article (gnus-summary-article-number))
426 (gnus-message-setup-hook '(gnus-maybe-setup-default-charset)))
427 (gnus-setup-message 'reply-yank
428 (gnus-summary-select-article t)
429 (set-buffer gnus-original-article-buffer)
433 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
435 (set-buffer ,gnus-summary-buffer)
436 (gnus-cache-possibly-remove-article ,article nil nil nil t)
437 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
438 message-send-actions))))
442 (defun gnus-copy-article-buffer (&optional article-buffer)
443 ;; make a copy of the article buffer with all text properties removed
444 ;; this copy is in the buffer gnus-article-copy.
445 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
446 ;; this buffer should be passed to all mail/news reply/post routines.
447 (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
448 (let ((article-buffer (or article-buffer gnus-article-buffer))
450 (if (not (and (get-buffer article-buffer)
451 (gnus-buffer-exists-p article-buffer)))
452 (error "Can't find any article buffer")
454 (set-buffer article-buffer)
456 ;; Copy over the (displayed) article buffer, delete
457 ;; hidden text and remove text properties.
459 (let ((inhibit-read-only t))
460 (copy-to-buffer gnus-article-copy (point-min) (point-max))
461 (set-buffer gnus-article-copy)
462 (gnus-article-delete-text-of-type 'annotation)
463 (gnus-remove-text-with-property 'gnus-prev)
464 (gnus-remove-text-with-property 'gnus-next)
465 (gnus-remove-text-with-property 'x-face-mule-bitmap-image)
468 (format "%s" (buffer-string))
471 ;; Find the original headers.
472 (set-buffer gnus-original-article-buffer)
473 (goto-char (point-min))
474 (while (looking-at message-unix-mail-delimiter)
477 (setq end (or (search-forward "\n\n" nil t) (point)))
478 ;; Delete the headers from the displayed articles.
479 (set-buffer gnus-article-copy)
480 (delete-region (goto-char (point-min))
481 (or (search-forward "\n\n" nil t) (point-max)))
482 ;; Insert the original article headers.
483 (insert-buffer-substring gnus-original-article-buffer beg end)
484 (article-decode-encoded-words)))
487 (defun gnus-post-news (post &optional group header article-buffer yank subject
490 (gnus-copy-article-buffer))
491 (let ((gnus-article-reply article-buffer)
492 (add-to-list gnus-add-to-list))
493 (gnus-setup-message (cond (yank 'reply-yank)
494 (article-buffer 'reply)
496 (let* ((group (or group gnus-newsgroup-name))
498 to-address to-group mailing-list to-list
501 (setq to-address (gnus-group-find-parameter group 'to-address)
502 to-group (gnus-group-find-parameter group 'to-group)
503 to-list (gnus-group-find-parameter group 'to-list)
504 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
505 mailing-list (when gnus-mailing-list-groups
506 (string-match gnus-mailing-list-groups group))
507 group (gnus-group-real-name group)))
508 (if (or (and to-group
509 (gnus-news-group-p to-group))
512 (and (gnus-news-group-p
513 (or pgroup gnus-newsgroup-name)
514 (if header (mail-header-number header)
515 gnus-current-article))
521 (message-news (or to-group group))
522 (set-buffer gnus-article-copy)
523 (gnus-msg-treat-broken-reply-to)
524 (message-followup (if (or newsgroup-p force-news) nil to-group)))
528 (message-mail (or to-address to-list))
529 ;; Arrange for mail groups that have no `to-address' to
530 ;; get that when the user sends off the mail.
531 (when (and (not to-list)
534 (push (list 'gnus-inews-add-to-address pgroup)
535 message-send-actions)))
536 (set-buffer gnus-article-copy)
537 (gnus-msg-treat-broken-reply-to)
538 (message-wide-reply to-address)))
540 (gnus-inews-yank-articles yank))))))
542 (defun gnus-msg-treat-broken-reply-to ()
543 "Remove the Reply-to header iff broken-reply-to."
544 (when (gnus-group-find-parameter
545 gnus-newsgroup-name 'broken-reply-to)
547 (message-narrow-to-head)
548 (message-remove-header "reply-to"))))
550 (defun gnus-post-method (arg group &optional silent)
551 "Return the posting method based on GROUP and ARG.
552 If SILENT, don't prompt the user."
553 (let ((group-method (gnus-find-method-for-group group)))
555 ;; If the group-method is nil (which shouldn't happen) we use
556 ;; the default method.
558 (or (and (null (eq gnus-post-method 'active)) gnus-post-method)
559 gnus-select-method message-post-method))
560 ;; We want the inverse of the default
561 ((and arg (not (eq arg 0)))
562 (if (eq gnus-post-method 'active)
565 ;; We query the user for a post method.
567 (and gnus-post-method
568 (not (eq gnus-post-method 'current))
569 (listp (car gnus-post-method))))
571 ;; Collect all methods we know about.
573 (when (and gnus-post-method
574 (not (eq gnus-post-method 'current)))
575 (if (listp (car gnus-post-method))
577 (list gnus-post-method)))
578 gnus-secondary-select-methods
579 (mapcar 'cdr gnus-server-alist)
580 (mapcar 'car gnus-opened-servers)
581 (list gnus-select-method)
582 (list group-method)))
583 method-alist post-methods method)
584 ;; Weed out all mail methods.
586 (setq method (gnus-server-get-method "" (pop methods)))
587 (when (and (or (gnus-method-option-p method 'post)
588 (gnus-method-option-p method 'post-mail))
589 (not (member method post-methods)))
590 (push method post-methods)))
591 ;; Create a name-method alist.
595 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m))
600 (setq gnus-last-posting-server
602 gnus-last-posting-server)
603 ;; Just use the last value.
604 gnus-last-posting-server
606 "Posting method: " method-alist nil t
607 (cons (or gnus-last-posting-server "") 0))))
609 ;; Override normal method.
610 ((and (eq gnus-post-method 'current)
611 (not (eq (car group-method) 'nndraft))
614 ((and gnus-post-method
615 (not (eq gnus-post-method 'current)))
617 ;; Use the normal select method.
618 (t gnus-select-method))))
622 (defun gnus-extended-version ()
623 "Stringified gnus version."
624 (concat gnus-product-name "/" gnus-version-number
626 gnus-original-product-name " v" gnus-original-version-number ")"
627 (if (zerop (string-to-number gnus-revision-number))
629 (concat " (revision " gnus-revision-number ")"))
632 (defun gnus-message-make-user-agent (&optional include-mime-info max-column)
633 "Return user-agent info.
634 INCLUDE-MIME-INFO the optional first argument if it is non-nil and the variable
635 `mime-edit-user-agent-value' exists, the return value will include it.
636 MAX-COLUMN the optional second argument if it is specified, the return value
637 will be folded up in the proper way."
638 (let ((user-agent (if (and include-mime-info
639 (boundp 'mime-edit-user-agent-value))
640 (concat (gnus-extended-version)
642 mime-edit-user-agent-value)
643 (gnus-extended-version))))
646 (unless (natnump max-column) (setq max-column 76))
648 (insert " " user-agent)
650 (while (re-search-forward "[\n\t ]+" nil t)
653 (while (re-search-forward "[^ ()/]+\\(/[^ ()/]+\\)? ?" nil t)
654 (while (eq ?\( (char-after (point)))
656 (skip-chars-forward " "))
657 (skip-chars-backward " ")
658 (if (> (current-column) max-column)
660 (if (or (not boundary) (eq ?\n (char-after boundary)))
662 (setq boundary (point))
669 (setq boundary (point))))
670 (buffer-substring 13 (point-max))))
675 ;;; Gnus Mail Functions
678 ;;; Mail reply commands of Gnus summary mode
680 (defun gnus-summary-reply (&optional yank wide)
681 "Start composing a reply mail to the current message.
682 If prefix argument YANK is non-nil, the original article is yanked
685 (list (and current-prefix-arg
686 (gnus-summary-work-articles 1))))
687 ;; Stripping headers should be specified with mail-yank-ignored-headers.
689 (gnus-summary-goto-subject (car yank)))
690 (let ((gnus-article-reply t))
691 (gnus-setup-message (if yank 'reply-yank 'reply)
692 (gnus-summary-select-article)
693 (set-buffer (gnus-copy-article-buffer))
694 (gnus-msg-treat-broken-reply-to)
695 (message-reply nil wide)
697 (gnus-inews-yank-articles yank)))))
699 (defun gnus-summary-reply-with-original (n &optional wide)
700 "Start composing a reply mail to the current message.
701 The original article will be yanked."
703 (gnus-summary-reply (gnus-summary-work-articles n) wide))
705 (defun gnus-summary-wide-reply (&optional yank)
706 "Start composing a wide reply mail to the current message.
707 If prefix argument YANK is non-nil, the original article is yanked
710 (list (and current-prefix-arg
711 (gnus-summary-work-articles 1))))
712 (gnus-summary-reply yank t))
714 (defun gnus-summary-wide-reply-with-original (n)
715 "Start composing a wide reply mail to the current message.
716 The original article will be yanked."
718 (gnus-summary-reply-with-original n t))
720 (defun gnus-summary-mail-forward (&optional full-headers post)
721 "Forward the current message to another user.
722 If FULL-HEADERS (the prefix), include full headers when forwarding."
724 (gnus-setup-message 'forward
725 (gnus-summary-select-article)
726 (let ((charset default-mime-charset))
727 (set-buffer gnus-original-article-buffer)
728 (make-local-variable 'default-mime-charset)
729 (setq default-mime-charset charset)
731 (let ((message-included-forward-headers
732 (if full-headers "" message-included-forward-headers)))
733 (message-forward post))))
735 ;;; XXX: generate Subject and ``Topics''?
736 (defun gnus-summary-mail-digest (&optional n post)
737 "Digests and forwards all articles in this series."
739 (let ((subject "Digested Articles")
740 (articles (gnus-summary-work-articles n))
742 (gnus-setup-message 'forward
743 (gnus-summary-select-article)
744 (if post (message-news nil subject) (message-mail nil subject))
745 (when (and message-use-multi-frames (cdr articles))
746 (setq frame (window-frame (get-buffer-window (current-buffer)))))
748 (while (setq article (pop articles))
749 (save-window-excursion
750 (set-buffer gnus-summary-buffer)
751 (gnus-summary-select-article nil nil nil article)
752 (gnus-summary-remove-process-mark article))
754 (select-frame frame))
755 (insert (mime-make-tag "message" "rfc822") "\n")
756 (insert-buffer-substring gnus-original-article-buffer))
759 (mime-edit-enclose-digest-region (point)(mark t)))))
761 (defun gnus-summary-post-digest (&optional n)
762 "Digest and forwards all articles in this series to a newsgroup."
764 (gnus-summary-mail-digest n t))
766 (defun gnus-summary-resend-message (address n)
767 "Resend the current article to ADDRESS."
768 (interactive "sResend message(s) to: \nP")
769 (let ((articles (gnus-summary-work-articles n))
771 (while (setq article (pop articles))
772 (gnus-summary-select-article nil nil nil article)
774 (set-buffer gnus-original-article-buffer)
775 (message-resend address)))))
777 (defun gnus-summary-post-forward (&optional full-headers)
778 "Forward the current article to a newsgroup.
779 If FULL-HEADERS (the prefix), include full headers when forwarding."
781 (gnus-summary-mail-forward full-headers t))
783 (defvar gnus-nastygram-message
784 "The following article was inappropriately posted to %s.\n\n"
785 "Format string to insert in nastygrams.
786 The current group name will be inserted at \"%s\".")
788 (defun gnus-summary-mail-nastygram (n)
789 "Send a nastygram to the author of the current article."
791 (when (or gnus-expert-user
793 "Really send a nastygram to the author of the current article? "))
794 (let ((group gnus-newsgroup-name))
795 (gnus-summary-reply-with-original n)
796 (set-buffer gnus-message-buffer)
798 (insert (format gnus-nastygram-message group))
799 (message-send-and-exit))))
801 (defun gnus-summary-mail-crosspost-complaint (n)
802 "Send a complaint about crossposting to the current article(s)."
804 (let ((articles (gnus-summary-work-articles n))
806 (while (setq article (pop articles))
807 (set-buffer gnus-summary-buffer)
808 (gnus-summary-goto-subject article)
809 (let ((group (gnus-group-real-name gnus-newsgroup-name))
810 newsgroups followup-to)
811 (gnus-summary-select-article)
812 (set-buffer gnus-original-article-buffer)
813 (if (and (<= (length (message-tokenize-header
815 (mail-fetch-field "newsgroups"))
818 (or (not (setq followup-to (mail-fetch-field "followup-to")))
819 (not (member group (message-tokenize-header
820 followup-to ", ")))))
822 (gnus-message 1 "Followup-to restricted")
823 (gnus-message 1 "Not a crossposted article"))
824 (set-buffer gnus-summary-buffer)
825 (gnus-summary-reply-with-original 1)
826 (set-buffer gnus-message-buffer)
828 (insert (format gnus-crosspost-complaint newsgroups group))
829 (message-goto-subject)
830 (re-search-forward " *$")
831 (replace-match " (crosspost notification)" t t)
832 (gnus-deactivate-mark)
833 (when (gnus-y-or-n-p "Send this complaint? ")
834 (message-send-and-exit)))))))
836 (defun gnus-summary-mail-other-window ()
837 "Compose mail in other window."
839 (gnus-setup-message 'message
842 (defun gnus-mail-parse-comma-list ()
845 (skip-chars-forward " ")
848 (skip-chars-forward "^,")
853 (narrow-to-region beg (point))
856 (while (search-forward "\"" nil t)
860 (skip-chars-forward ",")
861 (skip-chars-forward "^,"))
862 (skip-chars-backward " ")
863 (push (buffer-substring beg (point))
865 (skip-chars-forward "^,")
866 (skip-chars-forward ", "))
869 (defun gnus-inews-add-to-address (group)
870 (let ((to-address (mail-fetch-field "to")))
871 (when (and to-address
873 ;; This mail group doesn't have a `to-list', so we add one
876 (format "Do you want to add this as `to-list': %s " to-address))
877 (gnus-group-add-parameter group (cons 'to-list to-address))))))
879 (defun gnus-put-message ()
880 "Put the current message in some group and return to Gnus."
882 (let ((reply gnus-article-reply)
883 (winconf gnus-prev-winconf)
884 (group gnus-newsgroup-name))
886 (or (and group (not (gnus-group-read-only-p group)))
887 (setq group (read-string "Put in group: " nil
888 (gnus-writable-groups))))
889 (when (gnus-gethash group gnus-newsrc-hashtb)
890 (error "No such group: %s" group))
895 (message-narrow-to-headers)
896 (let (gnus-deletable-headers)
898 (message-generate-headers message-required-news-headers)
899 (message-generate-headers message-required-mail-headers)))
900 (goto-char (point-max))
901 (insert "Gcc: " group "\n")
906 (when (get-buffer gnus-group-buffer)
907 (when (gnus-buffer-exists-p (car-safe reply))
908 (set-buffer (car reply))
910 (gnus-summary-mark-article-as-replied
913 (set-window-configuration winconf)))))
915 (defun gnus-article-mail (yank)
916 "Send a reply to the address near point.
917 If YANK is non-nil, include the original article."
921 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
922 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
924 (message-reply address)
926 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
928 (defvar nntp-server-type)
930 "Send a bug report to the Gnus maintainers."
932 (unless (gnus-alive-p)
933 (error "Gnus has been shut down"))
934 (gnus-setup-message 'bug
935 (delete-other-windows)
936 (when gnus-bug-create-help-buffer
937 (switch-to-buffer "*Gnus Help Bug*")
939 (insert gnus-bug-message)
940 (goto-char (point-min)))
941 (message-pop-to-buffer "*Gnus Bug*")
943 `((To . ,gnus-maintainer) (Cc . ,semi-gnus-developers) (Subject . "")))
944 (when gnus-bug-create-help-buffer
945 (push `(gnus-bug-kill-buffer) message-send-actions))
946 (goto-char (point-min))
947 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
949 (insert (gnus-version) "\n"
950 (emacs-version) "\n")
951 (when (and (boundp 'nntp-server-type)
952 (stringp nntp-server-type))
953 (insert nntp-server-type))
954 (insert "\n\n\n\n\n")
955 (let (mime-content-types)
956 (mime-edit-insert-tag "text" "plain" "; type=emacs-lisp"))
957 (insert (with-temp-buffer
960 (goto-char (point-min))
961 (search-forward "Subject: " nil t)
964 (defun gnus-bug-kill-buffer ()
965 (when (get-buffer "*Gnus Help Bug*")
966 (kill-buffer "*Gnus Help Bug*")))
969 "Attempts to go through the Gnus source file and report what variables have been changed.
970 The source file has to be in the Emacs load path."
972 (let ((files '("gnus.el" "gnus-sum.el" "gnus-group.el"
973 "gnus-art.el" "gnus-start.el" "gnus-async.el"
974 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
975 "nnmail.el" "message.el"))
978 (gnus-message 4 "Please wait while we snoop your variables...")
980 ;; Go through all the files looking for non-default values for variables.
982 (set-buffer (gnus-get-buffer-create " *gnus bug info*"))
985 (when (and (setq file (locate-library (pop files)))
986 (file-exists-p file))
987 (insert-file-contents file)
988 (goto-char (point-min))
989 (if (not (re-search-forward "^;;* *Internal variables" nil t))
990 (gnus-message 4 "Malformed sources in file %s" file)
991 (narrow-to-region (point-min) (point))
992 (goto-char (point-min))
993 (while (setq expr (ignore-errors (read (current-buffer))))
995 (and (or (eq (car expr) 'defvar)
996 (eq (car expr) 'defcustom))
997 (stringp (nth 3 expr))
998 (or (not (boundp (nth 1 expr)))
999 (not (equal (eval (nth 2 expr))
1000 (symbol-value (nth 1 expr)))))
1001 (push (nth 1 expr) olist)))))))
1002 (kill-buffer (current-buffer)))
1003 (when (setq olist (nreverse olist))
1004 (insert "------------------ Environment follows ------------------\n\n"))
1006 (if (boundp (car olist))
1008 (pp `(setq ,(car olist)
1009 ,(if (or (consp (setq sym (symbol-value (car olist))))
1011 (not (or (eq sym nil)
1013 (list 'quote (symbol-value (car olist)))
1014 (symbol-value (car olist))))
1017 (format "(setq %s 'whatever)\n" (car olist))))
1018 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
1019 (setq olist (cdr olist)))
1021 ;; Remove any control chars - they seem to cause trouble for some
1022 ;; mailers. (Byte-compiled output from the stuff above.)
1024 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
1025 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
1028 ;;; Treatment of rejected articles.
1031 (defun gnus-summary-resend-bounced-mail (&optional fetch)
1032 "Re-mail the current message.
1033 This only makes sense if the current message is a bounce message than
1034 contains some mail you have written which has been bounced back to
1036 If FETCH, try to fetch the article that this is a reply to, if indeed
1039 (gnus-summary-select-article t)
1040 (set-buffer gnus-original-article-buffer)
1041 (let ((gnus-message-setup-hook '(gnus-maybe-setup-default-charset)))
1042 (gnus-setup-message 'compose-bounce
1043 (let* ((references (mail-fetch-field "references"))
1044 (parent (and references (gnus-parent-id references))))
1046 ;; If there are references, we fetch the article we answered to.
1048 (gnus-summary-refer-article parent)
1049 (gnus-summary-show-all-headers))))))
1053 ;; Do Gcc handling, which copied the message over to some group.
1054 (defun gnus-inews-do-gcc (&optional gcc)
1056 (when (gnus-alive-p)
1059 (message-narrow-to-headers)
1060 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
1061 (coding-system-for-write 'raw-text)
1062 (output-coding-system 'raw-text)
1063 groups group method)
1065 (message-remove-header "gcc")
1067 (setq groups (message-tokenize-header gcc " ,"))
1068 ;; Copy the article over to some group(s).
1069 (while (setq group (pop groups))
1072 (cond ((and (null (gnus-get-info group))
1073 (eq (car gnus-message-archive-method)
1075 (gnus-server-to-method
1076 (gnus-group-method group)))))
1077 ;; If the group doesn't exist, we assume
1078 ;; it's an archive group...
1079 gnus-message-archive-method)
1081 ((gnus-info-method (gnus-get-info group))
1082 (gnus-info-method (gnus-get-info group)))
1084 (t (gnus-group-method group)))))
1085 (gnus-check-server method)
1086 (unless (gnus-request-group group t method)
1087 (gnus-request-create-group group method))
1089 (nnheader-set-temp-buffer " *acc*")
1090 (insert-buffer-substring message-encoding-buffer)
1091 (gnus-run-hooks 'gnus-before-do-gcc-hook)
1092 (goto-char (point-min))
1093 (when (re-search-forward
1094 (concat "^" (regexp-quote mail-header-separator) "$")
1096 (replace-match "" t t ))
1097 (unless (gnus-request-accept-article group method t t)
1098 (gnus-message 1 "Couldn't store article in group %s: %s"
1099 group (gnus-status-message method))
1101 (kill-buffer (current-buffer))))))))))
1103 (defun gnus-inews-insert-gcc ()
1104 "Insert Gcc headers based on `gnus-outgoing-message-group'."
1107 (message-narrow-to-headers)
1108 (let* ((group gnus-outgoing-message-group)
1110 ((gnus-functionp group)
1112 ((or (stringp group) (list group))
1116 (if (stringp gcc) gcc
1117 (mapconcat 'identity gcc " "))
1120 (defun gnus-inews-insert-archive-gcc (&optional group)
1121 "Insert the Gcc to say where the article is to be archived."
1122 (let* ((var gnus-message-archive-group)
1123 (group (or group gnus-newsgroup-name ""))
1125 (and gnus-newsgroup-name
1126 (gnus-group-find-parameter
1127 gnus-newsgroup-name 'gcc-self)))
1131 ((null gnus-message-archive-method)
1135 ;; Just a single group.
1138 ;; We don't want this.
1140 ((and (listp var) (stringp (car var)))
1141 ;; A list of groups.
1143 ((gnus-functionp var)
1145 (funcall var group))
1147 ;; An alist of regexps/functions/forms.
1152 ((stringp (caar var))
1154 (when (string-match (caar var) group)
1156 ((gnus-functionp (car var))
1158 (funcall (car var) group))
1160 (eval (car var)))))))
1161 (setq var (cdr var)))
1164 (when (or groups gcc-self-val)
1165 (when (stringp groups)
1166 (setq groups (list groups)))
1169 (message-narrow-to-headers)
1170 (goto-char (point-max))
1173 ;; Use the `gcc-self' param value instead.
1176 (if (stringp gcc-self-val)
1179 (if (not (eq gcc-self-val 'none))
1184 ;; Use the list of groups.
1185 (while (setq name (pop groups))
1186 (insert (if (string-match ":" name)
1188 (gnus-group-prefixed-name
1189 name gnus-message-archive-method)))
1196 (defun gnus-configure-posting-styles ()
1197 "Configure posting styles according to `gnus-posting-styles'."
1198 (unless gnus-inhibit-posting-styles
1199 (let ((group (or gnus-newsgroup-name ""))
1200 (styles gnus-posting-styles)
1201 style match variable attribute value v results
1202 filep name address element)
1203 ;; If the group has a posting-style parameter, add it at the end with a
1204 ;; regexp matching everything, to be sure it takes precedence over all
1206 (when gnus-newsgroup-name
1207 (let ((tmp-style (gnus-group-find-parameter group 'posting-style t)))
1209 (setq styles (append styles (list (cons ".*" tmp-style)))))))
1210 ;; Go through all styles and look for matches.
1211 (dolist (style styles)
1212 (setq match (pop style))
1215 ;; Regexp string match on the group name.
1216 (string-match match group))
1217 ((or (symbolp match)
1218 (gnus-functionp match))
1220 ((gnus-functionp match)
1221 ;; Function to be called.
1224 ;; Variable to be checked.
1225 (symbol-value match))))
1227 ;; This is a form to be evaled.
1229 ;; We have a match, so we set the variables.
1230 (dolist (attribute style)
1231 (setq element (pop attribute)
1236 ((eq (car attribute) ':file)
1239 ((eq (car attribute) :value)
1243 ;; We get the value.
1248 ((or (symbolp value)
1249 (gnus-functionp value))
1250 (cond ((gnus-functionp value)
1253 (symbol-value value))))
1256 ;; Translate obsolescent value.
1257 (when (eq element 'signature-file)
1258 (setq element 'signature
1260 ;; Get the contents of file elems.
1262 (setq v (with-temp-buffer
1263 (insert-file-contents v)
1265 (setq results (delq (assoc element results) results))
1266 (push (cons element v) results))))
1267 ;; Now we have all the styles, so we insert them.
1268 (setq name (assq 'name results)
1269 address (assq 'address results))
1270 (setq results (delq name (delq address results)))
1271 (make-local-variable 'message-setup-hook)
1272 (dolist (result results)
1274 (add-hook 'message-setup-hook
1276 ((eq 'eval (car result))
1278 ((eq 'body (car result))
1282 (insert ,(cdr result)))))
1283 ((eq 'signature (car result))
1284 (set (make-local-variable 'message-signature) nil)
1285 (set (make-local-variable 'message-signature-file) nil)
1288 (let ((message-signature ,(cdr result)))
1289 (message-insert-signature)))))
1292 (if (symbolp (car result))
1293 (capitalize (symbol-name (car result)))
1297 (message-remove-header ,header)
1299 (insert ,header ": " ,(cdr result) "\n")))))))))
1300 (when (or name address)
1301 (add-hook 'message-setup-hook
1303 (let ((user-full-name ,(or (cdr name) user-full-name))
1305 ,(or (cdr address) user-mail-address)))
1307 (message-remove-header "From")
1309 (insert "From: " (message-make-from) "\n")))))))))
1312 ;;; @ for MIME Edit mode
1315 (defun gnus-maybe-setup-default-charset ()
1317 (and (boundp 'gnus-summary-buffer)
1318 (buffer-live-p gnus-summary-buffer)
1320 (set-buffer gnus-summary-buffer)
1321 default-mime-charset))))
1324 (make-local-variable 'default-mime-charset)
1325 (setq default-mime-charset charset)
1329 ;;; Allow redefinition of functions.
1335 ;;; gnus-msg.el ends here