1 ;;; gnus-msg.el --- mail and post interface for Semi-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>
7 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
8 ;; Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp>
9 ;; Katsumi Yamaoka <yamaoka@jpl.org>
10 ;; Kiyokazu SUTO <suto@merry.xmath.ous.ac.jp>
11 ;; Keywords: mail, news, MIME
13 ;; This file is part of GNU Emacs.
15 ;; GNU Emacs is free software; you can redistribute it and/or modify
16 ;; it under the terms of the GNU General Public License as published by
17 ;; the Free Software Foundation; either version 2, or (at your option)
20 ;; GNU Emacs is distributed in the hope that it will be useful,
21 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 ;; GNU General Public License for more details.
25 ;; You should have received a copy of the GNU General Public License
26 ;; along with GNU Emacs; see the file COPYING. If not, write to the
27 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
28 ;; Boston, MA 02111-1307, USA.
34 (eval-when-compile (require 'cl))
35 (eval-when-compile (require 'static))
42 (defcustom gnus-post-method 'current
43 "*Preferred method for posting USENET news.
45 If this variable is `current' (which is the default), Gnus will use
46 the \"current\" select method when posting. If it is `native', Gnus
47 will use the native select method when posting.
49 This method will not be used in mail groups and the like, only in
52 If not `native' nor `current', the value must be a valid method as discussed
53 in the documentation of `gnus-select-method'. It can also be a list of
54 methods. If that is the case, the user will be queried for what select
55 method to use when posting."
56 :group 'gnus-group-foreign
57 :link '(custom-manual "(gnus)Posting Server")
58 :type `(choice (const native)
60 (sexp :tag "Methods" ,gnus-select-method)))
62 (defcustom gnus-outgoing-message-group nil
63 "*All outgoing messages will be put in this group.
64 If you want to store all your outgoing mail and articles in the group
65 \"nnml:archive\", you set this variable to that value. This variable
66 can also be a list of group names.
68 If you want to have greater control over what group to put each
69 message in, you can set this variable to a function that checks the
70 current newsgroup name and then returns a suitable group name (or list
73 :type '(choice (string :tag "Group")
76 (defcustom gnus-mailing-list-groups nil
77 "*Regexp matching groups that are really mailing lists.
78 This is useful when you're reading a mailing list that has been
79 gatewayed to a newsgroup, and you want to followup to an article in
84 (defcustom gnus-add-to-list nil
85 "*If non-nil, add a `to-list' parameter automatically."
89 (defcustom gnus-crosspost-complaint
92 You posted the article below with the following Newsgroups header:
96 The %s group, at least, was an inappropriate recipient
97 of this message. Please trim your Newsgroups header to exclude this
98 group before posting in the future.
103 "Format string to be inserted when complaining about crossposts.
104 The first %s will be replaced by the Newsgroups header;
105 the second with the current group name."
109 (defcustom gnus-message-setup-hook nil
110 "Hook run after setting up a message buffer."
114 (defcustom gnus-bug-create-help-buffer t
115 "*Should we create the *Gnus Help Bug* buffer?"
119 (defcustom gnus-posting-styles nil
120 "*Alist of styles to use when posting.
121 See Info node `(gnus)Posting Styles'."
123 :type '(repeat (cons (choice (regexp)
126 (string :tag "Header")
127 (regexp :tag "Regexp"))
131 (choice (const signature)
132 (const signature-file)
139 (string :tag "Header"))
145 (defcustom gnus-gcc-mark-as-read nil
146 "If non-nil, automatically mark Gcc articles as read."
151 (defvar gnus-inews-mark-gcc-as-read nil
152 "Obsolete variable. Use `gnus-gcc-mark-as-read' instead.")
154 (make-obsolete-variable 'gnus-inews-mark-gcc-as-read
155 'gnus-gcc-mark-as-read)
157 (defcustom gnus-gcc-externalize-attachments nil
158 "Should local-file attachments be included as external parts in Gcc copies?
159 If it is `all', attach files as external parts;
160 if a regexp and matches the Gcc group name, attach files as external parts;
161 If nil, attach files as normal parts."
164 :type '(choice (const nil :tag "None")
165 (const all :tag "Any")
166 (string :tag "Regexp")))
168 (defcustom gnus-group-posting-charset-alist
169 '(("^\\(no\\|fr\\)\\.[^,]*\\(,[ \t\n]*\\(no\\|fr\\)\\.[^,]*\\)*$" iso-8859-1 (iso-8859-1))
170 ("^\\(fido7\\|relcom\\)\\.[^,]*\\(,[ \t\n]*\\(fido7\\|relcom\\)\\.[^,]*\\)*$" koi8-r (koi8-r))
171 (message-this-is-mail nil nil)
172 (message-this-is-news nil t))
173 "Alist of regexps and permitted unencoded charsets for posting.
174 Each element of the alist has the form (TEST HEADER BODY-LIST), where
175 TEST is either a regular expression matching the newsgroup header or a
177 HEADER is the charset which may be left unencoded in the header (nil
178 means encode all charsets),
179 BODY-LIST is a list of charsets which may be encoded using 8bit
180 content-transfer encoding in the body, or one of the special values
181 nil (always encode using quoted-printable) or t (always use 8bit).
183 Note that any value other than nil for HEADER infringes some RFCs, so
184 use this option with care."
185 :type '(repeat (list :tag "Permitted unencoded charsets"
187 (regexp :tag "Group")
188 (const :tag "Mail message"
189 :value message-this-is-mail)
190 (const :tag "News article"
191 :value message-this-is-news))
192 (choice :tag "Header"
193 (const :tag "None" nil)
194 (symbol :tag "Charset"))
196 (const :tag "Any" :value t)
197 (const :tag "None" :value nil)
198 (repeat :tag "Charsets"
199 (symbol :tag "Charset")))))
200 :group 'gnus-charset)
202 (defcustom gnus-debug-files
203 '("gnus.el" "gnus-sum.el" "gnus-group.el"
204 "gnus-art.el" "gnus-start.el" "gnus-async.el"
205 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
206 "gnus-agent.el" "gnus-cache.el" "gnus-srvr.el"
207 "mm-util.el" "mm-decode.el" "nnmail.el" "nntp.el" "message.el")
208 "Files whose variables will be reported in `gnus-bug'."
211 :type '(repeat (string :tag "File")))
213 (defcustom gnus-debug-exclude-variables
214 '(mm-mime-mule-charset-alist
215 nnmail-split-fancy message-minibuffer-local-map)
216 "Variables that should not be reported in `gnus-bug'."
219 :type '(repeat (symbol :tag "Variable")))
221 (defcustom gnus-discouraged-post-methods
222 '(nndraft nnml nnimap nnmaildir nnmh nnfolder nndir)
223 "A list of back ends that are not used in \"real\" newsgroups.
224 This variable is used only when `gnus-post-method' is `current'."
226 :group 'gnus-group-foreign
227 :type '(repeat (symbol :tag "Back end")))
229 (defcustom gnus-message-replysign
231 "Automatically sign replys to signed messages.
232 See also the `mml-default-sign-method' variable."
236 (defcustom gnus-message-replyencrypt
238 "Automatically encrypt replys to encrypted messages.
239 See also the `mml-default-encrypt-method' variable."
243 (defcustom gnus-message-replysignencrypted
245 "Setting this causes automatically encryped messages to also be signed."
249 (defcustom gnus-confirm-mail-reply-to-news nil
250 "If non-nil, Gnus requests confirmation when replying to news.
251 This is done because new users often reply by mistake when reading
256 (defcustom gnus-summary-resend-default-address t
257 "If non-nil, Gnus tries to suggest a default address to resend to.
258 If nil, the address field will always be empty after invoking
259 `gnus-summary-resend-message'."
263 ;;; Internal variables.
265 (defvar gnus-inhibit-posting-styles nil
266 "Inhibit the use of posting styles.")
268 (defvar gnus-message-buffer "*Mail Gnus*")
269 (defvar gnus-article-copy nil)
270 (defvar gnus-check-before-posting nil)
271 (defvar gnus-last-posting-server nil)
272 (defvar gnus-message-group-art nil)
274 (defvar gnus-msg-force-broken-reply-to nil)
276 (defconst gnus-bug-message
277 (format "Sending a bug report to the Gnus Towers.
278 ========================================
280 This gnus is the %s%s.
281 If you think the bug is a Semi-gnus bug, send a bug report to Semi-gnus
282 Developers. (the addresses below are mailing list addresses)
284 ========================================
286 The buffer below is a mail buffer. When you press `C-c C-c', it will
287 be sent to the Gnus Bug Exterminators.
289 The thing near the bottom of the buffer is how the environment
290 settings will be included in the mail. Please do not delete that.
291 They will tell the Bug People what your environment is, so that it
292 will be easier to locate the bugs.
294 If you have found a bug that makes Emacs go \"beep\", set
295 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
296 and include the backtrace in your bug report.
298 Please describe the bug in annoying, painstaking detail.
300 Thank you for your help in stamping out bugs.
303 (if (string= gnus-product-name "Semi-gnus")
305 ", a modified version of Semi-gnus")))
308 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
309 (autoload 'news-setup "rnewspost")
310 (autoload 'news-reply-mode "rnewspost")
311 (autoload 'rmail-dont-reply-to "mail-utils")
312 (autoload 'rmail-output "rmailout"))
316 ;;; Gnus Posting Functions
319 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
320 "p" gnus-summary-post-news
321 "i" gnus-summary-news-other-window
322 "f" gnus-summary-followup
323 "F" gnus-summary-followup-with-original
324 "c" gnus-summary-cancel-article
325 "s" gnus-summary-supersede-article
326 "r" gnus-summary-reply
327 "y" gnus-summary-yank-message
328 "R" gnus-summary-reply-with-original
329 "w" gnus-summary-wide-reply
330 "W" gnus-summary-wide-reply-with-original
331 "v" gnus-summary-very-wide-reply
332 "V" gnus-summary-very-wide-reply-with-original
333 "n" gnus-summary-followup-to-mail
334 "N" gnus-summary-followup-to-mail-with-original
335 "m" gnus-summary-mail-other-window
336 "u" gnus-uu-post-news
337 "\M-c" gnus-summary-mail-crosspost-complaint
338 "Br" gnus-summary-reply-broken-reply-to
339 "BR" gnus-summary-reply-broken-reply-to-with-original
340 "om" gnus-summary-mail-forward
341 "op" gnus-summary-post-forward
342 "Om" gnus-summary-digest-mail-forward
343 "Op" gnus-summary-digest-post-forward)
345 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
346 "b" gnus-summary-resend-bounced-mail
347 ;; "c" gnus-summary-send-draft
348 "r" gnus-summary-resend-message
349 "e" gnus-summary-resend-message-edit)
351 ;;; Internal functions.
353 (defvar gnus-article-reply nil)
354 (defmacro gnus-setup-message (config &rest forms)
355 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
356 (buffer (make-symbol "gnus-setup-message-buffer"))
357 (article (make-symbol "gnus-setup-message-article"))
358 (group (make-symbol "gnus-setup-message-group")))
359 `(let ((,winconf (current-window-configuration))
360 (,buffer (buffer-name (current-buffer)))
361 (,article gnus-article-reply)
362 (,group gnus-newsgroup-name)
363 (message-header-setup-hook
364 (copy-sequence message-header-setup-hook))
365 (message-mode-hook (copy-sequence message-mode-hook))
366 (message-startup-parameter-alist
367 '((reply-buffer . gnus-copy-article-buffer)
368 (original-buffer . gnus-original-article-buffer)
369 (user-agent . Gnus))))
370 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
371 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
372 ;; #### FIXME: for a reason that I did not manage to identify yet,
373 ;; the variable `gnus-newsgroup-name' does not honor a dynamically
374 ;; scoped or setq'ed value from a caller like `C-u gnus-summary-mail'.
375 ;; After evaluation of @forms below, it gets the value we actually want
376 ;; to override, and the posting styles are used. For that reason, I've
377 ;; added an optional argument to `gnus-configure-posting-styles' to
378 ;; make sure that the correct value for the group name is used. -- drv
379 (add-hook 'message-mode-hook
381 (gnus-configure-posting-styles ,group)))
385 (gnus-inews-add-send-actions ,winconf ,buffer ,article ,config)
386 (gnus-inews-insert-draft-meta-information ,group ,article)
387 (setq gnus-message-buffer (current-buffer))
388 (set (make-local-variable 'gnus-message-group-art)
389 (cons ,group ,article))
390 (set (make-local-variable 'gnus-newsgroup-name) ,group)
391 (gnus-maybe-setup-default-charset)
392 (gnus-run-hooks 'gnus-message-setup-hook))
394 (gnus-configure-windows ,config t)
395 (run-hooks 'post-command-hook)
396 (set-buffer-modified-p nil))))
398 (defun gnus-inews-insert-draft-meta-information (group article)
401 (not (string= group ""))
402 (not (message-fetch-field gnus-draft-meta-information-header)))
403 (goto-char (point-min))
404 (insert gnus-draft-meta-information-header ": (\"" group "\" "
405 (if article (number-to-string
412 (defun gnus-msg-mail (&optional to subject other-headers continue
413 switch-action yank-action send-actions)
414 "Start editing a mail message to be sent.
415 Like `message-mail', but with Gnus paraphernalia, particularly the
416 Gcc: header for archiving purposes."
418 (let ((buf (current-buffer))
420 (gnus-setup-message 'message
421 (message-mail to subject other-headers continue
422 nil yank-action send-actions))
424 (setq mail-buf (current-buffer))
425 (switch-to-buffer buf)
426 (apply switch-action mail-buf nil)))
427 ;; COMPOSEFUNC should return t if succeed. Undocumented ???
430 (defvar save-selected-window-window)
433 (defun gnus-button-mailto (address)
435 (set-buffer (gnus-copy-article-buffer))
436 (gnus-setup-message 'message
437 (message-reply address))
438 (and (boundp 'save-selected-window-window)
439 (not (window-live-p save-selected-window-window))
440 (setq save-selected-window-window (selected-window))))
443 (defun gnus-button-reply (&optional to-address wide)
444 "Like `message-reply'."
446 (gnus-setup-message 'message
447 (message-reply to-address wide))
448 (and (boundp 'save-selected-window-window)
449 (not (window-live-p save-selected-window-window))
450 (setq save-selected-window-window (selected-window))))
453 (define-mail-user-agent 'gnus-user-agent
454 'gnus-msg-mail 'message-send-and-exit
455 'message-kill-buffer 'message-send-hook)
457 (defun gnus-setup-posting-charset (group)
458 (let ((alist gnus-group-posting-charset-alist)
459 (group (or group ""))
463 (while (setq elem (pop alist))
464 (when (or (and (stringp (car elem))
465 (string-match (car elem) group))
466 (and (gnus-functionp (car elem))
467 (funcall (car elem) group))
468 (and (symbolp (car elem))
469 (symbol-value (car elem))))
470 (throw 'found (cons (cadr elem) (caddr elem)))))))))
472 (defun gnus-inews-add-send-actions (winconf buffer article &optional config)
473 (make-local-hook 'message-sent-hook)
474 (add-hook 'message-sent-hook (if gnus-agent 'gnus-agent-possibly-do-gcc
475 'gnus-inews-do-gcc) nil t)
477 (make-local-hook 'message-header-hook)
478 (add-hook 'message-header-hook 'gnus-agent-possibly-save-gcc nil t))
479 (setq message-post-method
481 (gnus-post-method arg ,gnus-newsgroup-name)))
482 (setq message-user-agent (gnus-extended-version))
483 (when (not message-use-multi-frames)
485 `(set-window-configuration ,winconf) 'exit 'postpone 'kill))
487 `(when (gnus-buffer-exists-p ,buffer)
491 (if (eq config 'forward)
492 `(gnus-summary-mark-article-as-forwarded ',article)
493 `(gnus-summary-mark-article-as-replied ',article)))))
496 (put 'gnus-setup-message 'lisp-indent-function 1)
497 (put 'gnus-setup-message 'edebug-form-spec '(form body))
499 ;;; Post news commands of Gnus group mode and summary mode
501 (defun gnus-group-mail (&optional arg)
502 "Start composing a mail.
503 If ARG, use the group under the point to find a posting style.
504 If ARG is 1, prompt for a group name to find the posting style."
506 ;; We can't `let' gnus-newsgroup-name here, since that leads
507 ;; to local variables leaking.
508 (let ((group gnus-newsgroup-name)
509 ;; make sure last viewed article doesn't affect posting styles:
511 (buffer (current-buffer)))
514 (setq gnus-newsgroup-name
516 (if (= 1 (prefix-numeric-value arg))
517 (completing-read "Use posting style of group: "
518 gnus-active-hashtb nil
519 (gnus-read-active-file-p))
520 (gnus-group-group-name))
522 ;; #### see comment in gnus-setup-message -- drv
523 (gnus-setup-message 'message (message-mail)))
526 (setq gnus-newsgroup-name group)))))
528 (defun gnus-group-news (&optional arg)
529 "Start composing a news.
530 If ARG, post to group under point.
531 If ARG is 1, prompt for group name to post to.
533 This function prepares a news even when using mail groups. This is useful
534 for posting messages to mail groups without actually sending them over the
535 network. The corresponding backend must have a 'request-post method."
537 ;; We can't `let' gnus-newsgroup-name here, since that leads
538 ;; to local variables leaking.
539 (let ((group gnus-newsgroup-name)
540 ;; make sure last viewed article doesn't affect posting styles:
542 (buffer (current-buffer)))
545 (setq gnus-newsgroup-name
547 (if (= 1 (prefix-numeric-value arg))
548 (completing-read "Use group: "
549 gnus-active-hashtb nil
550 (gnus-read-active-file-p))
551 (gnus-group-group-name))
553 ;; #### see comment in gnus-setup-message -- drv
554 (gnus-setup-message 'message
555 (message-news (gnus-group-real-name gnus-newsgroup-name))))
558 (setq gnus-newsgroup-name group)))))
560 (defun gnus-group-post-news (&optional arg)
561 "Start composing a message (a news by default).
562 If ARG, post to group under point. If ARG is 1, prompt for group name.
563 Depending on the selected group, the message might be either a mail or
566 ;; Bind this variable here to make message mode hooks work ok.
567 (let ((gnus-newsgroup-name
569 (if (= 1 (prefix-numeric-value arg))
570 (completing-read "Newsgroup: " gnus-active-hashtb nil
571 (gnus-read-active-file-p))
572 (gnus-group-group-name))
574 ;; make sure last viewed article doesn't affect posting styles:
576 (gnus-post-news 'post gnus-newsgroup-name)))
578 (defun gnus-summary-mail-other-window (&optional arg)
579 "Start composing a mail in another window.
580 Use the posting of the current group by default.
581 If ARG, don't do that. If ARG is 1, prompt for group name to find the
584 ;; We can't `let' gnus-newsgroup-name here, since that leads
585 ;; to local variables leaking.
586 (let ((group gnus-newsgroup-name)
587 ;; make sure last viewed article doesn't affect posting styles:
589 (buffer (current-buffer)))
592 (setq gnus-newsgroup-name
594 (if (= 1 (prefix-numeric-value arg))
595 (completing-read "Use group: "
596 gnus-active-hashtb nil
597 (gnus-read-active-file-p))
599 gnus-newsgroup-name))
600 ;; #### see comment in gnus-setup-message -- drv
601 (gnus-setup-message 'message (message-mail)))
604 (setq gnus-newsgroup-name group)))))
606 (defun gnus-summary-news-other-window (&optional arg)
607 "Start composing a news in another window.
608 Post to the current group by default.
609 If ARG, don't do that. If ARG is 1, prompt for group name to post to.
611 This function prepares a news even when using mail groups. This is useful
612 for posting messages to mail groups without actually sending them over the
613 network. The corresponding backend must have a 'request-post method."
615 ;; We can't `let' gnus-newsgroup-name here, since that leads
616 ;; to local variables leaking.
617 (let ((group gnus-newsgroup-name)
618 ;; make sure last viewed article doesn't affect posting styles:
620 (buffer (current-buffer)))
623 (setq gnus-newsgroup-name
625 (if (= 1 (prefix-numeric-value arg))
626 (completing-read "Use group: "
627 gnus-active-hashtb nil
628 (gnus-read-active-file-p))
630 gnus-newsgroup-name))
631 ;; #### see comment in gnus-setup-message -- drv
632 (gnus-setup-message 'message
633 (message-news (gnus-group-real-name gnus-newsgroup-name))))
636 (setq gnus-newsgroup-name group)))))
638 (defun gnus-summary-post-news (&optional arg)
639 "Start composing a message. Post to the current group by default.
640 If ARG, don't do that. If ARG is 1, prompt for a group name to post to.
641 Depending on the selected group, the message might be either a mail or
644 ;; Bind this variable here to make message mode hooks work ok.
645 (let ((gnus-newsgroup-name
647 (if (= 1 (prefix-numeric-value arg))
648 (completing-read "Newsgroup: " gnus-active-hashtb nil
649 (gnus-read-active-file-p))
651 gnus-newsgroup-name))
652 ;; make sure last viewed article doesn't affect posting styles:
654 (gnus-post-news 'post gnus-newsgroup-name)))
657 (defun gnus-summary-followup (yank &optional force-news)
658 "Compose a followup to an article.
659 If prefix argument YANK is non-nil, the original article is yanked
661 YANK is a list of elements, where the car of each element is the
662 article number, and the two following numbers is the region to be
665 (list (and current-prefix-arg
666 (gnus-summary-work-articles 1))))
668 (gnus-summary-goto-subject
669 (if (listp (car yank))
672 (save-window-excursion
673 (gnus-summary-select-article))
674 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
675 (gnus-newsgroup-name gnus-newsgroup-name))
677 (gnus-post-news nil gnus-newsgroup-name
678 headers gnus-article-buffer
680 (gnus-summary-handle-replysign)))
682 (defun gnus-summary-followup-with-original (n &optional force-news)
683 "Compose a followup to an article and include the original article."
685 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
687 (defun gnus-summary-followup-to-mail (&optional arg)
688 "Followup to the current mail message via news."
690 (list (and current-prefix-arg
691 (gnus-summary-work-articles 1))))
692 (gnus-summary-followup arg t))
694 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
695 "Followup to the current mail message via news."
697 (gnus-summary-followup (gnus-summary-work-articles arg) t))
699 (defun gnus-inews-yank-articles (articles)
700 (let (beg article yank-string
701 (more-than-one (cdr articles))
702 (cur (current-buffer))
705 (while (setq article (pop articles))
706 (when (listp article)
707 (setq yank-string (nth 1 article)
708 article (nth 0 article)))
709 (save-window-excursion
710 (set-buffer gnus-summary-buffer)
711 (gnus-summary-select-article nil nil nil article)
712 (gnus-summary-remove-process-mark article))
714 ;; Gathering references.
716 (setq refs (message-list-references
718 (mail-header-references gnus-current-headers)
719 (mail-header-message-id gnus-current-headers)))
720 (when message-use-multi-frames
721 (when (setq window (get-buffer-window cur t))
722 (select-frame (window-frame window)))))
724 (gnus-copy-article-buffer nil yank-string)
725 (let ((message-reply-buffer gnus-article-copy)
726 (message-reply-headers
727 ;; The headers are decoded.
728 (with-current-buffer gnus-article-copy
730 (nnheader-narrow-to-headers)
731 (ietf-drums-unfold-fws)
732 (nnheader-parse-head t)))))
733 (message-yank-original)
734 (setq beg (or beg (mark t))))
739 ;; Replace with the gathered references.
743 (message-narrow-to-headers)
744 (let ((case-fold-search t))
745 (if (re-search-forward "^References:\\([\t ]+.+\n\\)+" nil t)
747 (goto-char (point-max))))
749 (list (or (assq 'References message-header-format-alist)
750 '(References . message-shorten-references)))
751 (list (cons 'References
752 (mapconcat 'identity (nreverse refs) " "))))
753 (backward-delete-char 1))
759 (defun gnus-summary-cancel-article (&optional n symp)
760 "Cancel an article you posted.
761 Uses the process-prefix convention. If given the symbolic
762 prefix `a', cancel using the standard posting method; if not
763 post using the current select method."
764 (interactive (gnus-interactive "P\ny"))
765 (let ((articles (gnus-summary-work-articles n))
768 (gnus-post-method (eq ',symp 'a) ,gnus-newsgroup-name)))
770 (while (setq article (pop articles))
771 (when (gnus-summary-select-article t nil nil article)
772 (when (gnus-eval-in-buffer-window gnus-article-buffer
774 (set-buffer gnus-original-article-buffer)
775 (message-cancel-news)))
776 (gnus-summary-mark-as-read article gnus-canceled-mark)
777 (gnus-cache-remove-article 1))
778 (gnus-article-hide-headers-if-wanted))
779 (gnus-summary-remove-process-mark article))))
781 (defun gnus-summary-supersede-article ()
782 "Compose an article that will supersede a previous article.
783 This is done simply by taking the old article and adding a Supersedes
784 header line with the old Message-ID."
786 (let ((article (gnus-summary-article-number)))
787 (gnus-setup-message 'reply-yank
788 (gnus-summary-select-article t)
789 (set-buffer gnus-original-article-buffer)
793 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
795 (set-buffer ,gnus-summary-buffer)
796 (gnus-cache-possibly-remove-article ,article nil nil nil t)
797 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
798 message-send-actions))))
802 (defun gnus-copy-article-buffer (&optional article-buffer yank-string)
803 ;; make a copy of the article buffer with all text properties removed
804 ;; this copy is in the buffer gnus-article-copy.
805 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
806 ;; this buffer should be passed to all mail/news reply/post routines.
807 (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
809 (set-buffer gnus-article-copy)
810 (set-buffer-multibyte t))
811 (let ((article-buffer (or article-buffer gnus-article-buffer))
813 (if (not (and (get-buffer article-buffer)
814 (gnus-buffer-exists-p article-buffer)))
815 (error "Can't find any article buffer")
817 (set-buffer article-buffer)
818 (let ((gnus-newsgroup-charset (or gnus-article-charset
819 gnus-newsgroup-charset))
820 (gnus-newsgroup-ignored-charsets
821 (or gnus-article-ignored-charsets
822 gnus-newsgroup-ignored-charsets)))
824 ;; Copy over the (displayed) article buffer, delete
825 ;; hidden text and remove text properties.
827 (copy-to-buffer gnus-article-copy (point-min) (point-max))
828 (set-buffer gnus-article-copy)
829 ;; There's invisible and intangible text in T-gnus. Especially,
830 ;; if there is a boundary line (X-Boundary: ------------------),
831 ;; in the end of a header, it will cause a serious problem.
832 (add-text-properties (point-min) (point-max)
833 '(invisible nil intangible nil))
836 (delete-region (point) (point-max))
837 (insert yank-string))
838 ;; Encode bitmap smileys to ordinary text.
839 ;; Possibly, the original text might be restored.
840 (static-unless (featurep 'xemacs)
841 (when (featurep 'smiley-mule)
842 (smiley-encode-buffer)))
843 (gnus-article-delete-text-of-type 'annotation)
844 (gnus-remove-text-with-property 'gnus-prev)
845 (gnus-remove-text-with-property 'gnus-next)
846 (gnus-remove-text-with-property 'gnus-decoration)
847 (gnus-remove-text-with-property 'x-face-mule-bitmap-image)
850 (static-if (featurep 'xemacs)
851 ;; Revome smiley extents for (possibly) XEmacs 21.1.
853 (buffer-substring-no-properties (point-min)
855 (buffer-substring-no-properties (point-min) (point-max)))
857 ;; Find the original headers.
858 (set-buffer gnus-original-article-buffer)
859 (goto-char (point-min))
860 (while (looking-at message-unix-mail-delimiter)
863 end (or (message-goto-body) beg))
864 ;; Delete the headers from the displayed articles.
865 (set-buffer gnus-article-copy)
866 (delete-region (goto-char (point-min))
867 (or (message-goto-body) (point-max)))
868 ;; Insert the original article headers.
869 (insert-buffer-substring gnus-original-article-buffer beg end)
871 (let ((gnus-article-decode-hook
872 (delq 'article-decode-charset
873 (copy-sequence gnus-article-decode-hook))))
874 ;; Needed for T-gnus.
875 (add-hook 'gnus-article-decode-hook
876 'article-decode-encoded-words)
877 (run-hooks 'gnus-article-decode-hook)))))
880 (defun gnus-post-news (post &optional group header article-buffer yank subject
883 (gnus-copy-article-buffer))
884 (let ((gnus-article-reply (and article-buffer (gnus-summary-article-number)))
885 (add-to-list gnus-add-to-list))
886 (gnus-setup-message (cond (yank 'reply-yank)
887 (article-buffer 'reply)
889 (let* ((group (or group gnus-newsgroup-name))
890 (charset (gnus-group-name-charset nil group))
892 to-address to-group mailing-list to-list
895 (setq to-address (gnus-parameter-to-address group)
896 to-group (gnus-group-find-parameter group 'to-group)
897 to-list (gnus-parameter-to-list group)
898 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
899 mailing-list (when gnus-mailing-list-groups
900 (string-match gnus-mailing-list-groups group))
901 group (gnus-group-name-decode (gnus-group-real-name group)
903 (if (or (and to-group
904 (gnus-news-group-p to-group))
907 (and (gnus-news-group-p
908 (or pgroup gnus-newsgroup-name)
909 (or header gnus-current-article))
915 (message-news (or to-group group))
916 (set-buffer gnus-article-copy)
917 (gnus-msg-treat-broken-reply-to)
918 (message-followup (if (or newsgroup-p force-news)
919 (if (save-restriction
920 (article-narrow-to-head)
921 (message-fetch-field "newsgroups"))
928 (message-mail (or to-address to-list))
929 ;; Arrange for mail groups that have no `to-address' to
930 ;; get that when the user sends off the mail.
931 (when (and (not to-list)
934 (push (list 'gnus-inews-add-to-address pgroup)
935 message-send-actions)))
936 (set-buffer gnus-article-copy)
937 (gnus-msg-treat-broken-reply-to)
938 (message-wide-reply to-address)))
940 (gnus-inews-yank-articles yank))))))
942 (defun gnus-msg-treat-broken-reply-to (&optional force)
943 "Remove the Reply-to header iff broken-reply-to."
945 (gnus-group-find-parameter
946 gnus-newsgroup-name 'broken-reply-to))
948 (message-narrow-to-head)
949 (message-remove-header "reply-to"))))
951 (defun gnus-post-method (arg group &optional silent)
952 "Return the posting method based on GROUP and ARG.
953 If SILENT, don't prompt the user."
954 (let ((gnus-post-method (or (gnus-parameter-post-method group)
956 (group-method (gnus-find-method-for-group group)))
958 ;; If the group-method is nil (which shouldn't happen) we use
959 ;; the default method.
961 (or (and (listp gnus-post-method) ;If not current/native/nil
962 (not (listp (car gnus-post-method))) ; and not a list of methods
963 gnus-post-method) ;then use it.
965 message-post-method))
966 ;; We want the inverse of the default
967 ((and arg (not (eq arg 0)))
968 (if (eq gnus-post-method 'current)
971 ;; We query the user for a post method.
973 (and (listp gnus-post-method)
974 (listp (car gnus-post-method))))
976 ;; Collect all methods we know about.
978 (when (listp gnus-post-method)
979 (if (listp (car gnus-post-method))
981 (list gnus-post-method)))
982 gnus-secondary-select-methods
983 (mapcar 'cdr gnus-server-alist)
984 (mapcar 'car gnus-opened-servers)
985 (list gnus-select-method)
986 (list group-method)))
987 method-alist post-methods method)
988 ;; Weed out all mail methods.
990 (setq method (gnus-server-get-method "" (pop methods)))
991 (when (and (or (gnus-method-option-p method 'post)
992 (gnus-method-option-p method 'post-mail))
993 (not (member method post-methods)))
994 (push method post-methods)))
995 ;; Create a name-method alist.
999 (if (equal (cadr m) "")
1000 (list (symbol-name (car m)) m)
1001 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m)))
1006 (setq gnus-last-posting-server
1008 gnus-last-posting-server)
1009 ;; Just use the last value.
1010 gnus-last-posting-server
1012 "Posting method: " method-alist nil t
1013 (cons (or gnus-last-posting-server "") 0))))
1015 ;; Override normal method.
1016 ((and (eq gnus-post-method 'current)
1017 (not (memq (car group-method) gnus-discouraged-post-methods))
1018 (gnus-get-function group-method 'request-post t))
1021 ;; Use gnus-post-method.
1022 ((listp gnus-post-method) ;A method...
1023 (assert (not (listp (car gnus-post-method)))) ;... not a list of methods.
1025 ;; Use the normal select method (nil or native).
1026 (t gnus-select-method))))
1029 (defun gnus-message-make-user-agent (&optional include-mime-info max-column
1031 "Return a user-agent info. If INCLUDE-MIME-INFO is non-nil and the
1032 variable `mime-edit-user-agent-value' is bound, the value will be
1033 included in the return value. If MAX-COLUMN is specified, the return
1034 value will be folded up as it were filled. NEWLINE-PRODUCT specifies
1035 whether a newline should be inserted in front of each product-token.
1036 If the value is t or `hard', it works strictly. Otherwise, if it is
1037 non-nil (e.g. `soft'), it works semi-strictly.
1039 Here is an example of how to use this function:
1041 \(add-hook 'gnus-message-setup-hook
1043 (setq message-user-agent nil)
1046 (message-narrow-to-headers)
1047 (goto-char (point-max))
1048 (insert \"User-Agent: \"
1049 (gnus-message-make-user-agent t 76 'soft)
1052 (let ((user-agent (if (and include-mime-info
1053 (boundp 'mime-edit-user-agent-value))
1054 (concat (gnus-extended-version)
1056 mime-edit-user-agent-value)
1057 (gnus-extended-version))))
1059 (unless (natnump max-column)
1060 (setq max-column 76))
1062 (set-buffer-multibyte t)
1063 (insert (mapconcat 'identity (split-string user-agent) " "))
1064 (goto-char (point-min))
1066 start agent agents width element swidth)
1067 (while (re-search-forward "\\([^ ]+\\) ?" nil t)
1068 (setq start (match-beginning 0))
1069 (if (eq (char-after start) ?\()
1073 (push (buffer-substring start (point)) agent))
1075 (push (nreverse agent) agents))
1076 (setq agent (list (match-string 1)))))
1078 (push (nreverse agent) agents))
1079 (setq agents (nreverse agents))
1080 (if (> (+ 12 (string-width (caar agents))) max-column)
1081 (setq user-agent "\n"
1086 (setq agent (car agents)
1087 agents (cdr agents))
1088 (when (and (not bol)
1089 (or (memq newline-product '(t hard))
1090 (and newline-product
1092 (string-width (mapconcat 'identity
1095 (setq user-agent (concat user-agent "\n")
1099 (setq element (car agent)
1100 swidth (string-width element)
1103 (setq user-agent (if (member user-agent '("" "\n"))
1104 (concat user-agent element)
1105 (concat user-agent " " element))
1106 width (+ width 1 swidth)
1108 (if (> (+ width 1 swidth) max-column)
1109 (setq user-agent (concat user-agent "\n " element)
1111 (setq user-agent (concat user-agent " " element)
1112 width (+ width 1 swidth)))))))))
1117 ;;; Gnus Mail Functions
1120 ;;; Mail reply commands of Gnus summary mode
1122 (defun gnus-summary-reply (&optional yank wide very-wide)
1123 "Start composing a mail reply to the current message.
1124 If prefix argument YANK is non-nil, the original article is yanked
1126 If WIDE, make a wide reply.
1127 If VERY-WIDE, make a very wide reply."
1129 (list (and current-prefix-arg
1130 (gnus-summary-work-articles 1))))
1131 ;; Allow user to require confirmation before replying by mail to the
1132 ;; author of a news article.
1133 (when (or (not (gnus-news-group-p gnus-newsgroup-name))
1134 (not gnus-confirm-mail-reply-to-news)
1135 (y-or-n-p "Really reply by mail to article author? "))
1137 (if (listp (car yank))
1140 (gnus-article-reply (or article (gnus-summary-article-number)))
1142 ;; Stripping headers should be specified with mail-yank-ignored-headers.
1144 (gnus-summary-goto-subject article))
1145 (gnus-setup-message (if yank 'reply-yank 'reply)
1147 (gnus-summary-select-article)
1148 (dolist (article very-wide)
1149 (gnus-summary-select-article nil nil nil article)
1151 (set-buffer (gnus-copy-article-buffer))
1152 (gnus-msg-treat-broken-reply-to)
1154 (message-narrow-to-head)
1155 (setq headers (concat headers (buffer-string)))))))
1156 (set-buffer (gnus-copy-article-buffer))
1157 (gnus-msg-treat-broken-reply-to gnus-msg-force-broken-reply-to)
1159 (message-narrow-to-head)
1163 (goto-char (point-max)))
1164 (message-reply nil wide)
1166 (gnus-inews-yank-articles yank))
1167 (gnus-summary-handle-replysign)))))
1169 (defun gnus-summary-handle-replysign ()
1170 "Check the various replysign variables and take action accordingly."
1171 (when nil;;(or gnus-message-replysign gnus-message-replyencrypt)
1172 (let (signed encrypted)
1174 (set-buffer gnus-article-buffer)
1175 (setq signed (memq 'signed gnus-article-wash-types))
1176 (setq encrypted (memq 'encrypted gnus-article-wash-types)))
1177 (cond ((and gnus-message-replysign signed)
1178 (mml-secure-message mml-default-sign-method 'sign))
1179 ((and gnus-message-replyencrypt encrypted)
1180 (mml-secure-message mml-default-encrypt-method
1181 (if gnus-message-replysignencrypted
1185 (defun gnus-summary-reply-with-original (n &optional wide)
1186 "Start composing a reply mail to the current message.
1187 The original article will be yanked."
1189 (gnus-summary-reply (gnus-summary-work-articles n) wide))
1191 (defun gnus-summary-reply-broken-reply-to (&optional yank wide very-wide)
1192 "Like `gnus-summary-reply' except removing reply-to field.
1193 If prefix argument YANK is non-nil, the original article is yanked
1195 If WIDE, make a wide reply.
1196 If VERY-WIDE, make a very wide reply."
1198 (list (and current-prefix-arg
1199 (gnus-summary-work-articles 1))))
1200 (let ((gnus-msg-force-broken-reply-to t))
1201 (gnus-summary-reply yank wide very-wide)))
1203 (defun gnus-summary-reply-broken-reply-to-with-original (n &optional wide)
1204 "Like `gnus-summary-reply-with-original' except removing reply-to field.
1205 The original article will be yanked."
1207 (gnus-summary-reply-broken-reply-to (gnus-summary-work-articles n) wide))
1209 (defun gnus-summary-wide-reply (&optional yank)
1210 "Start composing a wide reply mail to the current message.
1211 If prefix argument YANK is non-nil, the original article is yanked
1214 (list (and current-prefix-arg
1215 (gnus-summary-work-articles 1))))
1216 (gnus-summary-reply yank t))
1218 (defun gnus-summary-wide-reply-with-original (n)
1219 "Start composing a wide reply mail to the current message.
1220 The original article will be yanked."
1222 (gnus-summary-reply-with-original n t))
1224 (defun gnus-summary-very-wide-reply (&optional yank)
1225 "Start composing a very wide reply mail to the current message.
1226 If prefix argument YANK is non-nil, the original article is yanked
1229 (list (and current-prefix-arg
1230 (gnus-summary-work-articles 1))))
1231 (gnus-summary-reply yank t (gnus-summary-work-articles yank)))
1233 (defun gnus-summary-very-wide-reply-with-original (n)
1234 "Start composing a very wide reply mail to the current message.
1235 The original article will be yanked."
1238 (gnus-summary-work-articles n) t (gnus-summary-work-articles n)))
1240 (defun gnus-summary-mail-forward (&optional full-headers post)
1241 "Forward the current message(s) to another user.
1242 If process marks exist, forward all marked messages;
1243 If FULL-HEADERS (the prefix), include full headers when forwarding.
1245 Note that this function definition for T-gnus is totally different
1246 from the original Gnus."
1248 (if (null (cdr (gnus-summary-work-articles nil)))
1249 (gnus-setup-message 'forward
1250 (gnus-summary-select-article)
1251 (let ((charset default-mime-charset))
1252 (set-buffer gnus-original-article-buffer)
1253 (make-local-variable 'default-mime-charset)
1254 (setq default-mime-charset charset))
1255 (let ((message-included-forward-headers
1256 (if full-headers "" message-included-forward-headers)))
1257 (message-forward post)))
1258 (gnus-summary-digest-mail-forward nil post)))
1260 (defun gnus-summary-digest-mail-forward (&optional n post)
1261 "Digests and forwards all articles in this series.
1262 If N is a positive number, forward the N next articles.
1263 If N is a negative number, forward the N previous articles.
1264 If N is nil and any articles have been marked with the process mark,
1265 forward those articles instead.
1266 Optional POST will use news to forward instead of mail."
1268 (let ((articles (gnus-summary-work-articles n))
1269 (topics "Topics:\n")
1270 subject article frame)
1271 (when (car articles)
1272 (gnus-setup-message 'forward
1273 (gnus-summary-select-article)
1275 (setq articles (sort articles '<)
1276 subject "Digested Articles")
1277 (with-current-buffer gnus-original-article-buffer
1278 (setq subject (message-make-forward-subject))))
1280 (message-news nil subject)
1281 (message-mail nil subject))
1282 (when (and message-use-multi-frames (cdr articles))
1283 (setq frame (window-frame (get-buffer-window (current-buffer)))))
1285 (while (setq article (pop articles))
1286 (save-window-excursion
1287 (set-buffer gnus-summary-buffer)
1288 (gnus-summary-select-article nil nil nil article)
1289 (setq topics (concat topics " "
1290 (mail-header-subject gnus-current-headers)
1292 (gnus-summary-remove-process-mark article))
1294 (select-frame frame))
1295 (insert (mime-make-tag "message" "rfc822") "\n")
1296 (narrow-to-region (point) (point))
1297 (insert-buffer-substring gnus-original-article-buffer)
1299 (article-narrow-to-head)
1300 (message-remove-header message-included-forward-headers t nil t))
1301 (goto-char (point-max))
1307 (mime-edit-enclose-digest-region (point)(mark t))))))
1309 (defun gnus-summary-digest-post-forward (&optional n)
1310 "Digest and forwards all articles in this series to a newsgroup.
1311 If N is a positive number, forward the N next articles.
1312 If N is a negative number, forward the N previous articles.
1313 If N is nil and any articles have been marked with the process mark,
1314 forward those articles instead."
1316 (gnus-summary-digest-mail-forward n t))
1318 (defun gnus-summary-resend-message (address n)
1319 "Resend the current article to ADDRESS."
1321 (list (message-read-from-minibuffer
1322 "Resend message(s) to: "
1323 (when (and gnus-summary-resend-default-address
1324 (gnus-buffer-live-p gnus-original-article-buffer))
1325 ;; If some other article is currently selected, the
1326 ;; initial-contents is wrong. Whatever, it is just the
1327 ;; initial-contents.
1328 (with-current-buffer gnus-original-article-buffer
1329 (nnmail-fetch-field "to"))))
1330 current-prefix-arg))
1331 (let ((articles (gnus-summary-work-articles n))
1333 (while (setq article (pop articles))
1334 (gnus-summary-select-article nil nil nil article)
1336 (set-buffer gnus-original-article-buffer)
1337 (message-resend address))
1338 (gnus-summary-mark-article-as-forwarded article))))
1340 ;; From: Matthieu Moy <Matthieu.Moy@imag.fr>
1341 (defun gnus-summary-resend-message-edit ()
1342 "Resend an article that has already been sent.
1343 A new buffer will be created to allow the user to modify body and
1344 contents of the message, and then, everything will happen as when
1345 composing a new message."
1347 (let ((article (gnus-summary-article-number)))
1348 (gnus-setup-message 'reply-yank
1349 (gnus-summary-select-article t)
1350 (set-buffer gnus-original-article-buffer)
1351 (let ((cur (current-buffer))
1352 (to (message-fetch-field "to")))
1353 ;; Get a normal message buffer.
1354 (message-pop-to-buffer (message-buffer-name "Resend" to))
1355 (insert-buffer-substring cur)
1357 ;; T-gnus change: Use MIME-Edit to recompose a message.
1359 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
1360 (fset 'mime-edit-decode-single-part-in-buffer
1361 (lambda (&rest args)
1362 (if (let ((content-type (car args)))
1363 (and (eq 'message (mime-content-type-primary-type
1365 (eq 'rfc822 (mime-content-type-subtype
1367 (setcar (cdr args) 'not-decode-text))
1370 (mime-edit-again nil t)
1371 (fset 'mime-edit-decode-single-part-in-buffer ofn)))
1372 (message-narrow-to-head-1)
1373 (insert "From: " (message-make-from) "\n")
1374 (while (re-search-forward "^From:" nil t)
1376 (insert "Original-"))
1377 (message-remove-header "^>From[\t ]" t)
1379 ;; Gnus will generate a new one when sending.
1380 (message-remove-header "Message-ID")
1381 (message-remove-header message-ignored-resent-headers t)
1382 ;; Remove unwanted headers.
1383 (goto-char (point-max))
1384 (insert mail-header-separator)
1385 (goto-char (point-min))
1386 (re-search-forward "^To:\\|^Newsgroups:" nil 'move)
1390 (defun gnus-summary-post-forward (&optional full-headers)
1391 "Forward the current article to a newsgroup.
1392 If FULL-HEADERS (the prefix), include full headers when forwarding."
1394 (gnus-summary-mail-forward full-headers t))
1396 (defvar gnus-nastygram-message
1397 "The following article was inappropriately posted to %s.\n\n"
1398 "Format string to insert in nastygrams.
1399 The current group name will be inserted at \"%s\".")
1401 (defun gnus-summary-mail-nastygram (n)
1402 "Send a nastygram to the author of the current article."
1404 (when (or gnus-expert-user
1406 "Really send a nastygram to the author of the current article? "))
1407 (let ((group gnus-newsgroup-name))
1408 (gnus-summary-reply-with-original n)
1409 (set-buffer gnus-message-buffer)
1411 (insert (format gnus-nastygram-message group))
1412 (message-send-and-exit))))
1414 (defun gnus-summary-mail-crosspost-complaint (n)
1415 "Send a complaint about crossposting to the current article(s)."
1417 (let ((articles (gnus-summary-work-articles n))
1419 (while (setq article (pop articles))
1420 (set-buffer gnus-summary-buffer)
1421 (gnus-summary-goto-subject article)
1422 (let ((group (gnus-group-real-name gnus-newsgroup-name))
1423 newsgroups followup-to)
1424 (gnus-summary-select-article)
1425 (set-buffer gnus-original-article-buffer)
1426 (if (and (<= (length (message-tokenize-header
1428 (mail-fetch-field "newsgroups"))
1431 (or (not (setq followup-to (mail-fetch-field "followup-to")))
1432 (not (member group (message-tokenize-header
1433 followup-to ", ")))))
1435 (gnus-message 1 "Followup-to restricted")
1436 (gnus-message 1 "Not a crossposted article"))
1437 (set-buffer gnus-summary-buffer)
1438 (gnus-summary-reply-with-original 1)
1439 (set-buffer gnus-message-buffer)
1441 (insert (format gnus-crosspost-complaint newsgroups group))
1442 (message-goto-subject)
1443 (re-search-forward " *$")
1444 (replace-match " (crosspost notification)" t t)
1445 (gnus-deactivate-mark)
1446 (when (gnus-y-or-n-p "Send this complaint? ")
1447 (message-send-and-exit)))))))
1449 (defun gnus-mail-parse-comma-list ()
1452 (skip-chars-forward " ")
1455 (skip-chars-forward "^,")
1460 (narrow-to-region beg (point))
1463 (while (search-forward "\"" nil t)
1467 (skip-chars-forward ",")
1468 (skip-chars-forward "^,"))
1469 (skip-chars-backward " ")
1470 (push (buffer-substring beg (point))
1472 (skip-chars-forward "^,")
1473 (skip-chars-forward ", "))
1476 (defun gnus-inews-add-to-address (group)
1477 (let ((to-address (mail-fetch-field "to")))
1478 (when (and to-address
1480 ;; This mail group doesn't have a `to-list', so we add one
1482 (when (gnus-y-or-n-p
1483 (format "Do you want to add this as `to-list': %s " to-address))
1484 (gnus-group-add-parameter group (cons 'to-list to-address))))))
1486 (defun gnus-put-message ()
1487 "Put the current message in some group and return to Gnus."
1489 (let ((reply gnus-article-reply)
1490 (winconf gnus-prev-winconf)
1491 (group gnus-newsgroup-name))
1493 (not (gnus-group-read-only-p group)))
1494 (setq group (read-string "Put in group: " nil (gnus-writable-groups))))
1496 (when (gnus-gethash group gnus-newsrc-hashtb)
1497 (error "No such group: %s" group))
1501 (message-narrow-to-headers)
1502 (let ((gnus-deletable-headers nil))
1503 (message-generate-headers
1504 (if (message-news-p)
1505 message-required-news-headers
1506 message-required-mail-headers)))
1507 (goto-char (point-max))
1508 (insert "Gcc: " group "\n")
1511 (when (and (get-buffer gnus-group-buffer)
1512 (gnus-buffer-exists-p (car-safe reply))
1514 (set-buffer (car reply))
1515 (gnus-summary-mark-article-as-replied (cdr reply)))
1517 (set-window-configuration winconf))))
1519 (defun gnus-article-mail (yank)
1520 "Send a reply to the address near point.
1521 If YANK is non-nil, include the original article."
1525 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
1526 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
1528 (gnus-msg-mail address)
1530 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
1532 (defvar nntp-server-type)
1534 "Send a bug report to the Gnus maintainers."
1536 (unless (gnus-alive-p)
1537 (error "Gnus has been shut down"))
1538 (gnus-setup-message (if (message-mail-user-agent) 'message 'bug)
1539 (unless (message-mail-user-agent)
1540 (message-pop-to-buffer "*Gnus Bug*")
1541 (delete-other-windows)
1542 (when gnus-bug-create-help-buffer
1543 (switch-to-buffer "*Gnus Help Bug*")
1545 (insert gnus-bug-message)
1546 (goto-char (point-min))
1548 (set-buffer "*Gnus Bug*")))
1549 (let ((message-this-is-mail t))
1550 (message-setup `((To . ,gnus-maintainer) (Subject . ""))))
1551 (when gnus-bug-create-help-buffer
1552 (push `(gnus-bug-kill-buffer) message-send-actions))
1553 (goto-char (point-min))
1554 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
1556 (insert gnus-product-name " " gnus-version-number
1557 " (r" gnus-revision-number ") "
1558 "based on " gnus-original-product-name " v"
1559 gnus-original-version-number "\n"
1560 (emacs-version) "\n")
1561 (when (and (boundp 'nntp-server-type)
1562 (stringp nntp-server-type))
1563 (insert nntp-server-type))
1564 (insert "\n\n\n\n\n")
1565 (let (mime-content-types)
1566 (mime-edit-insert-tag
1567 "application" "emacs-lisp"
1568 "\nContent-Disposition: inline\nContent-Description: User settings"))
1569 (insert (with-temp-buffer
1572 (let (mime-content-types)
1573 (mime-edit-insert-tag "text" "plain"))
1574 (goto-char (point-min))
1575 (search-forward "Subject: " nil t)
1578 (defun gnus-bug-kill-buffer ()
1579 (when (get-buffer "*Gnus Help Bug*")
1580 (kill-buffer "*Gnus Help Bug*")))
1582 (defun gnus-summary-yank-message (buffer n)
1583 "Yank the current article into a composed message."
1585 (list (completing-read "Buffer: " (mapcar 'list (message-buffers)) nil t)
1586 current-prefix-arg))
1587 (when (gnus-buffer-live-p buffer)
1588 (let ((summary-frame (selected-frame))
1589 (message-frame (when (static-if (featurep 'xemacs)
1590 (device-on-window-system-p)
1592 (let ((window (get-buffer-window buffer t)))
1594 (window-frame window)))))
1595 (separator (concat "^" (regexp-quote mail-header-separator)
1597 (gnus-summary-iterate n
1598 (gnus-summary-select-article)
1599 (gnus-copy-article-buffer)
1600 (when (frame-live-p message-frame)
1601 (raise-frame message-frame)
1602 (select-frame message-frame))
1603 (with-current-buffer buffer
1604 (when (save-excursion
1606 (let (case-fold-search)
1607 (and (not (re-search-backward separator nil t))
1608 (re-search-forward separator nil t))))
1609 (goto-char (match-end 0)))
1610 (message-yank-buffer gnus-article-copy))
1611 (select-frame summary-frame))
1612 (when (frame-live-p message-frame)
1613 (select-frame message-frame)))))
1615 (defun gnus-debug ()
1616 "Attempts to go through the Gnus source file and report what variables have been changed.
1617 The source file has to be in the Emacs load path."
1619 (let ((files gnus-debug-files)
1621 file expr olist sym)
1622 (gnus-message 4 "Please wait while we snoop your variables...")
1623 ;; Go through all the files looking for non-default values for variables.
1626 (set-buffer (gnus-get-buffer-create " *gnus bug info*"))
1629 (when (and (setq file (locate-library (pop files)))
1630 (file-exists-p file))
1631 (insert-file-contents file)
1632 (goto-char (point-min))
1633 (if (not (re-search-forward "^;;* *Internal variables" nil t))
1634 (gnus-message 4 "Malformed sources in file %s" file)
1635 (narrow-to-region (point-min) (point))
1636 (goto-char (point-min))
1637 (while (setq expr (ignore-errors (read (current-buffer))))
1639 (and (memq (car expr) '(defvar defcustom defvoo))
1640 (stringp (nth 3 expr))
1641 (not (memq (nth 1 expr) gnus-debug-exclude-variables))
1642 (or (not (boundp (nth 1 expr)))
1643 (not (equal (eval (nth 2 expr))
1644 (symbol-value (nth 1 expr)))))
1645 (push (nth 1 expr) olist)))))))
1646 (kill-buffer (current-buffer)))
1647 (when (setq olist (nreverse olist))
1648 (insert ";----------------- Environment follows ------------------\n\n"))
1650 (if (boundp (car olist))
1652 (pp `(setq ,(car olist)
1653 ,(if (or (consp (setq sym (symbol-value (car olist))))
1655 (not (or (eq sym nil)
1657 (list 'quote (symbol-value (car olist)))
1658 (symbol-value (car olist))))
1661 (format "(setq %s 'whatever)\n" (car olist))))
1662 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
1663 (setq olist (cdr olist)))
1664 ;; Remove any control chars - they seem to cause trouble for some
1665 ;; mailers. (Byte-compiled output from the stuff above.)
1667 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
1668 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
1670 ;; Break MIME tags purposely.
1672 (while (re-search-forward mime-edit-tag-regexp nil t)
1673 (goto-char (1+ (match-beginning 0)))
1676 ;;; Treatment of rejected articles.
1679 (defun gnus-summary-resend-bounced-mail (&optional fetch)
1680 "Re-mail the current message.
1681 This only makes sense if the current message is a bounce message than
1682 contains some mail you have written which has been bounced back to
1684 If FETCH, try to fetch the article that this is a reply to, if indeed
1687 (gnus-summary-select-article t)
1688 (set-buffer gnus-original-article-buffer)
1689 (gnus-setup-message 'compose-bounce
1690 (let* ((references (mail-fetch-field "references"))
1691 (parent (and references (gnus-parent-id references))))
1693 ;; If there are references, we fetch the article we answered to.
1695 (gnus-summary-refer-article parent)
1696 (gnus-summary-show-all-headers)))))
1700 (defun gnus-inews-group-method (group)
1702 ;; If the group doesn't exist, we assume
1703 ;; it's an archive group...
1704 ((and (null (gnus-get-info group))
1705 (eq (car (gnus-server-to-method gnus-message-archive-method))
1706 (car (gnus-server-to-method (gnus-group-method group)))))
1707 gnus-message-archive-method)
1709 ((gnus-info-method (gnus-get-info group))
1710 (gnus-info-method (gnus-get-info group)))
1712 (t (gnus-server-to-method (gnus-group-method group)))))
1714 ;; Do Gcc handling, which copied the message over to some group.
1715 (defun gnus-inews-do-gcc (&optional gcc)
1719 (message-narrow-to-headers)
1720 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
1721 (coding-system-for-write 'raw-text)
1722 (output-coding-system 'raw-text)
1723 groups group method group-art
1724 mml-externalize-attachments)
1726 (message-remove-header "gcc")
1728 (setq groups (message-unquote-tokens
1729 (message-tokenize-header gcc " ,")))
1730 ;; Copy the article over to some group(s).
1731 (while (setq group (pop groups))
1732 (unless (gnus-check-server
1733 (setq method (gnus-inews-group-method group)))
1734 (error "Can't open server %s" (if (stringp method) method
1736 (unless (gnus-request-group group nil method)
1737 (gnus-request-create-group group method))
1738 (setq mml-externalize-attachments
1739 (if (stringp gnus-gcc-externalize-attachments)
1740 (string-match gnus-gcc-externalize-attachments group)
1741 gnus-gcc-externalize-attachments))
1743 (nnheader-set-temp-buffer " *acc*")
1744 (insert-buffer-substring message-encoding-buffer)
1745 (gnus-run-hooks 'gnus-before-do-gcc-hook)
1746 (goto-char (point-min))
1747 (when (re-search-forward
1748 (concat "^" (regexp-quote mail-header-separator) "$")
1750 (replace-match "" t t ))
1751 (unless (setq group-art
1752 (gnus-request-accept-article group method t t))
1753 (gnus-message 1 "Couldn't store article in group %s: %s"
1754 group (gnus-status-message method))
1756 (when (and group-art
1757 (or gnus-gcc-mark-as-read
1758 gnus-inews-mark-gcc-as-read))
1759 (gnus-group-mark-article-read group (cdr group-art)))
1760 (kill-buffer (current-buffer)))))))))
1762 (defun gnus-inews-insert-gcc ()
1763 "Insert Gcc headers based on `gnus-outgoing-message-group'."
1766 (message-narrow-to-headers)
1767 (let* ((group gnus-outgoing-message-group)
1769 ((gnus-functionp group)
1771 ((or (stringp group) (list group))
1775 (if (stringp gcc) gcc
1776 (mapconcat 'identity gcc " "))
1779 (defun gnus-inews-insert-archive-gcc (&optional group)
1780 "Insert the Gcc to say where the article is to be archived."
1781 (let* ((var gnus-message-archive-group)
1782 (group (or group gnus-newsgroup-name ""))
1784 (and gnus-newsgroup-name
1785 (not (equal gnus-newsgroup-name ""))
1786 (gnus-group-find-parameter
1787 gnus-newsgroup-name 'gcc-self)))
1791 ((null gnus-message-archive-method)
1795 ;; Just a single group.
1798 ;; We don't want this.
1800 ((and (listp var) (stringp (car var)))
1801 ;; A list of groups.
1803 ((gnus-functionp var)
1805 (funcall var group))
1807 ;; An alist of regexps/functions/forms.
1812 ((stringp (caar var))
1814 (when (string-match (caar var) group)
1816 ((gnus-functionp (car var))
1818 (funcall (car var) group))
1820 (eval (car var)))))))
1821 (setq var (cdr var)))
1824 (when (or groups gcc-self-val)
1825 (when (stringp groups)
1826 (setq groups (list groups)))
1829 (message-narrow-to-headers)
1830 (goto-char (point-max))
1833 ;; Use the `gcc-self' param value instead.
1836 (if (stringp gcc-self-val)
1839 (if (not (eq gcc-self-val 'none))
1844 ;; Use the list of groups.
1845 (while (setq name (pop groups))
1846 (insert (if (string-match ":" name)
1848 (gnus-group-prefixed-name
1849 name gnus-message-archive-method)))
1856 (defun gnus-configure-posting-styles (&optional group-name)
1857 "Configure posting styles according to `gnus-posting-styles'."
1858 (unless gnus-inhibit-posting-styles
1859 (let ((group (or group-name gnus-newsgroup-name ""))
1860 (styles gnus-posting-styles)
1861 style match variable attribute value v results
1862 filep name address element)
1863 ;; If the group has a posting-style parameter, add it at the end with a
1864 ;; regexp matching everything, to be sure it takes precedence over all
1866 (when gnus-newsgroup-name
1867 (let ((tmp-style (gnus-group-find-parameter group 'posting-style t)))
1869 (setq styles (append styles (list (cons ".*" tmp-style)))))))
1870 ;; Go through all styles and look for matches.
1871 (dolist (style styles)
1872 (setq match (pop style))
1873 (goto-char (point-min))
1876 ;; Regexp string match on the group name.
1877 (string-match match group))
1879 ;; Obsolete format of header match.
1880 (and (gnus-buffer-live-p gnus-article-copy)
1881 (with-current-buffer gnus-article-copy
1882 (let ((header (message-fetch-field (pop style))))
1884 (string-match (pop style) header))))))
1885 ((or (symbolp match)
1886 (gnus-functionp match))
1888 ((gnus-functionp match)
1889 ;; Function to be called.
1892 ;; Variable to be checked.
1893 (symbol-value match))))
1896 ((eq (car match) 'header)
1897 ;; New format of header match.
1898 (and (gnus-buffer-live-p gnus-article-copy)
1899 (with-current-buffer gnus-article-copy
1900 (let ((header (message-fetch-field (nth 1 match))))
1902 (string-match (nth 2 match) header))))))
1904 ;; This is a form to be evaled.
1906 ;; We have a match, so we set the variables.
1907 (dolist (attribute style)
1908 (setq element (pop attribute)
1913 ((eq (car attribute) ':file)
1916 ((eq (car attribute) :value)
1920 ;; We get the value.
1925 ((or (symbolp value)
1926 (gnus-functionp value))
1927 (cond ((gnus-functionp value)
1930 (symbol-value value))))
1933 ;; Translate obsolescent value.
1935 ((eq element 'signature-file)
1936 (setq element 'signature
1938 ((eq element 'x-face-file)
1939 (setq element 'x-face
1941 ;; Get the contents of file elems.
1943 (setq v (with-temp-buffer
1944 (insert-file-contents v)
1945 (goto-char (point-max))
1949 (setq results (delq (assoc element results) results))
1950 (push (cons element v) results))))
1951 ;; Now we have all the styles, so we insert them.
1952 (setq name (assq 'name results)
1953 address (assq 'address results))
1954 (setq results (delq name (delq address results)))
1955 ;; make-local-hook is not obsolete in Emacs 20 or XEmacs.
1956 (make-local-hook 'message-setup-hook)
1957 (dolist (result results)
1958 (add-hook 'message-setup-hook
1960 ((eq 'eval (car result))
1962 ((eq 'body (car result))
1966 (insert ,(cdr result)))))
1967 ((eq 'signature (car result))
1968 (set (make-local-variable 'message-signature) nil)
1969 (set (make-local-variable 'message-signature-file) nil)
1970 (if (not (cdr result))
1974 (let ((message-signature ,(cdr result)))
1975 (when message-signature
1976 (message-insert-signature)))))))
1979 (if (symbolp (car result))
1980 (capitalize (symbol-name (car result)))
1984 (message-remove-header ,header)
1985 (let ((value ,(cdr result)))
1988 (insert ,header ": " value "\n"))))))))
1990 (when (or name address)
1991 (add-hook 'message-setup-hook
1993 (set (make-local-variable 'user-mail-address)
1994 ,(or (cdr address) user-mail-address))
1995 (let ((user-full-name ,(or (cdr name) (user-full-name)))
1997 ,(or (cdr address) user-mail-address)))
1999 (message-remove-header "From")
2001 (insert "From: " (message-make-from) "\n"))))
2005 ;;; @ for MIME Edit mode
2008 (defun gnus-maybe-setup-default-charset ()
2010 (and (boundp 'gnus-summary-buffer)
2011 (buffer-live-p gnus-summary-buffer)
2013 (set-buffer gnus-summary-buffer)
2014 default-mime-charset))))
2017 (make-local-variable 'default-mime-charset)
2018 (setq default-mime-charset charset)
2022 ;;; @ for MIME view mode
2025 (defun gnus-following-method (buf)
2026 (gnus-setup-message 'reply-yank
2028 (if (message-news-p)
2030 (message-reply nil 'wide))
2031 (let ((message-reply-buffer buf))
2032 (message-yank-original))
2033 (message-goto-body))
2037 ;;; Allow redefinition of functions.
2043 ;;; gnus-msg.el ends here