1 ;;; gnus-msg.el --- mail and post interface for Gnus
3 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
4 ;; 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
6 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
7 ;; Lars Magne Ingebrigtsen <larsi@gnus.org>
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
29 (eval-when-compile (require 'cl))
37 (defcustom gnus-post-method 'current
38 "*Preferred method for posting USENET news.
40 If this variable is `current' (which is the default), Gnus will use
41 the \"current\" select method when posting. If it is `native', Gnus
42 will use the native select method when posting.
44 This method will not be used in mail groups and the like, only in
47 If not `native' nor `current', the value must be a valid method as discussed
48 in the documentation of `gnus-select-method'. It can also be a list of
49 methods. If that is the case, the user will be queried for what select
50 method to use when posting."
51 :group 'gnus-group-foreign
52 :link '(custom-manual "(gnus)Posting Server")
53 :type `(choice (const native)
55 (sexp :tag "Methods" ,gnus-select-method)))
57 (defcustom gnus-outgoing-message-group nil
58 "*All outgoing messages will be put in this group.
59 If you want to store all your outgoing mail and articles in the group
60 \"nnml:archive\", you set this variable to that value. This variable
61 can also be a list of group names.
63 If you want to have greater control over what group to put each
64 message in, you can set this variable to a function that checks the
65 current newsgroup name and then returns a suitable group name (or list
68 :type '(choice (const nil)
71 (repeat :tag "List of groups" (string :tag "Group"))))
73 (defcustom gnus-mailing-list-groups nil
74 "*If non-nil a regexp matching groups that are really mailing lists.
75 This is useful when you're reading a mailing list that has been
76 gatewayed to a newsgroup, and you want to followup to an article in
79 :type '(choice (regexp)
82 (defcustom gnus-add-to-list nil
83 "*If non-nil, add a `to-list' parameter automatically."
87 (defcustom gnus-crosspost-complaint
90 You posted the article below with the following Newsgroups header:
94 The %s group, at least, was an inappropriate recipient
95 of this message. Please trim your Newsgroups header to exclude this
96 group before posting in the future.
101 "Format string to be inserted when complaining about crossposts.
102 The first %s will be replaced by the Newsgroups header;
103 the second with the current group name."
107 (defcustom gnus-message-setup-hook nil
108 "Hook run after setting up a message buffer."
110 :options '(message-remove-blank-cited-lines)
113 (defcustom gnus-bug-create-help-buffer t
114 "*Should we create the *Gnus Help Bug* buffer?"
118 (defcustom gnus-posting-styles nil
119 "*Alist of styles to use when posting.
120 See Info node `(gnus)Posting Styles'."
122 :link '(custom-manual "(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 (make-obsolete-variable 'gnus-inews-mark-gcc-as-read
152 'gnus-gcc-mark-as-read "Emacs 22.1")
154 (defcustom gnus-gcc-externalize-attachments nil
155 "Should local-file attachments be included as external parts in Gcc copies?
156 If it is `all', attach files as external parts;
157 if a regexp and matches the Gcc group name, attach files as external parts;
158 if nil, attach files as normal parts."
161 :type '(choice (const nil :tag "None")
162 (const all :tag "Any")
163 (string :tag "Regexp")))
165 (gnus-define-group-parameter
166 posting-charset-alist
169 "Return the permitted unencoded charsets for posting of GROUP."
170 :variable gnus-group-posting-charset-alist
172 '(("^\\(no\\|fr\\)\\.[^,]*\\(,[ \t\n]*\\(no\\|fr\\)\\.[^,]*\\)*$" iso-8859-1 (iso-8859-1))
173 ("^\\(fido7\\|relcom\\)\\.[^,]*\\(,[ \t\n]*\\(fido7\\|relcom\\)\\.[^,]*\\)*$" koi8-r (koi8-r))
174 (message-this-is-mail nil nil)
175 (message-this-is-news nil t))
177 "Alist of regexps and permitted unencoded charsets for posting.
178 Each element of the alist has the form (TEST HEADER BODY-LIST), where
179 TEST is either a regular expression matching the newsgroup header or a
181 HEADER is the charset which may be left unencoded in the header (nil
182 means encode all charsets),
183 BODY-LIST is a list of charsets which may be encoded using 8bit
184 content-transfer encoding in the body, or one of the special values
185 nil (always encode using quoted-printable) or t (always use 8bit).
187 Note that any value other than nil for HEADER infringes some RFCs, so
188 use this option with care."
189 :variable-group gnus-charset
191 '(repeat (list :tag "Permitted unencoded charsets"
193 (regexp :tag "Group")
194 (const :tag "Mail message" :value message-this-is-mail)
195 (const :tag "News article" :value message-this-is-news))
196 (choice :tag "Header"
197 (const :tag "None" nil)
198 (symbol :tag "Charset"))
200 (const :tag "Any" :value t)
201 (const :tag "None" :value nil)
202 (repeat :tag "Charsets"
203 (symbol :tag "Charset")))))
204 :parameter-type '(choice :tag "Permitted unencoded charsets"
207 :parameter-document "\
208 List of charsets that are permitted to be unencoded.")
210 (defcustom gnus-debug-files
211 '("gnus.el" "gnus-sum.el" "gnus-group.el"
212 "gnus-art.el" "gnus-start.el" "gnus-async.el"
213 "gnus-msg.el" "gnus-score.el" "gnus-win.el" "gnus-topic.el"
214 "gnus-agent.el" "gnus-cache.el" "gnus-srvr.el"
215 "mm-util.el" "mm-decode.el" "nnmail.el" "message.el")
216 "Files whose variables will be reported in `gnus-bug'."
219 :type '(repeat (string :tag "File")))
221 (defcustom gnus-debug-exclude-variables
222 '(mm-mime-mule-charset-alist
223 nnmail-split-fancy message-minibuffer-local-map)
224 "Variables that should not be reported in `gnus-bug'."
227 :type '(repeat (symbol :tag "Variable")))
229 (defcustom gnus-discouraged-post-methods
230 '(nndraft nnml nnimap nnmaildir nnmh nnfolder nndir)
231 "A list of back ends that are not used in \"real\" newsgroups.
232 This variable is used only when `gnus-post-method' is `current'."
234 :group 'gnus-group-foreign
235 :type '(repeat (symbol :tag "Back end")))
237 (defcustom gnus-message-replysign
239 "Automatically sign replies to signed messages.
240 See also the `mml-default-sign-method' variable."
244 (defcustom gnus-message-replyencrypt
246 "Automatically encrypt replies to encrypted messages.
247 See also the `mml-default-encrypt-method' variable."
251 (defcustom gnus-message-replysignencrypted
253 "Setting this causes automatically encrypted messages to also be signed."
257 (defcustom gnus-confirm-mail-reply-to-news (and gnus-novice-user
258 (not gnus-expert-user))
259 "If non-nil, Gnus requests confirmation when replying to news.
260 This is done because new users often reply by mistake when reading
262 This can also be a function receiving the group name as the only
263 parameter, which should return non-nil if a confirmation is needed; or
264 a regexp, in which case a confirmation is asked for if the group name
266 :version "23.1" ;; No Gnus (default changed)
268 :type '(choice (const :tag "No" nil)
270 (regexp :tag "If group matches regexp")
271 (function :tag "If function evaluates to non-nil")))
273 (defcustom gnus-confirm-treat-mail-like-news
275 "If non-nil, Gnus will treat mail like news with regard to confirmation
276 when replying by mail. See the `gnus-confirm-mail-reply-to-news' variable
277 for fine-tuning this.
278 If nil, Gnus will never ask for confirmation if replying to mail."
283 (defcustom gnus-summary-resend-default-address t
284 "If non-nil, Gnus tries to suggest a default address to resend to.
285 If nil, the address field will always be empty after invoking
286 `gnus-summary-resend-message'."
291 (defcustom gnus-message-highlight-citation
292 t ;; gnus-treat-highlight-citation ;; gnus-cite dependency
293 "Enable highlighting of different citation levels in message-mode."
294 :version "23.1" ;; No Gnus
299 (autoload 'gnus-message-citation-mode "gnus-cite" nil t)
301 ;;; Internal variables.
303 (defvar gnus-inhibit-posting-styles nil
304 "Inhibit the use of posting styles.")
306 (defvar gnus-article-yanked-articles nil)
307 (defvar gnus-message-buffer "*Mail Gnus*")
308 (defvar gnus-article-copy nil)
309 (defvar gnus-check-before-posting nil)
310 (defvar gnus-last-posting-server nil)
311 (defvar gnus-message-group-art nil)
313 (defvar gnus-msg-force-broken-reply-to nil)
315 (defconst gnus-bug-message
316 "Sending a bug report to the Gnus Towers.
317 ========================================
319 The buffer below is a mail buffer. When you press `C-c C-c', it will
320 be sent to the Gnus Bug Exterminators.
322 The thing near the bottom of the buffer is how the environment
323 settings will be included in the mail. Please do not delete that.
324 They will tell the Bug People what your environment is, so that it
325 will be easier to locate the bugs.
327 If you have found a bug that makes Emacs go \"beep\", set
328 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
329 and include the backtrace in your bug report.
331 Please describe the bug in annoying, painstaking detail.
333 Thank you for your help in stamping out bugs.
336 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
340 ;;; Gnus Posting Functions
343 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
344 "p" gnus-summary-post-news
345 "i" gnus-summary-news-other-window
346 "f" gnus-summary-followup
347 "F" gnus-summary-followup-with-original
348 "c" gnus-summary-cancel-article
349 "s" gnus-summary-supersede-article
350 "r" gnus-summary-reply
351 "y" gnus-summary-yank-message
352 "R" gnus-summary-reply-with-original
353 "w" gnus-summary-wide-reply
354 "W" gnus-summary-wide-reply-with-original
355 "v" gnus-summary-very-wide-reply
356 "V" gnus-summary-very-wide-reply-with-original
357 "n" gnus-summary-followup-to-mail
358 "N" gnus-summary-followup-to-mail-with-original
359 "m" gnus-summary-mail-other-window
360 "u" gnus-uu-post-news
361 "\M-c" gnus-summary-mail-crosspost-complaint
362 "Br" gnus-summary-reply-broken-reply-to
363 "BR" gnus-summary-reply-broken-reply-to-with-original
364 "om" gnus-summary-mail-forward
365 "op" gnus-summary-post-forward
366 "Om" gnus-uu-digest-mail-forward
367 "Op" gnus-uu-digest-post-forward)
369 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
370 "b" gnus-summary-resend-bounced-mail
371 ;; "c" gnus-summary-send-draft
372 "r" gnus-summary-resend-message
373 "e" gnus-summary-resend-message-edit)
375 ;;; Internal functions.
377 (defun gnus-inews-make-draft (articles)
379 (gnus-inews-make-draft-meta-information
380 ,(gnus-group-decoded-name gnus-newsgroup-name) ',articles)))
382 (defvar gnus-article-reply nil)
383 (defmacro gnus-setup-message (config &rest forms)
384 (let ((winconf (make-symbol "gnus-setup-message-winconf"))
385 (buffer (make-symbol "gnus-setup-message-buffer"))
386 (article (make-symbol "gnus-setup-message-article"))
387 (yanked (make-symbol "gnus-setup-yanked-articles"))
388 (group (make-symbol "gnus-setup-message-group")))
389 `(let ((,winconf (current-window-configuration))
390 (,buffer (buffer-name (current-buffer)))
391 (,article gnus-article-reply)
392 (,yanked gnus-article-yanked-articles)
393 (,group gnus-newsgroup-name)
394 (message-header-setup-hook
395 (copy-sequence message-header-setup-hook))
396 (mbl mml-buffer-list)
397 (message-mode-hook (copy-sequence message-mode-hook)))
398 (setq mml-buffer-list nil)
399 (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
400 (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
401 ;; message-newsreader and message-mailer were formerly set in
402 ;; gnus-inews-add-send-actions, but this is too late when
403 ;; message-generate-headers-first is used. --ansel
404 (add-hook 'message-mode-hook
406 (setq message-newsreader
407 (setq message-mailer (gnus-extended-version)))))
408 ;; #### FIXME: for a reason that I did not manage to identify yet,
409 ;; the variable `gnus-newsgroup-name' does not honor a dynamically
410 ;; scoped or setq'ed value from a caller like `C-u gnus-summary-mail'.
411 ;; After evaluation of @forms below, it gets the value we actually want
412 ;; to override, and the posting styles are used. For that reason, I've
413 ;; added an optional argument to `gnus-configure-posting-styles' to
414 ;; make sure that the correct value for the group name is used. -- drv
415 (add-hook 'message-mode-hook
416 (if (memq ,config '(reply-yank reply))
418 (gnus-configure-posting-styles ,group))
420 ;; There may be an old " *gnus article copy*" buffer.
421 (let (gnus-article-copy)
422 (gnus-configure-posting-styles ,group)))))
423 (gnus-alist-pull ',(intern gnus-draft-meta-information-header)
424 message-required-headers)
426 (not (string= ,group "")))
428 (intern gnus-draft-meta-information-header)
429 (gnus-inews-make-draft (or ,yanked ,article)))
430 message-required-headers))
434 (gnus-inews-add-send-actions ,winconf ,buffer ,article ,config
436 (setq gnus-message-buffer (current-buffer))
437 (set (make-local-variable 'gnus-message-group-art)
438 (cons ,group ,article))
439 (set (make-local-variable 'gnus-newsgroup-name) ,group)
440 ;; Enable highlighting of different citation levels
441 (when gnus-message-highlight-citation
442 (gnus-message-citation-mode 1))
443 (gnus-run-hooks 'gnus-message-setup-hook)
444 (if (eq major-mode 'message-mode)
445 (let ((mbl1 mml-buffer-list))
446 (setq mml-buffer-list mbl) ;; Global value
447 (set (make-local-variable 'mml-buffer-list) mbl1);; Local value
448 (gnus-make-local-hook 'kill-buffer-hook)
449 (gnus-make-local-hook 'change-major-mode-hook)
450 (add-hook 'change-major-mode-hook 'mml-destroy-buffers nil t)
451 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))
452 (mml-destroy-buffers)
453 (setq mml-buffer-list mbl)))
454 (message-hide-headers)
456 (gnus-configure-windows ,config t)
457 (run-hooks 'post-command-hook)
458 (set-buffer-modified-p nil))))
460 (defun gnus-inews-make-draft-meta-information (group articles)
461 (when (numberp articles)
462 (setq articles (list articles)))
463 (concat "(\"" group "\""
477 (defun gnus-msg-mail (&optional to subject other-headers continue
478 switch-action yank-action send-actions)
479 "Start editing a mail message to be sent.
480 Like `message-mail', but with Gnus paraphernalia, particularly the
481 Gcc: header for archiving purposes."
483 (let ((buf (current-buffer))
485 (gnus-setup-message 'message
486 (message-mail to subject other-headers continue
487 nil yank-action send-actions))
489 (setq mail-buf (current-buffer))
490 (switch-to-buffer buf)
491 (apply switch-action mail-buf nil)))
492 ;; COMPOSEFUNC should return t if succeed. Undocumented ???
496 (defun gnus-button-mailto (address)
498 (set-buffer (gnus-copy-article-buffer))
499 (gnus-setup-message 'message
500 (message-reply address)))
503 (defun gnus-button-reply (&optional to-address wide)
504 "Like `message-reply'."
506 (gnus-setup-message 'message
507 (message-reply to-address wide)))
510 (define-mail-user-agent 'gnus-user-agent
511 'gnus-msg-mail 'message-send-and-exit
512 'message-kill-buffer 'message-send-hook)
514 (defun gnus-setup-posting-charset (group)
515 (let ((alist gnus-group-posting-charset-alist)
516 (group (or group ""))
520 (while (setq elem (pop alist))
521 (when (or (and (stringp (car elem))
522 (string-match (car elem) group))
523 (and (functionp (car elem))
524 (funcall (car elem) group))
525 (and (symbolp (car elem))
526 (symbol-value (car elem))))
527 (throw 'found (cons (cadr elem) (caddr elem)))))))))
529 (defun gnus-inews-add-send-actions (winconf buffer article
530 &optional config yanked)
531 (gnus-make-local-hook 'message-sent-hook)
532 (add-hook 'message-sent-hook (if gnus-agent 'gnus-agent-possibly-do-gcc
533 'gnus-inews-do-gcc) nil t)
535 (gnus-make-local-hook 'message-header-hook)
536 (add-hook 'message-header-hook 'gnus-agent-possibly-save-gcc nil t))
537 (setq message-post-method
538 `(lambda (&optional arg)
539 (gnus-post-method arg ,gnus-newsgroup-name)))
541 `(when (gnus-buffer-exists-p ,buffer)
542 (set-window-configuration ,winconf))
543 'exit 'postpone 'kill)
544 (let ((to-be-marked (cond
547 (lambda (x) (if (listp x) (car x) x)) yanked))
548 (article (if (listp article) article (list article)))
551 `(when (gnus-buffer-exists-p ,buffer)
552 (with-current-buffer ,buffer
554 (if (eq config 'forward)
555 `(gnus-summary-mark-article-as-forwarded ',to-be-marked)
556 `(gnus-summary-mark-article-as-replied ',to-be-marked)))))
559 (put 'gnus-setup-message 'lisp-indent-function 1)
560 (put 'gnus-setup-message 'edebug-form-spec '(form body))
562 ;;; Post news commands of Gnus group mode and summary mode
564 (defun gnus-group-mail (&optional arg)
565 "Start composing a mail.
566 If ARG, use the group under the point to find a posting style.
567 If ARG is 1, prompt for a group name to find the posting style."
569 ;; We can't `let' gnus-newsgroup-name here, since that leads
570 ;; to local variables leaking.
571 (let ((group gnus-newsgroup-name)
572 ;; make sure last viewed article doesn't affect posting styles:
574 (buffer (current-buffer)))
577 (setq gnus-newsgroup-name
579 (if (= 1 (prefix-numeric-value arg))
580 (gnus-group-completing-read
581 "Use posting style of group"
582 nil (gnus-read-active-file-p))
583 (gnus-group-group-name))
585 ;; #### see comment in gnus-setup-message -- drv
586 (gnus-setup-message 'message (message-mail)))
587 (with-current-buffer buffer
588 (setq gnus-newsgroup-name group)))))
590 (defun gnus-group-news (&optional arg)
591 "Start composing a news.
592 If ARG, post to group under point.
593 If ARG is 1, prompt for group name to post to.
595 This function prepares a news even when using mail groups. This is useful
596 for posting messages to mail groups without actually sending them over the
597 network. The corresponding back end must have a 'request-post method."
599 ;; We can't `let' gnus-newsgroup-name here, since that leads
600 ;; to local variables leaking.
601 (let ((group gnus-newsgroup-name)
602 ;; make sure last viewed article doesn't affect posting styles:
604 (buffer (current-buffer)))
607 (setq gnus-newsgroup-name
609 (if (= 1 (prefix-numeric-value arg))
610 (gnus-group-completing-read "Use group"
612 (gnus-read-active-file-p))
613 (gnus-group-group-name))
615 ;; #### see comment in gnus-setup-message -- drv
616 (gnus-setup-message 'message
617 (message-news (gnus-group-real-name gnus-newsgroup-name))))
618 (with-current-buffer buffer
619 (setq gnus-newsgroup-name group)))))
621 (defun gnus-group-post-news (&optional arg)
622 "Start composing a message (a news by default).
623 If ARG, post to group under point. If ARG is 1, prompt for group name.
624 Depending on the selected group, the message might be either a mail or
627 ;; Bind this variable here to make message mode hooks work ok.
628 (let ((gnus-newsgroup-name
630 (if (= 1 (prefix-numeric-value arg))
631 (gnus-group-completing-read "Newsgroup" nil
632 (gnus-read-active-file-p))
633 (gnus-group-group-name))
635 ;; make sure last viewed article doesn't affect posting styles:
637 (gnus-post-news 'post gnus-newsgroup-name nil nil nil nil
638 (string= gnus-newsgroup-name ""))))
640 (defun gnus-summary-mail-other-window (&optional arg)
641 "Start composing a mail in another window.
642 Use the posting of the current group by default.
643 If ARG, don't do that. If ARG is 1, prompt for group name to find the
646 ;; We can't `let' gnus-newsgroup-name here, since that leads
647 ;; to local variables leaking.
648 (let ((group gnus-newsgroup-name)
649 ;; make sure last viewed article doesn't affect posting styles:
651 (buffer (current-buffer)))
654 (setq gnus-newsgroup-name
656 (if (= 1 (prefix-numeric-value arg))
657 (gnus-group-completing-read "Use group"
659 (gnus-read-active-file-p))
661 gnus-newsgroup-name))
662 ;; #### see comment in gnus-setup-message -- drv
663 (gnus-setup-message 'message (message-mail)))
664 (with-current-buffer buffer
665 (setq gnus-newsgroup-name group)))))
667 (defun gnus-summary-news-other-window (&optional arg)
668 "Start composing a news in another window.
669 Post to the current group by default.
670 If ARG, don't do that. If ARG is 1, prompt for group name to post to.
672 This function prepares a news even when using mail groups. This is useful
673 for posting messages to mail groups without actually sending them over the
674 network. The corresponding back end must have a 'request-post method."
676 ;; We can't `let' gnus-newsgroup-name here, since that leads
677 ;; to local variables leaking.
678 (let ((group gnus-newsgroup-name)
679 ;; make sure last viewed article doesn't affect posting styles:
681 (buffer (current-buffer)))
684 (setq gnus-newsgroup-name
686 (if (= 1 (prefix-numeric-value arg))
687 (gnus-group-completing-read "Use group"
689 (gnus-read-active-file-p))
691 gnus-newsgroup-name))
692 ;; #### see comment in gnus-setup-message -- drv
693 (gnus-setup-message 'message
695 (message-news (gnus-group-real-name gnus-newsgroup-name))
696 (set (make-local-variable 'gnus-discouraged-post-methods)
698 (car (gnus-find-method-for-group gnus-newsgroup-name))
699 gnus-discouraged-post-methods)))))
700 (with-current-buffer buffer
701 (setq gnus-newsgroup-name group)))))
703 (defun gnus-summary-post-news (&optional arg)
704 "Start composing a message. Post to the current group by default.
705 If ARG, don't do that. If ARG is 1, prompt for a group name to post to.
706 Depending on the selected group, the message might be either a mail or
709 ;; Bind this variable here to make message mode hooks work ok.
710 (let ((gnus-newsgroup-name
712 (if (= 1 (prefix-numeric-value arg))
713 (gnus-group-completing-read "Newsgroup" nil
714 (gnus-read-active-file-p))
716 gnus-newsgroup-name))
717 ;; make sure last viewed article doesn't affect posting styles:
719 (gnus-post-news 'post gnus-newsgroup-name)))
722 (defun gnus-summary-followup (yank &optional force-news)
723 "Compose a followup to an article.
724 If prefix argument YANK is non-nil, the original article is yanked
726 YANK is a list of elements, where the car of each element is the
727 article number, and the cdr is the string to be yanked."
729 (list (and current-prefix-arg
730 (gnus-summary-work-articles 1))))
732 (gnus-summary-goto-subject
733 (if (listp (car yank))
736 (save-window-excursion
737 (gnus-summary-select-article))
738 (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
739 (gnus-newsgroup-name gnus-newsgroup-name))
741 (gnus-post-news nil gnus-newsgroup-name
742 headers gnus-article-buffer
744 (gnus-summary-handle-replysign)))
746 (defun gnus-summary-followup-with-original (n &optional force-news)
747 "Compose a followup to an article and include the original article.
748 The text in the region will be yanked. If the region isn't
749 active, the entire article will be yanked."
751 (gnus-summary-followup (gnus-summary-work-articles n) force-news))
753 (defun gnus-summary-followup-to-mail (&optional arg)
754 "Followup to the current mail message via news."
756 (list (and current-prefix-arg
757 (gnus-summary-work-articles 1))))
758 (gnus-summary-followup arg t))
760 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
761 "Followup to the current mail message via news."
763 (gnus-summary-followup (gnus-summary-work-articles arg) t))
765 (defun gnus-inews-yank-articles (articles)
766 (let (beg article yank-string)
768 (while (setq article (pop articles))
769 (when (listp article)
770 (setq yank-string (nth 1 article)
771 article (nth 0 article)))
772 (save-window-excursion
773 (set-buffer gnus-summary-buffer)
774 (gnus-summary-select-article nil nil nil article)
775 (gnus-summary-remove-process-mark article))
776 (gnus-copy-article-buffer nil yank-string)
777 (let ((message-reply-buffer gnus-article-copy)
778 (message-reply-headers
779 ;; The headers are decoded.
780 (with-current-buffer gnus-article-copy
782 (nnheader-narrow-to-headers)
783 (nnheader-parse-naked-head)))))
784 (message-yank-original)
785 (message-exchange-point-and-mark)
786 (setq beg (or beg (mark t))))
792 (defun gnus-summary-cancel-article (&optional n symp)
793 "Cancel an article you posted.
794 Uses the process-prefix convention. If given the symbolic
795 prefix `a', cancel using the standard posting method; if not
796 post using the current select method."
797 (interactive (gnus-interactive "P\ny"))
798 (let ((message-post-method
800 (gnus-post-method (eq ',symp 'a) ,gnus-newsgroup-name))))
801 (dolist (article (gnus-summary-work-articles n))
802 (when (gnus-summary-select-article t nil nil article)
803 (when (gnus-eval-in-buffer-window gnus-original-article-buffer
804 (message-cancel-news))
805 (gnus-summary-mark-as-read article gnus-canceled-mark)
806 (gnus-cache-remove-article 1))
807 (gnus-article-hide-headers-if-wanted))
808 (gnus-summary-remove-process-mark article))))
810 (defun gnus-summary-supersede-article ()
811 "Compose an article that will supersede a previous article.
812 This is done simply by taking the old article and adding a Supersedes
813 header line with the old Message-ID."
815 (let ((article (gnus-summary-article-number))
816 (mail-parse-charset gnus-newsgroup-charset))
817 (gnus-setup-message 'reply-yank
818 (gnus-summary-select-article t)
819 (set-buffer gnus-original-article-buffer)
823 (when (gnus-buffer-exists-p ,gnus-summary-buffer)
824 (with-current-buffer ,gnus-summary-buffer
825 (gnus-cache-possibly-remove-article ,article nil nil nil t)
826 (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
827 message-send-actions)
829 (gnus-inews-insert-archive-gcc)
830 (gnus-inews-insert-gcc))))
834 (defun gnus-copy-article-buffer (&optional article-buffer yank-string)
835 ;; make a copy of the article buffer with all text properties removed
836 ;; this copy is in the buffer gnus-article-copy.
837 ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
838 ;; this buffer should be passed to all mail/news reply/post routines.
839 (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
840 (with-current-buffer gnus-article-copy
841 (mm-enable-multibyte))
842 (let ((article-buffer (or article-buffer gnus-article-buffer))
844 (if (not (and (get-buffer article-buffer)
845 (gnus-buffer-exists-p article-buffer)))
846 (error "Can't find any article buffer")
847 (with-current-buffer article-buffer
848 (let ((gnus-newsgroup-charset (or gnus-article-charset
849 gnus-newsgroup-charset))
850 (gnus-newsgroup-ignored-charsets
851 (or gnus-article-ignored-charsets
852 gnus-newsgroup-ignored-charsets)))
854 ;; Copy over the (displayed) article buffer, delete
855 ;; hidden text and remove text properties.
857 (copy-to-buffer gnus-article-copy (point-min) (point-max))
858 (set-buffer gnus-article-copy)
861 (delete-region (point) (point-max))
862 (insert yank-string))
863 (gnus-article-delete-text-of-type 'annotation)
864 (gnus-article-delete-text-of-type 'multipart)
865 (gnus-remove-text-with-property 'gnus-prev)
866 (gnus-remove-text-with-property 'gnus-next)
867 (gnus-remove-text-with-property 'gnus-decoration)
870 (buffer-substring-no-properties (point-min) (point-max))
872 ;; Find the original headers.
873 (set-buffer gnus-original-article-buffer)
874 (goto-char (point-min))
875 (while (looking-at message-unix-mail-delimiter)
877 (let ((mail-header-separator ""))
879 end (or (message-goto-body)
880 ;; There may be just a header.
882 ;; Delete the headers from the displayed articles.
883 (set-buffer gnus-article-copy)
884 (let ((mail-header-separator ""))
885 (delete-region (goto-char&