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 ;;; Internal variables.
258 (defvar gnus-inhibit-posting-styles nil
259 "Inhibit the use of posting styles.")
261 (defvar gnus-message-buffer "*Mail Gnus*")
262 (defvar gnus-article-copy nil)
263 (defvar gnus-check-before-posting nil)
264 (defvar gnus-last-posting-server nil)
265 (defvar gnus-message-group-art nil)
267 (defvar gnus-msg-force-broken-reply-to nil)
269 (defconst gnus-bug-message
270 (format "Sending a bug report to the Gnus Towers.
271 ========================================
273 This gnus is the %s%s.
274 If you think the bug is a Semi-gnus bug, send a bug report to Semi-gnus
275 Developers. (the addresses below are mailing list addresses)
277 ========================================
279 The buffer below is a mail buffer. When you press `C-c C-c', it will
280 be sent to the Gnus Bug Exterminators.
282 The thing near the bottom of the buffer is how the environment
283 settings will be included in the mail. Please do not delete that.
284 They will tell the Bug People what your environment is, so that it
285 will be easier to locate the bugs.
287 If you have found a bug that makes Emacs go \"beep\", set
288 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
289 and include the backtrace in your bug report.
291 Please describe the bug in annoying, painstaking detail.
293 Thank you for your help in stamping out bugs.
296 (if (string= gnus-product-name "Semi-gnus")
298 ", a modified version of Semi-gnus")))
301 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
302 (autoload 'news-setup "rnewspost")
303 (autoload 'news-reply-mode "rnewspost")
304 (autoload 'rmail-dont-reply-to "mail-utils")
305 (autoload 'rmail-output "rmailout"))
309 ;;; Gnus Posting Functions
312 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
313 "p" gnus-summary-post-news
314 "i" gnus-summary-news-other-window
315 "f" gnus-summary-followup
316 "F" gnus-summary-followup-with-original
317 "c" gnus-summary-cancel-article
318 "s" gnus-summary-supersede-article
319 "r" gnus-summary-reply
320 "y" gnus-summary-yank-message
321 "R" gnus-summary-reply-with-original
322 "w" gnus-summary-wide-reply
323 "W" gnus-summary-wide-reply-with-original
324 "v" gnus-summary-very-wide-reply
325 "V" gnus-summary-very-wide-reply-with-original
326 "n" gnus-summary-followup-to-mail
327 "N" gnus-summary-followup-to-mail-with-original
328 "m" gnus-summary-mail-other-window
329 "u" gnus-uu-post-news
330 "\M-c" gnus-summary-mail-crosspost-complaint
331 "Br" gnus-summary-reply-broken-reply-to
332 "BR" gnus-summary-reply-broken-reply-to-with-original
333 "om" gnus-summary-mail-forward
334 "op" gnus-summary-post-forward
335 "Om" gnus-summary-digest-mail-forward
336 "Op" gnus-summary-digest-post-forward)
338 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
339 "b" gnus-summary-resend-bounced-mail
340 ;; "c" gnus-summary-send-draft
341 "r" gnus-summary-resend-message
342 "e" gnus-summary-resend-message-edit)
344 ;;; Internal functions.
346 (defvar gnus-article-reply nil)
347 (defmacro gnus-setup-message (config &rest forms)
348 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
349 (buffer (make-symbol "gnus-setup-message-buffer"))
350 (article (make-symbol "gnus-setup-message-article"))
351 (group (make-symbol "gnus-setup-message-group")))
352 `(let ((,winconf (current-window-configuration))
353 (,buffer (buffer-name (current-buffer)))
354 (,article gnus-article-reply)
355 (,group gnus-newsgroup-name)
356 (message-header-setup-hook
357 (copy-sequence message-header-setup-hook))
358 (message-mode-hook (copy-sequence message-mode-hook))
359 (message-startup-parameter-alist
360 '((reply-buffer . gnus-copy-article-buffer)
361 (original-buffer . gnus-original-article-buffer)
362 (user-agent . Gnus))))
363 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
364 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
365 ;; #### FIXME: for a reason that I did not manage to identify yet,
366 ;; the variable `gnus-newsgroup-name' does not honor a dynamically
367 ;; scoped or setq'ed value from a caller like `C-u gnus-summary-mail'.
368 ;; After evaluation of @forms below, it gets the value we actually want
369 ;; to override, and the posting styles are used. For that reason, I've
370 ;; added an optional argument to `gnus-configure-posting-styles' to
371 ;; make sure that the correct value for the group name is used. -- drv
372 (add-hook 'message-mode-hook
374 (gnus-configure-posting-styles ,group)))
378 (gnus-inews-add-send-actions ,winconf ,buffer ,article ,config)
379 (gnus-inews-insert-draft-meta-information ,group ,article)
380 (setq gnus-message-buffer (current-buffer))
381 (set (make-local-variable 'gnus-message-group-art)
382 (cons ,group ,article))
383 (set (make-local-variable 'gnus-newsgroup-name) ,group)
384 (gnus-maybe-setup-default-charset)
385 (gnus-run-hooks 'gnus-message-setup-hook))
387 (gnus-configure-windows ,config t)
388 (run-hooks 'post-command-hook)
389 (set-buffer-modified-p nil))))
391 (defun gnus-inews-insert-draft-meta-information (group article)
394 (not (string= group ""))
395 (not (message-fetch-field gnus-draft-meta-information-header)))
396 (goto-char (point-min))
397 (insert gnus-draft-meta-information-header ": (\"" group "\" "
398 (if article (number-to-string
405 (defun gnus-msg-mail (&optional to subject other-headers continue
406 switch-action yank-action send-actions)
407 "Start editing a mail message to be sent.
408 Like `message-mail', but with Gnus paraphernalia, particularly the
409 Gcc: header for archiving purposes."
411 (let ((buf (current-buffer))
413 (gnus-setup-message 'message
414 (message-mail to subject other-headers continue
415 nil yank-action send-actions))
417 (setq mail-buf (current-buffer))
418 (switch-to-buffer buf)
419 (apply switch-action mail-buf nil)))
420 ;; COMPOSEFUNC should return t if succeed. Undocumented ???
423 (defvar save-selected-window-window)
426 (defun gnus-button-mailto (address)
428 (set-buffer (gnus-copy-article-buffer))
429 (gnus-setup-message 'message
430 (message-reply address))
431 (and (boundp 'save-selected-window-window)
432 (not (window-live-p save-selected-window-window))
433 (setq save-selected-window-window (selected-window))))
436 (defun gnus-button-reply (&optional to-address wide)
437 "Like `message-reply'."
439 (gnus-setup-message 'message
440 (message-reply to-address wide))
441 (and (boundp 'save-selected-window-window)
442 (not (window-live-p save-selected-window-window))
443 (setq save-selected-window-window (selected-window))))
446 (define-mail-user-agent 'gnus-user-agent
447 'gnus-msg-mail 'message-send-and-exit
448 'message-kill-buffer 'message-send-hook)
450 (defun gnus-setup-posting-charset (group)
451 (let ((alist gnus-group-posting-charset-alist)
452 (group (or group ""))
456 (while (setq elem (pop alist))
457 (when (or (and (stringp (car elem))
458 (string-match (car elem) group))
459 (and (gnus-functionp (car elem))
460 (funcall (car elem) group))
461 (and (symbolp (car elem))
462 (symbol-value (car elem))))
463 (throw 'found (cons (cadr elem) (caddr elem)))))))))
465 (defun gnus-inews-add-send-actions (winconf buffer article &optional config)
466 (make-local-hook 'message-sent-hook)
467 (add-hook 'message-sent-hook (if gnus-agent 'gnus-agent-possibly-do-gcc
468 'gnus-inews-do-gcc) nil t)
470 (make-local-hook 'message-header-hook)
471 (add-hook 'message-header-hook 'gnus-agent-possibly-save-gcc nil t))
472 (setq message-post-method
474 (gnus-post-method arg ,gnus-newsgroup-name)))
475 (setq message-user-agent (gnus-extended-version))
476 (when (not message-use-multi-frames)
478 `(set-window-configuration ,winconf) 'exit 'postpone 'kill))
480 `(when (gnus-buffer-exists-p ,buffer)
484 (if (eq config 'forward)
485 `(gnus-summary-mark-article-as-forwarded ',article)
486 `(gnus-summary-mark-article-as-replied ',article)))))
489 (put 'gnus-setup-message 'lisp-indent-function 1)
490 (put 'gnus-setup-message 'edebug-form-spec '(form body))
492 ;;; Post news commands of Gnus group mode and summary mode
494 (defun gnus-group-mail (&optional arg)
495 "Start composing a mail.
496 If ARG, use the group under the point to find a posting style.
497 If ARG is 1, prompt for a group name to find the posting style."
499 ;; We can't `let' gnus-newsgroup-name here, since that leads
500 ;; to local variables leaking.
501 (let ((group gnus-newsgroup-name)
502 ;; make sure last viewed article doesn't affect posting styles:
504 (buffer (current-buffer)))
507 (setq gnus-newsgroup-name
509 (if (= 1 (prefix-numeric-value arg))
510 (completing-read "Use posting style of group: "
511 gnus-active-hashtb nil
512 (gnus-read-active-file-p))
513 (gnus-group-group-name))
515 ;; #### see comment in gnus-setup-message -- drv
516 (gnus-setup-message 'message (message-mail)))
519 (setq gnus-newsgroup-name group)))))
521 (defun gnus-group-news (&optional arg)
522 "Start composing a news.
523 If ARG, post to group under point.
524 If ARG is 1, prompt for group name to post to.
526 This function prepares a news even when using mail groups. This is useful
527 for posting messages to mail groups without actually sending them over the
528 network. The corresponding backend must have a 'request-post method."
530 ;; We can't `let' gnus-newsgroup-name here, since that leads
531 ;; to local variables leaking.
532 (let ((group gnus-newsgroup-name)
533 ;; make sure last viewed article doesn't affect posting styles:
535 (buffer (current-buffer)))
538 (setq gnus-newsgroup-name
540 (if (= 1 (prefix-numeric-value arg))
541 (completing-read "Use group: "
542 gnus-active-hashtb nil
543 (gnus-read-active-file-p))
544 (gnus-group-group-name))
546 ;; #### see comment in gnus-setup-message -- drv
547 (gnus-setup-message 'message
548 (message-news (gnus-group-real-name gnus-newsgroup-name))))
551 (setq gnus-newsgroup-name group)))))
553 (defun gnus-group-post-news (&optional arg)
554 "Start composing a message (a news by default).
555 If ARG, post to group under point. If ARG is 1, prompt for group name.
556 Depending on the selected group, the message might be either a mail or
559 ;; Bind this variable here to make message mode hooks work ok.
560 (let ((gnus-newsgroup-name
562 (if (= 1 (prefix-numeric-value arg))
563 (completing-read "Newsgroup: " gnus-active-hashtb nil
564 (gnus-read-active-file-p))
565 (gnus-group-group-name))
567 ;; make sure last viewed article doesn't affect posting styles:
569 (gnus-post-news 'post gnus-newsgroup-name)))
571 (defun gnus-summary-mail-other-window (&optional arg)
572 "Start composing a mail in another window.
573 Use the posting of the current group by default.
574 If ARG, don't do that. If ARG is 1, prompt for group name to find the
577 ;; We can't `let' gnus-newsgroup-name here, since that leads
578 ;; to local variables leaking.
579 (let ((group gnus-newsgroup-name)
580 ;; make sure last viewed article doesn't affect posting styles:
582 (buffer (current-buffer)))
585 (setq gnus-newsgroup-name
587 (if (= 1 (prefix-numeric-value arg))
588 (completing-read "Use group: "
589 gnus-active-hashtb nil
590 (gnus-read-active-file-p))
592 gnus-newsgroup-name))
593 ;; #### see comment in gnus-setup-message -- drv
594 (gnus-setup-message 'message (message-mail)))
597 (setq gnus-newsgroup-name group)))))
599 (defun gnus-summary-news-other-window (&optional arg)
600 "Start composing a news in another window.
601 Post to the current group by default.
602 If ARG, don't do that. If ARG is 1, prompt for group name to post to.
604 This function prepares a news even when using mail groups. This is useful
605 for posting messages to mail groups without actually sending them over the
606 network. The corresponding backend must have a 'request-post method."
608 ;; We can't `let' gnus-newsgroup-name here, since that leads
609 ;; to local variables leaking.
610 (let ((group gnus-newsgroup-name)
611 ;; make sure last viewed article doesn't affect posting styles:
613 (buffer (current-buffer)))
616 (setq gnus-newsgroup-name
618 (if (= 1 (prefix-numeric-value arg))
619 (completing-read "Use group: "
620 gnus-active-hashtb nil
621 (gnus-read-active-file-p))
623 gnus-newsgroup-name))
624 ;; #### see comment in gnus-setup-message -- drv
625 (gnus-setup-message 'message
626 (message-news (gnus-group-real-name gnus-newsgroup-name))))
629 (setq gnus-newsgroup-name group)))))
631 (defun gnus-summary-post-news (&optional arg)
632 "Start composing a message. Post to the current group by default.
633 If ARG, don't do that. If ARG is 1, prompt for a group name to post to.
634 Depending on the selected group, the message might be either a mail or
637 ;; Bind this variable here to make message mode hooks work ok.
638 (let ((gnus-newsgroup-name
640 (if (= 1 (prefix-numeric-value arg))
641 (completing-read "Newsgroup: " gnus-active-hashtb nil
642 (gnus-read-active-file-p))
644 gnus-newsgroup-name))
645 ;; make sure last viewed article doesn't affect posting styles:
647 (gnus-post-news 'post gnus-newsgroup-name)))
650 (defun gnus-summary-followup (yank &optional force-news)
651 "Compose a followup to an article.
652 If prefix argument YANK is non-nil, the original article is yanked
654 YANK is a list of elements, where the car of each element is the
655 article number, and the two following numbers is the region to be
658 (list (and current-prefix-arg
659 (gnus-summary-work-articles 1))))
661 (gnus-summary-goto-subject
662 (if (listp (car yank))
665 (save-window-excursion
666 (gnus-summary-select-article))
667 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
668 (gnus-newsgroup-name gnus-newsgroup-name))
670 (gnus-post-news nil gnus-newsgroup-name
671 headers gnus-article-buffer
672 yank nil force-news)))
674 (defun gnus-summary-followup-with-original (n &optional force-news)
675 "Compose a followup to an article and include the original article."
677 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
679 (defun gnus-summary-followup-to-mail (&optional arg)
680 "Followup to the current mail message via news."
682 (list (and current-prefix-arg
683 (gnus-summary-work-articles 1))))
684 (gnus-summary-followup arg t))
686 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
687 "Followup to the current mail message via news."
689 (gnus-summary-followup (gnus-summary-work-articles arg) t))
691 (defun gnus-inews-yank-articles (articles)
692 (let (beg article yank-string
693 (more-than-one (cdr articles))
694 (cur (current-buffer))
697 (while (setq article (pop articles))
698 (when (listp article)
699 (setq yank-string (nth 1 article)
700 article (nth 0 article)))
701 (save-window-excursion
702 (set-buffer gnus-summary-buffer)
703 (gnus-summary-select-article nil nil nil article)
704 (gnus-summary-remove-process-mark article))
706 ;; Gathering references.
708 (setq refs (message-list-references
710 (mail-header-references gnus-current-headers)
711 (mail-header-message-id gnus-current-headers)))
712 (when message-use-multi-frames
713 (when (setq window (get-buffer-window cur t))
714 (select-frame (window-frame window)))))
716 (gnus-copy-article-buffer nil yank-string)
717 (let ((message-reply-buffer gnus-article-copy)
718 (message-reply-headers
719 ;; The headers are decoded.
720 (with-current-buffer gnus-article-copy
722 (nnheader-narrow-to-headers)
723 (ietf-drums-unfold-fws)
724 (nnheader-parse-head t)))))
725 (message-yank-original)
726 (setq beg (or beg (mark t))))
731 ;; Replace with the gathered references.
735 (message-narrow-to-headers)
736 (let ((case-fold-search t))
737 (if (re-search-forward "^References:\\([\t ]+.+\n\\)+" nil t)
739 (goto-char (point-max))))
741 (list (or (assq 'References message-header-format-alist)
742 '(References . message-shorten-references)))
743 (list (cons 'References
744 (mapconcat 'identity (nreverse refs) " "))))
745 (backward-delete-char 1))
751 (defun gnus-summary-cancel-article (&optional n symp)
752 "Cancel an article you posted.
753 Uses the process-prefix convention. If given the symbolic
754 prefix `a', cancel using the standard posting method; if not
755 post using the current select method."
756 (interactive (gnus-interactive "P\ny"))
757 (let ((articles (gnus-summary-work-articles n))
760 (gnus-post-method (eq ',symp 'a) ,gnus-newsgroup-name)))
762 (while (setq article (pop articles))
763 (when (gnus-summary-select-article t nil nil article)
764 (when (gnus-eval-in-buffer-window gnus-article-buffer
766 (set-buffer gnus-original-article-buffer)
767 (message-cancel-news)))
768 (gnus-summary-mark-as-read article gnus-canceled-mark)
769 (gnus-cache-remove-article 1))
770 (gnus-article-hide-headers-if-wanted))
771 (gnus-summary-remove-process-mark article))))
773 (defun gnus-summary-supersede-article ()
774 "Compose an article that will supersede a previous article.
775 This is done simply by taking the old article and adding a Supersedes
776 header line with the old Message-ID."
778 (let ((article (gnus-summary-article-number)))
779 (gnus-setup-message 'reply-yank
780 (gnus-summary-select-article t)
781 (set-buffer gnus-original-article-buffer)
785 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
787 (set-buffer ,gnus-summary-buffer)
788 (gnus-cache-possibly-remove-article ,article nil nil nil t)
789 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
790 message-send-actions))))
794 (defun gnus-copy-article-buffer (&optional article-buffer yank-string)
795 ;; make a copy of the article buffer with all text properties removed
796 ;; this copy is in the buffer gnus-article-copy.
797 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
798 ;; this buffer should be passed to all mail/news reply/post routines.
799 (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
800 (let ((article-buffer (or article-buffer gnus-article-buffer))
802 (if (not (and (get-buffer article-buffer)
803 (gnus-buffer-exists-p article-buffer)))
804 (error "Can't find any article buffer")
806 (set-buffer article-buffer)
807 (let ((gnus-newsgroup-charset (or gnus-article-charset
808 gnus-newsgroup-charset))
809 (gnus-newsgroup-ignored-charsets
810 (or gnus-article-ignored-charsets
811 gnus-newsgroup-ignored-charsets)))
813 ;; Copy over the (displayed) article buffer, delete
814 ;; hidden text and remove text properties.
816 (let ((inhibit-read-only t))
817 (copy-to-buffer gnus-article-copy (point-min) (point-max))
818 (set-buffer gnus-article-copy)
821 (delete-region (point) (point-max))
822 (insert yank-string))
823 ;; Encode bitmap smileys to ordinary text.
824 ;; Possibly, the original text might be restored.
825 (static-unless (featurep 'xemacs)
826 (when (featurep 'smiley-mule)
827 (smiley-encode-buffer)))
828 (gnus-article-delete-text-of-type 'annotation)
829 (gnus-remove-text-with-property 'gnus-prev)
830 (gnus-remove-text-with-property 'gnus-next)
831 (gnus-remove-text-with-property 'gnus-decoration)
832 (gnus-remove-text-with-property 'x-face-mule-bitmap-image)
835 (static-if (featurep 'xemacs)
836 ;; Revome smiley extents for (possibly) XEmacs 21.1.
838 (buffer-substring-no-properties (point-min)
840 (buffer-substring-no-properties (point-min) (point-max)))
842 ;; Find the original headers.
843 (set-buffer gnus-original-article-buffer)
844 (goto-char (point-min))
845 (while (looking-at message-unix-mail-delimiter)
848 end (or (message-goto-body) beg))
849 ;; Delete the headers from the displayed articles.
850 (set-buffer gnus-article-copy)
851 (delete-region (goto-char (point-min))
852 (or (message-goto-body) (point-max)))
853 ;; Insert the original article headers.
854 (insert-buffer-substring gnus-original-article-buffer beg end)
856 (let ((gnus-article-decode-hook
857 (delq 'article-decode-charset
858 (copy-sequence gnus-article-decode-hook))))
859 ;; Needed for T-gnus.
860 (add-hook 'gnus-article-decode-hook
861 'article-decode-encoded-words)
862 (run-hooks 'gnus-article-decode-hook)))))
865 (defun gnus-post-news (post &optional group header article-buffer yank subject
868 (gnus-copy-article-buffer))
869 (let ((gnus-article-reply (and article-buffer (gnus-summary-article-number)))
870 (add-to-list gnus-add-to-list))
871 (gnus-setup-message (cond (yank 'reply-yank)
872 (article-buffer 'reply)
874 (let* ((group (or group gnus-newsgroup-name))
875 (charset (gnus-group-name-charset nil group))
877 to-address to-group mailing-list to-list
880 (setq to-address (gnus-parameter-to-address group)
881 to-group (gnus-group-find-parameter group 'to-group)
882 to-list (gnus-parameter-to-list group)
883 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
884 mailing-list (when gnus-mailing-list-groups
885 (string-match gnus-mailing-list-groups group))
886 group (gnus-group-name-decode (gnus-group-real-name group)
888 (if (or (and to-group
889 (gnus-news-group-p to-group))
892 (and (gnus-news-group-p
893 (or pgroup gnus-newsgroup-name)
894 (or header gnus-current-article))
900 (message-news (or to-group group))
901 (set-buffer gnus-article-copy)
902 (gnus-msg-treat-broken-reply-to)
903 (message-followup (if (or newsgroup-p force-news)
904 (if (save-restriction
905 (article-narrow-to-head)
906 (message-fetch-field "newsgroups"))
913 (message-mail (or to-address to-list))
914 ;; Arrange for mail groups that have no `to-address' to
915 ;; get that when the user sends off the mail.
916 (when (and (not to-list)
919 (push (list 'gnus-inews-add-to-address pgroup)
920 message-send-actions)))
921 (set-buffer gnus-article-copy)
922 (gnus-msg-treat-broken-reply-to)
923 (message-wide-reply to-address)))
925 (gnus-inews-yank-articles yank))))))
927 (defun gnus-msg-treat-broken-reply-to (&optional force)
928 "Remove the Reply-to header iff broken-reply-to."
930 (gnus-group-find-parameter
931 gnus-newsgroup-name 'broken-reply-to))
933 (message-narrow-to-head)
934 (message-remove-header "reply-to"))))
936 (defun gnus-post-method (arg group &optional silent)
937 "Return the posting method based on GROUP and ARG.
938 If SILENT, don't prompt the user."
939 (let ((gnus-post-method (or (gnus-parameter-post-method group)
941 (group-method (gnus-find-method-for-group group)))
943 ;; If the group-method is nil (which shouldn't happen) we use
944 ;; the default method.
946 (or (and (listp gnus-post-method) ;If not current/native/nil
947 (not (listp (car gnus-post-method))) ; and not a list of methods
948 gnus-post-method) ;then use it.
950 message-post-method))
951 ;; We want the inverse of the default
952 ((and arg (not (eq arg 0)))
953 (if (eq gnus-post-method 'current)
956 ;; We query the user for a post method.
958 (and (listp gnus-post-method)
959 (listp (car gnus-post-method))))
961 ;; Collect all methods we know about.
963 (when (listp gnus-post-method)
964 (if (listp (car gnus-post-method))
966 (list gnus-post-method)))
967 gnus-secondary-select-methods
968 (mapcar 'cdr gnus-server-alist)
969 (mapcar 'car gnus-opened-servers)
970 (list gnus-select-method)
971 (list group-method)))
972 method-alist post-methods method)
973 ;; Weed out all mail methods.
975 (setq method (gnus-server-get-method "" (pop methods)))
976 (when (and (or (gnus-method-option-p method 'post)
977 (gnus-method-option-p method 'post-mail))
978 (not (member method post-methods)))
979 (push method post-methods)))
980 ;; Create a name-method alist.
984 (if (equal (cadr m) "")
985 (list (symbol-name (car m)) m)
986 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m)))
991 (setq gnus-last-posting-server
993 gnus-last-posting-server)
994 ;; Just use the last value.
995 gnus-last-posting-server
997 "Posting method: " method-alist nil t
998 (cons (or gnus-last-posting-server "") 0))))
1000 ;; Override normal method.
1001 ((and (eq gnus-post-method 'current)
1002 (not (memq (car group-method) gnus-discouraged-post-methods))
1003 (gnus-get-function group-method 'request-post t))
1006 ;; Use gnus-post-method.
1007 ((listp gnus-post-method) ;A method...
1008 (assert (not (listp (car gnus-post-method)))) ;... not a list of methods.
1010 ;; Use the normal select method (nil or native).
1011 (t gnus-select-method))))
1014 (defun gnus-message-make-user-agent (&optional include-mime-info max-column
1016 "Return a user-agent info. If INCLUDE-MIME-INFO is non-nil and the
1017 variable `mime-edit-user-agent-value' is bound, the value will be
1018 included in the return value. If MAX-COLUMN is specified, the return
1019 value will be folded up as it were filled. NEWLINE-PRODUCT specifies
1020 whether a newline should be inserted in front of each product-token.
1021 If the value is t or `hard', it works strictly. Otherwise, if it is
1022 non-nil (e.g. `soft'), it works semi-strictly.
1024 Here is an example of how to use this function:
1026 \(add-hook 'gnus-message-setup-hook
1028 (setq message-user-agent nil)
1031 (message-narrow-to-headers)
1032 (goto-char (point-max))
1033 (insert \"User-Agent: \"
1034 (gnus-message-make-user-agent t 76 'soft)
1037 (let ((user-agent (if (and include-mime-info
1038 (boundp 'mime-edit-user-agent-value))
1039 (concat (gnus-extended-version)
1041 mime-edit-user-agent-value)
1042 (gnus-extended-version))))
1044 (unless (natnump max-column)
1045 (setq max-column 76))
1047 (set-buffer-multibyte t)
1048 (insert (mapconcat 'identity (split-string user-agent) " "))
1049 (goto-char (point-min))
1051 start agent agents width element swidth)
1052 (while (re-search-forward "\\([^ ]+\\) ?" nil t)
1053 (setq start (match-beginning 0))
1054 (if (eq (char-after start) ?\()
1058 (push (buffer-substring start (point)) agent))
1060 (push (nreverse agent) agents))
1061 (setq agent (list (match-string 1)))))
1063 (push (nreverse agent) agents))
1064 (setq agents (nreverse agents))
1065 (if (> (+ 12 (string-width (caar agents))) max-column)
1066 (setq user-agent "\n"
1071 (setq agent (car agents)
1072 agents (cdr agents))
1073 (when (and (not bol)
1074 (or (memq newline-product '(t hard))
1075 (and newline-product
1077 (string-width (mapconcat 'identity
1080 (setq user-agent (concat user-agent "\n")
1084 (setq element (car agent)
1085 swidth (string-width element)
1088 (setq user-agent (if (member user-agent '("" "\n"))
1089 (concat user-agent element)
1090 (concat user-agent " " element))
1091 width (+ width 1 swidth)
1093 (if (> (+ width 1 swidth) max-column)
1094 (setq user-agent (concat user-agent "\n " element)
1096 (setq user-agent (concat user-agent " " element)
1097 width (+ width 1 swidth)))))))))
1102 ;;; Gnus Mail Functions
1105 ;;; Mail reply commands of Gnus summary mode
1107 (defun gnus-summary-reply (&optional yank wide very-wide)
1108 "Start composing a mail reply to the current message.
1109 If prefix argument YANK is non-nil, the original article is yanked
1111 If WIDE, make a wide reply.
1112 If VERY-WIDE, make a very wide reply."
1114 (list (and current-prefix-arg
1115 (gnus-summary-work-articles 1))))
1116 ;; Allow user to require confirmation before replying by mail to the
1117 ;; author of a news article.
1118 (when (or (not (gnus-news-group-p gnus-newsgroup-name))
1119 (not gnus-confirm-mail-reply-to-news)
1120 (y-or-n-p "Really reply by mail to article author? "))
1122 (if (listp (car yank))
1125 (gnus-article-reply (or article (gnus-summary-article-number)))
1127 ;; Stripping headers should be specified with mail-yank-ignored-headers.
1129 (gnus-summary-goto-subject article))
1130 (gnus-setup-message (if yank 'reply-yank 'reply)
1132 (gnus-summary-select-article)
1133 (dolist (article very-wide)
1134 (gnus-summary-select-article nil nil nil article)
1136 (set-buffer (gnus-copy-article-buffer))
1137 (gnus-msg-treat-broken-reply-to)
1139 (message-narrow-to-head)
1140 (setq headers (concat headers (buffer-string)))))))
1141 (set-buffer (gnus-copy-article-buffer))
1142 (gnus-msg-treat-broken-reply-to gnus-msg-force-broken-reply-to)
1144 (message-narrow-to-head)
1148 (goto-char (point-max)))
1149 (message-reply nil wide)
1151 (gnus-inews-yank-articles yank))
1152 ;; (when (or gnus-message-replysign gnus-message-replyencrypt)
1153 ;; (let (signed encrypted)
1155 ;; (set-buffer gnus-article-buffer)
1156 ;; (setq signed (memq 'signed gnus-article-wash-types))
1157 ;; (setq encrypted (memq 'encrypted gnus-article-wash-types)))
1158 ;; (cond ((and gnus-message-replysign signed)
1159 ;; (mml-secure-message mml-default-sign-method 'sign))
1160 ;; ((and gnus-message-replyencrypt encrypted)
1161 ;; (mml-secure-message mml-default-encrypt-method
1162 ;; (if gnus-message-replysignencrypted
1167 (defun gnus-summary-reply-with-original (n &optional wide)
1168 "Start composing a reply mail to the current message.
1169 The original article will be yanked."
1171 (gnus-summary-reply (gnus-summary-work-articles n) wide))
1173 (defun gnus-summary-reply-broken-reply-to (&optional yank wide very-wide)
1174 "Like `gnus-summary-reply' except removing reply-to field.
1175 If prefix argument YANK is non-nil, the original article is yanked
1177 If WIDE, make a wide reply.
1178 If VERY-WIDE, make a very wide reply."
1180 (list (and current-prefix-arg
1181 (gnus-summary-work-articles 1))))
1182 (let ((gnus-msg-force-broken-reply-to t))
1183 (gnus-summary-reply yank wide very-wide)))
1185 (defun gnus-summary-reply-broken-reply-to-with-original (n &optional wide)
1186 "Like `gnus-summary-reply-with-original' except removing reply-to field.
1187 The original article will be yanked."
1189 (gnus-summary-reply-broken-reply-to (gnus-summary-work-articles n) wide))
1191 (defun gnus-summary-wide-reply (&optional yank)
1192 "Start composing a wide reply mail to the current message.
1193 If prefix argument YANK is non-nil, the original article is yanked
1196 (list (and current-prefix-arg
1197 (gnus-summary-work-articles 1))))
1198 (gnus-summary-reply yank t))
1200 (defun gnus-summary-wide-reply-with-original (n)
1201 "Start composing a wide reply mail to the current message.
1202 The original article will be yanked."
1204 (gnus-summary-reply-with-original n t))
1206 (defun gnus-summary-very-wide-reply (&optional yank)
1207 "Start composing a very wide reply mail to the current message.
1208 If prefix argument YANK is non-nil, the original article is yanked
1211 (list (and current-prefix-arg
1212 (gnus-summary-work-articles 1))))
1213 (gnus-summary-reply yank t (gnus-summary-work-articles yank)))
1215 (defun gnus-summary-very-wide-reply-with-original (n)
1216 "Start composing a very wide reply mail to the current message.
1217 The original article will be yanked."
1220 (gnus-summary-work-articles n) t (gnus-summary-work-articles n)))
1222 (defun gnus-summary-mail-forward (&optional full-headers post)
1223 "Forward the current message(s) to another user.
1224 If process marks exist, forward all marked messages;
1225 If FULL-HEADERS (the prefix), include full headers when forwarding.
1227 Note that this function definition for T-gnus is totally different
1228 from the original Gnus."
1230 (if (null (cdr (gnus-summary-work-articles nil)))
1231 (gnus-setup-message 'forward
1232 (gnus-summary-select-article)
1233 (let ((charset default-mime-charset))
1234 (set-buffer gnus-original-article-buffer)
1235 (make-local-variable 'default-mime-charset)
1236 (setq default-mime-charset charset))
1237 (let ((message-included-forward-headers
1238 (if full-headers "" message-included-forward-headers)))
1239 (message-forward post)))
1240 (gnus-summary-digest-mail-forward nil post)))
1242 (defun gnus-summary-digest-mail-forward (&optional n post)
1243 "Digests and forwards all articles in this series.
1244 If N is a positive number, forward the N next articles.
1245 If N is a negative number, forward the N previous articles.
1246 If N is nil and any articles have been marked with the process mark,
1247 forward those articles instead.
1248 Optional POST will use news to forward instead of mail."
1250 (let ((articles (gnus-summary-work-articles n))
1251 (topics "Topics:\n")
1252 subject article frame)
1253 (when (car articles)
1254 (gnus-setup-message 'forward
1255 (gnus-summary-select-article)
1257 (setq articles (sort articles '<)
1258 subject "Digested Articles")
1259 (with-current-buffer gnus-original-article-buffer
1260 (setq subject (message-make-forward-subject))))
1262 (message-news nil subject)
1263 (message-mail nil subject))
1264 (when (and message-use-multi-frames (cdr articles))
1265 (setq frame (window-frame (get-buffer-window (current-buffer)))))
1267 (while (setq article (pop articles))
1268 (save-window-excursion
1269 (set-buffer gnus-summary-buffer)
1270 (gnus-summary-select-article nil nil nil article)
1271 (setq topics (concat topics " "
1272 (mail-header-subject gnus-current-headers)
1274 (gnus-summary-remove-process-mark article))
1276 (select-frame frame))
1277 (insert (mime-make-tag "message" "rfc822") "\n")
1278 (narrow-to-region (point) (point))
1279 (insert-buffer-substring gnus-original-article-buffer)
1281 (article-narrow-to-head)
1282 (message-remove-header message-included-forward-headers t nil t))
1283 (goto-char (point-max))
1289 (mime-edit-enclose-digest-region (point)(mark t))))))
1291 (defun gnus-summary-digest-post-forward (&optional n)
1292 "Digest and forwards all articles in this series to a newsgroup.
1293 If N is a positive number, forward the N next articles.
1294 If N is a negative number, forward the N previous articles.
1295 If N is nil and any articles have been marked with the process mark,
1296 forward those articles instead."
1298 (gnus-summary-digest-mail-forward n t))
1300 (defun gnus-summary-resend-message (address n)
1301 "Resend the current article to ADDRESS."
1303 (list (message-read-from-minibuffer
1304 "Resend message(s) to: "
1305 (when (gnus-buffer-live-p gnus-original-article-buffer)
1306 ;; If some other article is currently selected, the
1307 ;; initial-contents is wrong. Whatever, it is just the
1308 ;; initial-contents.
1309 (with-current-buffer gnus-original-article-buffer
1310 (nnmail-fetch-field "to"))))
1311 current-prefix-arg))
1312 (let ((articles (gnus-summary-work-articles n))
1314 (while (setq article (pop articles))
1315 (gnus-summary-select-article nil nil nil article)
1317 (set-buffer gnus-original-article-buffer)
1318 (message-resend address))
1319 (gnus-summary-mark-article-as-forwarded article))))
1321 ;; From: Matthieu Moy <Matthieu.Moy@imag.fr>
1322 (defun gnus-summary-resend-message-edit ()
1323 "Resend an article that has already been sent.
1324 A new buffer will be created to allow the user to modify body and
1325 contents of the message, and then, everything will happen as when
1326 composing a new message."
1328 (let ((article (gnus-summary-article-number)))
1329 (gnus-setup-message 'reply-yank
1330 (gnus-summary-select-article t)
1331 (set-buffer gnus-original-article-buffer)
1332 (let ((cur (current-buffer))
1333 (to (message-fetch-field "to")))
1334 ;; Get a normal message buffer.
1335 (message-pop-to-buffer (message-buffer-name "Resend" to))
1336 (insert-buffer-substring cur)
1338 ;; T-gnus change: Use MIME-Edit to recompose a message.
1340 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
1341 (fset 'mime-edit-decode-single-part-in-buffer
1342 (lambda (&rest args)
1343 (if (let ((content-type (car args)))
1344 (and (eq 'message (mime-content-type-primary-type
1346 (eq 'rfc822 (mime-content-type-subtype
1348 (setcar (cdr args) 'not-decode-text))
1351 (mime-edit-again nil t)
1352 (fset 'mime-edit-decode-single-part-in-buffer ofn)))
1353 (message-narrow-to-head-1)
1354 (insert "From: " (message-make-from) "\n")
1355 (while (re-search-forward "^From:" nil t)
1357 (insert "Original-"))
1358 (message-remove-header "^>From[\t ]" t)
1360 ;; Gnus will generate a new one when sending.
1361 (message-remove-header "Message-ID")
1362 (message-remove-header message-ignored-resent-headers t)
1363 ;; Remove unwanted headers.
1364 (goto-char (point-max))
1365 (insert mail-header-separator)
1366 (goto-char (point-min))
1367 (re-search-forward "^To:\\|^Newsgroups:" nil 'move)
1371 (defun gnus-summary-post-forward (&optional full-headers)
1372 "Forward the current article to a newsgroup.
1373 If FULL-HEADERS (the prefix), include full headers when forwarding."
1375 (gnus-summary-mail-forward full-headers t))
1377 (defvar gnus-nastygram-message
1378 "The following article was inappropriately posted to %s.\n\n"
1379 "Format string to insert in nastygrams.
1380 The current group name will be inserted at \"%s\".")
1382 (defun gnus-summary-mail-nastygram (n)
1383 "Send a nastygram to the author of the current article."
1385 (when (or gnus-expert-user
1387 "Really send a nastygram to the author of the current article? "))
1388 (let ((group gnus-newsgroup-name))
1389 (gnus-summary-reply-with-original n)
1390 (set-buffer gnus-message-buffer)
1392 (insert (format gnus-nastygram-message group))
1393 (message-send-and-exit))))
1395 (defun gnus-summary-mail-crosspost-complaint (n)
1396 "Send a complaint about crossposting to the current article(s)."
1398 (let ((articles (gnus-summary-work-articles n))
1400 (while (setq article (pop articles))
1401 (set-buffer gnus-summary-buffer)
1402 (gnus-summary-goto-subject article)
1403 (let ((group (gnus-group-real-name gnus-newsgroup-name))
1404 newsgroups followup-to)
1405 (gnus-summary-select-article)
1406 (set-buffer gnus-original-article-buffer)
1407 (if (and (<= (length (message-tokenize-header
1409 (mail-fetch-field "newsgroups"))
1412 (or (not (setq followup-to (mail-fetch-field "followup-to")))
1413 (not (member group (message-tokenize-header
1414 followup-to ", ")))))
1416 (gnus-message 1 "Followup-to restricted")
1417 (gnus-message 1 "Not a crossposted article"))
1418 (set-buffer gnus-summary-buffer)
1419 (gnus-summary-reply-with-original 1)
1420 (set-buffer gnus-message-buffer)
1422 (insert (format gnus-crosspost-complaint newsgroups group))
1423 (message-goto-subject)
1424 (re-search-forward " *$")
1425 (replace-match " (crosspost notification)" t t)
1426 (gnus-deactivate-mark)
1427 (when (gnus-y-or-n-p "Send this complaint? ")
1428 (message-send-and-exit)))))))
1430 (defun gnus-mail-parse-comma-list ()
1433 (skip-chars-forward " ")
1436 (skip-chars-forward "^,")
1441 (narrow-to-region beg (point))
1444 (while (search-forward "\"" nil t)
1448 (skip-chars-forward ",")
1449 (skip-chars-forward "^,"))
1450 (skip-chars-backward " ")
1451 (push (buffer-substring beg (point))
1453 (skip-chars-forward "^,")
1454 (skip-chars-forward ", "))
1457 (defun gnus-inews-add-to-address (group)
1458 (let ((to-address (mail-fetch-field "to")))
1459 (when (and to-address
1461 ;; This mail group doesn't have a `to-list', so we add one
1463 (when (gnus-y-or-n-p
1464 (format "Do you want to add this as `to-list': %s " to-address))
1465 (gnus-group-add-parameter group (cons 'to-list to-address))))))
1467 (defun gnus-put-message ()
1468 "Put the current message in some group and return to Gnus."
1470 (let ((reply gnus-article-reply)
1471 (winconf gnus-prev-winconf)
1472 (group gnus-newsgroup-name))
1474 (not (gnus-group-read-only-p group)))
1475 (setq group (read-string "Put in group: " nil (gnus-writable-groups))))
1477 (when (gnus-gethash group gnus-newsrc-hashtb)
1478 (error "No such group: %s" group))
1482 (message-narrow-to-headers)
1483 (let ((gnus-deletable-headers nil))
1484 (message-generate-headers
1485 (if (message-news-p)
1486 message-required-news-headers
1487 message-required-mail-headers)))
1488 (goto-char (point-max))
1489 (insert "Gcc: " group "\n")
1492 (when (and (get-buffer gnus-group-buffer)
1493 (gnus-buffer-exists-p (car-safe reply))
1495 (set-buffer (car reply))
1496 (gnus-summary-mark-article-as-replied (cdr reply)))
1498 (set-window-configuration winconf))))
1500 (defun gnus-article-mail (yank)
1501 "Send a reply to the address near point.
1502 If YANK is non-nil, include the original article."
1506 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
1507 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
1509 (gnus-msg-mail address)
1511 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
1513 (defvar nntp-server-type)
1515 "Send a bug report to the Gnus maintainers."
1517 (unless (gnus-alive-p)
1518 (error "Gnus has been shut down"))
1519 (gnus-setup-message (if (message-mail-user-agent) 'message 'bug)
1520 (unless (message-mail-user-agent)
1521 (message-pop-to-buffer "*Gnus Bug*")
1522 (delete-other-windows)
1523 (when gnus-bug-create-help-buffer
1524 (switch-to-buffer "*Gnus Help Bug*")
1526 (insert gnus-bug-message)
1527 (goto-char (point-min))
1529 (set-buffer "*Gnus Bug*")))
1530 (let ((message-this-is-mail t))
1531 (message-setup `((To . ,gnus-maintainer) (Subject . ""))))
1532 (when gnus-bug-create-help-buffer
1533 (push `(gnus-bug-kill-buffer) message-send-actions))
1534 (goto-char (point-min))
1535 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
1537 (insert gnus-product-name " " gnus-version-number
1538 " (r" gnus-revision-number ") "
1539 "based on " gnus-original-product-name " v"
1540 gnus-original-version-number "\n"
1541 (emacs-version) "\n")
1542 (when (and (boundp 'nntp-server-type)
1543 (stringp nntp-server-type))
1544 (insert nntp-server-type))
1545 (insert "\n\n\n\n\n")
1546 (let (mime-content-types)
1547 (mime-edit-insert-tag
1548 "application" "emacs-lisp"
1549 "\nContent-Disposition: inline\nContent-Description: User settings"))
1550 (insert (with-temp-buffer
1553 (let (mime-content-types)
1554 (mime-edit-insert-tag "text" "plain"))
1555 (goto-char (point-min))
1556 (search-forward "Subject: " nil t)
1559 (defun gnus-bug-kill-buffer ()
1560 (when (get-buffer "*Gnus Help Bug*")
1561 (kill-buffer "*Gnus Help Bug*")))
1563 (defun gnus-summary-yank-message (buffer n)
1564 "Yank the current article into a composed message."
1566 (list (completing-read "Buffer: " (mapcar 'list (message-buffers)) nil t)
1567 current-prefix-arg))
1568 (when (gnus-buffer-live-p buffer)
1569 (let ((summary-frame (selected-frame))
1570 (message-frame (when (static-if (featurep 'xemacs)
1571 (device-on-window-system-p)
1573 (let ((window (get-buffer-window buffer t)))
1575 (window-frame window)))))
1576 (separator (concat "^" (regexp-quote mail-header-separator)
1578 (gnus-summary-iterate n
1579 (gnus-summary-select-article)
1580 (gnus-copy-article-buffer)
1581 (when (frame-live-p message-frame)
1582 (raise-frame message-frame)
1583 (select-frame message-frame))
1584 (with-current-buffer buffer
1585 (when (save-excursion
1587 (let (case-fold-search)
1588 (and (not (re-search-backward separator nil t))
1589 (re-search-forward separator nil t))))
1590 (goto-char (match-end 0)))
1591 (message-yank-buffer gnus-article-copy))
1592 (select-frame summary-frame))
1593 (when (frame-live-p message-frame)
1594 (select-frame message-frame)))))
1596 (defun gnus-debug ()
1597 "Attempts to go through the Gnus source file and report what variables have been changed.
1598 The source file has to be in the Emacs load path."
1600 (let ((files gnus-debug-files)
1602 file expr olist sym)
1603 (gnus-message 4 "Please wait while we snoop your variables...")
1604 ;; Go through all the files looking for non-default values for variables.
1607 (set-buffer (gnus-get-buffer-create " *gnus bug info*"))
1610 (when (and (setq file (locate-library (pop files)))
1611 (file-exists-p file))
1612 (insert-file-contents file)
1613 (goto-char (point-min))
1614 (if (not (re-search-forward "^;;* *Internal variables" nil t))
1615 (gnus-message 4 "Malformed sources in file %s" file)
1616 (narrow-to-region (point-min) (point))
1617 (goto-char (point-min))
1618 (while (setq expr (ignore-errors (read (current-buffer))))
1620 (and (memq (car expr) '(defvar defcustom defvoo))
1621 (stringp (nth 3 expr))
1622 (not (memq (nth 1 expr) gnus-debug-exclude-variables))
1623 (or (not (boundp (nth 1 expr)))
1624 (not (equal (eval (nth 2 expr))
1625 (symbol-value (nth 1 expr)))))
1626 (push (nth 1 expr) olist)))))))
1627 (kill-buffer (current-buffer)))
1628 (when (setq olist (nreverse olist))
1629 (insert ";----------------- Environment follows ------------------\n\n"))
1631 (if (boundp (car olist))
1633 (pp `(setq ,(car olist)
1634 ,(if (or (consp (setq sym (symbol-value (car olist))))
1636 (not (or (eq sym nil)
1638 (list 'quote (symbol-value (car olist)))
1639 (symbol-value (car olist))))
1642 (format "(setq %s 'whatever)\n" (car olist))))
1643 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
1644 (setq olist (cdr olist)))
1645 ;; Remove any control chars - they seem to cause trouble for some
1646 ;; mailers. (Byte-compiled output from the stuff above.)
1648 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
1649 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
1651 ;; Break MIME tags purposely.
1653 (while (re-search-forward mime-edit-tag-regexp nil t)
1654 (goto-char (1+ (match-beginning 0)))
1657 ;;; Treatment of rejected articles.
1660 (defun gnus-summary-resend-bounced-mail (&optional fetch)
1661 "Re-mail the current message.
1662 This only makes sense if the current message is a bounce message than
1663 contains some mail you have written which has been bounced back to
1665 If FETCH, try to fetch the article that this is a reply to, if indeed
1668 (gnus-summary-select-article t)
1669 (set-buffer gnus-original-article-buffer)
1670 (gnus-setup-message 'compose-bounce
1671 (let* ((references (mail-fetch-field "references"))
1672 (parent (and references (gnus-parent-id references))))
1674 ;; If there are references, we fetch the article we answered to.
1676 (gnus-summary-refer-article parent)
1677 (gnus-summary-show-all-headers)))))
1681 (defun gnus-inews-group-method (group)
1683 ;; If the group doesn't exist, we assume
1684 ;; it's an archive group...
1685 ((and (null (gnus-get-info group))
1686 (eq (car (gnus-server-to-method gnus-message-archive-method))
1687 (car (gnus-server-to-method (gnus-group-method group)))))
1688 gnus-message-archive-method)
1690 ((gnus-info-method (gnus-get-info group))
1691 (gnus-info-method (gnus-get-info group)))
1693 (t (gnus-server-to-method (gnus-group-method group)))))
1695 ;; Do Gcc handling, which copied the message over to some group.
1696 (defun gnus-inews-do-gcc (&optional gcc)
1700 (message-narrow-to-headers)
1701 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
1702 (coding-system-for-write 'raw-text)
1703 (output-coding-system 'raw-text)
1704 groups group method group-art
1705 mml-externalize-attachments)
1707 (message-remove-header "gcc")
1709 (setq groups (message-unquote-tokens
1710 (message-tokenize-header gcc " ,")))
1711 ;; Copy the article over to some group(s).
1712 (while (setq group (pop groups))
1713 (unless (gnus-check-server
1714 (setq method (gnus-inews-group-method group)))
1715 (error "Can't open server %s" (if (stringp method) method
1717 (unless (gnus-request-group group nil method)
1718 (gnus-request-create-group group method))
1719 (setq mml-externalize-attachments
1720 (if (stringp gnus-gcc-externalize-attachments)
1721 (string-match gnus-gcc-externalize-attachments group)
1722 gnus-gcc-externalize-attachments))
1724 (nnheader-set-temp-buffer " *acc*")
1725 (insert-buffer-substring message-encoding-buffer)
1726 (gnus-run-hooks 'gnus-before-do-gcc-hook)
1727 (goto-char (point-min))
1728 (when (re-search-forward
1729 (concat "^" (regexp-quote mail-header-separator) "$")
1731 (replace-match "" t t ))
1732 (unless (setq group-art
1733 (gnus-request-accept-article group method t t))
1734 (gnus-message 1 "Couldn't store article in group %s: %s"
1735 group (gnus-status-message method))
1737 (when (and group-art
1738 (or gnus-gcc-mark-as-read
1739 gnus-inews-mark-gcc-as-read))
1740 (gnus-group-mark-article-read group (cdr group-art)))
1741 (kill-buffer (current-buffer)))))))))
1743 (defun gnus-inews-insert-gcc ()
1744 "Insert Gcc headers based on `gnus-outgoing-message-group'."
1747 (message-narrow-to-headers)
1748 (let* ((group gnus-outgoing-message-group)
1750 ((gnus-functionp group)
1752 ((or (stringp group) (list group))
1756 (if (stringp gcc) gcc
1757 (mapconcat 'identity gcc " "))
1760 (defun gnus-inews-insert-archive-gcc (&optional group)
1761 "Insert the Gcc to say where the article is to be archived."
1762 (let* ((var gnus-message-archive-group)
1763 (group (or group gnus-newsgroup-name ""))
1765 (and gnus-newsgroup-name
1766 (not (equal gnus-newsgroup-name ""))
1767 (gnus-group-find-parameter
1768 gnus-newsgroup-name 'gcc-self)))
1772 ((null gnus-message-archive-method)
1776 ;; Just a single group.
1779 ;; We don't want this.
1781 ((and (listp var) (stringp (car var)))
1782 ;; A list of groups.
1784 ((gnus-functionp var)
1786 (funcall var group))
1788 ;; An alist of regexps/functions/forms.
1793 ((stringp (caar var))
1795 (when (string-match (caar var) group)
1797 ((gnus-functionp (car var))
1799 (funcall (car var) group))
1801 (eval (car var)))))))
1802 (setq var (cdr var)))
1805 (when (or groups gcc-self-val)
1806 (when (stringp groups)
1807 (setq groups (list groups)))
1810 (message-narrow-to-headers)
1811 (goto-char (point-max))
1814 ;; Use the `gcc-self' param value instead.
1817 (if (stringp gcc-self-val)
1820 (if (not (eq gcc-self-val 'none))
1825 ;; Use the list of groups.
1826 (while (setq name (pop groups))
1827 (insert (if (string-match ":" name)
1829 (gnus-group-prefixed-name
1830 name gnus-message-archive-method)))
1837 (defun gnus-configure-posting-styles (&optional group-name)
1838 "Configure posting styles according to `gnus-posting-styles'."
1839 (unless gnus-inhibit-posting-styles
1840 (let ((group (or group-name gnus-newsgroup-name ""))
1841 (styles gnus-posting-styles)
1842 style match variable attribute value v results
1843 filep name address element)
1844 ;; If the group has a posting-style parameter, add it at the end with a
1845 ;; regexp matching everything, to be sure it takes precedence over all
1847 (when gnus-newsgroup-name
1848 (let ((tmp-style (gnus-group-find-parameter group 'posting-style t)))
1850 (setq styles (append styles (list (cons ".*" tmp-style)))))))
1851 ;; Go through all styles and look for matches.
1852 (dolist (style styles)
1853 (setq match (pop style))
1854 (goto-char (point-min))
1857 ;; Regexp string match on the group name.
1858 (string-match match group))
1860 ;; Obsolete format of header match.
1861 (and (gnus-buffer-live-p gnus-article-copy)
1862 (with-current-buffer gnus-article-copy
1863 (let ((header (message-fetch-field (pop style))))
1865 (string-match (pop style) header))))))
1866 ((or (symbolp match)
1867 (gnus-functionp match))
1869 ((gnus-functionp match)
1870 ;; Function to be called.
1873 ;; Variable to be checked.
1874 (symbol-value match))))
1877 ((eq (car match) 'header)
1878 ;; New format of header match.
1879 (and (gnus-buffer-live-p gnus-article-copy)
1880 (with-current-buffer gnus-article-copy
1881 (let ((header (message-fetch-field (nth 1 match))))
1883 (string-match (nth 2 match) header))))))
1885 ;; This is a form to be evaled.
1887 ;; We have a match, so we set the variables.
1888 (dolist (attribute style)
1889 (setq element (pop attribute)
1894 ((eq (car attribute) ':file)
1897 ((eq (car attribute) :value)
1901 ;; We get the value.
1906 ((or (symbolp value)
1907 (gnus-functionp value))
1908 (cond ((gnus-functionp value)
1911 (symbol-value value))))
1914 ;; Translate obsolescent value.
1916 ((eq element 'signature-file)
1917 (setq element 'signature
1919 ((eq element 'x-face-file)
1920 (setq element 'x-face
1922 ;; Get the contents of file elems.
1924 (setq v (with-temp-buffer
1925 (insert-file-contents v)
1926 (goto-char (point-max))
1930 (setq results (delq (assoc element results) results))
1931 (push (cons element v) results))))
1932 ;; Now we have all the styles, so we insert them.
1933 (setq name (assq 'name results)
1934 address (assq 'address results))
1935 (setq results (delq name (delq address results)))
1936 ;; make-local-hook is not obsolete in Emacs 20 or XEmacs.
1937 (make-local-hook 'message-setup-hook)
1938 (dolist (result results)
1939 (add-hook 'message-setup-hook
1941 ((eq 'eval (car result))
1943 ((eq 'body (car result))
1947 (insert ,(cdr result)))))
1948 ((eq 'signature (car result))
1949 (set (make-local-variable 'message-signature) nil)
1950 (set (make-local-variable 'message-signature-file) nil)
1951 (if (not (cdr result))
1955 (let ((message-signature ,(cdr result)))
1956 (when message-signature
1957 (message-insert-signature)))))))
1960 (if (symbolp (car result))
1961 (capitalize (symbol-name (car result)))
1965 (message-remove-header ,header)
1966 (let ((value ,(cdr result)))
1969 (insert ,header ": " value "\n"))))))))
1971 (when (or name address)
1972 (add-hook 'message-setup-hook
1974 (set (make-local-variable 'user-mail-address)
1975 ,(or (cdr address) user-mail-address))
1976 (let ((user-full-name ,(or (cdr name) (user-full-name)))
1978 ,(or (cdr address) user-mail-address)))
1980 (message-remove-header "From")
1982 (insert "From: " (message-make-from) "\n"))))
1986 ;;; @ for MIME Edit mode
1989 (defun gnus-maybe-setup-default-charset ()
1991 (and (boundp 'gnus-summary-buffer)
1992 (buffer-live-p gnus-summary-buffer)
1994 (set-buffer gnus-summary-buffer)
1995 default-mime-charset))))
1998 (make-local-variable 'default-mime-charset)
1999 (setq default-mime-charset charset)
2003 ;;; @ for MIME view mode
2006 (defun gnus-following-method (buf)
2007 (gnus-setup-message 'reply-yank
2009 (if (message-news-p)
2011 (message-reply nil 'wide))
2012 (let ((message-reply-buffer buf))
2013 (message-yank-original))
2014 (message-goto-body))
2018 ;;; Allow redefinition of functions.
2024 ;;; gnus-msg.el ends here