1 ;;; gnus-msg.el --- mail and post interface for Gnus
2 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 ;; Free Software Foundation, Inc.
5 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
6 ;; Lars Magne Ingebrigtsen <larsi@gnus.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
30 (eval-when-compile (require 'cl))
37 (defcustom gnus-post-method 'current
38 "*Preferred method for posting USENET news.
40 If this variable is `current' (which is the default), Gnus will use
41 the \"current\" select method when posting. If it is `native', Gnus
42 will use the native select method when posting.
44 This method will not be used in mail groups and the like, only in
47 If not `native' nor `current', the value must be a valid method as discussed
48 in the documentation of `gnus-select-method'. It can also be a list of
49 methods. If that is the case, the user will be queried for what select
50 method to use when posting."
51 :group 'gnus-group-foreign
52 :link '(custom-manual "(gnus)Posting Server")
53 :type `(choice (const native)
55 (sexp :tag "Methods" ,gnus-select-method)))
57 (defcustom gnus-outgoing-message-group nil
58 "*All outgoing messages will be put in this group.
59 If you want to store all your outgoing mail and articles in the group
60 \"nnml:archive\", you set this variable to that value. This variable
61 can also be a list of group names.
63 If you want to have greater control over what group to put each
64 message in, you can set this variable to a function that checks the
65 current newsgroup name and then returns a suitable group name (or list
68 :type '(choice (string :tag "Group")
71 (defcustom gnus-mailing-list-groups nil
72 "*Regexp matching groups that are really mailing lists.
73 This is useful when you're reading a mailing list that has been
74 gatewayed to a newsgroup, and you want to followup to an article in
79 (defcustom gnus-add-to-list nil
80 "*If non-nil, add a `to-list' parameter automatically."
84 (defcustom gnus-crosspost-complaint
87 You posted the article below with the following Newsgroups header:
91 The %s group, at least, was an inappropriate recipient
92 of this message. Please trim your Newsgroups header to exclude this
93 group before posting in the future.
98 "Format string to be inserted when complaining about crossposts.
99 The first %s will be replaced by the Newsgroups header;
100 the second with the current group name."
104 (defcustom gnus-message-setup-hook nil
105 "Hook run after setting up a message buffer."
109 (defcustom gnus-bug-create-help-buffer t
110 "*Should we create the *Gnus Help Bug* buffer?"
114 (defcustom gnus-posting-styles nil
115 "*Alist of styles to use when posting.
116 See Info node `(gnus)Posting Styles'."
118 :type '(repeat (cons (choice (regexp)
123 (choice (const signature)
124 (const signature-file)
129 (string :tag "Header"))
135 (defcustom gnus-gcc-mark-as-read nil
136 "If non-nil, automatically mark Gcc articles as read."
140 (defvar gnus-inews-mark-gcc-as-read nil
141 "Obsolete variable. Use `gnus-gcc-mark-as-read' instead.")
143 (make-obsolete-variable 'gnus-inews-mark-gcc-as-read
144 'gnus-gcc-mark-as-read)
146 (defcustom gnus-gcc-externalize-attachments nil
147 "Should local-file attachments be included as external parts in Gcc copies?
148 If it is `all', attach files as external parts;
149 if a regexp and matches the Gcc group name, attach files as external parts;
150 If nil, attach files as normal parts."
152 :type '(choice (const nil :tag "None")
153 (const all :tag "Any")
154 (string :tag "Regexp")))
156 (defcustom gnus-group-posting-charset-alist
157 '(("^\\(no\\|fr\\)\\.[^,]*\\(,[ \t\n]*\\(no\\|fr\\)\\.[^,]*\\)*$" iso-8859-1 (iso-8859-1))
158 ("^\\(fido7\\|relcom\\)\\.[^,]*\\(,[ \t\n]*\\(fido7\\|relcom\\)\\.[^,]*\\)*$" koi8-r (koi8-r))
159 (message-this-is-mail nil nil)
160 (message-this-is-news nil t))
161 "Alist of regexps and permitted unencoded charsets for posting.
162 Each element of the alist has the form (TEST HEADER BODY-LIST), where
163 TEST is either a regular expression matching the newsgroup header or a
165 HEADER is the charset which may be left unencoded in the header (nil
166 means encode all charsets),
167 BODY-LIST is a list of charsets which may be encoded using 8bit
168 content-transfer encoding in the body, or one of the special values
169 nil (always encode using quoted-printable) or t (always use 8bit).
171 Note that any value other than nil for HEADER infringes some RFCs, so
172 use this option with care."
173 :type '(repeat (list :tag "Permitted unencoded charsets"
175 (regexp :tag "Group")
176 (const :tag "Mail message" :value message-this-is-mail)
177 (const :tag "News article" :value message-this-is-news))
178 (choice :tag "Header"
179 (const :tag "None" nil)
180 (symbol :tag "Charset"))
182 (const :tag "Any" :value t)
183 (const :tag "None" :value nil)
184 (repeat :tag "Charsets"
185 (symbol :tag "Charset")))))
186 :group 'gnus-charset)
188 ;;; Internal variables.
190 (defvar gnus-inhibit-posting-styles nil
191 "Inhibit the use of posting styles.")
193 (defvar gnus-message-buffer "*Mail Gnus*")
194 (defvar gnus-article-copy nil)
195 (defvar gnus-check-before-posting nil)
196 (defvar gnus-last-posting-server nil)
197 (defvar gnus-message-group-art nil)
199 (defvar gnus-msg-force-broken-reply-to nil)
201 (defconst gnus-bug-message
202 "Sending a bug report to the Gnus Towers.
203 ========================================
205 The buffer below is a mail buffer. When you press `C-c C-c', it will
206 be sent to the Gnus Bug Exterminators.
208 The thing near the bottom of the buffer is how the environment
209 settings will be included in the mail. Please do not delete that.
210 They will tell the Bug People what your environment is, so that it
211 will be easier to locate the bugs.
213 If you have found a bug that makes Emacs go \"beep\", set
214 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
215 and include the backtrace in your bug report.
217 Please describe the bug in annoying, painstaking detail.
219 Thank you for your help in stamping out bugs.
223 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
224 (autoload 'news-setup "rnewspost")
225 (autoload 'news-reply-mode "rnewspost")
226 (autoload 'rmail-dont-reply-to "mail-utils")
227 (autoload 'rmail-output "rmailout"))
231 ;;; Gnus Posting Functions
234 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
235 "p" gnus-summary-post-news
236 "i" gnus-summary-news-other-window
237 "f" gnus-summary-followup
238 "F" gnus-summary-followup-with-original
239 "c" gnus-summary-cancel-article
240 "s" gnus-summary-supersede-article
241 "r" gnus-summary-reply
242 "y" gnus-summary-yank-message
243 "R" gnus-summary-reply-with-original
244 "w" gnus-summary-wide-reply
245 "W" gnus-summary-wide-reply-with-original
246 "v" gnus-summary-very-wide-reply
247 "V" gnus-summary-very-wide-reply-with-original
248 "n" gnus-summary-followup-to-mail
249 "N" gnus-summary-followup-to-mail-with-original
250 "m" gnus-summary-mail-other-window
251 "u" gnus-uu-post-news
252 "\M-c" gnus-summary-mail-crosspost-complaint
253 "Br" gnus-summary-reply-broken-reply-to
254 "BR" gnus-summary-reply-broken-reply-to-with-original
255 "om" gnus-summary-mail-forward
256 "op" gnus-summary-post-forward
257 "Om" gnus-uu-digest-mail-forward
258 "Op" gnus-uu-digest-post-forward)
260 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
261 "b" gnus-summary-resend-bounced-mail
262 ;; "c" gnus-summary-send-draft
263 "r" gnus-summary-resend-message)
265 ;;; Internal functions.
267 (defvar gnus-article-reply nil)
268 (defmacro gnus-setup-message (config &rest forms)
269 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
270 (buffer (make-symbol "gnus-setup-message-buffer"))
271 (article (make-symbol "gnus-setup-message-article"))
272 (group (make-symbol "gnus-setup-message-group")))
273 `(let ((,winconf (current-window-configuration))
274 (,buffer (buffer-name (current-buffer)))
275 (,article gnus-article-reply)
276 (,group gnus-newsgroup-name)
277 (message-header-setup-hook
278 (copy-sequence message-header-setup-hook))
279 (mbl mml-buffer-list)
280 (message-mode-hook (copy-sequence message-mode-hook)))
281 (setq mml-buffer-list nil)
282 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
283 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
284 ;; #### FIXME: for a reason that I did not manage to identify yet,
285 ;; the variable `gnus-newsgroup-name' does not honor a dynamically
286 ;; scoped or setq'ed value from a caller like `C-u gnus-summary-mail'.
287 ;; After evaluation of @forms below, it gets the value we actually want
288 ;; to override, and the posting styles are used. For that reason, I've
289 ;; added an optional argument to `gnus-configure-posting-styles' to
290 ;; make sure that the correct value for the group name is used. -- drv
291 (add-hook 'message-mode-hook
293 (gnus-configure-posting-styles ,group)))
297 (gnus-inews-add-send-actions ,winconf ,buffer ,article ,config)
298 (gnus-inews-insert-draft-meta-information ,group ,article)
299 (setq gnus-message-buffer (current-buffer))
300 (set (make-local-variable 'gnus-message-group-art)
301 (cons ,group ,article))
302 (set (make-local-variable 'gnus-newsgroup-name) ,group)
303 (gnus-run-hooks 'gnus-message-setup-hook)
304 (if (eq major-mode 'message-mode)
305 (let ((mbl1 mml-buffer-list))
306 (setq mml-buffer-list mbl) ;; Global value
307 (set (make-local-variable 'mml-buffer-list) mbl1);; Local value
308 ;; LOCAL argument of add-hook differs between GNU Emacs
309 ;; and XEmacs. make-local-hook makes sure they are local.
310 (make-local-hook 'kill-buffer-hook)
311 (make-local-hook 'change-major-mode-hook)
312 (add-hook 'change-major-mode-hook 'mml-destroy-buffers nil t)
313 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))
314 (mml-destroy-buffers)
315 (setq mml-buffer-list mbl)))
317 (gnus-configure-windows ,config t)
318 (run-hooks 'post-command-hook)
319 (set-buffer-modified-p nil))))
321 (defun gnus-inews-insert-draft-meta-information (group article)
324 (not (string= group ""))
325 (not (message-fetch-field gnus-draft-meta-information-header)))
326 (goto-char (point-min))
327 (insert gnus-draft-meta-information-header ": (\"" group "\" "
328 (if article (number-to-string
335 (defun gnus-msg-mail (&optional to subject other-headers continue
336 switch-action yank-action send-actions)
337 "Start editing a mail message to be sent.
338 Like `message-mail', but with Gnus paraphernalia, particularly the
339 Gcc: header for archiving purposes."
341 (let ((buf (current-buffer))
343 (gnus-setup-message 'message
344 (message-mail to subject other-headers continue
345 nil yank-action send-actions))
347 (setq mail-buf (current-buffer))
348 (switch-to-buffer buf)
349 (apply switch-action mail-buf nil)))
350 ;; COMPOSEFUNC should return t if succeed. Undocumented ???
353 (defvar save-selected-window-window)
356 (defun gnus-button-mailto (address)
358 (set-buffer (gnus-copy-article-buffer))
359 (gnus-setup-message 'message
360 (message-reply address))
361 (and (boundp 'save-selected-window-window)
362 (not (window-live-p save-selected-window-window))
363 (setq save-selected-window-window (selected-window))))
366 (defun gnus-button-reply (&optional to-address wide)
367 "Like `message-reply'."
369 (gnus-setup-message 'message
370 (message-reply to-address wide))
371 (and (boundp 'save-selected-window-window)
372 (not (window-live-p save-selected-window-window))
373 (setq save-selected-window-window (selected-window))))
376 (define-mail-user-agent 'gnus-user-agent
377 'gnus-msg-mail 'message-send-and-exit
378 'message-kill-buffer 'message-send-hook)
380 (defun gnus-setup-posting-charset (group)
381 (let ((alist gnus-group-posting-charset-alist)
382 (group (or group ""))
386 (while (setq elem (pop alist))
387 (when (or (and (stringp (car elem))
388 (string-match (car elem) group))
389 (and (gnus-functionp (car elem))
390 (funcall (car elem) group))
391 (and (symbolp (car elem))
392 (symbol-value (car elem))))
393 (throw 'found (cons (cadr elem) (caddr elem)))))))))
395 (defun gnus-inews-add-send-actions (winconf buffer article &optional config)
396 (make-local-hook 'message-sent-hook)
397 (add-hook 'message-sent-hook (if gnus-agent 'gnus-agent-possibly-do-gcc
398 'gnus-inews-do-gcc) nil t)
400 (make-local-hook 'message-header-hook)
401 (add-hook 'message-header-hook 'gnus-agent-possibly-save-gcc nil t))
402 (setq message-post-method
404 (gnus-post-method arg ,gnus-newsgroup-name)))
405 (setq message-newsreader (setq message-mailer (gnus-extended-version)))
407 `(set-window-configuration ,winconf) 'exit 'postpone 'kill)
409 `(when (gnus-buffer-exists-p ,buffer)
413 (if (eq config 'forward)
414 `(gnus-summary-mark-article-as-forwarded ',article)
415 `(gnus-summary-mark-article-as-replied ',article)))))
418 (put 'gnus-setup-message 'lisp-indent-function 1)
419 (put 'gnus-setup-message 'edebug-form-spec '(form body))
421 ;;; Post news commands of Gnus group mode and summary mode
423 (defun gnus-group-mail (&optional arg)
424 "Start composing a mail.
425 If ARG, use the group under the point to find a posting style.
426 If ARG is 1, prompt for a group name to find the posting style."
428 ;; We can't `let' gnus-newsgroup-name here, since that leads
429 ;; to local variables leaking.
430 (let ((group gnus-newsgroup-name)
431 (buffer (current-buffer)))
434 (setq gnus-newsgroup-name
436 (if (= 1 (prefix-numeric-value arg))
437 (completing-read "Use posting style of group: "
438 gnus-active-hashtb nil
439 (gnus-read-active-file-p))
440 (gnus-group-group-name))
442 ;; #### see comment in gnus-setup-message -- drv
443 (gnus-setup-message 'message (message-mail)))
446 (setq gnus-newsgroup-name group)))))
448 (defun gnus-group-news (&optional arg)
449 "Start composing a news.
450 If ARG, post to group under point.
451 If ARG is 1, prompt for group name to post to.
453 This function prepares a news even when using mail groups. This is useful
454 for posting messages to mail groups without actually sending them over the
455 network. The corresponding backend must have a 'request-post method."
457 ;; We can't `let' gnus-newsgroup-name here, since that leads
458 ;; to local variables leaking.
459 (let ((group gnus-newsgroup-name)
460 (buffer (current-buffer)))
463 (setq gnus-newsgroup-name
465 (if (= 1 (prefix-numeric-value arg))
466 (completing-read "Use group: "
467 gnus-active-hashtb nil
468 (gnus-read-active-file-p))
469 (gnus-group-group-name))
471 ;; #### see comment in gnus-setup-message -- drv
472 (gnus-setup-message 'message
473 (message-news (gnus-group-real-name gnus-newsgroup-name))))
476 (setq gnus-newsgroup-name group)))))
478 (defun gnus-group-post-news (&optional arg)
479 "Start composing a message (a news by default).
480 If ARG, post to group under point. If ARG is 1, prompt for group name.
481 Depending on the selected group, the message might be either a mail or
484 ;; Bind this variable here to make message mode hooks work ok.
485 (let ((gnus-newsgroup-name
487 (if (= 1 (prefix-numeric-value arg))
488 (completing-read "Newsgroup: " gnus-active-hashtb nil
489 (gnus-read-active-file-p))
490 (gnus-group-group-name))
492 (gnus-post-news 'post gnus-newsgroup-name)))
494 (defun gnus-summary-mail-other-window (&optional arg)
495 "Start composing a mail in another window.
496 Use the posting of the current group by default.
497 If ARG, don't do that. If ARG is 1, prompt for group name to find the
500 ;; We can't `let' gnus-newsgroup-name here, since that leads
501 ;; to local variables leaking.
502 (let ((group gnus-newsgroup-name)
503 (buffer (current-buffer)))
506 (setq gnus-newsgroup-name
508 (if (= 1 (prefix-numeric-value arg))
509 (completing-read "Use group: "
510 gnus-active-hashtb nil
511 (gnus-read-active-file-p))
513 gnus-newsgroup-name))
514 ;; #### see comment in gnus-setup-message -- drv
515 (gnus-setup-message 'message (message-mail)))
518 (setq gnus-newsgroup-name group)))))
520 (defun gnus-summary-news-other-window (&optional arg)
521 "Start composing a news in another window.
522 Post to the current group by default.
523 If ARG, don't do that. If ARG is 1, prompt for group name to post to.
525 This function prepares a news even when using mail groups. This is useful
526 for posting messages to mail groups without actually sending them over the
527 network. The corresponding backend must have a 'request-post method."
529 ;; We can't `let' gnus-newsgroup-name here, since that leads
530 ;; to local variables leaking.
531 (let ((group gnus-newsgroup-name)
532 (buffer (current-buffer)))
535 (setq gnus-newsgroup-name
537 (if (= 1 (prefix-numeric-value arg))
538 (completing-read "Use group: "
539 gnus-active-hashtb nil
540 (gnus-read-active-file-p))
542 gnus-newsgroup-name))
543 ;; #### see comment in gnus-setup-message -- drv
544 (gnus-setup-message 'message
545 (message-news (gnus-group-real-name gnus-newsgroup-name))))
548 (setq gnus-newsgroup-name group)))))
550 (defun gnus-summary-post-news (&optional arg)
551 "Start composing a message. Post to the current group by default.
552 If ARG, don't do that. If ARG is 1, prompt for a group name to post to.
553 Depending on the selected group, the message might be either a mail or
556 ;; Bind this variable here to make message mode hooks work ok.
557 (let ((gnus-newsgroup-name
559 (if (= 1 (prefix-numeric-value arg))
560 (completing-read "Newsgroup: " gnus-active-hashtb nil
561 (gnus-read-active-file-p))
563 gnus-newsgroup-name)))
564 (gnus-post-news 'post gnus-newsgroup-name)))
567 (defun gnus-summary-followup (yank &optional force-news)
568 "Compose a followup to an article.
569 If prefix argument YANK is non-nil, the original article is yanked
571 YANK is a list of elements, where the car of each element is the
572 article number, and the two following numbers is the region to be
575 (list (and current-prefix-arg
576 (gnus-summary-work-articles 1))))
578 (gnus-summary-goto-subject
579 (if (listp (car yank))
582 (save-window-excursion
583 (gnus-summary-select-article))
584 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
585 (gnus-newsgroup-name gnus-newsgroup-name))
587 (gnus-post-news nil gnus-newsgroup-name
588 headers gnus-article-buffer
589 yank nil force-news)))
591 (defun gnus-summary-followup-with-original (n &optional force-news)
592 "Compose a followup to an article and include the original article."
594 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
596 (defun gnus-summary-followup-to-mail (&optional arg)
597 "Followup to the current mail message via news."
599 (list (and current-prefix-arg
600 (gnus-summary-work-articles 1))))
601 (gnus-summary-followup arg t))
603 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
604 "Followup to the current mail message via news."
606 (gnus-summary-followup (gnus-summary-work-articles arg) t))
608 (defun gnus-inews-yank-articles (articles)
609 (let (beg article yank-string)
611 (while (setq article (pop articles))
612 (when (listp article)
613 (setq yank-string (nth 1 article)
614 article (nth 0 article)))
615 (save-window-excursion
616 (set-buffer gnus-summary-buffer)
617 (gnus-summary-select-article nil nil nil article)
618 (gnus-summary-remove-process-mark article))
619 (gnus-copy-article-buffer nil yank-string)
620 (let ((message-reply-buffer gnus-article-copy)
621 (message-reply-headers
622 ;; The headers are decoded.
623 (with-current-buffer gnus-article-copy
624 (nnheader-parse-head t))))
625 (message-yank-original)
626 (setq beg (or beg (mark t))))
632 (defun gnus-summary-cancel-article (&optional n symp)
633 "Cancel an article you posted.
634 Uses the process-prefix convention. If given the symbolic
635 prefix `a', cancel using the standard posting method; if not
636 post using the current select method."
637 (interactive (gnus-interactive "P\ny"))
638 (let ((articles (gnus-summary-work-articles n))
641 (gnus-post-method (not (eq symp 'a)) ,gnus-newsgroup-name)))
643 (while (setq article (pop articles))
644 (when (gnus-summary-select-article t nil nil article)
645 (when (gnus-eval-in-buffer-window gnus-original-article-buffer
646 (message-cancel-news))
647 (gnus-summary-mark-as-read article gnus-canceled-mark)
648 (gnus-cache-remove-article 1))
649 (gnus-article-hide-headers-if-wanted))
650 (gnus-summary-remove-process-mark article))))
652 (defun gnus-summary-supersede-article ()
653 "Compose an article that will supersede a previous article.
654 This is done simply by taking the old article and adding a Supersedes
655 header line with the old Message-ID."
657 (let ((article (gnus-summary-article-number)))
658 (gnus-setup-message 'reply-yank
659 (gnus-summary-select-article t)
660 (set-buffer gnus-original-article-buffer)
664 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
666 (set-buffer ,gnus-summary-buffer)
667 (gnus-cache-possibly-remove-article ,article nil nil nil t)
668 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
669 message-send-actions))))
673 (defun gnus-copy-article-buffer (&optional article-buffer yank-string)
674 ;; make a copy of the article buffer with all text properties removed
675 ;; this copy is in the buffer gnus-article-copy.
676 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
677 ;; this buffer should be passed to all mail/news reply/post routines.
678 (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
680 (set-buffer gnus-article-copy)
681 (mm-enable-multibyte))
682 (let ((article-buffer (or article-buffer gnus-article-buffer))
684 (if (not (and (get-buffer article-buffer)
685 (gnus-buffer-exists-p article-buffer)))
686 (error "Can't find any article buffer")
688 (set-buffer article-buffer)
689 (let ((gnus-newsgroup-charset (or gnus-article-charset
690 gnus-newsgroup-charset))
691 (gnus-newsgroup-ignored-charsets
692 (or gnus-article-ignored-charsets
693 gnus-newsgroup-ignored-charsets)))
695 ;; Copy over the (displayed) article buffer, delete
696 ;; hidden text and remove text properties.
698 (copy-to-buffer gnus-article-copy (point-min) (point-max))
699 (set-buffer gnus-article-copy)
702 (delete-region (point) (point-max))
703 (insert yank-string))
704 (gnus-article-delete-text-of-type 'annotation)
705 (gnus-remove-text-with-property 'gnus-prev)
706 (gnus-remove-text-with-property 'gnus-next)
709 (buffer-substring-no-properties (point-min) (point-max))
711 ;; Find the original headers.
712 (set-buffer gnus-original-article-buffer)
713 (goto-char (point-min))
714 (while (looking-at message-unix-mail-delimiter)
717 end (or (message-goto-body) beg))
718 ;; Delete the headers from the displayed articles.
719 (set-buffer gnus-article-copy)
720 (delete-region (goto-char (point-min))
721 (or (message-goto-body) (point-max)))
722 ;; Insert the original article headers.
723 (insert-buffer-substring gnus-original-article-buffer beg end)
725 (let ((gnus-article-decode-hook
726 (delq 'article-decode-charset
727 (copy-sequence gnus-article-decode-hook))))
728 (run-hooks 'gnus-article-decode-hook)))))
731 (defun gnus-post-news (post &optional group header article-buffer yank subject
734 (gnus-copy-article-buffer))
735 (let ((gnus-article-reply (and article-buffer (gnus-summary-article-number)))
736 (add-to-list gnus-add-to-list))
737 (gnus-setup-message (cond (yank 'reply-yank)
738 (article-buffer 'reply)
740 (let* ((group (or group gnus-newsgroup-name))
741 (charset (gnus-group-name-charset nil group))
743 to-address to-group mailing-list to-list
746 (setq to-address (gnus-parameter-to-address group)
747 to-group (gnus-group-find-parameter group 'to-group)
748 to-list (gnus-parameter-to-list group)
749 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
750 mailing-list (when gnus-mailing-list-groups
751 (string-match gnus-mailing-list-groups group))
752 group (gnus-group-name-decode (gnus-group-real-name group)
754 (if (or (and to-group
755 (gnus-news-group-p to-group))
758 (and (gnus-news-group-p
759 (or pgroup gnus-newsgroup-name)
760 (or header gnus-current-article))
766 (message-news (or to-group group))
767 (set-buffer gnus-article-copy)
768 (gnus-msg-treat-broken-reply-to)
769 (message-followup (if (or newsgroup-p force-news)
770 (if (save-restriction
771 (article-narrow-to-head)
772 (message-fetch-field "newsgroups"))
779 (message-mail (or to-address to-list))
780 ;; Arrange for mail groups that have no `to-address' to
781 ;; get that when the user sends off the mail.
782 (when (and (not to-list)
785 (push (list 'gnus-inews-add-to-address pgroup)
786 message-send-actions)))
787 (set-buffer gnus-article-copy)
788 (gnus-msg-treat-broken-reply-to)
789 (message-wide-reply to-address)))
791 (gnus-inews-yank-articles yank))))))
793 (defun gnus-msg-treat-broken-reply-to (&optional force)
794 "Remove the Reply-to header iff broken-reply-to."
796 (gnus-group-find-parameter
797 gnus-newsgroup-name 'broken-reply-to))
799 (message-narrow-to-head)
800 (message-remove-header "reply-to"))))
802 (defun gnus-post-method (arg group &optional silent)
803 "Return the posting method based on GROUP and ARG.
804 If SILENT, don't prompt the user."
805 (let ((gnus-post-method (or (gnus-parameter-post-method group)
807 (group-method (gnus-find-method-for-group group)))
809 ;; If the group-method is nil (which shouldn't happen) we use
810 ;; the default method.
812 (or (and (listp gnus-post-method) ;If not current/native/nil
813 (not (listp (car gnus-post-method))) ; and not a list of methods
814 gnus-post-method) ;then use it.
816 message-post-method))
817 ;; We want the inverse of the default
818 ((and arg (not (eq arg 0)))
819 (if (eq gnus-post-method 'current)
822 ;; We query the user for a post method.
824 (and (listp gnus-post-method)
825 (listp (car gnus-post-method))))
827 ;; Collect all methods we know about.
829 (when (listp gnus-post-method)
830 (if (listp (car gnus-post-method))
832 (list gnus-post-method)))
833 gnus-secondary-select-methods
834 (mapcar 'cdr gnus-server-alist)
835 (mapcar 'car gnus-opened-servers)
836 (list gnus-select-method)
837 (list group-method)))
838 method-alist post-methods method)
839 ;; Weed out all mail methods.
841 (setq method (gnus-server-get-method "" (pop methods)))
842 (when (and (or (gnus-method-option-p method 'post)
843 (gnus-method-option-p method 'post-mail))
844 (not (member method post-methods)))
845 (push method post-methods)))
846 ;; Create a name-method alist.
850 (if (equal (cadr m) "")
851 (list (symbol-name (car m)) m)
852 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m)))
857 (setq gnus-last-posting-server
859 gnus-last-posting-server)
860 ;; Just use the last value.
861 gnus-last-posting-server
863 "Posting method: " method-alist nil t
864 (cons (or gnus-last-posting-server "") 0))))
866 ;; Override normal method.
867 ((and (eq gnus-post-method 'current)
868 (not (eq (car group-method) 'nndraft))
869 (gnus-get-function group-method 'request-post t))
872 ;; Use gnus-post-method.
873 ((listp gnus-post-method) ;A method...
874 (assert (not (listp (car gnus-post-method)))) ;... not a list of methods.
876 ;; Use the normal select method (nil or native).
877 (t gnus-select-method))))
881 ;; Dummies to avoid byte-compile warning.
883 (defvar nnspool-rejected-article-hook)
884 (defvar xemacs-codename))
886 (defun gnus-extended-version ()
887 "Stringified Gnus version and Emacs version."
890 "Gnus/" (prin1-to-string (gnus-continuum-version gnus-version) t)
891 " (" gnus-version ")"
894 ((string-match "^\\(\\([.0-9]+\\)*\\)\\.[0-9]+$" emacs-version)
895 (concat "Emacs/" (match-string 1 emacs-version)
896 " (" system-configuration ")"))
897 ((string-match "\\([A-Z]*[Mm][Aa][Cc][Ss]\\)[^(]*\\(\\((beta.*)\\|'\\)\\)?"
899 (concat (match-string 1 emacs-version)
900 (format "/%d.%d" emacs-major-version emacs-minor-version)
901 (if (match-beginning 3)
902 (match-string 3 emacs-version)
904 (if (boundp 'xemacs-codename)
905 (concat " (" xemacs-codename ", " system-configuration ")")
911 ;;; Gnus Mail Functions
914 ;;; Mail reply commands of Gnus summary mode
916 (defun gnus-summary-reply (&optional yank wide very-wide)
917 "Start composing a mail reply to the current message.
918 If prefix argument YANK is non-nil, the original article is yanked
920 If WIDE, make a wide reply.
921 If VERY-WIDE, make a very wide reply."
923 (list (and current-prefix-arg
924 (gnus-summary-work-articles 1))))
926 (if (listp (car yank))
929 (gnus-article-reply (or article (gnus-summary-article-number)))
931 ;; Stripping headers should be specified with mail-yank-ignored-headers.
933 (gnus-summary-goto-subject article))
934 (gnus-setup-message (if yank 'reply-yank 'reply)
936 (gnus-summary-select-article)
937 (dolist (article very-wide)
938 (gnus-summary-select-article nil nil nil article)
940 (set-buffer (gnus-copy-article-buffer))
941 (gnus-msg-treat-broken-reply-to)
943 (message-narrow-to-head)
944 (setq headers (concat headers (buffer-string)))))))
945 (set-buffer (gnus-copy-article-buffer))
946 (gnus-msg-treat-broken-reply-to gnus-msg-force-broken-reply-to)
948 (message-narrow-to-head)
952 (goto-char (point-max)))
953 (mml-quote-region (point) (point-max))
954 (message-reply nil wide)
956 (gnus-inews-yank-articles yank)))))
958 (defun gnus-summary-reply-with-original (n &optional wide)
959 "Start composing a reply mail to the current message.
960 The original article will be yanked."
962 (gnus-summary-reply (gnus-summary-work-articles n) wide))
964 (defun gnus-summary-reply-broken-reply-to (&optional yank wide very-wide)
965 "Like `gnus-summary-reply' except removing reply-to field.
966 If prefix argument YANK is non-nil, the original article is yanked
968 If WIDE, make a wide reply.
969 If VERY-WIDE, make a very wide reply."
971 (list (and current-prefix-arg
972 (gnus-summary-work-articles 1))))
973 (let ((gnus-msg-force-broken-reply-to t))
974 (gnus-summary-reply yank wide very-wide)))
976 (defun gnus-summary-reply-broken-reply-to-with-original (n &optional wide)
977 "Like `gnus-summary-reply-with-original' except removing reply-to field.
978 The original article will be yanked."
980 (gnus-summary-reply-broken-reply-to (gnus-summary-work-articles n) wide))
982 (defun gnus-summary-wide-reply (&optional yank)
983 "Start composing a wide reply mail to the current message.
984 If prefix argument YANK is non-nil, the original article is yanked
987 (list (and current-prefix-arg
988 (gnus-summary-work-articles 1))))
989 (gnus-summary-reply yank t))
991 (defun gnus-summary-wide-reply-with-original (n)
992 "Start composing a wide reply mail to the current message.
993 The original article will be yanked."
995 (gnus-summary-reply-with-original n t))
997 (defun gnus-summary-very-wide-reply (&optional yank)
998 "Start composing a very wide reply mail to the current message.
999 If prefix argument YANK is non-nil, the original article is yanked
1002 (list (and current-prefix-arg
1003 (gnus-summary-work-articles 1))))
1004 (gnus-summary-reply yank t (gnus-summary-work-articles yank)))
1006 (defun gnus-summary-very-wide-reply-with-original (n)
1007 "Start composing a very wide reply mail to the current message.
1008 The original article will be yanked."
1011 (gnus-summary-work-articles n) t (gnus-summary-work-articles n)))
1013 (defun gnus-summary-mail-forward (&optional arg post)
1014 "Forward the current message(s) to another user.
1015 If process marks exist, forward all marked messages;
1016 if ARG is nil, see `message-forward-as-mime' and `message-forward-show-mml';
1017 if ARG is 1, decode the message and forward directly inline;
1018 if ARG is 2, forward message as an rfc822 MIME section;
1019 if ARG is 3, decode message and forward as an rfc822 MIME section;
1020 if ARG is 4, forward message directly inline;
1021 otherwise, use flipped `message-forward-as-mime'.
1022 If POST, post instead of mail.
1023 For the `inline' alternatives, also see the variable
1024 `message-forward-ignored-headers'."
1026 (if (null (cdr (gnus-summary-work-articles nil)))
1027 (let ((message-forward-as-mime message-forward-as-mime)
1028 (message-forward-show-mml message-forward-show-mml))
1032 (setq message-forward-as-mime nil
1033 message-forward-show-mml t))
1035 (setq message-forward-as-mime t
1036 message-forward-show-mml nil))
1038 (setq message-forward-as-mime t
1039 message-forward-show-mml t))
1041 (setq message-forward-as-mime nil
1042 message-forward-show-mml nil))
1044 (setq message-forward-as-mime (not message-forward-as-mime))))
1045 (let ((gnus-article-reply (gnus-summary-article-number)))
1046 (gnus-setup-message 'forward
1047 (gnus-summary-select-article)
1048 (let ((mail-parse-charset gnus-newsgroup-charset)
1049 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
1050 (set-buffer gnus-original-article-buffer)
1051 (message-forward post)))))
1052 (gnus-uu-digest-mail-forward arg post)))
1054 (defun gnus-summary-resend-message (address n)
1055 "Resend the current article to ADDRESS."
1057 (list (message-read-from-minibuffer
1058 "Resend message(s) to: "
1059 (when (gnus-buffer-live-p gnus-original-article-buffer)
1060 ;; If some other article is currently selected, the
1061 ;; initial-contents is wrong. Whatever, it is just the
1062 ;; initial-contents.
1063 (with-current-buffer gnus-original-article-buffer
1064 (nnmail-fetch-field "to"))))
1065 current-prefix-arg))
1066 (let ((articles (gnus-summary-work-articles n))
1068 (while (setq article (pop articles))
1069 (gnus-summary-select-article nil nil nil article)
1071 (set-buffer gnus-original-article-buffer)
1072 (message-resend address))
1073 (gnus-summary-mark-article-as-forwarded article))))
1075 (defun gnus-summary-post-forward (&optional arg)
1076 "Forward the current article to a newsgroup.
1077 See `gnus-summary-mail-forward' for ARG."
1079 (gnus-summary-mail-forward arg t))
1081 (defvar gnus-nastygram-message
1082 "The following article was inappropriately posted to %s.\n\n"
1083 "Format string to insert in nastygrams.
1084 The current group name will be inserted at \"%s\".")
1086 (defun gnus-summary-mail-nastygram (n)
1087 "Send a nastygram to the author of the current article."
1089 (when (or gnus-expert-user
1091 "Really send a nastygram to the author of the current article? "))
1092 (let ((group gnus-newsgroup-name))
1093 (gnus-summary-reply-with-original n)
1094 (set-buffer gnus-message-buffer)
1096 (insert (format gnus-nastygram-message group))
1097 (message-send-and-exit))))
1099 (defun gnus-summary-mail-crosspost-complaint (n)
1100 "Send a complaint about crossposting to the current article(s)."
1102 (let ((articles (gnus-summary-work-articles n))
1104 (while (setq article (pop articles))
1105 (set-buffer gnus-summary-buffer)
1106 (gnus-summary-goto-subject article)
1107 (let ((group (gnus-group-real-name gnus-newsgroup-name))
1108 newsgroups followup-to)
1109 (gnus-summary-select-article)
1110 (set-buffer gnus-original-article-buffer)
1111 (if (and (<= (length (message-tokenize-header
1113 (mail-fetch-field "newsgroups"))
1116 (or (not (setq followup-to (mail-fetch-field "followup-to")))
1117 (not (member group (message-tokenize-header
1118 followup-to ", ")))))
1120 (gnus-message 1 "Followup-to restricted")
1121 (gnus-message 1 "Not a crossposted article"))
1122 (set-buffer gnus-summary-buffer)
1123 (gnus-summary-reply-with-original 1)
1124 (set-buffer gnus-message-buffer)
1126 (insert (format gnus-crosspost-complaint newsgroups group))
1127 (message-goto-subject)
1128 (re-search-forward " *$")
1129 (replace-match " (crosspost notification)" t t)
1130 (gnus-deactivate-mark)
1131 (when (gnus-y-or-n-p "Send this complaint? ")
1132 (message-send-and-exit)))))))
1134 (defun gnus-mail-parse-comma-list ()
1137 (skip-chars-forward " ")
1140 (skip-chars-forward "^,")
1145 (narrow-to-region beg (point))
1148 (while (search-forward "\"" nil t)
1152 (skip-chars-forward ",")
1153 (skip-chars-forward "^,"))
1154 (skip-chars-backward " ")
1155 (push (buffer-substring beg (point))
1157 (skip-chars-forward "^,")
1158 (skip-chars-forward ", "))
1161 (defun gnus-inews-add-to-address (group)
1162 (let ((to-address (mail-fetch-field "to")))
1163 (when (and to-address
1165 ;; This mail group doesn't have a `to-list', so we add one
1167 (when (gnus-y-or-n-p
1168 (format "Do you want to add this as `to-list': %s " to-address))
1169 (gnus-group-add-parameter group (cons 'to-list to-address))))))
1171 (defun gnus-put-message ()
1172 "Put the current message in some group and return to Gnus."
1174 (let ((reply gnus-article-reply)
1175 (winconf gnus-prev-winconf)
1176 (group gnus-newsgroup-name))
1178 (not (gnus-group-read-only-p group)))
1179 (setq group (read-string "Put in group: " nil (gnus-writable-groups))))
1181 (when (gnus-gethash group gnus-newsrc-hashtb)
1182 (error "No such group: %s" group))
1186 (message-narrow-to-headers)
1187 (let ((gnus-deletable-headers nil))
1188 (message-generate-headers
1189 (if (message-news-p)
1190 message-required-news-headers
1191 message-required-mail-headers)))
1192 (goto-char (point-max))
1193 (insert "Gcc: " group "\n")
1196 (when (and (get-buffer gnus-group-buffer)
1197 (gnus-buffer-exists-p (car-safe reply))
1199 (set-buffer (car reply))
1200 (gnus-summary-mark-article-as-replied (cdr reply)))
1202 (set-window-configuration winconf))))
1204 (defun gnus-article-mail (yank)
1205 "Send a reply to the address near point.
1206 If YANK is non-nil, include the original article."
1210 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
1211 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
1213 (message-reply address)
1215 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
1217 (defvar nntp-server-type)
1219 "Send a bug report to the Gnus maintainers."
1221 (unless (gnus-alive-p)
1222 (error "Gnus has been shut down"))
1223 (gnus-setup-message (if (message-mail-user-agent) 'message 'bug)
1224 (unless (message-mail-user-agent)
1225 (delete-other-windows)
1226 (when gnus-bug-create-help-buffer
1227 (switch-to-buffer "*Gnus Help Bug*")
1229 (insert gnus-bug-message)
1230 (goto-char (point-min)))
1231 (message-pop-to-buffer "*Gnus Bug*"))
1232 (let ((message-this-is-mail t))
1233 (message-setup `((To . ,gnus-maintainer) (Subject . ""))))
1234 (when gnus-bug-create-help-buffer
1235 (push `(gnus-bug-kill-buffer) message-send-actions))
1236 (goto-char (point-min))
1237 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
1239 (insert (gnus-version) "\n"
1240 (emacs-version) "\n")
1241 (when (and (boundp 'nntp-server-type)
1242 (stringp nntp-server-type))
1243 (insert nntp-server-type))
1244 (insert "\n\n\n\n\n")
1247 (set-buffer (gnus-get-buffer-create " *gnus environment info*"))
1250 (setq text (buffer-string)))
1251 (insert "<#part type=application/emacs-lisp disposition=inline description=\"User settings\">\n" text "\n<#/part>"))
1252 (goto-char (point-min))
1253 (search-forward "Subject: " nil t)
1256 (defun gnus-bug-kill-buffer ()
1257 (when (get-buffer "*Gnus Help Bug*")
1258 (kill-buffer "*Gnus Help Bug*")))
1260 (defun gnus-summary-yank-message (buffer n)
1261 "Yank the current article into a composed message."
1263 (list (completing-read "Buffer: " (mapcar 'list (message-buffers)) nil t)
1264 current-prefix-arg))
1265 (gnus-summary-iterate n
1266 (let ((gnus-display-mime-function nil)
1267 (gnus-inhibit-treatment t))
1268 (gnus-summary-select-article))
1271 (message-yank-buffer gnus-article-buffer))))
1273 (defun gnus-debug ()
1274 "Attempts to go through the Gnus source file and report what variables have been changed.
1275 The source file has to be in the Emacs load path."
1277 (let ((files '("gnus.el" "gnus-sum.el" "gnus-group.el"
1278 "gnus-art.el" "gnus-start.el" "gnus-async.el"
1279 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
1280 "nnmail.el" "message.el"))
1282 file expr olist sym)
1283 (gnus-message 4 "Please wait while we snoop your variables...")
1285 ;; Go through all the files looking for non-default values for variables.
1287 (set-buffer (gnus-get-buffer-create " *gnus bug info*"))
1290 (when (and (setq file (locate-library (pop files)))
1291 (file-exists-p file))
1292 (insert-file-contents file)
1293 (goto-char (point-min))
1294 (if (not (re-search-forward "^;;* *Internal variables" nil t))
1295 (gnus-message 4 "Malformed sources in file %s" file)
1296 (narrow-to-region (point-min) (point))
1297 (goto-char (point-min))
1298 (while (setq expr (ignore-errors (read (current-buffer))))
1300 (and (or (eq (car expr) 'defvar)
1301 (eq (car expr) 'defcustom))
1302 (stringp (nth 3 expr))
1303 (or (not (boundp (nth 1 expr)))
1304 (not (equal (eval (nth 2 expr))
1305 (symbol-value (nth 1 expr)))))
1306 (push (nth 1 expr) olist)))))))
1307 (kill-buffer (current-buffer)))
1308 (when (setq olist (nreverse olist))
1309 (insert "------------------ Environment follows ------------------\n\n"))
1311 (if (boundp (car olist))
1313 (pp `(setq ,(car olist)
1314 ,(if (or (consp (setq sym (symbol-value (car olist))))
1316 (not (or (eq sym nil)
1318 (list 'quote (symbol-value (car olist)))
1319 (symbol-value (car olist))))
1322 (format "(setq %s 'whatever)\n" (car olist))))
1323 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
1324 (setq olist (cdr olist)))
1326 ;; Remove any control chars - they seem to cause trouble for some
1327 ;; mailers. (Byte-compiled output from the stuff above.)
1329 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
1330 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
1333 ;;; Treatment of rejected articles.
1336 (defun gnus-summary-resend-bounced-mail (&optional fetch)
1337 "Re-mail the current message.
1338 This only makes sense if the current message is a bounce message than
1339 contains some mail you have written which has been bounced back to
1341 If FETCH, try to fetch the article that this is a reply to, if indeed
1344 (gnus-summary-select-article t)
1345 (set-buffer gnus-original-article-buffer)
1346 (gnus-setup-message 'compose-bounce
1347 (let* ((references (mail-fetch-field "references"))
1348 (parent (and references (gnus-parent-id references))))
1350 ;; If there are references, we fetch the article we answered to.
1352 (gnus-summary-refer-article parent)
1353 (gnus-summary-show-all-headers)))))
1357 (defun gnus-inews-group-method (group)
1359 ;; If the group doesn't exist, we assume
1360 ;; it's an archive group...
1361 ((and (null (gnus-get-info group))
1362 (eq (car (gnus-server-to-method gnus-message-archive-method))
1363 (car (gnus-server-to-method (gnus-group-method group)))))
1364 gnus-message-archive-method)
1366 ((gnus-info-method (gnus-get-info group))
1367 (gnus-info-method (gnus-get-info group)))
1369 (t (gnus-server-to-method (gnus-group-method group)))))
1371 ;; Do Gcc handling, which copied the message over to some group.
1372 (defun gnus-inews-do-gcc (&optional gcc)
1376 (message-narrow-to-headers)
1377 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
1378 (cur (current-buffer))
1379 groups group method group-art
1380 mml-externalize-attachments)
1382 (message-remove-header "gcc")
1384 (setq groups (message-unquote-tokens
1385 (message-tokenize-header gcc " ,")))
1386 ;; Copy the article over to some group(s).
1387 (while (setq group (pop groups))
1388 (unless (gnus-check-server
1389 (setq method (gnus-inews-group-method group)))
1390 (error "Can't open server %s" (if (stringp method) method
1392 (unless (gnus-request-group group nil method)
1393 (gnus-request-create-group group method))
1394 (setq mml-externalize-attachments
1395 (if (stringp gnus-gcc-externalize-attachments)
1396 (string-match gnus-gcc-externalize-attachments group)
1397 gnus-gcc-externalize-attachments))
1399 (nnheader-set-temp-buffer " *acc*")
1400 (insert-buffer-substring cur)
1401 (message-encode-message-body)
1403 (message-narrow-to-headers)
1404 (let* ((mail-parse-charset message-default-charset)
1405 (newsgroups-field (save-restriction
1406 (message-narrow-to-headers-or-head)
1407 (message-fetch-field "Newsgroups")))
1408 (followup-field (save-restriction
1409 (message-narrow-to-headers-or-head)
1410 (message-fetch-field "Followup-To")))
1411 ;; BUG: We really need to get the charset for
1412 ;; each name in the Newsgroups and Followup-To
1413 ;; lines to allow crossposting between group
1414 ;; namess with incompatible character sets.
1415 ;; -- Per Abrahamsen <abraham@dina.kvl.dk> 2001-10-08.
1416 (group-field-charset
1417 (gnus-group-name-charset
1418 method (or newsgroups-field "")))
1419 (followup-field-charset
1420 (gnus-group-name-charset
1421 method (or followup-field "")))
1422 (rfc2047-header-encoding-alist
1424 (when group-field-charset
1425 (list (cons "Newsgroups" group-field-charset)))
1426 (when followup-field-charset
1427 (list (cons "Followup-To" followup-field-charset)))
1428 rfc2047-header-encoding-alist)))
1429 (mail-encode-encoded-word-buffer)))
1430 (goto-char (point-min))
1431 (when (re-search-forward
1432 (concat "^" (regexp-quote mail-header-separator) "$")
1434 (replace-match "" t t ))
1435 (unless (setq group-art
1436 (gnus-request-accept-article group method t t))
1437 (gnus-message 1 "Couldn't store article in group %s: %s"
1438 group (gnus-status-message method))
1440 (when (and group-art
1441 (or gnus-gcc-mark-as-read
1442 gnus-inews-mark-gcc-as-read))
1443 (gnus-group-mark-article-read group (cdr group-art)))
1444 (kill-buffer (current-buffer)))))))))
1446 (defun gnus-inews-insert-gcc ()
1447 "Insert Gcc headers based on `gnus-outgoing-message-group'."
1450 (message-narrow-to-headers)
1451 (let* ((group gnus-outgoing-message-group)
1453 ((gnus-functionp group)
1455 ((or (stringp group) (list group))
1459 (if (stringp gcc) gcc
1460 (mapconcat 'identity gcc " "))
1463 (defun gnus-inews-insert-archive-gcc (&optional group)
1464 "Insert the Gcc to say where the article is to be archived."
1465 (let* ((var gnus-message-archive-group)
1466 (group (or group gnus-newsgroup-name ""))
1468 (and gnus-newsgroup-name
1469 (not (equal gnus-newsgroup-name ""))
1470 (gnus-group-find-parameter
1471 gnus-newsgroup-name 'gcc-self)))
1475 ((null gnus-message-archive-method)
1479 ;; Just a single group.
1482 ;; We don't want this.
1484 ((and (listp var) (stringp (car var)))
1485 ;; A list of groups.
1487 ((gnus-functionp var)
1489 (funcall var group))
1491 ;; An alist of regexps/functions/forms.
1496 ((stringp (caar var))
1498 (when (string-match (caar var) group)
1500 ((gnus-functionp (car var))
1502 (funcall (car var) group))
1504 (eval (car var)))))))
1505 (setq var (cdr var)))
1508 (when (or groups gcc-self-val)
1509 (when (stringp groups)
1510 (setq groups (list groups)))
1513 (message-narrow-to-headers)
1514 (goto-char (point-max))
1517 ;; Use the `gcc-self' param value instead.
1520 (if (stringp gcc-self-val)
1523 (if (not (eq gcc-self-val 'none))
1528 ;; Use the list of groups.
1529 (while (setq name (pop groups))
1530 (insert (if (string-match ":" name)
1532 (gnus-group-prefixed-name
1533 name gnus-message-archive-method)))
1540 (defun gnus-configure-posting-styles (&optional group-name)
1541 "Configure posting styles according to `gnus-posting-styles'."
1542 (unless gnus-inhibit-posting-styles
1543 (let ((group (or group-name gnus-newsgroup-name ""))
1544 (styles gnus-posting-styles)
1545 style match variable attribute value v results
1546 filep name address element)
1547 ;; If the group has a posting-style parameter, add it at the end with a
1548 ;; regexp matching everything, to be sure it takes precedence over all
1550 (when gnus-newsgroup-name
1551 (let ((tmp-style (gnus-group-find-parameter group 'posting-style t)))
1553 (setq styles (append styles (list (cons ".*" tmp-style)))))))
1554 ;; Go through all styles and look for matches.
1555 (dolist (style styles)
1556 (setq match (pop style))
1557 (goto-char (point-min))
1560 ;; Regexp string match on the group name.
1561 (string-match match group))
1563 (and (gnus-buffer-live-p gnus-article-copy)
1564 (with-current-buffer gnus-article-copy
1565 (let ((header (message-fetch-field (pop style))))
1567 (string-match (pop style) header))))))
1568 ((or (symbolp match)
1569 (gnus-functionp match))
1571 ((gnus-functionp match)
1572 ;; Function to be called.
1575 ;; Variable to be checked.
1576 (symbol-value match))))
1578 ;; This is a form to be evaled.
1580 ;; We have a match, so we set the variables.
1581 (dolist (attribute style)
1582 (setq element (pop attribute)
1587 ((eq (car attribute) :file)
1590 ((eq (car attribute) :value)
1594 ;; We get the value.
1599 ((or (symbolp value)
1600 (gnus-functionp value))
1601 (cond ((gnus-functionp value)
1604 (symbol-value value))))
1607 ;; Translate obsolescent value.
1608 (when (eq element 'signature-file)
1609 (setq element 'signature
1611 ;; Get the contents of file elems.
1613 (setq v (with-temp-buffer
1614 (insert-file-contents v)
1616 (setq results (delq (assoc element results) results))
1617 (push (cons element v) results))))
1618 ;; Now we have all the styles, so we insert them.
1619 (setq name (assq 'name results)
1620 address (assq 'address results))
1621 (setq results (delq name (delq address results)))
1622 ;; make-local-hook is not obsolete in Emacs 20 or XEmacs.
1623 (make-local-hook 'message-setup-hook)
1624 (dolist (result results)
1625 (add-hook 'message-setup-hook
1627 ((eq 'eval (car result))
1629 ((eq 'body (car result))
1633 (insert ,(cdr result)))))
1634 ((eq 'signature (car result))
1635 (set (make-local-variable 'message-signature) nil)
1636 (set (make-local-variable 'message-signature-file) nil)
1637 (if (not (cdr result))
1641 (let ((message-signature ,(cdr result)))
1642 (when message-signature
1643 (message-insert-signature)))))))
1646 (if (symbolp (car result))
1647 (capitalize (symbol-name (car result)))
1651 (message-remove-header ,header)
1652 (let ((value ,(cdr result)))
1655 (insert ,header ": " value "\n"))))))))
1657 (when (or name address)
1658 (add-hook 'message-setup-hook
1660 (set (make-local-variable 'user-mail-address)
1661 ,(or (cdr address) user-mail-address))
1662 (let ((user-full-name ,(or (cdr name) (user-full-name)))
1664 ,(or (cdr address) user-mail-address)))
1666 (message-remove-header "From")
1668 (insert "From: " (message-make-from) "\n"))))
1671 ;;; Allow redefinition of functions.
1677 ;;; gnus-msg.el ends here