1 ;;; gnus-msg.el --- mail and post interface for Semi-gnus
2 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001
3 ;; Free Software Foundation, Inc.
5 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
6 ;; Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
8 ;; Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp>
9 ;; Katsumi Yamaoka <yamaoka@jpl.org>
10 ;; Kiyokazu SUTO <suto@merry.xmath.ous.ac.jp>
11 ;; Keywords: mail, news, MIME
13 ;; This file is part of GNU Emacs.
15 ;; GNU Emacs is free software; you can redistribute it and/or modify
16 ;; it under the terms of the GNU General Public License as published by
17 ;; the Free Software Foundation; either version 2, or (at your option)
20 ;; GNU Emacs is distributed in the hope that it will be useful,
21 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 ;; GNU General Public License for more details.
25 ;; You should have received a copy of the GNU General Public License
26 ;; along with GNU Emacs; see the file COPYING. If not, write to the
27 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
28 ;; Boston, MA 02111-1307, USA.
34 (eval-when-compile (require 'cl))
35 (eval-when-compile (require 'static))
42 (defcustom gnus-post-method 'current
43 "*Preferred method for posting USENET news.
45 If this variable is `current' (which is the default), Gnus will use
46 the \"current\" select method when posting. If it is nil, Gnus will
47 use the native select method when posting.
49 This method will not be used in mail groups and the like, only in
52 If not nil nor `native', the value must be a valid method as discussed
53 in the documentation of `gnus-select-method'. It can also be a list of
54 methods. If that is the case, the user will be queried for what select
55 method to use when posting."
56 :group 'gnus-group-foreign
57 :type `(choice (const nil)
60 (sexp :tag "Methods" ,gnus-select-method)))
62 (defvar 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 (defvar gnus-mailing-list-groups nil
74 "*Regexp matching groups that are really mailing lists.
75 This is useful when you're reading a mailing list that has been
76 gatewayed to a newsgroup, and you want to followup to an article in
79 (defvar gnus-add-to-list nil
80 "*If non-nil, add a `to-list' parameter automatically.")
82 (defvar gnus-crosspost-complaint
85 You posted the article below with the following Newsgroups header:
89 The %s group, at least, was an inappropriate recipient
90 of this message. Please trim your Newsgroups header to exclude this
91 group before posting in the future.
96 "Format string to be inserted when complaining about crossposts.
97 The first %s will be replaced by the Newsgroups header;
98 the second with the current group name.")
100 (defvar gnus-message-setup-hook '(gnus-maybe-setup-default-charset)
101 "Hook run after setting up a message buffer.")
103 (defvar gnus-bug-create-help-buffer t
104 "*Should we create the *Gnus Help Bug* buffer?")
106 (defvar gnus-posting-styles nil
107 "*Alist of styles to use when posting.")
109 (defvar gnus-inews-mark-gcc-as-read nil
110 "If non-nil, automatically mark Gcc articles as read.")
112 (defcustom gnus-group-posting-charset-alist
113 '(("^\\(no\\|fr\\)\\.[^,]*\\(,[ \t\n]*\\(no\\|fr\\)\\.[^,]*\\)*$" iso-8859-1 (iso-8859-1))
114 ("^\\(fido7\\|relcom\\)\\.[^,]*\\(,[ \t\n]*\\(fido7\\|relcom\\)\\.[^,]*\\)*$" koi8-r (koi8-r))
115 (message-this-is-mail nil nil)
116 (message-this-is-news nil t))
117 "Alist of regexps and permitted unencoded charsets for posting.
118 Each element of the alist has the form (TEST HEADER BODY-LIST), where
119 TEST is either a regular expression matching the newsgroup header or a
121 HEADER is the charset which may be left unencoded in the header (nil
122 means encode all charsets),
123 BODY-LIST is a list of charsets which may be encoded using 8bit
124 content-transfer encoding in the body, or one of the special values
125 nil (always encode using quoted-printable) or t (always use 8bit).
127 Note that any value other than nil for HEADER infringes some RFCs, so
128 use this option with care."
129 :type '(repeat (list :tag "Permitted unencoded charsets"
131 (regexp :tag "Group")
132 (const :tag "Mail message"
133 :value message-this-is-mail)
134 (const :tag "News article"
135 :value message-this-is-news))
136 (choice :tag "Header"
137 (const :tag "None" nil)
138 (symbol :tag "Charset"))
140 (const :tag "Any" :value t)
141 (const :tag "None" :value nil)
142 (repeat :tag "Charsets"
143 (symbol :tag "Charset")))))
144 :group 'gnus-charset)
146 ;;; Internal variables.
148 (defvar gnus-inhibit-posting-styles nil
149 "Inhibit the use of posting styles.")
151 (defvar gnus-message-buffer "*Mail Gnus*")
152 (defvar gnus-article-copy nil)
153 (defvar gnus-check-before-posting nil)
154 (defvar gnus-last-posting-server nil)
155 (defvar gnus-message-group-art nil)
157 (defvar gnus-msg-force-broken-reply-to nil)
159 (defconst gnus-bug-message
160 (format "Sending a bug report to the Gnus Towers.
161 ========================================
163 This gnus is the %s%s.
164 If you think the bug is a Semi-gnus bug, send a bug report to Semi-gnus
165 Developers. (the addresses below are mailing list addresses)
167 ========================================
169 The buffer below is a mail buffer. When you press `C-c C-c', it will
170 be sent to the Gnus Bug Exterminators.
172 The thing near the bottom of the buffer is how the environment
173 settings will be included in the mail. Please do not delete that.
174 They will tell the Bug People what your environment is, so that it
175 will be easier to locate the bugs.
177 If you have found a bug that makes Emacs go \"beep\", set
178 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
179 and include the backtrace in your bug report.
181 Please describe the bug in annoying, painstaking detail.
183 Thank you for your help in stamping out bugs.
186 (if (string= gnus-product-name "Semi-gnus")
188 ", a modified version of Semi-gnus")))
191 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
192 (autoload 'news-setup "rnewspost")
193 (autoload 'news-reply-mode "rnewspost")
194 (autoload 'rmail-dont-reply-to "mail-utils")
195 (autoload 'rmail-output "rmailout"))
199 ;;; Gnus Posting Functions
202 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
203 "p" gnus-summary-post-news
204 "f" gnus-summary-followup
205 "F" gnus-summary-followup-with-original
206 "c" gnus-summary-cancel-article
207 "s" gnus-summary-supersede-article
208 "r" gnus-summary-reply
209 "y" gnus-summary-yank-message
210 "R" gnus-summary-reply-with-original
211 "w" gnus-summary-wide-reply
212 "W" gnus-summary-wide-reply-with-original
213 "v" gnus-summary-very-wide-reply
214 "V" gnus-summary-very-wide-reply-with-original
215 "n" gnus-summary-followup-to-mail
216 "N" gnus-summary-followup-to-mail-with-original
217 "m" gnus-summary-mail-other-window
218 "u" gnus-uu-post-news
219 "\M-c" gnus-summary-mail-crosspost-complaint
220 "Br" gnus-summary-reply-broken-reply-to
221 "BR" gnus-summary-reply-broken-reply-to-with-original
222 "om" gnus-summary-mail-forward
223 "op" gnus-summary-post-forward
224 "Om" gnus-summary-digest-mail-forward
225 "Op" gnus-summary-digest-post-forward)
227 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
228 "b" gnus-summary-resend-bounced-mail
229 ;; "c" gnus-summary-send-draft
230 "r" gnus-summary-resend-message)
232 ;;; Internal functions.
234 (defvar gnus-article-reply nil)
235 (defmacro gnus-setup-message (config &rest forms)
236 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
237 (buffer (make-symbol "gnus-setup-message-buffer"))
238 (article (make-symbol "gnus-setup-message-article"))
239 (group (make-symbol "gnus-setup-message-group")))
240 `(let ((,winconf (current-window-configuration))
241 (,buffer (buffer-name (current-buffer)))
242 (,article gnus-article-reply)
243 (,group gnus-newsgroup-name)
244 (message-header-setup-hook
245 (copy-sequence message-header-setup-hook))
246 (message-mode-hook (copy-sequence message-mode-hook))
247 (message-startup-parameter-alist
248 '((reply-buffer . gnus-copy-article-buffer)
249 (original-buffer . gnus-original-article-buffer)
250 (user-agent . Gnus))))
251 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
252 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
253 (add-hook 'message-mode-hook 'gnus-configure-posting-styles)
257 (gnus-inews-add-send-actions ,winconf ,buffer ,article ,config)
258 (gnus-inews-insert-draft-meta-information ,group ,article)
259 (setq gnus-message-buffer (current-buffer))
260 (set (make-local-variable 'gnus-message-group-art)
261 (cons ,group ,article))
262 (set (make-local-variable 'gnus-newsgroup-name) ,group)
263 (gnus-run-hooks 'gnus-message-setup-hook))
265 (gnus-configure-windows ,config t)
266 (set-buffer-modified-p nil))))
268 (defun gnus-inews-insert-draft-meta-information (group article)
271 (not (string= group ""))
272 (not (message-fetch-field gnus-draft-meta-information-header)))
273 (goto-char (point-min))
274 (insert gnus-draft-meta-information-header ": (\"" group "\" "
275 (if article (number-to-string
282 (defun gnus-msg-mail (&optional to subject other-headers continue
283 switch-action yank-action send-actions)
284 "Start editing a mail message to be sent.
285 Like `message-mail', but with Gnus paraphernalia, particularly the
286 Gcc: header for archiving purposes."
288 (let ((buf (current-buffer))
290 (gnus-setup-message 'message
291 (message-mail to subject other-headers continue
292 nil yank-action send-actions))
294 (setq mail-buf (current-buffer))
295 (switch-to-buffer buf)
296 (apply switch-action mail-buf nil)))
297 ;; COMPOSEFUNC should return t if succeed. Undocumented ???
301 (defun gnus-button-mailto (address)
303 (set-buffer (gnus-copy-article-buffer))
304 (gnus-setup-message 'message
305 (message-reply address)))
308 (defun gnus-button-reply (&optional to-address wide)
309 "Like `message-reply'."
311 (gnus-setup-message 'message
312 (message-reply to-address wide)))
315 (define-mail-user-agent 'gnus-user-agent
316 'gnus-msg-mail 'message-send-and-exit
317 'message-kill-buffer 'message-send-hook)
319 (defun gnus-setup-posting-charset (group)
320 (let ((alist gnus-group-posting-charset-alist)
321 (group (or group ""))
325 (while (setq elem (pop alist))
326 (when (or (and (stringp (car elem))
327 (string-match (car elem) group))
328 (and (gnus-functionp (car elem))
329 (funcall (car elem) group))
330 (and (symbolp (car elem))
331 (symbol-value (car elem))))
332 (throw 'found (cons (cadr elem) (caddr elem)))))))))
334 (defun gnus-inews-add-send-actions (winconf buffer article &optional config)
335 (make-local-hook 'message-sent-hook)
336 (add-hook 'message-sent-hook (if gnus-agent 'gnus-agent-possibly-do-gcc
337 'gnus-inews-do-gcc) nil t)
339 (make-local-hook 'message-header-hook)
340 (add-hook 'message-header-hook 'gnus-agent-possibly-save-gcc nil t))
341 (setq message-post-method
343 (gnus-post-method arg ,gnus-newsgroup-name)))
344 (setq message-user-agent (gnus-extended-version))
345 (when (not message-use-multi-frames)
347 `(set-window-configuration ,winconf) 'exit 'postpone 'kill))
349 `(when (gnus-buffer-exists-p ,buffer)
353 (if (eq config 'forward)
354 `(gnus-summary-mark-article-as-forwarded ',article)
355 `(gnus-summary-mark-article-as-replied ',article)))))
358 (put 'gnus-setup-message 'lisp-indent-function 1)
359 (put 'gnus-setup-message 'edebug-form-spec '(form body))
361 ;;; Post news commands of Gnus group mode and summary mode
363 (defun gnus-group-mail (&optional arg)
364 "Start composing a mail.
365 If ARG, use the group under the point to find a posting style.
366 If ARG is 1, prompt for a group name to find the posting style."
368 ;; We can't `let' gnus-newsgroup-name here, since that leads
369 ;; to local variables leaking.
370 (let ((group gnus-newsgroup-name)
371 (buffer (current-buffer)))
374 (setq gnus-newsgroup-name
376 (if (= 1 (prefix-numeric-value arg))
377 (completing-read "Use posting style of group: "
378 gnus-active-hashtb nil
379 (gnus-read-active-file-p))
380 (gnus-group-group-name))
382 (gnus-setup-message 'message (message-mail)))
385 (setq gnus-newsgroup-name group)))))
387 (defun gnus-group-post-news (&optional arg)
388 "Start composing a news message.
389 If ARG, post to the group under point.
390 If ARG is 1, prompt for a group name."
392 ;; Bind this variable here to make message mode hooks work ok.
393 (let ((gnus-newsgroup-name
395 (if (= 1 (prefix-numeric-value arg))
396 (completing-read "Newsgroup: " gnus-active-hashtb nil
397 (gnus-read-active-file-p))
398 (gnus-group-group-name))
400 (gnus-post-news 'post gnus-newsgroup-name)))
402 (defun gnus-summary-post-news ()
403 "Start composing a news message."
405 (gnus-post-news 'post gnus-newsgroup-name))
407 (defun gnus-summary-followup (yank &optional force-news)
408 "Compose a followup to an article.
409 If prefix argument YANK is non-nil, original article is yanked automatically."
411 (list (and current-prefix-arg
412 (gnus-summary-work-articles 1))))
414 (gnus-summary-goto-subject (car yank)))
415 (save-window-excursion
416 (gnus-summary-select-article))
417 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
418 (gnus-newsgroup-name gnus-newsgroup-name))
420 (gnus-post-news nil gnus-newsgroup-name
421 headers gnus-article-buffer
422 yank nil force-news)))
424 (defun gnus-summary-followup-with-original (n &optional force-news)
425 "Compose a followup to an article and include the original article."
427 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
429 (defun gnus-summary-followup-to-mail (&optional arg)
430 "Followup to the current mail message via news."
432 (list (and current-prefix-arg
433 (gnus-summary-work-articles 1))))
434 (gnus-summary-followup arg t))
436 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
437 "Followup to the current mail message via news."
439 (gnus-summary-followup (gnus-summary-work-articles arg) t))
441 (defun gnus-inews-yank-articles (articles)
442 (let ((more-than-one (cdr articles))
443 (cur (current-buffer))
444 refs beg article window)
446 (while (setq article (pop articles))
447 (save-window-excursion
448 (set-buffer gnus-summary-buffer)
449 (gnus-summary-select-article nil nil nil article)
450 (gnus-summary-remove-process-mark article))
452 ;; Gathering references.
454 (setq refs (message-list-references
456 (mail-header-references gnus-current-headers)
457 (mail-header-message-id gnus-current-headers)))
458 (when message-use-multi-frames
459 (when (setq window (get-buffer-window cur t))
460 (select-frame (window-frame window)))))
462 (gnus-copy-article-buffer)
463 (let ((message-reply-buffer gnus-article-copy)
464 (message-reply-headers
465 (with-current-buffer gnus-article-copy
466 ;; The headers are decoded.
467 (nnheader-parse-head t))))
468 (message-yank-original)
469 (setq beg (or beg (mark t))))
474 ;; Replace with the gathered references.
478 (message-narrow-to-headers)
479 (let ((case-fold-search t))
480 (if (re-search-forward "^References:\\([\t ]+.+\n\\)+" nil t)
482 (goto-char (point-max))))
484 (list (or (assq 'References message-header-format-alist)
485 '(References . message-shorten-references)))
486 (list (cons 'References
487 (mapconcat 'identity (nreverse refs) " "))))
488 (backward-delete-char 1))
494 (defun gnus-summary-cancel-article (&optional n symp)
495 "Cancel an article you posted.
496 Uses the process-prefix convention. If given the symbolic
497 prefix `a', cancel using the standard posting method; if not
498 post using the current select method."
499 (interactive (gnus-interactive "P\ny"))
500 (let ((articles (gnus-summary-work-articles n))
503 (gnus-post-method (not (eq symp 'a)) ,gnus-newsgroup-name)))
505 (while (setq article (pop articles))
506 (when (gnus-summary-select-article t nil nil article)
507 (when (gnus-eval-in-buffer-window gnus-article-buffer
509 (set-buffer gnus-original-article-buffer)
510 (message-cancel-news)))
511 (gnus-summary-mark-as-read article gnus-canceled-mark)
512 (gnus-cache-remove-article 1))
513 (gnus-article-hide-headers-if-wanted))
514 (gnus-summary-remove-process-mark article))))
516 (defun gnus-summary-supersede-article ()
517 "Compose an article that will supersede a previous article.
518 This is done simply by taking the old article and adding a Supersedes
519 header line with the old Message-ID."
521 (let ((article (gnus-summary-article-number))
522 (gnus-message-setup-hook '(gnus-maybe-setup-default-charset)))
523 (gnus-setup-message 'reply-yank
524 (gnus-summary-select-article t)
525 (set-buffer gnus-original-article-buffer)
529 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
531 (set-buffer ,gnus-summary-buffer)
532 (gnus-cache-possibly-remove-article ,article nil nil nil t)
533 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
534 message-send-actions))))
538 (defun gnus-copy-article-buffer (&optional article-buffer)
539 ;; make a copy of the article buffer with all text properties removed
540 ;; this copy is in the buffer gnus-article-copy.
541 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
542 ;; this buffer should be passed to all mail/news reply/post routines.
543 (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
544 (let ((article-buffer (or article-buffer gnus-article-buffer))
546 (if (not (and (get-buffer article-buffer)
547 (gnus-buffer-exists-p article-buffer)))
548 (error "Can't find any article buffer")
550 (set-buffer article-buffer)
551 (let ((gnus-newsgroup-charset (or gnus-article-charset
552 gnus-newsgroup-charset))
553 (gnus-newsgroup-ignored-charsets
554 (or gnus-article-ignored-charsets
555 gnus-newsgroup-ignored-charsets)))
557 ;; Copy over the (displayed) article buffer, delete
558 ;; hidden text and remove text properties.
560 (let ((inhibit-read-only t))
561 (copy-to-buffer gnus-article-copy (point-min) (point-max))
562 (set-buffer gnus-article-copy)
563 ;; Encode bitmap smileys to ordinary text.
564 ;; Possibly, the original text might be restored.
565 (static-unless (featurep 'xemacs)
566 (when (featurep 'smiley-mule)
567 (smiley-encode-buffer)))
568 (gnus-article-delete-text-of-type 'annotation)
569 (gnus-remove-text-with-property 'gnus-prev)
570 (gnus-remove-text-with-property 'gnus-next)
571 (gnus-remove-text-with-property 'x-face-mule-bitmap-image)
574 (static-if (featurep 'xemacs)
575 ;; Revome smiley extents for (possibly) XEmacs 21.1.
577 (buffer-substring-no-properties (point-min)
579 (buffer-substring-no-properties (point-min) (point-max)))
581 ;; Find the original headers.
582 (set-buffer gnus-original-article-buffer)
583 (goto-char (point-min))
584 (while (looking-at message-unix-mail-delimiter)
587 (setq end (or (message-goto-body) beg))
588 ;; Delete the headers from the displayed articles.
589 (set-buffer gnus-article-copy)
590 (delete-region (goto-char (point-min))
591 (or (message-goto-body) (point-max)))
592 ;; Insert the original article headers.
593 (insert-buffer-substring gnus-original-article-buffer beg end)
594 (article-decode-encoded-words))))
597 (defun gnus-post-news (post &optional group header article-buffer yank subject
600 (gnus-copy-article-buffer))
601 (let ((gnus-article-reply (and article-buffer (gnus-summary-article-number)))
602 (add-to-list gnus-add-to-list))
603 (gnus-setup-message (cond (yank 'reply-yank)
604 (article-buffer 'reply)
606 (let* ((group (or group gnus-newsgroup-name))
607 (charset (gnus-group-name-charset nil group))
609 to-address to-group mailing-list to-list
612 (setq to-address (gnus-parameter-to-address group)
613 to-group (gnus-group-find-parameter group 'to-group)
614 to-list (gnus-parameter-to-list group)
615 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
616 mailing-list (when gnus-mailing-list-groups
617 (string-match gnus-mailing-list-groups group))
618 group (gnus-group-name-decode (gnus-group-real-name group)
620 (if (or (and to-group
621 (gnus-news-group-p to-group))
624 (and (gnus-news-group-p
625 (or pgroup gnus-newsgroup-name)
626 (if header (mail-header-number header)
627 gnus-current-article))
633 (message-news (or to-group group))
634 (set-buffer gnus-article-copy)
635 (gnus-msg-treat-broken-reply-to)
636 (message-followup (if (or newsgroup-p force-news)
637 (if (save-restriction
638 (article-narrow-to-head)
639 (message-fetch-field "newsgroups"))
646 (message-mail (or to-address to-list))
647 ;; Arrange for mail groups that have no `to-address' to
648 ;; get that when the user sends off the mail.
649 (when (and (not to-list)
652 (push (list 'gnus-inews-add-to-address pgroup)
653 message-send-actions)))
654 (set-buffer gnus-article-copy)
655 (gnus-msg-treat-broken-reply-to)
656 (message-wide-reply to-address)))
658 (gnus-inews-yank-articles yank))))))
660 (defun gnus-msg-treat-broken-reply-to (&optional force)
661 "Remove the Reply-to header iff broken-reply-to."
663 (gnus-group-find-parameter
664 gnus-newsgroup-name 'broken-reply-to))
666 (message-narrow-to-head)
667 (message-remove-header "reply-to"))))
669 (defun gnus-post-method (arg group &optional silent)
670 "Return the posting method based on GROUP and ARG.
671 If SILENT, don't prompt the user."
672 (let ((group-method (gnus-find-method-for-group group)))
674 ;; If the group-method is nil (which shouldn't happen) we use
675 ;; the default method.
677 (or (and (null (eq gnus-post-method 'active)) gnus-post-method)
678 gnus-select-method message-post-method))
679 ;; We want the inverse of the default
680 ((and arg (not (eq arg 0)))
681 (if (eq gnus-post-method 'active)
684 ;; We query the user for a post method.
686 (and gnus-post-method
687 (not (eq gnus-post-method 'current))
688 (listp (car gnus-post-method))))
690 ;; Collect all methods we know about.
692 (when (and gnus-post-method
693 (not (eq gnus-post-method 'current)))
694 (if (listp (car gnus-post-method))
696 (list gnus-post-method)))
697 gnus-secondary-select-methods
698 (mapcar 'cdr gnus-server-alist)
699 (mapcar 'car gnus-opened-servers)
700 (list gnus-select-method)
701 (list group-method)))
702 method-alist post-methods method)
703 ;; Weed out all mail methods.
705 (setq method (gnus-server-get-method "" (pop methods)))
706 (when (and (or (gnus-method-option-p method 'post)
707 (gnus-method-option-p method 'post-mail))
708 (not (member method post-methods)))
709 (push method post-methods)))
710 ;; Create a name-method alist.
714 (if (equal (cadr m) "")
715 (list (symbol-name (car m)) m)
716 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m)))
721 (setq gnus-last-posting-server
723 gnus-last-posting-server)
724 ;; Just use the last value.
725 gnus-last-posting-server
727 "Posting method: " method-alist nil t
728 (cons (or gnus-last-posting-server "") 0))))
730 ;; Override normal method.
731 ((and (eq gnus-post-method 'current)
732 (not (eq (car group-method) 'nndraft))
733 (gnus-get-function group-method 'request-post t)
736 ((and gnus-post-method
737 (not (eq gnus-post-method 'current)))
739 ;; Use the normal select method.
740 (t gnus-select-method))))
744 (defun gnus-message-make-user-agent (&optional include-mime-info max-column)
745 "Return user-agent info.
746 INCLUDE-MIME-INFO the optional first argument if it is non-nil and the variable
747 `mime-edit-user-agent-value' exists, the return value will include it.
748 MAX-COLUMN the optional second argument if it is specified, the return value
749 will be folded up in the proper way."
750 (let ((user-agent (if (and include-mime-info
751 (boundp 'mime-edit-user-agent-value))
752 (concat (gnus-extended-version)
754 mime-edit-user-agent-value)
755 (gnus-extended-version))))
758 (unless (natnump max-column) (setq max-column 76))
760 (insert " " user-agent)
762 (while (re-search-forward "[\n\t ]+" nil t)
765 (while (re-search-forward "[^ ()/]+\\(/[^ ()/]+\\)? ?" nil t)
766 (while (eq ?\( (char-after (point)))
768 (skip-chars-forward " "))
769 (skip-chars-backward " ")
770 (if (> (current-column) max-column)
772 (if (or (not boundary) (eq ?\n (char-after boundary)))
774 (setq boundary (point))
781 (setq boundary (point))))
782 (buffer-substring 13 (point-max))))
787 ;;; Gnus Mail Functions
790 ;;; Mail reply commands of Gnus summary mode
792 (defun gnus-summary-reply (&optional yank wide very-wide)
793 "Start composing a mail reply to the current message.
794 If prefix argument YANK is non-nil, the original article is yanked
796 If WIDE, make a wide reply.
797 If VERY-WIDE, make a very wide reply."
799 (list (and current-prefix-arg
800 (gnus-summary-work-articles 1))))
801 ;; Stripping headers should be specified with mail-yank-ignored-headers.
803 (gnus-summary-goto-subject (car yank)))
804 (let ((gnus-article-reply (or yank (gnus-summary-article-number)))
806 (gnus-setup-message (if yank 'reply-yank 'reply)
808 (gnus-summary-select-article)
809 (dolist (article very-wide)
810 (gnus-summary-select-article nil nil nil article)
812 (set-buffer (gnus-copy-article-buffer))
813 (gnus-msg-treat-broken-reply-to)
815 (message-narrow-to-head)
816 (setq headers (concat headers (buffer-string)))))))
817 (set-buffer (gnus-copy-article-buffer))
818 (gnus-msg-treat-broken-reply-to gnus-msg-force-broken-reply-to)
820 (message-narrow-to-head)
824 (goto-char (point-max)))
825 (message-reply nil wide)
827 (gnus-inews-yank-articles yank)))))
829 (defun gnus-summary-reply-with-original (n &optional wide)
830 "Start composing a reply mail to the current message.
831 The original article will be yanked."
833 (gnus-summary-reply (gnus-summary-work-articles n) wide))
835 (defun gnus-summary-reply-broken-reply-to (&optional yank wide very-wide)
836 "Like `gnus-summary-reply' except removing reply-to field.
837 If prefix argument YANK is non-nil, the original article is yanked
839 If WIDE, make a wide reply.
840 If VERY-WIDE, make a very wide reply."
842 (list (and current-prefix-arg
843 (gnus-summary-work-articles 1))))
844 (let ((gnus-msg-force-broken-reply-to t))
845 (gnus-summary-reply yank wide very-wide)))
847 (defun gnus-summary-reply-broken-reply-to-with-original (n &optional wide)
848 "Like `gnus-summary-reply-with-original' except removing reply-to field.
849 The original article will be yanked."
851 (gnus-summary-reply-broken-reply-to (gnus-summary-work-articles n) wide))
853 (defun gnus-summary-wide-reply (&optional yank)
854 "Start composing a wide reply mail to the current message.
855 If prefix argument YANK is non-nil, the original article is yanked
858 (list (and current-prefix-arg
859 (gnus-summary-work-articles 1))))
860 (gnus-summary-reply yank t))
862 (defun gnus-summary-wide-reply-with-original (n)
863 "Start composing a wide reply mail to the current message.
864 The original article will be yanked."
866 (gnus-summary-reply-with-original n t))
868 (defun gnus-summary-very-wide-reply (&optional yank)
869 "Start composing a very wide reply mail to the current message.
870 If prefix argument YANK is non-nil, the original article is yanked
873 (list (and current-prefix-arg
874 (gnus-summary-work-articles 1))))
875 (gnus-summary-reply yank t (gnus-summary-work-articles yank)))
877 (defun gnus-summary-very-wide-reply-with-original (n)
878 "Start composing a very wide reply mail to the current message.
879 The original article will be yanked."
882 (gnus-summary-work-articles n) t (gnus-summary-work-articles n)))
884 (defun gnus-summary-mail-forward (&optional full-headers post)
885 "Forward the current message to another user.
886 If FULL-HEADERS (the prefix), include full headers when forwarding."
888 (gnus-setup-message 'forward
889 (gnus-summary-select-article)
890 (let ((charset default-mime-charset))
891 (set-buffer gnus-original-article-buffer)
892 (make-local-variable 'default-mime-charset)
893 (setq default-mime-charset charset))
894 (let ((message-included-forward-headers
895 (if full-headers "" message-included-forward-headers)))
896 (message-forward post))))
898 (defun gnus-summary-digest-mail-forward (&optional n post)
899 "Digests and forwards all articles in this series.
900 If N is a positive number, forward the N next articles.
901 If N is a negative number, forward the N previous articles.
902 If N is nil and any articles have been marked with the process mark,
903 forward those articles instead.
904 Optional POST will use news to forward instead of mail."
906 (let ((articles (gnus-summary-work-articles n))
908 subject article frame)
910 (gnus-setup-message 'forward
911 (gnus-summary-select-article)
913 (setq articles (sort articles '<)
914 subject "Digested Articles")
915 (with-current-buffer gnus-original-article-buffer
916 (setq subject (message-make-forward-subject))))
918 (message-news nil subject)
919 (message-mail nil subject))
920 (when (and message-use-multi-frames (cdr articles))
921 (setq frame (window-frame (get-buffer-window (current-buffer)))))
923 (while (setq article (pop articles))
924 (save-window-excursion
925 (set-buffer gnus-summary-buffer)
926 (gnus-summary-select-article nil nil nil article)
927 (setq topics (concat topics " "
928 (mail-header-subject gnus-current-headers)
930 (gnus-summary-remove-process-mark article))
932 (select-frame frame))
933 (insert (mime-make-tag "message" "rfc822") "\n")
934 (narrow-to-region (point) (point))
935 (insert-buffer-substring gnus-original-article-buffer)
937 (article-narrow-to-head)
938 (message-remove-header message-included-forward-headers t nil t))
939 (goto-char (point-max))
945 (mime-edit-enclose-digest-region (point)(mark t))))))
947 (defun gnus-summary-digest-post-forward (&optional n)
948 "Digest and forwards all articles in this series to a newsgroup.
949 If N is a positive number, forward the N next articles.
950 If N is a negative number, forward the N previous articles.
951 If N is nil and any articles have been marked with the process mark,
952 forward those articles instead."
954 (gnus-summary-digest-mail-forward n t))
956 (defun gnus-summary-resend-message (address n)
957 "Resend the current article to ADDRESS."
959 (list (message-read-from-minibuffer "Resend message(s) to: ")
961 (let ((articles (gnus-summary-work-articles n))
963 (while (setq article (pop articles))
964 (gnus-summary-select-article nil nil nil article)
966 (set-buffer gnus-original-article-buffer)
967 (message-resend address))
968 (gnus-summary-mark-article-as-forwarded article))))
970 (defun gnus-summary-post-forward (&optional full-headers)
971 "Forward the current article to a newsgroup.
972 If FULL-HEADERS (the prefix), include full headers when forwarding."
974 (gnus-summary-mail-forward full-headers t))
976 (defvar gnus-nastygram-message
977 "The following article was inappropriately posted to %s.\n\n"
978 "Format string to insert in nastygrams.
979 The current group name will be inserted at \"%s\".")
981 (defun gnus-summary-mail-nastygram (n)
982 "Send a nastygram to the author of the current article."
984 (when (or gnus-expert-user
986 "Really send a nastygram to the author of the current article? "))
987 (let ((group gnus-newsgroup-name))
988 (gnus-summary-reply-with-original n)
989 (set-buffer gnus-message-buffer)
991 (insert (format gnus-nastygram-message group))
992 (message-send-and-exit))))
994 (defun gnus-summary-mail-crosspost-complaint (n)
995 "Send a complaint about crossposting to the current article(s)."
997 (let ((articles (gnus-summary-work-articles n))
999 (while (setq article (pop articles))
1000 (set-buffer gnus-summary-buffer)
1001 (gnus-summary-goto-subject article)
1002 (let ((group (gnus-group-real-name gnus-newsgroup-name))
1003 newsgroups followup-to)
1004 (gnus-summary-select-article)
1005 (set-buffer gnus-original-article-buffer)
1006 (if (and (<= (length (message-tokenize-header
1008 (mail-fetch-field "newsgroups"))
1011 (or (not (setq followup-to (mail-fetch-field "followup-to")))
1012 (not (member group (message-tokenize-header
1013 followup-to ", ")))))
1015 (gnus-message 1 "Followup-to restricted")
1016 (gnus-message 1 "Not a crossposted article"))
1017 (set-buffer gnus-summary-buffer)
1018 (gnus-summary-reply-with-original 1)
1019 (set-buffer gnus-message-buffer)
1021 (insert (format gnus-crosspost-complaint newsgroups group))
1022 (message-goto-subject)
1023 (re-search-forward " *$")
1024 (replace-match " (crosspost notification)" t t)
1025 (gnus-deactivate-mark)
1026 (when (gnus-y-or-n-p "Send this complaint? ")
1027 (message-send-and-exit)))))))
1029 (defun gnus-summary-mail-other-window ()
1030 "Compose mail in other window."
1032 (gnus-setup-message 'message
1035 (defun gnus-mail-parse-comma-list ()
1038 (skip-chars-forward " ")
1041 (skip-chars-forward "^,")
1046 (narrow-to-region beg (point))
1049 (while (search-forward "\"" nil t)
1053 (skip-chars-forward ",")
1054 (skip-chars-forward "^,"))
1055 (skip-chars-backward " ")
1056 (push (buffer-substring beg (point))
1058 (skip-chars-forward "^,")
1059 (skip-chars-forward ", "))
1062 (defun gnus-inews-add-to-address (group)
1063 (let ((to-address (mail-fetch-field "to")))
1064 (when (and to-address
1066 ;; This mail group doesn't have a `to-list', so we add one
1068 (when (gnus-y-or-n-p
1069 (format "Do you want to add this as `to-list': %s " to-address))
1070 (gnus-group-add-parameter group (cons 'to-list to-address))))))
1072 (defun gnus-put-message ()
1073 "Put the current message in some group and return to Gnus."
1075 (let ((reply gnus-article-reply)
1076 (winconf gnus-prev-winconf)
1077 (group gnus-newsgroup-name))
1079 (not (gnus-group-read-only-p group)))
1080 (setq group (read-string "Put in group: " nil (gnus-writable-groups))))
1082 (when (gnus-gethash group gnus-newsrc-hashtb)
1083 (error "No such group: %s" group))
1087 (message-narrow-to-headers)
1088 (let ((gnus-deletable-headers nil))
1089 (message-generate-headers
1090 (if (message-news-p)
1091 message-required-news-headers
1092 message-required-mail-headers)))
1093 (goto-char (point-max))
1094 (insert "Gcc: " group "\n")
1097 (when (and (get-buffer gnus-group-buffer)
1098 (gnus-buffer-exists-p (car-safe reply))
1100 (set-buffer (car reply))
1101 (gnus-summary-mark-article-as-replied (cdr reply)))
1103 (set-window-configuration winconf))))
1105 (defun gnus-article-mail (yank)
1106 "Send a reply to the address near point.
1107 If YANK is non-nil, include the original article."
1111 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
1112 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
1114 (message-reply address)
1116 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
1118 (defvar nntp-server-type)
1120 "Send a bug report to the Gnus maintainers."
1122 (unless (gnus-alive-p)
1123 (error "Gnus has been shut down"))
1124 (gnus-setup-message (if (message-mail-user-agent) 'message 'bug)
1125 (unless (message-mail-user-agent)
1126 (message-pop-to-buffer "*Gnus Bug*")
1127 (delete-other-windows)
1128 (when gnus-bug-create-help-buffer
1129 (switch-to-buffer "*Gnus Help Bug*")
1131 (insert gnus-bug-message)
1132 (goto-char (point-min))
1134 (set-buffer "*Gnus Bug*")))
1135 (let ((message-this-is-mail t))
1136 (message-setup `((To . ,gnus-maintainer) (Subject . ""))))
1137 (when gnus-bug-create-help-buffer
1138 (push `(gnus-bug-kill-buffer) message-send-actions))
1139 (goto-char (point-min))
1140 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
1142 (insert gnus-product-name " " gnus-version-number
1143 " (r" gnus-revision-number ") "
1144 "based on " gnus-original-product-name " v"
1145 gnus-original-version-number "\n"
1146 (emacs-version) "\n")
1147 (when (and (boundp 'nntp-server-type)
1148 (stringp nntp-server-type))
1149 (insert nntp-server-type))
1150 (insert "\n\n\n\n\n")
1151 (let (mime-content-types)
1152 (mime-edit-insert-tag "text" "plain" "; type=emacs-lisp"))
1153 (insert (with-temp-buffer
1156 (let (mime-content-types)
1157 (mime-edit-insert-tag "text" "plain"))
1158 (goto-char (point-min))
1159 (search-forward "Subject: " nil t)
1162 (defun gnus-bug-kill-buffer ()
1163 (when (get-buffer "*Gnus Help Bug*")
1164 (kill-buffer "*Gnus Help Bug*")))
1166 (defun gnus-summary-yank-message (buffer n)
1167 "Yank the current article into a composed message."
1169 (list (completing-read "Buffer: " (mapcar 'list (message-buffers)) nil t)
1170 current-prefix-arg))
1171 (when (gnus-buffer-live-p buffer)
1172 (let ((summary-frame (selected-frame))
1173 (message-frame (when (static-if (featurep 'xemacs)
1174 (device-on-window-system-p)
1176 (let ((window (get-buffer-window buffer t)))
1178 (window-frame window)))))
1179 (separator (concat "^" (regexp-quote mail-header-separator)
1181 (gnus-summary-iterate n
1182 (gnus-summary-select-article)
1183 (gnus-copy-article-buffer)
1184 (when (frame-live-p message-frame)
1185 (raise-frame message-frame)
1186 (select-frame message-frame))
1187 (with-current-buffer buffer
1188 (when (save-excursion
1190 (let (case-fold-search)
1191 (and (not (re-search-backward separator nil t))
1192 (re-search-forward separator nil t))))
1193 (goto-char (match-end 0)))
1194 (message-yank-buffer gnus-article-copy))
1195 (select-frame summary-frame))
1196 (when (frame-live-p message-frame)
1197 (select-frame message-frame)))))
1199 (defun gnus-debug ()
1200 "Attempts to go through the Gnus source file and report what variables have been changed.
1201 The source file has to be in the Emacs load path."
1203 (let ((files '("gnus.el" "gnus-sum.el" "gnus-group.el"
1204 "gnus-art.el" "gnus-start.el" "gnus-async.el"
1205 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
1206 "nnmail.el" "nntp.el" "message.el"))
1208 file expr olist sym)
1209 (gnus-message 4 "Please wait while we snoop your variables...")
1210 ;; Go through all the files looking for non-default values for variables.
1213 (set-buffer (gnus-get-buffer-create " *gnus bug info*"))
1216 (when (and (setq file (locate-library (pop files)))
1217 (file-exists-p file))
1218 (insert-file-contents file)
1219 (goto-char (point-min))
1220 (if (not (re-search-forward "^;;* *Internal variables" nil t))
1221 (gnus-message 4 "Malformed sources in file %s" file)
1222 (narrow-to-region (point-min) (point))
1223 (goto-char (point-min))
1224 (while (setq expr (ignore-errors (read (current-buffer))))
1226 (and (memq (car expr) '(defvar defcustom defvoo))
1227 (stringp (nth 3 expr))
1228 (or (not (boundp (nth 1 expr)))
1229 (not (equal (eval (nth 2 expr))
1230 (symbol-value (nth 1 expr)))))
1231 (push (nth 1 expr) olist)))))))
1232 (kill-buffer (current-buffer)))
1233 (when (setq olist (nreverse olist))
1234 (insert ";----------------- Environment follows ------------------\n\n"))
1236 (if (boundp (car olist))
1238 (pp `(setq ,(car olist)
1239 ,(if (or (consp (setq sym (symbol-value (car olist))))
1241 (not (or (eq sym nil)
1243 (list 'quote (symbol-value (car olist)))
1244 (symbol-value (car olist))))
1247 (format "(setq %s 'whatever)\n" (car olist))))
1248 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
1249 (setq olist (cdr olist)))
1250 ;; Remove any control chars - they seem to cause trouble for some
1251 ;; mailers. (Byte-compiled output from the stuff above.)
1253 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
1254 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
1256 ;; Break MIME tags purposely.
1258 (while (re-search-forward mime-edit-tag-regexp nil t)
1259 (goto-char (1+ (match-beginning 0)))
1262 ;;; Treatment of rejected articles.
1265 (defun gnus-summary-resend-bounced-mail (&optional fetch)
1266 "Re-mail the current message.
1267 This only makes sense if the current message is a bounce message than
1268 contains some mail you have written which has been bounced back to
1270 If FETCH, try to fetch the article that this is a reply to, if indeed
1273 (gnus-summary-select-article t)
1274 (set-buffer gnus-original-article-buffer)
1275 (let ((gnus-message-setup-hook '(gnus-maybe-setup-default-charset)))
1276 (gnus-setup-message 'compose-bounce
1277 (let* ((references (mail-fetch-field "references"))
1278 (parent (and references (gnus-parent-id references))))
1280 ;; If there are references, we fetch the article we answered to.
1282 (gnus-summary-refer-article parent)
1283 (gnus-summary-show-all-headers))))))
1287 (defun gnus-inews-group-method (group)
1288 (cond ((and (null (gnus-get-info group))
1289 (eq (car gnus-message-archive-method)
1291 (gnus-server-to-method
1292 (gnus-group-method group)))))
1293 ;; If the group doesn't exist, we assume
1294 ;; it's an archive group...
1295 gnus-message-archive-method)
1297 ((gnus-info-method (gnus-get-info group))
1298 (gnus-info-method (gnus-get-info group)))
1300 (t (gnus-group-method group))))
1302 ;; Do Gcc handling, which copied the message over to some group.
1303 (defun gnus-inews-do-gcc (&optional gcc)
1307 (message-narrow-to-headers)
1308 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
1309 (coding-system-for-write 'raw-text)
1310 (output-coding-system 'raw-text)
1311 groups group method group-art)
1313 (message-remove-header "gcc")
1315 (setq groups (message-unquote-tokens
1316 (message-tokenize-header gcc " ,")))
1317 ;; Copy the article over to some group(s).
1318 (while (setq group (pop groups))
1320 (setq method (gnus-inews-group-method group)))
1321 (unless (gnus-request-group group nil method)
1322 (gnus-request-create-group group method))
1324 (nnheader-set-temp-buffer " *acc*")
1325 (insert-buffer-substring message-encoding-buffer)
1326 (gnus-run-hooks 'gnus-before-do-gcc-hook)
1327 (goto-char (point-min))
1328 (when (re-search-forward
1329 (concat "^" (regexp-quote mail-header-separator) "$")
1331 (replace-match "" t t ))
1332 (unless (setq group-art
1333 (gnus-request-accept-article group method t t))
1334 (gnus-message 1 "Couldn't store article in group %s: %s"
1335 group (gnus-status-message method))
1337 (when (and group-art gnus-inews-mark-gcc-as-read)
1338 (gnus-group-mark-article-read group (cdr group-art)))
1339 (kill-buffer (current-buffer)))))))))
1341 (defun gnus-inews-insert-gcc ()
1342 "Insert Gcc headers based on `gnus-outgoing-message-group'."
1345 (message-narrow-to-headers)
1346 (let* ((group gnus-outgoing-message-group)
1348 ((gnus-functionp group)
1350 ((or (stringp group) (list group))
1354 (if (stringp gcc) gcc
1355 (mapconcat 'identity gcc " "))
1358 (defun gnus-inews-insert-archive-gcc (&optional group)
1359 "Insert the Gcc to say where the article is to be archived."
1360 (let* ((var gnus-message-archive-group)
1361 (group (or group gnus-newsgroup-name ""))
1363 (and gnus-newsgroup-name
1364 (not (equal gnus-newsgroup-name ""))
1365 (gnus-group-find-parameter
1366 gnus-newsgroup-name 'gcc-self)))
1370 ((null gnus-message-archive-method)
1374 ;; Just a single group.
1377 ;; We don't want this.
1379 ((and (listp var) (stringp (car var)))
1380 ;; A list of groups.
1382 ((gnus-functionp var)
1384 (funcall var group))
1386 ;; An alist of regexps/functions/forms.
1391 ((stringp (caar var))
1393 (when (string-match (caar var) group)
1395 ((gnus-functionp (car var))
1397 (funcall (car var) group))
1399 (eval (car var)))))))
1400 (setq var (cdr var)))
1403 (when (or groups gcc-self-val)
1404 (when (stringp groups)
1405 (setq groups (list groups)))
1408 (message-narrow-to-headers)
1409 (goto-char (point-max))
1412 ;; Use the `gcc-self' param value instead.
1415 (if (stringp gcc-self-val)
1418 (if (not (eq gcc-self-val 'none))
1423 ;; Use the list of groups.
1424 (while (setq name (pop groups))
1425 (insert (if (string-match ":" name)
1427 (gnus-group-prefixed-name
1428 name gnus-message-archive-method)))
1435 (defun gnus-configure-posting-styles ()
1436 "Configure posting styles according to `gnus-posting-styles'."
1437 (unless gnus-inhibit-posting-styles
1438 (let ((group (or gnus-newsgroup-name ""))
1439 (styles gnus-posting-styles)
1440 style match variable attribute value v results
1441 filep name address element)
1442 ;; If the group has a posting-style parameter, add it at the end with a
1443 ;; regexp matching everything, to be sure it takes precedence over all
1445 (when gnus-newsgroup-name
1446 (let ((tmp-style (gnus-group-find-parameter group 'posting-style t)))
1448 (setq styles (append styles (list (cons ".*" tmp-style)))))))
1449 ;; Go through all styles and look for matches.
1450 (dolist (style styles)
1451 (setq match (pop style))
1452 (goto-char (point-min))
1455 ;; Regexp string match on the group name.
1456 (string-match match group))
1458 (and (gnus-buffer-live-p gnus-article-copy)
1459 (with-current-buffer gnus-article-copy
1460 (let ((header (message-fetch-field (pop style))))
1462 (string-match (pop style) header))))))
1463 ((or (symbolp match)
1464 (gnus-functionp match))
1466 ((gnus-functionp match)
1467 ;; Function to be called.
1470 ;; Variable to be checked.
1471 (symbol-value match))))
1473 ;; This is a form to be evaled.
1475 ;; We have a match, so we set the variables.
1476 (dolist (attribute style)
1477 (setq element (pop attribute)
1482 ((eq (car attribute) ':file)
1485 ((eq (car attribute) :value)
1489 ;; We get the value.
1494 ((or (symbolp value)
1495 (gnus-functionp value))
1496 (cond ((gnus-functionp value)
1499 (symbol-value value))))
1502 ;; Translate obsolescent value.
1503 (when (eq element 'signature-file)
1504 (setq element 'signature
1506 ;; Get the contents of file elems.
1508 (setq v (with-temp-buffer
1509 (insert-file-contents v)
1511 (setq results (delq (assoc element results) results))
1512 (push (cons element v) results))))
1513 ;; Now we have all the styles, so we insert them.
1514 (setq name (assq 'name results)
1515 address (assq 'address results))
1516 (setq results (delq name (delq address results)))
1517 (make-local-variable 'message-setup-hook)
1518 (dolist (result results)
1519 (add-hook 'message-setup-hook
1521 ((eq 'eval (car result))
1523 ((eq 'body (car result))
1527 (insert ,(cdr result)))))
1528 ((eq 'signature (car result))
1529 (set (make-local-variable 'message-signature) nil)
1530 (set (make-local-variable 'message-signature-file) nil)
1531 (if (not (cdr result))
1535 (let ((message-signature ,(cdr result)))
1536 (when message-signature
1537 (message-insert-signature)))))))
1540 (if (symbolp (car result))
1541 (capitalize (symbol-name (car result)))
1545 (message-remove-header ,header)
1546 (let ((value ,(cdr result)))
1549 (insert ,header ": " value "\n"))))))))))
1550 (when (or name address)
1551 (add-hook 'message-setup-hook
1553 (set (make-local-variable 'user-mail-address)
1554 ,(or (cdr address) user-mail-address))
1555 (let ((user-full-name ,(or (cdr name) (user-full-name)))
1557 ,(or (cdr address) user-mail-address)))
1559 (message-remove-header "From")
1561 (insert "From: " (message-make-from) "\n")))))))))
1564 ;;; @ for MIME Edit mode
1567 (defun gnus-maybe-setup-default-charset ()
1569 (and (boundp 'gnus-summary-buffer)
1570 (buffer-live-p gnus-summary-buffer)
1572 (set-buffer gnus-summary-buffer)
1573 default-mime-charset))))
1576 (make-local-variable 'default-mime-charset)
1577 (setq default-mime-charset charset)
1581 ;;; @ for MIME view mode
1584 (defun gnus-following-method (buf)
1585 (gnus-setup-message 'reply-yank
1587 (if (message-news-p)
1589 (message-reply nil 'wide))
1590 (let ((message-reply-buffer buf))
1591 (message-yank-original))
1592 (message-goto-body))
1596 ;;; Allow redefinition of functions.
1602 ;;; gnus-msg.el ends here