1 ;;; gnus-msg.el --- mail and post interface for Gnus
2 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 ;; Free Software Foundation, Inc.
5 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
6 ;; Lars Magne Ingebrigtsen <larsi@gnus.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
30 (eval-when-compile (require 'cl))
37 (defcustom gnus-post-method 'current
38 "*Preferred method for posting USENET news.
40 If this variable is `current' (which is the default), Gnus will use
41 the \"current\" select method when posting. If it is `native', Gnus
42 will use the native select method when posting.
44 This method will not be used in mail groups and the like, only in
47 If not `native' nor `current', the value must be a valid method as discussed
48 in the documentation of `gnus-select-method'. It can also be a list of
49 methods. If that is the case, the user will be queried for what select
50 method to use when posting."
51 :group 'gnus-group-foreign
52 :link '(custom-manual "(gnus)Posting Server")
53 :type `(choice (const native)
55 (sexp :tag "Methods" ,gnus-select-method)))
57 (defcustom gnus-outgoing-message-group nil
58 "*All outgoing messages will be put in this group.
59 If you want to store all your outgoing mail and articles in the group
60 \"nnml:archive\", you set this variable to that value. This variable
61 can also be a list of group names.
63 If you want to have greater control over what group to put each
64 message in, you can set this variable to a function that checks the
65 current newsgroup name and then returns a suitable group name (or list
68 :type '(choice (string :tag "Group")
71 (defcustom gnus-mailing-list-groups nil
72 "*Regexp matching groups that are really mailing lists.
73 This is useful when you're reading a mailing list that has been
74 gatewayed to a newsgroup, and you want to followup to an article in
79 (defcustom gnus-add-to-list nil
80 "*If non-nil, add a `to-list' parameter automatically."
84 (defcustom gnus-crosspost-complaint
87 You posted the article below with the following Newsgroups header:
91 The %s group, at least, was an inappropriate recipient
92 of this message. Please trim your Newsgroups header to exclude this
93 group before posting in the future.
98 "Format string to be inserted when complaining about crossposts.
99 The first %s will be replaced by the Newsgroups header;
100 the second with the current group name."
104 (defcustom gnus-message-setup-hook nil
105 "Hook run after setting up a message buffer."
109 (defcustom gnus-bug-create-help-buffer t
110 "*Should we create the *Gnus Help Bug* buffer?"
114 (defcustom gnus-posting-styles nil
115 "*Alist of styles to use when posting.
116 See Info node `(gnus)Posting Styles'."
118 :type '(repeat (cons (choice (regexp)
121 (string :tag "Header")
122 (regexp :tag "Regexp"))
126 (choice (const signature)
127 (const signature-file)
134 (string :tag "Header"))
140 (defcustom gnus-gcc-mark-as-read nil
141 "If non-nil, automatically mark Gcc articles as read."
146 (defvar gnus-inews-mark-gcc-as-read nil
147 "Obsolete variable. Use `gnus-gcc-mark-as-read' instead.")
149 (make-obsolete-variable 'gnus-inews-mark-gcc-as-read
150 'gnus-gcc-mark-as-read)
152 (defcustom gnus-gcc-externalize-attachments nil
153 "Should local-file attachments be included as external parts in Gcc copies?
154 If it is `all', attach files as external parts;
155 if a regexp and matches the Gcc group name, attach files as external parts;
156 If nil, attach files as normal parts."
159 :type '(choice (const nil :tag "None")
160 (const all :tag "Any")
161 (string :tag "Regexp")))
163 (defcustom gnus-group-posting-charset-alist
164 '(("^\\(no\\|fr\\)\\.[^,]*\\(,[ \t\n]*\\(no\\|fr\\)\\.[^,]*\\)*$" iso-8859-1 (iso-8859-1))
165 ("^\\(fido7\\|relcom\\)\\.[^,]*\\(,[ \t\n]*\\(fido7\\|relcom\\)\\.[^,]*\\)*$" koi8-r (koi8-r))
166 (message-this-is-mail nil nil)
167 (message-this-is-news nil t))
168 "Alist of regexps and permitted unencoded charsets for posting.
169 Each element of the alist has the form (TEST HEADER BODY-LIST), where
170 TEST is either a regular expression matching the newsgroup header or a
172 HEADER is the charset which may be left unencoded in the header (nil
173 means encode all charsets),
174 BODY-LIST is a list of charsets which may be encoded using 8bit
175 content-transfer encoding in the body, or one of the special values
176 nil (always encode using quoted-printable) or t (always use 8bit).
178 Note that any value other than nil for HEADER infringes some RFCs, so
179 use this option with care."
180 :type '(repeat (list :tag "Permitted unencoded charsets"
182 (regexp :tag "Group")
183 (const :tag "Mail message" :value message-this-is-mail)
184 (const :tag "News article" :value message-this-is-news))
185 (choice :tag "Header"
186 (const :tag "None" nil)
187 (symbol :tag "Charset"))
189 (const :tag "Any" :value t)
190 (const :tag "None" :value nil)
191 (repeat :tag "Charsets"
192 (symbol :tag "Charset")))))
193 :group 'gnus-charset)
195 (defcustom gnus-debug-files
196 '("gnus.el" "gnus-sum.el" "gnus-group.el"
197 "gnus-art.el" "gnus-start.el" "gnus-async.el"
198 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
199 "gnus-agent.el" "gnus-cache.el" "gnus-srvr.el"
200 "mm-util.el" "mm-decode.el" "nnmail.el" "message.el")
201 "Files whose variables will be reported in `gnus-bug'."
204 :type '(repeat (string :tag "File")))
206 (defcustom gnus-debug-exclude-variables
207 '(mm-mime-mule-charset-alist
208 nnmail-split-fancy message-minibuffer-local-map)
209 "Variables that should not be reported in `gnus-bug'."
212 :type '(repeat (symbol :tab "Variable")))
214 (defcustom gnus-discouraged-post-methods
215 '(nndraft nnml nnimap nnmaildir nnmh nnfolder nndir)
216 "A list of back ends that are not used in \"real\" newsgroups.
217 This variable is used only when `gnus-post-method' is `current'."
219 :group 'gnus-group-foreign
220 :type '(repeat (symbol :tab "Back end")))
222 ;;; Internal variables.
224 (defvar gnus-inhibit-posting-styles nil
225 "Inhibit the use of posting styles.")
227 (defvar gnus-message-buffer "*Mail Gnus*")
228 (defvar gnus-article-copy nil)
229 (defvar gnus-check-before-posting nil)
230 (defvar gnus-last-posting-server nil)
231 (defvar gnus-message-group-art nil)
233 (defvar gnus-msg-force-broken-reply-to nil)
235 (defconst gnus-bug-message
236 "Sending a bug report to the Gnus Towers.
237 ========================================
239 The buffer below is a mail buffer. When you press `C-c C-c', it will
240 be sent to the Gnus Bug Exterminators.
242 The thing near the bottom of the buffer is how the environment
243 settings will be included in the mail. Please do not delete that.
244 They will tell the Bug People what your environment is, so that it
245 will be easier to locate the bugs.
247 If you have found a bug that makes Emacs go \"beep\", set
248 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
249 and include the backtrace in your bug report.
251 Please describe the bug in annoying, painstaking detail.
253 Thank you for your help in stamping out bugs.
257 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
258 (autoload 'news-setup "rnewspost")
259 (autoload 'news-reply-mode "rnewspost")
260 (autoload 'rmail-dont-reply-to "mail-utils")
261 (autoload 'rmail-output "rmailout"))
265 ;;; Gnus Posting Functions
268 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
269 "p" gnus-summary-post-news
270 "i" gnus-summary-news-other-window
271 "f" gnus-summary-followup
272 "F" gnus-summary-followup-with-original
273 "c" gnus-summary-cancel-article
274 "s" gnus-summary-supersede-article
275 "r" gnus-summary-reply
276 "y" gnus-summary-yank-message
277 "R" gnus-summary-reply-with-original
278 "w" gnus-summary-wide-reply
279 "W" gnus-summary-wide-reply-with-original
280 "v" gnus-summary-very-wide-reply
281 "V" gnus-summary-very-wide-reply-with-original
282 "n" gnus-summary-followup-to-mail
283 "N" gnus-summary-followup-to-mail-with-original
284 "m" gnus-summary-mail-other-window
285 "u" gnus-uu-post-news
286 "\M-c" gnus-summary-mail-crosspost-complaint
287 "Br" gnus-summary-reply-broken-reply-to
288 "BR" gnus-summary-reply-broken-reply-to-with-original
289 "om" gnus-summary-mail-forward
290 "op" gnus-summary-post-forward
291 "Om" gnus-uu-digest-mail-forward
292 "Op" gnus-uu-digest-post-forward)
294 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
295 "b" gnus-summary-resend-bounced-mail
296 ;; "c" gnus-summary-send-draft
297 "r" gnus-summary-resend-message)
299 ;;; Internal functions.
301 (defvar gnus-article-reply nil)
302 (defmacro gnus-setup-message (config &rest forms)
303 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
304 (buffer (make-symbol "gnus-setup-message-buffer"))
305 (article (make-symbol "gnus-setup-message-article"))
306 (group (make-symbol "gnus-setup-message-group")))
307 `(let ((,winconf (current-window-configuration))
308 (,buffer (buffer-name (current-buffer)))
309 (,article gnus-article-reply)
310 (,group gnus-newsgroup-name)
311 (message-header-setup-hook
312 (copy-sequence message-header-setup-hook))
313 (mbl mml-buffer-list)
314 (message-mode-hook (copy-sequence message-mode-hook)))
315 (setq mml-buffer-list nil)
316 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
317 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
318 ;; #### FIXME: for a reason that I did not manage to identify yet,
319 ;; the variable `gnus-newsgroup-name' does not honor a dynamically
320 ;; scoped or setq'ed value from a caller like `C-u gnus-summary-mail'.
321 ;; After evaluation of @forms below, it gets the value we actually want
322 ;; to override, and the posting styles are used. For that reason, I've
323 ;; added an optional argument to `gnus-configure-posting-styles' to
324 ;; make sure that the correct value for the group name is used. -- drv
325 (add-hook 'message-mode-hook
327 (gnus-configure-posting-styles ,group)))
331 (gnus-inews-add-send-actions ,winconf ,buffer ,article ,config)
332 (gnus-inews-insert-draft-meta-information ,group ,article)
333 (setq gnus-message-buffer (current-buffer))
334 (set (make-local-variable 'gnus-message-group-art)
335 (cons ,group ,article))
336 (set (make-local-variable 'gnus-newsgroup-name) ,group)
337 (gnus-run-hooks 'gnus-message-setup-hook)
338 (if (eq major-mode 'message-mode)
339 (let ((mbl1 mml-buffer-list))
340 (setq mml-buffer-list mbl) ;; Global value
341 (set (make-local-variable 'mml-buffer-list) mbl1);; Local value
342 ;; LOCAL argument of add-hook differs between GNU Emacs
343 ;; and XEmacs. make-local-hook makes sure they are local.
344 (make-local-hook 'kill-buffer-hook)
345 (make-local-hook 'change-major-mode-hook)
346 (add-hook 'change-major-mode-hook 'mml-destroy-buffers nil t)
347 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))
348 (mml-destroy-buffers)
349 (setq mml-buffer-list mbl)))
351 (gnus-configure-windows ,config t)
352 (run-hooks 'post-command-hook)
353 (set-buffer-modified-p nil))))
355 (defun gnus-inews-insert-draft-meta-information (group article)
358 (not (string= group ""))
359 (not (message-fetch-field gnus-draft-meta-information-header)))
360 (goto-char (point-min))
361 (insert gnus-draft-meta-information-header ": (\"" group "\" "
362 (if article (number-to-string
369 (defun gnus-msg-mail (&optional to subject other-headers continue
370 switch-action yank-action send-actions)
371 "Start editing a mail message to be sent.
372 Like `message-mail', but with Gnus paraphernalia, particularly the
373 Gcc: header for archiving purposes."
375 (let ((buf (current-buffer))
377 (gnus-setup-message 'message
378 (message-mail to subject other-headers continue
379 nil yank-action send-actions))
381 (setq mail-buf (current-buffer))
382 (switch-to-buffer buf)
383 (apply switch-action mail-buf nil)))
384 ;; COMPOSEFUNC should return t if succeed. Undocumented ???
387 (defvar save-selected-window-window)
390 (defun gnus-button-mailto (address)
392 (set-buffer (gnus-copy-article-buffer))
393 (gnus-setup-message 'message
394 (message-reply address))
395 (and (boundp 'save-selected-window-window)
396 (not (window-live-p save-selected-window-window))
397 (setq save-selected-window-window (selected-window))))
400 (defun gnus-button-reply (&optional to-address wide)
401 "Like `message-reply'."
403 (gnus-setup-message 'message
404 (message-reply to-address wide))
405 (and (boundp 'save-selected-window-window)
406 (not (window-live-p save-selected-window-window))
407 (setq save-selected-window-window (selected-window))))
410 (define-mail-user-agent 'gnus-user-agent
411 'gnus-msg-mail 'message-send-and-exit
412 'message-kill-buffer 'message-send-hook)
414 (defun gnus-setup-posting-charset (group)
415 (let ((alist gnus-group-posting-charset-alist)
416 (group (or group ""))
420 (while (setq elem (pop alist))
421 (when (or (and (stringp (car elem))
422 (string-match (car elem) group))
423 (and (gnus-functionp (car elem))
424 (funcall (car elem) group))
425 (and (symbolp (car elem))
426 (symbol-value (car elem))))
427 (throw 'found (cons (cadr elem) (caddr elem)))))))))
429 (defun gnus-inews-add-send-actions (winconf buffer article &optional config)
430 (make-local-hook 'message-sent-hook)
431 (add-hook 'message-sent-hook (if gnus-agent 'gnus-agent-possibly-do-gcc
432 'gnus-inews-do-gcc) nil t)
434 (make-local-hook 'message-header-hook)
435 (add-hook 'message-header-hook 'gnus-agent-possibly-save-gcc nil t))
436 (setq message-post-method
438 (gnus-post-method arg ,gnus-newsgroup-name)))
439 (setq message-newsreader (setq message-mailer (gnus-extended-version)))
441 `(set-window-configuration ,winconf) 'exit 'postpone 'kill)
443 `(when (gnus-buffer-exists-p ,buffer)
447 (if (eq config 'forward)
448 `(gnus-summary-mark-article-as-forwarded ',article)
449 `(gnus-summary-mark-article-as-replied ',article)))))
452 (put 'gnus-setup-message 'lisp-indent-function 1)
453 (put 'gnus-setup-message 'edebug-form-spec '(form body))
455 ;;; Post news commands of Gnus group mode and summary mode
457 (defun gnus-group-mail (&optional arg)
458 "Start composing a mail.
459 If ARG, use the group under the point to find a posting style.
460 If ARG is 1, prompt for a group name to find the posting style."
462 ;; We can't `let' gnus-newsgroup-name here, since that leads
463 ;; to local variables leaking.
464 (let ((group gnus-newsgroup-name)
465 (buffer (current-buffer)))
468 (setq gnus-newsgroup-name
470 (if (= 1 (prefix-numeric-value arg))
471 (completing-read "Use posting style of group: "
472 gnus-active-hashtb nil
473 (gnus-read-active-file-p))
474 (gnus-group-group-name))
476 ;; #### see comment in gnus-setup-message -- drv
477 (gnus-setup-message 'message (message-mail)))
480 (setq gnus-newsgroup-name group)))))
482 (defun gnus-group-news (&optional arg)
483 "Start composing a news.
484 If ARG, post to group under point.
485 If ARG is 1, prompt for group name to post to.
487 This function prepares a news even when using mail groups. This is useful
488 for posting messages to mail groups without actually sending them over the
489 network. The corresponding backend must have a 'request-post method."
491 ;; We can't `let' gnus-newsgroup-name here, since that leads
492 ;; to local variables leaking.
493 (let ((group gnus-newsgroup-name)
494 (buffer (current-buffer)))
497 (setq gnus-newsgroup-name
499 (if (= 1 (prefix-numeric-value arg))
500 (completing-read "Use group: "
501 gnus-active-hashtb nil
502 (gnus-read-active-file-p))
503 (gnus-group-group-name))
505 ;; #### see comment in gnus-setup-message -- drv
506 (gnus-setup-message 'message
507 (message-news (gnus-group-real-name gnus-newsgroup-name))))
510 (setq gnus-newsgroup-name group)))))
512 (defun gnus-group-post-news (&optional arg)
513 "Start composing a message (a news by default).
514 If ARG, post to group under point. If ARG is 1, prompt for group name.
515 Depending on the selected group, the message might be either a mail or
518 ;; Bind this variable here to make message mode hooks work ok.
519 (let ((gnus-newsgroup-name
521 (if (= 1 (prefix-numeric-value arg))
522 (completing-read "Newsgroup: " gnus-active-hashtb nil
523 (gnus-read-active-file-p))
524 (gnus-group-group-name))
526 (gnus-post-news 'post gnus-newsgroup-name)))
528 (defun gnus-summary-mail-other-window (&optional arg)
529 "Start composing a mail in another window.
530 Use the posting of the current group by default.
531 If ARG, don't do that. If ARG is 1, prompt for group name to find the
534 ;; We can't `let' gnus-newsgroup-name here, since that leads
535 ;; to local variables leaking.
536 (let ((group gnus-newsgroup-name)
537 (buffer (current-buffer)))
540 (setq gnus-newsgroup-name
542 (if (= 1 (prefix-numeric-value arg))
543 (completing-read "Use group: "
544 gnus-active-hashtb nil
545 (gnus-read-active-file-p))
547 gnus-newsgroup-name))
548 ;; #### see comment in gnus-setup-message -- drv
549 (gnus-setup-message 'message (message-mail)))
552 (setq gnus-newsgroup-name group)))))
554 (defun gnus-summary-news-other-window (&optional arg)
555 "Start composing a news in another window.
556 Post to the current group by default.
557 If ARG, don't do that. If ARG is 1, prompt for group name to post to.
559 This function prepares a news even when using mail groups. This is useful
560 for posting messages to mail groups without actually sending them over the
561 network. The corresponding backend must have a 'request-post method."
563 ;; We can't `let' gnus-newsgroup-name here, since that leads
564 ;; to local variables leaking.
565 (let ((group gnus-newsgroup-name)
566 (buffer (current-buffer)))
569 (setq gnus-newsgroup-name
571 (if (= 1 (prefix-numeric-value arg))
572 (completing-read "Use group: "
573 gnus-active-hashtb nil
574 (gnus-read-active-file-p))
576 gnus-newsgroup-name))
577 ;; #### see comment in gnus-setup-message -- drv
578 (gnus-setup-message 'message
579 (message-news (gnus-group-real-name gnus-newsgroup-name))))
582 (setq gnus-newsgroup-name group)))))
584 (defun gnus-summary-post-news (&optional arg)
585 "Start composing a message. Post to the current group by default.
586 If ARG, don't do that. If ARG is 1, prompt for a group name to post to.
587 Depending on the selected group, the message might be either a mail or
590 ;; Bind this variable here to make message mode hooks work ok.
591 (let ((gnus-newsgroup-name
593 (if (= 1 (prefix-numeric-value arg))
594 (completing-read "Newsgroup: " gnus-active-hashtb nil
595 (gnus-read-active-file-p))
597 gnus-newsgroup-name)))
598 (gnus-post-news 'post gnus-newsgroup-name)))
601 (defun gnus-summary-followup (yank &optional force-news)
602 "Compose a followup to an article.
603 If prefix argument YANK is non-nil, the original article is yanked
605 YANK is a list of elements, where the car of each element is the
606 article number, and the two following numbers is the region to be
609 (list (and current-prefix-arg
610 (gnus-summary-work-articles 1))))
612 (gnus-summary-goto-subject
613 (if (listp (car yank))
616 (save-window-excursion
617 (gnus-summary-select-article))
618 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
619 (gnus-newsgroup-name gnus-newsgroup-name))
621 (gnus-post-news nil gnus-newsgroup-name
622 headers gnus-article-buffer
623 yank nil force-news)))
625 (defun gnus-summary-followup-with-original (n &optional force-news)
626 "Compose a followup to an article and include the original article."
628 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
630 (defun gnus-summary-followup-to-mail (&optional arg)
631 "Followup to the current mail message via news."
633 (list (and current-prefix-arg
634 (gnus-summary-work-articles 1))))
635 (gnus-summary-followup arg t))
637 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
638 "Followup to the current mail message via news."
640 (gnus-summary-followup (gnus-summary-work-articles arg) t))
642 (defun gnus-inews-yank-articles (articles)
643 (let (beg article yank-string)
645 (while (setq article (pop articles))
646 (when (listp article)
647 (setq yank-string (nth 1 article)
648 article (nth 0 article)))
649 (save-window-excursion
650 (set-buffer gnus-summary-buffer)
651 (gnus-summary-select-article nil nil nil article)
652 (gnus-summary-remove-process-mark article))
653 (gnus-copy-article-buffer nil yank-string)
654 (let ((message-reply-buffer gnus-article-copy)
655 (message-reply-headers
656 ;; The headers are decoded.
657 (with-current-buffer gnus-article-copy
658 (nnheader-parse-head t))))
659 (message-yank-original)
660 (setq beg (or beg (mark t))))
666 (defun gnus-summary-cancel-article (&optional n symp)
667 "Cancel an article you posted.
668 Uses the process-prefix convention. If given the symbolic
669 prefix `a', cancel using the standard posting method; if not
670 post using the current select method."
671 (interactive (gnus-interactive "P\ny"))
672 (let ((articles (gnus-summary-work-articles n))
675 (gnus-post-method (not (eq symp 'a)) ,gnus-newsgroup-name)))
677 (while (setq article (pop articles))
678 (when (gnus-summary-select-article t nil nil article)
679 (when (gnus-eval-in-buffer-window gnus-original-article-buffer
680 (message-cancel-news))
681 (gnus-summary-mark-as-read article gnus-canceled-mark)
682 (gnus-cache-remove-article 1))
683 (gnus-article-hide-headers-if-wanted))
684 (gnus-summary-remove-process-mark article))))
686 (defun gnus-summary-supersede-article ()
687 "Compose an article that will supersede a previous article.
688 This is done simply by taking the old article and adding a Supersedes
689 header line with the old Message-ID."
691 (let ((article (gnus-summary-article-number)))
692 (gnus-setup-message 'reply-yank
693 (gnus-summary-select-article t)
694 (set-buffer gnus-original-article-buffer)
698 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
700 (set-buffer ,gnus-summary-buffer)
701 (gnus-cache-possibly-remove-article ,article nil nil nil t)
702 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
703 message-send-actions))))
707 (defun gnus-copy-article-buffer (&optional article-buffer yank-string)
708 ;; make a copy of the article buffer with all text properties removed
709 ;; this copy is in the buffer gnus-article-copy.
710 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
711 ;; this buffer should be passed to all mail/news reply/post routines.
712 (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
714 (set-buffer gnus-article-copy)
715 (mm-enable-multibyte))
716 (let ((article-buffer (or article-buffer gnus-article-buffer))
718 (if (not (and (get-buffer article-buffer)
719 (gnus-buffer-exists-p article-buffer)))
720 (error "Can't find any article buffer")
722 (set-buffer article-buffer)
723 (let ((gnus-newsgroup-charset (or gnus-article-charset
724 gnus-newsgroup-charset))
725 (gnus-newsgroup-ignored-charsets
726 (or gnus-article-ignored-charsets
727 gnus-newsgroup-ignored-charsets)))
729 ;; Copy over the (displayed) article buffer, delete
730 ;; hidden text and remove text properties.
732 (copy-to-buffer gnus-article-copy (point-min) (point-max))
733 (set-buffer gnus-article-copy)
736 (delete-region (point) (point-max))
737 (insert yank-string))
738 (gnus-article-delete-text-of-type 'annotation)
739 (gnus-remove-text-with-property 'gnus-prev)
740 (gnus-remove-text-with-property 'gnus-next)
741 (gnus-remove-text-with-property 'gnus-decoration)
744 (buffer-substring-no-properties (point-min) (point-max))
746 ;; Find the original headers.
747 (set-buffer gnus-original-article-buffer)
748 (goto-char (point-min))
749 (while (looking-at message-unix-mail-delimiter)
752 end (or (message-goto-body) beg))
753 ;; Delete the headers from the displayed articles.
754 (set-buffer gnus-article-copy)
755 (delete-region (goto-char (point-min))
756 (or (message-goto-body) (point-max)))
757 ;; Insert the original article headers.
758 (insert-buffer-substring gnus-original-article-buffer beg end)
760 (let ((gnus-article-decode-hook
761 (delq 'article-decode-charset
762 (copy-sequence gnus-article-decode-hook))))
763 (run-hooks 'gnus-article-decode-hook)))))
766 (defun gnus-post-news (post &optional group header article-buffer yank subject
769 (gnus-copy-article-buffer))
770 (let ((gnus-article-reply (and article-buffer (gnus-summary-article-number)))
771 (add-to-list gnus-add-to-list))
772 (gnus-setup-message (cond (yank 'reply-yank)
773 (article-buffer 'reply)
775 (let* ((group (or group gnus-newsgroup-name))
776 (charset (gnus-group-name-charset nil group))
778 to-address to-group mailing-list to-list
781 (setq to-address (gnus-parameter-to-address group)
782 to-group (gnus-group-find-parameter group 'to-group)
783 to-list (gnus-parameter-to-list group)
784 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
785 mailing-list (when gnus-mailing-list-groups
786 (string-match gnus-mailing-list-groups group))
787 group (gnus-group-name-decode (gnus-group-real-name group)
789 (if (or (and to-group
790 (gnus-news-group-p to-group))
793 (and (gnus-news-group-p
794 (or pgroup gnus-newsgroup-name)
795 (or header gnus-current-article))
801 (message-news (or to-group group))
802 (set-buffer gnus-article-copy)
803 (gnus-msg-treat-broken-reply-to)
804 (message-followup (if (or newsgroup-p force-news)
805 (if (save-restriction
806 (article-narrow-to-head)
807 (message-fetch-field "newsgroups"))
814 (message-mail (or to-address to-list))
815 ;; Arrange for mail groups that have no `to-address' to
816 ;; get that when the user sends off the mail.
817 (when (and (not to-list)
820 (push (list 'gnus-inews-add-to-address pgroup)
821 message-send-actions)))
822 (set-buffer gnus-article-copy)
823 (gnus-msg-treat-broken-reply-to)
824 (message-wide-reply to-address)))
826 (gnus-inews-yank-articles yank))))))
828 (defun gnus-msg-treat-broken-reply-to (&optional force)
829 "Remove the Reply-to header iff broken-reply-to."
831 (gnus-group-find-parameter
832 gnus-newsgroup-name 'broken-reply-to))
834 (message-narrow-to-head)
835 (message-remove-header "reply-to"))))
837 (defun gnus-post-method (arg group &optional silent)
838 "Return the posting method based on GROUP and ARG.
839 If SILENT, don't prompt the user."
840 (let ((gnus-post-method (or (gnus-parameter-post-method group)
842 (group-method (gnus-find-method-for-group group)))
844 ;; If the group-method is nil (which shouldn't happen) we use
845 ;; the default method.
847 (or (and (listp gnus-post-method) ;If not current/native/nil
848 (not (listp (car gnus-post-method))) ; and not a list of methods
849 gnus-post-method) ;then use it.
851 message-post-method))
852 ;; We want the inverse of the default
853 ((and arg (not (eq arg 0)))
854 (if (eq gnus-post-method 'current)
857 ;; We query the user for a post method.
859 (and (listp gnus-post-method)
860 (listp (car gnus-post-method))))
862 ;; Collect all methods we know about.
864 (when (listp gnus-post-method)
865 (if (listp (car gnus-post-method))
867 (list gnus-post-method)))
868 gnus-secondary-select-methods
869 (mapcar 'cdr gnus-server-alist)
870 (mapcar 'car gnus-opened-servers)
871 (list gnus-select-method)
872 (list group-method)))
873 method-alist post-methods method)
874 ;; Weed out all mail methods.
876 (setq method (gnus-server-get-method "" (pop methods)))
877 (when (and (or (gnus-method-option-p method 'post)
878 (gnus-method-option-p method 'post-mail))
879 (not (member method post-methods)))
880 (push method post-methods)))
881 ;; Create a name-method alist.
885 (if (equal (cadr m) "")
886 (list (symbol-name (car m)) m)
887 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m)))
892 (setq gnus-last-posting-server
894 gnus-last-posting-server)
895 ;; Just use the last value.
896 gnus-last-posting-server
898 "Posting method: " method-alist nil t
899 (cons (or gnus-last-posting-server "") 0))))
901 ;; Override normal method.
902 ((and (eq gnus-post-method 'current)
903 (not (memq (car group-method) gnus-discouraged-post-methods))
904 (gnus-get-function group-method 'request-post t))
907 ;; Use gnus-post-method.
908 ((listp gnus-post-method) ;A method...
909 (assert (not (listp (car gnus-post-method)))) ;... not a list of methods.
911 ;; Use the normal select method (nil or native).
912 (t gnus-select-method))))
916 ;; Dummies to avoid byte-compile warning.
918 (defvar nnspool-rejected-article-hook)
919 (defvar xemacs-codename))
921 (defun gnus-extended-version ()
922 "Stringified Gnus version and Emacs version."
925 "Gnus/" (prin1-to-string (gnus-continuum-version gnus-version) t)
926 " (" gnus-version ")"
929 ((string-match "^\\(\\([.0-9]+\\)*\\)\\.[0-9]+$" emacs-version)
930 (concat "Emacs/" (match-string 1 emacs-version)
931 " (" system-configuration ")"))
932 ((string-match "\\([A-Z]*[Mm][Aa][Cc][Ss]\\)[^(]*\\(\\((beta.*)\\|'\\)\\)?"
934 (concat (match-string 1 emacs-version)
935 (format "/%d.%d" emacs-major-version emacs-minor-version)
936 (if (match-beginning 3)
937 (match-string 3 emacs-version)
939 (if (boundp 'xemacs-codename)
940 (concat " (" xemacs-codename ", " system-configuration ")")
946 ;;; Gnus Mail Functions
949 ;;; Mail reply commands of Gnus summary mode
951 (defun gnus-summary-reply (&optional yank wide very-wide)
952 "Start composing a mail reply to the current message.
953 If prefix argument YANK is non-nil, the original article is yanked
955 If WIDE, make a wide reply.
956 If VERY-WIDE, make a very wide reply."
958 (list (and current-prefix-arg
959 (gnus-summary-work-articles 1))))
961 (if (listp (car yank))
964 (gnus-article-reply (or article (gnus-summary-article-number)))
966 ;; Stripping headers should be specified with mail-yank-ignored-headers.
968 (gnus-summary-goto-subject article))
969 (gnus-setup-message (if yank 'reply-yank 'reply)
971 (gnus-summary-select-article)
972 (dolist (article very-wide)
973 (gnus-summary-select-article nil nil nil article)
975 (set-buffer (gnus-copy-article-buffer))
976 (gnus-msg-treat-broken-reply-to)
978 (message-narrow-to-head)
979 (setq headers (concat headers (buffer-string)))))))
980 (set-buffer (gnus-copy-article-buffer))
981 (gnus-msg-treat-broken-reply-to gnus-msg-force-broken-reply-to)
983 (message-narrow-to-head)
987 (goto-char (point-max)))
988 (mml-quote-region (point) (point-max))
989 (message-reply nil wide)
991 (gnus-inews-yank-articles yank)))))
993 (defun gnus-summary-reply-with-original (n &optional wide)
994 "Start composing a reply mail to the current message.
995 The original article will be yanked."
997 (gnus-summary-reply (gnus-summary-work-articles n) wide))
999 (defun gnus-summary-reply-broken-reply-to (&optional yank wide very-wide)
1000 "Like `gnus-summary-reply' except removing reply-to field.
1001 If prefix argument YANK is non-nil, the original article is yanked
1003 If WIDE, make a wide reply.
1004 If VERY-WIDE, make a very wide reply."
1006 (list (and current-prefix-arg
1007 (gnus-summary-work-articles 1))))
1008 (let ((gnus-msg-force-broken-reply-to t))
1009 (gnus-summary-reply yank wide very-wide)))
1011 (defun gnus-summary-reply-broken-reply-to-with-original (n &optional wide)
1012 "Like `gnus-summary-reply-with-original' except removing reply-to field.
1013 The original article will be yanked."
1015 (gnus-summary-reply-broken-reply-to (gnus-summary-work-articles n) wide))
1017 (defun gnus-summary-wide-reply (&optional yank)
1018 "Start composing a wide reply mail to the current message.
1019 If prefix argument YANK is non-nil, the original article is yanked
1022 (list (and current-prefix-arg
1023 (gnus-summary-work-articles 1))))
1024 (gnus-summary-reply yank t))
1026 (defun gnus-summary-wide-reply-with-original (n)
1027 "Start composing a wide reply mail to the current message.
1028 The original article will be yanked."
1030 (gnus-summary-reply-with-original n t))
1032 (defun gnus-summary-very-wide-reply (&optional yank)
1033 "Start composing a very wide reply mail to the current message.
1034 If prefix argument YANK is non-nil, the original article is yanked
1037 (list (and current-prefix-arg
1038 (gnus-summary-work-articles 1))))
1039 (gnus-summary-reply yank t (gnus-summary-work-articles yank)))
1041 (defun gnus-summary-very-wide-reply-with-original (n)
1042 "Start composing a very wide reply mail to the current message.
1043 The original article will be yanked."
1046 (gnus-summary-work-articles n) t (gnus-summary-work-articles n)))
1048 (defun gnus-summary-mail-forward (&optional arg post)
1049 "Forward the current message(s) to another user.
1050 If process marks exist, forward all marked messages;
1051 if ARG is nil, see `message-forward-as-mime' and `message-forward-show-mml';
1052 if ARG is 1, decode the message and forward directly inline;
1053 if ARG is 2, forward message as an rfc822 MIME section;
1054 if ARG is 3, decode message and forward as an rfc822 MIME section;
1055 if ARG is 4, forward message directly inline;
1056 otherwise, use flipped `message-forward-as-mime'.
1057 If POST, post instead of mail.
1058 For the `inline' alternatives, also see the variable
1059 `message-forward-ignored-headers'."
1061 (if (null (cdr (gnus-summary-work-articles nil)))
1062 (let ((message-forward-as-mime message-forward-as-mime)
1063 (message-forward-show-mml message-forward-show-mml))
1067 (setq message-forward-as-mime nil
1068 message-forward-show-mml t))
1070 (setq message-forward-as-mime t
1071 message-forward-show-mml nil))
1073 (setq message-forward-as-mime t
1074 message-forward-show-mml t))
1076 (setq message-forward-as-mime nil
1077 message-forward-show-mml nil))
1079 (setq message-forward-as-mime (not message-forward-as-mime))))
1080 (let ((gnus-article-reply (gnus-summary-article-number)))
1081 (gnus-setup-message 'forward
1082 (gnus-summary-select-article)
1083 (let ((mail-parse-charset
1084 (or (and (gnus-buffer-live-p gnus-article-buffer)
1085 (with-current-buffer gnus-article-buffer
1086 gnus-article-charset))
1087 gnus-newsgroup-charset))
1088 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
1089 (set-buffer gnus-original-article-buffer)
1090 (message-forward post)))))
1091 (gnus-uu-digest-mail-forward arg post)))
1093 (defun gnus-summary-resend-message (address n)
1094 "Resend the current article to ADDRESS."
1096 (list (message-read-from-minibuffer
1097 "Resend message(s) to: "
1098 (when (gnus-buffer-live-p gnus-original-article-buffer)
1099 ;; If some other article is currently selected, the
1100 ;; initial-contents is wrong. Whatever, it is just the
1101 ;; initial-contents.
1102 (with-current-buffer gnus-original-article-buffer
1103 (nnmail-fetch-field "to"))))
1104 current-prefix-arg))
1105 (let ((articles (gnus-summary-work-articles n))
1107 (while (setq article (pop articles))
1108 (gnus-summary-select-article nil nil nil article)
1110 (set-buffer gnus-original-article-buffer)
1111 (message-resend address))
1112 (gnus-summary-mark-article-as-forwarded article))))
1114 (defun gnus-summary-post-forward (&optional arg)
1115 "Forward the current article to a newsgroup.
1116 See `gnus-summary-mail-forward' for ARG."
1118 (gnus-summary-mail-forward arg t))
1120 (defvar gnus-nastygram-message
1121 "The following article was inappropriately posted to %s.\n\n"
1122 "Format string to insert in nastygrams.
1123 The current group name will be inserted at \"%s\".")
1125 (defun gnus-summary-mail-nastygram (n)
1126 "Send a nastygram to the author of the current article."
1128 (when (or gnus-expert-user
1130 "Really send a nastygram to the author of the current article? "))
1131 (let ((group gnus-newsgroup-name))
1132 (gnus-summary-reply-with-original n)
1133 (set-buffer gnus-message-buffer)
1135 (insert (format gnus-nastygram-message group))
1136 (message-send-and-exit))))
1138 (defun gnus-summary-mail-crosspost-complaint (n)
1139 "Send a complaint about crossposting to the current article(s)."
1141 (let ((articles (gnus-summary-work-articles n))
1143 (while (setq article (pop articles))
1144 (set-buffer gnus-summary-buffer)
1145 (gnus-summary-goto-subject article)
1146 (let ((group (gnus-group-real-name gnus-newsgroup-name))
1147 newsgroups followup-to)
1148 (gnus-summary-select-article)
1149 (set-buffer gnus-original-article-buffer)
1150 (if (and (<= (length (message-tokenize-header
1152 (mail-fetch-field "newsgroups"))
1155 (or (not (setq followup-to (mail-fetch-field "followup-to")))
1156 (not (member group (message-tokenize-header
1157 followup-to ", ")))))
1159 (gnus-message 1 "Followup-to restricted")
1160 (gnus-message 1 "Not a crossposted article"))
1161 (set-buffer gnus-summary-buffer)
1162 (gnus-summary-reply-with-original 1)
1163 (set-buffer gnus-message-buffer)
1165 (insert (format gnus-crosspost-complaint newsgroups group))
1166 (message-goto-subject)
1167 (re-search-forward " *$")
1168 (replace-match " (crosspost notification)" t t)
1169 (gnus-deactivate-mark)
1170 (when (gnus-y-or-n-p "Send this complaint? ")
1171 (message-send-and-exit)))))))
1173 (defun gnus-mail-parse-comma-list ()
1176 (skip-chars-forward " ")
1179 (skip-chars-forward "^,")
1184 (narrow-to-region beg (point))
1187 (while (search-forward "\"" nil t)
1191 (skip-chars-forward ",")
1192 (skip-chars-forward "^,"))
1193 (skip-chars-backward " ")
1194 (push (buffer-substring beg (point))
1196 (skip-chars-forward "^,")
1197 (skip-chars-forward ", "))
1200 (defun gnus-inews-add-to-address (group)
1201 (let ((to-address (mail-fetch-field "to")))
1202 (when (and to-address
1204 ;; This mail group doesn't have a `to-list', so we add one
1206 (when (gnus-y-or-n-p
1207 (format "Do you want to add this as `to-list': %s " to-address))
1208 (gnus-group-add-parameter group (cons 'to-list to-address))))))
1210 (defun gnus-put-message ()
1211 "Put the current message in some group and return to Gnus."
1213 (let ((reply gnus-article-reply)
1214 (winconf gnus-prev-winconf)
1215 (group gnus-newsgroup-name))
1217 (not (gnus-group-read-only-p group)))
1218 (setq group (read-string "Put in group: " nil (gnus-writable-groups))))
1220 (when (gnus-gethash group gnus-newsrc-hashtb)
1221 (error "No such group: %s" group))
1225 (message-narrow-to-headers)
1226 (let ((gnus-deletable-headers nil))
1227 (message-generate-headers
1228 (if (message-news-p)
1229 message-required-news-headers
1230 message-required-mail-headers)))
1231 (goto-char (point-max))
1232 (insert "Gcc: " group "\n")
1235 (when (and (get-buffer gnus-group-buffer)
1236 (gnus-buffer-exists-p (car-safe reply))
1238 (set-buffer (car reply))
1239 (gnus-summary-mark-article-as-replied (cdr reply)))
1241 (set-window-configuration winconf))))
1243 (defun gnus-article-mail (yank)
1244 "Send a reply to the address near point.
1245 If YANK is non-nil, include the original article."
1249 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
1250 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
1252 (message-reply address)
1254 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
1256 (defvar nntp-server-type)
1258 "Send a bug report to the Gnus maintainers."
1260 (unless (gnus-alive-p)
1261 (error "Gnus has been shut down"))
1262 (gnus-setup-message (if (message-mail-user-agent) 'message 'bug)
1263 (unless (message-mail-user-agent)
1264 (delete-other-windows)
1265 (when gnus-bug-create-help-buffer
1266 (switch-to-buffer "*Gnus Help Bug*")
1268 (insert gnus-bug-message)
1269 (goto-char (point-min)))
1270 (message-pop-to-buffer "*Gnus Bug*"))
1271 (let ((message-this-is-mail t))
1272 (message-setup `((To . ,gnus-maintainer) (Subject . ""))))
1273 (when gnus-bug-create-help-buffer
1274 (push `(gnus-bug-kill-buffer) message-send-actions))
1275 (goto-char (point-min))
1276 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
1278 (insert (gnus-version) "\n"
1279 (emacs-version) "\n")
1280 (when (and (boundp 'nntp-server-type)
1281 (stringp nntp-server-type))
1282 (insert nntp-server-type))
1283 (insert "\n\n\n\n\n")
1286 (set-buffer (gnus-get-buffer-create " *gnus environment info*"))
1289 (setq text (buffer-string)))
1290 (insert "<#part type=application/emacs-lisp disposition=inline description=\"User settings\">\n" text "\n<#/part>"))
1291 (goto-char (point-min))
1292 (search-forward "Subject: " nil t)
1295 (defun gnus-bug-kill-buffer ()
1296 (when (get-buffer "*Gnus Help Bug*")
1297 (kill-buffer "*Gnus Help Bug*")))
1299 (defun gnus-summary-yank-message (buffer n)
1300 "Yank the current article into a composed message."
1302 (list (completing-read "Buffer: " (mapcar 'list (message-buffers)) nil t)
1303 current-prefix-arg))
1304 (gnus-summary-iterate n
1305 (let ((gnus-display-mime-function nil)
1306 (gnus-inhibit-treatment t))
1307 (gnus-summary-select-article))
1310 (message-yank-buffer gnus-article-buffer))))
1312 (defun gnus-debug ()
1313 "Attempts to go through the Gnus source file and report what variables have been changed.
1314 The source file has to be in the Emacs load path."
1316 (let ((files gnus-debug-files)
1318 file expr olist sym)
1319 (gnus-message 4 "Please wait while we snoop your variables...")
1321 ;; Go through all the files looking for non-default values for variables.
1323 (set-buffer (gnus-get-buffer-create " *gnus bug info*"))
1326 (when (and (setq file (locate-library (pop files)))
1327 (file-exists-p file))
1328 (insert-file-contents file)
1329 (goto-char (point-min))
1330 (if (not (re-search-forward "^;;* *Internal variables" nil t))
1331 (gnus-message 4 "Malformed sources in file %s" file)
1332 (narrow-to-region (point-min) (point))
1333 (goto-char (point-min))
1334 (while (setq expr (ignore-errors (read (current-buffer))))
1336 (and (or (eq (car expr) 'defvar)
1337 (eq (car expr) 'defcustom))
1338 (stringp (nth 3 expr))
1339 (not (memq (nth 1 expr) gnus-debug-exclude-variables))
1340 (or (not (boundp (nth 1 expr)))
1341 (not (equal (eval (nth 2 expr))
1342 (symbol-value (nth 1 expr)))))
1343 (push (nth 1 expr) olist)))))))
1344 (kill-buffer (current-buffer)))
1345 (when (setq olist (nreverse olist))
1346 (insert "------------------ Environment follows ------------------\n\n"))
1348 (if (boundp (car olist))
1350 (pp `(setq ,(car olist)
1351 ,(if (or (consp (setq sym (symbol-value (car olist))))
1353 (not (or (eq sym nil)
1355 (list 'quote (symbol-value (car olist)))
1356 (symbol-value (car olist))))
1359 (format "(setq %s 'whatever)\n" (car olist))))
1360 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
1361 (setq olist (cdr olist)))
1363 ;; Remove any control chars - they seem to cause trouble for some
1364 ;; mailers. (Byte-compiled output from the stuff above.)
1366 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
1367 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
1370 ;;; Treatment of rejected articles.
1373 (defun gnus-summary-resend-bounced-mail (&optional fetch)
1374 "Re-mail the current message.
1375 This only makes sense if the current message is a bounce message than
1376 contains some mail you have written which has been bounced back to
1378 If FETCH, try to fetch the article that this is a reply to, if indeed
1381 (gnus-summary-select-article t)
1382 (set-buffer gnus-original-article-buffer)
1383 (gnus-setup-message 'compose-bounce
1384 (let* ((references (mail-fetch-field "references"))
1385 (parent (and references (gnus-parent-id references))))
1387 ;; If there are references, we fetch the article we answered to.
1389 (gnus-summary-refer-article parent)
1390 (gnus-summary-show-all-headers)))))
1394 (defun gnus-inews-group-method (group)
1396 ;; If the group doesn't exist, we assume
1397 ;; it's an archive group...
1398 ((and (null (gnus-get-info group))
1399 (eq (car (gnus-server-to-method gnus-message-archive-method))
1400 (car (gnus-server-to-method (gnus-group-method group)))))
1401 gnus-message-archive-method)
1403 ((gnus-info-method (gnus-get-info group))
1404 (gnus-info-method (gnus-get-info group)))
1406 (t (gnus-server-to-method (gnus-group-method group)))))
1408 ;; Do Gcc handling, which copied the message over to some group.
1409 (defun gnus-inews-do-gcc (&optional gcc)
1413 (message-narrow-to-headers)
1414 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
1415 (cur (current-buffer))
1416 groups group method group-art
1417 mml-externalize-attachments)
1419 (message-remove-header "gcc")
1421 (setq groups (message-unquote-tokens
1422 (message-tokenize-header gcc " ,")))
1423 ;; Copy the article over to some group(s).
1424 (while (setq group (pop groups))
1425 (unless (gnus-check-server
1426 (setq method (gnus-inews-group-method group)))
1427 (error "Can't open server %s" (if (stringp method) method
1429 (unless (gnus-request-group group nil method)
1430 (gnus-request-create-group group method))
1431 (setq mml-externalize-attachments
1432 (if (stringp gnus-gcc-externalize-attachments)
1433 (string-match gnus-gcc-externalize-attachments group)
1434 gnus-gcc-externalize-attachments))
1436 (nnheader-set-temp-buffer " *acc*")
1437 (insert-buffer-substring cur)
1438 (message-encode-message-body)
1440 (message-narrow-to-headers)
1441 (let* ((mail-parse-charset message-default-charset)
1442 (newsgroups-field (save-restriction
1443 (message-narrow-to-headers-or-head)
1444 (message-fetch-field "Newsgroups")))
1445 (followup-field (save-restriction
1446 (message-narrow-to-headers-or-head)
1447 (message-fetch-field "Followup-To")))
1448 ;; BUG: We really need to get the charset for
1449 ;; each name in the Newsgroups and Followup-To
1450 ;; lines to allow crossposting between group
1451 ;; namess with incompatible character sets.
1452 ;; -- Per Abrahamsen <abraham@dina.kvl.dk> 2001-10-08.
1453 (group-field-charset
1454 (gnus-group-name-charset
1455 method (or newsgroups-field "")))
1456 (followup-field-charset
1457 (gnus-group-name-charset
1458 method (or followup-field "")))
1459 (rfc2047-header-encoding-alist
1461 (when group-field-charset
1462 (list (cons "Newsgroups" group-field-charset)))
1463 (when followup-field-charset
1464 (list (cons "Followup-To" followup-field-charset)))
1465 rfc2047-header-encoding-alist)))
1466 (mail-encode-encoded-word-buffer)))
1467 (goto-char (point-min))
1468 (when (re-search-forward
1469 (concat "^" (regexp-quote mail-header-separator) "$")
1471 (replace-match "" t t ))
1472 (unless (setq group-art
1473 (gnus-request-accept-article group method t t))
1474 (gnus-message 1 "Couldn't store article in group %s: %s"
1475 group (gnus-status-message method))
1477 (when (and group-art
1478 (or gnus-gcc-mark-as-read
1479 gnus-inews-mark-gcc-as-read))
1480 (gnus-group-mark-article-read group (cdr group-art)))
1481 (kill-buffer (current-buffer)))))))))
1483 (defun gnus-inews-insert-gcc ()
1484 "Insert Gcc headers based on `gnus-outgoing-message-group'."
1487 (message-narrow-to-headers)
1488 (let* ((group gnus-outgoing-message-group)
1490 ((gnus-functionp group)
1492 ((or (stringp group) (list group))
1496 (if (stringp gcc) gcc
1497 (mapconcat 'identity gcc " "))
1500 (defun gnus-inews-insert-archive-gcc (&optional group)
1501 "Insert the Gcc to say where the article is to be archived."
1502 (let* ((var gnus-message-archive-group)
1503 (group (or group gnus-newsgroup-name ""))
1505 (and gnus-newsgroup-name
1506 (not (equal gnus-newsgroup-name ""))
1507 (gnus-group-find-parameter
1508 gnus-newsgroup-name 'gcc-self)))
1512 ((null gnus-message-archive-method)
1516 ;; Just a single group.
1519 ;; We don't want this.
1521 ((and (listp var) (stringp (car var)))
1522 ;; A list of groups.
1524 ((gnus-functionp var)
1526 (funcall var group))
1528 ;; An alist of regexps/functions/forms.
1533 ((stringp (caar var))
1535 (when (string-match (caar var) group)
1537 ((gnus-functionp (car var))
1539 (funcall (car var) group))
1541 (eval (car var)))))))
1542 (setq var (cdr var)))
1545 (when (or groups gcc-self-val)
1546 (when (stringp groups)
1547 (setq groups (list groups)))
1550 (message-narrow-to-headers)
1551 (goto-char (point-max))
1554 ;; Use the `gcc-self' param value instead.
1557 (if (stringp gcc-self-val)
1560 (if (not (eq gcc-self-val 'none))
1565 ;; Use the list of groups.
1566 (while (setq name (pop groups))
1567 (insert (if (string-match ":" name)
1569 (gnus-group-prefixed-name
1570 name gnus-message-archive-method)))
1577 (defun gnus-configure-posting-styles (&optional group-name)
1578 "Configure posting styles according to `gnus-posting-styles'."
1579 (unless gnus-inhibit-posting-styles
1580 (let ((group (or group-name gnus-newsgroup-name ""))
1581 (styles gnus-posting-styles)
1582 style match variable attribute value v results
1583 filep name address element)
1584 ;; If the group has a posting-style parameter, add it at the end with a
1585 ;; regexp matching everything, to be sure it takes precedence over all
1587 (when gnus-newsgroup-name
1588 (let ((tmp-style (gnus-group-find-parameter group 'posting-style t)))
1590 (setq styles (append styles (list (cons ".*" tmp-style)))))))
1591 ;; Go through all styles and look for matches.
1592 (dolist (style styles)
1593 (setq match (pop style))
1594 (goto-char (point-min))
1597 ;; Regexp string match on the group name.
1598 (string-match match group))
1600 ;; Obsolete format of header match.
1601 (and (gnus-buffer-live-p gnus-article-copy)
1602 (with-current-buffer gnus-article-copy
1603 (let ((header (message-fetch-field (pop style))))
1605 (string-match (pop style) header))))))
1606 ((or (symbolp match)
1607 (gnus-functionp match))
1609 ((gnus-functionp match)
1610 ;; Function to be called.
1613 ;; Variable to be checked.
1614 (symbol-value match))))
1617 ((eq (car match) 'header)
1618 ;; New format of header match.
1619 (and (gnus-buffer-live-p gnus-article-copy)
1620 (with-current-buffer gnus-article-copy
1621 (let ((header (message-fetch-field (nth 1 match))))
1623 (string-match (nth 2 match) header))))))
1625 ;; This is a form to be evaled.
1627 ;; We have a match, so we set the variables.
1628 (dolist (attribute style)
1629 (setq element (pop attribute)
1634 ((eq (car attribute) :file)
1637 ((eq (car attribute) :value)
1641 ;; We get the value.
1646 ((or (symbolp value)
1647 (gnus-functionp value))
1648 (cond ((gnus-functionp value)
1651 (symbol-value value))))
1654 ;; Translate obsolescent value.
1656 ((eq element 'signature-file)
1657 (setq element 'signature
1659 ((eq element 'x-face-file)
1660 (setq element 'x-face
1662 ;; Get the contents of file elems.
1664 (setq v (with-temp-buffer
1665 (insert-file-contents v)
1666 (goto-char (point-max))
1670 (setq results (delq (assoc element results) results))
1671 (push (cons element v) results))))
1672 ;; Now we have all the styles, so we insert them.
1673 (setq name (assq 'name results)
1674 address (assq 'address results))
1675 (setq results (delq name (delq address results)))
1676 ;; make-local-hook is not obsolete in Emacs 20 or XEmacs.
1677 (make-local-hook 'message-setup-hook)
1678 (dolist (result results)
1679 (add-hook 'message-setup-hook
1681 ((eq 'eval (car result))
1683 ((eq 'body (car result))
1687 (insert ,(cdr result)))))
1688 ((eq 'signature (car result))
1689 (set (make-local-variable 'message-signature) nil)
1690 (set (make-local-variable 'message-signature-file) nil)
1691 (if (not (cdr result))
1695 (let ((message-signature ,(cdr result)))
1696 (when message-signature
1697 (message-insert-signature)))))))
1700 (if (symbolp (car result))
1701 (capitalize (symbol-name (car result)))
1705 (message-remove-header ,header)
1706 (let ((value ,(cdr result)))
1709 (insert ,header ": " value "\n"))))))))
1711 (when (or name address)
1712 (add-hook 'message-setup-hook
1714 (set (make-local-variable 'user-mail-address)
1715 ,(or (cdr address) user-mail-address))
1716 (let ((user-full-name ,(or (cdr name) (user-full-name)))
1718 ,(or (cdr address) user-mail-address)))
1720 (message-remove-header "From")
1722 (insert "From: " (message-make-from) "\n"))))
1725 ;;; Allow redefinition of functions.
1731 ;;; gnus-msg.el ends here