emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r111144: rmail-cease-edit fixes relat


From: Glenn Morris
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r111144: rmail-cease-edit fixes related to "^From " escaping
Date: Fri, 07 Dec 2012 00:59:14 -0800
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 111144
fixes bug: http://debbugs.gnu.org/9841
committer: Glenn Morris <address@hidden>
branch nick: trunk
timestamp: Fri 2012-12-07 00:59:14 -0800
message:
  rmail-cease-edit fixes related to "^From " escaping
  
  * mail/rmail.el (rmail-mime-decoded): New permanent local.
  (rmail-show-message-1): Set rmail-mime-decoded when appropriate.
  * mail/rmailedit.el (rmail-cease-edit): Respect rmail-mbox-format
  and rmail-mime-decoded.
modified:
  lisp/ChangeLog
  lisp/mail/rmail.el
  lisp/mail/rmailedit.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-12-07 04:37:14 +0000
+++ b/lisp/ChangeLog    2012-12-07 08:59:14 +0000
@@ -1,5 +1,10 @@
 2012-12-07  Glenn Morris  <address@hidden>
 
+       * mail/rmail.el (rmail-mime-decoded): New permanent local.
+       (rmail-show-message-1): Set rmail-mime-decoded when appropriate.
+       * mail/rmailedit.el (rmail-cease-edit): Respect rmail-mbox-format
+       and rmail-mime-decoded.  (Bug#9841)
+
        * mail/unrmail.el (unrmail-mbox-format): New option.  (Bug#6574)
        (batch-unrmail, unrmail): Doc fixes.
        (unrmail): Respect unrmail-mbox-format.

=== modified file 'lisp/mail/rmail.el'
--- a/lisp/mail/rmail.el        2012-12-07 04:57:43 +0000
+++ b/lisp/mail/rmail.el        2012-12-07 08:59:14 +0000
@@ -100,6 +100,10 @@
   "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)
@@ -2768,6 +2772,7 @@
                 (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))

=== modified file 'lisp/mail/rmailedit.el'
--- a/lisp/mail/rmailedit.el    2012-09-18 07:19:25 +0000
+++ b/lisp/mail/rmailedit.el    2012-12-07 08:59:14 +0000
@@ -167,10 +167,25 @@
   (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))
@@ -201,6 +216,7 @@
       (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)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]