1 ;;; gnus-msg.el --- mail and post interface for Semi-gnus
2 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001
3 ;; Free Software Foundation, Inc.
5 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
6 ;; Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
8 ;; Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp>
9 ;; Katsumi Yamaoka <yamaoka@jpl.org>
10 ;; Kiyokazu SUTO <suto@merry.xmath.ous.ac.jp>
11 ;; Keywords: mail, news, MIME
13 ;; This file is part of GNU Emacs.
15 ;; GNU Emacs is free software; you can redistribute it and/or modify
16 ;; it under the terms of the GNU General Public License as published by
17 ;; the Free Software Foundation; either version 2, or (at your option)
20 ;; GNU Emacs is distributed in the hope that it will be useful,
21 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 ;; GNU General Public License for more details.
25 ;; You should have received a copy of the GNU General Public License
26 ;; along with GNU Emacs; see the file COPYING. If not, write to the
27 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
28 ;; Boston, MA 02111-1307, USA.
34 (eval-when-compile (require 'cl))
35 (eval-when-compile (require 'static))
42 (defcustom gnus-post-method 'current
43 "*Preferred method for posting USENET news.
45 If this variable is `current' (which is the default), Gnus will use
46 the \"current\" select method when posting. If it is `native', Gnus
47 will use the native select method when posting.
49 This method will not be used in mail groups and the like, only in
52 If not `native' nor `current', the value must be a valid method as discussed
53 in the documentation of `gnus-select-method'. It can also be a list of
54 methods. If that is the case, the user will be queried for what select
55 method to use when posting."
56 :group 'gnus-group-foreign
57 :link '(custom-manual "(gnus)Posting Server")
58 :type `(choice (const native)
60 (sexp :tag "Methods" ,gnus-select-method)))
62 (defcustom gnus-outgoing-message-group nil
63 "*All outgoing messages will be put in this group.
64 If you want to store all your outgoing mail and articles in the group
65 \"nnml:archive\", you set this variable to that value. This variable
66 can also be a list of group names.
68 If you want to have greater control over what group to put each
69 message in, you can set this variable to a function that checks the
70 current newsgroup name and then returns a suitable group name (or list
73 :type '(choice (string :tag "Group")
76 (defcustom gnus-mailing-list-groups nil
77 "*Regexp matching groups that are really mailing lists.
78 This is useful when you're reading a mailing list that has been
79 gatewayed to a newsgroup, and you want to followup to an article in
84 (defcustom gnus-add-to-list nil
85 "*If non-nil, add a `to-list' parameter automatically."
89 (defcustom gnus-crosspost-complaint
92 You posted the article below with the following Newsgroups header:
96 The %s group, at least, was an inappropriate recipient
97 of this message. Please trim your Newsgroups header to exclude this
98 group before posting in the future.
103 "Format string to be inserted when complaining about crossposts.
104 The first %s will be replaced by the Newsgroups header;
105 the second with the current group name."
109 (defcustom gnus-message-setup-hook '(gnus-maybe-setup-default-charset)
110 "Hook run after setting up a message buffer."
114 (defcustom gnus-bug-create-help-buffer t
115 "*Should we create the *Gnus Help Bug* buffer?"
119 (defcustom gnus-posting-styles nil
120 "*Alist of styles to use when posting.
121 See Info node `(gnus)Posting Styles'."
123 :type '(repeat (cons (choice (regexp)
128 (choice (const signature)
129 (const signature-file)
134 (string :tag "Header"))
140 (defcustom gnus-inews-mark-gcc-as-read nil
141 "If non-nil, automatically mark Gcc articles as read."
145 (defcustom gnus-group-posting-charset-alist
146 '(("^\\(no\\|fr\\)\\.[^,]*\\(,[ \t\n]*\\(no\\|fr\\)\\.[^,]*\\)*$" iso-8859-1 (iso-8859-1))
147 ("^\\(fido7\\|relcom\\)\\.[^,]*\\(,[ \t\n]*\\(fido7\\|relcom\\)\\.[^,]*\\)*$" koi8-r (koi8-r))
148 (message-this-is-mail nil nil)
149 (message-this-is-news nil t))
150 "Alist of regexps and permitted unencoded charsets for posting.
151 Each element of the alist has the form (TEST HEADER BODY-LIST), where
152 TEST is either a regular expression matching the newsgroup header or a
154 HEADER is the charset which may be left unencoded in the header (nil
155 means encode all charsets),
156 BODY-LIST is a list of charsets which may be encoded using 8bit
157 content-transfer encoding in the body, or one of the special values
158 nil (always encode using quoted-printable) or t (always use 8bit).
160 Note that any value other than nil for HEADER infringes some RFCs, so
161 use this option with care."
162 :type '(repeat (list :tag "Permitted unencoded charsets"
164 (regexp :tag "Group")
165 (const :tag "Mail message"
166 :value message-this-is-mail)
167 (const :tag "News article"
168 :value message-this-is-news))
169 (choice :tag "Header"
170 (const :tag "None" nil)
171 (symbol :tag "Charset"))
173 (const :tag "Any" :value t)
174 (const :tag "None" :value nil)
175 (repeat :tag "Charsets"
176 (symbol :tag "Charset")))))
177 :group 'gnus-charset)
179 ;;; Internal variables.
181 (defvar gnus-inhibit-posting-styles nil
182 "Inhibit the use of posting styles.")
184 (defvar gnus-message-buffer "*Mail Gnus*")
185 (defvar gnus-article-copy nil)
186 (defvar gnus-check-before-posting nil)
187 (defvar gnus-last-posting-server nil)
188 (defvar gnus-message-group-art nil)
190 (defvar gnus-msg-force-broken-reply-to nil)
192 (defconst gnus-bug-message
193 (format "Sending a bug report to the Gnus Towers.
194 ========================================
196 This gnus is the %s%s.
197 If you think the bug is a Semi-gnus bug, send a bug report to Semi-gnus
198 Developers. (the addresses below are mailing list addresses)
200 ========================================
202 The buffer below is a mail buffer. When you press `C-c C-c', it will
203 be sent to the Gnus Bug Exterminators.
205 The thing near the bottom of the buffer is how the environment
206 settings will be included in the mail. Please do not delete that.
207 They will tell the Bug People what your environment is, so that it
208 will be easier to locate the bugs.
210 If you have found a bug that makes Emacs go \"beep\", set
211 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
212 and include the backtrace in your bug report.
214 Please describe the bug in annoying, painstaking detail.
216 Thank you for your help in stamping out bugs.
219 (if (string= gnus-product-name "Semi-gnus")
221 ", a modified version of Semi-gnus")))
224 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
225 (autoload 'news-setup "rnewspost")
226 (autoload 'news-reply-mode "rnewspost")
227 (autoload 'rmail-dont-reply-to "mail-utils")
228 (autoload 'rmail-output "rmailout"))
232 ;;; Gnus Posting Functions
235 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
236 "p" gnus-summary-post-news
237 "f" gnus-summary-followup
238 "F" gnus-summary-followup-with-original
239 "c" gnus-summary-cancel-article
240 "s" gnus-summary-supersede-article
241 "r" gnus-summary-reply
242 "y" gnus-summary-yank-message
243 "R" gnus-summary-reply-with-original
244 "w" gnus-summary-wide-reply
245 "W" gnus-summary-wide-reply-with-original
246 "v" gnus-summary-very-wide-reply
247 "V" gnus-summary-very-wide-reply-with-original
248 "n" gnus-summary-followup-to-mail
249 "N" gnus-summary-followup-to-mail-with-original
250 "m" gnus-summary-mail-other-window
251 "u" gnus-uu-post-news
252 "\M-c" gnus-summary-mail-crosspost-complaint
253 "Br" gnus-summary-reply-broken-reply-to
254 "BR" gnus-summary-reply-broken-reply-to-with-original
255 "om" gnus-summary-mail-forward
256 "op" gnus-summary-post-forward
257 "Om" gnus-summary-digest-mail-forward
258 "Op" gnus-summary-digest-post-forward)
260 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
261 "b" gnus-summary-resend-bounced-mail
262 ;; "c" gnus-summary-send-draft
263 "r" gnus-summary-resend-message)
265 ;;; Internal functions.
267 (defvar gnus-article-reply nil)
268 (defmacro gnus-setup-message (config &rest forms)
269 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
270 (buffer (make-symbol "gnus-setup-message-buffer"))
271 (article (make-symbol "gnus-setup-message-article"))
272 (group (make-symbol "gnus-setup-message-group")))
273 `(let ((,winconf (current-window-configuration))
274 (,buffer (buffer-name (current-buffer)))
275 (,article gnus-article-reply)
276 (,group gnus-newsgroup-name)
277 (message-header-setup-hook
278 (copy-sequence message-header-setup-hook))
279 (message-mode-hook (copy-sequence message-mode-hook))
280 (message-startup-parameter-alist
281 '((reply-buffer . gnus-copy-article-buffer)
282 (original-buffer . gnus-original-article-buffer)
283 (user-agent . Gnus))))
284 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
285 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
286 (add-hook 'message-mode-hook 'gnus-configure-posting-styles)
290 (gnus-inews-add-send-actions ,winconf ,buffer ,article ,config)
291 (gnus-inews-insert-draft-meta-information ,group ,article)
292 (setq gnus-message-buffer (current-buffer))
293 (set (make-local-variable 'gnus-message-group-art)
294 (cons ,group ,article))
295 (set (make-local-variable 'gnus-newsgroup-name) ,group)
296 (gnus-run-hooks 'gnus-message-setup-hook))
298 (gnus-configure-windows ,config t)
299 (run-hooks 'post-command-hook)
300 (set-buffer-modified-p nil))))
302 (defun gnus-inews-insert-draft-meta-information (group article)
305 (not (string= group ""))
306 (not (message-fetch-field gnus-draft-meta-information-header)))
307 (goto-char (point-min))
308 (insert gnus-draft-meta-information-header ": (\"" group "\" "
309 (if article (number-to-string
316 (defun gnus-msg-mail (&optional to subject other-headers continue
317 switch-action yank-action send-actions)
318 "Start editing a mail message to be sent.
319 Like `message-mail', but with Gnus paraphernalia, particularly the
320 Gcc: header for archiving purposes."
322 (let ((buf (current-buffer))
324 (gnus-setup-message 'message
325 (message-mail to subject other-headers continue
326 nil yank-action send-actions))
328 (setq mail-buf (current-buffer))
329 (switch-to-buffer buf)
330 (apply switch-action mail-buf nil)))
331 ;; COMPOSEFUNC should return t if succeed. Undocumented ???
334 (defvar save-selected-window-window)
337 (defun gnus-button-mailto (address)
339 (set-buffer (gnus-copy-article-buffer))
340 (gnus-setup-message 'message
341 (message-reply address))
342 (and (boundp 'save-selected-window-window)
343 (not (window-live-p save-selected-window-window))
344 (setq save-selected-window-window (selected-window))))
347 (defun gnus-button-reply (&optional to-address wide)
348 "Like `message-reply'."
350 (gnus-setup-message 'message
351 (message-reply to-address wide))
352 (and (boundp 'save-selected-window-window)
353 (not (window-live-p save-selected-window-window))
354 (setq save-selected-window-window (selected-window))))
357 (define-mail-user-agent 'gnus-user-agent
358 'gnus-msg-mail 'message-send-and-exit
359 'message-kill-buffer 'message-send-hook)
361 (defun gnus-setup-posting-charset (group)
362 (let ((alist gnus-group-posting-charset-alist)
363 (group (or group ""))
367 (while (setq elem (pop alist))
368 (when (or (and (stringp (car elem))
369 (string-match (car elem) group))
370 (and (gnus-functionp (car elem))
371 (funcall (car elem) group))
372 (and (symbolp (car elem))
373 (symbol-value (car elem))))
374 (throw 'found (cons (cadr elem) (caddr elem)))))))))
376 (defun gnus-inews-add-send-actions (winconf buffer article &optional config)
377 (make-local-hook 'message-sent-hook)
378 (add-hook 'message-sent-hook (if gnus-agent 'gnus-agent-possibly-do-gcc
379 'gnus-inews-do-gcc) nil t)
381 (make-local-hook 'message-header-hook)
382 (add-hook 'message-header-hook 'gnus-agent-possibly-save-gcc nil t))
383 (setq message-post-method
385 (gnus-post-method arg ,gnus-newsgroup-name)))
386 (setq message-user-agent (gnus-extended-version))
387 (when (not message-use-multi-frames)
389 `(set-window-configuration ,winconf) 'exit 'postpone 'kill))
391 `(when (gnus-buffer-exists-p ,buffer)
395 (if (eq config 'forward)
396 `(gnus-summary-mark-article-as-forwarded ',article)
397 `(gnus-summary-mark-article-as-replied ',article)))))
400 (put 'gnus-setup-message 'lisp-indent-function 1)
401 (put 'gnus-setup-message 'edebug-form-spec '(form body))
403 ;;; Post news commands of Gnus group mode and summary mode
405 (defun gnus-group-mail (&optional arg)
406 "Start composing a mail.
407 If ARG, use the group under the point to find a posting style.
408 If ARG is 1, prompt for a group name to find the posting style."
410 ;; We can't `let' gnus-newsgroup-name here, since that leads
411 ;; to local variables leaking.
412 (let ((group gnus-newsgroup-name)
413 (buffer (current-buffer)))
416 (setq gnus-newsgroup-name
418 (if (= 1 (prefix-numeric-value arg))
419 (completing-read "Use posting style of group: "
420 gnus-active-hashtb nil
421 (gnus-read-active-file-p))
422 (gnus-group-group-name))
424 (gnus-setup-message 'message (message-mail)))
427 (setq gnus-newsgroup-name group)))))
429 (defun gnus-group-post-news (&optional arg)
430 "Start composing a news message.
431 If ARG, post to the group under point.
432 If ARG is 1, prompt for a group name."
434 ;; Bind this variable here to make message mode hooks work ok.
435 (let ((gnus-newsgroup-name
437 (if (= 1 (prefix-numeric-value arg))
438 (completing-read "Newsgroup: " gnus-active-hashtb nil
439 (gnus-read-active-file-p))
440 (gnus-group-group-name))
442 (gnus-post-news 'post gnus-newsgroup-name)))
444 (defun gnus-summary-post-news ()
445 "Start composing a news message."
447 (gnus-post-news 'post gnus-newsgroup-name))
449 (defun gnus-summary-followup (yank &optional force-news)
450 "Compose a followup to an article.
451 If prefix argument YANK is non-nil, original article is yanked automatically."
453 (list (and current-prefix-arg
454 (gnus-summary-work-articles 1))))
456 (gnus-summary-goto-subject (car yank)))
457 (save-window-excursion
458 (gnus-summary-select-article))
459 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
460 (gnus-newsgroup-name gnus-newsgroup-name))
462 (gnus-post-news nil gnus-newsgroup-name
463 headers gnus-article-buffer
464 yank nil force-news)))
466 (defun gnus-summary-followup-with-original (n &optional force-news)
467 "Compose a followup to an article and include the original article."
469 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
471 (defun gnus-summary-followup-to-mail (&optional arg)
472 "Followup to the current mail message via news."
474 (list (and current-prefix-arg
475 (gnus-summary-work-articles 1))))
476 (gnus-summary-followup arg t))
478 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
479 "Followup to the current mail message via news."
481 (gnus-summary-followup (gnus-summary-work-articles arg) t))
483 (defun gnus-inews-yank-articles (articles)
484 (let ((more-than-one (cdr articles))
485 (cur (current-buffer))
486 refs beg article window)
488 (while (setq article (pop articles))
489 (save-window-excursion
490 (set-buffer gnus-summary-buffer)
491 (gnus-summary-select-article nil nil nil article)
492 (gnus-summary-remove-process-mark article))
494 ;; Gathering references.
496 (setq refs (message-list-references
498 (mail-header-references gnus-current-headers)
499 (mail-header-message-id gnus-current-headers)))
500 (when message-use-multi-frames
501 (when (setq window (get-buffer-window cur t))
502 (select-frame (window-frame window)))))
504 (gnus-copy-article-buffer)
505 (let ((message-reply-buffer gnus-article-copy)
506 (message-reply-headers
507 (with-current-buffer gnus-article-copy
508 ;; The headers are decoded.
509 (nnheader-parse-head t))))
510 (message-yank-original)
511 (setq beg (or beg (mark t))))
516 ;; Replace with the gathered references.
520 (message-narrow-to-headers)
521 (let ((case-fold-search t))
522 (if (re-search-forward "^References:\\([\t ]+.+\n\\)+" nil t)
524 (goto-char (point-max))))
526 (list (or (assq 'References message-header-format-alist)
527 '(References . message-shorten-references)))
528 (list (cons 'References
529 (mapconcat 'identity (nreverse refs) " "))))
530 (backward-delete-char 1))
536 (defun gnus-summary-cancel-article (&optional n symp)
537 "Cancel an article you posted.
538 Uses the process-prefix convention. If given the symbolic
539 prefix `a', cancel using the standard posting method; if not
540 post using the current select method."
541 (interactive (gnus-interactive "P\ny"))
542 (let ((articles (gnus-summary-work-articles n))
545 (gnus-post-method (not (eq symp 'a)) ,gnus-newsgroup-name)))
547 (while (setq article (pop articles))
548 (when (gnus-summary-select-article t nil nil article)
549 (when (gnus-eval-in-buffer-window gnus-article-buffer
551 (set-buffer gnus-original-article-buffer)
552 (message-cancel-news)))
553 (gnus-summary-mark-as-read article gnus-canceled-mark)
554 (gnus-cache-remove-article 1))
555 (gnus-article-hide-headers-if-wanted))
556 (gnus-summary-remove-process-mark article))))
558 (defun gnus-summary-supersede-article ()
559 "Compose an article that will supersede a previous article.
560 This is done simply by taking the old article and adding a Supersedes
561 header line with the old Message-ID."
563 (let ((article (gnus-summary-article-number))
564 (gnus-message-setup-hook '(gnus-maybe-setup-default-charset)))
565 (gnus-setup-message 'reply-yank
566 (gnus-summary-select-article t)
567 (set-buffer gnus-original-article-buffer)
571 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
573 (set-buffer ,gnus-summary-buffer)
574 (gnus-cache-possibly-remove-article ,article nil nil nil t)
575 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
576 message-send-actions))))
580 (defun gnus-copy-article-buffer (&optional article-buffer)
581 ;; make a copy of the article buffer with all text properties removed
582 ;; this copy is in the buffer gnus-article-copy.
583 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
584 ;; this buffer should be passed to all mail/news reply/post routines.
585 (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
586 (let ((article-buffer (or article-buffer gnus-article-buffer))
588 (if (not (and (get-buffer article-buffer)
589 (gnus-buffer-exists-p article-buffer)))
590 (error "Can't find any article buffer")
592 (set-buffer article-buffer)
593 (let ((gnus-newsgroup-charset (or gnus-article-charset
594 gnus-newsgroup-charset))
595 (gnus-newsgroup-ignored-charsets
596 (or gnus-article-ignored-charsets
597 gnus-newsgroup-ignored-charsets)))
599 ;; Copy over the (displayed) article buffer, delete
600 ;; hidden text and remove text properties.
602 (let ((inhibit-read-only t))
603 (copy-to-buffer gnus-article-copy (point-min) (point-max))
604 (set-buffer gnus-article-copy)
605 ;; Encode bitmap smileys to ordinary text.
606 ;; Possibly, the original text might be restored.
607 (static-unless (featurep 'xemacs)
608 (when (featurep 'smiley-mule)
609 (smiley-encode-buffer)))
610 (gnus-article-delete-text-of-type 'annotation)
611 (gnus-remove-text-with-property 'gnus-prev)
612 (gnus-remove-text-with-property 'gnus-next)
613 (gnus-remove-text-with-property 'x-face-mule-bitmap-image)
616 (static-if (featurep 'xemacs)
617 ;; Revome smiley extents for (possibly) XEmacs 21.1.
619 (buffer-substring-no-properties (point-min)
621 (buffer-substring-no-properties (point-min) (point-max)))
623 ;; Find the original headers.
624 (set-buffer gnus-original-article-buffer)
625 (goto-char (point-min))
626 (while (looking-at message-unix-mail-delimiter)
629 (setq end (or (message-goto-body) beg))
630 ;; Delete the headers from the displayed articles.
631 (set-buffer gnus-article-copy)
632 (delete-region (goto-char (point-min))
633 (or (message-goto-body) (point-max)))
634 ;; Insert the original article headers.
635 (insert-buffer-substring gnus-original-article-buffer beg end)
637 (let ((gnus-article-decode-hook
638 (delq 'article-decode-charset
639 (copy-sequence gnus-article-decode-hook))))
640 ;; Needed for T-gnus.
641 (add-hook 'gnus-article-decode-hook
642 'article-decode-encoded-words)
643 (run-hooks 'gnus-article-decode-hook)))))
646 (defun gnus-post-news (post &optional group header article-buffer yank subject
649 (gnus-copy-article-buffer))
650 (let ((gnus-article-reply (and article-buffer (gnus-summary-article-number)))
651 (add-to-list gnus-add-to-list))
652 (gnus-setup-message (cond (yank 'reply-yank)
653 (article-buffer 'reply)
655 (let* ((group (or group gnus-newsgroup-name))
656 (charset (gnus-group-name-charset nil group))
658 to-address to-group mailing-list to-list
661 (setq to-address (gnus-parameter-to-address group)
662 to-group (gnus-group-find-parameter group 'to-group)
663 to-list (gnus-parameter-to-list group)
664 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
665 mailing-list (when gnus-mailing-list-groups
666 (string-match gnus-mailing-list-groups group))
667 group (gnus-group-name-decode (gnus-group-real-name group)
669 (if (or (and to-group
670 (gnus-news-group-p to-group))
673 (and (gnus-news-group-p
674 (or pgroup gnus-newsgroup-name)
675 (or header gnus-current-article))
681 (message-news (or to-group group))
682 (set-buffer gnus-article-copy)
683 (gnus-msg-treat-broken-reply-to)
684 (message-followup (if (or newsgroup-p force-news)
685 (if (save-restriction
686 (article-narrow-to-head)
687 (message-fetch-field "newsgroups"))
694 (message-mail (or to-address to-list))
695 ;; Arrange for mail groups that have no `to-address' to
696 ;; get that when the user sends off the mail.
697 (when (and (not to-list)
700 (push (list 'gnus-inews-add-to-address pgroup)
701 message-send-actions)))
702 (set-buffer gnus-article-copy)
703 (gnus-msg-treat-broken-reply-to)
704 (message-wide-reply to-address)))
706 (gnus-inews-yank-articles yank))))))
708 (defun gnus-msg-treat-broken-reply-to (&optional force)
709 "Remove the Reply-to header iff broken-reply-to."
711 (gnus-group-find-parameter
712 gnus-newsgroup-name 'broken-reply-to))
714 (message-narrow-to-head)
715 (message-remove-header "reply-to"))))
717 (defun gnus-post-method (arg group &optional silent)
718 "Return the posting method based on GROUP and ARG.
719 If SILENT, don't prompt the user."
720 (let ((gnus-post-method (or (gnus-parameter-post-method group)
722 (group-method (gnus-find-method-for-group group)))
724 ;; If the group-method is nil (which shouldn't happen) we use
725 ;; the default method.
727 (or (and (listp gnus-post-method) ;If not current/native/nil
728 (not (listp (car gnus-post-method))) ; and not a list of methods
729 gnus-post-method) ;then use it.
731 message-post-method))
732 ;; We want the inverse of the default
733 ((and arg (not (eq arg 0)))
734 (if (eq gnus-post-method 'current)
737 ;; We query the user for a post method.
739 (and (listp gnus-post-method)
740 (listp (car gnus-post-method))))
742 ;; Collect all methods we know about.
744 (when (listp gnus-post-method)
745 (if (listp (car gnus-post-method))
747 (list gnus-post-method)))
748 gnus-secondary-select-methods
749 (mapcar 'cdr gnus-server-alist)
750 (mapcar 'car gnus-opened-servers)
751 (list gnus-select-method)
752 (list group-method)))
753 method-alist post-methods method)
754 ;; Weed out all mail methods.
756 (setq method (gnus-server-get-method "" (pop methods)))
757 (when (and (or (gnus-method-option-p method 'post)
758 (gnus-method-option-p method 'post-mail))
759 (not (member method post-methods)))
760 (push method post-methods)))
761 ;; Create a name-method alist.
765 (if (equal (cadr m) "")
766 (list (symbol-name (car m)) m)
767 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m)))
772 (setq gnus-last-posting-server
774 gnus-last-posting-server)
775 ;; Just use the last value.
776 gnus-last-posting-server
778 "Posting method: " method-alist nil t
779 (cons (or gnus-last-posting-server "") 0))))
781 ;; Override normal method.
782 ((and (eq gnus-post-method 'current)
783 (not (eq (car group-method) 'nndraft))
784 (gnus-get-function group-method 'request-post t))
787 ;; Use gnus-post-method.
788 ((listp gnus-post-method) ;A method...
789 (assert (not (listp (car gnus-post-method)))) ;... not a list of methods.
791 ;; Use the normal select method (nil or native).
792 (t gnus-select-method))))
795 (defun gnus-message-make-user-agent (&optional include-mime-info max-column
797 "Return a user-agent info. If INCLUDE-MIME-INFO is non-nil and the
798 variable `mime-edit-user-agent-value' is bound, the value will be
799 included in the return value. If MAX-COLUMN is specified, the return
800 value will be folded up as it were filled. NEWLINE-PRODUCT specifies
801 whether a newline should be inserted in front of each product-token.
802 If the value is t or `hard', it works strictly. Otherwise, if it is
803 non-nil (e.g. `soft'), it works semi-strictly.
805 Here is an example of how to use this function:
807 \(add-hook 'gnus-message-setup-hook
809 (setq message-user-agent nil)
812 (message-narrow-to-headers)
813 (goto-char (point-max))
814 (insert \"User-Agent: \"
815 (gnus-message-make-user-agent t 76 'soft)
818 (let ((user-agent (if (and include-mime-info
819 (boundp 'mime-edit-user-agent-value))
820 (concat (gnus-extended-version)
822 mime-edit-user-agent-value)
823 (gnus-extended-version))))
825 (unless (natnump max-column)
826 (setq max-column 76))
828 (set-buffer-multibyte t)
829 (insert (mapconcat 'identity (split-string user-agent) " "))
830 (goto-char (point-min))
832 start agent agents width element swidth)
833 (while (re-search-forward "\\([^ ]+\\) ?" nil t)
834 (setq start (match-beginning 0))
835 (if (eq (char-after start) ?\()
839 (push (buffer-substring start (point)) agent))
841 (push (nreverse agent) agents))
842 (setq agent (list (match-string 1)))))
844 (push (nreverse agent) agents))
845 (setq agents (nreverse agents))
846 (if (> (+ 12 (string-width (caar agents))) max-column)
847 (setq user-agent "\n"
852 (setq agent (car agents)
855 (or (memq newline-product '(t hard))
858 (string-width (mapconcat 'identity
861 (setq user-agent (concat user-agent "\n")
865 (setq element (car agent)
866 swidth (string-width element)
869 (setq user-agent (if (member user-agent '("" "\n"))
870 (concat user-agent element)
871 (concat user-agent " " element))
872 width (+ width 1 swidth)
874 (if (> (+ width 1 swidth) max-column)
875 (setq user-agent (concat user-agent "\n " element)
877 (setq user-agent (concat user-agent " " element)
878 width (+ width 1 swidth)))))))))
883 ;;; Gnus Mail Functions
886 ;;; Mail reply commands of Gnus summary mode
888 (defun gnus-summary-reply (&optional yank wide very-wide)
889 "Start composing a mail reply to the current message.
890 If prefix argument YANK is non-nil, the original article is yanked
892 If WIDE, make a wide reply.
893 If VERY-WIDE, make a very wide reply."
895 (list (and current-prefix-arg
896 (gnus-summary-work-articles 1))))
897 ;; Stripping headers should be specified with mail-yank-ignored-headers.
899 (gnus-summary-goto-subject (car yank)))
900 (let ((gnus-article-reply (or yank (gnus-summary-article-number)))
902 (gnus-setup-message (if yank 'reply-yank 'reply)
904 (gnus-summary-select-article)
905 (dolist (article very-wide)
906 (gnus-summary-select-article nil nil nil article)
908 (set-buffer (gnus-copy-article-buffer))
909 (gnus-msg-treat-broken-reply-to)
911 (message-narrow-to-head)
912 (setq headers (concat headers (buffer-string)))))))
913 (set-buffer (gnus-copy-article-buffer))
914 (gnus-msg-treat-broken-reply-to gnus-msg-force-broken-reply-to)
916 (message-narrow-to-head)
920 (goto-char (point-max)))
921 (message-reply nil wide)
923 (gnus-inews-yank-articles yank)))))
925 (defun gnus-summary-reply-with-original (n &optional wide)
926 "Start composing a reply mail to the current message.
927 The original article will be yanked."
929 (gnus-summary-reply (gnus-summary-work-articles n) wide))
931 (defun gnus-summary-reply-broken-reply-to (&optional yank wide very-wide)
932 "Like `gnus-summary-reply' except removing reply-to field.
933 If prefix argument YANK is non-nil, the original article is yanked
935 If WIDE, make a wide reply.
936 If VERY-WIDE, make a very wide reply."
938 (list (and current-prefix-arg
939 (gnus-summary-work-articles 1))))
940 (let ((gnus-msg-force-broken-reply-to t))
941 (gnus-summary-reply yank wide very-wide)))
943 (defun gnus-summary-reply-broken-reply-to-with-original (n &optional wide)
944 "Like `gnus-summary-reply-with-original' except removing reply-to field.
945 The original article will be yanked."
947 (gnus-summary-reply-broken-reply-to (gnus-summary-work-articles n) wide))
949 (defun gnus-summary-wide-reply (&optional yank)
950 "Start composing a wide reply mail to the current message.
951 If prefix argument YANK is non-nil, the original article is yanked
954 (list (and current-prefix-arg
955 (gnus-summary-work-articles 1))))
956 (gnus-summary-reply yank t))
958 (defun gnus-summary-wide-reply-with-original (n)
959 "Start composing a wide reply mail to the current message.
960 The original article will be yanked."
962 (gnus-summary-reply-with-original n t))
964 (defun gnus-summary-very-wide-reply (&optional yank)
965 "Start composing a very wide reply mail to the current message.
966 If prefix argument YANK is non-nil, the original article is yanked
969 (list (and current-prefix-arg
970 (gnus-summary-work-articles 1))))
971 (gnus-summary-reply yank t (gnus-summary-work-articles yank)))
973 (defun gnus-summary-very-wide-reply-with-original (n)
974 "Start composing a very wide reply mail to the current message.
975 The original article will be yanked."
978 (gnus-summary-work-articles n) t (gnus-summary-work-articles n)))
980 (defun gnus-summary-mail-forward (&optional full-headers post)
981 "Forward the current message to another user.
982 If FULL-HEADERS (the prefix), include full headers when forwarding."
984 (gnus-setup-message 'forward
985 (gnus-summary-select-article)
986 (let ((charset default-mime-charset))
987 (set-buffer gnus-original-article-buffer)
988 (make-local-variable 'default-mime-charset)
989 (setq default-mime-charset charset))
990 (let ((message-included-forward-headers
991 (if full-headers "" message-included-forward-headers)))
992 (message-forward post))))
994 (defun gnus-summary-digest-mail-forward (&optional n post)
995 "Digests and forwards all articles in this series.
996 If N is a positive number, forward the N next articles.
997 If N is a negative number, forward the N previous articles.
998 If N is nil and any articles have been marked with the process mark,
999 forward those articles instead.
1000 Optional POST will use news to forward instead of mail."
1002 (let ((articles (gnus-summary-work-articles n))
1003 (topics "Topics:\n")
1004 subject article frame)
1005 (when (car articles)
1006 (gnus-setup-message 'forward
1007 (gnus-summary-select-article)
1009 (setq articles (sort articles '<)
1010 subject "Digested Articles")
1011 (with-current-buffer gnus-original-article-buffer
1012 (setq subject (message-make-forward-subject))))
1014 (message-news nil subject)
1015 (message-mail nil subject))
1016 (when (and message-use-multi-frames (cdr articles))
1017 (setq frame (window-frame (get-buffer-window (current-buffer)))))
1019 (while (setq article (pop articles))
1020 (save-window-excursion
1021 (set-buffer gnus-summary-buffer)
1022 (gnus-summary-select-article nil nil nil article)
1023 (setq topics (concat topics " "
1024 (mail-header-subject gnus-current-headers)
1026 (gnus-summary-remove-process-mark article))
1028 (select-frame frame))
1029 (insert (mime-make-tag "message" "rfc822") "\n")
1030 (narrow-to-region (point) (point))
1031 (insert-buffer-substring gnus-original-article-buffer)
1033 (article-narrow-to-head)
1034 (message-remove-header message-included-forward-headers t nil t))
1035 (goto-char (point-max))
1041 (mime-edit-enclose-digest-region (point)(mark t))))))
1043 (defun gnus-summary-digest-post-forward (&optional n)
1044 "Digest and forwards all articles in this series to a newsgroup.
1045 If N is a positive number, forward the N next articles.
1046 If N is a negative number, forward the N previous articles.
1047 If N is nil and any articles have been marked with the process mark,
1048 forward those articles instead."
1050 (gnus-summary-digest-mail-forward n t))
1052 (defun gnus-summary-resend-message (address n)
1053 "Resend the current article to ADDRESS."
1055 (list (message-read-from-minibuffer "Resend message(s) to: ")
1056 current-prefix-arg))
1057 (let ((articles (gnus-summary-work-articles n))
1059 (while (setq article (pop articles))
1060 (gnus-summary-select-article nil nil nil article)
1062 (set-buffer gnus-original-article-buffer)
1063 (message-resend address))
1064 (gnus-summary-mark-article-as-forwarded article))))
1066 (defun gnus-summary-post-forward (&optional full-headers)
1067 "Forward the current article to a newsgroup.
1068 If FULL-HEADERS (the prefix), include full headers when forwarding."
1070 (gnus-summary-mail-forward full-headers t))
1072 (defvar gnus-nastygram-message
1073 "The following article was inappropriately posted to %s.\n\n"
1074 "Format string to insert in nastygrams.
1075 The current group name will be inserted at \"%s\".")
1077 (defun gnus-summary-mail-nastygram (n)
1078 "Send a nastygram to the author of the current article."
1080 (when (or gnus-expert-user
1082 "Really send a nastygram to the author of the current article? "))
1083 (let ((group gnus-newsgroup-name))
1084 (gnus-summary-reply-with-original n)
1085 (set-buffer gnus-message-buffer)
1087 (insert (format gnus-nastygram-message group))
1088 (message-send-and-exit))))
1090 (defun gnus-summary-mail-crosspost-complaint (n)
1091 "Send a complaint about crossposting to the current article(s)."
1093 (let ((articles (gnus-summary-work-articles n))
1095 (while (setq article (pop articles))
1096 (set-buffer gnus-summary-buffer)
1097 (gnus-summary-goto-subject article)
1098 (let ((group (gnus-group-real-name gnus-newsgroup-name))
1099 newsgroups followup-to)
1100 (gnus-summary-select-article)
1101 (set-buffer gnus-original-article-buffer)
1102 (if (and (<= (length (message-tokenize-header
1104 (mail-fetch-field "newsgroups"))
1107 (or (not (setq followup-to (mail-fetch-field "followup-to")))
1108 (not (member group (message-tokenize-header
1109 followup-to ", ")))))
1111 (gnus-message 1 "Followup-to restricted")
1112 (gnus-message 1 "Not a crossposted article"))
1113 (set-buffer gnus-summary-buffer)
1114 (gnus-summary-reply-with-original 1)
1115 (set-buffer gnus-message-buffer)
1117 (insert (format gnus-crosspost-complaint newsgroups group))
1118 (message-goto-subject)
1119 (re-search-forward " *$")
1120 (replace-match " (crosspost notification)" t t)
1121 (gnus-deactivate-mark)
1122 (when (gnus-y-or-n-p "Send this complaint? ")
1123 (message-send-and-exit)))))))
1125 (defun gnus-summary-mail-other-window ()
1126 "Compose mail in other window."
1128 (gnus-setup-message 'message
1131 (defun gnus-mail-parse-comma-list ()
1134 (skip-chars-forward " ")
1137 (skip-chars-forward "^,")
1142 (narrow-to-region beg (point))
1145 (while (search-forward "\"" nil t)
1149 (skip-chars-forward ",")
1150 (skip-chars-forward "^,"))
1151 (skip-chars-backward " ")
1152 (push (buffer-substring beg (point))
1154 (skip-chars-forward "^,")
1155 (skip-chars-forward ", "))
1158 (defun gnus-inews-add-to-address (group)
1159 (let ((to-address (mail-fetch-field "to")))
1160 (when (and to-address
1162 ;; This mail group doesn't have a `to-list', so we add one
1164 (when (gnus-y-or-n-p
1165 (format "Do you want to add this as `to-list': %s " to-address))
1166 (gnus-group-add-parameter group (cons 'to-list to-address))))))
1168 (defun gnus-put-message ()
1169 "Put the current message in some group and return to Gnus."
1171 (let ((reply gnus-article-reply)
1172 (winconf gnus-prev-winconf)
1173 (group gnus-newsgroup-name))
1175 (not (gnus-group-read-only-p group)))
1176 (setq group (read-string "Put in group: " nil (gnus-writable-groups))))
1178 (when (gnus-gethash group gnus-newsrc-hashtb)
1179 (error "No such group: %s" group))
1183 (message-narrow-to-headers)
1184 (let ((gnus-deletable-headers nil))
1185 (message-generate-headers
1186 (if (message-news-p)
1187 message-required-news-headers
1188 message-required-mail-headers)))
1189 (goto-char (point-max))
1190 (insert "Gcc: " group "\n")
1193 (when (and (get-buffer gnus-group-buffer)
1194 (gnus-buffer-exists-p (car-safe reply))
1196 (set-buffer (car reply))
1197 (gnus-summary-mark-article-as-replied (cdr reply)))
1199 (set-window-configuration winconf))))
1201 (defun gnus-article-mail (yank)
1202 "Send a reply to the address near point.
1203 If YANK is non-nil, include the original article."
1207 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
1208 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
1210 (message-reply address)
1212 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
1214 (defvar nntp-server-type)
1216 "Send a bug report to the Gnus maintainers."
1218 (unless (gnus-alive-p)
1219 (error "Gnus has been shut down"))
1220 (gnus-setup-message (if (message-mail-user-agent) 'message 'bug)
1221 (unless (message-mail-user-agent)
1222 (message-pop-to-buffer "*Gnus Bug*")
1223 (delete-other-windows)
1224 (when gnus-bug-create-help-buffer
1225 (switch-to-buffer "*Gnus Help Bug*")
1227 (insert gnus-bug-message)
1228 (goto-char (point-min))
1230 (set-buffer "*Gnus Bug*")))
1231 (let ((message-this-is-mail t))
1232 (message-setup `((To . ,gnus-maintainer) (Subject . ""))))
1233 (when gnus-bug-create-help-buffer
1234 (push `(gnus-bug-kill-buffer) message-send-actions))
1235 (goto-char (point-min))
1236 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
1238 (insert gnus-product-name " " gnus-version-number
1239 " (r" gnus-revision-number ") "
1240 "based on " gnus-original-product-name " v"
1241 gnus-original-version-number "\n"
1242 (emacs-version) "\n")
1243 (when (and (boundp 'nntp-server-type)
1244 (stringp nntp-server-type))
1245 (insert nntp-server-type))
1246 (insert "\n\n\n\n\n")
1247 (let (mime-content-types)
1248 (mime-edit-insert-tag "text" "plain" "; type=emacs-lisp"))
1249 (insert (with-temp-buffer
1252 (let (mime-content-types)
1253 (mime-edit-insert-tag "text" "plain"))
1254 (goto-char (point-min))
1255 (search-forward "Subject: " nil t)
1258 (defun gnus-bug-kill-buffer ()
1259 (when (get-buffer "*Gnus Help Bug*")
1260 (kill-buffer "*Gnus Help Bug*")))
1262 (defun gnus-summary-yank-message (buffer n)
1263 "Yank the current article into a composed message."
1265 (list (completing-read "Buffer: " (mapcar 'list (message-buffers)) nil t)
1266 current-prefix-arg))
1267 (when (gnus-buffer-live-p buffer)
1268 (let ((summary-frame (selected-frame))
1269 (message-frame (when (static-if (featurep 'xemacs)
1270 (device-on-window-system-p)
1272 (let ((window (get-buffer-window buffer t)))
1274 (window-frame window)))))
1275 (separator (concat "^" (regexp-quote mail-header-separator)
1277 (gnus-summary-iterate n
1278 (gnus-summary-select-article)
1279 (gnus-copy-article-buffer)
1280 (when (frame-live-p message-frame)
1281 (raise-frame message-frame)
1282 (select-frame message-frame))
1283 (with-current-buffer buffer
1284 (when (save-excursion
1286 (let (case-fold-search)
1287 (and (not (re-search-backward separator nil t))
1288 (re-search-forward separator nil t))))
1289 (goto-char (match-end 0)))
1290 (message-yank-buffer gnus-article-copy))
1291 (select-frame summary-frame))
1292 (when (frame-live-p message-frame)
1293 (select-frame message-frame)))))
1295 (defun gnus-debug ()
1296 "Attempts to go through the Gnus source file and report what variables have been changed.
1297 The source file has to be in the Emacs load path."
1299 (let ((files '("gnus.el" "gnus-sum.el" "gnus-group.el"
1300 "gnus-art.el" "gnus-start.el" "gnus-async.el"
1301 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
1302 "nnmail.el" "nntp.el" "message.el"))
1304 file expr olist sym)
1305 (gnus-message 4 "Please wait while we snoop your variables...")
1306 ;; Go through all the files looking for non-default values for variables.
1309 (set-buffer (gnus-get-buffer-create " *gnus bug info*"))
1312 (when (and (setq file (locate-library (pop files)))
1313 (file-exists-p file))
1314 (insert-file-contents file)
1315 (goto-char (point-min))
1316 (if (not (re-search-forward "^;;* *Internal variables" nil t))
1317 (gnus-message 4 "Malformed sources in file %s" file)
1318 (narrow-to-region (point-min) (point))
1319 (goto-char (point-min))
1320 (while (setq expr (ignore-errors (read (current-buffer))))
1322 (and (memq (car expr) '(defvar defcustom defvoo))
1323 (stringp (nth 3 expr))
1324 (or (not (boundp (nth 1 expr)))
1325 (not (equal (eval (nth 2 expr))
1326 (symbol-value (nth 1 expr)))))
1327 (push (nth 1 expr) olist)))))))
1328 (kill-buffer (current-buffer)))
1329 (when (setq olist (nreverse olist))
1330 (insert ";----------------- Environment follows ------------------\n\n"))
1332 (if (boundp (car olist))
1334 (pp `(setq ,(car olist)
1335 ,(if (or (consp (setq sym (symbol-value (car olist))))
1337 (not (or (eq sym nil)
1339 (list 'quote (symbol-value (car olist)))
1340 (symbol-value (car olist))))
1343 (format "(setq %s 'whatever)\n" (car olist))))
1344 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
1345 (setq olist (cdr olist)))
1346 ;; Remove any control chars - they seem to cause trouble for some
1347 ;; mailers. (Byte-compiled output from the stuff above.)
1349 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
1350 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
1352 ;; Break MIME tags purposely.
1354 (while (re-search-forward mime-edit-tag-regexp nil t)
1355 (goto-char (1+ (match-beginning 0)))
1358 ;;; Treatment of rejected articles.
1361 (defun gnus-summary-resend-bounced-mail (&optional fetch)
1362 "Re-mail the current message.
1363 This only makes sense if the current message is a bounce message than
1364 contains some mail you have written which has been bounced back to
1366 If FETCH, try to fetch the article that this is a reply to, if indeed
1369 (gnus-summary-select-article t)
1370 (set-buffer gnus-original-article-buffer)
1371 (let ((gnus-message-setup-hook '(gnus-maybe-setup-default-charset)))
1372 (gnus-setup-message 'compose-bounce
1373 (let* ((references (mail-fetch-field "references"))
1374 (parent (and references (gnus-parent-id references))))
1376 ;; If there are references, we fetch the article we answered to.
1378 (gnus-summary-refer-article parent)
1379 (gnus-summary-show-all-headers))))))
1383 (defun gnus-inews-group-method (group)
1385 ;; If the group doesn't exist, we assume
1386 ;; it's an archive group...
1387 ((and (null (gnus-get-info group))
1388 (eq (car (gnus-server-to-method gnus-message-archive-method))
1389 (car (gnus-server-to-method (gnus-group-method group)))))
1390 gnus-message-archive-method)
1392 ((gnus-info-method (gnus-get-info group))
1393 (gnus-info-method (gnus-get-info group)))
1395 (t (gnus-server-to-method (gnus-group-method group)))))
1397 ;; Do Gcc handling, which copied the message over to some group.
1398 (defun gnus-inews-do-gcc (&optional gcc)
1402 (message-narrow-to-headers)
1403 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
1404 (coding-system-for-write 'raw-text)
1405 (output-coding-system 'raw-text)
1406 groups group method group-art)
1408 (message-remove-header "gcc")
1410 (setq groups (message-unquote-tokens
1411 (message-tokenize-header gcc " ,")))
1412 ;; Copy the article over to some group(s).
1413 (while (setq group (pop groups))
1414 (unless (gnus-check-server
1415 (setq method (gnus-inews-group-method group)))
1416 (error "Can't open server %s" (if (stringp method) method
1418 (unless (gnus-request-group group nil method)
1419 (gnus-request-create-group group method))
1421 (nnheader-set-temp-buffer " *acc*")
1422 (insert-buffer-substring message-encoding-buffer)
1423 (gnus-run-hooks 'gnus-before-do-gcc-hook)
1424 (goto-char (point-min))
1425 (when (re-search-forward
1426 (concat "^" (regexp-quote mail-header-separator) "$")
1428 (replace-match "" t t ))
1429 (unless (setq group-art
1430 (gnus-request-accept-article group method t t))
1431 (gnus-message 1 "Couldn't store article in group %s: %s"
1432 group (gnus-status-message method))
1434 (when (and group-art gnus-inews-mark-gcc-as-read)
1435 (gnus-group-mark-article-read group (cdr group-art)))
1436 (kill-buffer (current-buffer)))))))))
1438 (defun gnus-inews-insert-gcc ()
1439 "Insert Gcc headers based on `gnus-outgoing-message-group'."
1442 (message-narrow-to-headers)
1443 (let* ((group gnus-outgoing-message-group)
1445 ((gnus-functionp group)
1447 ((or (stringp group) (list group))
1451 (if (stringp gcc) gcc
1452 (mapconcat 'identity gcc " "))
1455 (defun gnus-inews-insert-archive-gcc (&optional group)
1456 "Insert the Gcc to say where the article is to be archived."
1457 (let* ((var gnus-message-archive-group)
1458 (group (or group gnus-newsgroup-name ""))
1460 (and gnus-newsgroup-name
1461 (not (equal gnus-newsgroup-name ""))
1462 (gnus-group-find-parameter
1463 gnus-newsgroup-name 'gcc-self)))
1467 ((null gnus-message-archive-method)
1471 ;; Just a single group.
1474 ;; We don't want this.
1476 ((and (listp var) (stringp (car var)))
1477 ;; A list of groups.
1479 ((gnus-functionp var)
1481 (funcall var group))
1483 ;; An alist of regexps/functions/forms.
1488 ((stringp (caar var))
1490 (when (string-match (caar var) group)
1492 ((gnus-functionp (car var))
1494 (funcall (car var) group))
1496 (eval (car var)))))))
1497 (setq var (cdr var)))
1500 (when (or groups gcc-self-val)
1501 (when (stringp groups)
1502 (setq groups (list groups)))
1505 (message-narrow-to-headers)
1506 (goto-char (point-max))
1509 ;; Use the `gcc-self' param value instead.
1512 (if (stringp gcc-self-val)
1515 (if (not (eq gcc-self-val 'none))
1520 ;; Use the list of groups.
1521 (while (setq name (pop groups))
1522 (insert (if (string-match ":" name)
1524 (gnus-group-prefixed-name
1525 name gnus-message-archive-method)))
1532 (defun gnus-configure-posting-styles ()
1533 "Configure posting styles according to `gnus-posting-styles'."
1534 (unless gnus-inhibit-posting-styles
1535 (let ((group (or gnus-newsgroup-name ""))
1536 (styles gnus-posting-styles)
1537 style match variable attribute value v results
1538 filep name address element)
1539 ;; If the group has a posting-style parameter, add it at the end with a
1540 ;; regexp matching everything, to be sure it takes precedence over all
1542 (when gnus-newsgroup-name
1543 (let ((tmp-style (gnus-group-find-parameter group 'posting-style t)))
1545 (setq styles (append styles (list (cons ".*" tmp-style)))))))
1546 ;; Go through all styles and look for matches.
1547 (dolist (style styles)
1548 (setq match (pop style))
1549 (goto-char (point-min))
1552 ;; Regexp string match on the group name.
1553 (string-match match group))
1555 (and (gnus-buffer-live-p gnus-article-copy)
1556 (with-current-buffer gnus-article-copy
1557 (let ((header (message-fetch-field (pop style))))
1559 (string-match (pop style) header))))))
1560 ((or (symbolp match)
1561 (gnus-functionp match))
1563 ((gnus-functionp match)
1564 ;; Function to be called.
1567 ;; Variable to be checked.
1568 (symbol-value match))))
1570 ;; This is a form to be evaled.
1572 ;; We have a match, so we set the variables.
1573 (dolist (attribute style)
1574 (setq element (pop attribute)
1579 ((eq (car attribute) ':file)
1582 ((eq (car attribute) :value)
1586 ;; We get the value.
1591 ((or (symbolp value)
1592 (gnus-functionp value))
1593 (cond ((gnus-functionp value)
1596 (symbol-value value))))
1599 ;; Translate obsolescent value.
1600 (when (eq element 'signature-file)
1601 (setq element 'signature
1603 ;; Get the contents of file elems.
1605 (setq v (with-temp-buffer
1606 (insert-file-contents v)
1608 (setq results (delq (assoc element results) results))
1609 (push (cons element v) results))))
1610 ;; Now we have all the styles, so we insert them.
1611 (setq name (assq 'name results)
1612 address (assq 'address results))
1613 (setq results (delq name (delq address results)))
1614 (make-local-variable 'message-setup-hook)
1615 (dolist (result results)
1616 (add-hook 'message-setup-hook
1618 ((eq 'eval (car result))
1620 ((eq 'body (car result))
1624 (insert ,(cdr result)))))
1625 ((eq 'signature (car result))
1626 (set (make-local-variable 'message-signature) nil)
1627 (set (make-local-variable 'message-signature-file) nil)
1628 (if (not (cdr result))
1632 (let ((message-signature ,(cdr result)))
1633 (when message-signature
1634 (message-insert-signature)))))))
1637 (if (symbolp (car result))
1638 (capitalize (symbol-name (car result)))
1642 (message-remove-header ,header)
1643 (let ((value ,(cdr result)))
1646 (insert ,header ": " value "\n"))))))))))
1647 (when (or name address)
1648 (add-hook 'message-setup-hook
1650 (set (make-local-variable 'user-mail-address)
1651 ,(or (cdr address) user-mail-address))
1652 (let ((user-full-name ,(or (cdr name) (user-full-name)))
1654 ,(or (cdr address) user-mail-address)))
1656 (message-remove-header "From")
1658 (insert "From: " (message-make-from) "\n")))))))))
1661 ;;; @ for MIME Edit mode
1664 (defun gnus-maybe-setup-default-charset ()
1666 (and (boundp 'gnus-summary-buffer)
1667 (buffer-live-p gnus-summary-buffer)
1669 (set-buffer gnus-summary-buffer)
1670 default-mime-charset))))
1673 (make-local-variable 'default-mime-charset)
1674 (setq default-mime-charset charset)
1678 ;;; @ for MIME view mode
1681 (defun gnus-following-method (buf)
1682 (gnus-setup-message 'reply-yank
1684 (if (message-news-p)
1686 (message-reply nil 'wide))
1687 (let ((message-reply-buffer buf))
1688 (message-yank-original))
1689 (message-goto-body))
1693 ;;; Allow redefinition of functions.
1699 ;;; gnus-msg.el ends here