Make message-options buffer-local only under GNU Emacs.
[gnus] / lisp / message.el
index 1111d2c..a6e007a 100644 (file)
@@ -1858,6 +1858,12 @@ You must have the \"hashcash\" binary installed, see `hashcash-path'."
 
 (defvar        message-options nil
   "Some saved answers when sending message.")
+;; FIXME: On XEmacs this causes problems since let-binding like:
+;; (let ((message-options message-options)) ...)
+;; as in `message-send' and `mml-preview' loses to buffer-local
+;; variable initialization.
+(unless (featurep 'xemacs)
+  (make-variable-buffer-local 'message-options))
 
 (defvar message-send-mail-real-function nil
   "Internal send mail function.")
@@ -2819,7 +2825,7 @@ message composition doesn't break too bad."
   :link '(custom-manual "(message)Various Message Variables")
   :type 'boolean)
 
-(defconst message-forbidden-properties
+(defvar message-forbidden-properties
   ;; No reason this should be clutter up customize.  We make it a
   ;; property list (rather than a list of property symbols), to be
   ;; directly useful for `remove-text-properties'.
@@ -4054,11 +4060,11 @@ Instead, just auto-save the buffer and then bury it."
 
 (defun message-bury (buffer)
   "Bury this mail BUFFER."
-  (let ((newbuf (other-buffer buffer)))
-    (bury-buffer buffer)
-    (if message-return-action
-       (apply (car message-return-action) (cdr message-return-action))
-      (switch-to-buffer newbuf))))
+  (if message-return-action
+      (progn
+        (bury-buffer buffer)
+        (apply (car message-return-action) (cdr message-return-action)))
+    (with-current-buffer buffer (bury-buffer))))
 
 (defun message-send (&optional arg)
   "Send the message in the current buffer.
@@ -6455,14 +6461,15 @@ are not included."
          (funcall message-default-headers)
        message-default-headers))
     (or (bolp) (insert ?\n)))
-  (insert (propertize (concat mail-header-separator "\n")
-                     'read-only t 'rear-nonsticky t 'intangible t))
+  (insert (concat mail-header-separator "\n"))
   (forward-line -1)
   ;; If a crash happens while replying, the auto-save file would *not* have a
   ;; `References:' header if `message-generate-headers-first' was nil.
   ;; Therefore, always generate it first.
   (let ((message-generate-headers-first
-         (append message-generate-headers-first '(References))))
+         (if (eq message-generate-headers-first t)
+             t
+           (append message-generate-headers-first '(References)))))
     (when (message-news-p)
       (when message-default-news-headers
         (insert message-default-news-headers)
@@ -6821,7 +6828,7 @@ Useful functions to put in this list include:
   subject)
 
 ;;;###autoload
-(defun message-reply (&optional to-address wide)
+(defun message-reply (&optional to-address wide switch-function)
   "Start editing a reply to the article in the current buffer."
   (interactive)
   (require 'gnus-sum)                  ; for gnus-list-identifiers
@@ -6864,7 +6871,8 @@ Useful functions to put in this list include:
       (message-pop-to-buffer
        (message-buffer-name
        (if wide "wide reply" "reply") from
-       (if wide to-address nil))))
+       (if wide to-address nil))
+       switch-function))
 
     (setq message-reply-headers
          (vector 0 subject from date message-id references 0 0 ""))
@@ -7483,7 +7491,8 @@ is for the internal use."
       ;; We first set up a normal mail buffer.
       (unless (message-mail-user-agent)
        (set-buffer (get-buffer-create " *message resend*"))
-       (erase-buffer))
+       (let ((inhibit-read-only t))
+         (erase-buffer)))
       (let ((message-this-is-mail t)
            message-generate-hashcash
            message-setup-hook)
@@ -7500,7 +7509,8 @@ is for the internal use."
        (insert "Resent-"))
       (widen)
       (forward-line)
-      (delete-region (point) (point-max))
+      (let ((inhibit-read-only t))
+       (delete-region (point) (point-max)))
       (setq beg (point))
       ;; Insert the message to be resent.
       (insert-buffer-substring cur)