1 ;;; gnus-msg.el --- mail and post interface for Semi-gnus
2 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001
3 ;; Free Software Foundation, Inc.
5 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
6 ;; Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
8 ;; Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp>
9 ;; Katsumi Yamaoka <yamaoka@jpl.org>
10 ;; Kiyokazu SUTO <suto@merry.xmath.ous.ac.jp>
11 ;; Keywords: mail, news, MIME
13 ;; This file is part of GNU Emacs.
15 ;; GNU Emacs is free software; you can redistribute it and/or modify
16 ;; it under the terms of the GNU General Public License as published by
17 ;; the Free Software Foundation; either version 2, or (at your option)
20 ;; GNU Emacs is distributed in the hope that it will be useful,
21 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 ;; GNU General Public License for more details.
25 ;; You should have received a copy of the GNU General Public License
26 ;; along with GNU Emacs; see the file COPYING. If not, write to the
27 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
28 ;; Boston, MA 02111-1307, USA.
34 (eval-when-compile (require 'cl))
35 (eval-when-compile (require 'static))
42 (defcustom gnus-post-method 'current
43 "*Preferred method for posting USENET news.
45 If this variable is `current' (which is the default), Gnus will use
46 the \"current\" select method when posting. If it is nil, Gnus will
47 use the native select method when posting.
49 This method will not be used in mail groups and the like, only in
52 If not nil nor `native', the value must be a valid method as discussed
53 in the documentation of `gnus-select-method'. It can also be a list of
54 methods. If that is the case, the user will be queried for what select
55 method to use when posting."
56 :group 'gnus-group-foreign
57 :type `(choice (const nil)
60 (sexp :tag "Methods" ,gnus-select-method)))
62 (defcustom gnus-outgoing-message-group nil
63 "*All outgoing messages will be put in this group.
64 If you want to store all your outgoing mail and articles in the group
65 \"nnml:archive\", you set this variable to that value. This variable
66 can also be a list of group names.
68 If you want to have greater control over what group to put each
69 message in, you can set this variable to a function that checks the
70 current newsgroup name and then returns a suitable group name (or list
73 :type '(choice (string :tag "Group")
76 (defcustom gnus-mailing-list-groups nil
77 "*Regexp matching groups that are really mailing lists.
78 This is useful when you're reading a mailing list that has been
79 gatewayed to a newsgroup, and you want to followup to an article in
84 (defcustom gnus-add-to-list nil
85 "*If non-nil, add a `to-list' parameter automatically."
89 (defcustom gnus-crosspost-complaint
92 You posted the article below with the following Newsgroups header:
96 The %s group, at least, was an inappropriate recipient
97 of this message. Please trim your Newsgroups header to exclude this
98 group before posting in the future.
103 "Format string to be inserted when complaining about crossposts.
104 The first %s will be replaced by the Newsgroups header;
105 the second with the current group name."
109 (defcustom gnus-message-setup-hook '(gnus-maybe-setup-default-charset)
110 "Hook run after setting up a message buffer."
114 (defcustom gnus-bug-create-help-buffer t
115 "*Should we create the *Gnus Help Bug* buffer?"
119 (defcustom gnus-posting-styles nil
120 "*Alist of styles to use when posting."
122 :type '(repeat (cons (choice (regexp)
127 (choice (const signature)
128 (const signature-file)
133 (string :tag "Header"))
139 (defcustom gnus-inews-mark-gcc-as-read nil
140 "If non-nil, automatically mark Gcc articles as read."
144 (defcustom gnus-group-posting-charset-alist
145 '(("^\\(no\\|fr\\)\\.[^,]*\\(,[ \t\n]*\\(no\\|fr\\)\\.[^,]*\\)*$" iso-8859-1 (iso-8859-1))
146 ("^\\(fido7\\|relcom\\)\\.[^,]*\\(,[ \t\n]*\\(fido7\\|relcom\\)\\.[^,]*\\)*$" koi8-r (koi8-r))
147 (message-this-is-mail nil nil)
148 (message-this-is-news nil t))
149 "Alist of regexps and permitted unencoded charsets for posting.
150 Each element of the alist has the form (TEST HEADER BODY-LIST), where
151 TEST is either a regular expression matching the newsgroup header or a
153 HEADER is the charset which may be left unencoded in the header (nil
154 means encode all charsets),
155 BODY-LIST is a list of charsets which may be encoded using 8bit
156 content-transfer encoding in the body, or one of the special values
157 nil (always encode using quoted-printable) or t (always use 8bit).
159 Note that any value other than nil for HEADER infringes some RFCs, so
160 use this option with care."
161 :type '(repeat (list :tag "Permitted unencoded charsets"
163 (regexp :tag "Group")
164 (const :tag "Mail message"
165 :value message-this-is-mail)
166 (const :tag "News article"
167 :value message-this-is-news))
168 (choice :tag "Header"
169 (const :tag "None" nil)
170 (symbol :tag "Charset"))
172 (const :tag "Any" :value t)
173 (const :tag "None" :value nil)
174 (repeat :tag "Charsets"
175 (symbol :tag "Charset")))))
176 :group 'gnus-charset)
178 ;;; Internal variables.
180 (defvar gnus-inhibit-posting-styles nil
181 "Inhibit the use of posting styles.")
183 (defvar gnus-message-buffer "*Mail Gnus*")
184 (defvar gnus-article-copy nil)
185 (defvar gnus-check-before-posting nil)
186 (defvar gnus-last-posting-server nil)
187 (defvar gnus-message-group-art nil)
189 (defvar gnus-msg-force-broken-reply-to nil)
191 (defconst gnus-bug-message
192 (format "Sending a bug report to the Gnus Towers.
193 ========================================
195 This gnus is the %s%s.
196 If you think the bug is a Semi-gnus bug, send a bug report to Semi-gnus
197 Developers. (the addresses below are mailing list addresses)
199 ========================================
201 The buffer below is a mail buffer. When you press `C-c C-c', it will
202 be sent to the Gnus Bug Exterminators.
204 The thing near the bottom of the buffer is how the environment
205 settings will be included in the mail. Please do not delete that.
206 They will tell the Bug People what your environment is, so that it
207 will be easier to locate the bugs.
209 If you have found a bug that makes Emacs go \"beep\", set
210 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
211 and include the backtrace in your bug report.
213 Please describe the bug in annoying, painstaking detail.
215 Thank you for your help in stamping out bugs.
218 (if (string= gnus-product-name "Semi-gnus")
220 ", a modified version of Semi-gnus")))
223 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
224 (autoload 'news-setup "rnewspost")
225 (autoload 'news-reply-mode "rnewspost")
226 (autoload 'rmail-dont-reply-to "mail-utils")
227 (autoload 'rmail-output "rmailout"))
231 ;;; Gnus Posting Functions
234 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
235 "p" gnus-summary-post-news
236 "f" gnus-summary-followup
237 "F" gnus-summary-followup-with-original
238 "c" gnus-summary-cancel-article
239 "s" gnus-summary-supersede-article
240 "r" gnus-summary-reply
241 "y" gnus-summary-yank-message
242 "R" gnus-summary-reply-with-original
243 "w" gnus-summary-wide-reply
244 "W" gnus-summary-wide-reply-with-original
245 "v" gnus-summary-very-wide-reply
246 "V" gnus-summary-very-wide-reply-with-original
247 "n" gnus-summary-followup-to-mail
248 "N" gnus-summary-followup-to-mail-with-original
249 "m" gnus-summary-mail-other-window
250 "u" gnus-uu-post-news
251 "\M-c" gnus-summary-mail-crosspost-complaint
252 "Br" gnus-summary-reply-broken-reply-to
253 "BR" gnus-summary-reply-broken-reply-to-with-original
254 "om" gnus-summary-mail-forward
255 "op" gnus-summary-post-forward
256 "Om" gnus-summary-digest-mail-forward
257 "Op" gnus-summary-digest-post-forward)
259 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
260 "b" gnus-summary-resend-bounced-mail
261 ;; "c" gnus-summary-send-draft
262 "r" gnus-summary-resend-message)
264 ;;; Internal functions.
266 (defvar gnus-article-reply nil)
267 (defmacro gnus-setup-message (config &rest forms)
268 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
269 (buffer (make-symbol "gnus-setup-message-buffer"))
270 (article (make-symbol "gnus-setup-message-article"))
271 (group (make-symbol "gnus-setup-message-group")))
272 `(let ((,winconf (current-window-configuration))
273 (,buffer (buffer-name (current-buffer)))
274 (,article gnus-article-reply)
275 (,group gnus-newsgroup-name)
276 (message-header-setup-hook
277 (copy-sequence message-header-setup-hook))
278 (message-mode-hook (copy-sequence message-mode-hook))
279 (message-startup-parameter-alist
280 '((reply-buffer . gnus-copy-article-buffer)
281 (original-buffer . gnus-original-article-buffer)
282 (user-agent . Gnus))))
283 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
284 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
285 (add-hook 'message-mode-hook 'gnus-configure-posting-styles)
289 (gnus-inews-add-send-actions ,winconf ,buffer ,article ,config)
290 (gnus-inews-insert-draft-meta-information ,group ,article)
291 (setq gnus-message-buffer (current-buffer))
292 (set (make-local-variable 'gnus-message-group-art)
293 (cons ,group ,article))
294 (set (make-local-variable 'gnus-newsgroup-name) ,group)
295 (gnus-run-hooks 'gnus-message-setup-hook))
297 (gnus-configure-windows ,config t)
298 (set-buffer-modified-p nil))))
300 (defun gnus-inews-insert-draft-meta-information (group article)
303 (not (string= group ""))
304 (not (message-fetch-field gnus-draft-meta-information-header)))
305 (goto-char (point-min))
306 (insert gnus-draft-meta-information-header ": (\"" group "\" "
307 (if article (number-to-string
314 (defun gnus-msg-mail (&optional to subject other-headers continue
315 switch-action yank-action send-actions)
316 "Start editing a mail message to be sent.
317 Like `message-mail', but with Gnus paraphernalia, particularly the
318 Gcc: header for archiving purposes."
320 (let ((buf (current-buffer))
322 (gnus-setup-message 'message
323 (message-mail to subject other-headers continue
324 nil yank-action send-actions))
326 (setq mail-buf (current-buffer))
327 (switch-to-buffer buf)
328 (apply switch-action mail-buf nil)))
329 ;; COMPOSEFUNC should return t if succeed. Undocumented ???
333 (defun gnus-button-mailto (address)
335 (set-buffer (gnus-copy-article-buffer))
336 (gnus-setup-message 'message
337 (message-reply address)))
340 (defun gnus-button-reply (&optional to-address wide)
341 "Like `message-reply'."
343 (gnus-setup-message 'message
344 (message-reply to-address wide)))
347 (define-mail-user-agent 'gnus-user-agent
348 'gnus-msg-mail 'message-send-and-exit
349 'message-kill-buffer 'message-send-hook)
351 (defun gnus-setup-posting-charset (group)
352 (let ((alist gnus-group-posting-charset-alist)
353 (group (or group ""))
357 (while (setq elem (pop alist))
358 (when (or (and (stringp (car elem))
359 (string-match (car elem) group))
360 (and (gnus-functionp (car elem))
361 (funcall (car elem) group))
362 (and (symbolp (car elem))
363 (symbol-value (car elem))))
364 (throw 'found (cons (cadr elem) (caddr elem)))))))))
366 (defun gnus-inews-add-send-actions (winconf buffer article &optional config)
367 (make-local-hook 'message-sent-hook)
368 (add-hook 'message-sent-hook (if gnus-agent 'gnus-agent-possibly-do-gcc
369 'gnus-inews-do-gcc) nil t)
371 (make-local-hook 'message-header-hook)
372 (add-hook 'message-header-hook 'gnus-agent-possibly-save-gcc nil t))
373 (setq message-post-method
375 (gnus-post-method arg ,gnus-newsgroup-name)))
376 (setq message-user-agent (gnus-extended-version))
377 (when (not message-use-multi-frames)
379 `(set-window-configuration ,winconf) 'exit 'postpone 'kill))
381 `(when (gnus-buffer-exists-p ,buffer)
385 (if (eq config 'forward)
386 `(gnus-summary-mark-article-as-forwarded ',article)
387 `(gnus-summary-mark-article-as-replied ',article)))))
390 (put 'gnus-setup-message 'lisp-indent-function 1)
391 (put 'gnus-setup-message 'edebug-form-spec '(form body))
393 ;;; Post news commands of Gnus group mode and summary mode
395 (defun gnus-group-mail (&optional arg)
396 "Start composing a mail.
397 If ARG, use the group under the point to find a posting style.
398 If ARG is 1, prompt for a group name to find the posting style."
400 ;; We can't `let' gnus-newsgroup-name here, since that leads
401 ;; to local variables leaking.
402 (let ((group gnus-newsgroup-name)
403 (buffer (current-buffer)))
406 (setq gnus-newsgroup-name
408 (if (= 1 (prefix-numeric-value arg))
409 (completing-read "Use posting style of group: "
410 gnus-active-hashtb nil
411 (gnus-read-active-file-p))
412 (gnus-group-group-name))
414 (gnus-setup-message 'message (message-mail)))
417 (setq gnus-newsgroup-name group)))))
419 (defun gnus-group-post-news (&optional arg)
420 "Start composing a news message.
421 If ARG, post to the group under point.
422 If ARG is 1, prompt for a group name."
424 ;; Bind this variable here to make message mode hooks work ok.
425 (let ((gnus-newsgroup-name
427 (if (= 1 (prefix-numeric-value arg))
428 (completing-read "Newsgroup: " gnus-active-hashtb nil
429 (gnus-read-active-file-p))
430 (gnus-group-group-name))
432 (gnus-post-news 'post gnus-newsgroup-name)))
434 (defun gnus-summary-post-news ()
435 "Start composing a news message."
437 (gnus-post-news 'post gnus-newsgroup-name))
439 (defun gnus-summary-followup (yank &optional force-news)
440 "Compose a followup to an article.
441 If prefix argument YANK is non-nil, original article is yanked automatically."
443 (list (and current-prefix-arg
444 (gnus-summary-work-articles 1))))
446 (gnus-summary-goto-subject (car yank)))
447 (save-window-excursion
448 (gnus-summary-select-article))
449 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
450 (gnus-newsgroup-name gnus-newsgroup-name))
452 (gnus-post-news nil gnus-newsgroup-name
453 headers gnus-article-buffer
454 yank nil force-news)))
456 (defun gnus-summary-followup-with-original (n &optional force-news)
457 "Compose a followup to an article and include the original article."
459 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
461 (defun gnus-summary-followup-to-mail (&optional arg)
462 "Followup to the current mail message via news."
464 (list (and current-prefix-arg
465 (gnus-summary-work-articles 1))))
466 (gnus-summary-followup arg t))
468 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
469 "Followup to the current mail message via news."
471 (gnus-summary-followup (gnus-summary-work-articles arg) t))
473 (defun gnus-inews-yank-articles (articles)
474 (let ((more-than-one (cdr articles))
475 (cur (current-buffer))
476 refs beg article window)
478 (while (setq article (pop articles))
479 (save-window-excursion
480 (set-buffer gnus-summary-buffer)
481 (gnus-summary-select-article nil nil nil article)
482 (gnus-summary-remove-process-mark article))
484 ;; Gathering references.
486 (setq refs (message-list-references
488 (mail-header-references gnus-current-headers)
489 (mail-header-message-id gnus-current-headers)))
490 (when message-use-multi-frames
491 (when (setq window (get-buffer-window cur t))
492 (select-frame (window-frame window)))))
494 (gnus-copy-article-buffer)
495 (let ((message-reply-buffer gnus-article-copy)
496 (message-reply-headers
497 (with-current-buffer gnus-article-copy
498 ;; The headers are decoded.
499 (nnheader-parse-head t))))
500 (message-yank-original)
501 (setq beg (or beg (mark t))))
506 ;; Replace with the gathered references.
510 (message-narrow-to-headers)
511 (let ((case-fold-search t))
512 (if (re-search-forward "^References:\\([\t ]+.+\n\\)+" nil t)
514 (goto-char (point-max))))
516 (list (or (assq 'References message-header-format-alist)
517 '(References . message-shorten-references)))
518 (list (cons 'References
519 (mapconcat 'identity (nreverse refs) " "))))
520 (backward-delete-char 1))
526 (defun gnus-summary-cancel-article (&optional n symp)
527 "Cancel an article you posted.
528 Uses the process-prefix convention. If given the symbolic
529 prefix `a', cancel using the standard posting method; if not
530 post using the current select method."
531 (interactive (gnus-interactive "P\ny"))
532 (let ((articles (gnus-summary-work-articles n))
535 (gnus-post-method (not (eq symp 'a)) ,gnus-newsgroup-name)))
537 (while (setq article (pop articles))
538 (when (gnus-summary-select-article t nil nil article)
539 (when (gnus-eval-in-buffer-window gnus-article-buffer
541 (set-buffer gnus-original-article-buffer)
542 (message-cancel-news)))
543 (gnus-summary-mark-as-read article gnus-canceled-mark)
544 (gnus-cache-remove-article 1))
545 (gnus-article-hide-headers-if-wanted))
546 (gnus-summary-remove-process-mark article))))
548 (defun gnus-summary-supersede-article ()
549 "Compose an article that will supersede a previous article.
550 This is done simply by taking the old article and adding a Supersedes
551 header line with the old Message-ID."
553 (let ((article (gnus-summary-article-number))
554 (gnus-message-setup-hook '(gnus-maybe-setup-default-charset)))
555 (gnus-setup-message 'reply-yank
556 (gnus-summary-select-article t)
557 (set-buffer gnus-original-article-buffer)
561 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
563 (set-buffer ,gnus-summary-buffer)
564 (gnus-cache-possibly-remove-article ,article nil nil nil t)
565 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
566 message-send-actions))))
570 (defun gnus-copy-article-buffer (&optional article-buffer)
571 ;; make a copy of the article buffer with all text properties removed
572 ;; this copy is in the buffer gnus-article-copy.
573 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
574 ;; this buffer should be passed to all mail/news reply/post routines.
575 (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
576 (let ((article-buffer (or article-buffer gnus-article-buffer))
578 (if (not (and (get-buffer article-buffer)
579 (gnus-buffer-exists-p article-buffer)))
580 (error "Can't find any article buffer")
582 (set-buffer article-buffer)
583 (let ((gnus-newsgroup-charset (or gnus-article-charset
584 gnus-newsgroup-charset))
585 (gnus-newsgroup-ignored-charsets
586 (or gnus-article-ignored-charsets
587 gnus-newsgroup-ignored-charsets)))
589 ;; Copy over the (displayed) article buffer, delete
590 ;; hidden text and remove text properties.
592 (let ((inhibit-read-only t))
593 (copy-to-buffer gnus-article-copy (point-min) (point-max))
594 (set-buffer gnus-article-copy)
595 ;; Encode bitmap smileys to ordinary text.
596 ;; Possibly, the original text might be restored.
597 (static-unless (featurep 'xemacs)
598 (when (featurep 'smiley-mule)
599 (smiley-encode-buffer)))
600 (gnus-article-delete-text-of-type 'annotation)
601 (gnus-remove-text-with-property 'gnus-prev)
602 (gnus-remove-text-with-property 'gnus-next)
603 (gnus-remove-text-with-property 'x-face-mule-bitmap-image)
606 (static-if (featurep 'xemacs)
607 ;; Revome smiley extents for (possibly) XEmacs 21.1.
609 (buffer-substring-no-properties (point-min)
611 (buffer-substring-no-properties (point-min) (point-max)))
613 ;; Find the original headers.
614 (set-buffer gnus-original-article-buffer)
615 (goto-char (point-min))
616 (while (looking-at message-unix-mail-delimiter)
619 (setq end (or (message-goto-body) beg))
620 ;; Delete the headers from the displayed articles.
621 (set-buffer gnus-article-copy)
622 (delete-region (goto-char (point-min))
623 (or (message-goto-body) (point-max)))
624 ;; Insert the original article headers.
625 (insert-buffer-substring gnus-original-article-buffer beg end)
626 (article-decode-encoded-words))))
629 (defun gnus-post-news (post &optional group header article-buffer yank subject
632 (gnus-copy-article-buffer))
633 (let ((gnus-article-reply (and article-buffer (gnus-summary-article-number)))
634 (add-to-list gnus-add-to-list))
635 (gnus-setup-message (cond (yank 'reply-yank)
636 (article-buffer 'reply)
638 (let* ((group (or group gnus-newsgroup-name))
639 (charset (gnus-group-name-charset nil group))
641 to-address to-group mailing-list to-list
644 (setq to-address (gnus-parameter-to-address group)
645 to-group (gnus-group-find-parameter group 'to-group)
646 to-list (gnus-parameter-to-list group)
647 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
648 mailing-list (when gnus-mailing-list-groups
649 (string-match gnus-mailing-list-groups group))
650 group (gnus-group-name-decode (gnus-group-real-name group)
652 (if (or (and to-group
653 (gnus-news-group-p to-group))
656 (and (gnus-news-group-p
657 (or pgroup gnus-newsgroup-name)
658 (if header (mail-header-number header)
659 gnus-current-article))
665 (message-news (or to-group group))
666 (set-buffer gnus-article-copy)
667 (gnus-msg-treat-broken-reply-to)
668 (message-followup (if (or newsgroup-p force-news)
669 (if (save-restriction
670 (article-narrow-to-head)
671 (message-fetch-field "newsgroups"))
678 (message-mail (or to-address to-list))
679 ;; Arrange for mail groups that have no `to-address' to
680 ;; get that when the user sends off the mail.
681 (when (and (not to-list)
684 (push (list 'gnus-inews-add-to-address pgroup)
685 message-send-actions)))
686 (set-buffer gnus-article-copy)
687 (gnus-msg-treat-broken-reply-to)
688 (message-wide-reply to-address)))
690 (gnus-inews-yank-articles yank))))))
692 (defun gnus-msg-treat-broken-reply-to (&optional force)
693 "Remove the Reply-to header iff broken-reply-to."
695 (gnus-group-find-parameter
696 gnus-newsgroup-name 'broken-reply-to))
698 (message-narrow-to-head)
699 (message-remove-header "reply-to"))))
701 (defun gnus-post-method (arg group &optional silent)
702 "Return the posting method based on GROUP and ARG.
703 If SILENT, don't prompt the user."
704 (let ((gnus-post-method (or (gnus-parameter-post-method group)
706 (group-method (gnus-find-method-for-group group)))
708 ;; If the group-method is nil (which shouldn't happen) we use
709 ;; the default method.
711 (or (and (null (eq gnus-post-method 'active)) gnus-post-method)
712 gnus-select-method message-post-method))
713 ;; We want the inverse of the default
714 ((and arg (not (eq arg 0)))
715 (if (eq gnus-post-method 'active)
718 ;; We query the user for a post method.
720 (and gnus-post-method
721 (not (eq gnus-post-method 'current))
722 (listp (car gnus-post-method))))
724 ;; Collect all methods we know about.
726 (when (and gnus-post-method
727 (not (eq gnus-post-method 'current)))
728 (if (listp (car gnus-post-method))
730 (list gnus-post-method)))
731 gnus-secondary-select-methods
732 (mapcar 'cdr gnus-server-alist)
733 (mapcar 'car gnus-opened-servers)
734 (list gnus-select-method)
735 (list group-method)))
736 method-alist post-methods method)
737 ;; Weed out all mail methods.
739 (setq method (gnus-server-get-method "" (pop methods)))
740 (when (and (or (gnus-method-option-p method 'post)
741 (gnus-method-option-p method 'post-mail))
742 (not (member method post-methods)))
743 (push method post-methods)))
744 ;; Create a name-method alist.
748 (if (equal (cadr m) "")
749 (list (symbol-name (car m)) m)
750 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m)))
755 (setq gnus-last-posting-server
757 gnus-last-posting-server)
758 ;; Just use the last value.
759 gnus-last-posting-server
761 "Posting method: " method-alist nil t
762 (cons (or gnus-last-posting-server "") 0))))
764 ;; Override normal method.
765 ((and (eq gnus-post-method 'current)
766 (not (eq (car group-method) 'nndraft))
767 (gnus-get-function group-method 'request-post t)
770 ((and gnus-post-method
771 (not (eq gnus-post-method 'current)))
773 ;; Use the normal select method.
774 (t gnus-select-method))))
777 (defun gnus-message-make-user-agent (&optional include-mime-info max-column
779 "Return a user-agent info. If INCLUDE-MIME-INFO is non-nil and the
780 variable `mime-edit-user-agent-value' is bound, the value will be
781 included in the return value. If MAX-COLUMN is specified, the return
782 value will be folded up as it were filled. NEWLINE-PRODUCT specifies
783 whether a newline should be inserted in front of each product-token.
784 If the value is t or `hard', it works strictly. Otherwise, if it is
785 non-nil (e.g. `soft'), it works semi-strictly.
787 Here is an example of how to use this function:
789 \(add-hook 'gnus-message-setup-hook
791 (setq message-user-agent nil)
794 (message-narrow-to-headers)
795 (goto-char (point-max))
796 (insert \"User-Agent: \"
797 (gnus-message-make-user-agent t 76 'soft)
800 (let ((user-agent (if (and include-mime-info
801 (boundp 'mime-edit-user-agent-value))
802 (concat (gnus-extended-version)
804 mime-edit-user-agent-value)
805 (gnus-extended-version))))
807 (unless (natnump max-column)
808 (setq max-column 76))
810 (set-buffer-multibyte t)
811 (insert (mapconcat 'identity (split-string user-agent) " "))
812 (goto-char (point-min))
814 start agent agents width element swidth)
815 (while (re-search-forward "\\([^ ]+\\) ?" nil t)
816 (setq start (match-beginning 0))
817 (if (eq (char-after start) ?\()
821 (push (buffer-substring start (point)) agent))
823 (push (nreverse agent) agents))
824 (setq agent (list (match-string 1)))))
826 (push (nreverse agent) agents))
827 (setq agents (nreverse agents))
828 (if (> (+ 12 (string-width (caar agents))) max-column)
829 (setq user-agent "\n"
834 (setq agent (car agents)
837 (or (memq newline-product '(t hard))
840 (string-width (mapconcat 'identity
843 (setq user-agent (concat user-agent "\n")
847 (setq element (car agent)
848 swidth (string-width element)
851 (setq user-agent (if (member user-agent '("" "\n"))
852 (concat user-agent element)
853 (concat user-agent " " element))
854 width (+ width 1 swidth)
856 (if (> (+ width 1 swidth) max-column)
857 (setq user-agent (concat user-agent "\n " element)
859 (setq user-agent (concat user-agent " " element)
860 width (+ width 1 swidth)))))))))
865 ;;; Gnus Mail Functions
868 ;;; Mail reply commands of Gnus summary mode
870 (defun gnus-summary-reply (&optional yank wide very-wide)
871 "Start composing a mail reply to the current message.
872 If prefix argument YANK is non-nil, the original article is yanked
874 If WIDE, make a wide reply.
875 If VERY-WIDE, make a very wide reply."
877 (list (and current-prefix-arg
878 (gnus-summary-work-articles 1))))
879 ;; Stripping headers should be specified with mail-yank-ignored-headers.
881 (gnus-summary-goto-subject (car yank)))
882 (let ((gnus-article-reply (or yank (gnus-summary-article-number)))
884 (gnus-setup-message (if yank 'reply-yank 'reply)
886 (gnus-summary-select-article)
887 (dolist (article very-wide)
888 (gnus-summary-select-article nil nil nil article)
890 (set-buffer (gnus-copy-article-buffer))
891 (gnus-msg-treat-broken-reply-to)
893 (message-narrow-to-head)
894 (setq headers (concat headers (buffer-string)))))))
895 (set-buffer (gnus-copy-article-buffer))
896 (gnus-msg-treat-broken-reply-to gnus-msg-force-broken-reply-to)
898 (message-narrow-to-head)
902 (goto-char (point-max)))
903 (message-reply nil wide)
905 (gnus-inews-yank-articles yank)))))
907 (defun gnus-summary-reply-with-original (n &optional wide)
908 "Start composing a reply mail to the current message.
909 The original article will be yanked."
911 (gnus-summary-reply (gnus-summary-work-articles n) wide))
913 (defun gnus-summary-reply-broken-reply-to (&optional yank wide very-wide)
914 "Like `gnus-summary-reply' except removing reply-to field.
915 If prefix argument YANK is non-nil, the original article is yanked
917 If WIDE, make a wide reply.
918 If VERY-WIDE, make a very wide reply."
920 (list (and current-prefix-arg
921 (gnus-summary-work-articles 1))))
922 (let ((gnus-msg-force-broken-reply-to t))
923 (gnus-summary-reply yank wide very-wide)))
925 (defun gnus-summary-reply-broken-reply-to-with-original (n &optional wide)
926 "Like `gnus-summary-reply-with-original' except removing reply-to field.
927 The original article will be yanked."
929 (gnus-summary-reply-broken-reply-to (gnus-summary-work-articles n) wide))
931 (defun gnus-summary-wide-reply (&optional yank)
932 "Start composing a wide reply mail to the current message.
933 If prefix argument YANK is non-nil, the original article is yanked
936 (list (and current-prefix-arg
937 (gnus-summary-work-articles 1))))
938 (gnus-summary-reply yank t))
940 (defun gnus-summary-wide-reply-with-original (n)
941 "Start composing a wide reply mail to the current message.
942 The original article will be yanked."
944 (gnus-summary-reply-with-original n t))
946 (defun gnus-summary-very-wide-reply (&optional yank)
947 "Start composing a very wide reply mail to the current message.
948 If prefix argument YANK is non-nil, the original article is yanked
951 (list (and current-prefix-arg
952 (gnus-summary-work-articles 1))))
953 (gnus-summary-reply yank t (gnus-summary-work-articles yank)))
955 (defun gnus-summary-very-wide-reply-with-original (n)
956 "Start composing a very wide reply mail to the current message.
957 The original article will be yanked."
960 (gnus-summary-work-articles n) t (gnus-summary-work-articles n)))
962 (defun gnus-summary-mail-forward (&optional full-headers post)
963 "Forward the current message to another user.
964 If FULL-HEADERS (the prefix), include full headers when forwarding."
966 (gnus-setup-message 'forward
967 (gnus-summary-select-article)
968 (let ((charset default-mime-charset))
969 (set-buffer gnus-original-article-buffer)
970 (make-local-variable 'default-mime-charset)
971 (setq default-mime-charset charset))
972 (let ((message-included-forward-headers
973 (if full-headers "" message-included-forward-headers)))
974 (message-forward post))))
976 (defun gnus-summary-digest-mail-forward (&optional n post)
977 "Digests and forwards all articles in this series.
978 If N is a positive number, forward the N next articles.
979 If N is a negative number, forward the N previous articles.
980 If N is nil and any articles have been marked with the process mark,
981 forward those articles instead.
982 Optional POST will use news to forward instead of mail."
984 (let ((articles (gnus-summary-work-articles n))
986 subject article frame)
988 (gnus-setup-message 'forward
989 (gnus-summary-select-article)
991 (setq articles (sort articles '<)
992 subject "Digested Articles")
993 (with-current-buffer gnus-original-article-buffer
994 (setq subject (message-make-forward-subject))))
996 (message-news nil subject)
997 (message-mail nil subject))
998 (when (and message-use-multi-frames (cdr articles))
999 (setq frame (window-frame (get-buffer-window (current-buffer)))))
1001 (while (setq article (pop articles))
1002 (save-window-excursion
1003 (set-buffer gnus-summary-buffer)
1004 (gnus-summary-select-article nil nil nil article)
1005 (setq topics (concat topics " "
1006 (mail-header-subject gnus-current-headers)
1008 (gnus-summary-remove-process-mark article))
1010 (select-frame frame))
1011 (insert (mime-make-tag "message" "rfc822") "\n")
1012 (narrow-to-region (point) (point))
1013 (insert-buffer-substring gnus-original-article-buffer)
1015 (article-narrow-to-head)
1016 (message-remove-header message-included-forward-headers t nil t))
1017 (goto-char (point-max))
1023 (mime-edit-enclose-digest-region (point)(mark t))))))
1025 (defun gnus-summary-digest-post-forward (&optional n)
1026 "Digest and forwards all articles in this series to a newsgroup.
1027 If N is a positive number, forward the N next articles.
1028 If N is a negative number, forward the N previous articles.
1029 If N is nil and any articles have been marked with the process mark,
1030 forward those articles instead."
1032 (gnus-summary-digest-mail-forward n t))
1034 (defun gnus-summary-resend-message (address n)
1035 "Resend the current article to ADDRESS."
1037 (list (message-read-from-minibuffer "Resend message(s) to: ")
1038 current-prefix-arg))
1039 (let ((articles (gnus-summary-work-articles n))
1041 (while (setq article (pop articles))
1042 (gnus-summary-select-article nil nil nil article)
1044 (set-buffer gnus-original-article-buffer)
1045 (message-resend address))
1046 (gnus-summary-mark-article-as-forwarded article))))
1048 (defun gnus-summary-post-forward (&optional full-headers)
1049 "Forward the current article to a newsgroup.
1050 If FULL-HEADERS (the prefix), include full headers when forwarding."
1052 (gnus-summary-mail-forward full-headers t))
1054 (defvar gnus-nastygram-message
1055 "The following article was inappropriately posted to %s.\n\n"
1056 "Format string to insert in nastygrams.
1057 The current group name will be inserted at \"%s\".")
1059 (defun gnus-summary-mail-nastygram (n)
1060 "Send a nastygram to the author of the current article."
1062 (when (or gnus-expert-user
1064 "Really send a nastygram to the author of the current article? "))
1065 (let ((group gnus-newsgroup-name))
1066 (gnus-summary-reply-with-original n)
1067 (set-buffer gnus-message-buffer)
1069 (insert (format gnus-nastygram-message group))
1070 (message-send-and-exit))))
1072 (defun gnus-summary-mail-crosspost-complaint (n)
1073 "Send a complaint about crossposting to the current article(s)."
1075 (let ((articles (gnus-summary-work-articles n))
1077 (while (setq article (pop articles))
1078 (set-buffer gnus-summary-buffer)
1079 (gnus-summary-goto-subject article)
1080 (let ((group (gnus-group-real-name gnus-newsgroup-name))
1081 newsgroups followup-to)
1082 (gnus-summary-select-article)
1083 (set-buffer gnus-original-article-buffer)
1084 (if (and (<= (length (message-tokenize-header
1086 (mail-fetch-field "newsgroups"))
1089 (or (not (setq followup-to (mail-fetch-field "followup-to")))
1090 (not (member group (message-tokenize-header
1091 followup-to ", ")))))
1093 (gnus-message 1 "Followup-to restricted")
1094 (gnus-message 1 "Not a crossposted article"))
1095 (set-buffer gnus-summary-buffer)
1096 (gnus-summary-reply-with-original 1)
1097 (set-buffer gnus-message-buffer)
1099 (insert (format gnus-crosspost-complaint newsgroups group))
1100 (message-goto-subject)
1101 (re-search-forward " *$")
1102 (replace-match " (crosspost notification)" t t)
1103 (gnus-deactivate-mark)
1104 (when (gnus-y-or-n-p "Send this complaint? ")
1105 (message-send-and-exit)))))))
1107 (defun gnus-summary-mail-other-window ()
1108 "Compose mail in other window."
1110 (gnus-setup-message 'message
1113 (defun gnus-mail-parse-comma-list ()
1116 (skip-chars-forward " ")
1119 (skip-chars-forward "^,")
1124 (narrow-to-region beg (point))
1127 (while (search-forward "\"" nil t)
1131 (skip-chars-forward ",")
1132 (skip-chars-forward "^,"))
1133 (skip-chars-backward " ")
1134 (push (buffer-substring beg (point))
1136 (skip-chars-forward "^,")
1137 (skip-chars-forward ", "))
1140 (defun gnus-inews-add-to-address (group)
1141 (let ((to-address (mail-fetch-field "to")))
1142 (when (and to-address
1144 ;; This mail group doesn't have a `to-list', so we add one
1146 (when (gnus-y-or-n-p
1147 (format "Do you want to add this as `to-list': %s " to-address))
1148 (gnus-group-add-parameter group (cons 'to-list to-address))))))
1150 (defun gnus-put-message ()
1151 "Put the current message in some group and return to Gnus."
1153 (let ((reply gnus-article-reply)
1154 (winconf gnus-prev-winconf)
1155 (group gnus-newsgroup-name))
1157 (not (gnus-group-read-only-p group)))
1158 (setq group (read-string "Put in group: " nil (gnus-writable-groups))))
1160 (when (gnus-gethash group gnus-newsrc-hashtb)
1161 (error "No such group: %s" group))
1165 (message-narrow-to-headers)
1166 (let ((gnus-deletable-headers nil))
1167 (message-generate-headers
1168 (if (message-news-p)
1169 message-required-news-headers
1170 message-required-mail-headers)))
1171 (goto-char (point-max))
1172 (insert "Gcc: " group "\n")
1175 (when (and (get-buffer gnus-group-buffer)
1176 (gnus-buffer-exists-p (car-safe reply))
1178 (set-buffer (car reply))
1179 (gnus-summary-mark-article-as-replied (cdr reply)))
1181 (set-window-configuration winconf))))
1183 (defun gnus-article-mail (yank)
1184 "Send a reply to the address near point.
1185 If YANK is non-nil, include the original article."
1189 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
1190 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
1192 (message-reply address)
1194 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
1196 (defvar nntp-server-type)
1198 "Send a bug report to the Gnus maintainers."
1200 (unless (gnus-alive-p)
1201 (error "Gnus has been shut down"))
1202 (gnus-setup-message (if (message-mail-user-agent) 'message 'bug)
1203 (unless (message-mail-user-agent)
1204 (message-pop-to-buffer "*Gnus Bug*")
1205 (delete-other-windows)
1206 (when gnus-bug-create-help-buffer
1207 (switch-to-buffer "*Gnus Help Bug*")
1209 (insert gnus-bug-message)
1210 (goto-char (point-min))
1212 (set-buffer "*Gnus Bug*")))
1213 (let ((message-this-is-mail t))
1214 (message-setup `((To . ,gnus-maintainer) (Subject . ""))))
1215 (when gnus-bug-create-help-buffer
1216 (push `(gnus-bug-kill-buffer) message-send-actions))
1217 (goto-char (point-min))
1218 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
1220 (insert gnus-product-name " " gnus-version-number
1221 " (r" gnus-revision-number ") "
1222 "based on " gnus-original-product-name " v"
1223 gnus-original-version-number "\n"
1224 (emacs-version) "\n")
1225 (when (and (boundp 'nntp-server-type)
1226 (stringp nntp-server-type))
1227 (insert nntp-server-type))
1228 (insert "\n\n\n\n\n")
1229 (let (mime-content-types)
1230 (mime-edit-insert-tag "text" "plain" "; type=emacs-lisp"))
1231 (insert (with-temp-buffer
1234 (let (mime-content-types)
1235 (mime-edit-insert-tag "text" "plain"))
1236 (goto-char (point-min))
1237 (search-forward "Subject: " nil t)
1240 (defun gnus-bug-kill-buffer ()
1241 (when (get-buffer "*Gnus Help Bug*")
1242 (kill-buffer "*Gnus Help Bug*")))
1244 (defun gnus-summary-yank-message (buffer n)
1245 "Yank the current article into a composed message."
1247 (list (completing-read "Buffer: " (mapcar 'list (message-buffers)) nil t)
1248 current-prefix-arg))
1249 (when (gnus-buffer-live-p buffer)
1250 (let ((summary-frame (selected-frame))
1251 (message-frame (when (static-if (featurep 'xemacs)
1252 (device-on-window-system-p)
1254 (let ((window (get-buffer-window buffer t)))
1256 (window-frame window)))))
1257 (separator (concat "^" (regexp-quote mail-header-separator)
1259 (gnus-summary-iterate n
1260 (gnus-summary-select-article)
1261 (gnus-copy-article-buffer)
1262 (when (frame-live-p message-frame)
1263 (raise-frame message-frame)
1264 (select-frame message-frame))
1265 (with-current-buffer buffer
1266 (when (save-excursion
1268 (let (case-fold-search)
1269 (and (not (re-search-backward separator nil t))
1270 (re-search-forward separator nil t))))
1271 (goto-char (match-end 0)))
1272 (message-yank-buffer gnus-article-copy))
1273 (select-frame summary-frame))
1274 (when (frame-live-p message-frame)
1275 (select-frame message-frame)))))
1277 (defun gnus-debug ()
1278 "Attempts to go through the Gnus source file and report what variables have been changed.
1279 The source file has to be in the Emacs load path."
1281 (let ((files '("gnus.el" "gnus-sum.el" "gnus-group.el"
1282 "gnus-art.el" "gnus-start.el" "gnus-async.el"
1283 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
1284 "nnmail.el" "nntp.el" "message.el"))
1286 file expr olist sym)
1287 (gnus-message 4 "Please wait while we snoop your variables...")
1288 ;; Go through all the files looking for non-default values for variables.
1291 (set-buffer (gnus-get-buffer-create " *gnus bug info*"))
1294 (when (and (setq file (locate-library (pop files)))
1295 (file-exists-p file))
1296 (insert-file-contents file)
1297 (goto-char (point-min))
1298 (if (not (re-search-forward "^;;* *Internal variables" nil t))
1299 (gnus-message 4 "Malformed sources in file %s" file)
1300 (narrow-to-region (point-min) (point))
1301 (goto-char (point-min))
1302 (while (setq expr (ignore-errors (read (current-buffer))))
1304 (and (memq (car expr) '(defvar defcustom defvoo))
1305 (stringp (nth 3 expr))
1306 (or (not (boundp (nth 1 expr)))
1307 (not (equal (eval (nth 2 expr))
1308 (symbol-value (nth 1 expr)))))
1309 (push (nth 1 expr) olist)))))))
1310 (kill-buffer (current-buffer)))
1311 (when (setq olist (nreverse olist))
1312 (insert ";----------------- Environment follows ------------------\n\n"))
1314 (if (boundp (car olist))
1316 (pp `(setq ,(car olist)
1317 ,(if (or (consp (setq sym (symbol-value (car olist))))
1319 (not (or (eq sym nil)
1321 (list 'quote (symbol-value (car olist)))
1322 (symbol-value (car olist))))
1325 (format "(setq %s 'whatever)\n" (car olist))))
1326 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
1327 (setq olist (cdr olist)))
1328 ;; Remove any control chars - they seem to cause trouble for some
1329 ;; mailers. (Byte-compiled output from the stuff above.)
1331 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
1332 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
1334 ;; Break MIME tags purposely.
1336 (while (re-search-forward mime-edit-tag-regexp nil t)
1337 (goto-char (1+ (match-beginning 0)))
1340 ;;; Treatment of rejected articles.
1343 (defun gnus-summary-resend-bounced-mail (&optional fetch)
1344 "Re-mail the current message.
1345 This only makes sense if the current message is a bounce message than
1346 contains some mail you have written which has been bounced back to
1348 If FETCH, try to fetch the article that this is a reply to, if indeed
1351 (gnus-summary-select-article t)
1352 (set-buffer gnus-original-article-buffer)
1353 (let ((gnus-message-setup-hook '(gnus-maybe-setup-default-charset)))
1354 (gnus-setup-message 'compose-bounce
1355 (let* ((references (mail-fetch-field "references"))
1356 (parent (and references (gnus-parent-id references))))
1358 ;; If there are references, we fetch the article we answered to.
1360 (gnus-summary-refer-article parent)
1361 (gnus-summary-show-all-headers))))))
1365 (defun gnus-inews-group-method (group)
1367 ;; If the group doesn't exist, we assume
1368 ;; it's an archive group...
1369 ((and (null (gnus-get-info group))
1370 (eq (car (gnus-server-to-method gnus-message-archive-method))
1371 (car (gnus-server-to-method (gnus-group-method group)))))
1372 gnus-message-archive-method)
1374 ((gnus-info-method (gnus-get-info group))
1375 (gnus-info-method (gnus-get-info group)))
1377 (t (gnus-server-to-method (gnus-group-method group)))))
1379 ;; Do Gcc handling, which copied the message over to some group.
1380 (defun gnus-inews-do-gcc (&optional gcc)
1384 (message-narrow-to-headers)
1385 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
1386 (coding-system-for-write 'raw-text)
1387 (output-coding-system 'raw-text)
1388 groups group method group-art)
1390 (message-remove-header "gcc")
1392 (setq groups (message-unquote-tokens
1393 (message-tokenize-header gcc " ,")))
1394 ;; Copy the article over to some group(s).
1395 (while (setq group (pop groups))
1396 (unless (gnus-check-server
1397 (setq method (gnus-inews-group-method group)))
1398 (error "Can't open server %s" (if (stringp method) method
1400 (unless (gnus-request-group group nil method)
1401 (gnus-request-create-group group method))
1403 (nnheader-set-temp-buffer " *acc*")
1404 (insert-buffer-substring message-encoding-buffer)
1405 (gnus-run-hooks 'gnus-before-do-gcc-hook)
1406 (goto-char (point-min))
1407 (when (re-search-forward
1408 (concat "^" (regexp-quote mail-header-separator) "$")
1410 (replace-match "" t t ))
1411 (unless (setq group-art
1412 (gnus-request-accept-article group method t t))
1413 (gnus-message 1 "Couldn't store article in group %s: %s"
1414 group (gnus-status-message method))
1416 (when (and group-art gnus-inews-mark-gcc-as-read)
1417 (gnus-group-mark-article-read group (cdr group-art)))
1418 (kill-buffer (current-buffer)))))))))
1420 (defun gnus-inews-insert-gcc ()
1421 "Insert Gcc headers based on `gnus-outgoing-message-group'."
1424 (message-narrow-to-headers)
1425 (let* ((group gnus-outgoing-message-group)
1427 ((gnus-functionp group)
1429 ((or (stringp group) (list group))
1433 (if (stringp gcc) gcc
1434 (mapconcat 'identity gcc " "))
1437 (defun gnus-inews-insert-archive-gcc (&optional group)
1438 "Insert the Gcc to say where the article is to be archived."
1439 (let* ((var gnus-message-archive-group)
1440 (group (or group gnus-newsgroup-name ""))
1442 (and gnus-newsgroup-name
1443 (not (equal gnus-newsgroup-name ""))
1444 (gnus-group-find-parameter
1445 gnus-newsgroup-name 'gcc-self)))
1449 ((null gnus-message-archive-method)
1453 ;; Just a single group.
1456 ;; We don't want this.
1458 ((and (listp var) (stringp (car var)))
1459 ;; A list of groups.
1461 ((gnus-functionp var)
1463 (funcall var group))
1465 ;; An alist of regexps/functions/forms.
1470 ((stringp (caar var))
1472 (when (string-match (caar var) group)
1474 ((gnus-functionp (car var))
1476 (funcall (car var) group))
1478 (eval (car var)))))))
1479 (setq var (cdr var)))
1482 (when (or groups gcc-self-val)
1483 (when (stringp groups)
1484 (setq groups (list groups)))
1487 (message-narrow-to-headers)
1488 (goto-char (point-max))
1491 ;; Use the `gcc-self' param value instead.
1494 (if (stringp gcc-self-val)
1497 (if (not (eq gcc-self-val 'none))
1502 ;; Use the list of groups.
1503 (while (setq name (pop groups))
1504 (insert (if (string-match ":" name)
1506 (gnus-group-prefixed-name
1507 name gnus-message-archive-method)))
1514 (defun gnus-configure-posting-styles ()
1515 "Configure posting styles according to `gnus-posting-styles'."
1516 (unless gnus-inhibit-posting-styles
1517 (let ((group (or gnus-newsgroup-name ""))
1518 (styles gnus-posting-styles)
1519 style match variable attribute value v results
1520 filep name address element)
1521 ;; If the group has a posting-style parameter, add it at the end with a
1522 ;; regexp matching everything, to be sure it takes precedence over all
1524 (when gnus-newsgroup-name
1525 (let ((tmp-style (gnus-group-find-parameter group 'posting-style t)))
1527 (setq styles (append styles (list (cons ".*" tmp-style)))))))
1528 ;; Go through all styles and look for matches.
1529 (dolist (style styles)
1530 (setq match (pop style))
1531 (goto-char (point-min))
1534 ;; Regexp string match on the group name.
1535 (string-match match group))
1537 (and (gnus-buffer-live-p gnus-article-copy)
1538 (with-current-buffer gnus-article-copy
1539 (let ((header (message-fetch-field (pop style))))
1541 (string-match (pop style) header))))))
1542 ((or (symbolp match)
1543 (gnus-functionp match))
1545 ((gnus-functionp match)
1546 ;; Function to be called.
1549 ;; Variable to be checked.
1550 (symbol-value match))))
1552 ;; This is a form to be evaled.
1554 ;; We have a match, so we set the variables.
1555 (dolist (attribute style)
1556 (setq element (pop attribute)
1561 ((eq (car attribute) ':file)
1564 ((eq (car attribute) :value)
1568 ;; We get the value.
1573 ((or (symbolp value)
1574 (gnus-functionp value))
1575 (cond ((gnus-functionp value)
1578 (symbol-value value))))
1581 ;; Translate obsolescent value.
1582 (when (eq element 'signature-file)
1583 (setq element 'signature
1585 ;; Get the contents of file elems.
1587 (setq v (with-temp-buffer
1588 (insert-file-contents v)
1590 (setq results (delq (assoc element results) results))
1591 (push (cons element v) results))))
1592 ;; Now we have all the styles, so we insert them.
1593 (setq name (assq 'name results)
1594 address (assq 'address results))
1595 (setq results (delq name (delq address results)))
1596 (make-local-variable 'message-setup-hook)
1597 (dolist (result results)
1598 (add-hook 'message-setup-hook
1600 ((eq 'eval (car result))
1602 ((eq 'body (car result))
1606 (insert ,(cdr result)))))
1607 ((eq 'signature (car result))
1608 (set (make-local-variable 'message-signature) nil)
1609 (set (make-local-variable 'message-signature-file) nil)
1610 (if (not (cdr result))
1614 (let ((message-signature ,(cdr result)))
1615 (when message-signature
1616 (message-insert-signature)))))))
1619 (if (symbolp (car result))
1620 (capitalize (symbol-name (car result)))
1624 (message-remove-header ,header)
1625 (let ((value ,(cdr result)))
1628 (insert ,header ": " value "\n"))))))))))
1629 (when (or name address)
1630 (add-hook 'message-setup-hook
1632 (set (make-local-variable 'user-mail-address)
1633 ,(or (cdr address) user-mail-address))
1634 (let ((user-full-name ,(or (cdr name) (user-full-name)))
1636 ,(or (cdr address) user-mail-address)))
1638 (message-remove-header "From")
1640 (insert "From: " (message-make-from) "\n")))))))))
1643 ;;; @ for MIME Edit mode
1646 (defun gnus-maybe-setup-default-charset ()
1648 (and (boundp 'gnus-summary-buffer)
1649 (buffer-live-p gnus-summary-buffer)
1651 (set-buffer gnus-summary-buffer)
1652 default-mime-charset))))
1655 (make-local-variable 'default-mime-charset)
1656 (setq default-mime-charset charset)
1660 ;;; @ for MIME view mode
1663 (defun gnus-following-method (buf)
1664 (gnus-setup-message 'reply-yank
1666 (if (message-news-p)
1668 (message-reply nil 'wide))
1669 (let ((message-reply-buffer buf))
1670 (message-yank-original))
1671 (message-goto-body))
1675 ;;; Allow redefinition of functions.
1681 ;;; gnus-msg.el ends here