rmail-cease-edit fixes related to "^From " escaping
[bpt/emacs.git] / lisp / mail / rmail.el
index 9fe8f28..c0fb7d1 100644 (file)
@@ -100,6 +100,10 @@ its character representation and its display representation.")
   "The current header display style choice, one of
 'normal (selected headers) or 'full (all headers).")
 
   "The current header display style choice, one of
 'normal (selected headers) or 'full (all headers).")
 
+(defvar rmail-mime-decoded nil
+  "Non-nil if message has been processed by `rmail-show-mime-function'.")
+(put 'rmail-mime-decoded 'permanent-local t) ; for rmail-edit
+
 (defgroup rmail nil
   "Mail reader for Emacs."
   :group 'mail)
 (defgroup rmail nil
   "Mail reader for Emacs."
   :group 'mail)
@@ -663,6 +667,7 @@ Element N specifies the summary line for message N+1.")
 (defvar rmail-last-regexp nil)
 (put 'rmail-last-regexp 'permanent-local t)
 
 (defvar rmail-last-regexp nil)
 (put 'rmail-last-regexp 'permanent-local t)
 
+;; Note that rmail-output-read-file-name modifies this.
 (defcustom rmail-default-file "~/xmail"
   "Default file name for \\[rmail-output]."
   :type 'file
 (defcustom rmail-default-file "~/xmail"
   "Default file name for \\[rmail-output]."
   :type 'file
@@ -2698,6 +2703,27 @@ N defaults to the current message."
   :group 'rmail
   :version "23.1")
 
   :group 'rmail
   :version "23.1")
 
+;; FIXME?
+;; rmail-show-mime-function does not unquote >From lines.  Should it?
+(defcustom rmail-mbox-format 'mboxrd
+  "The mbox format that your system uses.
+There is no way to determine this, so you should set the appropriate value.
+The formats quote lines containing \"From \" differently.
+The choices are:
+  `mboxo' : lines that start with \"From \" quoted as \">From \"
+  `mboxrd': lines that start with \">*From \" quoted with another \">\"
+The `mboxo' format is ambiguous, in that one cannot know whether
+a line starting with \">From \" originally had a \">\" or not.
+
+It is not critical to set this to the correct value; it only affects
+how Rmail displays lines starting with \">*From \" in non-MIME messages.
+
+See also `unrmail-mbox-format'."
+  :type '(choice (const mboxrd)
+                (const mboxro))
+  :version "24.4"
+  :group 'rmail-files)
+
 (defun rmail-show-message-1 (&optional msg)
   "Show message MSG (default: current message) using `rmail-view-buffer'.
 Return text to display in the minibuffer if MSG is out of
 (defun rmail-show-message-1 (&optional msg)
   "Show message MSG (default: current message) using `rmail-view-buffer'.
 Return text to display in the minibuffer if MSG is out of
@@ -2746,6 +2772,7 @@ The current mail message becomes the message displayed."
                 (re-search-forward "mime-version: 1.0" nil t))
            (let ((rmail-buffer mbox-buf)
                  (rmail-view-buffer view-buf))
                 (re-search-forward "mime-version: 1.0" nil t))
            (let ((rmail-buffer mbox-buf)
                  (rmail-view-buffer view-buf))
+             (set (make-local-variable 'rmail-mime-decoded) t)
              (funcall rmail-show-mime-function))
          (setq body-start (search-forward "\n\n" nil t))
          (narrow-to-region beg (point))
              (funcall rmail-show-mime-function))
          (setq body-start (search-forward "\n\n" nil t))
          (narrow-to-region beg (point))
@@ -2790,11 +2817,15 @@ The current mail message becomes the message displayed."
            ;; Prepare the separator (blank line) before the body.
            (goto-char (point-min))
            (insert "\n")
            ;; Prepare the separator (blank line) before the body.
            (goto-char (point-min))
            (insert "\n")
-           ;; Unquote quoted From lines
-           (while (re-search-forward "^>+From " nil t)
-             (beginning-of-line)
-             (delete-char 1)
-             (forward-line))
+           ;; Unquote quoted From lines.
+           (let ((fromline (if (eq 'mboxrd rmail-mbox-format)
+                               "^>+From "
+                             "^>From "))
+                 case-fold-search)
+             (while (re-search-forward fromline nil t)
+               (beginning-of-line)
+               (delete-char 1)
+               (forward-line)))
            (goto-char (point-min)))
          ;; Copy the headers to the front of the message view buffer.
          (rmail-copy-headers beg end)
            (goto-char (point-min)))
          ;; Copy the headers to the front of the message view buffer.
          (rmail-copy-headers beg end)
@@ -3868,6 +3899,7 @@ see the documentation of `rmail-resend'."
          (msgnum rmail-current-message)
          (subject (concat "["
                           (let ((from (or (mail-fetch-field "From")
          (msgnum rmail-current-message)
          (subject (concat "["
                           (let ((from (or (mail-fetch-field "From")
+                                          ;; FIXME - huh?
                                           (mail-fetch-field ">From"))))
                             (if from
                                 (concat (mail-strip-quoted-names from) ": ")
                                           (mail-fetch-field ">From"))))
                             (if from
                                 (concat (mail-strip-quoted-names from) ": ")
@@ -4067,6 +4099,13 @@ The variable `rmail-retry-ignored-headers' is a regular expression
 specifying headers which should not be copied into the new message."
   (interactive)
   (require 'mail-utils)
 specifying headers which should not be copied into the new message."
   (interactive)
   (require 'mail-utils)
+  (if rmail-enable-mime
+      (with-current-buffer rmail-buffer
+       (if (rmail-mime-message-p)
+           (let ((rmail-mime-mbox-buffer rmail-view-buffer)
+                 (rmail-mime-view-buffer rmail-buffer))
+             (rmail-mime-toggle-raw 'raw)))))
+
   (let ((rmail-this-buffer (current-buffer))
        (msgnum rmail-current-message)
        bounce-start bounce-end bounce-indent resending
   (let ((rmail-this-buffer (current-buffer))
        (msgnum rmail-current-message)
        bounce-start bounce-end bounce-indent resending
@@ -4542,7 +4581,7 @@ encoded string (and the same mask) will decode the string."
 ;;; Start of automatically extracted autoloads.
 \f
 ;;;### (autoloads (rmail-edit-current-message) "rmailedit" "rmailedit.el"
 ;;; Start of automatically extracted autoloads.
 \f
 ;;;### (autoloads (rmail-edit-current-message) "rmailedit" "rmailedit.el"
-;;;;;;  "7d558f958574f6003fa474ce2f3c80a8")
+;;;;;;  "78b8b7d5c679935c118d595d473d7c5e")
 ;;; Generated autoloads from rmailedit.el
 
 (autoload 'rmail-edit-current-message "rmailedit" "\
 ;;; Generated autoloads from rmailedit.el
 
 (autoload 'rmail-edit-current-message "rmailedit" "\
@@ -4597,7 +4636,7 @@ With prefix argument N moves forward N messages with these labels.
 
 ;;;***
 \f
 
 ;;;***
 \f
-;;;### (autoloads (rmail-mime) "rmailmm" "rmailmm.el" "cd7656f82944d0b92b0d093a5f3a4c36")
+;;;### (autoloads (rmail-mime) "rmailmm" "rmailmm.el" "f1937f85a1258de8880a089fa5ae5621")
 ;;; Generated autoloads from rmailmm.el
 
 (autoload 'rmail-mime "rmailmm" "\
 ;;; Generated autoloads from rmailmm.el
 
 (autoload 'rmail-mime "rmailmm" "\
@@ -4699,7 +4738,7 @@ If prefix argument REVERSE is non-nil, sorts in reverse order.
 \f
 ;;;### (autoloads (rmail-summary-by-senders rmail-summary-by-topic
 ;;;;;;  rmail-summary-by-regexp rmail-summary-by-recipients rmail-summary-by-labels
 \f
 ;;;### (autoloads (rmail-summary-by-senders rmail-summary-by-topic
 ;;;;;;  rmail-summary-by-regexp rmail-summary-by-recipients rmail-summary-by-labels
-;;;;;;  rmail-summary) "rmailsum" "rmailsum.el" "bef21a376bd5bd59792a20dd86e6ec34")
+;;;;;;  rmail-summary) "rmailsum" "rmailsum.el" "856fc6e337d5398b302c448ee7a2315e")
 ;;; Generated autoloads from rmailsum.el
 
 (autoload 'rmail-summary "rmailsum" "\
 ;;; Generated autoloads from rmailsum.el
 
 (autoload 'rmail-summary "rmailsum" "\