* gnus-sum.el (gnus-summary-find-for-reselect): Renamed from
[gnus] / lisp / gnus-msg.el
1 ;;; gnus-msg.el --- mail and post interface for Gnus
2 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
3 ;;        Free Software Foundation, Inc.
4
5 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
6 ;;      Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; Keywords: news
8
9 ;; This file is part of GNU Emacs.
10
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
15
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 ;; GNU General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
25
26 ;;; Commentary:
27
28 ;;; Code:
29
30 (eval-when-compile (require 'cl))
31
32 (require 'gnus)
33 (require 'gnus-ems)
34 (require 'message)
35 (require 'gnus-art)
36 (require 'gnus-util)
37
38 (defcustom gnus-post-method 'current
39   "*Preferred method for posting USENET news.
40
41 If this variable is `current' (which is the default), Gnus will use
42 the \"current\" select method when posting.  If it is `native', Gnus
43 will use the native select method when posting.
44
45 This method will not be used in mail groups and the like, only in
46 \"real\" newsgroups.
47
48 If not `native' nor `current', the value must be a valid method as discussed
49 in the documentation of `gnus-select-method'.  It can also be a list of
50 methods.  If that is the case, the user will be queried for what select
51 method to use when posting."
52   :group 'gnus-group-foreign
53   :link '(custom-manual "(gnus)Posting Server")
54   :type `(choice (const native)
55                  (const current)
56                  (sexp :tag "Methods" ,gnus-select-method)))
57
58 (defcustom gnus-outgoing-message-group nil
59   "*All outgoing messages will be put in this group.
60 If you want to store all your outgoing mail and articles in the group
61 \"nnml:archive\", you set this variable to that value.  This variable
62 can also be a list of group names.
63
64 If you want to have greater control over what group to put each
65 message in, you can set this variable to a function that checks the
66 current newsgroup name and then returns a suitable group name (or list
67 of names)."
68   :group 'gnus-message
69   :type '(choice (string :tag "Group")
70                  (function)))
71
72 (defcustom gnus-mailing-list-groups nil
73   "*Regexp matching groups that are really mailing lists.
74 This is useful when you're reading a mailing list that has been
75 gatewayed to a newsgroup, and you want to followup to an article in
76 the group."
77   :group 'gnus-message
78   :type 'regexp)
79
80 (defcustom gnus-add-to-list nil
81   "*If non-nil, add a `to-list' parameter automatically."
82   :group 'gnus-message
83   :type 'boolean)
84
85 (defcustom gnus-crosspost-complaint
86   "Hi,
87
88 You posted the article below with the following Newsgroups header:
89
90 Newsgroups: %s
91
92 The %s group, at least, was an inappropriate recipient
93 of this message.  Please trim your Newsgroups header to exclude this
94 group before posting in the future.
95
96 Thank you.
97
98 "
99   "Format string to be inserted when complaining about crossposts.
100 The first %s will be replaced by the Newsgroups header;
101 the second with the current group name."
102   :group 'gnus-message
103   :type 'string)
104
105 (defcustom gnus-message-setup-hook nil
106   "Hook run after setting up a message buffer."
107   :group 'gnus-message
108   :type 'hook)
109
110 (defcustom gnus-bug-create-help-buffer t
111   "*Should we create the *Gnus Help Bug* buffer?"
112   :group 'gnus-message
113   :type 'boolean)
114
115 (defcustom gnus-posting-styles nil
116   "*Alist of styles to use when posting.
117 See Info node `(gnus)Posting Styles'."
118   :group 'gnus-message
119   :link '(custom-manual "(gnus)Posting Styles")
120   :type '(repeat (cons (choice (regexp)
121                                (variable)
122                                (list (const header)
123                                      (string :tag "Header")
124                                      (regexp :tag "Regexp"))
125                                (function)
126                                (sexp))
127                        (repeat (list
128                                 (choice (const signature)
129                                         (const signature-file)
130                                         (const organization)
131                                         (const address)
132                                         (const x-face-file)
133                                         (const name)
134                                         (const body)
135                                         (symbol)
136                                         (string :tag "Header"))
137                                 (choice (string)
138                                         (function)
139                                         (variable)
140                                         (sexp)))))))
141
142 (defcustom gnus-gcc-mark-as-read nil
143   "If non-nil, automatically mark Gcc articles as read."
144   :version "21.1"
145   :group 'gnus-message
146   :type 'boolean)
147
148 (defvar gnus-inews-mark-gcc-as-read nil
149   "Obsolete variable. Use `gnus-gcc-mark-as-read' instead.")
150
151 (make-obsolete-variable 'gnus-inews-mark-gcc-as-read
152                         'gnus-gcc-mark-as-read)
153
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."
159   :version "21.1"
160   :group 'gnus-message
161   :type '(choice (const nil :tag "None")
162                  (const all :tag "Any")
163                  (string :tag "Regexp")))
164
165 (gnus-define-group-parameter
166  posting-charset-alist
167  :type list
168  :function-document
169  "Return the permitted unencoded charsets for posting of GROUP."
170  :variable gnus-group-posting-charset-alist
171  :variable-default
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))
176  :variable-document
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
180 variable to query,
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).
186
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
190  :variable-type
191  '(repeat (list :tag "Permitted unencoded charsets"
192                 (choice :tag "Where"
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"))
199                 (choice :tag "Body"
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"
205                           :value nil
206                           (repeat (symbol)))
207  :parameter-document       "\
208 List of charsets that are permitted to be unencoded.")
209
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'."
217   :version "21.1"
218   :group 'gnus-message
219   :type '(repeat (string :tag "File")))
220
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'."
225   :version "21.1"
226   :group 'gnus-message
227   :type '(repeat (symbol :tag "Variable")))
228
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'."
233   :version "21.3"
234   :group 'gnus-group-foreign
235   :type '(repeat (symbol :tag "Back end")))
236
237 (defcustom gnus-message-replysign
238   nil
239   "Automatically sign replies to signed messages.
240 See also the `mml-default-sign-method' variable."
241   :group 'gnus-message
242   :type 'boolean)
243
244 (defcustom gnus-message-replyencrypt
245   nil
246   "Automatically encrypt replies to encrypted messages.
247 See also the `mml-default-encrypt-method' variable."
248   :group 'gnus-message
249   :type 'boolean)
250
251 (defcustom gnus-message-replysignencrypted
252   t
253   "Setting this causes automatically encryped messages to also be signed."
254   :group 'gnus-message
255   :type 'boolean)
256
257 (defcustom gnus-confirm-mail-reply-to-news nil
258   "If non-nil, Gnus requests confirmation when replying to news.
259 This is done because new users often reply by mistake when reading
260 news.
261 This can also be a function receiving the group name as the only
262 parameter which should return non-nil iff a confirmation is needed, or
263 a regexp, in which case a confirmation is asked for iff the group name
264 matches the regexp."
265   :group 'gnus-message
266   :type '(choice (const :tag "No" nil)
267                  (const :tag "Yes" t)
268                  (regexp :tag "Iff group matches regexp")
269                  (function :tag "Iff function evaluates to non-nil")))
270
271 (defcustom gnus-confirm-treat-mail-like-news
272   nil
273   "If non-nil, Gnus will treat mail like news with regard to confirmation
274 when replying by mail.  See the `gnus-confirm-mail-reply-to-news' variable
275 for fine-tuning this.
276 If nil, Gnus will never ask for confirmation if replying to mail."
277   :group 'gnus-message
278   :type 'boolean)
279
280 (defcustom gnus-summary-resend-default-address t
281   "If non-nil, Gnus tries to suggest a default address to resend to.
282 If nil, the address field will always be empty after invoking
283 `gnus-summary-resend-message'."
284   :group 'gnus-message
285   :type 'boolean)
286
287 (defcustom gnus-user-agent 'emacs-gnus-type
288   "Which information should be exposed in the User-Agent header.
289
290 It can be one of the symbols `gnus' \(show only Gnus version\), `emacs-gnus'
291 \(show only Emacs and Gnus versions\), `emacs-gnus-config' \(same as
292 `emacs-gnus' plus system configuration\), `emacs-gnus-type' \(same as
293 `emacs-gnus' plus system type\) or a custom string.  If you set it to a
294 string, be sure to use a valid format, see RFC 2616."
295   :group 'gnus-message
296   :type '(choice
297           (item :tag "Show Gnus and Emacs versions and system type"
298                 emacs-gnus-type)
299           (item :tag "Show Gnus and Emacs versions and system configuration"
300                 emacs-gnus-config)
301           (item :tag "Show Gnus and Emacs versions" emacs-gnus)
302           (item :tag "Show only Gnus version" gnus)
303           (string :tag "Other")))
304
305 ;;; Internal variables.
306
307 (defvar gnus-inhibit-posting-styles nil
308   "Inhibit the use of posting styles.")
309
310 (defvar gnus-article-yanked-articles nil)
311 (defvar gnus-message-buffer "*Mail Gnus*")
312 (defvar gnus-article-copy nil)
313 (defvar gnus-check-before-posting nil)
314 (defvar gnus-last-posting-server nil)
315 (defvar gnus-message-group-art nil)
316
317 (defvar gnus-msg-force-broken-reply-to nil)
318
319 (defconst gnus-bug-message
320   "Sending a bug report to the Gnus Towers.
321 ========================================
322
323 The buffer below is a mail buffer.  When you press `C-c C-c', it will
324 be sent to the Gnus Bug Exterminators.
325
326 The thing near the bottom of the buffer is how the environment
327 settings will be included in the mail.  Please do not delete that.
328 They will tell the Bug People what your environment is, so that it
329 will be easier to locate the bugs.
330
331 If you have found a bug that makes Emacs go \"beep\", set
332 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
333 and include the backtrace in your bug report.
334
335 Please describe the bug in annoying, painstaking detail.
336
337 Thank you for your help in stamping out bugs.
338 ")
339
340 (eval-and-compile
341   (autoload 'gnus-uu-post-news "gnus-uu" nil t)
342   (autoload 'news-setup "rnewspost")
343   (autoload 'news-reply-mode "rnewspost")
344   (autoload 'rmail-dont-reply-to "mail-utils")
345   (autoload 'rmail-output "rmailout"))
346
347 \f
348 ;;;
349 ;;; Gnus Posting Functions
350 ;;;
351
352 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
353   "p" gnus-summary-post-news
354   "i" gnus-summary-news-other-window
355   "f" gnus-summary-followup
356   "F" gnus-summary-followup-with-original
357   "c" gnus-summary-cancel-article
358   "s" gnus-summary-supersede-article
359   "r" gnus-summary-reply
360   "y" gnus-summary-yank-message
361   "R" gnus-summary-reply-with-original
362   "w" gnus-summary-wide-reply
363   "W" gnus-summary-wide-reply-with-original
364   "v" gnus-summary-very-wide-reply
365   "V" gnus-summary-very-wide-reply-with-original
366   "n" gnus-summary-followup-to-mail
367   "N" gnus-summary-followup-to-mail-with-original
368   "m" gnus-summary-mail-other-window
369   "u" gnus-uu-post-news
370   "\M-c" gnus-summary-mail-crosspost-complaint
371   "Br" gnus-summary-reply-broken-reply-to
372   "BR" gnus-summary-reply-broken-reply-to-with-original
373   "om" gnus-summary-mail-forward
374   "op" gnus-summary-post-forward
375   "Om" gnus-uu-digest-mail-forward
376   "Op" gnus-uu-digest-post-forward)
377
378 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
379   "b" gnus-summary-resend-bounced-mail
380   ;; "c" gnus-summary-send-draft
381   "r" gnus-summary-resend-message
382   "e" gnus-summary-resend-message-edit)
383
384 ;;; Internal functions.
385
386 (defun gnus-inews-make-draft ()
387   `(lambda ()
388      (gnus-inews-make-draft-meta-information
389       ,gnus-newsgroup-name ',gnus-article-reply)))
390
391 (defvar gnus-article-reply nil)
392 (defmacro gnus-setup-message (config &rest forms)
393   (let ((winconf (make-symbol "gnus-setup-message-winconf"))
394         (buffer (make-symbol "gnus-setup-message-buffer"))
395         (article (make-symbol "gnus-setup-message-article"))
396         (yanked (make-symbol "gnus-setup-yanked-articles"))
397         (group (make-symbol "gnus-setup-message-group")))
398     `(let ((,winconf (current-window-configuration))
399            (,buffer (buffer-name (current-buffer)))
400            (,article gnus-article-reply)
401            (,yanked gnus-article-yanked-articles)
402            (,group gnus-newsgroup-name)
403            (message-header-setup-hook
404             (copy-sequence message-header-setup-hook))
405            (mbl mml-buffer-list)
406            (message-mode-hook (copy-sequence message-mode-hook)))
407        (setq mml-buffer-list nil)
408        (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
409        (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
410        ;; #### FIXME: for a reason that I did not manage to identify yet,
411        ;; the variable `gnus-newsgroup-name' does not honor a dynamically
412        ;; scoped or setq'ed value from a caller like `C-u gnus-summary-mail'.
413        ;; After evaluation of @forms below, it gets the value we actually want
414        ;; to override, and the posting styles are used. For that reason, I've
415        ;; added an optional argument to `gnus-configure-posting-styles' to
416        ;; make sure that the correct value for the group name is used. -- drv
417        (add-hook 'message-mode-hook
418                  (lambda ()
419                    (gnus-configure-posting-styles ,group)))
420        (gnus-pull ',(intern gnus-draft-meta-information-header)
421                   message-required-headers)
422        (when (and ,group
423                   (not (string= ,group "")))
424          (push (cons
425                 (intern gnus-draft-meta-information-header)
426                 (gnus-inews-make-draft))
427                message-required-headers))
428        (unwind-protect
429            (progn
430              ,@forms)
431          (gnus-inews-add-send-actions ,winconf ,buffer ,article ,config
432                                       ,yanked)
433          (setq gnus-message-buffer (current-buffer))
434          (set (make-local-variable 'gnus-message-group-art)
435               (cons ,group ,article))
436          (set (make-local-variable 'gnus-newsgroup-name) ,group)
437          (gnus-run-hooks 'gnus-message-setup-hook)
438          (if (eq major-mode 'message-mode)
439              (let ((mbl1 mml-buffer-list))
440                (setq mml-buffer-list mbl)  ;; Global value
441                (set (make-local-variable 'mml-buffer-list) mbl1);; Local value
442                ;; LOCAL argument of add-hook differs between GNU Emacs
443                ;; and XEmacs. make-local-hook makes sure they are local.
444                (make-local-hook 'kill-buffer-hook)
445                (make-local-hook 'change-major-mode-hook)
446                (add-hook 'change-major-mode-hook 'mml-destroy-buffers nil t)
447                (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))
448            (mml-destroy-buffers)
449            (setq mml-buffer-list mbl)))
450        (gnus-add-buffer)
451        (gnus-configure-windows ,config t)
452        (run-hooks 'post-command-hook)
453        (set-buffer-modified-p nil))))
454
455 (defun gnus-inews-make-draft-meta-information (group article)
456   (concat "(\"" group "\" "
457           (if article (number-to-string
458                        (if (listp article)
459                            (car article)
460                          article)) "\"\"")
461           ")"))
462
463 ;;;###autoload
464 (defun gnus-msg-mail (&optional to subject other-headers continue
465                                 switch-action yank-action send-actions)
466   "Start editing a mail message to be sent.
467 Like `message-mail', but with Gnus paraphernalia, particularly the
468 Gcc: header for archiving purposes."
469   (interactive)
470   (let ((buf (current-buffer))
471         mail-buf)
472     (gnus-setup-message 'message
473       (message-mail to subject other-headers continue
474                     nil yank-action send-actions))
475     (when switch-action
476       (setq mail-buf (current-buffer))
477       (switch-to-buffer buf)
478       (apply switch-action mail-buf nil)))
479   ;; COMPOSEFUNC should return t if succeed.  Undocumented ???
480   t)
481
482 (defvar save-selected-window-window)
483
484 ;;;###autoload
485 (defun gnus-button-mailto (address)
486   "Mail to ADDRESS."
487   (set-buffer (gnus-copy-article-buffer))
488   (gnus-setup-message 'message
489     (message-reply address))
490   (and (boundp 'save-selected-window-window)
491        (not (window-live-p save-selected-window-window))
492        (setq save-selected-window-window (selected-window))))
493
494 ;;;###autoload
495 (defun gnus-button-reply (&optional to-address wide)
496   "Like `message-reply'."
497   (interactive)
498   (gnus-setup-message 'message
499     (message-reply to-address wide))
500   (and (boundp 'save-selected-window-window)
501        (not (window-live-p save-selected-window-window))
502        (setq save-selected-window-window (selected-window))))
503
504 ;;;###autoload
505 (define-mail-user-agent 'gnus-user-agent
506   'gnus-msg-mail 'message-send-and-exit
507   'message-kill-buffer 'message-send-hook)
508
509 (defun gnus-setup-posting-charset (group)
510   (let ((alist gnus-group-posting-charset-alist)
511         (group (or group ""))
512         elem)
513     (when group
514       (catch 'found
515         (while (setq elem (pop alist))
516           (when (or (and (stringp (car elem))
517                          (string-match (car elem) group))
518                     (and (gnus-functionp (car elem))
519                          (funcall (car elem) group))
520                     (and (symbolp (car elem))
521                          (symbol-value (car elem))))
522             (throw 'found (cons (cadr elem) (caddr elem)))))))))
523
524 (defun gnus-inews-add-send-actions (winconf buffer article
525                                             &optional config yanked)
526   (make-local-hook 'message-sent-hook)
527   (add-hook 'message-sent-hook (if gnus-agent 'gnus-agent-possibly-do-gcc
528                                  'gnus-inews-do-gcc) nil t)
529   (when gnus-agent
530     (make-local-hook 'message-header-hook)
531     (add-hook 'message-header-hook 'gnus-agent-possibly-save-gcc nil t))
532   (setq message-post-method
533         `(lambda (arg)
534            (gnus-post-method arg ,gnus-newsgroup-name)))
535   (setq message-newsreader (setq message-mailer (gnus-extended-version)))
536   (message-add-action
537    `(when (gnus-buffer-exists-p ,buffer)
538       (set-window-configuration ,winconf))
539    'exit 'postpone 'kill)
540   (let ((to-be-marked (cond
541                        (yanked yanked)
542                        (article (if (listp article) article (list article)))
543                        (t nil))))
544     (message-add-action
545      `(when (gnus-buffer-exists-p ,buffer)
546         (save-excursion
547           (set-buffer ,buffer)
548           ,(when to-be-marked
549              (if (eq config 'forward)
550                  `(gnus-summary-mark-article-as-forwarded ',to-be-marked)
551                `(gnus-summary-mark-article-as-replied ',to-be-marked)))))
552      'send)))
553
554 (put 'gnus-setup-message 'lisp-indent-function 1)
555 (put 'gnus-setup-message 'edebug-form-spec '(form body))
556
557 ;;; Post news commands of Gnus group mode and summary mode
558
559 (defun gnus-group-mail (&optional arg)
560   "Start composing a mail.
561 If ARG, use the group under the point to find a posting style.
562 If ARG is 1, prompt for a group name to find the posting style."
563   (interactive "P")
564   ;; We can't `let' gnus-newsgroup-name here, since that leads
565   ;; to local variables leaking.
566   (let ((group gnus-newsgroup-name)
567         ;; make sure last viewed article doesn't affect posting styles:
568         (gnus-article-copy)
569         (buffer (current-buffer)))
570     (unwind-protect
571         (progn
572           (setq gnus-newsgroup-name
573                 (if arg
574                     (if (= 1 (prefix-numeric-value arg))
575                         (completing-read "Use posting style of group: "
576                                          gnus-active-hashtb nil
577                                          (gnus-read-active-file-p))
578                       (gnus-group-group-name))
579                   ""))
580           ;; #### see comment in gnus-setup-message -- drv
581           (gnus-setup-message 'message (message-mail)))
582       (save-excursion
583         (set-buffer buffer)
584         (setq gnus-newsgroup-name group)))))
585
586 (defun gnus-group-news (&optional arg)
587   "Start composing a news.
588 If ARG, post to group under point.
589 If ARG is 1, prompt for group name to post to.
590
591 This function prepares a news even when using mail groups.  This is useful
592 for posting messages to mail groups without actually sending them over the
593 network.  The corresponding backend must have a 'request-post method."
594   (interactive "P")
595   ;; We can't `let' gnus-newsgroup-name here, since that leads
596   ;; to local variables leaking.
597   (let ((group gnus-newsgroup-name)
598         ;; make sure last viewed article doesn't affect posting styles:
599         (gnus-article-copy)
600         (buffer (current-buffer)))
601     (unwind-protect
602         (progn
603           (setq gnus-newsgroup-name
604                 (if arg
605                     (if (= 1 (prefix-numeric-value arg))
606                         (completing-read "Use group: "
607                                          gnus-active-hashtb nil
608                                          (gnus-read-active-file-p))
609                       (gnus-group-group-name))
610                   ""))
611           ;; #### see comment in gnus-setup-message -- drv
612           (gnus-setup-message 'message
613             (message-news (gnus-group-real-name gnus-newsgroup-name))))
614       (save-excursion
615         (set-buffer buffer)
616         (setq gnus-newsgroup-name group)))))
617
618 (defun gnus-group-post-news (&optional arg)
619   "Start composing a message (a news by default).
620 If ARG, post to group under point.  If ARG is 1, prompt for group name.
621 Depending on the selected group, the message might be either a mail or
622 a news."
623   (interactive "P")
624   ;; Bind this variable here to make message mode hooks work ok.
625   (let ((gnus-newsgroup-name
626          (if arg
627              (if (= 1 (prefix-numeric-value arg))
628                  (completing-read "Newsgroup: " gnus-active-hashtb nil
629                                   (gnus-read-active-file-p))
630                (gnus-group-group-name))
631            ""))
632         ;; make sure last viewed article doesn't affect posting styles:
633         (gnus-article-copy))
634     (gnus-post-news 'post gnus-newsgroup-name nil nil nil nil
635                     (string= gnus-newsgroup-name ""))))
636
637 (defun gnus-summary-mail-other-window (&optional arg)
638   "Start composing a mail in another window.
639 Use the posting of the current group by default.
640 If ARG, don't do that.  If ARG is 1, prompt for group name to find the
641 posting style."
642   (interactive "P")
643   ;; We can't `let' gnus-newsgroup-name here, since that leads
644   ;; to local variables leaking.
645   (let ((group gnus-newsgroup-name)
646         ;; make sure last viewed article doesn't affect posting styles:
647         (gnus-article-copy)
648         (buffer (current-buffer)))
649     (unwind-protect
650         (progn
651           (setq gnus-newsgroup-name
652                 (if arg
653                     (if (= 1 (prefix-numeric-value arg))
654                         (completing-read "Use group: "
655                                          gnus-active-hashtb nil
656                                          (gnus-read-active-file-p))
657                       "")
658                   gnus-newsgroup-name))
659           ;; #### see comment in gnus-setup-message -- drv
660           (gnus-setup-message 'message (message-mail)))
661       (save-excursion
662         (set-buffer buffer)
663         (setq gnus-newsgroup-name group)))))
664
665 (defun gnus-summary-news-other-window (&optional arg)
666   "Start composing a news in another window.
667 Post to the current group by default.
668 If ARG, don't do that.  If ARG is 1, prompt for group name to post to.
669
670 This function prepares a news even when using mail groups.  This is useful
671 for posting messages to mail groups without actually sending them over the
672 network.  The corresponding backend must have a 'request-post method."
673   (interactive "P")
674   ;; We can't `let' gnus-newsgroup-name here, since that leads
675   ;; to local variables leaking.
676   (let ((group gnus-newsgroup-name)
677         ;; make sure last viewed article doesn't affect posting styles:
678         (gnus-article-copy)
679         (buffer (current-buffer)))
680     (unwind-protect
681         (progn
682           (setq gnus-newsgroup-name
683                 (if arg
684                     (if (= 1 (prefix-numeric-value arg))
685                         (completing-read "Use group: "
686                                          gnus-active-hashtb nil
687                                          (gnus-read-active-file-p))
688                       "")
689                   gnus-newsgroup-name))
690           ;; #### see comment in gnus-setup-message -- drv
691           (gnus-setup-message 'message
692             (message-news (gnus-group-real-name gnus-newsgroup-name))))
693       (save-excursion
694         (set-buffer buffer)
695         (setq gnus-newsgroup-name group)))))
696
697 (defun gnus-summary-post-news (&optional arg)
698   "Start composing a message.  Post to the current group by default.
699 If ARG, don't do that.  If ARG is 1, prompt for a group name to post to.
700 Depending on the selected group, the message might be either a mail or
701 a news."
702   (interactive "P")
703   ;; Bind this variable here to make message mode hooks work ok.
704   (let ((gnus-newsgroup-name
705          (if arg
706              (if (= 1 (prefix-numeric-value arg))
707                  (completing-read "Newsgroup: " gnus-active-hashtb nil
708                                   (gnus-read-active-file-p))
709                "")
710            gnus-newsgroup-name))
711         ;; make sure last viewed article doesn't affect posting styles:
712         (gnus-article-copy))
713     (gnus-post-news 'post gnus-newsgroup-name)))
714
715
716 (defun gnus-summary-followup (yank &optional force-news)
717   "Compose a followup to an article.
718 If prefix argument YANK is non-nil, the original article is yanked
719 automatically.
720 YANK is a list of elements, where the car of each element is the
721 article number, and the two following numbers is the region to be
722 yanked."
723   (interactive
724    (list (and current-prefix-arg
725               (gnus-summary-work-articles 1))))
726   (when yank
727     (gnus-summary-goto-subject
728      (if (listp (car yank))
729          (caar yank)
730        (car yank))))
731   (save-window-excursion
732     (gnus-summary-select-article))
733   (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
734         (gnus-newsgroup-name gnus-newsgroup-name))
735     ;; Send a followup.
736     (gnus-post-news nil gnus-newsgroup-name
737                     headers gnus-article-buffer
738                     yank nil force-news)
739     (gnus-summary-handle-replysign)))
740
741 (defun gnus-summary-followup-with-original (n &optional force-news)
742   "Compose a followup to an article and include the original article."
743   (interactive "P")
744   (gnus-summary-followup (gnus-summary-work-articles n) force-news))
745
746 (defun gnus-summary-followup-to-mail (&optional arg)
747   "Followup to the current mail message via news."
748   (interactive
749    (list (and current-prefix-arg
750               (gnus-summary-work-articles 1))))
751   (gnus-summary-followup arg t))
752
753 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
754   "Followup to the current mail message via news."
755   (interactive "P")
756   (gnus-summary-followup (gnus-summary-work-articles arg) t))
757
758 (defun gnus-inews-yank-articles (articles)
759   (let (beg article yank-string)
760     (message-goto-body)
761     (while (setq article (pop articles))
762       (when (listp article)
763         (setq yank-string (nth 1 article)
764               article (nth 0 article)))
765       (save-window-excursion
766         (set-buffer gnus-summary-buffer)
767         (gnus-summary-select-article nil nil nil article)
768         (gnus-summary-remove-process-mark article))
769       (gnus-copy-article-buffer nil yank-string)
770       (let ((message-reply-buffer gnus-article-copy)
771             (message-reply-headers
772              ;; The headers are decoded.
773              (with-current-buffer gnus-article-copy
774                (save-restriction
775                  (nnheader-narrow-to-headers)
776                  (nnheader-parse-naked-head)))))
777         (message-yank-original)
778         (setq beg (or beg (mark t))))
779       (when articles
780         (insert "\n")))
781     (push-mark)
782     (goto-char beg)))
783
784 (defun gnus-summary-cancel-article (&optional n symp)
785   "Cancel an article you posted.
786 Uses the process-prefix convention.  If given the symbolic
787 prefix `a', cancel using the standard posting method; if not
788 post using the current select method."
789   (interactive (gnus-interactive "P\ny"))
790   (let ((articles (gnus-summary-work-articles n))
791         (message-post-method
792          `(lambda (arg)
793             (gnus-post-method (eq ',symp 'a) ,gnus-newsgroup-name)))
794         article)
795     (while (setq article (pop articles))
796       (when (gnus-summary-select-article t nil nil article)
797         (when (gnus-eval-in-buffer-window gnus-original-article-buffer
798                 (message-cancel-news))
799           (gnus-summary-mark-as-read article gnus-canceled-mark)
800           (gnus-cache-remove-article 1))
801         (gnus-article-hide-headers-if-wanted))
802       (gnus-summary-remove-process-mark article))))
803
804 (defun gnus-summary-supersede-article ()
805   "Compose an article that will supersede a previous article.
806 This is done simply by taking the old article and adding a Supersedes
807 header line with the old Message-ID."
808   (interactive)
809   (let ((article (gnus-summary-article-number)))
810     (gnus-setup-message 'reply-yank
811       (gnus-summary-select-article t)
812       (set-buffer gnus-original-article-buffer)
813       (message-supersede)
814       (push
815        `((lambda ()
816            (when (gnus-buffer-exists-p ,gnus-summary-buffer)
817              (save-excursion
818                (set-buffer ,gnus-summary-buffer)
819                (gnus-cache-possibly-remove-article ,article nil nil nil t)
820                (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
821        message-send-actions))))
822
823 \f
824
825 (defun gnus-copy-article-buffer (&optional article-buffer yank-string)
826   ;; make a copy of the article buffer with all text properties removed
827   ;; this copy is in the buffer gnus-article-copy.
828   ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
829   ;; this buffer should be passed to all mail/news reply/post routines.
830   (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
831   (save-excursion
832     (set-buffer gnus-article-copy)
833     (mm-enable-multibyte))
834   (let ((article-buffer (or article-buffer gnus-article-buffer))
835         end beg)
836     (if (not (and (get-buffer article-buffer)
837                   (gnus-buffer-exists-p article-buffer)))
838         (error "Can't find any article buffer")
839       (save-excursion
840         (set-buffer article-buffer)
841         (let ((gnus-newsgroup-charset (or gnus-article-charset
842                                           gnus-newsgroup-charset))
843               (gnus-newsgroup-ignored-charsets
844                (or gnus-article-ignored-charsets
845                    gnus-newsgroup-ignored-charsets)))
846           (save-restriction
847             ;; Copy over the (displayed) article buffer, delete
848             ;; hidden text and remove text properties.
849             (widen)
850             (copy-to-buffer gnus-article-copy (point-min) (point-max))
851             (set-buffer gnus-article-copy)
852             (when yank-string
853               (message-goto-body)
854               (delete-region (point) (point-max))
855               (insert yank-string))
856             (gnus-article-delete-text-of-type 'annotation)
857             (gnus-remove-text-with-property 'gnus-prev)
858             (gnus-remove-text-with-property 'gnus-next)
859             (gnus-remove-text-with-property 'gnus-decoration)
860             (insert
861              (prog1
862                  (buffer-substring-no-properties (point-min) (point-max))
863                (erase-buffer)))
864             ;; Find the original headers.
865             (set-buffer gnus-original-article-buffer)
866             (goto-char (point-min))
867             (while (looking-at message-unix-mail-delimiter)
868               (forward-line 1))
869             (let ((mail-header-separator ""))
870               (setq beg (point)
871                     end (or (message-goto-body)
872                             ;; There may be just a header.
873                             (point-max))))
874             ;; Delete the headers from the displayed articles.
875             (set-buffer gnus-article-copy)
876             (let ((mail-header-separator ""))
877               (delete-region (goto-char (point-min))
878                              (or (message-goto-body) (point-max))))
879             ;; Insert the original article headers.
880             (insert-buffer-substring gnus-original-article-buffer beg end)
881             ;; Decode charsets.
882             (let ((gnus-article-decode-hook
883                    (delq 'article-decode-charset
884                          (copy-sequence gnus-article-decode-hook))))
885               (run-hooks 'gnus-article-decode-hook)))))
886       gnus-article-copy)))
887
888 (defun gnus-post-news (post &optional group header article-buffer yank subject
889                             force-news)
890   (when article-buffer
891     (gnus-copy-article-buffer))
892   (let ((gnus-article-reply (and article-buffer (gnus-summary-article-number)))
893         (gnus-article-yanked-articles yank)
894         (add-to-list gnus-add-to-list))
895     (gnus-setup-message (cond (yank 'reply-yank)
896                               (article-buffer 'reply)
897                               (t 'message))
898       (let* ((group (or group gnus-newsgroup-name))
899              (charset (gnus-group-name-charset nil group))
900              (pgroup group)
901              to-address to-group mailing-list to-list
902              newsgroup-p)
903         (when group
904           (setq to-address (gnus-parameter-to-address group)
905                 to-group (gnus-group-find-parameter group 'to-group)
906                 to-list (gnus-parameter-to-list group)
907                 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
908                 mailing-list (when gnus-mailing-list-groups
909                                (string-match gnus-mailing-list-groups group))
910                 group (gnus-group-name-decode (gnus-group-real-name group)
911                                               charset)))
912         (if (or (and to-group
913                      (gnus-news-group-p to-group))
914                 newsgroup-p
915                 force-news
916                 (and (gnus-news-group-p
917                       (or pgroup gnus-newsgroup-name)
918                       (or header gnus-current-article))
919                      (not mailing-list)
920                      (not to-list)
921                      (not to-address)))
922             ;; This is news.
923             (if post
924                 (message-news (or to-group group))
925               (set-buffer gnus-article-copy)
926               (gnus-msg-treat-broken-reply-to)
927               (message-followup (if (or newsgroup-p force-news)
928                                     (if (save-restriction
929                                           (article-narrow-to-head)
930                                           (message-fetch-field "newsgroups"))
931                                         nil
932                                       "")
933                                   to-group)))
934           ;; The is mail.
935           (if post
936               (progn
937                 (message-mail (or to-address to-list))
938                 ;; Arrange for mail groups that have no `to-address' to
939                 ;; get that when the user sends off the mail.
940                 (when (and (not to-list)
941                            (not to-address)
942                            add-to-list)
943                   (push (list 'gnus-inews-add-to-address pgroup)
944                         message-send-actions)))
945             (set-buffer gnus-article-copy)
946             (gnus-msg-treat-broken-reply-to)
947             (message-wide-reply to-address)))
948         (when yank
949           (gnus-inews-yank-articles yank))))))
950
951 (defun gnus-msg-treat-broken-reply-to (&optional force)
952   "Remove the Reply-to header if broken-reply-to."
953   (when (or force
954             (gnus-group-find-parameter
955              gnus-newsgroup-name 'broken-reply-to))
956     (save-restriction
957       (message-narrow-to-head)
958       (message-remove-header "reply-to"))))
959
960 (defun gnus-post-method (arg group &optional silent)
961   "Return the posting method based on GROUP and ARG.
962 If SILENT, don't prompt the user."
963   (let ((gnus-post-method (or (gnus-parameter-post-method group)
964                               gnus-post-method))
965         (group-method (gnus-find-method-for-group group)))
966     (cond
967      ;; If the group-method is nil (which shouldn't happen) we use
968      ;; the default method.
969      ((null group-method)
970       (or (and (listp gnus-post-method) ;If not current/native/nil
971                (not (listp (car gnus-post-method))) ; and not a list of methods
972                gnus-post-method)        ;then use it.
973           gnus-select-method
974           message-post-method))
975      ;; We want the inverse of the default
976      ((and arg (not (eq arg 0)))
977       (if (eq gnus-post-method 'current)
978           gnus-select-method
979         group-method))
980      ;; We query the user for a post method.
981      ((or arg
982           (and (listp gnus-post-method)
983                (listp (car gnus-post-method))))
984       (let* ((methods
985               ;; Collect all methods we know about.
986               (append
987                (when (listp gnus-post-method)
988                  (if (listp (car gnus-post-method))
989                      gnus-post-method
990                    (list gnus-post-method)))
991                gnus-secondary-select-methods
992                (mapcar 'cdr gnus-server-alist)
993                (mapcar 'car gnus-opened-servers)
994                (list gnus-select-method)
995                (list group-method)))
996              method-alist post-methods method)
997         ;; Weed out all mail methods.
998         (while methods
999           (setq method (gnus-server-get-method "" (pop methods)))
1000           (when (and (or (gnus-method-option-p method 'post)
1001                          (gnus-method-option-p method 'post-mail))
1002                      (not (member method post-methods)))
1003             (push method post-methods)))
1004         ;; Create a name-method alist.
1005         (setq method-alist
1006               (mapcar
1007                (lambda (m)
1008                  (if (equal (cadr m) "")
1009                      (list (symbol-name (car m)) m)
1010                    (list (concat (cadr m) " (" (symbol-name (car m)) ")") m)))
1011                post-methods))
1012         ;; Query the user.
1013         (cadr
1014          (assoc
1015           (setq gnus-last-posting-server
1016                 (if (and silent
1017                          gnus-last-posting-server)
1018                     ;; Just use the last value.
1019                     gnus-last-posting-server
1020                   (completing-read
1021                    "Posting method: " method-alist nil t
1022                    (cons (or gnus-last-posting-server "") 0))))
1023           method-alist))))
1024      ;; Override normal method.
1025      ((and (eq gnus-post-method 'current)
1026            (not (memq (car group-method) gnus-discouraged-post-methods))
1027            (gnus-get-function group-method 'request-post t))
1028       (assert (not arg))
1029       group-method)
1030      ;; Use gnus-post-method.
1031      ((listp gnus-post-method)          ;A method...
1032       (assert (not (listp (car gnus-post-method)))) ;... not a list of methods.
1033       gnus-post-method)
1034      ;; Use the normal select method (nil or native).
1035      (t gnus-select-method))))
1036
1037 \f
1038
1039 ;; Dummies to avoid byte-compile warning.
1040 (eval-when-compile
1041   (defvar nnspool-rejected-article-hook)
1042   (defvar xemacs-codename))
1043
1044 (defun gnus-extended-version ()
1045   "Stringified Gnus version and Emacs version.
1046 See the variable `gnus-user-agent'."
1047   (interactive)
1048   (let* ((gnus-v
1049           (concat "Gnus/"
1050                   (prin1-to-string (gnus-continuum-version gnus-version) t)
1051                   " (" gnus-version ")"))
1052          (system-v
1053           (cond
1054            ((eq gnus-user-agent 'emacs-gnus-config)
1055             system-configuration)
1056            ((eq gnus-user-agent 'emacs-gnus-type)
1057             (symbol-name system-type))
1058            (t nil)))
1059          (emacs-v
1060           (cond
1061            ((eq gnus-user-agent 'gnus)
1062             nil)
1063            ((string-match "^\\(\\([.0-9]+\\)*\\)\\.[0-9]+$" emacs-version)
1064             (concat "Emacs/" (match-string 1 emacs-version)
1065                     (if system-v
1066                         (concat " (" system-v ")")
1067                       "")))
1068            ((string-match
1069              "\\([A-Z]*[Mm][Aa][Cc][Ss]\\)[^(]*\\(\\((beta.*)\\|'\\)\\)?"
1070              emacs-version)
1071             (concat
1072              (match-string 1 emacs-version)
1073              (format "/%d.%d" emacs-major-version emacs-minor-version)
1074              (if (match-beginning 3)
1075                  (match-string 3 emacs-version)
1076                "")
1077              (if (boundp 'xemacs-codename)
1078                  (concat
1079                   " (" xemacs-codename
1080                   (if system-v
1081                       (concat ", " system-v ")")
1082                     ")"))
1083                "")))
1084            (t emacs-version))))
1085     (if (stringp gnus-user-agent)
1086         gnus-user-agent
1087       (concat gnus-v
1088               (when emacs-v
1089                 (concat " " emacs-v))))))
1090
1091 \f
1092 ;;;
1093 ;;; Gnus Mail Functions
1094 ;;;
1095
1096 ;;; Mail reply commands of Gnus summary mode
1097
1098 (defun gnus-summary-reply (&optional yank wide very-wide)
1099   "Start composing a mail reply to the current message.
1100 If prefix argument YANK is non-nil, the original article is yanked
1101 automatically.
1102 If WIDE, make a wide reply.
1103 If VERY-WIDE, make a very wide reply."
1104   (interactive
1105    (list (and current-prefix-arg
1106               (gnus-summary-work-articles 1))))
1107   ;; Allow user to require confirmation before replying by mail to the
1108   ;; author of a news article (or mail message).
1109   (when (or 
1110             (not (or (gnus-news-group-p gnus-newsgroup-name)
1111                      gnus-confirm-treat-mail-like-news))
1112             (not (cond ((stringp gnus-confirm-mail-reply-to-news)
1113                         (string-match gnus-confirm-mail-reply-to-news
1114                                       gnus-newsgroup-name))
1115                        ((functionp gnus-confirm-mail-reply-to-news)
1116                         (funcall gnus-confirm-mail-reply-to-news gnus-newsgroup-name))
1117                        (t gnus-confirm-mail-reply-to-news)))
1118             (y-or-n-p "Really reply by mail to article author? "))
1119     (let* ((article
1120             (if (listp (car yank))
1121                 (caar yank)
1122               (car yank)))
1123            (gnus-article-reply (or article (gnus-summary-article-number)))
1124            (gnus-article-yanked-articles yank)
1125            (headers ""))
1126       ;; Stripping headers should be specified with mail-yank-ignored-headers.
1127       (when yank
1128         (gnus-summary-goto-subject article))
1129       (gnus-setup-message (if yank 'reply-yank 'reply)
1130         (if (not very-wide)
1131             (gnus-summary-select-article)
1132           (dolist (article very-wide)
1133             (gnus-summary-select-article nil nil nil article)
1134             (save-excursion
1135               (set-buffer (gnus-copy-article-buffer))
1136               (gnus-msg-treat-broken-reply-to)
1137               (save-restriction
1138                 (message-narrow-to-head)
1139                 (setq headers (concat headers (buffer-string)))))))
1140         (set-buffer (gnus-copy-article-buffer))
1141         (gnus-msg-treat-broken-reply-to gnus-msg-force-broken-reply-to)
1142         (save-restriction
1143           (message-narrow-to-head)
1144           (when very-wide
1145             (erase-buffer)
1146             (insert headers))
1147           (goto-char (point-max)))
1148         (mml-quote-region (point) (point-max))
1149         (message-reply nil wide)
1150         (when yank
1151           (gnus-inews-yank-articles yank))
1152         (gnus-summary-handle-replysign)))))
1153
1154 (defun gnus-summary-handle-replysign ()
1155   "Check the various replysign variables and take action accordingly."
1156   (when (or gnus-message-replysign gnus-message-replyencrypt)
1157     (let (signed encrypted)
1158       (save-excursion
1159         (set-buffer gnus-article-buffer)
1160         (setq signed (memq 'signed gnus-article-wash-types))
1161         (setq encrypted (memq 'encrypted gnus-article-wash-types)))
1162       (cond ((and gnus-message-replyencrypt encrypted)
1163              (mml-secure-message mml-default-encrypt-method
1164                                  (if gnus-message-replysignencrypted
1165                                      'signencrypt
1166                                    'encrypt)))
1167             ((and gnus-message-replysign signed)
1168              (mml-secure-message mml-default-sign-method 'sign))))))
1169
1170 (defun gnus-summary-reply-with-original (n &optional wide)
1171   "Start composing a reply mail to the current message.
1172 The original article will be yanked."
1173   (interactive "P")
1174   (gnus-summary-reply (gnus-summary-work-articles n) wide))
1175
1176 (defun gnus-summary-reply-broken-reply-to (&optional yank wide very-wide)
1177   "Like `gnus-summary-reply' except removing reply-to field.
1178 If prefix argument YANK is non-nil, the original article is yanked
1179 automatically.
1180 If WIDE, make a wide reply.
1181 If VERY-WIDE, make a very wide reply."
1182   (interactive
1183    (list (and current-prefix-arg
1184               (gnus-summary-work-articles 1))))
1185   (let ((gnus-msg-force-broken-reply-to t))
1186     (gnus-summary-reply yank wide very-wide)))
1187
1188 (defun gnus-summary-reply-broken-reply-to-with-original (n &optional wide)
1189   "Like `gnus-summary-reply-with-original' except removing reply-to field.
1190 The original article will be yanked."
1191   (interactive "P")
1192   (gnus-summary-reply-broken-reply-to (gnus-summary-work-articles n) wide))
1193
1194 (defun gnus-summary-wide-reply (&optional yank)
1195   "Start composing a wide reply mail to the current message.
1196 If prefix argument YANK is non-nil, the original article is yanked
1197 automatically."
1198   (interactive
1199    (list (and current-prefix-arg
1200               (gnus-summary-work-articles 1))))
1201   (gnus-summary-reply yank t))
1202
1203 (defun gnus-summary-wide-reply-with-original (n)
1204   "Start composing a wide reply mail to the current message.
1205 The original article will be yanked."
1206   (interactive "P")
1207   (gnus-summary-reply-with-original n t))
1208
1209 (defun gnus-summary-very-wide-reply (&optional yank)
1210   "Start composing a very wide reply mail to the current message.
1211 If prefix argument YANK is non-nil, the original article is yanked
1212 automatically."
1213   (interactive
1214    (list (and current-prefix-arg
1215               (gnus-summary-work-articles 1))))
1216   (gnus-summary-reply yank t (gnus-summary-work-articles yank)))
1217
1218 (defun gnus-summary-very-wide-reply-with-original (n)
1219   "Start composing a very wide reply mail to the current message.
1220 The original article will be yanked."
1221   (interactive "P")
1222   (gnus-summary-reply
1223    (gnus-summary-work-articles n) t (gnus-summary-work-articles n)))
1224
1225 (defun gnus-summary-mail-forward (&optional arg post)
1226   "Forward the current message(s) to another user.
1227 If process marks exist, forward all marked messages;
1228 if ARG is nil, see `message-forward-as-mime' and `message-forward-show-mml';
1229 if ARG is 1, decode the message and forward directly inline;
1230 if ARG is 2, forward message as an rfc822 MIME section;
1231 if ARG is 3, decode message and forward as an rfc822 MIME section;
1232 if ARG is 4, forward message directly inline;
1233 otherwise, use flipped `message-forward-as-mime'.
1234 If POST, post instead of mail.
1235 For the `inline' alternatives, also see the variable
1236 `message-forward-ignored-headers'."
1237   (interactive "P")
1238   (if (cdr (gnus-summary-work-articles nil))
1239       ;; Process marks are given.
1240       (gnus-uu-digest-mail-forward arg post)
1241     ;; No process marks.
1242     (let ((message-forward-as-mime message-forward-as-mime)
1243           (message-forward-show-mml message-forward-show-mml))
1244       (cond
1245        ((null arg))
1246        ((eq arg 1)
1247         (setq message-forward-as-mime nil
1248               message-forward-show-mml t))
1249        ((eq arg 2)
1250         (setq message-forward-as-mime t
1251               message-forward-show-mml nil))
1252        ((eq arg 3)
1253         (setq message-forward-as-mime t
1254               message-forward-show-mml t))
1255        ((eq arg 4)
1256         (setq message-forward-as-mime nil
1257               message-forward-show-mml nil))
1258        (t
1259         (setq message-forward-as-mime (not message-forward-as-mime))))
1260       (let* ((gnus-article-reply (gnus-summary-article-number))
1261              (gnus-article-yanked-articles (list gnus-article-reply)))
1262         (gnus-setup-message 'forward
1263           (gnus-summary-select-article)
1264           (let ((mail-parse-charset
1265                  (or (and (gnus-buffer-live-p gnus-article-buffer)
1266                           (with-current-buffer gnus-article-buffer
1267                             gnus-article-charset))
1268                      gnus-newsgroup-charset))
1269                 (mail-parse-ignored-charsets
1270                  gnus-newsgroup-ignored-charsets))
1271             (set-buffer gnus-original-article-buffer)
1272             (message-forward post)))))))
1273
1274 (defun gnus-summary-resend-message (address n)