Bad group name in history.
[gnus] / lisp / gnus-msg.el
1 ;;; gnus-msg.el --- mail and post interface for Gnus
2 ;; Copyright (C) 1995,96,97,98,99 Free Software Foundation, Inc.
3
4 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
5 ;;      Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; Keywords: news
7
8 ;; This file is part of GNU Emacs.
9
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
24
25 ;;; Commentary:
26
27 ;;; Code:
28
29 (eval-when-compile (require 'cl))
30
31 (require 'gnus)
32 (require 'gnus-ems)
33 (require 'message)
34 (require 'gnus-art)
35
36 (defcustom gnus-post-method 'current
37   "*Preferred method for posting USENET news.
38
39 If this variable is `current', Gnus will use the \"current\" select
40 method when posting.  If it is nil (which is the default), Gnus will
41 use the native select method when posting.
42
43 This method will not be used in mail groups and the like, only in
44 \"real\" newsgroups.
45
46 If not nil nor `native', the value must be a valid method as discussed
47 in the documentation of `gnus-select-method'.  It can also be a list of
48 methods.  If that is the case, the user will be queried for what select
49 method to use when posting."
50   :group 'gnus-group-foreign
51   :type `(choice (const nil)
52                  (const current)
53                  (const native)
54                  (sexp :tag "Methods" ,gnus-select-method)))
55
56 (defvar gnus-outgoing-message-group nil
57   "*All outgoing messages will be put in this group.
58 If you want to store all your outgoing mail and articles in the group
59 \"nnml:archive\", you set this variable to that value.  This variable
60 can also be a list of group names.
61
62 If you want to have greater control over what group to put each
63 message in, you can set this variable to a function that checks the
64 current newsgroup name and then returns a suitable group name (or list
65 of names).")
66
67 (defvar gnus-mailing-list-groups nil
68   "*Regexp matching groups that are really mailing lists.
69 This is useful when you're reading a mailing list that has been
70 gatewayed to a newsgroup, and you want to followup to an article in
71 the group.")
72
73 (defvar gnus-add-to-list nil
74   "*If non-nil, add a `to-list' parameter automatically.")
75
76 (defvar gnus-crosspost-complaint
77   "Hi,
78
79 You posted the article below with the following Newsgroups header:
80
81 Newsgroups: %s
82
83 The %s group, at least, was an inappropriate recipient
84 of this message.  Please trim your Newsgroups header to exclude this
85 group before posting in the future.
86
87 Thank you.
88
89 "
90   "Format string to be inserted when complaining about crossposts.
91 The first %s will be replaced by the Newsgroups header;
92 the second with the current group name.")
93
94 (defvar gnus-message-setup-hook nil
95   "Hook run after setting up a message buffer.")
96
97 (defvar gnus-bug-create-help-buffer t
98   "*Should we create the *Gnus Help Bug* buffer?")
99
100 (defvar gnus-posting-styles nil
101   "*Alist of styles to use when posting.")
102
103 (defcustom gnus-group-posting-charset-alist
104   '(("^no\\." iso-8859-1)
105     ("^de\\." iso-8859-1)
106     (message-this-is-mail nil)
107     (".*" iso-8859-1)
108     (message-this-is-news iso-8859-1))
109   "Alist of regexps (to match group names) and default charsets to be unencoded when posting."
110   :type '(repeat (list (regexp :tag "Group")
111                        (symbol :tag "Charset")))
112   :group 'gnus-charset)
113
114 ;;; Internal variables.
115
116 (defvar gnus-inhibit-posting-styles nil
117   "Inhibit the use of posting styles.")
118
119 (defvar gnus-message-buffer "*Mail Gnus*")
120 (defvar gnus-article-copy nil)
121 (defvar gnus-last-posting-server nil)
122 (defvar gnus-message-group-art nil)
123
124 (defconst gnus-bug-message
125   "Sending a bug report to the Gnus Towers.
126 ========================================
127
128 The buffer below is a mail buffer.  When you press `C-c C-c', it will
129 be sent to the Gnus Bug Exterminators.
130
131 The thing near the bottom of the buffer is how the environment
132 settings will be included in the mail.  Please do not delete that.
133 They will tell the Bug People what your environment is, so that it
134 will be easier to locate the bugs.
135
136 If you have found a bug that makes Emacs go \"beep\", set
137 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
138 and include the backtrace in your bug report.
139
140 Please describe the bug in annoying, painstaking detail.
141
142 Thank you for your help in stamping out bugs.
143 ")
144
145 (eval-and-compile
146   (autoload 'gnus-uu-post-news "gnus-uu" nil t)
147   (autoload 'news-setup "rnewspost")
148   (autoload 'news-reply-mode "rnewspost")
149   (autoload 'rmail-dont-reply-to "mail-utils")
150   (autoload 'rmail-output "rmailout"))
151
152 \f
153 ;;;
154 ;;; Gnus Posting Functions
155 ;;;
156
157 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
158   "p" gnus-summary-post-news
159   "f" gnus-summary-followup
160   "F" gnus-summary-followup-with-original
161   "c" gnus-summary-cancel-article
162   "s" gnus-summary-supersede-article
163   "r" gnus-summary-reply
164   "y" gnus-summary-yank-message
165   "R" gnus-summary-reply-with-original
166   "w" gnus-summary-wide-reply
167   "W" gnus-summary-wide-reply-with-original
168   "n" gnus-summary-followup-to-mail
169   "N" gnus-summary-followup-to-mail-with-original
170   "m" gnus-summary-mail-other-window
171   "u" gnus-uu-post-news
172   "\M-c" gnus-summary-mail-crosspost-complaint
173   "om" gnus-summary-mail-forward
174   "op" gnus-summary-post-forward
175   "Om" gnus-uu-digest-mail-forward
176   "Op" gnus-uu-digest-post-forward)
177
178 (gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
179   "b" gnus-summary-resend-bounced-mail
180   ;; "c" gnus-summary-send-draft
181   "r" gnus-summary-resend-message)
182
183 ;;; Internal functions.
184
185 (defvar gnus-article-reply nil)
186 (defmacro gnus-setup-message (config &rest forms)
187   (let ((winconf (make-symbol "gnus-setup-message-winconf"))
188         (buffer (make-symbol "gnus-setup-message-buffer"))
189         (article (make-symbol "gnus-setup-message-article"))
190         (group (make-symbol "gnus-setup-message-group")))
191     `(let ((,winconf (current-window-configuration))
192            (,buffer (buffer-name (current-buffer)))
193            (,article (and gnus-article-reply (gnus-summary-article-number)))
194            (,group gnus-newsgroup-name)
195            (message-header-setup-hook
196             (copy-sequence message-header-setup-hook))
197            (message-mode-hook (copy-sequence message-mode-hook)))
198        (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
199        (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
200        (add-hook 'message-mode-hook 'gnus-configure-posting-styles)
201        (add-hook 'message-mode-hook
202                  (lambda ()
203                    (set (make-local-variable 'message-posting-charset)
204                         (gnus-setup-posting-charset ,group))))
205        (unwind-protect
206            (progn
207              ,@forms)
208          (gnus-inews-add-send-actions ,winconf ,buffer ,article)
209          (setq gnus-message-buffer (current-buffer))
210          (set (make-local-variable 'gnus-message-group-art)
211               (cons ,group ,article))
212          (set (make-local-variable 'gnus-newsgroup-name) ,group)
213          (gnus-run-hooks 'gnus-message-setup-hook))
214        (gnus-add-buffer)
215        (gnus-configure-windows ,config t)
216        (set-buffer-modified-p nil))))
217
218 (defun gnus-setup-posting-charset (group)
219   (let ((alist gnus-group-posting-charset-alist)
220         (group (or group ""))
221         elem)
222     (when group
223       (catch 'found
224         (while (setq elem (pop alist))
225           (when (or (and (stringp (car elem))
226                          (string-match (car elem) group))
227                     (and (gnus-functionp (car elem))
228                          (funcall (car elem) group))
229                     (and (symbolp (car elem))
230                          (symbol-value (car elem))))
231             (throw 'found (cadr elem))))))))
232
233 (defun gnus-inews-add-send-actions (winconf buffer article)
234   (make-local-hook 'message-sent-hook)
235   (add-hook 'message-sent-hook 'gnus-inews-do-gcc nil t)
236   (setq message-post-method
237         `(lambda (arg)
238            (gnus-post-method arg ,gnus-newsgroup-name)))
239   (setq message-newsreader (setq message-mailer (gnus-extended-version)))
240   (message-add-action
241    `(set-window-configuration ,winconf) 'exit 'postpone 'kill)
242   (message-add-action
243    `(when (gnus-buffer-exists-p ,buffer)
244       (save-excursion
245         (set-buffer ,buffer)
246         ,(when article
247            `(gnus-summary-mark-article-as-replied ,article))))
248    'send))
249
250 (put 'gnus-setup-message 'lisp-indent-function 1)
251 (put 'gnus-setup-message 'edebug-form-spec '(form body))
252
253 ;;; Post news commands of Gnus group mode and summary mode
254
255 (defun gnus-group-mail (&optional arg)
256   "Start composing a mail.
257 If ARG, use the group under the point to find a posting style.
258 If ARG is 1, prompt for a group name to find the posting style."
259   (interactive "P")
260   ;; We can't `let' gnus-newsgroup-name here, since that leads
261   ;; to local variables leaking.
262   (let ((group gnus-newsgroup-name)
263         (buffer (current-buffer)))
264     (unwind-protect
265         (progn
266           (setq gnus-newsgroup-name
267                 (if arg
268                     (if (= 1 (prefix-numeric-value arg))
269                         (completing-read "Use posting style of group: "
270                                          gnus-active-hashtb nil
271                                          (gnus-read-active-file-p))
272                       (gnus-group-group-name))
273                   ""))
274           (gnus-setup-message 'message (message-mail)))
275       (save-excursion
276         (set-buffer buffer)
277         (setq gnus-newsgroup-name group)))))
278
279 (defun gnus-group-post-news (&optional arg)
280   "Start composing a news message.
281 If ARG, post to the group under point.
282 If ARG is 1, prompt for a group name."
283   (interactive "P")
284   ;; Bind this variable here to make message mode hooks work ok.
285   (let ((gnus-newsgroup-name
286          (if arg
287              (if (= 1 (prefix-numeric-value arg))
288                  (completing-read "Newsgroup: " gnus-active-hashtb nil
289                                   (gnus-read-active-file-p))
290                (gnus-group-group-name))
291            "")))
292     (gnus-post-news 'post gnus-newsgroup-name)))
293
294 (defun gnus-summary-post-news ()
295   "Start composing a news message."
296   (interactive)
297   (gnus-post-news 'post gnus-newsgroup-name))
298
299 (defun gnus-summary-followup (yank &optional force-news)
300   "Compose a followup to an article.
301 If prefix argument YANK is non-nil, original article is yanked automatically."
302   (interactive
303    (list (and current-prefix-arg
304               (gnus-summary-work-articles 1))))
305   (when yank
306     (gnus-summary-goto-subject (car yank)))
307   (save-window-excursion
308     (gnus-summary-select-article))
309   (let ((headers (gnus-summary-article-header (gnus-summary-article-number)))
310         (gnus-newsgroup-name gnus-newsgroup-name))
311     ;; Send a followup.
312     (gnus-post-news nil gnus-newsgroup-name
313                     headers gnus-article-buffer
314                     yank nil force-news)))
315
316 (defun gnus-summary-followup-with-original (n &optional force-news)
317   "Compose a followup to an article and include the original article."
318   (interactive "P")
319   (gnus-summary-followup (gnus-summary-work-articles n) force-news))
320
321 (defun gnus-summary-followup-to-mail (&optional arg)
322   "Followup to the current mail message via news."
323   (interactive
324    (list (and current-prefix-arg
325               (gnus-summary-work-articles 1))))
326   (gnus-summary-followup arg t))
327
328 (defun gnus-summary-followup-to-mail-with-original (&optional arg)
329   "Followup to the current mail message via news."
330   (interactive "P")
331   (gnus-summary-followup (gnus-summary-work-articles arg) t))
332
333 (defun gnus-inews-yank-articles (articles)
334   (let (beg article)
335     (message-goto-body)
336     (while (setq article (pop articles))
337       (save-window-excursion
338         (set-buffer gnus-summary-buffer)
339         (gnus-summary-select-article nil nil nil article)
340         (gnus-summary-remove-process-mark article))
341       (gnus-copy-article-buffer)
342       (let ((message-reply-buffer gnus-article-copy)
343             (message-reply-headers gnus-current-headers))
344         (message-yank-original)
345         (setq beg (or beg (mark t))))
346       (when articles
347         (insert "\n")))
348     (push-mark)
349     (goto-char beg)))
350
351 (defun gnus-summary-cancel-article (&optional n symp)
352   "Cancel an article you posted.
353 Uses the process-prefix convention.  If given the symbolic
354 prefix `a', cancel using the standard posting method; if not
355 post using the current select method."
356   (interactive (gnus-interactive "P\ny"))
357   (let ((articles (gnus-summary-work-articles n))
358         (message-post-method
359          `(lambda (arg)
360             (gnus-post-method (not (eq symp 'a)) ,gnus-newsgroup-name)))
361         article)
362     (while (setq article (pop articles))
363       (when (gnus-summary-select-article t nil nil article)
364         (when (gnus-eval-in-buffer-window gnus-original-article-buffer
365                 (message-cancel-news))
366           (gnus-summary-mark-as-read article gnus-canceled-mark)
367           (gnus-cache-remove-article 1))
368         (gnus-article-hide-headers-if-wanted))
369       (gnus-summary-remove-process-mark article))))
370
371 (defun gnus-summary-supersede-article ()
372   "Compose an article that will supersede a previous article.
373 This is done simply by taking the old article and adding a Supersedes
374 header line with the old Message-ID."
375   (interactive)
376   (let ((article (gnus-summary-article-number)))
377     (gnus-setup-message 'reply-yank
378       (gnus-summary-select-article t)
379       (set-buffer gnus-original-article-buffer)
380       (message-supersede)
381       (push
382        `((lambda ()
383            (when (gnus-buffer-exists-p ,gnus-summary-buffer)
384              (save-excursion
385                (set-buffer ,gnus-summary-buffer)
386                (gnus-cache-possibly-remove-article ,article nil nil nil t)
387                (gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
388        message-send-actions))))
389
390 \f
391
392 (defun gnus-copy-article-buffer (&optional article-buffer)
393   ;; make a copy of the article buffer with all text properties removed
394   ;; this copy is in the buffer gnus-article-copy.
395   ;; if ARTICLE-BUFFER is nil, gnus-article-buffer is used
396   ;; this buffer should be passed to all mail/news reply/post routines.
397   (setq gnus-article-copy (gnus-get-buffer-create " *gnus article copy*"))
398   (save-excursion
399     (set-buffer gnus-article-copy)
400     (mm-enable-multibyte))
401   (let ((article-buffer (or article-buffer gnus-article-buffer))
402         end beg)
403     (if (not (and (get-buffer article-buffer)
404                   (gnus-buffer-exists-p article-buffer)))
405         (error "Can't find any article buffer")
406       (save-excursion
407         (set-buffer article-buffer)
408         (save-restriction
409           ;; Copy over the (displayed) article buffer, delete
410           ;; hidden text and remove text properties.
411           (widen)
412           (copy-to-buffer gnus-article-copy (point-min) (point-max))
413           (set-buffer gnus-article-copy)
414           (gnus-article-delete-text-of-type 'annotation)
415           (gnus-remove-text-with-property 'gnus-prev)
416           (gnus-remove-text-with-property 'gnus-next)
417           (insert
418            (prog1
419                (format "%s" (buffer-string))
420              (erase-buffer)))
421           ;; Find the original headers.
422           (set-buffer gnus-original-article-buffer)
423           (goto-char (point-min))
424           (while (looking-at message-unix-mail-delimiter)
425             (forward-line 1))
426           (setq beg (point))
427           (setq end (or (search-forward "\n\n" nil t) (point)))
428           ;; Delete the headers from the displayed articles.
429           (set-buffer gnus-article-copy)
430           (delete-region (goto-char (point-min))
431                          (or (search-forward "\n\n" nil t) (point-max)))
432           ;; Insert the original article headers.
433           (insert-buffer-substring gnus-original-article-buffer beg end)
434           (article-decode-encoded-words)))
435       gnus-article-copy)))
436
437 (defun gnus-post-news (post &optional group header article-buffer yank subject
438                             force-news)
439   (when article-buffer
440     (gnus-copy-article-buffer))
441   (let ((gnus-article-reply article-buffer)
442         (add-to-list gnus-add-to-list))
443     (gnus-setup-message (cond (yank 'reply-yank)
444                               (article-buffer 'reply)
445                               (t 'message))
446       (let* ((group (or group gnus-newsgroup-name))
447              (pgroup group)
448              to-address to-group mailing-list to-list
449              newsgroup-p)
450         (when group
451           (setq to-address (gnus-group-find-parameter group 'to-address)
452                 to-group (gnus-group-find-parameter group 'to-group)
453                 to-list (gnus-group-find-parameter group 'to-list)
454                 newsgroup-p (gnus-group-find-parameter group 'newsgroup)
455                 mailing-list (when gnus-mailing-list-groups
456                                (string-match gnus-mailing-list-groups group))
457                 group (gnus-group-real-name group)))
458         (if (or (and to-group
459                      (gnus-news-group-p to-group))
460                 newsgroup-p
461                 force-news
462                 (and (gnus-news-group-p
463                       (or pgroup gnus-newsgroup-name)
464                       (if header (mail-header-number header)
465                         gnus-current-article))
466                      (not mailing-list)
467                      (not to-list)
468                      (not to-address)))
469             ;; This is news.
470             (if post
471                 (message-news (or to-group group))
472               (set-buffer gnus-article-copy)
473               (gnus-msg-treat-broken-reply-to)
474               (message-followup (if (or newsgroup-p force-news) nil to-group)))
475           ;; The is mail.
476           (if post
477               (progn
478                 (message-mail (or to-address to-list))
479                 ;; Arrange for mail groups that have no `to-address' to
480                 ;; get that when the user sends off the mail.
481                 (when (and (not to-list)
482                            (not to-address)
483                            add-to-list)
484                   (push (list 'gnus-inews-add-to-address pgroup)
485                         message-send-actions)))
486             (set-buffer gnus-article-copy)
487             (gnus-msg-treat-broken-reply-to)
488             (message-wide-reply to-address)))
489         (when yank
490           (gnus-inews-yank-articles yank))))))
491
492 (defun gnus-msg-treat-broken-reply-to ()
493   "Remove the Reply-to header iff broken-reply-to."
494   (when (gnus-group-find-parameter
495          gnus-newsgroup-name 'broken-reply-to)
496     (save-restriction
497       (message-narrow-to-head)
498       (message-remove-header "reply-to"))))
499
500 (defun gnus-post-method (arg group &optional silent)
501   "Return the posting method based on GROUP and ARG.
502 If SILENT, don't prompt the user."
503   (let ((group-method (gnus-find-method-for-group group)))
504     (cond
505      ;; If the group-method is nil (which shouldn't happen) we use
506      ;; the default method.
507      ((null group-method)
508       (or (and (null (eq gnus-post-method 'active)) gnus-post-method)
509           gnus-select-method message-post-method))
510      ;; We want the inverse of the default
511      ((and arg (not (eq arg 0)))
512       (if (eq gnus-post-method 'active)
513           gnus-select-method
514         group-method))
515      ;; We query the user for a post method.
516      ((or arg
517           (and gnus-post-method
518                (not (eq gnus-post-method 'current))
519                (listp (car gnus-post-method))))
520       (let* ((methods
521               ;; Collect all methods we know about.
522               (append
523                (when (and gnus-post-method
524                           (not (eq gnus-post-method 'current)))
525                  (if (listp (car gnus-post-method))
526                      gnus-post-method
527                    (list gnus-post-method)))
528                gnus-secondary-select-methods
529                (mapcar 'cdr gnus-server-alist)
530                (mapcar 'car gnus-opened-servers)
531                (list gnus-select-method)
532                (list group-method)))
533              method-alist post-methods method)
534         ;; Weed out all mail methods.
535         (while methods
536           (setq method (gnus-server-get-method "" (pop methods)))
537           (when (and (or (gnus-method-option-p method 'post)
538                          (gnus-method-option-p method 'post-mail))
539                      (not (member method post-methods)))
540             (push method post-methods)))
541         ;; Create a name-method alist.
542         (setq method-alist
543               (mapcar
544                (lambda (m)
545                  (list (concat (cadr m) " (" (symbol-name (car m)) ")") m))
546                post-methods))
547         ;; Query the user.
548         (cadr
549          (assoc
550           (setq gnus-last-posting-server
551                 (if (and silent
552                          gnus-last-posting-server)
553                     ;; Just use the last value.
554                     gnus-last-posting-server
555                   (completing-read
556                    "Posting method: " method-alist nil t
557                    (cons (or gnus-last-posting-server "") 0))))
558           method-alist))))
559      ;; Override normal method.
560      ((and (eq gnus-post-method 'current)
561            (not (eq (car group-method) 'nndraft))
562            (gnus-get-function group-method 'request-post t)
563            (not arg))
564       group-method)
565      ((and gnus-post-method
566            (not (eq gnus-post-method 'current)))
567       gnus-post-method)
568      ;; Use the normal select method.
569      (t gnus-select-method))))
570
571 \f
572
573 ;; Dummies to avoid byte-compile warning.
574 (defvar nnspool-rejected-article-hook)
575 (defvar xemacs-codename)
576
577 (defun gnus-extended-version ()
578   "Stringified Gnus version and Emacs version."
579   (interactive)
580   (concat
581    "Gnus/" (prin1-to-string (gnus-continuum-version gnus-version) t)
582    " (" gnus-version ")"
583    " "
584    (cond
585     ((string-match "^\\(\\([.0-9]+\\)*\\)\\.[0-9]+$" emacs-version)
586      (concat "Emacs/" (match-string 1 emacs-version)))
587     ((string-match "\\([A-Z]*[Mm][Aa][Cc][Ss]\\)[^(]*\\(\\((beta.*)\\|'\\)\\)?"
588                    emacs-version)
589      (concat (match-string 1 emacs-version)
590              (format "/%d.%d" emacs-major-version emacs-minor-version)
591              (if (match-beginning 3)
592                  (match-string 3 emacs-version)
593                "")
594              (if (boundp 'xemacs-codename)
595                  (concat " (" xemacs-codename ")")
596                "")))
597     (t emacs-version))))
598
599 \f
600 ;;;
601 ;;; Gnus Mail Functions
602 ;;;
603
604 ;;; Mail reply commands of Gnus summary mode
605
606 (defun gnus-summary-reply (&optional yank wide)
607   "Start composing a reply mail to the current message.
608 If prefix argument YANK is non-nil, the original article is yanked
609 automatically."
610   (interactive
611    (list (and current-prefix-arg
612               (gnus-summary-work-articles 1))))
613   ;; Stripping headers should be specified with mail-yank-ignored-headers.
614   (when yank
615     (gnus-summary-goto-subject (car yank)))
616   (let ((gnus-article-reply t))
617     (gnus-setup-message (if yank 'reply-yank 'reply)
618       (gnus-summary-select-article)
619       (set-buffer (gnus-copy-article-buffer))
620       (gnus-msg-treat-broken-reply-to)
621       (message-reply nil wide)
622       (when yank
623         (gnus-inews-yank-articles yank)))))
624
625 (defun gnus-summary-reply-with-original (n &optional wide)
626   "Start composing a reply mail to the current message.
627 The original article will be yanked."
628   (interactive "P")
629   (gnus-summary-reply (gnus-summary-work-articles n) wide))
630
631 (defun gnus-summary-wide-reply (&optional yank)
632   "Start composing a wide reply mail to the current message.
633 If prefix argument YANK is non-nil, the original article is yanked
634 automatically."
635   (interactive
636    (list (and current-prefix-arg
637               (gnus-summary-work-articles 1))))
638   (gnus-summary-reply yank t))
639
640 (defun gnus-summary-wide-reply-with-original (n)
641   "Start composing a wide reply mail to the current message.
642 The original article will be yanked."
643   (interactive "P")
644   (gnus-summary-reply-with-original n t))
645
646 (defun gnus-summary-mail-forward (&optional not-used post)
647   "Forward the current message to another user.
648 If POST, post instead of mail."
649   (interactive "P")
650   (gnus-setup-message 'forward
651     (gnus-summary-select-article)
652     (let (text)
653       (save-excursion
654         (set-buffer gnus-original-article-buffer)
655         (setq text (buffer-string)))
656       (set-buffer (gnus-get-buffer-create
657                    (generate-new-buffer-name " *Gnus forward*")))
658       (erase-buffer)
659       (insert text)
660       (goto-char (point-min))
661       (when (looking-at "From ")
662         (replace-match "X-From-Line: ") )
663       (run-hooks 'gnus-article-decode-hook)
664       (message-forward post))))
665
666 (defun gnus-summary-resend-message (address n)
667   "Resend the current article to ADDRESS."
668   (interactive "sResend message(s) to: \nP")
669   (let ((articles (gnus-summary-work-articles n))
670         article)
671     (while (setq article (pop articles))
672       (gnus-summary-select-article nil nil nil article)
673       (save-excursion
674         (set-buffer gnus-original-article-buffer)
675         (message-resend address)))))
676
677 (defun gnus-summary-post-forward (&optional full-headers)
678   "Forward the current article to a newsgroup.
679 If FULL-HEADERS (the prefix), include full headers when forwarding."
680   (interactive "P")
681   (gnus-summary-mail-forward full-headers t))
682
683 (defvar gnus-nastygram-message
684   "The following article was inappropriately posted to %s.\n\n"
685   "Format string to insert in nastygrams.
686 The current group name will be inserted at \"%s\".")
687
688 (defun gnus-summary-mail-nastygram (n)
689   "Send a nastygram to the author of the current article."
690   (interactive "P")
691   (when (or gnus-expert-user
692             (gnus-y-or-n-p
693              "Really send a nastygram to the author of the current article? "))
694     (let ((group gnus-newsgroup-name))
695       (gnus-summary-reply-with-original n)
696       (set-buffer gnus-message-buffer)
697       (message-goto-body)
698       (insert (format gnus-nastygram-message group))
699       (message-send-and-exit))))
700
701 (defun gnus-summary-mail-crosspost-complaint (n)
702   "Send a complaint about crossposting to the current article(s)."
703   (interactive "P")
704   (let ((articles (gnus-summary-work-articles n))
705         article)
706     (while (setq article (pop articles))
707       (set-buffer gnus-summary-buffer)