]> code.delx.au - gnu-emacs/blobdiff - lisp/mail/rmailedit.el
rmail generate autoloads to non-versioned file.
[gnu-emacs] / lisp / mail / rmailedit.el
index 0b837a43d947c2913de7b1a44c78d05cd6cc0c3e..d79ec39da8056059f7c9f4c326d03bf10f2c71de 100644 (file)
@@ -1,8 +1,8 @@
 ;;; rmailedit.el --- "RMAIL edit mode"  Edit the current message
 
-;; Copyright (C) 1985, 1994, 2001-201 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1994, 2001-2015 Free Software Foundation, Inc.
 
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
 ;; Keywords: mail
 ;; Package: rmail
 
@@ -44,6 +44,8 @@
 
 (declare-function rmail-summary-disable "rmailsum" ())
 
+;; We can't straightforwardly make this derive from text-mode, because
+;; we need to bind (rmail-buffer-swapped) around the text-mode call.  :(
 (defun rmail-edit-mode ()
   "Major mode for editing the contents of an Rmail message.
 The editing commands are the same as in Text mode, together with
@@ -111,6 +113,8 @@ This function runs the hooks `text-mode-hook' and `rmail-edit-mode-hook'.
              ;; Even if the message is in `raw' state, boundaries etc
              ;; are still missing.  All we can do is insert the real
              ;; raw message.  (Bug#9840)
+             ;; FIXME?  Since the 2012-09-17 changes to rmail-mime,
+             ;; can we just use that function now?
              (when (and entity
                         (not (equal "text/plain"
                                     (car (rmail-mime-entity-type entity)))))
@@ -165,10 +169,25 @@ This function runs the hooks `text-mode-hook' and `rmail-edit-mode-hook'.
   (if (or rmail-old-mime-state
          (not rmail-old-pruned))
       (forward-line 1))
-  (while (re-search-forward "^>*From " nil t)
-    (beginning-of-line)
-    (insert ">")
-    (forward-line))
+  ;; When editing a non-MIME message, rmail-show-message-1 has unescaped
+  ;; ^>*From lines according to rmail-mbox-format.  We are editing
+  ;; the message as it was displayed, and need to put the escapes when done.
+  ;; When editing a MIME message, we are editing the "raw" message.
+  ;; ^>*From lines have not been escaped, but we still need to ensure
+  ;; a "^From " line is escaped so as not to break later parsing (?).
+  ;; With ^>+From lines, we have no way of knowing whether the person
+  ;; doing the editing escaped them or not, so it seems best to leave
+  ;; them alone.  (This all assumes you are using rmailmm rather than
+  ;; something else that behaves differently.)
+  (let ((fromline (if (or (eq 'mboxo rmail-mbox-format)
+                         rmail-mime-decoded)
+                     "^From "
+                   "^>*From "))
+       case-fold-search)
+    (while (re-search-forward fromline nil t)
+      (beginning-of-line)
+      (insert ">")
+      (forward-line)))
   ;; Make sure buffer ends with a blank line so as not to run this
   ;; message together with the following one.
   (goto-char (point-max))
@@ -199,6 +218,7 @@ This function runs the hooks `text-mode-hook' and `rmail-edit-mode-hook'.
       (setq buffer-undo-list t)
       (rmail-variables))
     ;; If text has really changed, mark message as edited.
+    ;; FIXME we should do the comparison before escaping From lines.
     (unless (and (= (length old) (- (point-max) (point-min)))
                 (string= old (buffer-substring (point-min) (point-max))))
       (setq old nil)
@@ -428,7 +448,7 @@ HEADER-DIFF should be a return value from `rmail-edit-diff-headers'."
 (provide 'rmailedit)
 
 ;; Local Variables:
-;; generated-autoload-file: "rmail.el"
+;; generated-autoload-file: "rmail-loaddefs.el"
 ;; End:
 
 ;;; rmailedit.el ends here