1 ;;; gnus-msg.el --- mail and post interface for Gnus
2 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
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-gcc-externalize-attachments nil
141 "Should local-file attachments be included as external parts in Gcc copies?
142 If it is `all', attach files as external parts;
143 if a regexp and matches the Gcc group name, attach files as external parts;
144 If nil, attach files as normal parts."
146 :type '(choice (const nil :tag "None")
147 (const all :tag "Any")
148 (string :tag "Regexp")))
150 (defcustom gnus-group-posting-charset-alist
151 '(("^\\(no\\|fr\\)\\.[^,]*\\(,[ \t\n]*\\(no\\|fr\\)\\.[^,]*\\)*$" iso-8859-1 (iso-8859-1))
152 ("^\\(fido7\\|relcom\\)\\.[^,]*\\(,[ \t\n]*\\(fido7\\|relcom\\)\\.[^,]*\\)*$" koi8-r (koi8-r))
153 (message-this-is-mail nil nil)
154 (message-this-is-news nil t))
155 "Alist of regexps and permitted unencoded charsets for posting.
156 Each element of the alist has the form (TEST HEADER BODY-LIST), where
157 TEST is either a regular expression matching the newsgroup header or a
159 HEADER is the charset which may be left unencoded in the header (nil
160 means encode all charsets),
161 BODY-LIST is a list of charsets which may be encoded using 8bit
162 content-transfer encoding in the body, or one of the special values
163 nil (always encode using quoted-printable) or t (always use 8bit).
165 Note that any value other than nil for HEADER infringes some RFCs, so
166 use this option with care."
167 :type '(repeat (list :tag "Permitted unencoded charsets"
169 (regexp :tag "Group")
170 (const :tag "Mail message" :value message-this-is-mail)
171 (const :tag "News article" :value message-this-is-news))
172 (choice :tag "Header"
173 (const :tag "None" nil)
174 (symbol :tag "Charset"))
176 (const :tag "Any" :value t)
177 (const :tag "None" :value nil)
178 (repeat :tag "Charsets"
179 (symbol :tag "Charset")))))
180 :group 'gnus-charset)
182 ;;; Internal variables.
184 (defvar gnus-inhibit-posting-styles nil
185 "Inhibit the use of posting styles.")
187 (defvar gnus-message-buffer "*Mail Gnus*")
188 (defvar gnus-article-copy nil)
189 (defvar gnus-check-before-posting nil)
190 (defvar gnus-last-posting-server nil)
191 (defvar gnus-message-group-art nil)
193 (defvar gnus-msg-force-broken-reply-to nil)
195 (defconst gnus-bug-message
196 "Sending a bug report to the Gnus Towers.
197 ========================================
199 The buffer below is a mail buffer. When you press `C-c C-c', it will
200 be sent to the Gnus Bug Exterminators.
202 The thing near the bottom of the buffer is how the environment
203 settings will be included in the mail. Please do not delete that.
204 They will tell the Bug People what your environment is, so that it
205 will be easier to locate the bugs.
207 If you have found a bug that makes Emacs go \"beep\", set
208 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
209 and include the backtrace in your bug report.
211 Please describe the bug in annoying, painstaking detail.
213 Thank you for your help in stamping out bugs.
217 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
218 (autoload 'news-setup "rnewspost")
219 (autoload 'news-reply-mode "rnewspost")
220 (autoload 'rmail-dont-reply-to "mail-utils")
221 (autoload 'rmail-output "rmailout"))
225 ;;; Gnus Posting Functions
228 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
229 "p" gnus-summary-post-news
230 "i" gnus-summary-news-other-window
231 "f" gnus-summary-followup
232 "F" gnus-summary-followup-with-original
233 "c" gnus-summary-cancel-article
234 "s" gnus-summary-supersede-article
235 "r" gnus-summary-reply
236 "y" gnus-summary-yank-message
237 "R" gnus-summary-reply-with-original
238 "w" gnus-summary-wide-reply
239 "W" gnus-summary-wide-reply-with-original
240 "v" gnus-summary-very-wide-reply
241 "W" gnus-summary-very-wide-reply-with-original
242 "n" gnus-summary-followup-to-mail
243 "N" gnus-summary-followup-to-mail-with-original
244 "m" gnus-summary-mail-other-window
245 "u" gnus-uu-post-news
246 "\M-c" gnus-summary-mail-crosspost-complaint
247 "Br" gnus-summary-reply-broken-reply-to
248 "BR" gnus-summary-reply-broken-reply-to-with-original
249 "om" gnus-summary-mail-forward
250 "op" gnus-summary-post-forward
251 "Om" gnus-uu-digest-mail-forward
252 "Op" gnus-uu-digest-post-forward)
254 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
255 "b" gnus-summary-resend-bounced-mail
256 ;; "c" gnus-summary-send-draft
257 "r" gnus-summary-resend-message)
259 ;;; Internal functions.
261 (defvar gnus-article-reply nil)
262 (defmacro gnus-setup-message (config &rest forms)
263 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
264 (buffer (make-symbol "gnus-setup-message-buffer"))
265 (article (make-symbol "gnus-setup-message-article"))
266 (group (make-symbol "gnus-setup-message-group")))
267 `(let ((,winconf (current-window-configuration))
268 (,buffer (buffer-name (current-buffer)))
269 (,article gnus-article-reply)
270 (,group gnus-newsgroup-name)
271 (message-header-setup-hook
272 (copy-sequence message-header-setup-hook))
273 (mbl mml-buffer-list)
274 (message-mode-hook (copy-sequence message-mode-hook)))
275 (setq mml-buffer-list nil)
276 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
277 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
278 ;; #### FIXME: for a reason that I did not manage to identify yet,
279 ;; the variable `gnus-newsgroup-name' does not honor a dynamically
280 ;; scoped or setq'ed value from a caller like `C-u gnus-summary-mail'.
281 ;; After evaluation of @forms below, it gets the value we actually want
282 ;; to override, and the posting styles are used. For that reason, I've
283 ;; added an optional argument to `gnus-configure-posting-styles' to
284 ;; make sure that the correct value for the group name is used. -- drv
285 (add-hook 'message-mode-hook
287 (gnus-configure-posting-styles ,group)))
291 (gnus-inews-add-send-actions ,winconf ,buffer ,article ,config)
292 (gnus-inews-insert-draft-meta-information ,group ,article)
293 (setq gnus-message-buffer (current-buffer))
294 (set (make-local-variable 'gnus-message-group-art)
295 (cons ,group ,article))
296 (set (make-local-variable 'gnus-newsgroup-name) ,group)
297 (gnus-run-hooks 'gnus-message-setup-hook)
298 (if (eq major-mode 'message-mode)
299 (let ((mbl1 mml-buffer-list))
300 (setq mml-buffer-list mbl) ;; Global value
301 (set (make-local-variable 'mml-buffer-list) mbl1);; Local value
302 ;; LOCAL argument of add-hook differs between GNU Emacs
303 ;; and XEmacs. make-local-hook makes sure they are local.
304 (make-local-hook 'kill-buffer-hook)
305 (make-local-hook 'change-major-mode-hook)
306 (add-hook 'change-major-mode-hook 'mml-destroy-buffers nil t)
307 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))
308 (mml-destroy-buffers)
309 (setq mml-buffer-list mbl)))
311 (gnus-configure-windows ,config t)
312 (run-hooks 'post-command-hook)
313 (set-buffer-modified-p nil))))
315 (defun gnus-inews-insert-draft-meta-information (group article)
318 (not (string= group ""))
319 (not (message-fetch-field gnus-draft-meta-information-header)))
320 (goto-char (point-min))
321 (insert gnus-draft-meta-information-header ": (\"" group "\" "
322 (if article (number-to-string
329 (defun gnus-msg-mail (&optional to subject other-headers continue
330 switch-action yank-action send-actions)
331 "Start editing a mail message to be sent.
332 Like `message-mail', but with Gnus paraphernalia, particularly the
333 Gcc: header for archiving purposes."
335 (let ((buf (current-buffer))
337 (gnus-setup-message 'message
338 (message-mail to subject other-headers continue
339 nil yank-action send-actions))
341 (setq mail-buf (current-buffer))
342 (switch-to-buffer buf)
343 (apply switch-action mail-buf nil)))
344 ;; COMPOSEFUNC should return t if succeed. Undocumented ???
347 (defvar save-selected-window-window)
350 (defun gnus-button-mailto (address)
352 (set-buffer (gnus-copy-article-buffer))
353 (gnus-setup-message 'message
354 (message-reply address))
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 (defun gnus-button-reply (&optional to-address wide)
361 "Like `message-reply'."
363 (gnus-setup-message 'message
364 (message-reply to-address wide))
365 (and (boundp 'save-selected-window-window)
366 (not (window-live-p save-selected-window-window))
367 (setq save-selected-window-window (selected-window))))
370 (define-mail-user-agent 'gnus-user-agent
371 'gnus-msg-mail 'message-send-and-exit
372 'message-kill-buffer 'message-send-hook)
374 (defun gnus-setup-posting-charset (group)
375 (let ((alist gnus-group-posting-charset-alist)
376 (group (or group ""))
380 (while (setq elem (pop alist))
381 (when (or (and (stringp (car elem))
382 (string-match (car elem) group))
383 (and (gnus-functionp (car elem))
384 (funcall (car elem) group))
385 (and (symbolp (car elem))
386 (symbol-value (car elem))))
387 (throw 'found (cons (cadr elem) (caddr elem)))))))))
389 (defun gnus-inews-add-send-actions (winconf buffer article &optional config)
390 (make-local-hook 'message-sent-hook)
391 (add-hook 'message-sent-hook (if gnus-agent 'gnus-agent-possibly-do-gcc
392 'gnus-inews-do-gcc) nil t)
394 (make-local-hook 'message-header-hook)
395 (add-hook 'message-header-hook 'gnus-agent-possibly-save-gcc nil t))
396 (setq message-post-method
398 (gnus-post-method arg ,gnus-newsgroup-name)))
399 (setq message-newsreader (setq message-mailer (gnus-extended-version)))
401 `(set-window-configuration ,winconf) 'exit 'postpone 'kill)
403 `(when (gnus-buffer-exists-p ,buffer)
407 (if (eq config 'forward)
408 `(gnus-summary-mark-article-as-forwarded ',article)
409 `(gnus-summary-mark-article-as-replied ',article)))))
412 (put 'gnus-setup-message 'lisp-indent-function 1)
413 (put 'gnus-setup-message 'edebug-form-spec '(form body))
415 ;;; Post news commands of Gnus group mode and summary mode
417 (defun gnus-group-mail (&optional arg)
418 "Start composing a mail.
419 If ARG, use the group under the point to find a posting style.
420 If ARG is 1, prompt for a group name to find the posting style."
422 ;; We can't `let' gnus-newsgroup-name here, since that leads
423 ;; to local variables leaking.
424 (let ((group gnus-newsgroup-name)
425 (buffer (current-buffer)))
428 (setq gnus-newsgroup-name
430 (if (= 1 (prefix-numeric-value arg))
431 (completing-read "Use posting style of group: "
432 gnus-active-hashtb nil
433 (gnus-read-active-file-p))
434 (gnus-group-group-name))
436 ;; #### see comment in gnus-setup-message -- drv
437 (gnus-setup-message 'message (message-mail)))
440 (setq gnus-newsgroup-name group)))))
442 (defun gnus-group-news (&optional arg)
443 "Start composing a news.
444 If ARG, post to group under point.
445 If ARG is 1, prompt for group name to post to.
447 This function prepares a news even when using mail groups. This is useful
448 for posting messages to mail groups without actually sending them over the
449 network. The corresponding backend must have a 'request-post method."
451 ;; We can't `let' gnus-newsgroup-name here, since that leads
452 ;; to local variables leaking.
453 (let ((group gnus-newsgroup-name)
454 (buffer (current-buffer)))
457 (setq gnus-newsgroup-name
459 (if (= 1 (prefix-numeric-value arg))
460 (completing-read "Use group: "
461 gnus-active-hashtb nil
462 (gnus-read-active-file-p))
463 (gnus-group-group-name))
465 ;; #### see comment in gnus-setup-message -- drv
466 (gnus-setup-message 'message
467 (message-news (gnus-group-real-name gnus-newsgroup-name))))
470 (setq gnus-newsgroup-name group)))))
472 (defun gnus-group-post-news (&optional arg)
473 "Start composing a message (a news by default).
474 If ARG, post to group under point. If ARG is 1, prompt for group name.
475 Depending on the selected group, the message might be either a mail or
478 ;; Bind this variable here to make message mode hooks work ok.
479 (let ((gnus-newsgroup-name
481 (if (= 1 (prefix-numeric-value arg))
482 (completing-read "Newsgroup: " gnus-active-hashtb nil
483 (gnus-read-active-file-p))
484 (gnus-group-group-name))
486 (gnus-post-news 'post gnus-newsgroup-name)))
488 (defun gnus-summary-mail-other-window (&optional arg)
489 "Start composing a mail in another window.
490 Use the posting of the current group by default.
491 If ARG, don't do that. If ARG is 1, prompt for group name to find the
494 ;; We can't `let' gnus-newsgroup-name here, since that leads
495 ;; to local variables leaking.
496 (let ((group gnus-newsgroup-name)
497 (buffer (current-buffer)))
500 (setq gnus-newsgroup-name
502 (if (= 1 (prefix-numeric-value arg))
503 (completing-read "Use group: "
504 gnus-active-hashtb nil
505 (gnus-read-active-file-p))
507 gnus-newsgroup-name))
508 ;; #### see comment in gnus-setup-message -- drv
509 (gnus-setup-message 'message (message-mail)))
512 (setq gnus-newsgroup-name group)))))
514 (defun gnus-summary-news-other-window (&optional arg)
515 "Start composing a news in another window.
516 Post to the current group by default.
517 If ARG, don't do that. If ARG is 1, prompt for group name to post to.
519 This function prepares a news even when using mail groups. This is useful
520 for posting messages to mail groups without actually sending them over the
521 network. The corresponding backend must have a 'request-post method."
523 ;; We can't `let' gnus-newsgroup-name here, since that leads
524 ;; to local variables leaking.
525 (let ((group gnus-newsgroup-name)
526 (buffer (current-buffer)))
529 (setq gnus-newsgroup-name
531 (if (= 1 (prefix-numeric-value arg))
532 (completing-read "Use group: "
533 gnus-active-hashtb nil
534 (gnus-read-active-file-p))
536 gnus-newsgroup-name))
537 ;; #### see comment in gnus-setup-message -- drv
538 (gnus-setup-message 'message
539 (message-news (gnus-group-real-name gnus-newsgroup-name))))
542 (setq gnus-newsgroup-name group)))))
544 (defun gnus-summary-post-news (&optional arg)
545 "Start composing a message. Post to the current group by default.
546 If ARG, don't do that. If ARG is 1, prompt for a group name to post to.
547 Depending on the selected group, the message might be either a mail or
550 ;; Bind this variable here to make message mode hooks work ok.
551 (let ((gnus-newsgroup-name
553 (if (= 1 (prefix-numeric-value arg))
554 (completing-read "Newsgroup: " gnus-active-hashtb nil
555 (gnus-read-active-file-p))
557 gnus-newsgroup-name)))
558 (gnus-post-news 'post gnus-newsgroup-name)))
561 (defun gnus-summary-followup (yank &optional force-news)
562 "Compose a followup to an article.
563 If prefix argument YANK is non-nil, the original article is yanked
565 YANK is a list of elements, where the car of each element is the
566 article number, and the two following numbers is the region to be
569 (list (and current-prefix-arg
570 (gnus-summary-work-articles 1))))
572 (gnus-summary-goto-subject
573 (if (listp (car yank))
576 (save-window-excursion
577 (gnus-summary-select-article))
578 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
579 (gnus-newsgroup-name gnus-newsgroup-name))
581 (gnus-post-news nil gnus-newsgroup-name
582 headers gnus-article-buffer
583 yank nil force-news)))
585 (defun gnus-summary-followup-with-original (n &optional force-news)
586 "Compose a followup to an article and include the original article."
588 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
590 (defun gnus-summary-followup-to-mail (&optional arg)
591 "Followup to the current mail message via news."
593 (list (and current-prefix-arg
594 (gnus-summary-work-articles 1))))
595 (gnus-summary-followup arg t))
597 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
598 "Followup to the current mail message via news."
600 (gnus-summary-followup (gnus-summary-work-articles arg) t))
602 (defun gnus-inews-yank-articles (articles)
603 (let (beg article yank-string)
605 (while (setq article (pop articles))
606 (when (listp article)
607 (setq yank-string (nth 1 article)
608 article (nth 0 article)))
609 (save-window-excursion
610 (set-buffer gnus-summary-buffer)
611 (gnus-summary-select-article nil nil nil article)
612 (gnus-summary-remove-process-mark article))
613 (gnus-copy-article-buffer nil yank-string)
614 (let ((message-reply-buffer gnus-article-copy)
615 (message-reply-headers
616 ;; The headers are decoded.
617 (with-current-buffer gnus-article-copy
618 (nnheader-parse-head t))))
619 (message-yank-original)
620 (setq beg (or beg (mark t))))
626 (defun gnus-summary-cancel-article (&optional n symp)
627 "Cancel an article you posted.
628 Uses the process-prefix convention. If given the symbolic
629 prefix `a', cancel using the standard posting method; if not
630 post using the current select method."
631 (interactive (gnus-interactive "P\ny"))
632 (let ((articles (gnus-summary-work-articles n))
635 (gnus-post-method (not (eq symp 'a)) ,gnus-newsgroup-name)))
637 (while (setq article (pop articles))
638 (when (gnus-summary-select-article t nil nil article)
639 (when (gnus-eval-in-buffer-window gnus-original-article-buffer
640 (message-cancel-news))
641 (gnus-summary-mark-as-read article gnus-canceled-mark)
642 (gnus-cache-remove-article 1))
643 (gnus-article-hide-headers-if-wanted))
644 (gnus-summary-remove-process-mark article))))
646 (defun gnus-summary-supersede-article ()
647 "Compose an article that will supersede a previous article.
648 This is done simply by taking the old article and adding a Supersedes
649 header line with the old Message-ID."
651 (let ((article (gnus-summary-article-number)))
652 (gnus-setup-message 'reply-yank
653 (gnus-summary-select-article t)
654 (set-buffer gnus-original-article-buffer)
658 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
660 (set-buffer ,gnus-summary-buffer)
661 (gnus-cache-possibly-remove-article ,article nil nil nil t)
662 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
663 message-send-actions))))
667 (defun gnus-copy-article-buffer (&optional article-buffer yank-string)
668 ;; make a copy of the article buffer with all text properties removed
669 ;; this copy is in the buffer gnus-article-copy.
670 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
671 ;; this buffer should be passed to all mail/news reply/post routines.
672 (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
674 (set-buffer gnus-article-copy)
675 (mm-enable-multibyte))
676 (let ((article-buffer (or article-buffer gnus-article-buffer))
678 (if (not (and (get-buffer article-buffer)
679 (gnus-buffer-exists-p article-buffer)))
680 (error "Can't find any article buffer")
682 (set-buffer article-buffer)
683 (let ((gnus-newsgroup-charset (or gnus-article-charset
684 gnus-newsgroup-charset))
685 (gnus-newsgroup-ignored-charsets
686 (or gnus-article-ignored-charsets
687 gnus-newsgroup-ignored-charsets)))
689 ;; Copy over the (displayed) article buffer, delete
690 ;; hidden text and remove text properties.
692 (copy-to-buffer gnus-article-copy (point-min) (point-max))
693 (set-buffer gnus-article-copy)
696 (delete-region (point) (point-max))
697 (insert yank-string))
698 (gnus-article-delete-text-of-type 'annotation)
699 (gnus-remove-text-with-property 'gnus-prev)
700 (gnus-remove-text-with-property 'gnus-next)
703 (buffer-substring-no-properties (point-min) (point-max))
705 ;; Find the original headers.
706 (set-buffer gnus-original-article-buffer)
707 (goto-char (point-min))
708 (while (looking-at message-unix-mail-delimiter)
711 end (or (message-goto-body) beg))
712 ;; Delete the headers from the displayed articles.
713 (set-buffer gnus-article-copy)
714 (delete-region (goto-char (point-min))
715 (or (message-goto-body) (point-max)))
716 ;; Insert the original article headers.
717 (insert-buffer-substring gnus-original-article-buffer beg end)
719 (let ((gnus-article-decode-hook
720 (delq 'article-decode-charset
721 (copy-sequence gnus-article-decode-hook))))
722 (run-hooks 'gnus-article-decode-hook)))))
725 (defun gnus-post-news (post &optional group header article-buffer yank subject
728 (gnus-copy-article-buffer))
729 (let ((gnus-article-reply (and article-buffer (gnus-summary-article-number)))
730 (add-to-list gnus-add-to-list))
731 (gnus-setup-message (cond (yank 'reply-yank)
732 (article-buffer 'reply)
734 (let* ((group (or group gnus-newsgroup-name))
735 (charset (gnus-group-name-charset nil group))
737 to-address to-group mailing-list to-list
740 (setq to-address (gnus-parameter-to-address group)
741 to-group (gnus-group-find-parameter group 'to-group)
742 to-list (gnus-parameter-to-list group)
743 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
744 mailing-list (when gnus-mailing-list-groups
745 (string-match gnus-mailing-list-groups group))
746 group (gnus-group-name-decode (gnus-group-real-name group)
748 (if (or (and to-group
749 (gnus-news-group-p to-group))
752 (and (gnus-news-group-p
753 (or pgroup gnus-newsgroup-name)
754 (or header gnus-current-article))
760 (message-news (or to-group group))
761 (set-buffer gnus-article-copy)
762 (gnus-msg-treat-broken-reply-to)
763 (message-followup (if (or newsgroup-p force-news)
764 (if (save-restriction
765 (article-narrow-to-head)
766 (message-fetch-field "newsgroups"))
773 (message-mail (or to-address to-list))
774 ;; Arrange for mail groups that have no `to-address' to
775 ;; get that when the user sends off the mail.
776 (when (and (not to-list)
779 (push (list 'gnus-inews-add-to-address pgroup)
780 message-send-actions)))
781 (set-buffer gnus-article-copy)
782 (gnus-msg-treat-broken-reply-to)
783 (message-wide-reply to-address)))
785 (gnus-inews-yank-articles yank))))))
787 (defun gnus-msg-treat-broken-reply-to (&optional force)
788 "Remove the Reply-to header iff broken-reply-to."
790 (gnus-group-find-parameter
791 gnus-newsgroup-name 'broken-reply-to))
793 (message-narrow-to-head)
794 (message-remove-header "reply-to"))))
796 (defun gnus-post-method (arg group &optional silent)
797 "Return the posting method based on GROUP and ARG.
798 If SILENT, don't prompt the user."
799 (let ((gnus-post-method (or (gnus-parameter-post-method group)
801 (group-method (gnus-find-method-for-group group)))
803 ;; If the group-method is nil (which shouldn't happen) we use
804 ;; the default method.
806 (or (and (listp gnus-post-method) ;If not current/native/nil
807 (not (listp (car gnus-post-method))) ; and not a list of methods
808 gnus-post-method) ;then use it.
810 message-post-method))
811 ;; We want the inverse of the default
812 ((and arg (not (eq arg 0)))
813 (if (eq gnus-post-method 'current)
816 ;; We query the user for a post method.
818 (and (listp gnus-post-method)
819 (listp (car gnus-post-method))))
821 ;; Collect all methods we know about.
823 (when (listp gnus-post-method)
824 (if (listp (car gnus-post-method))
826 (list gnus-post-method)))
827 gnus-secondary-select-methods
828 (mapcar 'cdr gnus-server-alist)
829 (mapcar 'car gnus-opened-servers)
830 (list gnus-select-method)
831 (list group-method)))
832 method-alist post-methods method)
833 ;; Weed out all mail methods.
835 (setq method (gnus-server-get-method "" (pop methods)))
836 (when (and (or (gnus-method-option-p method 'post)
837 (gnus-method-option-p method 'post-mail))
838 (not (member method post-methods)))
839 (push method post-methods)))
840 ;; Create a name-method alist.
844 (if (equal (cadr m) "")
845 (list (symbol-name (car m)) m)
846 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m)))
851 (setq gnus-last-posting-server
853 gnus-last-posting-server)
854 ;; Just use the last value.
855 gnus-last-posting-server
857 "Posting method: " method-alist nil t
858 (cons (or gnus-last-posting-server "") 0))))
860 ;; Override normal method.
861 ((and (eq gnus-post-method 'current)
862 (not (eq (car group-method) 'nndraft))
863 (gnus-get-function group-method 'request-post t))
866 ;; Use gnus-post-method.
867 ((listp gnus-post-method) ;A method...
868 (assert (not (listp (car gnus-post-method)))) ;... not a list of methods.
870 ;; Use the normal select method (nil or native).
871 (t gnus-select-method))))
875 ;; Dummies to avoid byte-compile warning.
877 (defvar nnspool-rejected-article-hook)
878 (defvar xemacs-codename))
880 (defun gnus-extended-version ()
881 "Stringified Gnus version and Emacs version."
884 "Gnus/" (prin1-to-string (gnus-continuum-version gnus-version) t)
885 " (" gnus-version ")"
888 ((string-match "^\\(\\([.0-9]+\\)*\\)\\.[0-9]+$" emacs-version)
889 (concat "Emacs/" (match-string 1 emacs-version)
890 " (" system-configuration ")"))
891 ((string-match "\\([A-Z]*[Mm][Aa][Cc][Ss]\\)[^(]*\\(\\((beta.*)\\|'\\)\\)?"
893 (concat (match-string 1 emacs-version)
894 (format "/%d.%d" emacs-major-version emacs-minor-version)
895 (if (match-beginning 3)
896 (match-string 3 emacs-version)
898 (if (boundp 'xemacs-codename)
899 (concat " (" xemacs-codename ", " system-configuration ")")
905 ;;; Gnus Mail Functions
908 ;;; Mail reply commands of Gnus summary mode
910 (defun gnus-summary-reply (&optional yank wide very-wide)
911 "Start composing a mail reply to the current message.
912 If prefix argument YANK is non-nil, the original article is yanked
914 If WIDE, make a wide reply.
915 If VERY-WIDE, make a very wide reply."
917 (list (and current-prefix-arg
918 (gnus-summary-work-articles 1))))
919 ;; Stripping headers should be specified with mail-yank-ignored-headers.
921 (gnus-summary-goto-subject
922 (if (listp (car yank))
925 (let ((gnus-article-reply (or yank (gnus-summary-article-number)))
927 (gnus-setup-message (if yank 'reply-yank 'reply)
929 (gnus-summary-select-article)
930 (dolist (article very-wide)
931 (gnus-summary-select-article nil nil nil article)
933 (set-buffer (gnus-copy-article-buffer))
934 (gnus-msg-treat-broken-reply-to)
936 (message-narrow-to-head)
937 (setq headers (concat headers (buffer-string)))))))
938 (set-buffer (gnus-copy-article-buffer))
939 (gnus-msg-treat-broken-reply-to gnus-msg-force-broken-reply-to)
941 (message-narrow-to-head)
945 (goto-char (point-max)))
946 (mml-quote-region (point) (point-max))
947 (message-reply nil wide)
949 (gnus-inews-yank-articles yank)))))
951 (defun gnus-summary-reply-with-original (n &optional wide)
952 "Start composing a reply mail to the current message.
953 The original article will be yanked."
955 (gnus-summary-reply (gnus-summary-work-articles n) wide))
957 (defun gnus-summary-reply-broken-reply-to (&optional yank wide very-wide)
958 "Like `gnus-summary-reply' except removing reply-to field.
959 If prefix argument YANK is non-nil, the original article is yanked
961 If WIDE, make a wide reply.
962 If VERY-WIDE, make a very wide reply."
964 (list (and current-prefix-arg
965 (gnus-summary-work-articles 1))))
966 (let ((gnus-msg-force-broken-reply-to t))
967 (gnus-summary-reply yank wide very-wide)))
969 (defun gnus-summary-reply-broken-reply-to-with-original (n &optional wide)
970 "Like `gnus-summary-reply-with-original' except removing reply-to field.
971 The original article will be yanked."
973 (gnus-summary-reply-broken-reply-to (gnus-summary-work-articles n) wide))
975 (defun gnus-summary-wide-reply (&optional yank)
976 "Start composing a wide reply mail to the current message.
977 If prefix argument YANK is non-nil, the original article is yanked
980 (list (and current-prefix-arg
981 (gnus-summary-work-articles 1))))
982 (gnus-summary-reply yank t))
984 (defun gnus-summary-wide-reply-with-original (n)
985 "Start composing a wide reply mail to the current message.
986 The original article will be yanked."
988 (gnus-summary-reply-with-original n t))
990 (defun gnus-summary-very-wide-reply (&optional yank)
991 "Start composing a very wide reply mail to the current message.
992 If prefix argument YANK is non-nil, the original article is yanked
995 (list (and current-prefix-arg
996 (gnus-summary-work-articles 1))))
997 (gnus-summary-reply yank t (gnus-summary-work-articles yank)))
999 (defun gnus-summary-very-wide-reply-with-original (n)
1000 "Start composing a very wide reply mail to the current message.
1001 The original article will be yanked."
1004 (gnus-summary-work-articles n) t (gnus-summary-work-articles n)))
1006 (defun gnus-summary-mail-forward (&optional arg post)
1007 "Forward the current message(s) to another user.
1008 If process marks exist, forward all marked messages;
1009 if ARG is nil, see `message-forward-as-mime' and `message-forward-show-mml';
1010 if ARG is 1, decode the message and forward directly inline;
1011 if ARG is 2, forward message as an rfc822 MIME section;
1012 if ARG is 3, decode message and forward as an rfc822 MIME section;
1013 if ARG is 4, forward message directly inline;
1014 otherwise, use flipped `message-forward-as-mime'.
1015 If POST, post instead of mail.
1016 For the `inline' alternatives, also see the variable
1017 `message-forward-ignored-headers'."
1019 (if (null (cdr (gnus-summary-work-articles nil)))
1020 (let ((message-forward-as-mime message-forward-as-mime)
1021 (message-forward-show-mml message-forward-show-mml))
1025 (setq message-forward-as-mime nil
1026 message-forward-show-mml t))
1028 (setq message-forward-as-mime t
1029 message-forward-show-mml nil))
1031 (setq message-forward-as-mime t
1032 message-forward-show-mml t))
1034 (setq message-forward-as-mime nil
1035 message-forward-show-mml nil))
1037 (setq message-forward-as-mime (not message-forward-as-mime))))
1038 (let ((gnus-article-reply (gnus-summary-article-number)))
1039 (gnus-setup-message 'forward
1040 (gnus-summary-select-article)
1041 (let ((mail-parse-charset gnus-newsgroup-charset)
1042 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
1043 (set-buffer gnus-original-article-buffer)
1044 (message-forward post)))))
1045 (gnus-uu-digest-mail-forward arg post)))
1047 (defun gnus-summary-resend-message (address n)
1048 "Resend the current article to ADDRESS."
1050 (list (message-read-from-minibuffer "Resend message(s) to: ")
1051 current-prefix-arg))
1052 (let ((articles (gnus-summary-work-articles n))
1054 (while (setq article (pop articles))
1055 (gnus-summary-select-article nil nil nil article)
1057 (set-buffer gnus-original-article-buffer)
1058 (message-resend address))
1059 (gnus-summary-mark-article-as-forwarded article))))
1061 (defun gnus-summary-post-forward (&optional arg)
1062 "Forward the current article to a newsgroup.
1063 See `gnus-summary-mail-forward' for ARG."
1065 (gnus-summary-mail-forward arg t))
1067 (defvar gnus-nastygram-message
1068 "The following article was inappropriately posted to %s.\n\n"
1069 "Format string to insert in nastygrams.
1070 The current group name will be inserted at \"%s\".")
1072 (defun gnus-summary-mail-nastygram (n)
1073 "Send a nastygram to the author of the current article."
1075 (when (or gnus-expert-user
1077 "Really send a nastygram to the author of the current article? "))
1078 (let ((group gnus-newsgroup-name))
1079 (gnus-summary-reply-with-original n)
1080 (set-buffer gnus-message-buffer)
1082 (insert (format gnus-nastygram-message group))
1083 (message-send-and-exit))))
1085 (defun gnus-summary-mail-crosspost-complaint (n)
1086 "Send a complaint about crossposting to the current article(s)."
1088 (let ((articles (gnus-summary-work-articles n))
1090 (while (setq article (pop articles))
1091 (set-buffer gnus-summary-buffer)
1092 (gnus-summary-goto-subject article)
1093 (let ((group (gnus-group-real-name gnus-newsgroup-name))
1094 newsgroups followup-to)
1095 (gnus-summary-select-article)
1096 (set-buffer gnus-original-article-buffer)
1097 (if (and (<= (length (message-tokenize-header
1099 (mail-fetch-field "newsgroups"))
1102 (or (not (setq followup-to (mail-fetch-field "followup-to")))
1103 (not (member group (message-tokenize-header
1104 followup-to ", ")))))
1106 (gnus-message 1 "Followup-to restricted")
1107 (gnus-message 1 "Not a crossposted article"))
1108 (set-buffer gnus-summary-buffer)
1109 (gnus-summary-reply-with-original 1)
1110 (set-buffer gnus-message-buffer)
1112 (insert (format gnus-crosspost-complaint newsgroups group))
1113 (message-goto-subject)
1114 (re-search-forward " *$")
1115 (replace-match " (crosspost notification)" t t)
1116 (gnus-deactivate-mark)
1117 (when (gnus-y-or-n-p "Send this complaint? ")
1118 (message-send-and-exit)))))))
1120 (defun gnus-mail-parse-comma-list ()
1123 (skip-chars-forward " ")
1126 (skip-chars-forward "^,")
1131 (narrow-to-region beg (point))
1134 (while (search-forward "\"" nil t)
1138 (skip-chars-forward ",")
1139 (skip-chars-forward "^,"))
1140 (skip-chars-backward " ")
1141 (push (buffer-substring beg (point))
1143 (skip-chars-forward "^,")
1144 (skip-chars-forward ", "))
1147 (defun gnus-inews-add-to-address (group)
1148 (let ((to-address (mail-fetch-field "to")))
1149 (when (and to-address
1151 ;; This mail group doesn't have a `to-list', so we add one
1153 (when (gnus-y-or-n-p
1154 (format "Do you want to add this as `to-list': %s " to-address))
1155 (gnus-group-add-parameter group (cons 'to-list to-address))))))
1157 (defun gnus-put-message ()
1158 "Put the current message in some group and return to Gnus."
1160 (let ((reply gnus-article-reply)
1161 (winconf gnus-prev-winconf)
1162 (group gnus-newsgroup-name))
1164 (not (gnus-group-read-only-p group)))
1165 (setq group (read-string "Put in group: " nil (gnus-writable-groups))))
1167 (when (gnus-gethash group gnus-newsrc-hashtb)
1168 (error "No such group: %s" group))
1172 (message-narrow-to-headers)
1173 (let ((gnus-deletable-headers nil))
1174 (message-generate-headers
1175 (if (message-news-p)
1176 message-required-news-headers
1177 message-required-mail-headers)))
1178 (goto-char (point-max))
1179 (insert "Gcc: " group "\n")
1182 (when (and (get-buffer gnus-group-buffer)
1183 (gnus-buffer-exists-p (car-safe reply))
1185 (set-buffer (car reply))
1186 (gnus-summary-mark-article-as-replied (cdr reply)))
1188 (set-window-configuration winconf))))
1190 (defun gnus-article-mail (yank)
1191 "Send a reply to the address near point.
1192 If YANK is non-nil, include the original article."
1196 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
1197 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
1199 (message-reply address)
1201 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
1203 (defvar nntp-server-type)
1205 "Send a bug report to the Gnus maintainers."
1207 (unless (gnus-alive-p)
1208 (error "Gnus has been shut down"))
1209 (gnus-setup-message (if (message-mail-user-agent) 'message 'bug)
1210 (unless (message-mail-user-agent)
1211 (delete-other-windows)
1212 (when gnus-bug-create-help-buffer
1213 (switch-to-buffer "*Gnus Help Bug*")
1215 (insert gnus-bug-message)
1216 (goto-char (point-min)))
1217 (message-pop-to-buffer "*Gnus Bug*"))
1218 (let ((message-this-is-mail t))
1219 (message-setup `((To . ,gnus-maintainer) (Subject . ""))))
1220 (when gnus-bug-create-help-buffer
1221 (push `(gnus-bug-kill-buffer) message-send-actions))
1222 (goto-char (point-min))
1223 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
1225 (insert (gnus-version) "\n"
1226 (emacs-version) "\n")
1227 (when (and (boundp 'nntp-server-type)
1228 (stringp nntp-server-type))
1229 (insert nntp-server-type))
1230 (insert "\n\n\n\n\n")
1233 (set-buffer (gnus-get-buffer-create " *gnus environment info*"))
1236 (setq text (buffer-string)))
1237 (insert "<#part type=application/x-emacs-lisp disposition=inline description=\"User settings\">\n" text "\n<#/part>"))
1238 (goto-char (point-min))
1239 (search-forward "Subject: " nil t)
1242 (defun gnus-bug-kill-buffer ()
1243 (when (get-buffer "*Gnus Help Bug*")
1244 (kill-buffer "*Gnus Help Bug*")))
1246 (defun gnus-summary-yank-message (buffer n)
1247 "Yank the current article into a composed message."
1249 (list (completing-read "Buffer: " (mapcar 'list (message-buffers)) nil t)
1250 current-prefix-arg))
1251 (gnus-summary-iterate n
1252 (let ((gnus-display-mime-function nil)
1253 (gnus-inhibit-treatment t))
1254 (gnus-summary-select-article))
1257 (message-yank-buffer gnus-article-buffer))))
1259 (defun gnus-debug ()
1260 "Attempts to go through the Gnus source file and report what variables have been changed.
1261 The source file has to be in the Emacs load path."
1263 (let ((files '("gnus.el" "gnus-sum.el" "gnus-group.el"
1264 "gnus-art.el" "gnus-start.el" "gnus-async.el"
1265 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
1266 "nnmail.el" "message.el"))
1268 file expr olist sym)
1269 (gnus-message 4 "Please wait while we snoop your variables...")
1271 ;; Go through all the files looking for non-default values for variables.
1273 (set-buffer (gnus-get-buffer-create " *gnus bug info*"))
1276 (when (and (setq file (locate-library (pop files)))
1277 (file-exists-p file))
1278 (insert-file-contents file)
1279 (goto-char (point-min))
1280 (if (not (re-search-forward "^;;* *Internal variables" nil t))
1281 (gnus-message 4 "Malformed sources in file %s" file)
1282 (narrow-to-region (point-min) (point))
1283 (goto-char (point-min))
1284 (while (setq expr (ignore-errors (read (current-buffer))))
1286 (and (or (eq (car expr) 'defvar)
1287 (eq (car expr) 'defcustom))
1288 (stringp (nth 3 expr))
1289 (or (not (boundp (nth 1 expr)))
1290 (not (equal (eval (nth 2 expr))
1291 (symbol-value (nth 1 expr)))))
1292 (push (nth 1 expr) olist)))))))
1293 (kill-buffer (current-buffer)))
1294 (when (setq olist (nreverse olist))
1295 (insert "------------------ Environment follows ------------------\n\n"))
1297 (if (boundp (car olist))
1299 (pp `(setq ,(car olist)
1300 ,(if (or (consp (setq sym (symbol-value (car olist))))
1302 (not (or (eq sym nil)
1304 (list 'quote (symbol-value (car olist)))
1305 (symbol-value (car olist))))
1308 (format "(setq %s 'whatever)\n" (car olist))))
1309 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
1310 (setq olist (cdr olist)))
1312 ;; Remove any control chars - they seem to cause trouble for some
1313 ;; mailers. (Byte-compiled output from the stuff above.)
1315 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
1316 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
1319 ;;; Treatment of rejected articles.
1322 (defun gnus-summary-resend-bounced-mail (&optional fetch)
1323 "Re-mail the current message.
1324 This only makes sense if the current message is a bounce message than
1325 contains some mail you have written which has been bounced back to
1327 If FETCH, try to fetch the article that this is a reply to, if indeed
1330 (gnus-summary-select-article t)
1331 (set-buffer gnus-original-article-buffer)
1332 (gnus-setup-message 'compose-bounce
1333 (let* ((references (mail-fetch-field "references"))
1334 (parent (and references (gnus-parent-id references))))
1336 ;; If there are references, we fetch the article we answered to.
1338 (gnus-summary-refer-article parent)
1339 (gnus-summary-show-all-headers)))))
1343 (defun gnus-inews-group-method (group)
1345 ;; If the group doesn't exist, we assume
1346 ;; it's an archive group...
1347 ((and (null (gnus-get-info group))
1348 (eq (car (gnus-server-to-method gnus-message-archive-method))
1349 (car (gnus-server-to-method (gnus-group-method group)))))
1350 gnus-message-archive-method)
1352 ((gnus-info-method (gnus-get-info group))
1353 (gnus-info-method (gnus-get-info group)))
1355 (t (gnus-server-to-method (gnus-group-method group)))))
1357 ;; Do Gcc handling, which copied the message over to some group.
1358 (defun gnus-inews-do-gcc (&optional gcc)
1362 (message-narrow-to-headers)
1363 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
1364 (cur (current-buffer))
1365 groups group method group-art
1366 mml-externalize-attachments)
1368 (message-remove-header "gcc")
1370 (setq groups (message-unquote-tokens
1371 (message-tokenize-header gcc " ,")))
1372 ;; Copy the article over to some group(s).
1373 (while (setq group (pop groups))
1374 (unless (gnus-check-server
1375 (setq method (gnus-inews-group-method group)))
1376 (error "Can't open server %s" (if (stringp method) method
1378 (unless (gnus-request-group group nil method)
1379 (gnus-request-create-group group method))
1380 (setq mml-externalize-attachments
1381 (if (stringp gnus-gcc-externalize-attachments)
1382 (string-match gnus-gcc-externalize-attachments group)
1383 gnus-gcc-externalize-attachments))
1385 (nnheader-set-temp-buffer " *acc*")
1386 (insert-buffer-substring cur)
1387 (message-encode-message-body)
1389 (message-narrow-to-headers)
1390 (let* ((mail-parse-charset message-default-charset)
1391 (newsgroups-field (save-restriction
1392 (message-narrow-to-headers-or-head)
1393 (message-fetch-field "Newsgroups")))
1394 (followup-field (save-restriction
1395 (message-narrow-to-headers-or-head)
1396 (message-fetch-field "Followup-To")))
1397 ;; BUG: We really need to get the charset for
1398 ;; each name in the Newsgroups and Followup-To
1399 ;; lines to allow crossposting between group
1400 ;; namess with incompatible character sets.
1401 ;; -- Per Abrahamsen <abraham@dina.kvl.dk> 2001-10-08.
1402 (group-field-charset
1403 (gnus-group-name-charset
1404 method (or newsgroups-field "")))
1405 (followup-field-charset
1406 (gnus-group-name-charset
1407 method (or followup-field "")))
1408 (rfc2047-header-encoding-alist
1410 (when group-field-charset
1411 (list (cons "Newsgroups" group-field-charset)))
1412 (when followup-field-charset
1413 (list (cons "Followup-To" followup-field-charset)))
1414 rfc2047-header-encoding-alist)))
1415 (mail-encode-encoded-word-buffer)))
1416 (goto-char (point-min))
1417 (when (re-search-forward
1418 (concat "^" (regexp-quote mail-header-separator) "$")
1420 (replace-match "" t t ))
1421 (unless (setq group-art
1422 (gnus-request-accept-article group method t t))
1423 (gnus-message 1 "Couldn't store article in group %s: %s"
1424 group (gnus-status-message method))
1426 (when (and group-art gnus-inews-mark-gcc-as-read)
1427 (gnus-group-mark-article-read group (cdr group-art)))
1428 (kill-buffer (current-buffer)))))))))
1430 (defun gnus-inews-insert-gcc ()
1431 "Insert Gcc headers based on `gnus-outgoing-message-group'."
1434 (message-narrow-to-headers)
1435 (let* ((group gnus-outgoing-message-group)
1437 ((gnus-functionp group)
1439 ((or (stringp group) (list group))
1443 (if (stringp gcc) gcc
1444 (mapconcat 'identity gcc " "))
1447 (defun gnus-inews-insert-archive-gcc (&optional group)
1448 "Insert the Gcc to say where the article is to be archived."
1449 (let* ((var gnus-message-archive-group)
1450 (group (or group gnus-newsgroup-name ""))
1452 (and gnus-newsgroup-name
1453 (not (equal gnus-newsgroup-name ""))
1454 (gnus-group-find-parameter
1455 gnus-newsgroup-name 'gcc-self)))
1459 ((null gnus-message-archive-method)
1463 ;; Just a single group.
1466 ;; We don't want this.
1468 ((and (listp var) (stringp (car var)))
1469 ;; A list of groups.
1471 ((gnus-functionp var)
1473 (funcall var group))
1475 ;; An alist of regexps/functions/forms.
1480 ((stringp (caar var))
1482 (when (string-match (caar var) group)
1484 ((gnus-functionp (car var))
1486 (funcall (car var) group))
1488 (eval (car var)))))))
1489 (setq var (cdr var)))
1492 (when (or groups gcc-self-val)
1493 (when (stringp groups)
1494 (setq groups (list groups)))
1497 (message-narrow-to-headers)
1498 (goto-char (point-max))
1501 ;; Use the `gcc-self' param value instead.
1504 (if (stringp gcc-self-val)
1507 (if (not (eq gcc-self-val 'none))
1512 ;; Use the list of groups.
1513 (while (setq name (pop groups))
1514 (insert (if (string-match ":" name)
1516 (gnus-group-prefixed-name
1517 name gnus-message-archive-method)))
1524 (defun gnus-configure-posting-styles (&optional group-name)
1525 "Configure posting styles according to `gnus-posting-styles'."
1526 (unless gnus-inhibit-posting-styles
1527 (let ((group (or group-name gnus-newsgroup-name ""))
1528 (styles gnus-posting-styles)
1529 style match variable attribute value v results
1530 filep name address element)
1531 ;; If the group has a posting-style parameter, add it at the end with a
1532 ;; regexp matching everything, to be sure it takes precedence over all
1534 (when gnus-newsgroup-name
1535 (let ((tmp-style (gnus-group-find-parameter group 'posting-style t)))
1537 (setq styles (append styles (list (cons ".*" tmp-style)))))))
1538 ;; Go through all styles and look for matches.
1539 (dolist (style styles)
1540 (setq match (pop style))
1541 (goto-char (point-min))
1544 ;; Regexp string match on the group name.
1545 (string-match match group))
1547 (and (gnus-buffer-live-p gnus-article-copy)
1548 (with-current-buffer gnus-article-copy
1549 (let ((header (message-fetch-field (pop style))))
1551 (string-match (pop style) header))))))
1552 ((or (symbolp match)
1553 (gnus-functionp match))
1555 ((gnus-functionp match)
1556 ;; Function to be called.
1559 ;; Variable to be checked.
1560 (symbol-value match))))
1562 ;; This is a form to be evaled.
1564 ;; We have a match, so we set the variables.
1565 (dolist (attribute style)
1566 (setq element (pop attribute)
1571 ((eq (car attribute) :file)
1574 ((eq (car attribute) :value)
1578 ;; We get the value.
1583 ((or (symbolp value)
1584 (gnus-functionp value))
1585 (cond ((gnus-functionp value)
1588 (symbol-value value))))
1591 ;; Translate obsolescent value.
1592 (when (eq element 'signature-file)
1593 (setq element 'signature
1595 ;; Get the contents of file elems.
1597 (setq v (with-temp-buffer
1598 (insert-file-contents v)
1600 (setq results (delq (assoc element results) results))
1601 (push (cons element v) results))))
1602 ;; Now we have all the styles, so we insert them.
1603 (setq name (assq 'name results)
1604 address (assq 'address results))
1605 (setq results (delq name (delq address results)))
1606 ;; make-local-hook is not obsolete in Emacs 20 or XEmacs.
1607 (make-local-hook 'message-setup-hook)
1608 (dolist (result results)
1609 (add-hook 'message-setup-hook
1611 ((eq 'eval (car result))
1613 ((eq 'body (car result))
1617 (insert ,(cdr result)))))
1618 ((eq 'signature (car result))
1619 (set (make-local-variable 'message-signature) nil)
1620 (set (make-local-variable 'message-signature-file) nil)
1621 (if (not (cdr result))
1625 (let ((message-signature ,(cdr result)))
1626 (when message-signature
1627 (message-insert-signature)))))))
1630 (if (symbolp (car result))
1631 (capitalize (symbol-name (car result)))
1635 (message-remove-header ,header)
1636 (let ((value ,(cdr result)))
1639 (insert ,header ": " value "\n"))))))))
1641 (when (or name address)
1642 (add-hook 'message-setup-hook
1644 (set (make-local-variable 'user-mail-address)
1645 ,(or (cdr address) user-mail-address))
1646 (let ((user-full-name ,(or (cdr name) (user-full-name)))
1648 ,(or (cdr address) user-mail-address)))
1650 (message-remove-header "From")
1652 (insert "From: " (message-make-from) "\n"))))
1655 ;;; Allow redefinition of functions.
1661 ;;; gnus-msg.el ends here