*** empty log message ***
[gnus] / lisp / gnus-msg.el
index f76041d..2f9afb4 100644 (file)
 
 ;;; Code:
 
-(require 'gnus)
-(require 'sendmail)
+(require 'gnus-load)
 (require 'gnus-ems)
 (require 'message)
-(eval-when-compile (require 'cl))
+(require 'gnus-art)
+(require 'gnus)
 
 ;; Added by Sudish Joseph <joseph@cis.ohio-state.edu>.
 (defvar gnus-post-method nil
@@ -48,7 +48,7 @@ posting.")
 (defvar gnus-outgoing-message-group nil
   "*All outgoing messages will be put in this group.
 If you want to store all your outgoing mail and articles in the group
-\"nnml:archive\", you set this variable to that value. This variable
+\"nnml:archive\", you set this variable to that value.  This variable
 can also be a list of group names. 
 
 If you want to have greater control over what group to put each
@@ -56,14 +56,6 @@ message in, you can set this variable to a function that checks the
 current newsgroup name and then returns a suitable group name (or list
 of names).")
 
-(defvar gnus-message-archive-group
-  '((if (message-news-p) "misc-news" "misc-mail"))
-  "*Name of the group in which to save the messages you've written.
-This can either be a string, a list of strings; or an alist
-of regexps/functions/forms to be evaluated to return a string (or a list
-of strings).  The functions are called with the name of the current
-group (or nil) as a parameter.")
-
 (defvar gnus-mailing-list-groups nil
   "*Regexp matching groups that are really mailing lists.
 This is useful when you're reading a mailing list that has been
@@ -71,19 +63,56 @@ gatewayed to a newsgroup, and you want to followup to an article in
 the group.")
 
 (defvar gnus-sent-message-ids-file 
-  (concat (file-name-as-directory gnus-article-save-directory)
-         "Sent-Message-IDs")
+  (nnheader-concat gnus-directory "Sent-Message-IDs")
   "File where Gnus saves a cache of sent message ids.")
 
 (defvar gnus-sent-message-ids-length 1000
   "The number of sent Message-IDs to save.")
 
+(defvar gnus-crosspost-complaint
+  "Hi,
+
+You posted the article below with the following Newsgroups header:
+
+Newsgroups: %s
+
+The %s group, at least, was an inappropriate recipient
+of this message.  Please trim your Newsgroups header to exclude this
+group before posting in the future.
+
+Thank you.
+
+"
+  "Format string to be inserted when complaining about crossposts.
+The first %s will be replaced by the Newsgroups header;
+the second with the current group name.")
+
 ;;; Internal variables.
 
 (defvar gnus-message-buffer "*Mail Gnus*")
 (defvar gnus-article-copy nil)
 (defvar gnus-last-posting-server nil)
 
+(defconst gnus-bug-message
+  "Sending a bug report to the Gnus Towers.
+========================================
+
+The buffer below is a mail buffer.  When you press `C-c C-c', it will
+be sent to the Gnus Bug Exterminators.
+
+At the bottom of the buffer you'll see lots of variable settings.
+Please do not delete those.  They will tell the Bug People what your
+environment is, so that it will be easier to locate the bugs.
+
+If you have found a bug that makes Emacs go \"beep\", set
+debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
+and include the backtrace in your bug report.
+
+Please describe the bug in annoying, painstaking detail.
+
+Thank you for your help in stamping out bugs.
+")
+
 (eval-and-compile
   (autoload 'gnus-uu-post-news "gnus-uu" nil t)
   (autoload 'news-setup "rnewspost")
@@ -96,27 +125,26 @@ the group.")
 ;;; Gnus Posting Functions
 ;;;
 
-(gnus-define-keys 
- (gnus-summary-send-map "S" gnus-summary-mode-map)
- "p" gnus-summary-post-news
- "f" gnus-summary-followup
- "F" gnus-summary-followup-with-original
- "c" gnus-summary-cancel-article
- "s" gnus-summary-supersede-article
- "r" gnus-summary-reply
- "R" gnus-summary-reply-with-original
- "m" gnus-summary-mail-other-window
- "u" gnus-uu-post-news
- "om" gnus-summary-mail-forward
- "op" gnus-summary-post-forward
- "Om" gnus-uu-digest-mail-forward
- "Op" gnus-uu-digest-post-forward)
-
-(gnus-define-keys
- (gnus-send-bounce-map "D" gnus-summary-send-map)
- "b" gnus-summary-resend-bounced-mail
- "c" gnus-summary-send-draft
- "r" gnus-summary-resend-message)
+(gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
+  "p" gnus-summary-post-news
+  "f" gnus-summary-followup
+  "F" gnus-summary-followup-with-original
+  "c" gnus-summary-cancel-article
+  "s" gnus-summary-supersede-article
+  "r" gnus-summary-reply
+  "R" gnus-summary-reply-with-original
+  "m" gnus-summary-mail-other-window
+  "u" gnus-uu-post-news
+  "\M-c" gnus-summary-mail-crosspost-complaint
+  "om" gnus-summary-mail-forward
+  "op" gnus-summary-post-forward
+  "Om" gnus-uu-digest-mail-forward
+  "Op" gnus-uu-digest-post-forward)
+
+(gnus-define-keys (gnus-send-bounce-map "D" gnus-summary-send-map)
+  "b" gnus-summary-resend-bounced-mail
+  ;; "c" gnus-summary-send-draft
+  "r" gnus-summary-resend-message)
 
 ;;; Internal functions.
 
@@ -128,32 +156,36 @@ the group.")
     `(let ((,winconf (current-window-configuration))
           (,buffer (current-buffer))
           (,article (and gnus-article-reply (gnus-summary-article-number)))
-          message-header-setup-hook)
+          (message-header-setup-hook
+           (copy-sequence message-header-setup-hook)))
        (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
        (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
        ,@forms
        (gnus-inews-add-send-actions ,winconf ,buffer ,article)
        (setq gnus-message-buffer (current-buffer))
+       (make-local-variable 'gnus-newsgroup-name)
        (gnus-configure-windows ,config t))))
     
 (defun gnus-inews-add-send-actions (winconf buffer article)
-  (make-local-hook 'message-sent-hook)
-  (add-hook 'message-sent-hook 'gnus-inews-do-gcc)
+  (gnus-make-local-hook 'message-sent-hook)
+  (gnus-add-hook 'message-sent-hook 'gnus-inews-do-gcc nil t)
   (setq message-post-method
        `(lambda (arg)
           (gnus-post-method arg ,gnus-newsgroup-name)))
   (setq message-newsreader (setq message-mailer (gnus-extended-version)))
-  (let ((actions
-        `((set-window-configuration ,winconf)
-          ((lambda ()
-             (when (buffer-name ,buffer)
-               (set-buffer ,buffer)
-               ,(when article
-                  `(gnus-summary-mark-article-as-replied ,article))))))))
-    (setq message-send-actions (append message-send-actions actions))))
+  (message-add-action
+   `(set-window-configuration ,winconf) 'exit 'postpone 'kill)
+  (message-add-action
+   `(when (buffer-name ,buffer)
+      (save-excursion
+       (set-buffer ,buffer)
+       ,(when article
+          `(gnus-summary-mark-article-as-replied ,article))))
+   'send))
 
 (put 'gnus-setup-message 'lisp-indent-function 1)
 (put 'gnus-setup-message 'lisp-indent-hook 1)
+(put 'gnus-setup-message 'edebug-form-spec '(form body))
 
 ;;; Post news commands of Gnus group mode and summary mode
 
@@ -164,27 +196,23 @@ the group.")
     (message-mail)))
 
 (defun gnus-group-post-news (&optional arg)
-  "Post an article.
-The newsgroup under the cursor is used as the group to post to.
-
-If you wish to get an empty post buffer, use a prefix ARG.  You can
-also do this by calling this function from the bottom of the Group
-buffer."
+  "Start composing a news message.
+If ARG, post to the group under point.
+If ARG is 1, prompt for a group name."
   (interactive "P")
-  (gnus-setup-message 'message
-    (let ((gnus-newsgroup-name nil)
-         (group (unless arg (gnus-group-group-name))))
-      ;; We might want to prompt here.
-      (when (and gnus-interactive-post
-                (not gnus-expert-user))
-       (setq gnus-newsgroup-name
-             (setq group 
-                   (completing-read "Group: " gnus-active-hashtb nil nil
-                                    (cons (or group "") 0)))))
-      (gnus-post-news 'post group))))
+  ;; Bind this variable here to make message mode hooks
+  ;; work ok.
+  (let ((gnus-newsgroup-name
+        (if arg
+            (if (= 1 (prefix-numeric-value arg))
+                (completing-read "Newsgroup: " gnus-active-hashtb nil
+                                 (gnus-read-active-file-p))
+              (gnus-group-group-name))
+          "")))
+    (gnus-post-news 'post gnus-newsgroup-name)))
 
 (defun gnus-summary-post-news ()
-  "Post an article."
+  "Start composing a news message."
   (interactive)
   (gnus-set-global-variables)
   (gnus-post-news 'post gnus-newsgroup-name))
@@ -220,12 +248,13 @@ If prefix argument YANK is non-nil, original article is yanked automatically."
        (gnus-summary-select-article nil nil nil article)
        (gnus-summary-remove-process-mark article))
       (gnus-copy-article-buffer)
+      (message-goto-body)      
       (let ((message-reply-buffer gnus-article-copy)
            (message-reply-headers gnus-current-headers))
        (message-yank-original)
        (setq beg (or beg (mark t))))
       (when articles (insert "\n")))
-    (set-marker (mark-marker) (point))
+    (push-mark)
     (goto-char beg)))
 
 (defun gnus-summary-cancel-article (n)
@@ -233,12 +262,16 @@ If prefix argument YANK is non-nil, original article is yanked automatically."
   (interactive "P")
   (gnus-set-global-variables)
   (let ((articles (gnus-summary-work-articles n))
+       (message-post-method
+        `(lambda (arg)
+           (gnus-post-method nil ,gnus-newsgroup-name)))
        article)
     (while (setq article (pop articles))
       (when (gnus-summary-select-article t nil nil article)
-       (when (gnus-eval-in-buffer-window 
-              gnus-original-article-buffer (message-cancel-news))
-         (gnus-summary-mark-as-read article gnus-canceled-mark))
+       (when (gnus-eval-in-buffer-window gnus-original-article-buffer
+               (message-cancel-news))
+         (gnus-summary-mark-as-read article gnus-canceled-mark)
+         (gnus-cache-remove-article 1))
        (gnus-article-hide-headers-if-wanted))
       (gnus-summary-remove-process-mark article))))
 
@@ -248,10 +281,15 @@ This is done simply by taking the old article and adding a Supersedes
 header line with the old Message-ID."
   (interactive)
   (gnus-set-global-variables)
-  (gnus-setup-message 'reply-yank
-    (gnus-summary-select-article t)
-    (set-buffer gnus-original-article-buffer)
-    (message-supersede)))
+  (let ((article (gnus-summary-article-number)))
+    (gnus-setup-message 'reply-yank
+      (gnus-summary-select-article t)
+      (set-buffer gnus-original-article-buffer)
+      (message-supersede)
+      (push
+       `((lambda ()
+          (gnus-cache-possibly-remove-article ,article nil nil nil t)))
+       message-send-actions))))
 
 \f
 
@@ -264,16 +302,38 @@ header line with the old Message-ID."
   (buffer-disable-undo gnus-article-copy)
   (or (memq gnus-article-copy gnus-buffer-list)
       (setq gnus-buffer-list (cons gnus-article-copy gnus-buffer-list)))
-  (let ((article-buffer (or article-buffer gnus-article-buffer)))
-    (if (and (get-buffer article-buffer)
-            (buffer-name (get-buffer article-buffer)))
-       (save-excursion
-         (set-buffer article-buffer)
+  (let ((article-buffer (or article-buffer gnus-article-buffer))
+       end beg contents)
+    (when (and (get-buffer article-buffer)
+              (buffer-name (get-buffer article-buffer)))
+      (save-excursion
+       (set-buffer article-buffer)
+       (save-restriction
+         ;; Copy over the (displayed) article buffer, delete
+         ;; hidden text and remove text properties.
          (widen)
          (copy-to-buffer gnus-article-copy (point-min) (point-max))
-         (gnus-set-text-properties (point-min) (point-max) 
-                                   nil gnus-article-copy)))
-    gnus-article-copy))
+         (set-buffer gnus-article-copy)
+         (article-delete-text-of-type 'annotation)
+         (insert
+          (prog1
+              (format "%s" (buffer-string))
+            (erase-buffer)))
+         ;; Find the original headers.
+         (set-buffer gnus-original-article-buffer)
+         (goto-char (point-min))
+         (while (looking-at message-unix-mail-delimiter)
+           (forward-line 1))
+         (setq beg (point))
+         (setq end (or (search-forward "\n\n" nil t) (point)))
+         ;; Delete the headers from the displayed articles.
+         (set-buffer gnus-article-copy)
+         (delete-region (goto-char (point-min))
+                        (or (search-forward "\n\n" nil t) (point)))
+         ;; Insert the original article headers.
+         (insert-buffer-substring gnus-original-article-buffer beg end)
+         (article-decode-rfc1522)))
+      gnus-article-copy)))
 
 (defun gnus-post-news (post &optional group header article-buffer yank subject
                            force-news)
@@ -287,9 +347,9 @@ header line with the old Message-ID."
             (pgroup group)
             to-address to-group mailing-list to-list)
        (when group
-         (setq to-address (gnus-group-get-parameter group 'to-address)
-               to-group (gnus-group-get-parameter group 'to-group)
-               to-list (gnus-group-get-parameter group 'to-list)
+         (setq to-address (gnus-group-find-parameter group 'to-address)
+               to-group (gnus-group-find-parameter group 'to-group)
+               to-list (gnus-group-find-parameter group 'to-list)
                mailing-list (when gnus-mailing-list-groups
                               (string-match gnus-mailing-list-groups group))
                group (gnus-group-real-name group)))
@@ -307,7 +367,7 @@ header line with the old Message-ID."
            (if post
                (message-news (or to-group group))
              (set-buffer gnus-article-copy)
-             (message-followup))
+             (message-followup to-group))
          ;; The is mail.
          (if post
              (progn
@@ -328,7 +388,7 @@ If SILENT, don't prompt the user."
     (cond 
      ;; If the group-method is nil (which shouldn't happen) we use 
      ;; the default method.
-     ((null arg)
+     ((null group-method)
       (or gnus-post-method gnus-select-method message-post-method))
      ;; We want this group's method.
      ((and arg (not (eq arg 0)))
@@ -343,7 +403,7 @@ If SILENT, don't prompt the user."
               (when gnus-post-method
                 (if (listp (car gnus-post-method))
                     gnus-post-method
-                  (listp gnus-post-method)))
+                  (list gnus-post-method)))
               gnus-secondary-select-methods
               (list gnus-select-method)
               (list group-method)))
@@ -373,23 +433,11 @@ If SILENT, don't prompt the user."
                   (cons (or gnus-last-posting-server "") 0))))
          method-alist))))
      ;; Override normal method.
-     ((and gnus-post-method
-          (or (gnus-method-option-p group-method 'post)
-              (gnus-method-option-p group-method 'post-mail)))
+     (gnus-post-method
       gnus-post-method)
-     ;; Perhaps this is a mail group?
-     ((and (not (gnus-member-of-valid 'post group))
-          (not (gnus-method-option-p group-method 'post-mail)))
-      group-method)
      ;; Use the normal select method.
      (t gnus-select-method))))
 
-(defun gnus-news-group-p (group &optional article)
-  "Return non-nil if GROUP (and ARTICLE) come from a news server."
-  (or (gnus-member-of-valid 'post group) ; Ordinary news group.
-      (and (gnus-member-of-valid 'post-mail group) ; Combined group.
-          (eq (gnus-request-type group article) 'news))))
-
 (defun gnus-inews-narrow-to-headers ()
   (widen)
   (narrow-to-region
@@ -428,8 +476,7 @@ If SILENT, don't prompt the user."
                                  gnus-inews-sent-ids))
            (setcdr end nil))
          (nnheader-temp-write gnus-sent-message-ids-file
-           (prin1 `(setq gnus-inews-sent-ids ',gnus-inews-sent-ids)
-                  (current-buffer)))
+           (gnus-prin1 `(setq gnus-inews-sent-ids ',gnus-inews-sent-ids)))
          nil)))))
 
 \f
@@ -458,7 +505,7 @@ If SILENT, don't prompt the user."
             (format " %d.%d" emacs-major-version emacs-minor-version)))
     (t emacs-version))))
 
-;; Written by "Mr. Per Persson" <pp@solace.mh.se>.
+;; Written by "Mr. Per Persson" <pp@gnu.ai.mit.edu>.
 (defun gnus-inews-insert-mime-headers ()
   (goto-char (point-min))
   (let ((mail-header-separator 
@@ -506,13 +553,13 @@ If prefix argument YANK is non-nil, original article is yanked automatically."
     (gnus-setup-message (if yank 'reply-yank 'reply)
       (gnus-summary-select-article)
       (set-buffer (gnus-copy-article-buffer))
-      (message-reply)
+      (message-reply nil nil (gnus-group-find-parameter
+                             gnus-newsgroup-name 'broken-reply-to))
       (when yank
        (gnus-inews-yank-articles yank)))))
 
 (defun gnus-summary-reply-with-original (n)
-  "Reply mail to news author with original article.
-Customize the variable gnus-mail-reply-method to use another mailer."
+  "Reply mail to news author with original article."
   (interactive "P")
   (gnus-summary-reply (gnus-summary-work-articles n)))
 
@@ -539,7 +586,7 @@ Customize the variable gnus-mail-reply-method to use another mailer."
   (gnus-summary-mail-forward t))
 
 (defvar gnus-nastygram-message 
-  "The following article was inappropriately posted to %s.\n"
+  "The following article was inappropriately posted to %s.\n\n"
   "Format string to insert in nastygrams.
 The current group name will be inserted at \"%s\".")
 
@@ -552,14 +599,45 @@ The current group name will be inserted at \"%s\".")
       (let ((group gnus-newsgroup-name))
        (gnus-summary-reply-with-original n)
        (set-buffer gnus-message-buffer)
+       (message-goto-body)
        (insert (format gnus-nastygram-message group))
        (message-send-and-exit))))
 
+(defun gnus-summary-mail-crosspost-complaint (n)
+  "Send a complaint about crossposting to the current article(s)."
+  (interactive "P")
+  (let ((articles (gnus-summary-work-articles n))
+       article)
+    (while (setq article (pop articles))
+      (set-buffer gnus-summary-buffer)
+      (gnus-summary-goto-subject article)
+      (let ((group (gnus-group-real-name gnus-newsgroup-name))
+           newsgroups followup-to)
+       (gnus-summary-select-article)
+       (set-buffer gnus-original-article-buffer)
+       (if (and (<= (length (message-tokenize-header
+                             (setq newsgroups (mail-fetch-field "newsgroups"))
+                             ", "))
+                    1)
+                (or (not (setq followup-to (mail-fetch-field "followup-to")))
+                    (not (member group (message-tokenize-header
+                                        followup-to ", ")))))
+           (if followup-to
+               (gnus-message 1 "Followup-to restricted")
+             (gnus-message 1 "Not a crossposted article"))
+         (set-buffer gnus-summary-buffer)
+         (gnus-summary-reply-with-original 1)
+         (set-buffer gnus-message-buffer)
+         (message-goto-body)
+         (insert (format gnus-crosspost-complaint newsgroups group))
+         (when (gnus-y-or-n-p "Send this complaint? ")
+           (message-send-and-exit)))))))
+
 (defun gnus-summary-mail-other-window ()
   "Compose mail in other window."
   (interactive)
-  (gnus-set-global-variables)
-  (message-mail))
+  (gnus-setup-message 'message
+    (message-mail)))
 
 (defun gnus-mail-parse-comma-list ()
   (let (accumulated
@@ -648,28 +726,25 @@ If YANK is non-nil, include the original article."
         (buffer-substring
          (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
          (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
-    (and address
-        (progn
-          (switch-to-buffer gnus-summary-buffer)
-          (gnus-mail-reply yank address)))))
+    (when address
+      (message-reply address)
+      (when yank
+       (gnus-inews-yank-articles (list (cdr gnus-article-current)))))))
 
 (defun gnus-bug ()
   "Send a bug report to the Gnus maintainers."
   (interactive)
-  (let ((winconf (current-window-configuration)))
+  (unless (gnus-alive-p)
+    (error "Gnus has been shut down"))
+  (gnus-setup-message 'bug
     (delete-other-windows)
     (switch-to-buffer "*Gnus Help Bug*")
     (erase-buffer)
     (insert gnus-bug-message)
     (goto-char (point-min))
-    (pop-to-buffer "*Gnus Bug*")
-    (erase-buffer)
-    (mail-mode)
-    (mail-setup gnus-maintainer nil nil nil nil nil)
-    (auto-save-mode auto-save-default)
-    (make-local-variable 'gnus-prev-winconf)
-    (setq gnus-prev-winconf winconf)
-    (local-set-key "\C-c\C-c" 'gnus-bug-mail-send-and-exit)
+    (message-pop-to-buffer "*Gnus Bug*")
+    (message-setup `((To . ,gnus-maintainer) (Subject . "")))
+    (push `(gnus-bug-kill-buffer) message-send-actions)
     (goto-char (point-min))
     (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
     (forward-line 1)
@@ -681,55 +756,44 @@ If YANK is non-nil, include the original article."
     (search-forward "Subject: " nil t)
     (message "")))
 
-(defun gnus-bug-mail-send-and-exit ()
-  "Send the bug message and exit."
-  (interactive)
-  (let ((cur (current-buffer)))
-    (and (get-buffer "*Gnus Help Bug*")
-        (kill-buffer "*Gnus Help Bug*"))
-    (message-send-and-exit)
-    (when (buffer-name cur)
-      (kill-buffer cur))))
+(defun gnus-bug-kill-buffer ()
+  (and (get-buffer "*Gnus Help Bug*")
+       (kill-buffer "*Gnus Help Bug*")))
 
 (defun gnus-debug ()
-  "Attemps to go through the Gnus source file and report what variables have been changed.
+  "Attempts to go through the Gnus source file and report what variables have been changed.
 The source file has to be in the Emacs load path."
   (interactive)
-  (let ((files '("gnus.el" "gnus-msg.el" "gnus-score.el" "nnmail.el"))
-       file dirs expr olist sym)
-    (message "Please wait while we snoop your variables...")
+  (let ((files '("gnus-load.el" "gnus-sum.el" "gnus-group.el"
+                "gnus-art.el" "gnus-start.el"
+                "gnus-msg.el" "gnus-score.el" "gnus-win.el"
+                "nnmail.el" "message.el"))
+       file expr olist sym)
+    (gnus-message 4 "Please wait while we snoop your variables...")
     (sit-for 0)
+    ;; Go through all the files looking for non-default values for variables.
     (save-excursion
       (set-buffer (get-buffer-create " *gnus bug info*"))
       (buffer-disable-undo (current-buffer))
       (while files
        (erase-buffer)
-       (setq dirs load-path)
-       (while dirs
-         (if (or (not (car dirs))
-                 (not (stringp (car dirs)))
-                 (not (file-exists-p 
-                       (setq file (concat (file-name-as-directory 
-                                           (car dirs)) (car files))))))
-             (setq dirs (cdr dirs))
-           (setq dirs nil)
-           (insert-file-contents file)
+       (when (file-exists-p (setq file (locate-library (pop files))))
+         (insert-file-contents file)
+         (goto-char (point-min))
+         (if (not (re-search-forward "^;;* *Internal variables" nil t))
+             (gnus-message 4 "Malformed sources in file %s" file)
+           (narrow-to-region (point-min) (point))
            (goto-char (point-min))
-           (if (not (re-search-forward "^;;* *Internal variables" nil t))
-               (message "Malformed sources in file %s" file)
-             (narrow-to-region (point-min) (point))
-             (goto-char (point-min))
-             (while (setq expr (condition-case () 
-                                   (read (current-buffer)) (error nil)))
-               (condition-case ()
-                   (and (eq (car expr) 'defvar)
-                        (stringp (nth 3 expr))
-                        (or (not (boundp (nth 1 expr)))
-                            (not (equal (eval (nth 2 expr))
-                                        (symbol-value (nth 1 expr)))))
-                        (setq olist (cons (nth 1 expr) olist)))
-                 (error nil))))))
-       (setq files (cdr files)))
+           (while (setq expr (condition-case () 
+                                 (read (current-buffer)) (error nil)))
+             (condition-case ()
+                 (and (eq (car expr) 'defvar)
+                      (stringp (nth 3 expr))
+                      (or (not (boundp (nth 1 expr)))
+                          (not (equal (eval (nth 2 expr))
+                                      (symbol-value (nth 1 expr)))))
+                      (push (nth 1 expr) olist))
+               (error nil))))))
       (kill-buffer (current-buffer)))
     (when (setq olist (nreverse olist))
       (insert "------------------ Environment follows ------------------\n\n"))
@@ -750,7 +814,7 @@ The source file has to be in the Emacs load path."
       (setq olist (cdr olist)))
     (insert "\n\n")
     ;; Remove any null chars - they seem to cause trouble for some
-    ;; mailers. (Byte-compiled output from the stuff above.) 
+    ;; mailers.  (Byte-compiled output from the stuff above.) 
     (goto-char (point-min))
     (while (re-search-forward "[\000\200]" nil t)
       (replace-match "" t t))))
@@ -781,42 +845,50 @@ this is a reply."
 
 ;; Do Gcc handling, which copied the message over to some group. 
 (defun gnus-inews-do-gcc (&optional gcc)
-  (save-excursion
-    (save-restriction
-      (nnheader-narrow-to-headers)
-      (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
-           (cur (current-buffer))
-           groups group method)
-       (when gcc
-         (message-remove-header "gcc")
-         (widen)
-         (setq groups (message-tokenize-header gcc " ,"))
-         ;; Copy the article over to some group(s).
-         (while (setq group (pop groups))
-           (gnus-check-server 
-            (setq method
-                  (cond ((and (null (gnus-get-info group))
-                              (eq (car gnus-message-archive-method)
-                                  (car 
-                                   (gnus-server-to-method
-                                    (gnus-group-method group)))))
-                         ;; If the group doesn't exist, we assume
-                         ;; it's an archive group...
-                         gnus-message-archive-method)
-                        (t (gnus-group-method group)))))
-           (unless (gnus-request-group group t method)
-             (gnus-request-create-group group method))
-           (gnus-check-server method)
-           (save-excursion
-             (nnheader-set-temp-buffer " *acc*")
-             (insert-buffer-substring cur)
-             (unless (condition-case ()
-                         (gnus-request-accept-article group t method)
-                       (error nil))
-               (gnus-message 1 "Couldn't store article in group %s: %s" 
-                             group (gnus-status-message method))
-               (sit-for 2))
-             (kill-buffer (current-buffer)))))))))
+  (when (gnus-alive-p)
+    (save-excursion
+      (save-restriction
+       (message-narrow-to-headers)
+       (let ((gcc (or gcc (mail-fetch-field "gcc" nil t)))
+             (cur (current-buffer))
+             groups group method)
+         (when gcc
+           (message-remove-header "gcc")
+           (widen)
+           (setq groups (message-tokenize-header gcc " ,"))
+           ;; Copy the article over to some group(s).
+           (while (setq group (pop groups))
+             (gnus-check-server 
+              (setq method
+                    (cond ((and (null (gnus-get-info group))
+                                (eq (car gnus-message-archive-method)
+                                    (car 
+                                     (gnus-server-to-method
+                                      (gnus-group-method group)))))
+                           ;; If the group doesn't exist, we assume
+                           ;; it's an archive group...
+                           gnus-message-archive-method)
+                          ;; Use the method.
+                          ((gnus-info-method (gnus-get-info group))
+                           (gnus-info-method (gnus-get-info group)))
+                          ;; Find the method.
+                          (t (gnus-group-method group)))))
+             (gnus-check-server method)
+             (unless (gnus-request-group group t method)
+               (gnus-request-create-group group method))
+             (save-excursion
+               (nnheader-set-temp-buffer " *acc*")
+               (insert-buffer-substring cur)
+               (goto-char (point-min))
+               (when (re-search-forward 
+                      (concat "^" (regexp-quote mail-header-separator) "$")
+                      nil t)
+                 (replace-match "" t t ))
+               (unless (gnus-request-accept-article group method t)
+                 (gnus-message 1 "Couldn't store article in group %s: %s" 
+                               group (gnus-status-message method))
+                 (sit-for 2))
+               (kill-buffer (current-buffer))))))))))
 
 (defun gnus-inews-insert-gcc ()
   "Insert Gcc headers based on `gnus-outgoing-message-group'."
@@ -840,6 +912,7 @@ this is a reply."
   (let* ((var gnus-message-archive-group)
         (group (or group gnus-newsgroup-name ""))
         result
+        gcc-self-val
         (groups
          (cond 
           ((null gnus-message-archive-method)
@@ -873,7 +946,8 @@ this is a reply."
                                (t
                                 (eval (car var)))))))
              (setq var (cdr var)))
-           result))))
+           result)))
+        name)
     (when groups
       (when (stringp groups)
        (setq groups (list groups)))
@@ -882,11 +956,27 @@ this is a reply."
          (gnus-inews-narrow-to-headers)
          (goto-char (point-max))
          (insert "Gcc: ")
-         (while groups
-           (insert (gnus-group-prefixed-name 
-                    (pop groups) gnus-message-archive-method))
-           (insert " "))
-         (insert "\n"))))))
+         (if (and gnus-newsgroup-name
+                  (setq gcc-self-val
+                        (gnus-group-find-parameter
+                         gnus-newsgroup-name 'gcc-self)))
+             (progn 
+               (insert
+                (if (stringp gcc-self-val)
+                    gcc-self-val
+                  group))
+               (if (not (eq gcc-self-val 'none))
+                   (insert "\n")
+                 (progn
+                   (beginning-of-line)
+                   (kill-line))))
+           (while (setq name (pop groups))
+             (insert (if (string-match ":" name)
+                         name
+                       (gnus-group-prefixed-name 
+                        name gnus-message-archive-method)))
+             (if groups (insert " ")))
+           (insert "\n")))))))
 
 (defun gnus-summary-send-draft ()
   "Enter a mail/post buffer to edit and send the draft."