Synch with Oort Gnus.
[elisp/gnus.git-] / lisp / gnus-msg.el
index ab401fe..6bf7aaf 100644 (file)
@@ -106,7 +106,7 @@ the second with the current group name."
   :group 'gnus-message
   :type 'string)
 
-(defcustom gnus-message-setup-hook '(gnus-maybe-setup-default-charset)
+(defcustom gnus-message-setup-hook nil
   "Hook run after setting up a message buffer."
   :group 'gnus-message
   :type 'hook)
@@ -253,6 +253,13 @@ news."
   :group 'gnus-message
   :type 'boolean)
 
+(defcustom gnus-summary-resend-default-address t
+  "If non-nil, Gnus tries to suggest a default address to resend to.
+If nil, the address field will always be empty after invoking
+`gnus-summary-resend-message'."
+  :group 'gnus-message
+  :type 'boolean)
+
 ;;; Internal variables.
 
 (defvar gnus-inhibit-posting-styles nil
@@ -381,6 +388,7 @@ Thank you for your help in stamping out bugs.
         (set (make-local-variable 'gnus-message-group-art)
              (cons ,group ,article))
         (set (make-local-variable 'gnus-newsgroup-name) ,group)
+        (gnus-maybe-setup-default-charset)
         (gnus-run-hooks 'gnus-message-setup-hook))
        (gnus-add-buffer)
        (gnus-configure-windows ,config t)
@@ -498,6 +506,8 @@ If ARG is 1, prompt for a group name to find the posting style."
   ;; We can't `let' gnus-newsgroup-name here, since that leads
   ;; to local variables leaking.
   (let ((group gnus-newsgroup-name)
+       ;; make sure last viewed article doesn't affect posting styles:
+       (gnus-article-copy)
        (buffer (current-buffer)))
     (unwind-protect
        (progn
@@ -527,6 +537,8 @@ network.  The corresponding backend must have a 'request-post method."
   ;; We can't `let' gnus-newsgroup-name here, since that leads
   ;; to local variables leaking.
   (let ((group gnus-newsgroup-name)
+       ;; make sure last viewed article doesn't affect posting styles:
+       (gnus-article-copy)
        (buffer (current-buffer)))
     (unwind-protect
        (progn
@@ -558,7 +570,9 @@ a news."
                 (completing-read "Newsgroup: " gnus-active-hashtb nil
                                  (gnus-read-active-file-p))
               (gnus-group-group-name))
-          "")))
+          ""))
+       ;; make sure last viewed article doesn't affect posting styles:
+       (gnus-article-copy))
     (gnus-post-news 'post gnus-newsgroup-name)))
 
 (defun gnus-summary-mail-other-window (&optional arg)
@@ -570,6 +584,8 @@ posting style."
   ;; We can't `let' gnus-newsgroup-name here, since that leads
   ;; to local variables leaking.
   (let ((group gnus-newsgroup-name)
+       ;; make sure last viewed article doesn't affect posting styles:
+       (gnus-article-copy)
        (buffer (current-buffer)))
     (unwind-protect
        (progn
@@ -599,6 +615,8 @@ network.  The corresponding backend must have a 'request-post method."
   ;; We can't `let' gnus-newsgroup-name here, since that leads
   ;; to local variables leaking.
   (let ((group gnus-newsgroup-name)
+       ;; make sure last viewed article doesn't affect posting styles:
+       (gnus-article-copy)
        (buffer (current-buffer)))
     (unwind-protect
        (progn
@@ -630,7 +648,9 @@ a news."
                 (completing-read "Newsgroup: " gnus-active-hashtb nil
                                  (gnus-read-active-file-p))
               "")
-          gnus-newsgroup-name)))
+          gnus-newsgroup-name))
+       ;; make sure last viewed article doesn't affect posting styles:
+       (gnus-article-copy))
     (gnus-post-news 'post gnus-newsgroup-name)))
 
 
@@ -656,7 +676,8 @@ yanked."
     ;; Send a followup.
     (gnus-post-news nil gnus-newsgroup-name
                    headers gnus-article-buffer
-                   yank nil force-news)))
+                   yank nil force-news)
+    (gnus-summary-handle-replysign)))
 
 (defun gnus-summary-followup-with-original (n &optional force-news)
   "Compose a followup to an article and include the original article."
@@ -705,8 +726,10 @@ yanked."
            (message-reply-headers
             ;; The headers are decoded.
             (with-current-buffer gnus-article-copy
-              (nnheader-fold-continuation-lines)
-              (nnheader-parse-head t))))
+              (save-restriction
+                (nnheader-narrow-to-headers)
+                (ietf-drums-unfold-fws)
+                (nnheader-parse-head t)))))
        (message-yank-original)
        (setq beg (or beg (mark t))))
       (when articles
@@ -760,8 +783,7 @@ post using the current select method."
 This is done simply by taking the old article and adding a Supersedes
 header line with the old Message-ID."
   (interactive)
-  (let ((article (gnus-summary-article-number))
-       (gnus-message-setup-hook '(gnus-maybe-setup-default-charset)))
+  (let ((article (gnus-summary-article-number)))
     (gnus-setup-message 'reply-yank
       (gnus-summary-select-article t)
       (set-buffer gnus-original-article-buffer)
@@ -1135,20 +1157,23 @@ If VERY-WIDE, make a very wide reply."
        (message-reply nil wide)
        (when yank
          (gnus-inews-yank-articles yank))
-;;     (when (or gnus-message-replysign gnus-message-replyencrypt)
-;;       (let (signed encrypted)
-;;         (save-excursion
-;;           (set-buffer gnus-article-buffer)
-;;           (setq signed (memq 'signed gnus-article-wash-types))
-;;           (setq encrypted (memq 'encrypted gnus-article-wash-types)))
-;;         (cond ((and gnus-message-replysign signed)
-;;                (mml-secure-message mml-default-sign-method 'sign))
-;;               ((and gnus-message-replyencrypt encrypted)
-;;                (mml-secure-message mml-default-encrypt-method
-;;                                    (if gnus-message-replysignencrypted
-;;                                        'signencrypt
-;;                                      'encrypt))))))
-       ))))
+       (gnus-summary-handle-replysign)))))
+
+(defun gnus-summary-handle-replysign ()
+  "Check the various replysign variables and take action accordingly."
+  (when nil;;(or gnus-message-replysign gnus-message-replyencrypt)
+    (let (signed encrypted)
+      (save-excursion
+       (set-buffer gnus-article-buffer)
+       (setq signed (memq 'signed gnus-article-wash-types))
+       (setq encrypted (memq 'encrypted gnus-article-wash-types)))
+      (cond ((and gnus-message-replysign signed)
+            (mml-secure-message mml-default-sign-method 'sign))
+           ((and gnus-message-replyencrypt encrypted)
+            (mml-secure-message mml-default-encrypt-method
+                                (if gnus-message-replysignencrypted
+                                    'signencrypt
+                                  'encrypt)))))))
 
 (defun gnus-summary-reply-with-original (n &optional wide)
   "Start composing a reply mail to the current message.
@@ -1288,7 +1313,8 @@ forward those articles instead."
   (interactive
    (list (message-read-from-minibuffer
          "Resend message(s) to: "
-         (when (gnus-buffer-live-p gnus-original-article-buffer)
+         (when (and gnus-summary-resend-default-address
+                    (gnus-buffer-live-p gnus-original-article-buffer))
            ;; If some other article is currently selected, the
            ;; initial-contents is wrong. Whatever, it is just the
            ;; initial-contents.
@@ -1653,15 +1679,14 @@ this is a reply."
   (interactive "P")
   (gnus-summary-select-article t)
   (set-buffer gnus-original-article-buffer)
-  (let ((gnus-message-setup-hook '(gnus-maybe-setup-default-charset)))
-    (gnus-setup-message 'compose-bounce
-      (let* ((references (mail-fetch-field "references"))
-            (parent (and references (gnus-parent-id references))))
-       (message-bounce)
-       ;; If there are references, we fetch the article we answered to.
-       (and fetch parent
-            (gnus-summary-refer-article parent)
-            (gnus-summary-show-all-headers))))))
+  (gnus-setup-message 'compose-bounce
+    (let* ((references (mail-fetch-field "references"))
+          (parent (and references (gnus-parent-id references))))
+      (message-bounce)
+      ;; If there are references, we fetch the article we answered to.
+      (and fetch parent
+          (gnus-summary-refer-article parent)
+          (gnus-summary-show-all-headers)))))
 
 ;;; Gcc handling.