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" :value message-this-is-mail)
133 (const :tag "News article" :value message-this-is-news))
134 (choice :tag "Header"
135 (const :tag "None" nil)
136 (symbol :tag "Charset"))
138 (const :tag "Any" :value t)
139 (const :tag "None" :value nil)
140 (repeat :tag "Charsets"
141 (symbol :tag "Charset")))))
142 :group 'gnus-charset)
144 ;;; Internal variables.
146 (defvar gnus-inhibit-posting-styles nil
147 "Inhibit the use of posting styles.")
149 (defvar gnus-message-buffer "*Mail Gnus*")
150 (defvar gnus-article-copy nil)
151 (defvar gnus-check-before-posting nil)
152 (defvar gnus-last-posting-server nil)
153 (defvar gnus-message-group-art nil)
155 (defconst gnus-bug-message
156 (format "Sending a bug report to the Gnus Towers.
157 ========================================
159 This gnus is the %s%s.
160 If you think the bug is a Semi-gnus bug, send a bug report to Semi-gnus
161 Developers. (the addresses below are mailing list addresses)
163 ========================================
165 The buffer below is a mail buffer. When you press `C-c C-c', it will
166 be sent to the Gnus Bug Exterminators.
168 The thing near the bottom of the buffer is how the environment
169 settings will be included in the mail. Please do not delete that.
170 They will tell the Bug People what your environment is, so that it
171 will be easier to locate the bugs.
173 If you have found a bug that makes Emacs go \"beep\", set
174 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
175 and include the backtrace in your bug report.
177 Please describe the bug in annoying, painstaking detail.
179 Thank you for your help in stamping out bugs.
182 (if (string= gnus-product-name "Semi-gnus")
184 ", a modified version of Semi-gnus")))
187 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
188 (autoload 'news-setup "rnewspost")
189 (autoload 'news-reply-mode "rnewspost")
190 (autoload 'rmail-dont-reply-to "mail-utils")
191 (autoload 'rmail-output "rmailout"))
195 ;;; Gnus Posting Functions
198 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
199 "p" gnus-summary-post-news
200 "f" gnus-summary-followup
201 "F" gnus-summary-followup-with-original
202 "c" gnus-summary-cancel-article
203 "s" gnus-summary-supersede-article
204 "r" gnus-summary-reply
205 "y" gnus-summary-yank-message
206 "R" gnus-summary-reply-with-original
207 "w" gnus-summary-wide-reply
208 "W" gnus-summary-wide-reply-with-original
209 "v" gnus-summary-very-wide-reply
210 "V" gnus-summary-very-wide-reply-with-original
211 "n" gnus-summary-followup-to-mail
212 "N" gnus-summary-followup-to-mail-with-original
213 "m" gnus-summary-mail-other-window
214 "u" gnus-uu-post-news
215 "\M-c" gnus-summary-mail-crosspost-complaint
216 "om" gnus-summary-mail-forward
217 "op" gnus-summary-post-forward
218 "Om" gnus-summary-digest-mail-forward
219 "Op" gnus-summary-digest-post-forward)
221 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
222 "b" gnus-summary-resend-bounced-mail
223 ;; "c" gnus-summary-send-draft
224 "r" gnus-summary-resend-message)
226 ;;; Internal functions.
228 (defvar gnus-article-reply nil)
229 (defmacro gnus-setup-message (config &rest forms)
230 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
231 (buffer (make-symbol "gnus-setup-message-buffer"))
232 (article (make-symbol "gnus-setup-message-article"))
233 (group (make-symbol "gnus-setup-message-group")))
234 `(let ((,winconf (current-window-configuration))
235 (,buffer (buffer-name (current-buffer)))
236 (,article gnus-article-reply)
237 (,group gnus-newsgroup-name)
238 (message-header-setup-hook
239 (copy-sequence message-header-setup-hook))
240 (message-mode-hook (copy-sequence message-mode-hook))
241 (message-startup-parameter-alist
242 '((reply-buffer . gnus-copy-article-buffer)
243 (original-buffer . gnus-original-article-buffer)
244 (user-agent . Gnus))))
245 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
246 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
247 (add-hook 'message-mode-hook 'gnus-configure-posting-styles)
251 (gnus-inews-add-send-actions ,winconf ,buffer ,article ,config)
252 (gnus-inews-insert-draft-meta-information ,group ,article)
253 (setq gnus-message-buffer (current-buffer))
254 (set (make-local-variable 'gnus-message-group-art)
255 (cons ,group ,article))
256 (set (make-local-variable 'gnus-newsgroup-name) ,group)
257 (gnus-run-hooks 'gnus-message-setup-hook))
259 (gnus-configure-windows ,config t)
260 (set-buffer-modified-p nil))))
262 (defun gnus-inews-insert-draft-meta-information (group article)
265 (not (string= group ""))
266 (not (message-fetch-field gnus-draft-meta-information-header)))
267 (goto-char (point-min))
268 (insert gnus-draft-meta-information-header ": (\"" group "\" "
269 (if article (number-to-string
276 (defun gnus-msg-mail (&optional to subject other-headers continue
277 switch-action yank-action send-actions)
278 "Start editing a mail message to be sent.
279 Like `message-mail', but with Gnus paraphernalia, particularly the
280 Gcc: header for archiving purposes."
282 (let ((buf (current-buffer))
284 (gnus-setup-message 'message
285 (message-mail to subject other-headers continue
286 nil yank-action send-actions))
288 (setq mail-buf (current-buffer))
289 (switch-to-buffer buf)
290 (apply switch-action mail-buf nil)))
291 ;; COMPOSEFUNC should return t if succeed. Undocumented ???
295 (defun gnus-button-mailto (address)
297 (set-buffer (gnus-copy-article-buffer))
298 (gnus-setup-message 'message
299 (message-reply address)))
302 (defun gnus-button-reply (&optional to-address wide)
303 "Like `message-reply'."
305 (gnus-setup-message 'message
306 (message-reply to-address wide)))
309 (define-mail-user-agent 'gnus-user-agent
310 'gnus-msg-mail 'message-send-and-exit
311 'message-kill-buffer 'message-send-hook)
313 (defun gnus-setup-posting-charset (group)
314 (let ((alist gnus-group-posting-charset-alist)
315 (group (or group ""))
319 (while (setq elem (pop alist))
320 (when (or (and (stringp (car elem))
321 (string-match (car elem) group))
322 (and (gnus-functionp (car elem))
323 (funcall (car elem) group))
324 (and (symbolp (car elem))
325 (symbol-value (car elem))))
326 (throw 'found (cons (cadr elem) (caddr elem)))))))))
328 (defun gnus-inews-add-send-actions (winconf buffer article &optional config)
329 (make-local-hook 'message-sent-hook)
330 (add-hook 'message-sent-hook (if gnus-agent 'gnus-agent-possibly-do-gcc
331 'gnus-inews-do-gcc) nil t)
333 (make-local-hook 'message-header-hook)
334 (add-hook 'message-header-hook 'gnus-agent-possibly-save-gcc nil t))
335 (setq message-post-method
337 (gnus-post-method arg ,gnus-newsgroup-name)))
338 (setq message-user-agent (gnus-extended-version))
339 (when (not message-use-multi-frames)
341 `(set-window-configuration ,winconf) 'exit 'postpone 'kill))
343 `(when (gnus-buffer-exists-p ,buffer)
347 (if (eq config 'forward)
348 `(gnus-summary-mark-article-as-forwarded ',article)
349 `(gnus-summary-mark-article-as-replied ',article)))))
352 (put 'gnus-setup-message 'lisp-indent-function 1)
353 (put 'gnus-setup-message 'edebug-form-spec '(form body))
355 ;;; Post news commands of Gnus group mode and summary mode
357 (defun gnus-group-mail (&optional arg)
358 "Start composing a mail.
359 If ARG, use the group under the point to find a posting style.
360 If ARG is 1, prompt for a group name to find the posting style."
362 ;; We can't `let' gnus-newsgroup-name here, since that leads
363 ;; to local variables leaking.
364 (let ((group gnus-newsgroup-name)
365 (buffer (current-buffer)))
368 (setq gnus-newsgroup-name
370 (if (= 1 (prefix-numeric-value arg))
371 (completing-read "Use posting style of group: "
372 gnus-active-hashtb nil
373 (gnus-read-active-file-p))
374 (gnus-group-group-name))
376 (gnus-setup-message 'message (message-mail)))
379 (setq gnus-newsgroup-name group)))))
381 (defun gnus-group-post-news (&optional arg)
382 "Start composing a news message.
383 If ARG, post to the group under point.
384 If ARG is 1, prompt for a group name."
386 ;; Bind this variable here to make message mode hooks work ok.
387 (let ((gnus-newsgroup-name
389 (if (= 1 (prefix-numeric-value arg))
390 (completing-read "Newsgroup: " gnus-active-hashtb nil
391 (gnus-read-active-file-p))
392 (gnus-group-group-name))
394 (gnus-post-news 'post gnus-newsgroup-name)))
396 (defun gnus-summary-post-news ()
397 "Start composing a news message."
399 (gnus-post-news 'post gnus-newsgroup-name))
401 (defun gnus-summary-followup (yank &optional force-news)
402 "Compose a followup to an article.
403 If prefix argument YANK is non-nil, original article is yanked automatically."
405 (list (and current-prefix-arg
406 (gnus-summary-work-articles 1))))
408 (gnus-summary-goto-subject (car yank)))
409 (save-window-excursion
410 (gnus-summary-select-article))
411 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
412 (gnus-newsgroup-name gnus-newsgroup-name))
414 (gnus-post-news nil gnus-newsgroup-name
415 headers gnus-article-buffer
416 yank nil force-news)))
418 (defun gnus-summary-followup-with-original (n &optional force-news)
419 "Compose a followup to an article and include the original article."
421 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
423 (defun gnus-summary-followup-to-mail (&optional arg)
424 "Followup to the current mail message via news."
426 (list (and current-prefix-arg
427 (gnus-summary-work-articles 1))))
428 (gnus-summary-followup arg t))
430 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
431 "Followup to the current mail message via news."
433 (gnus-summary-followup (gnus-summary-work-articles arg) t))
435 (defun gnus-inews-yank-articles (articles)
436 (let ((more-than-one (cdr articles))
437 (cur (current-buffer))
438 refs beg article window)
440 (while (setq article (pop articles))
441 (save-window-excursion
442 (set-buffer gnus-summary-buffer)
443 (gnus-summary-select-article nil nil nil article)
444 (gnus-summary-remove-process-mark article))
446 ;; Gathering references.
448 (setq refs (message-list-references
450 (mail-header-references gnus-current-headers)
451 (mail-header-message-id gnus-current-headers)))
452 (when message-use-multi-frames
453 (when (setq window (get-buffer-window cur t))
454 (select-frame (window-frame window)))))
456 (gnus-copy-article-buffer)
457 (let ((message-reply-buffer gnus-article-copy)
458 (message-reply-headers
459 (with-current-buffer gnus-article-copy
460 ;; The headers are decoded.
461 (nnheader-parse-head t))))
462 (message-yank-original)
463 (setq beg (or beg (mark t))))
468 ;; Replace with the gathered references.
472 (message-narrow-to-headers)
473 (let ((case-fold-search t))
474 (if (re-search-forward "^References:\\([\t ]+.+\n\\)+" nil t)
476 (goto-char (point-max))))
478 (list (or (assq 'References message-header-format-alist)
479 '(References . message-shorten-references)))
480 (list (cons 'References
481 (mapconcat 'identity (nreverse refs) " "))))
482 (backward-delete-char 1))
488 (defun gnus-summary-cancel-article (&optional n symp)
489 "Cancel an article you posted.
490 Uses the process-prefix convention. If given the symbolic
491 prefix `a', cancel using the standard posting method; if not
492 post using the current select method."
493 (interactive (gnus-interactive "P\ny"))
494 (let ((articles (gnus-summary-work-articles n))
497 (gnus-post-method (not (eq symp 'a)) ,gnus-newsgroup-name)))
499 (while (setq article (pop articles))
500 (when (gnus-summary-select-article t nil nil article)
501 (when (gnus-eval-in-buffer-window gnus-article-buffer
503 (set-buffer gnus-original-article-buffer)
504 (message-cancel-news)))
505 (gnus-summary-mark-as-read article gnus-canceled-mark)
506 (gnus-cache-remove-article 1))
507 (gnus-article-hide-headers-if-wanted))
508 (gnus-summary-remove-process-mark article))))
510 (defun gnus-summary-supersede-article ()
511 "Compose an article that will supersede a previous article.
512 This is done simply by taking the old article and adding a Supersedes
513 header line with the old Message-ID."
515 (let ((article (gnus-summary-article-number))
516 (gnus-message-setup-hook '(gnus-maybe-setup-default-charset)))
517 (gnus-setup-message 'reply-yank
518 (gnus-summary-select-article t)
519 (set-buffer gnus-original-article-buffer)
523 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
525 (set-buffer ,gnus-summary-buffer)
526 (gnus-cache-possibly-remove-article ,article nil nil nil t)
527 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
528 message-send-actions))))
532 (defun gnus-copy-article-buffer (&optional article-buffer)
533 ;; make a copy of the article buffer with all text properties removed
534 ;; this copy is in the buffer gnus-article-copy.
535 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
536 ;; this buffer should be passed to all mail/news reply/post routines.
537 (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
538 (let ((article-buffer (or article-buffer gnus-article-buffer))
540 (if (not (and (get-buffer article-buffer)
541 (gnus-buffer-exists-p article-buffer)))
542 (error "Can't find any article buffer")
544 (set-buffer article-buffer)
545 (let ((gnus-newsgroup-charset (or gnus-article-charset
546 gnus-newsgroup-charset))
547 (gnus-newsgroup-ignored-charsets
548 (or gnus-article-ignored-charsets
549 gnus-newsgroup-ignored-charsets)))
551 ;; Copy over the (displayed) article buffer, delete
552 ;; hidden text and remove text properties.
554 (let ((inhibit-read-only t))
555 (copy-to-buffer gnus-article-copy (point-min) (point-max))
556 (set-buffer gnus-article-copy)
557 ;; Encode bitmap smileys to ordinary text.
558 ;; Possibly, the original text might be restored.
559 (static-unless (featurep 'xemacs)
560 (when (featurep 'smiley-mule)
561 (smiley-encode-buffer)))
562 (gnus-article-delete-text-of-type 'annotation)
563 (gnus-remove-text-with-property 'gnus-prev)
564 (gnus-remove-text-with-property 'gnus-next)
565 (gnus-remove-text-with-property 'x-face-mule-bitmap-image)
568 (static-if (featurep 'xemacs)
569 ;; Revome smiley extents for (possibly) XEmacs 21.1.
571 (buffer-substring-no-properties (point-min)
573 (buffer-substring-no-properties (point-min) (point-max)))
575 ;; Find the original headers.
576 (set-buffer gnus-original-article-buffer)
577 (goto-char (point-min))
578 (while (looking-at message-unix-mail-delimiter)
581 (setq end (or (search-forward "\n\n" nil t) (point)))
582 ;; Delete the headers from the displayed articles.
583 (set-buffer gnus-article-copy)
584 (delete-region (goto-char (point-min))
585 (or (search-forward "\n\n" nil t) (point-max)))
586 ;; Insert the original article headers.
587 (insert-buffer-substring gnus-original-article-buffer beg end)
588 (article-decode-encoded-words))))
591 (defun gnus-post-news (post &optional group header article-buffer yank subject
594 (gnus-copy-article-buffer))
595 (let ((gnus-article-reply (and article-buffer (gnus-summary-article-number)))
596 (add-to-list gnus-add-to-list))
597 (gnus-setup-message (cond (yank 'reply-yank)
598 (article-buffer 'reply)
600 (let* ((group (or group gnus-newsgroup-name))
601 (charset (gnus-group-name-charset nil group))
603 to-address to-group mailing-list to-list
606 (setq to-address (gnus-parameter-to-address group)
607 to-group (gnus-group-find-parameter group 'to-group)
608 to-list (gnus-parameter-to-list group)
609 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
610 mailing-list (when gnus-mailing-list-groups
611 (string-match gnus-mailing-list-groups group))
612 group (gnus-group-name-decode (gnus-group-real-name group)
614 (if (or (and to-group
615 (gnus-news-group-p to-group))
618 (and (gnus-news-group-p
619 (or pgroup gnus-newsgroup-name)
620 (if header (mail-header-number header)
621 gnus-current-article))
627 (message-news (or to-group group))
628 (set-buffer gnus-article-copy)
629 (gnus-msg-treat-broken-reply-to)
630 (message-followup (if (or newsgroup-p force-news)
631 (if (save-restriction
632 (article-narrow-to-head)
633 (message-fetch-field "newsgroups"))
640 (message-mail (or to-address to-list))
641 ;; Arrange for mail groups that have no `to-address' to
642 ;; get that when the user sends off the mail.
643 (when (and (not to-list)
646 (push (list 'gnus-inews-add-to-address pgroup)
647 message-send-actions)))
648 (set-buffer gnus-article-copy)
649 (gnus-msg-treat-broken-reply-to)
650 (message-wide-reply to-address)))
652 (gnus-inews-yank-articles yank))))))
654 (defun gnus-msg-treat-broken-reply-to ()
655 "Remove the Reply-to header iff broken-reply-to."
656 (when (gnus-group-find-parameter
657 gnus-newsgroup-name 'broken-reply-to)
659 (message-narrow-to-head)
660 (message-remove-header "reply-to"))))
662 (defun gnus-post-method (arg group &optional silent)
663 "Return the posting method based on GROUP and ARG.
664 If SILENT, don't prompt the user."
665 (let ((group-method (gnus-find-method-for-group group)))
667 ;; If the group-method is nil (which shouldn't happen) we use
668 ;; the default method.
670 (or (and (null (eq gnus-post-method 'active)) gnus-post-method)
671 gnus-select-method message-post-method))
672 ;; We want the inverse of the default
673 ((and arg (not (eq arg 0)))
674 (if (eq gnus-post-method 'active)
677 ;; We query the user for a post method.
679 (and gnus-post-method
680 (not (eq gnus-post-method 'current))
681 (listp (car gnus-post-method))))
683 ;; Collect all methods we know about.
685 (when (and gnus-post-method
686 (not (eq gnus-post-method 'current)))
687 (if (listp (car gnus-post-method))
689 (list gnus-post-method)))
690 gnus-secondary-select-methods
691 (mapcar 'cdr gnus-server-alist)
692 (mapcar 'car gnus-opened-servers)
693 (list gnus-select-method)
694 (list group-method)))
695 method-alist post-methods method)
696 ;; Weed out all mail methods.
698 (setq method (gnus-server-get-method "" (pop methods)))
699 (when (and (or (gnus-method-option-p method 'post)
700 (gnus-method-option-p method 'post-mail))
701 (not (member method post-methods)))
702 (push method post-methods)))
703 ;; Create a name-method alist.
707 (if (equal (cadr m) "")
708 (list (symbol-name (car m)) m)
709 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m)))
714 (setq gnus-last-posting-server
716 gnus-last-posting-server)
717 ;; Just use the last value.
718 gnus-last-posting-server
720 "Posting method: " method-alist nil t
721 (cons (or gnus-last-posting-server "") 0))))
723 ;; Override normal method.
724 ((and (eq gnus-post-method 'current)
725 (not (eq (car group-method) 'nndraft))
726 (gnus-get-function group-method 'request-post t)
729 ((and gnus-post-method
730 (not (eq gnus-post-method 'current)))
732 ;; Use the normal select method.
733 (t gnus-select-method))))
736 (defun gnus-message-make-user-agent (&optional include-mime-info max-column
738 "Return a user-agent info. If INCLUDE-MIME-INFO is non-nil and the
739 variable `mime-edit-user-agent-value' is bound, the value will be
740 included in the return value. If MAX-COLUMN is specified, the return
741 value will be folded up as it were filled. NEWLINE-PRODUCT specifies
742 whether a newline should be inserted in front of each product-token.
743 If the value is t or `hard', it works strictly. Otherwise, if it is
744 non-nil (e.g. `soft'), it works semi-strictly.
746 Here is an example of how to use this function:
748 \(add-hook 'gnus-message-setup-hook
750 (setq message-user-agent nil)
753 (message-narrow-to-headers)
754 (goto-char (point-max))
755 (insert \"User-Agent: \"
756 (gnus-message-make-user-agent t 76 'soft)
759 (let ((user-agent (if (and include-mime-info
760 (boundp 'mime-edit-user-agent-value))
761 (concat (gnus-extended-version)
763 mime-edit-user-agent-value)
764 (gnus-extended-version))))
766 (unless (natnump max-column)
767 (setq max-column 76))
769 (set-buffer-multibyte t)
770 (insert (mapconcat 'identity (split-string user-agent) " "))
771 (goto-char (point-min))
773 start agent agents width element swidth)
774 (while (re-search-forward "\\([^ ]+\\) ?" nil t)
775 (setq start (match-beginning 0))
776 (if (eq (char-after start) ?\()
780 (push (buffer-substring start (point)) agent))
782 (push (nreverse agent) agents))
783 (setq agent (list (match-string 1)))))
785 (push (nreverse agent) agents))
786 (setq agents (nreverse agents))
787 (if (> (+ 12 (string-width (caar agents))) max-column)
788 (setq user-agent "\n"
793 (setq agent (car agents)
796 (or (memq newline-product '(t hard))
799 (string-width (mapconcat 'identity
802 (setq user-agent (concat user-agent "\n")
806 (setq element (car agent)
807 swidth (string-width element)
810 (setq user-agent (if (member user-agent '("" "\n"))
811 (concat user-agent element)
812 (concat user-agent " " element))
813 width (+ width 1 swidth)
815 (if (> (+ width 1 swidth) max-column)
816 (setq user-agent (concat user-agent "\n " element)
818 (setq user-agent (concat user-agent " " element)
819 width (+ width 1 swidth)))))))))
824 ;;; Gnus Mail Functions
827 ;;; Mail reply commands of Gnus summary mode
829 (defun gnus-summary-reply (&optional yank wide very-wide)
830 "Start composing a mail reply to the current message.
831 If prefix argument YANK is non-nil, the original article is yanked
833 If WIDE, make a wide reply.
834 If VERY-WIDE, make a very wide reply."
836 (list (and current-prefix-arg
837 (gnus-summary-work-articles 1))))
838 ;; Stripping headers should be specified with mail-yank-ignored-headers.
840 (gnus-summary-goto-subject (car yank)))
841 (let ((gnus-article-reply (or yank (gnus-summary-article-number)))
843 (gnus-setup-message (if yank 'reply-yank 'reply)
845 (gnus-summary-select-article)
846 (dolist (article very-wide)
847 (gnus-summary-select-article nil nil nil article)
849 (set-buffer (gnus-copy-article-buffer))
850 (gnus-msg-treat-broken-reply-to)
852 (message-narrow-to-head)
853 (setq headers (concat headers (buffer-string)))))))
854 (set-buffer (gnus-copy-article-buffer))
855 (gnus-msg-treat-broken-reply-to)
857 (message-narrow-to-head)
861 (goto-char (point-max)))
862 (message-reply nil wide)
864 (gnus-inews-yank-articles yank)))))
866 (defun gnus-summary-reply-with-original (n &optional wide)
867 "Start composing a reply mail to the current message.
868 The original article will be yanked."
870 (gnus-summary-reply (gnus-summary-work-articles n) wide))
872 (defun gnus-summary-wide-reply (&optional yank)
873 "Start composing a wide reply mail to the current message.
874 If prefix argument YANK is non-nil, the original article is yanked
877 (list (and current-prefix-arg
878 (gnus-summary-work-articles 1))))
879 (gnus-summary-reply yank t))
881 (defun gnus-summary-wide-reply-with-original (n)
882 "Start composing a wide reply mail to the current message.
883 The original article will be yanked."
885 (gnus-summary-reply-with-original n t))
887 (defun gnus-summary-very-wide-reply (&optional yank)
888 "Start composing a very wide reply mail to the current message.
889 If prefix argument YANK is non-nil, the original article is yanked
892 (list (and current-prefix-arg
893 (gnus-summary-work-articles 1))))
894 (gnus-summary-reply yank t (gnus-summary-work-articles yank)))
896 (defun gnus-summary-very-wide-reply-with-original (n)
897 "Start composing a very wide reply mail to the current message.
898 The original article will be yanked."
901 (gnus-summary-work-articles n) t (gnus-summary-work-articles n)))
903 (defun gnus-summary-mail-forward (&optional full-headers post)
904 "Forward the current message to another user.
905 If FULL-HEADERS (the prefix), include full headers when forwarding."
907 (gnus-setup-message 'forward
908 (gnus-summary-select-article)
909 (let ((charset default-mime-charset))
910 (set-buffer gnus-original-article-buffer)
911 (make-local-variable 'default-mime-charset)
912 (setq default-mime-charset charset))
913 (let ((message-included-forward-headers
914 (if full-headers "" message-included-forward-headers)))
915 (message-forward post))))
917 (defun gnus-summary-digest-mail-forward (&optional n post)
918 "Digests and forwards all articles in this series.
919 If N is a positive number, forward the N next articles.
920 If N is a negative number, forward the N previous articles.
921 If N is nil and any articles have been marked with the process mark,
922 forward those articles instead.
923 Optional POST will use news to forward instead of mail."
925 (let ((articles (gnus-summary-work-articles n))
927 subject article frame)
929 (gnus-setup-message 'forward
930 (gnus-summary-select-article)
932 (setq articles (sort articles '<)
933 subject "Digested Articles")
934 (with-current-buffer gnus-original-article-buffer
935 (setq subject (message-make-forward-subject))))
937 (message-news nil subject)
938 (message-mail nil subject))
939 (when (and message-use-multi-frames (cdr articles))
940 (setq frame (window-frame (get-buffer-window (current-buffer)))))
942 (while (setq article (pop articles))
943 (save-window-excursion
944 (set-buffer gnus-summary-buffer)
945 (gnus-summary-select-article nil nil nil article)
946 (setq topics (concat topics " "
947 (mail-header-subject gnus-current-headers)
949 (gnus-summary-remove-process-mark article))
951 (select-frame frame))
952 (insert (mime-make-tag "message" "rfc822") "\n")
953 (narrow-to-region (point) (point))
954 (insert-buffer-substring gnus-original-article-buffer)
956 (article-narrow-to-head)
957 (message-remove-header message-included-forward-headers t nil t))
958 (goto-char (point-max))
964 (mime-edit-enclose-digest-region (point)(mark t))))))
966 (defun gnus-summary-digest-post-forward (&optional n)
967 "Digest and forwards all articles in this series to a newsgroup.
968 If N is a positive number, forward the N next articles.
969 If N is a negative number, forward the N previous articles.
970 If N is nil and any articles have been marked with the process mark,
971 forward those articles instead."
973 (gnus-summary-digest-mail-forward n t))
975 (defun gnus-summary-resend-message (address n)
976 "Resend the current article to ADDRESS."
978 (list (message-read-from-minibuffer "Resend message(s) to: ")
980 (let ((articles (gnus-summary-work-articles n))
982 (while (setq article (pop articles))
983 (gnus-summary-select-article nil nil nil article)
985 (set-buffer gnus-original-article-buffer)
986 (message-resend address))
987 (gnus-summary-mark-article-as-forwarded article))))
989 (defun gnus-summary-post-forward (&optional full-headers)
990 "Forward the current article to a newsgroup.
991 If FULL-HEADERS (the prefix), include full headers when forwarding."
993 (gnus-summary-mail-forward full-headers t))
995 (defvar gnus-nastygram-message
996 "The following article was inappropriately posted to %s.\n\n"
997 "Format string to insert in nastygrams.
998 The current group name will be inserted at \"%s\".")
1000 (defun gnus-summary-mail-nastygram (n)
1001 "Send a nastygram to the author of the current article."
1003 (when (or gnus-expert-user
1005 "Really send a nastygram to the author of the current article? "))
1006 (let ((group gnus-newsgroup-name))
1007 (gnus-summary-reply-with-original n)
1008 (set-buffer gnus-message-buffer)
1010 (insert (format gnus-nastygram-message group))
1011 (message-send-and-exit))))
1013 (defun gnus-summary-mail-crosspost-complaint (n)
1014 "Send a complaint about crossposting to the current article(s)."
1016 (let ((articles (gnus-summary-work-articles n))
1018 (while (setq article (pop articles))
1019 (set-buffer gnus-summary-buffer)
1020 (gnus-summary-goto-subject article)
1021 (let ((group (gnus-group-real-name gnus-newsgroup-name))
1022 newsgroups followup-to)
1023 (gnus-summary-select-article)
1024 (set-buffer gnus-original-article-buffer)
1025 (if (and (<= (length (message-tokenize-header
1027 (mail-fetch-field "newsgroups"))
1030 (or (not (setq followup-to (mail-fetch-field "followup-to")))
1031 (not (member group (message-tokenize-header
1032 followup-to ", ")))))
1034 (gnus-message 1 "Followup-to restricted")
1035 (gnus-message 1 "Not a crossposted article"))
1036 (set-buffer gnus-summary-buffer)
1037 (gnus-summary-reply-with-original 1)
1038 (set-buffer gnus-message-buffer)
1040 (insert (format gnus-crosspost-complaint newsgroups group))
1041 (message-goto-subject)
1042 (re-search-forward " *$")
1043 (replace-match " (crosspost notification)" t t)
1044 (gnus-deactivate-mark)
1045 (when (gnus-y-or-n-p "Send this complaint? ")
1046 (message-send-and-exit)))))))
1048 (defun gnus-summary-mail-other-window ()
1049 "Compose mail in other window."
1051 (gnus-setup-message 'message
1054 (defun gnus-mail-parse-comma-list ()
1057 (skip-chars-forward " ")
1060 (skip-chars-forward "^,")
1065 (narrow-to-region beg (point))
1068 (while (search-forward "\"" nil t)
1072 (skip-chars-forward ",")
1073 (skip-chars-forward "^,"))
1074 (skip-chars-backward " ")
1075 (push (buffer-substring beg (point))
1077 (skip-chars-forward "^,")
1078 (skip-chars-forward ", "))
1081 (defun gnus-inews-add-to-address (group)
1082 (let ((to-address (mail-fetch-field "to")))
1083 (when (and to-address
1085 ;; This mail group doesn't have a `to-list', so we add one
1087 (when (gnus-y-or-n-p
1088 (format "Do you want to add this as `to-list': %s " to-address))
1089 (gnus-group-add-parameter group (cons 'to-list to-address))))))
1091 (defun gnus-put-message ()
1092 "Put the current message in some group and return to Gnus."
1094 (let ((reply gnus-article-reply)
1095 (winconf gnus-prev-winconf)
1096 (group gnus-newsgroup-name))
1098 (not (gnus-group-read-only-p group)))
1099 (setq group (read-string "Put in group: " nil (gnus-writable-groups))))
1101 (when (gnus-gethash group gnus-newsrc-hashtb)
1102 (error "No such group: %s" group))
1106 (message-narrow-to-headers)
1107 (let ((gnus-deletable-headers nil))
1108 (message-generate-headers
1109 (if (message-news-p)
1110 message-required-news-headers
1111 message-required-mail-headers)))
1112 (goto-char (point-max))
1113 (insert "Gcc: " group "\n")
1116 (when (and (get-buffer gnus-group-buffer)
1117 (gnus-buffer-exists-p (car-safe reply))
1119 (set-buffer (car reply))
1120 (gnus-summary-mark-article-as-replied (cdr reply)))
1122 (set-window-configuration winconf))))
1124 (defun gnus-article-mail (yank)
1125 "Send a reply to the address near point.
1126 If YANK is non-nil, include the original article."
1130 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
1131 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
1133 (message-reply address)
1135 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
1137 (defvar nntp-server-type)
1139 "Send a bug report to the Gnus maintainers."
1141 (unless (gnus-alive-p)
1142 (error "Gnus has been shut down"))
1143 (gnus-setup-message (if (message-mail-user-agent) 'message 'bug)
1144 (unless (message-mail-user-agent)
1145 (message-pop-to-buffer "*Gnus Bug*")
1146 (delete-other-windows)
1147 (when gnus-bug-create-help-buffer
1148 (switch-to-buffer "*Gnus Help Bug*")
1150 (insert gnus-bug-message)
1151 (goto-char (point-min))
1153 (set-buffer "*Gnus Bug*")))
1154 (let ((message-this-is-mail t))
1155 (message-setup `((To . ,gnus-maintainer) (Subject . ""))))
1156 (when gnus-bug-create-help-buffer
1157 (push `(gnus-bug-kill-buffer) message-send-actions))
1158 (goto-char (point-min))
1159 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
1161 (insert gnus-product-name " " gnus-version-number
1162 " (r" gnus-revision-number ") "
1163 "based on " gnus-original-product-name " v"
1164 gnus-original-version-number "\n"
1165 (emacs-version) "\n")
1166 (when (and (boundp 'nntp-server-type)
1167 (stringp nntp-server-type))
1168 (insert nntp-server-type))
1169 (insert "\n\n\n\n\n")
1170 (let (mime-content-types)
1171 (mime-edit-insert-tag "text" "plain" "; type=emacs-lisp"))
1172 (insert (with-temp-buffer
1175 (let (mime-content-types)
1176 (mime-edit-insert-tag "text" "plain"))
1177 (goto-char (point-min))
1178 (search-forward "Subject: " nil t)
1181 (defun gnus-bug-kill-buffer ()
1182 (when (get-buffer "*Gnus Help Bug*")
1183 (kill-buffer "*Gnus Help Bug*")))
1185 (defun gnus-summary-yank-message (buffer n)
1186 "Yank the current article into a composed message."
1188 (list (completing-read "Buffer: " (mapcar 'list (message-buffers)) nil t)
1189 current-prefix-arg))
1190 (when (gnus-buffer-live-p buffer)
1191 (let ((summary-frame (selected-frame))
1192 (message-frame (when (static-if (featurep 'xemacs)
1193 (device-on-window-system-p)
1195 (let ((window (get-buffer-window buffer t)))
1197 (window-frame window)))))
1198 (separator (concat "^" (regexp-quote mail-header-separator)
1200 (gnus-summary-iterate n
1201 (gnus-summary-select-article)
1202 (gnus-copy-article-buffer)
1203 (when (frame-live-p message-frame)
1204 (raise-frame message-frame)
1205 (select-frame message-frame))
1206 (with-current-buffer buffer
1207 (when (save-excursion
1209 (let (case-fold-search)
1210 (and (not (re-search-backward separator nil t))
1211 (re-search-forward separator nil t))))
1212 (goto-char (match-end 0)))
1213 (message-yank-buffer gnus-article-copy))
1214 (select-frame summary-frame))
1215 (when (frame-live-p message-frame)
1216 (select-frame message-frame)))))
1218 (defun gnus-debug ()
1219 "Attempts to go through the Gnus source file and report what variables have been changed.
1220 The source file has to be in the Emacs load path."
1222 (let ((files '("gnus.el" "gnus-sum.el" "gnus-group.el"
1223 "gnus-art.el" "gnus-start.el" "gnus-async.el"
1224 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
1225 "nnmail.el" "nntp.el" "message.el"))
1227 file expr olist sym)
1228 (gnus-message 4 "Please wait while we snoop your variables...")
1229 ;; Go through all the files looking for non-default values for variables.
1232 (set-buffer (gnus-get-buffer-create " *gnus bug info*"))
1235 (when (and (setq file (locate-library (pop files)))
1236 (file-exists-p file))
1237 (insert-file-contents file)
1238 (goto-char (point-min))
1239 (if (not (re-search-forward "^;;* *Internal variables" nil t))
1240 (gnus-message 4 "Malformed sources in file %s" file)
1241 (narrow-to-region (point-min) (point))
1242 (goto-char (point-min))
1243 (while (setq expr (ignore-errors (read (current-buffer))))
1245 (and (memq (car expr) '(defvar defcustom defvoo))
1246 (stringp (nth 3 expr))
1247 (or (not (boundp (nth 1 expr)))
1248 (not (equal (eval (nth 2 expr))
1249 (symbol-value (nth 1 expr)))))
1250 (push (nth 1 expr) olist)))))))
1251 (kill-buffer (current-buffer)))
1252 (when (setq olist (nreverse olist))
1253 (insert ";----------------- Environment follows ------------------\n\n"))
1255 (if (boundp (car olist))
1257 (pp `(setq ,(car olist)
1258 ,(if (or (consp (setq sym (symbol-value (car olist))))
1260 (not (or (eq sym nil)
1262 (list 'quote (symbol-value (car olist)))
1263 (symbol-value (car olist))))
1266 (format "(setq %s 'whatever)\n" (car olist))))
1267 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
1268 (setq olist (cdr olist)))
1269 ;; Remove any control chars - they seem to cause trouble for some
1270 ;; mailers. (Byte-compiled output from the stuff above.)
1272 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
1273 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
1275 ;; Break MIME tags purposely.
1277 (while (re-search-forward mime-edit-tag-regexp nil t)
1278 (goto-char (1+ (match-beginning 0)))
1281 ;;; Treatment of rejected articles.
1284 (defun gnus-summary-resend-bounced-mail (&optional fetch)
1285 "Re-mail the current message.
1286 This only makes sense if the current message is a bounce message than
1287 contains some mail you have written which has been bounced back to
1289 If FETCH, try to fetch the article that this is a reply to, if indeed
1292 (gnus-summary-select-article t)
1293 (set-buffer gnus-original-article-buffer)
1294 (let ((gnus-message-setup-hook '(gnus-maybe-setup-default-charset)))
1295 (gnus-setup-message 'compose-bounce
1296 (let* ((references (mail-fetch-field "references"))
1297 (parent (and references (gnus-parent-id references))))
1299 ;; If there are references, we fetch the article we answered to.
1301 (gnus-summary-refer-article parent)
1302 (gnus-summary-show-all-headers))))))
1306 (defun gnus-inews-group-method (group)
1307 (cond ((and (null (gnus-get-info group))
1308 (eq (car gnus-message-archive-method)
1310 (gnus-server-to-method
1311 (gnus-group-method group)))))
1312 ;; If the group doesn't exist, we assume
1313 ;; it's an archive group...
1314 gnus-message-archive-method)
1316 ((gnus-info-method (gnus-get-info group))
1317 (gnus-info-method (gnus-get-info group)))
1319 (t (gnus-group-method group))))
1321 ;; Do Gcc handling, which copied the message over to some group.
1322 (defun gnus-inews-do-gcc (&optional gcc)
1324 (when (gnus-alive-p)
1327 (message-narrow-to-headers)
1328 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
1329 (coding-system-for-write 'raw-text)
1330 (output-coding-system 'raw-text)
1331 groups group method group-art)
1333 (message-remove-header "gcc")
1335 (setq groups (message-unquote-tokens
1336 (message-tokenize-header gcc " ,")))
1337 ;; Copy the article over to some group(s).
1338 (while (setq group (pop groups))
1340 (setq method (gnus-inews-group-method group)))
1341 (unless (gnus-request-group group nil method)
1342 (gnus-request-create-group group method))
1344 (nnheader-set-temp-buffer " *acc*")
1345 (insert-buffer-substring message-encoding-buffer)
1346 (gnus-run-hooks 'gnus-before-do-gcc-hook)
1347 (goto-char (point-min))
1348 (when (re-search-forward
1349 (concat "^" (regexp-quote mail-header-separator) "$")
1351 (replace-match "" t t ))
1352 (unless (setq group-art
1353 (gnus-request-accept-article group method t t))
1354 (gnus-message 1 "Couldn't store article in group %s: %s"
1355 group (gnus-status-message method))
1357 (when (and group-art gnus-inews-mark-gcc-as-read)
1358 (gnus-group-mark-article-read group (cdr group-art)))
1359 (kill-buffer (current-buffer))))))))))
1361 (defun gnus-inews-insert-gcc ()
1362 "Insert Gcc headers based on `gnus-outgoing-message-group'."
1365 (message-narrow-to-headers)
1366 (let* ((group gnus-outgoing-message-group)
1368 ((gnus-functionp group)
1370 ((or (stringp group) (list group))
1374 (if (stringp gcc) gcc
1375 (mapconcat 'identity gcc " "))
1378 (defun gnus-inews-insert-archive-gcc (&optional group)
1379 "Insert the Gcc to say where the article is to be archived."
1380 (let* ((var gnus-message-archive-group)
1381 (group (or group gnus-newsgroup-name ""))
1383 (and gnus-newsgroup-name
1384 (not (equal gnus-newsgroup-name ""))
1385 (gnus-group-find-parameter
1386 gnus-newsgroup-name 'gcc-self)))
1390 ((null gnus-message-archive-method)
1394 ;; Just a single group.
1397 ;; We don't want this.
1399 ((and (listp var) (stringp (car var)))
1400 ;; A list of groups.
1402 ((gnus-functionp var)
1404 (funcall var group))
1406 ;; An alist of regexps/functions/forms.
1411 ((stringp (caar var))
1413 (when (string-match (caar var) group)
1415 ((gnus-functionp (car var))
1417 (funcall (car var) group))
1419 (eval (car var)))))))
1420 (setq var (cdr var)))
1423 (when (or groups gcc-self-val)
1424 (when (stringp groups)
1425 (setq groups (list groups)))
1428 (message-narrow-to-headers)
1429 (goto-char (point-max))
1432 ;; Use the `gcc-self' param value instead.
1435 (if (stringp gcc-self-val)
1438 (if (not (eq gcc-self-val 'none))
1443 ;; Use the list of groups.
1444 (while (setq name (pop groups))
1445 (insert (if (string-match ":" name)
1447 (gnus-group-prefixed-name
1448 name gnus-message-archive-method)))
1455 (defun gnus-configure-posting-styles ()
1456 "Configure posting styles according to `gnus-posting-styles'."
1457 (unless gnus-inhibit-posting-styles
1458 (let ((group (or gnus-newsgroup-name ""))
1459 (styles gnus-posting-styles)
1460 style match variable attribute value v results
1461 filep name address element)
1462 ;; If the group has a posting-style parameter, add it at the end with a
1463 ;; regexp matching everything, to be sure it takes precedence over all
1465 (when gnus-newsgroup-name
1466 (let ((tmp-style (gnus-group-find-parameter group 'posting-style t)))
1468 (setq styles (append styles (list (cons ".*" tmp-style)))))))
1469 ;; Go through all styles and look for matches.
1470 (dolist (style styles)
1471 (setq match (pop style))
1472 (goto-char (point-min))
1475 ;; Regexp string match on the group name.
1476 (string-match match group))
1478 (and (gnus-buffer-live-p gnus-article-copy)
1479 (with-current-buffer gnus-article-copy
1480 (let ((header (message-fetch-field (pop style))))
1482 (string-match (pop style) header))))))
1483 ((or (symbolp match)
1484 (gnus-functionp match))
1486 ((gnus-functionp match)
1487 ;; Function to be called.
1490 ;; Variable to be checked.
1491 (symbol-value match))))
1493 ;; This is a form to be evaled.
1495 ;; We have a match, so we set the variables.
1496 (dolist (attribute style)
1497 (setq element (pop attribute)
1502 ((eq (car attribute) ':file)
1505 ((eq (car attribute) :value)
1509 ;; We get the value.
1514 ((or (symbolp value)
1515 (gnus-functionp value))
1516 (cond ((gnus-functionp value)
1519 (symbol-value value))))
1522 ;; Translate obsolescent value.
1523 (when (eq element 'signature-file)
1524 (setq element 'signature
1526 ;; Get the contents of file elems.
1528 (setq v (with-temp-buffer
1529 (insert-file-contents v)
1531 (setq results (delq (assoc element results) results))
1532 (push (cons element v) results))))
1533 ;; Now we have all the styles, so we insert them.
1534 (setq name (assq 'name results)
1535 address (assq 'address results))
1536 (setq results (delq name (delq address results)))
1537 (make-local-variable 'message-setup-hook)
1538 (dolist (result results)
1539 (add-hook 'message-setup-hook
1541 ((eq 'eval (car result))
1543 ((eq 'body (car result))
1547 (insert ,(cdr result)))))
1548 ((eq 'signature (car result))
1549 (set (make-local-variable 'message-signature) nil)
1550 (set (make-local-variable 'message-signature-file) nil)
1551 (if (not (cdr result))
1555 (let ((message-signature ,(cdr result)))
1556 (when message-signature
1557 (message-insert-signature)))))))
1560 (if (symbolp (car result))
1561 (capitalize (symbol-name (car result)))
1565 (message-remove-header ,header)
1566 (let ((value ,(cdr result)))
1569 (insert ,header ": " value "\n"))))))))))
1570 (when (or name address)
1571 (add-hook 'message-setup-hook
1573 (set (make-local-variable 'user-mail-address)
1574 ,(or (cdr address) user-mail-address))
1575 (let ((user-full-name ,(or (cdr name) (user-full-name)))
1577 ,(or (cdr address) user-mail-address)))
1579 (message-remove-header "From")
1581 (insert "From: " (message-make-from) "\n")))))))))
1584 ;;; @ for MIME Edit mode
1587 (defun gnus-maybe-setup-default-charset ()
1589 (and (boundp 'gnus-summary-buffer)
1590 (buffer-live-p gnus-summary-buffer)
1592 (set-buffer gnus-summary-buffer)
1593 default-mime-charset))))
1596 (make-local-variable 'default-mime-charset)
1597 (setq default-mime-charset charset)
1601 ;;; @ for MIME view mode
1604 (defun gnus-following-method (buf)
1605 (gnus-setup-message 'reply-yank
1607 (if (message-news-p)
1609 (message-reply nil 'wide))
1610 (let ((message-reply-buffer buf))
1611 (message-yank-original))
1612 (message-goto-body))
1616 ;;; Allow redefinition of functions.
1622 ;;; gnus-msg.el ends here