1 ;;; gnus-msg.el --- mail and post interface for 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>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
30 (eval-when-compile (require 'cl))
37 (defcustom gnus-post-method 'current
38 "*Preferred method for posting USENET news.
40 If this variable is `current' (which is the default), Gnus will use
41 the \"current\" select method when posting. If it is `native', Gnus
42 will use the native select method when posting.
44 This method will not be used in mail groups and the like, only in
47 If not `native' nor `current', the value must be a valid method as discussed
48 in the documentation of `gnus-select-method'. It can also be a list of
49 methods. If that is the case, the user will be queried for what select
50 method to use when posting."
51 :group 'gnus-group-foreign
52 :link '(custom-manual "(gnus)Posting Server")
53 :type `(choice (const native)
55 (sexp :tag "Methods" ,gnus-select-method)))
57 (defcustom gnus-outgoing-message-group nil
58 "*All outgoing messages will be put in this group.
59 If you want to store all your outgoing mail and articles in the group
60 \"nnml:archive\", you set this variable to that value. This variable
61 can also be a list of group names.
63 If you want to have greater control over what group to put each
64 message in, you can set this variable to a function that checks the
65 current newsgroup name and then returns a suitable group name (or list
68 :type '(choice (string :tag "Group")
71 (defcustom 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
79 (defcustom gnus-add-to-list nil
80 "*If non-nil, add a `to-list' parameter automatically."
84 (defcustom gnus-crosspost-complaint
87 You posted the article below with the following Newsgroups header:
91 The %s group, at least, was an inappropriate recipient
92 of this message. Please trim your Newsgroups header to exclude this
93 group before posting in the future.
98 "Format string to be inserted when complaining about crossposts.
99 The first %s will be replaced by the Newsgroups header;
100 the second with the current group name."
104 (defcustom gnus-message-setup-hook nil
105 "Hook run after setting up a message buffer."
109 (defcustom gnus-bug-create-help-buffer t
110 "*Should we create the *Gnus Help Bug* buffer?"
114 (defcustom gnus-posting-styles nil
115 "*Alist of styles to use when posting.
116 See Info node `(gnus)Posting Styles'."
118 :type '(repeat (cons (choice (regexp)
123 (choice (const signature)
124 (const signature-file)
129 (string :tag "Header"))
135 (defcustom gnus-inews-mark-gcc-as-read nil
136 "If non-nil, automatically mark Gcc articles as read."
140 (defcustom gnus-group-posting-charset-alist
141 '(("^\\(no\\|fr\\)\\.[^,]*\\(,[ \t\n]*\\(no\\|fr\\)\\.[^,]*\\)*$" iso-8859-1 (iso-8859-1))
142 ("^\\(fido7\\|relcom\\)\\.[^,]*\\(,[ \t\n]*\\(fido7\\|relcom\\)\\.[^,]*\\)*$" koi8-r (koi8-r))
143 (message-this-is-mail nil nil)
144 (message-this-is-news nil t))
145 "Alist of regexps and permitted unencoded charsets for posting.
146 Each element of the alist has the form (TEST HEADER BODY-LIST), where
147 TEST is either a regular expression matching the newsgroup header or a
149 HEADER is the charset which may be left unencoded in the header (nil
150 means encode all charsets),
151 BODY-LIST is a list of charsets which may be encoded using 8bit
152 content-transfer encoding in the body, or one of the special values
153 nil (always encode using quoted-printable) or t (always use 8bit).
155 Note that any value other than nil for HEADER infringes some RFCs, so
156 use this option with care."
157 :type '(repeat (list :tag "Permitted unencoded charsets"
159 (regexp :tag "Group")
160 (const :tag "Mail message" :value message-this-is-mail)
161 (const :tag "News article" :value message-this-is-news))
162 (choice :tag "Header"
163 (const :tag "None" nil)
164 (symbol :tag "Charset"))
166 (const :tag "Any" :value t)
167 (const :tag "None" :value nil)
168 (repeat :tag "Charsets"
169 (symbol :tag "Charset")))))
170 :group 'gnus-charset)
172 ;;; Internal variables.
174 (defvar gnus-inhibit-posting-styles nil
175 "Inhibit the use of posting styles.")
177 (defvar gnus-message-buffer "*Mail Gnus*")
178 (defvar gnus-article-copy nil)
179 (defvar gnus-check-before-posting nil)
180 (defvar gnus-last-posting-server nil)
181 (defvar gnus-message-group-art nil)
183 (defvar gnus-msg-force-broken-reply-to nil)
185 (defconst gnus-bug-message
186 "Sending a bug report to the Gnus Towers.
187 ========================================
189 The buffer below is a mail buffer. When you press `C-c C-c', it will
190 be sent to the Gnus Bug Exterminators.
192 The thing near the bottom of the buffer is how the environment
193 settings will be included in the mail. Please do not delete that.
194 They will tell the Bug People what your environment is, so that it
195 will be easier to locate the bugs.
197 If you have found a bug that makes Emacs go \"beep\", set
198 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
199 and include the backtrace in your bug report.
201 Please describe the bug in annoying, painstaking detail.
203 Thank you for your help in stamping out bugs.
207 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
208 (autoload 'news-setup "rnewspost")
209 (autoload 'news-reply-mode "rnewspost")
210 (autoload 'rmail-dont-reply-to "mail-utils")
211 (autoload 'rmail-output "rmailout"))
215 ;;; Gnus Posting Functions
218 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
219 "p" gnus-summary-post-news
220 "i" gnus-summary-news-other-window
221 "f" gnus-summary-followup
222 "F" gnus-summary-followup-with-original
223 "c" gnus-summary-cancel-article
224 "s" gnus-summary-supersede-article
225 "r" gnus-summary-reply
226 "y" gnus-summary-yank-message
227 "R" gnus-summary-reply-with-original
228 "w" gnus-summary-wide-reply
229 "W" gnus-summary-wide-reply-with-original
230 "v" gnus-summary-very-wide-reply
231 "W" gnus-summary-very-wide-reply-with-original
232 "n" gnus-summary-followup-to-mail
233 "N" gnus-summary-followup-to-mail-with-original
234 "m" gnus-summary-mail-other-window
235 "u" gnus-uu-post-news
236 "\M-c" gnus-summary-mail-crosspost-complaint
237 "Br" gnus-summary-reply-broken-reply-to
238 "BR" gnus-summary-reply-broken-reply-to-with-original
239 "om" gnus-summary-mail-forward
240 "op" gnus-summary-post-forward
241 "Om" gnus-uu-digest-mail-forward
242 "Op" gnus-uu-digest-post-forward)
244 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
245 "b" gnus-summary-resend-bounced-mail
246 ;; "c" gnus-summary-send-draft
247 "r" gnus-summary-resend-message)
249 ;;; Internal functions.
251 (defvar gnus-article-reply nil)
252 (defmacro gnus-setup-message (config &rest forms)
253 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
254 (buffer (make-symbol "gnus-setup-message-buffer"))
255 (article (make-symbol "gnus-setup-message-article"))
256 (group (make-symbol "gnus-setup-message-group")))
257 `(let ((,winconf (current-window-configuration))
258 (,buffer (buffer-name (current-buffer)))
259 (,article gnus-article-reply)
260 (,group gnus-newsgroup-name)
261 (message-header-setup-hook
262 (copy-sequence message-header-setup-hook))
263 (mbl mml-buffer-list)
264 (message-mode-hook (copy-sequence message-mode-hook)))
265 (setq mml-buffer-list nil)
266 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
267 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
268 ;; #### FIXME: for a reason that I did not manage to identify yet,
269 ;; the variable `gnus-newsgroup-name' does not honor a dynamically
270 ;; scoped or setq'ed value from a caller like `C-u gnus-summary-mail'.
271 ;; After evaluation of @forms below, it gets the value we actually want
272 ;; to override, and the posting styles are used. For that reason, I've
273 ;; added an optional argument to `gnus-configure-posting-styles' to
274 ;; make sure that the correct value for the group name is used. -- drv
275 (add-hook 'message-mode-hook
277 (gnus-configure-posting-styles ,group)))
281 (gnus-inews-add-send-actions ,winconf ,buffer ,article ,config)
282 (gnus-inews-insert-draft-meta-information ,group ,article)
283 (setq gnus-message-buffer (current-buffer))
284 (set (make-local-variable 'gnus-message-group-art)
285 (cons ,group ,article))
286 (set (make-local-variable 'gnus-newsgroup-name) ,group)
287 (gnus-run-hooks 'gnus-message-setup-hook)
288 (if (eq major-mode 'message-mode)
289 (let ((mbl1 mml-buffer-list))
290 (setq mml-buffer-list mbl) ;; Global value
291 (set (make-local-variable 'mml-buffer-list) mbl1);; Local value
292 ;; LOCAL argument of add-hook differs between GNU Emacs
293 ;; and XEmacs. make-local-hook makes sure they are local.
294 (make-local-hook 'kill-buffer-hook)
295 (make-local-hook 'change-major-mode-hook)
296 (add-hook 'change-major-mode-hook 'mml-destroy-buffers nil t)
297 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))
298 (mml-destroy-buffers)
299 (setq mml-buffer-list mbl)))
301 (gnus-configure-windows ,config t)
302 (run-hooks 'post-command-hook)
303 (set-buffer-modified-p nil))))
305 (defun gnus-inews-insert-draft-meta-information (group article)
308 (not (string= group ""))
309 (not (message-fetch-field gnus-draft-meta-information-header)))
310 (goto-char (point-min))
311 (insert gnus-draft-meta-information-header ": (\"" group "\" "
312 (if article (number-to-string
319 (defun gnus-msg-mail (&optional to subject other-headers continue
320 switch-action yank-action send-actions)
321 "Start editing a mail message to be sent.
322 Like `message-mail', but with Gnus paraphernalia, particularly the
323 Gcc: header for archiving purposes."
325 (let ((buf (current-buffer))
327 (gnus-setup-message 'message
328 (message-mail to subject other-headers continue
329 nil yank-action send-actions))
331 (setq mail-buf (current-buffer))
332 (switch-to-buffer buf)
333 (apply switch-action mail-buf nil)))
334 ;; COMPOSEFUNC should return t if succeed. Undocumented ???
337 (defvar save-selected-window-window)
340 (defun gnus-button-mailto (address)
342 (set-buffer (gnus-copy-article-buffer))
343 (gnus-setup-message 'message
344 (message-reply address))
345 (and (boundp 'save-selected-window-window)
346 (not (window-live-p save-selected-window-window))
347 (setq save-selected-window-window (selected-window))))
350 (defun gnus-button-reply (&optional to-address wide)
351 "Like `message-reply'."
353 (gnus-setup-message 'message
354 (message-reply to-address wide))
355 (and (boundp 'save-selected-window-window)
356 (not (window-live-p save-selected-window-window))
357 (setq save-selected-window-window (selected-window))))
360 (define-mail-user-agent 'gnus-user-agent
361 'gnus-msg-mail 'message-send-and-exit
362 'message-kill-buffer 'message-send-hook)
364 (defun gnus-setup-posting-charset (group)
365 (let ((alist gnus-group-posting-charset-alist)
366 (group (or group ""))
370 (while (setq elem (pop alist))
371 (when (or (and (stringp (car elem))
372 (string-match (car elem) group))
373 (and (gnus-functionp (car elem))
374 (funcall (car elem) group))
375 (and (symbolp (car elem))
376 (symbol-value (car elem))))
377 (throw 'found (cons (cadr elem) (caddr elem)))))))))
379 (defun gnus-inews-add-send-actions (winconf buffer article &optional config)
380 (make-local-hook 'message-sent-hook)
381 (add-hook 'message-sent-hook (if gnus-agent 'gnus-agent-possibly-do-gcc
382 'gnus-inews-do-gcc) nil t)
384 (make-local-hook 'message-header-hook)
385 (add-hook 'message-header-hook 'gnus-agent-possibly-save-gcc nil t))
386 (setq message-post-method
388 (gnus-post-method arg ,gnus-newsgroup-name)))
389 (setq message-newsreader (setq message-mailer (gnus-extended-version)))
391 `(set-window-configuration ,winconf) 'exit 'postpone 'kill)
393 `(when (gnus-buffer-exists-p ,buffer)
397 (if (eq config 'forward)
398 `(gnus-summary-mark-article-as-forwarded ',article)
399 `(gnus-summary-mark-article-as-replied ',article)))))
402 (put 'gnus-setup-message 'lisp-indent-function 1)
403 (put 'gnus-setup-message 'edebug-form-spec '(form body))
405 ;;; Post news commands of Gnus group mode and summary mode
407 (defun gnus-group-mail (&optional arg)
408 "Start composing a mail.
409 If ARG, use the group under the point to find a posting style.
410 If ARG is 1, prompt for a group name to find the posting style."
412 ;; We can't `let' gnus-newsgroup-name here, since that leads
413 ;; to local variables leaking.
414 (let ((group gnus-newsgroup-name)
415 (buffer (current-buffer)))
418 (setq gnus-newsgroup-name
420 (if (= 1 (prefix-numeric-value arg))
421 (completing-read "Use posting style of group: "
422 gnus-active-hashtb nil
423 (gnus-read-active-file-p))
424 (gnus-group-group-name))
426 ;; #### see comment in gnus-setup-message -- drv
427 (gnus-setup-message 'message (message-mail)))
430 (setq gnus-newsgroup-name group)))))
432 (defun gnus-group-news (&optional arg)
433 "Start composing a news.
434 If ARG, post to group under point.
435 If ARG is 1, prompt for group name to post to.
437 This function prepares a news even when using mail groups. This is useful
438 for posting messages to mail groups without actually sending them over the
439 network. The corresponding backend must have a 'request-post method."
441 ;; We can't `let' gnus-newsgroup-name here, since that leads
442 ;; to local variables leaking.
443 (let ((group gnus-newsgroup-name)
444 (buffer (current-buffer)))
447 (setq gnus-newsgroup-name
449 (if (= 1 (prefix-numeric-value arg))
450 (completing-read "Use group: "
451 gnus-active-hashtb nil
452 (gnus-read-active-file-p))
453 (gnus-group-group-name))
455 ;; #### see comment in gnus-setup-message -- drv
456 (gnus-setup-message 'message
457 (message-news (gnus-group-real-name gnus-newsgroup-name))))
460 (setq gnus-newsgroup-name group)))))
462 (defun gnus-group-post-news (&optional arg)
463 "Start composing a message (a news by default).
464 If ARG, post to group under point. If ARG is 1, prompt for group name.
465 Depending on the selected group, the message might be either a mail or
468 ;; Bind this variable here to make message mode hooks work ok.
469 (let ((gnus-newsgroup-name
471 (if (= 1 (prefix-numeric-value arg))
472 (completing-read "Newsgroup: " gnus-active-hashtb nil
473 (gnus-read-active-file-p))
474 (gnus-group-group-name))
476 (gnus-post-news 'post gnus-newsgroup-name)))
478 (defun gnus-summary-mail-other-window (&optional arg)
479 "Start composing a mail in another window.
480 Use the posting of the current group by default.
481 If ARG, don't do that. If ARG is 1, prompt for group name to find the
484 ;; We can't `let' gnus-newsgroup-name here, since that leads
485 ;; to local variables leaking.
486 (let ((group gnus-newsgroup-name)
487 (buffer (current-buffer)))
490 (setq gnus-newsgroup-name
492 (if (= 1 (prefix-numeric-value arg))
493 (completing-read "Use group: "
494 gnus-active-hashtb nil
495 (gnus-read-active-file-p))
497 gnus-newsgroup-name))
498 ;; #### see comment in gnus-setup-message -- drv
499 (gnus-setup-message 'message (message-mail)))
502 (setq gnus-newsgroup-name group)))))
504 (defun gnus-summary-news-other-window (&optional arg)
505 "Start composing a news in another window.
506 Post to the current group by default.
507 If ARG, don't do that. If ARG is 1, prompt for group name to post to.
509 This function prepares a news even when using mail groups. This is useful
510 for posting messages to mail groups without actually sending them over the
511 network. The corresponding backend must have a 'request-post method."
513 ;; We can't `let' gnus-newsgroup-name here, since that leads
514 ;; to local variables leaking.
515 (let ((group gnus-newsgroup-name)
516 (buffer (current-buffer)))
519 (setq gnus-newsgroup-name
521 (if (= 1 (prefix-numeric-value arg))
522 (completing-read "Use group: "
523 gnus-active-hashtb nil
524 (gnus-read-active-file-p))
526 gnus-newsgroup-name))
527 ;; #### see comment in gnus-setup-message -- drv
528 (gnus-setup-message 'message
529 (message-news (gnus-group-real-name gnus-newsgroup-name))))
532 (setq gnus-newsgroup-name group)))))
534 (defun gnus-summary-post-news (&optional arg)
535 "Start composing a message. Post to the current group by default.
536 If ARG, don't do that. If ARG is 1, prompt for a group name to post to.
537 Depending on the selected group, the message might be either a mail or
540 ;; Bind this variable here to make message mode hooks work ok.
541 (let ((gnus-newsgroup-name
543 (if (= 1 (prefix-numeric-value arg))
544 (completing-read "Newsgroup: " gnus-active-hashtb nil
545 (gnus-read-active-file-p))
547 gnus-newsgroup-name)))
548 (gnus-post-news 'post gnus-newsgroup-name)))
551 (defun gnus-summary-followup (yank &optional force-news)
552 "Compose a followup to an article.
553 If prefix argument YANK is non-nil, original article is yanked automatically."
555 (list (and current-prefix-arg
556 (gnus-summary-work-articles 1))))
558 (gnus-summary-goto-subject (car yank)))
559 (save-window-excursion
560 (gnus-summary-select-article))
561 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
562 (gnus-newsgroup-name gnus-newsgroup-name))
564 (gnus-post-news nil gnus-newsgroup-name
565 headers gnus-article-buffer
566 yank nil force-news)))
568 (defun gnus-summary-followup-with-original (n &optional force-news)
569 "Compose a followup to an article and include the original article."
571 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
573 (defun gnus-summary-followup-to-mail (&optional arg)
574 "Followup to the current mail message via news."
576 (list (and current-prefix-arg
577 (gnus-summary-work-articles 1))))
578 (gnus-summary-followup arg t))
580 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
581 "Followup to the current mail message via news."
583 (gnus-summary-followup (gnus-summary-work-articles arg) t))
585 (defun gnus-inews-yank-articles (articles)
588 (while (setq article (pop articles))
589 (save-window-excursion
590 (set-buffer gnus-summary-buffer)
591 (gnus-summary-select-article nil nil nil article)
592 (gnus-summary-remove-process-mark article))
593 (gnus-copy-article-buffer)
594 (let ((message-reply-buffer gnus-article-copy)
595 (message-reply-headers
596 (with-current-buffer gnus-article-copy
597 ;; The headers are decoded.
598 (nnheader-parse-head t))))
599 (message-yank-original)
600 (setq beg (or beg (mark t))))
606 (defun gnus-summary-cancel-article (&optional n symp)
607 "Cancel an article you posted.
608 Uses the process-prefix convention. If given the symbolic
609 prefix `a', cancel using the standard posting method; if not
610 post using the current select method."
611 (interactive (gnus-interactive "P\ny"))
612 (let ((articles (gnus-summary-work-articles n))
615 (gnus-post-method (not (eq symp 'a)) ,gnus-newsgroup-name)))
617 (while (setq article (pop articles))
618 (when (gnus-summary-select-article t nil nil article)
619 (when (gnus-eval-in-buffer-window gnus-original-article-buffer
620 (message-cancel-news))
621 (gnus-summary-mark-as-read article gnus-canceled-mark)
622 (gnus-cache-remove-article 1))
623 (gnus-article-hide-headers-if-wanted))
624 (gnus-summary-remove-process-mark article))))
626 (defun gnus-summary-supersede-article ()
627 "Compose an article that will supersede a previous article.
628 This is done simply by taking the old article and adding a Supersedes
629 header line with the old Message-ID."
631 (let ((article (gnus-summary-article-number)))
632 (gnus-setup-message 'reply-yank
633 (gnus-summary-select-article t)
634 (set-buffer gnus-original-article-buffer)
638 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
640 (set-buffer ,gnus-summary-buffer)
641 (gnus-cache-possibly-remove-article ,article nil nil nil t)
642 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
643 message-send-actions))))
647 (defun gnus-copy-article-buffer (&optional article-buffer)
648 ;; make a copy of the article buffer with all text properties removed
649 ;; this copy is in the buffer gnus-article-copy.
650 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
651 ;; this buffer should be passed to all mail/news reply/post routines.
652 (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
654 (set-buffer gnus-article-copy)
655 (mm-enable-multibyte))
656 (let ((article-buffer (or article-buffer gnus-article-buffer))
658 (if (not (and (get-buffer article-buffer)
659 (gnus-buffer-exists-p article-buffer)))
660 (error "Can't find any article buffer")
662 (set-buffer article-buffer)
663 (let ((gnus-newsgroup-charset (or gnus-article-charset
664 gnus-newsgroup-charset))
665 (gnus-newsgroup-ignored-charsets
666 (or gnus-article-ignored-charsets
667 gnus-newsgroup-ignored-charsets)))
669 ;; Copy over the (displayed) article buffer, delete
670 ;; hidden text and remove text properties.
672 (copy-to-buffer gnus-article-copy (point-min) (point-max))
673 (set-buffer gnus-article-copy)
674 (gnus-article-delete-text-of-type 'annotation)
675 (gnus-remove-text-with-property 'gnus-prev)
676 (gnus-remove-text-with-property 'gnus-next)
679 (buffer-substring-no-properties (point-min) (point-max))
681 ;; Find the original headers.
682 (set-buffer gnus-original-article-buffer)
683 (goto-char (point-min))
684 (while (looking-at message-unix-mail-delimiter)
687 (setq end (or (message-goto-body) beg))
688 ;; Delete the headers from the displayed articles.
689 (set-buffer gnus-article-copy)
690 (delete-region (goto-char (point-min))
691 (or (message-goto-body) (point-max)))
692 ;; Insert the original article headers.
693 (insert-buffer-substring gnus-original-article-buffer beg end)
695 (let ((gnus-article-decode-hook
696 (delq 'article-decode-charset
697 (copy-sequence gnus-article-decode-hook))))
698 (run-hooks 'gnus-article-decode-hook)))))
701 (defun gnus-post-news (post &optional group header article-buffer yank subject
704 (gnus-copy-article-buffer))
705 (let ((gnus-article-reply (and article-buffer (gnus-summary-article-number)))
706 (add-to-list gnus-add-to-list))
707 (gnus-setup-message (cond (yank 'reply-yank)
708 (article-buffer 'reply)
710 (let* ((group (or group gnus-newsgroup-name))
711 (charset (gnus-group-name-charset nil group))
713 to-address to-group mailing-list to-list
716 (setq to-address (gnus-parameter-to-address group)
717 to-group (gnus-group-find-parameter group 'to-group)
718 to-list (gnus-parameter-to-list group)
719 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
720 mailing-list (when gnus-mailing-list-groups
721 (string-match gnus-mailing-list-groups group))
722 group (gnus-group-name-decode (gnus-group-real-name group)
724 (if (or (and to-group
725 (gnus-news-group-p to-group))
728 (and (gnus-news-group-p
729 (or pgroup gnus-newsgroup-name)
730 (or header gnus-current-article))
736 (message-news (or to-group group))
737 (set-buffer gnus-article-copy)
738 (gnus-msg-treat-broken-reply-to)
739 (message-followup (if (or newsgroup-p force-news)
740 (if (save-restriction
741 (article-narrow-to-head)
742 (message-fetch-field "newsgroups"))
749 (message-mail (or to-address to-list))
750 ;; Arrange for mail groups that have no `to-address' to
751 ;; get that when the user sends off the mail.
752 (when (and (not to-list)
755 (push (list 'gnus-inews-add-to-address pgroup)
756 message-send-actions)))
757 (set-buffer gnus-article-copy)
758 (gnus-msg-treat-broken-reply-to)
759 (message-wide-reply to-address)))
761 (gnus-inews-yank-articles yank))))))
763 (defun gnus-msg-treat-broken-reply-to (&optional force)
764 "Remove the Reply-to header iff broken-reply-to."
766 (gnus-group-find-parameter
767 gnus-newsgroup-name 'broken-reply-to))
769 (message-narrow-to-head)
770 (message-remove-header "reply-to"))))
772 (defun gnus-post-method (arg group &optional silent)
773 "Return the posting method based on GROUP and ARG.
774 If SILENT, don't prompt the user."
775 (let ((gnus-post-method (or (gnus-parameter-post-method group)
777 (group-method (gnus-find-method-for-group group)))
779 ;; If the group-method is nil (which shouldn't happen) we use
780 ;; the default method.
782 (or (and (listp gnus-post-method) ;If not current/native/nil
783 (not (listp (car gnus-post-method))) ; and not a list of methods
784 gnus-post-method) ;then use it.
786 message-post-method))
787 ;; We want the inverse of the default
788 ((and arg (not (eq arg 0)))
789 (if (eq gnus-post-method 'current)
792 ;; We query the user for a post method.
794 (and (listp gnus-post-method)
795 (listp (car gnus-post-method))))
797 ;; Collect all methods we know about.
799 (when (listp gnus-post-method)
800 (if (listp (car gnus-post-method))
802 (list gnus-post-method)))
803 gnus-secondary-select-methods
804 (mapcar 'cdr gnus-server-alist)
805 (mapcar 'car gnus-opened-servers)
806 (list gnus-select-method)
807 (list group-method)))
808 method-alist post-methods method)
809 ;; Weed out all mail methods.
811 (setq method (gnus-server-get-method "" (pop methods)))
812 (when (and (or (gnus-method-option-p method 'post)
813 (gnus-method-option-p method 'post-mail))
814 (not (member method post-methods)))
815 (push method post-methods)))
816 ;; Create a name-method alist.
820 (if (equal (cadr m) "")
821 (list (symbol-name (car m)) m)
822 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m)))
827 (setq gnus-last-posting-server
829 gnus-last-posting-server)
830 ;; Just use the last value.
831 gnus-last-posting-server
833 "Posting method: " method-alist nil t
834 (cons (or gnus-last-posting-server "") 0))))
836 ;; Override normal method.
837 ((and (eq gnus-post-method 'current)
838 (not (eq (car group-method) 'nndraft))
839 (gnus-get-function group-method 'request-post t))
842 ;; Use gnus-post-method.
843 ((listp gnus-post-method) ;A method...
844 (assert (not (listp (car gnus-post-method)))) ;... not a list of methods.
846 ;; Use the normal select method (nil or native).
847 (t gnus-select-method))))
851 ;; Dummies to avoid byte-compile warning.
853 (defvar nnspool-rejected-article-hook)
854 (defvar xemacs-codename))
856 (defun gnus-extended-version ()
857 "Stringified Gnus version and Emacs version."
860 "Gnus/" (prin1-to-string (gnus-continuum-version gnus-version) t)
861 " (" gnus-version ")"
864 ((string-match "^\\(\\([.0-9]+\\)*\\)\\.[0-9]+$" emacs-version)
865 (concat "Emacs/" (match-string 1 emacs-version)
866 " (" system-configuration ")"))
867 ((string-match "\\([A-Z]*[Mm][Aa][Cc][Ss]\\)[^(]*\\(\\((beta.*)\\|'\\)\\)?"
869 (concat (match-string 1 emacs-version)
870 (format "/%d.%d" emacs-major-version emacs-minor-version)
871 (if (match-beginning 3)
872 (match-string 3 emacs-version)
874 (if (boundp 'xemacs-codename)
875 (concat " (" xemacs-codename ", " system-configuration ")")
881 ;;; Gnus Mail Functions
884 ;;; Mail reply commands of Gnus summary mode
886 (defun gnus-summary-reply (&optional yank wide very-wide)
887 "Start composing a mail reply to the current message.
888 If prefix argument YANK is non-nil, the original article is yanked
890 If WIDE, make a wide reply.
891 If VERY-WIDE, make a very wide reply."
893 (list (and current-prefix-arg
894 (gnus-summary-work-articles 1))))
895 ;; Stripping headers should be specified with mail-yank-ignored-headers.
897 (gnus-summary-goto-subject (car yank)))
898 (let ((gnus-article-reply (or yank (gnus-summary-article-number)))
900 (gnus-setup-message (if yank 'reply-yank 'reply)
902 (gnus-summary-select-article)
903 (dolist (article very-wide)
904 (gnus-summary-select-article nil nil nil article)
906 (set-buffer (gnus-copy-article-buffer))
907 (gnus-msg-treat-broken-reply-to)
909 (message-narrow-to-head)
910 (setq headers (concat headers (buffer-string)))))))
911 (set-buffer (gnus-copy-article-buffer))
912 (gnus-msg-treat-broken-reply-to gnus-msg-force-broken-reply-to)
914 (message-narrow-to-head)
918 (goto-char (point-max)))
919 (mml-quote-region (point) (point-max))
920 (message-reply nil wide)
922 (gnus-inews-yank-articles yank)))))
924 (defun gnus-summary-reply-with-original (n &optional wide)
925 "Start composing a reply mail to the current message.
926 The original article will be yanked."
928 (gnus-summary-reply (gnus-summary-work-articles n) wide))
930 (defun gnus-summary-reply-broken-reply-to (&optional yank wide very-wide)
931 "Like `gnus-summary-reply' except removing reply-to field.
932 If prefix argument YANK is non-nil, the original article is yanked
934 If WIDE, make a wide reply.
935 If VERY-WIDE, make a very wide reply."
937 (list (and current-prefix-arg
938 (gnus-summary-work-articles 1))))
939 (let ((gnus-msg-force-broken-reply-to t))
940 (gnus-summary-reply yank wide very-wide)))
942 (defun gnus-summary-reply-broken-reply-to-with-original (n &optional wide)
943 "Like `gnus-summary-reply-with-original' except removing reply-to field.
944 The original article will be yanked."
946 (gnus-summary-reply-broken-reply-to (gnus-summary-work-articles n) wide))
948 (defun gnus-summary-wide-reply (&optional yank)
949 "Start composing a wide reply mail to the current message.
950 If prefix argument YANK is non-nil, the original article is yanked
953 (list (and current-prefix-arg
954 (gnus-summary-work-articles 1))))
955 (gnus-summary-reply yank t))
957 (defun gnus-summary-wide-reply-with-original (n)
958 "Start composing a wide reply mail to the current message.
959 The original article will be yanked."
961 (gnus-summary-reply-with-original n t))
963 (defun gnus-summary-very-wide-reply (&optional yank)
964 "Start composing a very wide reply mail to the current message.
965 If prefix argument YANK is non-nil, the original article is yanked
968 (list (and current-prefix-arg
969 (gnus-summary-work-articles 1))))
970 (gnus-summary-reply yank t (gnus-summary-work-articles yank)))
972 (defun gnus-summary-very-wide-reply-with-original (n)
973 "Start composing a very wide reply mail to the current message.
974 The original article will be yanked."
977 (gnus-summary-work-articles n) t (gnus-summary-work-articles n)))
979 (defun gnus-summary-mail-forward (&optional arg post)
980 "Forward the current message(s) to another user.
981 If process marks exist, forward all marked messages;
982 if ARG is nil, see `message-forward-as-mime' and `message-forward-show-mml';
983 if ARG is 1, decode the message and forward directly inline;
984 if ARG is 2, forward message as an rfc822 MIME section;
985 if ARG is 3, decode message and forward as an rfc822 MIME section;
986 if ARG is 4, forward message directly inline;
987 otherwise, use flipped `message-forward-as-mime'.
988 If POST, post instead of mail.
989 For the `inline' alternatives, also see the variable
990 `message-forward-ignored-headers'."
992 (if (null (cdr (gnus-summary-work-articles nil)))
993 (let ((message-forward-as-mime message-forward-as-mime)
994 (message-forward-show-mml message-forward-show-mml))
998 (setq message-forward-as-mime nil
999 message-forward-show-mml t))
1001 (setq message-forward-as-mime t
1002 message-forward-show-mml nil))
1004 (setq message-forward-as-mime t
1005 message-forward-show-mml t))
1007 (setq message-forward-as-mime nil
1008 message-forward-show-mml nil))
1010 (setq message-forward-as-mime (not message-forward-as-mime))))
1011 (let ((gnus-article-reply (gnus-summary-article-number)))
1012 (gnus-setup-message 'forward
1013 (gnus-summary-select-article)
1014 (let ((mail-parse-charset gnus-newsgroup-charset)
1015 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
1016 (set-buffer gnus-original-article-buffer)
1017 (message-forward post)))))
1018 (gnus-uu-digest-mail-forward arg post)))
1020 (defun gnus-summary-resend-message (address n)
1021 "Resend the current article to ADDRESS."
1023 (list (message-read-from-minibuffer "Resend message(s) to: ")
1024 current-prefix-arg))
1025 (let ((articles (gnus-summary-work-articles n))
1027 (while (setq article (pop articles))
1028 (gnus-summary-select-article nil nil nil article)
1030 (set-buffer gnus-original-article-buffer)
1031 (message-resend address))
1032 (gnus-summary-mark-article-as-forwarded article))))
1034 (defun gnus-summary-post-forward (&optional arg)
1035 "Forward the current article to a newsgroup.
1036 See `gnus-summary-mail-forward' for ARG."
1038 (gnus-summary-mail-forward arg t))
1040 (defvar gnus-nastygram-message
1041 "The following article was inappropriately posted to %s.\n\n"
1042 "Format string to insert in nastygrams.
1043 The current group name will be inserted at \"%s\".")
1045 (defun gnus-summary-mail-nastygram (n)
1046 "Send a nastygram to the author of the current article."
1048 (when (or gnus-expert-user
1050 "Really send a nastygram to the author of the current article? "))
1051 (let ((group gnus-newsgroup-name))
1052 (gnus-summary-reply-with-original n)
1053 (set-buffer gnus-message-buffer)
1055 (insert (format gnus-nastygram-message group))
1056 (message-send-and-exit))))
1058 (defun gnus-summary-mail-crosspost-complaint (n)
1059 "Send a complaint about crossposting to the current article(s)."
1061 (let ((articles (gnus-summary-work-articles n))
1063 (while (setq article (pop articles))
1064 (set-buffer gnus-summary-buffer)
1065 (gnus-summary-goto-subject article)
1066 (let ((group (gnus-group-real-name gnus-newsgroup-name))
1067 newsgroups followup-to)
1068 (gnus-summary-select-article)
1069 (set-buffer gnus-original-article-buffer)
1070 (if (and (<= (length (message-tokenize-header
1072 (mail-fetch-field "newsgroups"))
1075 (or (not (setq followup-to (mail-fetch-field "followup-to")))
1076 (not (member group (message-tokenize-header
1077 followup-to ", ")))))
1079 (gnus-message 1 "Followup-to restricted")
1080 (gnus-message 1 "Not a crossposted article"))
1081 (set-buffer gnus-summary-buffer)
1082 (gnus-summary-reply-with-original 1)
1083 (set-buffer gnus-message-buffer)
1085 (insert (format gnus-crosspost-complaint newsgroups group))
1086 (message-goto-subject)
1087 (re-search-forward " *$")
1088 (replace-match " (crosspost notification)" t t)
1089 (gnus-deactivate-mark)
1090 (when (gnus-y-or-n-p "Send this complaint? ")
1091 (message-send-and-exit)))))))
1093 (defun gnus-mail-parse-comma-list ()
1096 (skip-chars-forward " ")
1099 (skip-chars-forward "^,")
1104 (narrow-to-region beg (point))
1107 (while (search-forward "\"" nil t)
1111 (skip-chars-forward ",")
1112 (skip-chars-forward "^,"))
1113 (skip-chars-backward " ")
1114 (push (buffer-substring beg (point))
1116 (skip-chars-forward "^,")
1117 (skip-chars-forward ", "))
1120 (defun gnus-inews-add-to-address (group)
1121 (let ((to-address (mail-fetch-field "to")))
1122 (when (and to-address
1124 ;; This mail group doesn't have a `to-list', so we add one
1126 (when (gnus-y-or-n-p
1127 (format "Do you want to add this as `to-list': %s " to-address))
1128 (gnus-group-add-parameter group (cons 'to-list to-address))))))
1130 (defun gnus-put-message ()
1131 "Put the current message in some group and return to Gnus."
1133 (let ((reply gnus-article-reply)
1134 (winconf gnus-prev-winconf)
1135 (group gnus-newsgroup-name))
1137 (not (gnus-group-read-only-p group)))
1138 (setq group (read-string "Put in group: " nil (gnus-writable-groups))))
1140 (when (gnus-gethash group gnus-newsrc-hashtb)
1141 (error "No such group: %s" group))
1145 (message-narrow-to-headers)
1146 (let ((gnus-deletable-headers nil))
1147 (message-generate-headers
1148 (if (message-news-p)
1149 message-required-news-headers
1150 message-required-mail-headers)))
1151 (goto-char (point-max))
1152 (insert "Gcc: " group "\n")
1155 (when (and (get-buffer gnus-group-buffer)
1156 (gnus-buffer-exists-p (car-safe reply))
1158 (set-buffer (car reply))
1159 (gnus-summary-mark-article-as-replied (cdr reply)))
1161 (set-window-configuration winconf))))
1163 (defun gnus-article-mail (yank)
1164 "Send a reply to the address near point.
1165 If YANK is non-nil, include the original article."
1169 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
1170 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
1172 (message-reply address)
1174 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
1176 (defvar nntp-server-type)
1178 "Send a bug report to the Gnus maintainers."
1180 (unless (gnus-alive-p)
1181 (error "Gnus has been shut down"))
1182 (gnus-setup-message (if (message-mail-user-agent) 'message 'bug)
1183 (unless (message-mail-user-agent)
1184 (delete-other-windows)
1185 (when gnus-bug-create-help-buffer
1186 (switch-to-buffer "*Gnus Help Bug*")
1188 (insert gnus-bug-message)
1189 (goto-char (point-min)))
1190 (message-pop-to-buffer "*Gnus Bug*"))
1191 (let ((message-this-is-mail t))
1192 (message-setup `((To . ,gnus-maintainer) (Subject . ""))))
1193 (when gnus-bug-create-help-buffer
1194 (push `(gnus-bug-kill-buffer) message-send-actions))
1195 (goto-char (point-min))
1196 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
1198 (insert (gnus-version) "\n"
1199 (emacs-version) "\n")
1200 (when (and (boundp 'nntp-server-type)
1201 (stringp nntp-server-type))
1202 (insert nntp-server-type))
1203 (insert "\n\n\n\n\n")
1206 (set-buffer (gnus-get-buffer-create " *gnus environment info*"))
1209 (setq text (buffer-string)))
1210 (insert "<#part type=application/x-emacs-lisp disposition=inline description=\"User settings\">\n" text "\n<#/part>"))
1211 (goto-char (point-min))
1212 (search-forward "Subject: " nil t)
1215 (defun gnus-bug-kill-buffer ()
1216 (when (get-buffer "*Gnus Help Bug*")
1217 (kill-buffer "*Gnus Help Bug*")))
1219 (defun gnus-summary-yank-message (buffer n)
1220 "Yank the current article into a composed message."
1222 (list (completing-read "Buffer: " (mapcar 'list (message-buffers)) nil t)
1223 current-prefix-arg))
1224 (gnus-summary-iterate n
1225 (let ((gnus-display-mime-function nil)
1226 (gnus-inhibit-treatment t))
1227 (gnus-summary-select-article))
1230 (message-yank-buffer gnus-article-buffer))))
1232 (defun gnus-debug ()
1233 "Attempts to go through the Gnus source file and report what variables have been changed.
1234 The source file has to be in the Emacs load path."
1236 (let ((files '("gnus.el" "gnus-sum.el" "gnus-group.el"
1237 "gnus-art.el" "gnus-start.el" "gnus-async.el"
1238 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
1239 "nnmail.el" "message.el"))
1241 file expr olist sym)
1242 (gnus-message 4 "Please wait while we snoop your variables...")
1244 ;; Go through all the files looking for non-default values for variables.
1246 (set-buffer (gnus-get-buffer-create " *gnus bug info*"))
1249 (when (and (setq file (locate-library (pop files)))
1250 (file-exists-p file))
1251 (insert-file-contents file)
1252 (goto-char (point-min))
1253 (if (not (re-search-forward "^;;* *Internal variables" nil t))
1254 (gnus-message 4 "Malformed sources in file %s" file)
1255 (narrow-to-region (point-min) (point))
1256 (goto-char (point-min))
1257 (while (setq expr (ignore-errors (read (current-buffer))))
1259 (and (or (eq (car expr) 'defvar)
1260 (eq (car expr) 'defcustom))
1261 (stringp (nth 3 expr))
1262 (or (not (boundp (nth 1 expr)))
1263 (not (equal (eval (nth 2 expr))
1264 (symbol-value (nth 1 expr)))))
1265 (push (nth 1 expr) olist)))))))
1266 (kill-buffer (current-buffer)))
1267 (when (setq olist (nreverse olist))
1268 (insert "------------------ Environment follows ------------------\n\n"))
1270 (if (boundp (car olist))
1272 (pp `(setq ,(car olist)
1273 ,(if (or (consp (setq sym (symbol-value (car olist))))
1275 (not (or (eq sym nil)
1277 (list 'quote (symbol-value (car olist)))
1278 (symbol-value (car olist))))
1281 (format "(setq %s 'whatever)\n" (car olist))))
1282 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
1283 (setq olist (cdr olist)))
1285 ;; Remove any control chars - they seem to cause trouble for some
1286 ;; mailers. (Byte-compiled output from the stuff above.)
1288 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
1289 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
1292 ;;; Treatment of rejected articles.
1295 (defun gnus-summary-resend-bounced-mail (&optional fetch)
1296 "Re-mail the current message.
1297 This only makes sense if the current message is a bounce message than
1298 contains some mail you have written which has been bounced back to
1300 If FETCH, try to fetch the article that this is a reply to, if indeed
1303 (gnus-summary-select-article t)
1304 (set-buffer gnus-original-article-buffer)
1305 (gnus-setup-message 'compose-bounce
1306 (let* ((references (mail-fetch-field "references"))
1307 (parent (and references (gnus-parent-id references))))
1309 ;; If there are references, we fetch the article we answered to.
1311 (gnus-summary-refer-article parent)
1312 (gnus-summary-show-all-headers)))))
1316 (defun gnus-inews-group-method (group)
1318 ;; If the group doesn't exist, we assume
1319 ;; it's an archive group...
1320 ((and (null (gnus-get-info group))
1321 (eq (car (gnus-server-to-method gnus-message-archive-method))
1322 (car (gnus-server-to-method (gnus-group-method group)))))
1323 gnus-message-archive-method)
1325 ((gnus-info-method (gnus-get-info group))
1326 (gnus-info-method (gnus-get-info group)))
1328 (t (gnus-server-to-method (gnus-group-method group)))))
1330 ;; Do Gcc handling, which copied the message over to some group.
1331 (defun gnus-inews-do-gcc (&optional gcc)
1335 (message-narrow-to-headers)
1336 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
1337 (cur (current-buffer))
1338 groups group method group-art)
1340 (message-remove-header "gcc")
1342 (setq groups (message-unquote-tokens
1343 (message-tokenize-header gcc " ,")))
1344 ;; Copy the article over to some group(s).
1345 (while (setq group (pop groups))
1346 (unless (gnus-check-server
1347 (setq method (gnus-inews-group-method group)))
1348 (error "Can't open server %s" (if (stringp method) method
1350 (unless (gnus-request-group group nil method)
1351 (gnus-request-create-group group method))
1353 (nnheader-set-temp-buffer " *acc*")
1354 (insert-buffer-substring cur)
1355 (message-encode-message-body)
1357 (message-narrow-to-headers)
1358 (let* ((mail-parse-charset message-default-charset)
1359 (newsgroups-field (save-restriction
1360 (message-narrow-to-headers-or-head)
1361 (message-fetch-field "Newsgroups")))
1362 (followup-field (save-restriction
1363 (message-narrow-to-headers-or-head)
1364 (message-fetch-field "Followup-To")))
1365 ;; BUG: We really need to get the charset for
1366 ;; each name in the Newsgroups and Followup-To
1367 ;; lines to allow crossposting between group
1368 ;; namess with incompatible character sets.
1369 ;; -- Per Abrahamsen <abraham@dina.kvl.dk> 2001-10-08.
1370 (group-field-charset
1371 (gnus-group-name-charset
1372 method (or newsgroups-field "")))
1373 (followup-field-charset
1374 (gnus-group-name-charset
1375 method (or followup-field "")))
1376 (rfc2047-header-encoding-alist
1378 (when group-field-charset
1379 (list (cons "Newsgroups" group-field-charset)))
1380 (when followup-field-charset
1381 (list (cons "Followup-To" followup-field-charset)))
1382 rfc2047-header-encoding-alist)))
1383 (mail-encode-encoded-word-buffer)))
1384 (goto-char (point-min))
1385 (when (re-search-forward
1386 (concat "^" (regexp-quote mail-header-separator) "$")
1388 (replace-match "" t t ))
1389 (unless (setq group-art
1390 (gnus-request-accept-article group method t t))
1391 (gnus-message 1 "Couldn't store article in group %s: %s"
1392 group (gnus-status-message method))
1394 (when (and group-art gnus-inews-mark-gcc-as-read)
1395 (gnus-group-mark-article-read group (cdr group-art)))
1396 (kill-buffer (current-buffer)))))))))
1398 (defun gnus-inews-insert-gcc ()
1399 "Insert Gcc headers based on `gnus-outgoing-message-group'."
1402 (message-narrow-to-headers)
1403 (let* ((group gnus-outgoing-message-group)
1405 ((gnus-functionp group)
1407 ((or (stringp group) (list group))
1411 (if (stringp gcc) gcc
1412 (mapconcat 'identity gcc " "))
1415 (defun gnus-inews-insert-archive-gcc (&optional group)
1416 "Insert the Gcc to say where the article is to be archived."
1417 (let* ((var gnus-message-archive-group)
1418 (group (or group gnus-newsgroup-name ""))
1420 (and gnus-newsgroup-name
1421 (not (equal gnus-newsgroup-name ""))
1422 (gnus-group-find-parameter
1423 gnus-newsgroup-name 'gcc-self)))
1427 ((null gnus-message-archive-method)
1431 ;; Just a single group.
1434 ;; We don't want this.
1436 ((and (listp var) (stringp (car var)))
1437 ;; A list of groups.
1439 ((gnus-functionp var)
1441 (funcall var group))
1443 ;; An alist of regexps/functions/forms.
1448 ((stringp (caar var))
1450 (when (string-match (caar var) group)
1452 ((gnus-functionp (car var))
1454 (funcall (car var) group))
1456 (eval (car var)))))))
1457 (setq var (cdr var)))
1460 (when (or groups gcc-self-val)
1461 (when (stringp groups)
1462 (setq groups (list groups)))
1465 (message-narrow-to-headers)
1466 (goto-char (point-max))
1469 ;; Use the `gcc-self' param value instead.
1472 (if (stringp gcc-self-val)
1475 (if (not (eq gcc-self-val 'none))
1480 ;; Use the list of groups.
1481 (while (setq name (pop groups))
1482 (insert (if (string-match ":" name)
1484 (gnus-group-prefixed-name
1485 name gnus-message-archive-method)))
1492 (defun gnus-configure-posting-styles (&optional group-name)
1493 "Configure posting styles according to `gnus-posting-styles'."
1494 (unless gnus-inhibit-posting-styles
1495 (let ((group (or group-name gnus-newsgroup-name ""))
1496 (styles gnus-posting-styles)
1497 style match variable attribute value v results
1498 filep name address element)
1499 ;; If the group has a posting-style parameter, add it at the end with a
1500 ;; regexp matching everything, to be sure it takes precedence over all
1502 (when gnus-newsgroup-name
1503 (let ((tmp-style (gnus-group-find-parameter group 'posting-style t)))
1505 (setq styles (append styles (list (cons ".*" tmp-style)))))))
1506 ;; Go through all styles and look for matches.
1507 (dolist (style styles)
1508 (setq match (pop style))
1509 (goto-char (point-min))
1512 ;; Regexp string match on the group name.
1513 (string-match match group))
1515 (and (gnus-buffer-live-p gnus-article-copy)
1516 (with-current-buffer gnus-article-copy
1517 (let ((header (message-fetch-field (pop style))))
1519 (string-match (pop style) header))))))
1520 ((or (symbolp match)
1521 (gnus-functionp match))
1523 ((gnus-functionp match)
1524 ;; Function to be called.
1527 ;; Variable to be checked.
1528 (symbol-value match))))
1530 ;; This is a form to be evaled.
1532 ;; We have a match, so we set the variables.
1533 (dolist (attribute style)
1534 (setq element (pop attribute)
1539 ((eq (car attribute) :file)
1542 ((eq (car attribute) :value)
1546 ;; We get the value.
1551 ((or (symbolp value)
1552 (gnus-functionp value))
1553 (cond ((gnus-functionp value)
1556 (symbol-value value))))
1559 ;; Translate obsolescent value.
1560 (when (eq element 'signature-file)
1561 (setq element 'signature
1563 ;; Get the contents of file elems.
1565 (setq v (with-temp-buffer
1566 (insert-file-contents v)
1568 (setq results (delq (assoc element results) results))
1569 (push (cons element v) results))))
1570 ;; Now we have all the styles, so we insert them.
1571 (setq name (assq 'name results)
1572 address (assq 'address results))
1573 (setq results (delq name (delq address results)))
1574 ;; make-local-hook is not obsolete in Emacs 20 or XEmacs.
1575 (make-local-hook 'message-setup-hook)
1576 (dolist (result results)
1577 (add-hook 'message-setup-hook
1579 ((eq 'eval (car result))
1581 ((eq 'body (car result))
1585 (insert ,(cdr result)))))
1586 ((eq 'signature (car result))
1587 (set (make-local-variable 'message-signature) nil)
1588 (set (make-local-variable 'message-signature-file) nil)
1589 (if (not (cdr result))
1593 (let ((message-signature ,(cdr result)))
1594 (when message-signature
1595 (message-insert-signature)))))))
1598 (if (symbolp (car result))
1599 (capitalize (symbol-name (car result)))
1603 (message-remove-header ,header)
1604 (let ((value ,(cdr result)))
1607 (insert ,header ": " value "\n"))))))))
1609 (when (or name address)
1610 (add-hook 'message-setup-hook
1612 (set (make-local-variable 'user-mail-address)
1613 ,(or (cdr address) user-mail-address))
1614 (let ((user-full-name ,(or (cdr name) (user-full-name)))
1616 ,(or (cdr address) user-mail-address)))
1618 (message-remove-header "From")
1620 (insert "From: " (message-make-from) "\n"))))
1623 ;;; Allow redefinition of functions.
1629 ;;; gnus-msg.el ends here