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 ;;; Internal variables.
251 (defvar gnus-inhibit-posting-styles nil
252 "Inhibit the use of posting styles.")
254 (defvar gnus-message-buffer "*Mail Gnus*")
255 (defvar gnus-article-copy nil)
256 (defvar gnus-check-before-posting nil)
257 (defvar gnus-last-posting-server nil)
258 (defvar gnus-message-group-art nil)
260 (defvar gnus-msg-force-broken-reply-to nil)
262 (defconst gnus-bug-message
263 (format "Sending a bug report to the Gnus Towers.
264 ========================================
266 This gnus is the %s%s.
267 If you think the bug is a Semi-gnus bug, send a bug report to Semi-gnus
268 Developers. (the addresses below are mailing list addresses)
270 ========================================
272 The buffer below is a mail buffer. When you press `C-c C-c', it will
273 be sent to the Gnus Bug Exterminators.
275 The thing near the bottom of the buffer is how the environment
276 settings will be included in the mail. Please do not delete that.
277 They will tell the Bug People what your environment is, so that it
278 will be easier to locate the bugs.
280 If you have found a bug that makes Emacs go \"beep\", set
281 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
282 and include the backtrace in your bug report.
284 Please describe the bug in annoying, painstaking detail.
286 Thank you for your help in stamping out bugs.
289 (if (string= gnus-product-name "Semi-gnus")
291 ", a modified version of Semi-gnus")))
294 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
295 (autoload 'news-setup "rnewspost")
296 (autoload 'news-reply-mode "rnewspost")
297 (autoload 'rmail-dont-reply-to "mail-utils")
298 (autoload 'rmail-output "rmailout"))
302 ;;; Gnus Posting Functions
305 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
306 "p" gnus-summary-post-news
307 "i" gnus-summary-news-other-window
308 "f" gnus-summary-followup
309 "F" gnus-summary-followup-with-original
310 "c" gnus-summary-cancel-article
311 "s" gnus-summary-supersede-article
312 "r" gnus-summary-reply
313 "y" gnus-summary-yank-message
314 "R" gnus-summary-reply-with-original
315 "w" gnus-summary-wide-reply
316 "W" gnus-summary-wide-reply-with-original
317 "v" gnus-summary-very-wide-reply
318 "V" gnus-summary-very-wide-reply-with-original
319 "n" gnus-summary-followup-to-mail
320 "N" gnus-summary-followup-to-mail-with-original
321 "m" gnus-summary-mail-other-window
322 "u" gnus-uu-post-news
323 "\M-c" gnus-summary-mail-crosspost-complaint
324 "Br" gnus-summary-reply-broken-reply-to
325 "BR" gnus-summary-reply-broken-reply-to-with-original
326 "om" gnus-summary-mail-forward
327 "op" gnus-summary-post-forward
328 "Om" gnus-summary-digest-mail-forward
329 "Op" gnus-summary-digest-post-forward)
331 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
332 "b" gnus-summary-resend-bounced-mail
333 ;; "c" gnus-summary-send-draft
334 "r" gnus-summary-resend-message
335 "e" gnus-summary-resend-message-edit)
337 ;;; Internal functions.
339 (defvar gnus-article-reply nil)
340 (defmacro gnus-setup-message (config &rest forms)
341 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
342 (buffer (make-symbol "gnus-setup-message-buffer"))
343 (article (make-symbol "gnus-setup-message-article"))
344 (group (make-symbol "gnus-setup-message-group")))
345 `(let ((,winconf (current-window-configuration))
346 (,buffer (buffer-name (current-buffer)))
347 (,article gnus-article-reply)
348 (,group gnus-newsgroup-name)
349 (message-header-setup-hook
350 (copy-sequence message-header-setup-hook))
351 (message-mode-hook (copy-sequence message-mode-hook))
352 (message-startup-parameter-alist
353 '((reply-buffer . gnus-copy-article-buffer)
354 (original-buffer . gnus-original-article-buffer)
355 (user-agent . Gnus))))
356 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
357 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
358 ;; #### FIXME: for a reason that I did not manage to identify yet,
359 ;; the variable `gnus-newsgroup-name' does not honor a dynamically
360 ;; scoped or setq'ed value from a caller like `C-u gnus-summary-mail'.
361 ;; After evaluation of @forms below, it gets the value we actually want
362 ;; to override, and the posting styles are used. For that reason, I've
363 ;; added an optional argument to `gnus-configure-posting-styles' to
364 ;; make sure that the correct value for the group name is used. -- drv
365 (add-hook 'message-mode-hook
367 (gnus-configure-posting-styles ,group)))
371 (gnus-inews-add-send-actions ,winconf ,buffer ,article ,config)
372 (gnus-inews-insert-draft-meta-information ,group ,article)
373 (setq gnus-message-buffer (current-buffer))
374 (set (make-local-variable 'gnus-message-group-art)
375 (cons ,group ,article))
376 (set (make-local-variable 'gnus-newsgroup-name) ,group)
377 (gnus-maybe-setup-default-charset)
378 (gnus-run-hooks 'gnus-message-setup-hook))
380 (gnus-configure-windows ,config t)
381 (run-hooks 'post-command-hook)
382 (set-buffer-modified-p nil))))
384 (defun gnus-inews-insert-draft-meta-information (group article)
387 (not (string= group ""))
388 (not (message-fetch-field gnus-draft-meta-information-header)))
389 (goto-char (point-min))
390 (insert gnus-draft-meta-information-header ": (\"" group "\" "
391 (if article (number-to-string
398 (defun gnus-msg-mail (&optional to subject other-headers continue
399 switch-action yank-action send-actions)
400 "Start editing a mail message to be sent.
401 Like `message-mail', but with Gnus paraphernalia, particularly the
402 Gcc: header for archiving purposes."
404 (let ((buf (current-buffer))
406 (gnus-setup-message 'message
407 (message-mail to subject other-headers continue
408 nil yank-action send-actions))
410 (setq mail-buf (current-buffer))
411 (switch-to-buffer buf)
412 (apply switch-action mail-buf nil)))
413 ;; COMPOSEFUNC should return t if succeed. Undocumented ???
416 (defvar save-selected-window-window)
419 (defun gnus-button-mailto (address)
421 (set-buffer (gnus-copy-article-buffer))
422 (gnus-setup-message 'message
423 (message-reply address))
424 (and (boundp 'save-selected-window-window)
425 (not (window-live-p save-selected-window-window))
426 (setq save-selected-window-window (selected-window))))
429 (defun gnus-button-reply (&optional to-address wide)
430 "Like `message-reply'."
432 (gnus-setup-message 'message
433 (message-reply to-address wide))
434 (and (boundp 'save-selected-window-window)
435 (not (window-live-p save-selected-window-window))
436 (setq save-selected-window-window (selected-window))))
439 (define-mail-user-agent 'gnus-user-agent
440 'gnus-msg-mail 'message-send-and-exit
441 'message-kill-buffer 'message-send-hook)
443 (defun gnus-setup-posting-charset (group)
444 (let ((alist gnus-group-posting-charset-alist)
445 (group (or group ""))
449 (while (setq elem (pop alist))
450 (when (or (and (stringp (car elem))
451 (string-match (car elem) group))
452 (and (gnus-functionp (car elem))
453 (funcall (car elem) group))
454 (and (symbolp (car elem))
455 (symbol-value (car elem))))
456 (throw 'found (cons (cadr elem) (caddr elem)))))))))
458 (defun gnus-inews-add-send-actions (winconf buffer article &optional config)
459 (make-local-hook 'message-sent-hook)
460 (add-hook 'message-sent-hook (if gnus-agent 'gnus-agent-possibly-do-gcc
461 'gnus-inews-do-gcc) nil t)
463 (make-local-hook 'message-header-hook)
464 (add-hook 'message-header-hook 'gnus-agent-possibly-save-gcc nil t))
465 (setq message-post-method
467 (gnus-post-method arg ,gnus-newsgroup-name)))
468 (setq message-user-agent (gnus-extended-version))
469 (when (not message-use-multi-frames)
471 `(set-window-configuration ,winconf) 'exit 'postpone 'kill))
473 `(when (gnus-buffer-exists-p ,buffer)
477 (if (eq config 'forward)
478 `(gnus-summary-mark-article-as-forwarded ',article)
479 `(gnus-summary-mark-article-as-replied ',article)))))
482 (put 'gnus-setup-message 'lisp-indent-function 1)
483 (put 'gnus-setup-message 'edebug-form-spec '(form body))
485 ;;; Post news commands of Gnus group mode and summary mode
487 (defun gnus-group-mail (&optional arg)
488 "Start composing a mail.
489 If ARG, use the group under the point to find a posting style.
490 If ARG is 1, prompt for a group name to find the posting style."
492 ;; We can't `let' gnus-newsgroup-name here, since that leads
493 ;; to local variables leaking.
494 (let ((group gnus-newsgroup-name)
495 (buffer (current-buffer)))
498 (setq gnus-newsgroup-name
500 (if (= 1 (prefix-numeric-value arg))
501 (completing-read "Use posting style of group: "
502 gnus-active-hashtb nil
503 (gnus-read-active-file-p))
504 (gnus-group-group-name))
506 ;; #### see comment in gnus-setup-message -- drv
507 (gnus-setup-message 'message (message-mail)))
510 (setq gnus-newsgroup-name group)))))
512 (defun gnus-group-news (&optional arg)
513 "Start composing a news.
514 If ARG, post to group under point.
515 If ARG is 1, prompt for group name to post to.
517 This function prepares a news even when using mail groups. This is useful
518 for posting messages to mail groups without actually sending them over the
519 network. The corresponding backend must have a 'request-post method."
521 ;; We can't `let' gnus-newsgroup-name here, since that leads
522 ;; to local variables leaking.
523 (let ((group gnus-newsgroup-name)
524 (buffer (current-buffer)))
527 (setq gnus-newsgroup-name
529 (if (= 1 (prefix-numeric-value arg))
530 (completing-read "Use group: "
531 gnus-active-hashtb nil
532 (gnus-read-active-file-p))
533 (gnus-group-group-name))
535 ;; #### see comment in gnus-setup-message -- drv
536 (gnus-setup-message 'message
537 (message-news (gnus-group-real-name gnus-newsgroup-name))))
540 (setq gnus-newsgroup-name group)))))
542 (defun gnus-group-post-news (&optional arg)
543 "Start composing a message (a news by default).
544 If ARG, post to group under point. If ARG is 1, prompt for group name.
545 Depending on the selected group, the message might be either a mail or
548 ;; Bind this variable here to make message mode hooks work ok.
549 (let ((gnus-newsgroup-name
551 (if (= 1 (prefix-numeric-value arg))
552 (completing-read "Newsgroup: " gnus-active-hashtb nil
553 (gnus-read-active-file-p))
554 (gnus-group-group-name))
556 (gnus-post-news 'post gnus-newsgroup-name)))
558 (defun gnus-summary-mail-other-window (&optional arg)
559 "Start composing a mail in another window.
560 Use the posting of the current group by default.
561 If ARG, don't do that. If ARG is 1, prompt for group name to find the
564 ;; We can't `let' gnus-newsgroup-name here, since that leads
565 ;; to local variables leaking.
566 (let ((group gnus-newsgroup-name)
567 (buffer (current-buffer)))
570 (setq gnus-newsgroup-name
572 (if (= 1 (prefix-numeric-value arg))
573 (completing-read "Use group: "
574 gnus-active-hashtb nil
575 (gnus-read-active-file-p))
577 gnus-newsgroup-name))
578 ;; #### see comment in gnus-setup-message -- drv
579 (gnus-setup-message 'message (message-mail)))
582 (setq gnus-newsgroup-name group)))))
584 (defun gnus-summary-news-other-window (&optional arg)
585 "Start composing a news in another window.
586 Post to the current group by default.
587 If ARG, don't do that. If ARG is 1, prompt for group name to post to.
589 This function prepares a news even when using mail groups. This is useful
590 for posting messages to mail groups without actually sending them over the
591 network. The corresponding backend must have a 'request-post method."
593 ;; We can't `let' gnus-newsgroup-name here, since that leads
594 ;; to local variables leaking.
595 (let ((group gnus-newsgroup-name)
596 (buffer (current-buffer)))
599 (setq gnus-newsgroup-name
601 (if (= 1 (prefix-numeric-value arg))
602 (completing-read "Use group: "
603 gnus-active-hashtb nil
604 (gnus-read-active-file-p))
606 gnus-newsgroup-name))
607 ;; #### see comment in gnus-setup-message -- drv
608 (gnus-setup-message 'message
609 (message-news (gnus-group-real-name gnus-newsgroup-name))))
612 (setq gnus-newsgroup-name group)))))
614 (defun gnus-summary-post-news (&optional arg)
615 "Start composing a message. Post to the current group by default.
616 If ARG, don't do that. If ARG is 1, prompt for a group name to post to.
617 Depending on the selected group, the message might be either a mail or
620 ;; Bind this variable here to make message mode hooks work ok.
621 (let ((gnus-newsgroup-name
623 (if (= 1 (prefix-numeric-value arg))
624 (completing-read "Newsgroup: " gnus-active-hashtb nil
625 (gnus-read-active-file-p))
627 gnus-newsgroup-name)))
628 (gnus-post-news 'post gnus-newsgroup-name)))
631 (defun gnus-summary-followup (yank &optional force-news)
632 "Compose a followup to an article.
633 If prefix argument YANK is non-nil, the original article is yanked
635 YANK is a list of elements, where the car of each element is the
636 article number, and the two following numbers is the region to be
639 (list (and current-prefix-arg
640 (gnus-summary-work-articles 1))))
642 (gnus-summary-goto-subject
643 (if (listp (car yank))
646 (save-window-excursion
647 (gnus-summary-select-article))
648 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
649 (gnus-newsgroup-name gnus-newsgroup-name))
651 (gnus-post-news nil gnus-newsgroup-name
652 headers gnus-article-buffer
653 yank nil force-news)))
655 (defun gnus-summary-followup-with-original (n &optional force-news)
656 "Compose a followup to an article and include the original article."
658 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
660 (defun gnus-summary-followup-to-mail (&optional arg)
661 "Followup to the current mail message via news."
663 (list (and current-prefix-arg
664 (gnus-summary-work-articles 1))))
665 (gnus-summary-followup arg t))
667 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
668 "Followup to the current mail message via news."
670 (gnus-summary-followup (gnus-summary-work-articles arg) t))
672 (defun gnus-inews-yank-articles (articles)
673 (let (beg article yank-string
674 (more-than-one (cdr articles))
675 (cur (current-buffer))
678 (while (setq article (pop articles))
679 (when (listp article)
680 (setq yank-string (nth 1 article)
681 article (nth 0 article)))
682 (save-window-excursion
683 (set-buffer gnus-summary-buffer)
684 (gnus-summary-select-article nil nil nil article)
685 (gnus-summary-remove-process-mark article))
687 ;; Gathering references.
689 (setq refs (message-list-references
691 (mail-header-references gnus-current-headers)
692 (mail-header-message-id gnus-current-headers)))
693 (when message-use-multi-frames
694 (when (setq window (get-buffer-window cur t))
695 (select-frame (window-frame window)))))
697 (gnus-copy-article-buffer nil yank-string)
698 (let ((message-reply-buffer gnus-article-copy)
699 (message-reply-headers
700 ;; The headers are decoded.
701 (with-current-buffer gnus-article-copy
702 (nnheader-parse-head t))))
703 (message-yank-original)
704 (setq beg (or beg (mark t))))
709 ;; Replace with the gathered references.
713 (message-narrow-to-headers)
714 (let ((case-fold-search t))
715 (if (re-search-forward "^References:\\([\t ]+.+\n\\)+" nil t)
717 (goto-char (point-max))))
719 (list (or (assq 'References message-header-format-alist)
720 '(References . message-shorten-references)))
721 (list (cons 'References
722 (mapconcat 'identity (nreverse refs) " "))))
723 (backward-delete-char 1))
729 (defun gnus-summary-cancel-article (&optional n symp)
730 "Cancel an article you posted.
731 Uses the process-prefix convention. If given the symbolic
732 prefix `a', cancel using the standard posting method; if not
733 post using the current select method."
734 (interactive (gnus-interactive "P\ny"))
735 (let ((articles (gnus-summary-work-articles n))
738 (gnus-post-method (eq ',symp 'a) ,gnus-newsgroup-name)))
740 (while (setq article (pop articles))
741 (when (gnus-summary-select-article t nil nil article)
742 (when (gnus-eval-in-buffer-window gnus-article-buffer
744 (set-buffer gnus-original-article-buffer)
745 (message-cancel-news)))
746 (gnus-summary-mark-as-read article gnus-canceled-mark)
747 (gnus-cache-remove-article 1))
748 (gnus-article-hide-headers-if-wanted))
749 (gnus-summary-remove-process-mark article))))
751 (defun gnus-summary-supersede-article ()
752 "Compose an article that will supersede a previous article.
753 This is done simply by taking the old article and adding a Supersedes
754 header line with the old Message-ID."
756 (let ((article (gnus-summary-article-number)))
757 (gnus-setup-message 'reply-yank
758 (gnus-summary-select-article t)
759 (set-buffer gnus-original-article-buffer)
763 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
765 (set-buffer ,gnus-summary-buffer)
766 (gnus-cache-possibly-remove-article ,article nil nil nil t)
767 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
768 message-send-actions))))
772 (defun gnus-copy-article-buffer (&optional article-buffer yank-string)
773 ;; make a copy of the article buffer with all text properties removed
774 ;; this copy is in the buffer gnus-article-copy.
775 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
776 ;; this buffer should be passed to all mail/news reply/post routines.
777 (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
778 (let ((article-buffer (or article-buffer gnus-article-buffer))
780 (if (not (and (get-buffer article-buffer)
781 (gnus-buffer-exists-p article-buffer)))
782 (error "Can't find any article buffer")
784 (set-buffer article-buffer)
785 (let ((gnus-newsgroup-charset (or gnus-article-charset
786 gnus-newsgroup-charset))
787 (gnus-newsgroup-ignored-charsets
788 (or gnus-article-ignored-charsets
789 gnus-newsgroup-ignored-charsets)))
791 ;; Copy over the (displayed) article buffer, delete
792 ;; hidden text and remove text properties.
794 (let ((inhibit-read-only t))
795 (copy-to-buffer gnus-article-copy (point-min) (point-max))
796 (set-buffer gnus-article-copy)
799 (delete-region (point) (point-max))
800 (insert yank-string))
801 ;; Encode bitmap smileys to ordinary text.
802 ;; Possibly, the original text might be restored.
803 (static-unless (featurep 'xemacs)
804 (when (featurep 'smiley-mule)
805 (smiley-encode-buffer)))
806 (gnus-article-delete-text-of-type 'annotation)
807 (gnus-remove-text-with-property 'gnus-prev)
808 (gnus-remove-text-with-property 'gnus-next)
809 (gnus-remove-text-with-property 'gnus-decoration)
810 (gnus-remove-text-with-property 'x-face-mule-bitmap-image)
813 (static-if (featurep 'xemacs)
814 ;; Revome smiley extents for (possibly) XEmacs 21.1.
816 (buffer-substring-no-properties (point-min)
818 (buffer-substring-no-properties (point-min) (point-max)))
820 ;; Find the original headers.
821 (set-buffer gnus-original-article-buffer)
822 (goto-char (point-min))
823 (while (looking-at message-unix-mail-delimiter)
826 end (or (message-goto-body) beg))
827 ;; Delete the headers from the displayed articles.
828 (set-buffer gnus-article-copy)
829 (delete-region (goto-char (point-min))
830 (or (message-goto-body) (point-max)))
831 ;; Insert the original article headers.
832 (insert-buffer-substring gnus-original-article-buffer beg end)
834 (let ((gnus-article-decode-hook
835 (delq 'article-decode-charset
836 (copy-sequence gnus-article-decode-hook))))
837 ;; Needed for T-gnus.
838 (add-hook 'gnus-article-decode-hook
839 'article-decode-encoded-words)
840 (run-hooks 'gnus-article-decode-hook)))))
843 (defun gnus-post-news (post &optional group header article-buffer yank subject
846 (gnus-copy-article-buffer))
847 (let ((gnus-article-reply (and article-buffer (gnus-summary-article-number)))
848 (add-to-list gnus-add-to-list))
849 (gnus-setup-message (cond (yank 'reply-yank)
850 (article-buffer 'reply)
852 (let* ((group (or group gnus-newsgroup-name))
853 (charset (gnus-group-name-charset nil group))
855 to-address to-group mailing-list to-list
858 (setq to-address (gnus-parameter-to-address group)
859 to-group (gnus-group-find-parameter group 'to-group)
860 to-list (gnus-parameter-to-list group)
861 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
862 mailing-list (when gnus-mailing-list-groups
863 (string-match gnus-mailing-list-groups group))
864 group (gnus-group-name-decode (gnus-group-real-name group)
866 (if (or (and to-group
867 (gnus-news-group-p to-group))
870 (and (gnus-news-group-p
871 (or pgroup gnus-newsgroup-name)
872 (or header gnus-current-article))
878 (message-news (or to-group group))
879 (set-buffer gnus-article-copy)
880 (gnus-msg-treat-broken-reply-to)
881 (message-followup (if (or newsgroup-p force-news)
882 (if (save-restriction
883 (article-narrow-to-head)
884 (message-fetch-field "newsgroups"))
891 (message-mail (or to-address to-list))
892 ;; Arrange for mail groups that have no `to-address' to
893 ;; get that when the user sends off the mail.
894 (when (and (not to-list)
897 (push (list 'gnus-inews-add-to-address pgroup)
898 message-send-actions)))
899 (set-buffer gnus-article-copy)
900 (gnus-msg-treat-broken-reply-to)
901 (message-wide-reply to-address)))
903 (gnus-inews-yank-articles yank))))))
905 (defun gnus-msg-treat-broken-reply-to (&optional force)
906 "Remove the Reply-to header iff broken-reply-to."
908 (gnus-group-find-parameter
909 gnus-newsgroup-name 'broken-reply-to))
911 (message-narrow-to-head)
912 (message-remove-header "reply-to"))))
914 (defun gnus-post-method (arg group &optional silent)
915 "Return the posting method based on GROUP and ARG.
916 If SILENT, don't prompt the user."
917 (let ((gnus-post-method (or (gnus-parameter-post-method group)
919 (group-method (gnus-find-method-for-group group)))
921 ;; If the group-method is nil (which shouldn't happen) we use
922 ;; the default method.
924 (or (and (listp gnus-post-method) ;If not current/native/nil
925 (not (listp (car gnus-post-method))) ; and not a list of methods
926 gnus-post-method) ;then use it.
928 message-post-method))
929 ;; We want the inverse of the default
930 ((and arg (not (eq arg 0)))
931 (if (eq gnus-post-method 'current)
934 ;; We query the user for a post method.
936 (and (listp gnus-post-method)
937 (listp (car gnus-post-method))))
939 ;; Collect all methods we know about.
941 (when (listp gnus-post-method)
942 (if (listp (car gnus-post-method))
944 (list gnus-post-method)))
945 gnus-secondary-select-methods
946 (mapcar 'cdr gnus-server-alist)
947 (mapcar 'car gnus-opened-servers)
948 (list gnus-select-method)
949 (list group-method)))
950 method-alist post-methods method)
951 ;; Weed out all mail methods.
953 (setq method (gnus-server-get-method "" (pop methods)))
954 (when (and (or (gnus-method-option-p method 'post)
955 (gnus-method-option-p method 'post-mail))
956 (not (member method post-methods)))
957 (push method post-methods)))
958 ;; Create a name-method alist.
962 (if (equal (cadr m) "")
963 (list (symbol-name (car m)) m)
964 (list (concat (cadr m) " (" (symbol-name (car m)) ")") m)))
969 (setq gnus-last-posting-server
971 gnus-last-posting-server)
972 ;; Just use the last value.
973 gnus-last-posting-server
975 "Posting method: " method-alist nil t
976 (cons (or gnus-last-posting-server "") 0))))
978 ;; Override normal method.
979 ((and (eq gnus-post-method 'current)
980 (not (memq (car group-method) gnus-discouraged-post-methods))
981 (gnus-get-function group-method 'request-post t))
984 ;; Use gnus-post-method.
985 ((listp gnus-post-method) ;A method...
986 (assert (not (listp (car gnus-post-method)))) ;... not a list of methods.
988 ;; Use the normal select method (nil or native).
989 (t gnus-select-method))))
992 (defun gnus-message-make-user-agent (&optional include-mime-info max-column
994 "Return a user-agent info. If INCLUDE-MIME-INFO is non-nil and the
995 variable `mime-edit-user-agent-value' is bound, the value will be
996 included in the return value. If MAX-COLUMN is specified, the return
997 value will be folded up as it were filled. NEWLINE-PRODUCT specifies
998 whether a newline should be inserted in front of each product-token.
999 If the value is t or `hard', it works strictly. Otherwise, if it is
1000 non-nil (e.g. `soft'), it works semi-strictly.
1002 Here is an example of how to use this function:
1004 \(add-hook 'gnus-message-setup-hook
1006 (setq message-user-agent nil)
1009 (message-narrow-to-headers)
1010 (goto-char (point-max))
1011 (insert \"User-Agent: \"
1012 (gnus-message-make-user-agent t 76 'soft)
1015 (let ((user-agent (if (and include-mime-info
1016 (boundp 'mime-edit-user-agent-value))
1017 (concat (gnus-extended-version)
1019 mime-edit-user-agent-value)
1020 (gnus-extended-version))))
1022 (unless (natnump max-column)
1023 (setq max-column 76))
1025 (set-buffer-multibyte t)
1026 (insert (mapconcat 'identity (split-string user-agent) " "))
1027 (goto-char (point-min))
1029 start agent agents width element swidth)
1030 (while (re-search-forward "\\([^ ]+\\) ?" nil t)
1031 (setq start (match-beginning 0))
1032 (if (eq (char-after start) ?\()
1036 (push (buffer-substring start (point)) agent))
1038 (push (nreverse agent) agents))
1039 (setq agent (list (match-string 1)))))
1041 (push (nreverse agent) agents))
1042 (setq agents (nreverse agents))
1043 (if (> (+ 12 (string-width (caar agents))) max-column)
1044 (setq user-agent "\n"
1049 (setq agent (car agents)
1050 agents (cdr agents))
1051 (when (and (not bol)
1052 (or (memq newline-product '(t hard))
1053 (and newline-product
1055 (string-width (mapconcat 'identity
1058 (setq user-agent (concat user-agent "\n")
1062 (setq element (car agent)
1063 swidth (string-width element)
1066 (setq user-agent (if (member user-agent '("" "\n"))
1067 (concat user-agent element)
1068 (concat user-agent " " element))
1069 width (+ width 1 swidth)
1071 (if (> (+ width 1 swidth) max-column)
1072 (setq user-agent (concat user-agent "\n " element)
1074 (setq user-agent (concat user-agent " " element)
1075 width (+ width 1 swidth)))))))))
1080 ;;; Gnus Mail Functions
1083 ;;; Mail reply commands of Gnus summary mode
1085 (defun gnus-summary-reply (&optional yank wide very-wide)
1086 "Start composing a mail reply to the current message.
1087 If prefix argument YANK is non-nil, the original article is yanked
1089 If WIDE, make a wide reply.
1090 If VERY-WIDE, make a very wide reply."
1092 (list (and current-prefix-arg
1093 (gnus-summary-work-articles 1))))
1095 (if (listp (car yank))
1098 (gnus-article-reply (or article (gnus-summary-article-number)))
1100 ;; Stripping headers should be specified with mail-yank-ignored-headers.
1102 (gnus-summary-goto-subject article))
1103 (gnus-setup-message (if yank 'reply-yank 'reply)
1105 (gnus-summary-select-article)
1106 (dolist (article very-wide)
1107 (gnus-summary-select-article nil nil nil article)
1109 (set-buffer (gnus-copy-article-buffer))
1110 (gnus-msg-treat-broken-reply-to)
1112 (message-narrow-to-head)
1113 (setq headers (concat headers (buffer-string)))))))
1114 (set-buffer (gnus-copy-article-buffer))
1115 (gnus-msg-treat-broken-reply-to gnus-msg-force-broken-reply-to)
1117 (message-narrow-to-head)
1121 (goto-char (point-max)))
1122 (message-reply nil wide)
1124 (gnus-inews-yank-articles yank))
1125 ;; (when (or gnus-message-replysign gnus-message-replyencrypt)
1126 ;; (let (signed encrypted)
1128 ;; (set-buffer gnus-article-buffer)
1129 ;; (setq signed (memq 'signed gnus-article-wash-types))
1130 ;; (setq encrypted (memq 'encrypted gnus-article-wash-types)))
1131 ;; (cond ((and gnus-message-replysign signed)
1132 ;; (mml-secure-message mml-default-sign-method 'sign))
1133 ;; ((and gnus-message-replyencrypt encrypted)
1134 ;; (mml-secure-message mml-default-encrypt-method
1135 ;; (if gnus-message-replysignencrypted
1140 (defun gnus-summary-reply-with-original (n &optional wide)
1141 "Start composing a reply mail to the current message.
1142 The original article will be yanked."
1144 (gnus-summary-reply (gnus-summary-work-articles n) wide))
1146 (defun gnus-summary-reply-broken-reply-to (&optional yank wide very-wide)
1147 "Like `gnus-summary-reply' except removing reply-to field.
1148 If prefix argument YANK is non-nil, the original article is yanked
1150 If WIDE, make a wide reply.
1151 If VERY-WIDE, make a very wide reply."
1153 (list (and current-prefix-arg
1154 (gnus-summary-work-articles 1))))
1155 (let ((gnus-msg-force-broken-reply-to t))
1156 (gnus-summary-reply yank wide very-wide)))
1158 (defun gnus-summary-reply-broken-reply-to-with-original (n &optional wide)
1159 "Like `gnus-summary-reply-with-original' except removing reply-to field.
1160 The original article will be yanked."
1162 (gnus-summary-reply-broken-reply-to (gnus-summary-work-articles n) wide))
1164 (defun gnus-summary-wide-reply (&optional yank)
1165 "Start composing a wide reply mail to the current message.
1166 If prefix argument YANK is non-nil, the original article is yanked
1169 (list (and current-prefix-arg
1170 (gnus-summary-work-articles 1))))
1171 (gnus-summary-reply yank t))
1173 (defun gnus-summary-wide-reply-with-original (n)
1174 "Start composing a wide reply mail to the current message.
1175 The original article will be yanked."
1177 (gnus-summary-reply-with-original n t))
1179 (defun gnus-summary-very-wide-reply (&optional yank)
1180 "Start composing a very wide reply mail to the current message.
1181 If prefix argument YANK is non-nil, the original article is yanked
1184 (list (and current-prefix-arg
1185 (gnus-summary-work-articles 1))))
1186 (gnus-summary-reply yank t (gnus-summary-work-articles yank)))
1188 (defun gnus-summary-very-wide-reply-with-original (n)
1189 "Start composing a very wide reply mail to the current message.
1190 The original article will be yanked."
1193 (gnus-summary-work-articles n) t (gnus-summary-work-articles n)))
1195 (defun gnus-summary-mail-forward (&optional full-headers post)
1196 "Forward the current message(s) to another user.
1197 If process marks exist, forward all marked messages;
1198 If FULL-HEADERS (the prefix), include full headers when forwarding.
1200 Note that this function definition for T-gnus is totally different
1201 from the original Gnus."
1203 (if (null (cdr (gnus-summary-work-articles nil)))
1204 (gnus-setup-message 'forward
1205 (gnus-summary-select-article)
1206 (let ((charset default-mime-charset))
1207 (set-buffer gnus-original-article-buffer)
1208 (make-local-variable 'default-mime-charset)
1209 (setq default-mime-charset charset))
1210 (let ((message-included-forward-headers
1211 (if full-headers "" message-included-forward-headers)))
1212 (message-forward post)))
1213 (gnus-summary-digest-mail-forward nil post)))
1215 (defun gnus-summary-digest-mail-forward (&optional n post)
1216 "Digests and forwards all articles in this series.
1217 If N is a positive number, forward the N next articles.
1218 If N is a negative number, forward the N previous articles.
1219 If N is nil and any articles have been marked with the process mark,
1220 forward those articles instead.
1221 Optional POST will use news to forward instead of mail."
1223 (let ((articles (gnus-summary-work-articles n))
1224 (topics "Topics:\n")
1225 subject article frame)
1226 (when (car articles)
1227 (gnus-setup-message 'forward
1228 (gnus-summary-select-article)
1230 (setq articles (sort articles '<)
1231 subject "Digested Articles")
1232 (with-current-buffer gnus-original-article-buffer
1233 (setq subject (message-make-forward-subject))))
1235 (message-news nil subject)
1236 (message-mail nil subject))
1237 (when (and message-use-multi-frames (cdr articles))
1238 (setq frame (window-frame (get-buffer-window (current-buffer)))))
1240 (while (setq article (pop articles))
1241 (save-window-excursion
1242 (set-buffer gnus-summary-buffer)
1243 (gnus-summary-select-article nil nil nil article)
1244 (setq topics (concat topics " "
1245 (mail-header-subject gnus-current-headers)
1247 (gnus-summary-remove-process-mark article))
1249 (select-frame frame))
1250 (insert (mime-make-tag "message" "rfc822") "\n")
1251 (narrow-to-region (point) (point))
1252 (insert-buffer-substring gnus-original-article-buffer)
1254 (article-narrow-to-head)
1255 (message-remove-header message-included-forward-headers t nil t))
1256 (goto-char (point-max))
1262 (mime-edit-enclose-digest-region (point)(mark t))))))
1264 (defun gnus-summary-digest-post-forward (&optional n)
1265 "Digest and forwards all articles in this series to a newsgroup.
1266 If N is a positive number, forward the N next articles.
1267 If N is a negative number, forward the N previous articles.
1268 If N is nil and any articles have been marked with the process mark,
1269 forward those articles instead."
1271 (gnus-summary-digest-mail-forward n t))
1273 (defun gnus-summary-resend-message (address n)
1274 "Resend the current article to ADDRESS."
1276 (list (message-read-from-minibuffer
1277 "Resend message(s) to: "
1278 (when (gnus-buffer-live-p gnus-original-article-buffer)
1279 ;; If some other article is currently selected, the
1280 ;; initial-contents is wrong. Whatever, it is just the
1281 ;; initial-contents.
1282 (with-current-buffer gnus-original-article-buffer
1283 (nnmail-fetch-field "to"))))
1284 current-prefix-arg))
1285 (let ((articles (gnus-summary-work-articles n))
1287 (while (setq article (pop articles))
1288 (gnus-summary-select-article nil nil nil article)
1290 (set-buffer gnus-original-article-buffer)
1291 (message-resend address))
1292 (gnus-summary-mark-article-as-forwarded article))))
1294 ;; From: Matthieu Moy <Matthieu.Moy@imag.fr>
1295 (defun gnus-summary-resend-message-edit ()
1296 "Resend an article that has already been sent.
1297 A new buffer will be created to allow the user to modify body and
1298 contents of the message, and then, everything will happen as when
1299 composing a new message."
1301 (let ((article (gnus-summary-article-number)))
1302 (gnus-setup-message 'reply-yank
1303 (gnus-summary-select-article t)
1304 (set-buffer gnus-original-article-buffer)
1305 (let ((cur (current-buffer))
1306 (to (message-fetch-field "to")))
1307 ;; Get a normal message buffer.
1308 (message-pop-to-buffer (message-buffer-name "Resend" to))
1309 (insert-buffer-substring cur)
1311 ;; T-gnus change: Use MIME-Edit to recompose a message.
1313 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
1314 (fset 'mime-edit-decode-single-part-in-buffer
1315 (lambda (&rest args)
1316 (if (let ((content-type (car args)))
1317 (and (eq 'message (mime-content-type-primary-type
1319 (eq 'rfc822 (mime-content-type-subtype
1321 (setcar (cdr args) 'not-decode-text))
1324 (mime-edit-again nil t)
1325 (fset 'mime-edit-decode-single-part-in-buffer ofn)))
1326 (message-narrow-to-head-1)
1327 (insert "From: " (message-make-from) "\n")
1328 (while (re-search-forward "^From:" nil t)
1330 (insert "Original-"))
1331 (message-remove-header "^>From[\t ]" t)
1333 ;; Gnus will generate a new one when sending.
1334 (message-remove-header "Message-ID")
1335 (message-remove-header message-ignored-resent-headers t)
1336 ;; Remove unwanted headers.
1337 (goto-char (point-max))
1338 (insert mail-header-separator)
1339 (goto-char (point-min))
1340 (re-search-forward "^To:\\|^Newsgroups:" nil 'move)
1344 (defun gnus-summary-post-forward (&optional full-headers)
1345 "Forward the current article to a newsgroup.
1346 If FULL-HEADERS (the prefix), include full headers when forwarding."
1348 (gnus-summary-mail-forward full-headers t))
1350 (defvar gnus-nastygram-message
1351 "The following article was inappropriately posted to %s.\n\n"
1352 "Format string to insert in nastygrams.
1353 The current group name will be inserted at \"%s\".")
1355 (defun gnus-summary-mail-nastygram (n)
1356 "Send a nastygram to the author of the current article."
1358 (when (or gnus-expert-user
1360 "Really send a nastygram to the author of the current article? "))
1361 (let ((group gnus-newsgroup-name))
1362 (gnus-summary-reply-with-original n)
1363 (set-buffer gnus-message-buffer)
1365 (insert (format gnus-nastygram-message group))
1366 (message-send-and-exit))))
1368 (defun gnus-summary-mail-crosspost-complaint (n)
1369 "Send a complaint about crossposting to the current article(s)."
1371 (let ((articles (gnus-summary-work-articles n))
1373 (while (setq article (pop articles))
1374 (set-buffer gnus-summary-buffer)
1375 (gnus-summary-goto-subject article)
1376 (let ((group (gnus-group-real-name gnus-newsgroup-name))
1377 newsgroups followup-to)
1378 (gnus-summary-select-article)
1379 (set-buffer gnus-original-article-buffer)
1380 (if (and (<= (length (message-tokenize-header
1382 (mail-fetch-field "newsgroups"))
1385 (or (not (setq followup-to (mail-fetch-field "followup-to")))
1386 (not (member group (message-tokenize-header
1387 followup-to ", ")))))
1389 (gnus-message 1 "Followup-to restricted")
1390 (gnus-message 1 "Not a crossposted article"))
1391 (set-buffer gnus-summary-buffer)
1392 (gnus-summary-reply-with-original 1)
1393 (set-buffer gnus-message-buffer)
1395 (insert (format gnus-crosspost-complaint newsgroups group))
1396 (message-goto-subject)
1397 (re-search-forward " *$")
1398 (replace-match " (crosspost notification)" t t)
1399 (gnus-deactivate-mark)
1400 (when (gnus-y-or-n-p "Send this complaint? ")
1401 (message-send-and-exit)))))))
1403 (defun gnus-mail-parse-comma-list ()
1406 (skip-chars-forward " ")
1409 (skip-chars-forward "^,")
1414 (narrow-to-region beg (point))
1417 (while (search-forward "\"" nil t)
1421 (skip-chars-forward ",")
1422 (skip-chars-forward "^,"))
1423 (skip-chars-backward " ")
1424 (push (buffer-substring beg (point))
1426 (skip-chars-forward "^,")
1427 (skip-chars-forward ", "))
1430 (defun gnus-inews-add-to-address (group)
1431 (let ((to-address (mail-fetch-field "to")))
1432 (when (and to-address
1434 ;; This mail group doesn't have a `to-list', so we add one
1436 (when (gnus-y-or-n-p
1437 (format "Do you want to add this as `to-list': %s " to-address))
1438 (gnus-group-add-parameter group (cons 'to-list to-address))))))
1440 (defun gnus-put-message ()
1441 "Put the current message in some group and return to Gnus."
1443 (let ((reply gnus-article-reply)
1444 (winconf gnus-prev-winconf)
1445 (group gnus-newsgroup-name))
1447 (not (gnus-group-read-only-p group)))
1448 (setq group (read-string "Put in group: " nil (gnus-writable-groups))))
1450 (when (gnus-gethash group gnus-newsrc-hashtb)
1451 (error "No such group: %s" group))
1455 (message-narrow-to-headers)
1456 (let ((gnus-deletable-headers nil))
1457 (message-generate-headers
1458 (if (message-news-p)
1459 message-required-news-headers
1460 message-required-mail-headers)))
1461 (goto-char (point-max))
1462 (insert "Gcc: " group "\n")
1465 (when (and (get-buffer gnus-group-buffer)
1466 (gnus-buffer-exists-p (car-safe reply))
1468 (set-buffer (car reply))
1469 (gnus-summary-mark-article-as-replied (cdr reply)))
1471 (set-window-configuration winconf))))
1473 (defun gnus-article-mail (yank)
1474 "Send a reply to the address near point.
1475 If YANK is non-nil, include the original article."
1479 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
1480 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
1482 (gnus-msg-mail address)
1484 (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
1486 (defvar nntp-server-type)
1488 "Send a bug report to the Gnus maintainers."
1490 (unless (gnus-alive-p)
1491 (error "Gnus has been shut down"))
1492 (gnus-setup-message (if (message-mail-user-agent) 'message 'bug)
1493 (unless (message-mail-user-agent)
1494 (message-pop-to-buffer "*Gnus Bug*")
1495 (delete-other-windows)
1496 (when gnus-bug-create-help-buffer
1497 (switch-to-buffer "*Gnus Help Bug*")
1499 (insert gnus-bug-message)
1500 (goto-char (point-min))
1502 (set-buffer "*Gnus Bug*")))
1503 (let ((message-this-is-mail t))
1504 (message-setup `((To . ,gnus-maintainer) (Subject . ""))))
1505 (when gnus-bug-create-help-buffer
1506 (push `(gnus-bug-kill-buffer) message-send-actions))
1507 (goto-char (point-min))
1508 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
1510 (insert gnus-product-name " " gnus-version-number
1511 " (r" gnus-revision-number ") "
1512 "based on " gnus-original-product-name " v"
1513 gnus-original-version-number "\n"
1514 (emacs-version) "\n")
1515 (when (and (boundp 'nntp-server-type)
1516 (stringp nntp-server-type))
1517 (insert nntp-server-type))
1518 (insert "\n\n\n\n\n")
1519 (let (mime-content-types)
1520 (mime-edit-insert-tag
1521 "application" "emacs-lisp"
1522 "\nContent-Disposition: inline\nContent-Description: User settings"))
1523 (insert (with-temp-buffer
1526 (let (mime-content-types)
1527 (mime-edit-insert-tag "text" "plain"))
1528 (goto-char (point-min))
1529 (search-forward "Subject: " nil t)
1532 (defun gnus-bug-kill-buffer ()
1533 (when (get-buffer "*Gnus Help Bug*")
1534 (kill-buffer "*Gnus Help Bug*")))
1536 (defun gnus-summary-yank-message (buffer n)
1537 "Yank the current article into a composed message."
1539 (list (completing-read "Buffer: " (mapcar 'list (message-buffers)) nil t)
1540 current-prefix-arg))
1541 (when (gnus-buffer-live-p buffer)
1542 (let ((summary-frame (selected-frame))
1543 (message-frame (when (static-if (featurep 'xemacs)
1544 (device-on-window-system-p)
1546 (let ((window (get-buffer-window buffer t)))
1548 (window-frame window)))))
1549 (separator (concat "^" (regexp-quote mail-header-separator)
1551 (gnus-summary-iterate n
1552 (gnus-summary-select-article)
1553 (gnus-copy-article-buffer)
1554 (when (frame-live-p message-frame)
1555 (raise-frame message-frame)
1556 (select-frame message-frame))
1557 (with-current-buffer buffer
1558 (when (save-excursion
1560 (let (case-fold-search)
1561 (and (not (re-search-backward separator nil t))
1562 (re-search-forward separator nil t))))
1563 (goto-char (match-end 0)))
1564 (message-yank-buffer gnus-article-copy))
1565 (select-frame summary-frame))
1566 (when (frame-live-p message-frame)
1567 (select-frame message-frame)))))
1569 (defun gnus-debug ()
1570 "Attempts to go through the Gnus source file and report what variables have been changed.
1571 The source file has to be in the Emacs load path."
1573 (let ((files gnus-debug-files)
1575 file expr olist sym)
1576 (gnus-message 4 "Please wait while we snoop your variables...")
1577 ;; Go through all the files looking for non-default values for variables.
1580 (set-buffer (gnus-get-buffer-create " *gnus bug info*"))
1583 (when (and (setq file (locate-library (pop files)))
1584 (file-exists-p file))
1585 (insert-file-contents file)
1586 (goto-char (point-min))
1587 (if (not (re-search-forward "^;;* *Internal variables" nil t))
1588 (gnus-message 4 "Malformed sources in file %s" file)
1589 (narrow-to-region (point-min) (point))
1590 (goto-char (point-min))
1591 (while (setq expr (ignore-errors (read (current-buffer))))
1593 (and (memq (car expr) '(defvar defcustom defvoo))
1594 (stringp (nth 3 expr))
1595 (not (memq (nth 1 expr) gnus-debug-exclude-variables))
1596 (or (not (boundp (nth 1 expr)))
1597 (not (equal (eval (nth 2 expr))
1598 (symbol-value (nth 1 expr)))))
1599 (push (nth 1 expr) olist)))))))
1600 (kill-buffer (current-buffer)))
1601 (when (setq olist (nreverse olist))
1602 (insert ";----------------- Environment follows ------------------\n\n"))
1604 (if (boundp (car olist))
1606 (pp `(setq ,(car olist)
1607 ,(if (or (consp (setq sym (symbol-value (car olist))))
1609 (not (or (eq sym nil)
1611 (list 'quote (symbol-value (car olist)))
1612 (symbol-value (car olist))))
1615 (format "(setq %s 'whatever)\n" (car olist))))
1616 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
1617 (setq olist (cdr olist)))
1618 ;; Remove any control chars - they seem to cause trouble for some
1619 ;; mailers. (Byte-compiled output from the stuff above.)
1621 (while (re-search-forward "[\000-\010\013-\037\200-\237]" nil t)
1622 (replace-match (format "\\%03o" (string-to-char (match-string 0)))
1624 ;; Break MIME tags purposely.
1626 (while (re-search-forward mime-edit-tag-regexp nil t)
1627 (goto-char (1+ (match-beginning 0)))
1630 ;;; Treatment of rejected articles.
1633 (defun gnus-summary-resend-bounced-mail (&optional fetch)
1634 "Re-mail the current message.
1635 This only makes sense if the current message is a bounce message than
1636 contains some mail you have written which has been bounced back to
1638 If FETCH, try to fetch the article that this is a reply to, if indeed
1641 (gnus-summary-select-article t)
1642 (set-buffer gnus-original-article-buffer)
1643 (gnus-setup-message 'compose-bounce
1644 (let* ((references (mail-fetch-field "references"))
1645 (parent (and references (gnus-parent-id references))))
1647 ;; If there are references, we fetch the article we answered to.
1649 (gnus-summary-refer-article parent)
1650 (gnus-summary-show-all-headers)))))
1654 (defun gnus-inews-group-method (group)
1656 ;; If the group doesn't exist, we assume
1657 ;; it's an archive group...
1658 ((and (null (gnus-get-info group))
1659 (eq (car (gnus-server-to-method gnus-message-archive-method))
1660 (car (gnus-server-to-method (gnus-group-method group)))))
1661 gnus-message-archive-method)
1663 ((gnus-info-method (gnus-get-info group))
1664 (gnus-info-method (gnus-get-info group)))
1666 (t (gnus-server-to-method (gnus-group-method group)))))
1668 ;; Do Gcc handling, which copied the message over to some group.
1669 (defun gnus-inews-do-gcc (&optional gcc)
1673 (message-narrow-to-headers)
1674 (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
1675 (coding-system-for-write 'raw-text)
1676 (output-coding-system 'raw-text)
1677 groups group method group-art
1678 mml-externalize-attachments)
1680 (message-remove-header "gcc")
1682 (setq groups (message-unquote-tokens
1683 (message-tokenize-header gcc " ,")))
1684 ;; Copy the article over to some group(s).
1685 (while (setq group (pop groups))
1686 (unless (gnus-check-server
1687 (setq method (gnus-inews-group-method group)))
1688 (error "Can't open server %s" (if (stringp method) method
1690 (unless (gnus-request-group group nil method)
1691 (gnus-request-create-group group method))
1692 (setq mml-externalize-attachments
1693 (if (stringp gnus-gcc-externalize-attachments)
1694 (string-match gnus-gcc-externalize-attachments group)
1695 gnus-gcc-externalize-attachments))
1697 (nnheader-set-temp-buffer " *acc*")
1698 (insert-buffer-substring message-encoding-buffer)
1699 (gnus-run-hooks 'gnus-before-do-gcc-hook)
1700 (goto-char (point-min))
1701 (when (re-search-forward
1702 (concat "^" (regexp-quote mail-header-separator) "$")
1704 (replace-match "" t t ))
1705 (unless (setq group-art
1706 (gnus-request-accept-article group method t t))
1707 (gnus-message 1 "Couldn't store article in group %s: %s"
1708 group (gnus-status-message method))
1710 (when (and group-art
1711 (or gnus-gcc-mark-as-read
1712 gnus-inews-mark-gcc-as-read))
1713 (gnus-group-mark-article-read group (cdr group-art)))
1714 (kill-buffer (current-buffer)))))))))
1716 (defun gnus-inews-insert-gcc ()
1717 "Insert Gcc headers based on `gnus-outgoing-message-group'."
1720 (message-narrow-to-headers)
1721 (let* ((group gnus-outgoing-message-group)
1723 ((gnus-functionp group)
1725 ((or (stringp group) (list group))
1729 (if (stringp gcc) gcc
1730 (mapconcat 'identity gcc " "))
1733 (defun gnus-inews-insert-archive-gcc (&optional group)
1734 "Insert the Gcc to say where the article is to be archived."
1735 (let* ((var gnus-message-archive-group)
1736 (group (or group gnus-newsgroup-name ""))
1738 (and gnus-newsgroup-name
1739 (not (equal gnus-newsgroup-name ""))
1740 (gnus-group-find-parameter
1741 gnus-newsgroup-name 'gcc-self)))
1745 ((null gnus-message-archive-method)
1749 ;; Just a single group.
1752 ;; We don't want this.
1754 ((and (listp var) (stringp (car var)))
1755 ;; A list of groups.
1757 ((gnus-functionp var)
1759 (funcall var group))
1761 ;; An alist of regexps/functions/forms.
1766 ((stringp (caar var))
1768 (when (string-match (caar var) group)
1770 ((gnus-functionp (car var))
1772 (funcall (car var) group))
1774 (eval (car var)))))))
1775 (setq var (cdr var)))
1778 (when (or groups gcc-self-val)
1779 (when (stringp groups)
1780 (setq groups (list groups)))
1783 (message-narrow-to-headers)
1784 (goto-char (point-max))
1787 ;; Use the `gcc-self' param value instead.
1790 (if (stringp gcc-self-val)
1793 (if (not (eq gcc-self-val 'none))
1798 ;; Use the list of groups.
1799 (while (setq name (pop groups))
1800 (insert (if (string-match ":" name)
1802 (gnus-group-prefixed-name
1803 name gnus-message-archive-method)))
1810 (defun gnus-configure-posting-styles (&optional group-name)
1811 "Configure posting styles according to `gnus-posting-styles'."
1812 (unless gnus-inhibit-posting-styles
1813 (let ((group (or group-name gnus-newsgroup-name ""))
1814 (styles gnus-posting-styles)
1815 style match variable attribute value v results
1816 filep name address element)
1817 ;; If the group has a posting-style parameter, add it at the end with a
1818 ;; regexp matching everything, to be sure it takes precedence over all
1820 (when gnus-newsgroup-name
1821 (let ((tmp-style (gnus-group-find-parameter group 'posting-style t)))
1823 (setq styles (append styles (list (cons ".*" tmp-style)))))))
1824 ;; Go through all styles and look for matches.
1825 (dolist (style styles)
1826 (setq match (pop style))
1827 (goto-char (point-min))
1830 ;; Regexp string match on the group name.
1831 (string-match match group))
1833 ;; Obsolete format of header match.
1834 (and (gnus-buffer-live-p gnus-article-copy)
1835 (with-current-buffer gnus-article-copy
1836 (let ((header (message-fetch-field (pop style))))
1838 (string-match (pop style) header))))))
1839 ((or (symbolp match)
1840 (gnus-functionp match))
1842 ((gnus-functionp match)
1843 ;; Function to be called.
1846 ;; Variable to be checked.
1847 (symbol-value match))))
1850 ((eq (car match) 'header)
1851 ;; New format of header match.
1852 (and (gnus-buffer-live-p gnus-article-copy)
1853 (with-current-buffer gnus-article-copy
1854 (let ((header (message-fetch-field (nth 1 match))))
1856 (string-match (nth 2 match) header))))))
1858 ;; This is a form to be evaled.
1860 ;; We have a match, so we set the variables.
1861 (dolist (attribute style)
1862 (setq element (pop attribute)
1867 ((eq (car attribute) ':file)
1870 ((eq (car attribute) :value)
1874 ;; We get the value.
1879 ((or (symbolp value)
1880 (gnus-functionp value))
1881 (cond ((gnus-functionp value)
1884 (symbol-value value))))
1887 ;; Translate obsolescent value.
1889 ((eq element 'signature-file)
1890 (setq element 'signature
1892 ((eq element 'x-face-file)
1893 (setq element 'x-face
1895 ;; Get the contents of file elems.
1897 (setq v (with-temp-buffer
1898 (insert-file-contents v)
1899 (goto-char (point-max))
1903 (setq results (delq (assoc element results) results))
1904 (push (cons element v) results))))
1905 ;; Now we have all the styles, so we insert them.
1906 (setq name (assq 'name results)
1907 address (assq 'address results))
1908 (setq results (delq name (delq address results)))
1909 ;; make-local-hook is not obsolete in Emacs 20 or XEmacs.
1910 (make-local-hook 'message-setup-hook)
1911 (dolist (result results)
1912 (add-hook 'message-setup-hook
1914 ((eq 'eval (car result))
1916 ((eq 'body (car result))
1920 (insert ,(cdr result)))))
1921 ((eq 'signature (car result))
1922 (set (make-local-variable 'message-signature) nil)
1923 (set (make-local-variable 'message-signature-file) nil)
1924 (if (not (cdr result))
1928 (let ((message-signature ,(cdr result)))
1929 (when message-signature
1930 (message-insert-signature)))))))
1933 (if (symbolp (car result))
1934 (capitalize (symbol-name (car result)))
1938 (message-remove-header ,header)
1939 (let ((value ,(cdr result)))
1942 (insert ,header ": " value "\n"))))))))
1944 (when (or name address)
1945 (add-hook 'message-setup-hook
1947 (set (make-local-variable 'user-mail-address)
1948 ,(or (cdr address) user-mail-address))
1949 (let ((user-full-name ,(or (cdr name) (user-full-name)))
1951 ,(or (cdr address) user-mail-address)))
1953 (message-remove-header "From")
1955 (insert "From: " (message-make-from) "\n"))))
1959 ;;; @ for MIME Edit mode
1962 (defun gnus-maybe-setup-default-charset ()
1964 (and (boundp 'gnus-summary-buffer)
1965 (buffer-live-p gnus-summary-buffer)
1967 (set-buffer gnus-summary-buffer)
1968 default-mime-charset))))
1971 (make-local-variable 'default-mime-charset)
1972 (setq default-mime-charset charset)
1976 ;;; @ for MIME view mode
1979 (defun gnus-following-method (buf)
1980 (gnus-setup-message 'reply-yank
1982 (if (message-news-p)
1984 (message-reply nil 'wide))
1985 (let ((message-reply-buffer buf))
1986 (message-yank-original))
1987 (message-goto-body))
1991 ;;; Allow redefinition of functions.
1997 ;;; gnus-msg.el ends here