changeset 103247:0eb3cdddefb2

* mail/rmail.el (rmail-expunge-confirmed): Return nil if nothing to do. Don't call rmail-modify-format here. (rmail-expunge): Call it here after expunge is confirmed. (rmail-confirm-expunge): Doc fix. Mark as risky. (rmail-convert-babyl-to-mbox): Call rmail-modify-format. (rmail-set-attribute): Call rmail-dont-modify-format only for `unseen'. For other attributes, call `rmail-modify-format', and propagate the modified flag to rmail-buffer.
author Richard M. Stallman <rms@gnu.org>
date Mon, 18 May 2009 16:26:57 +0000
parents 94e71fa6e9ac
children 97c6a390ad50
files lisp/ChangeLog lisp/mail/rmail.el
diffstat 2 files changed, 35 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Mon May 18 12:14:14 2009 +0000
+++ b/lisp/ChangeLog	Mon May 18 16:26:57 2009 +0000
@@ -1,3 +1,14 @@
+2009-05-18  Richard M Stallman  <rms@gnu.org>
+
+	* mail/rmail.el (rmail-expunge-confirmed): Return nil if nothing to do.
+	Don't call rmail-modify-format here.
+	(rmail-expunge): Call it here after expunge is confirmed.
+	(rmail-confirm-expunge): Doc fix.  Mark as risky.
+	(rmail-convert-babyl-to-mbox): Call rmail-modify-format.
+	(rmail-set-attribute): Call rmail-dont-modify-format only for `unseen'.
+	For other attributes, call `rmail-modify-format',
+	and propagate the modified flag to rmail-buffer.
+
 2009-05-17  Richard M Stallman  <rms@gnu.org>
 
 	* mail/rmailedit.el (rmail-edit-current-message):
--- a/lisp/mail/rmail.el	Mon May 18 12:14:14 2009 +0000
+++ b/lisp/mail/rmail.el	Mon May 18 16:26:57 2009 +0000
@@ -440,12 +440,15 @@
   :group 'rmail-files)
 
 (defcustom rmail-confirm-expunge 'y-or-n-p
-  "Whether and how to ask for confirmation before expunging deleted messages."
+  "Whether and how to ask for confirmation before expunging deleted messages.
+The value, if non-nil is a function to call with a question (string)
+as argument, to ask the user that question."
   :type '(choice (const :tag "No confirmation" nil)
 		 (const :tag "Confirm with y-or-n-p" y-or-n-p)
 		 (const :tag "Confirm with yes-or-no-p" yes-or-no-p))
   :version "21.1"
   :group 'rmail-files)
+(put 'rmail-confirm-expunge 'risky-local-variable t)
 
 ;;;###autoload
 (defvar rmail-mode-hook nil
@@ -967,6 +970,7 @@
 	    (rmail-perm-variables)
 	    (rmail-variables)
 	    (setq rmail-was-converted t)
+	    (rmail-dont-modify-format)
 	    (goto-char (point-max))
 	    (rmail-set-message-counters))
 	  (message "Replacing BABYL format with mbox format...done"))
@@ -2257,6 +2261,10 @@
       (setq n (1+ n))))
   (if (stringp attr)
       (error "Unknown attribute `%s'" attr))
+  ;; Ask for confirmation before setting any attribute except `unseen'
+  ;; if it would force a format change.
+  (unless (= attr rmail-unseen-attr-index)
+    (rmail-modify-format))
   (with-current-buffer rmail-buffer
     (or msgnum (setq msgnum rmail-current-message))
     (when (> msgnum 0)
@@ -2269,8 +2277,12 @@
             (if (= msgnum rmail-current-message)
                 (rmail-display-labels)))
 	  ;; Don't save in mbox format over a Babyl file
-	  ;; merely because of this.
-	  (rmail-dont-modify-format)))))
+	  ;; merely because of a change in `unseen' attribute.
+	  (if (= attr rmail-unseen-attr-index)
+	      (rmail-dont-modify-format)
+	    ;; Otherwise, if we modified the file text via the view buffer,
+	    ;; mark the main buffer modified too.
+	    (set-buffer-modified-p t))))))
 
 (defun rmail-message-attr-p (msg attrs)
   "Return non-nil if message number MSG has attributes matching regexp ATTRS."
@@ -3252,17 +3264,15 @@
       newnum)))
 
 (defun rmail-expunge-confirmed ()
-  "Return t if deleted message should be expunged. If necessary, ask the user.
-See also user-option `rmail-confirm-expunge'."
+  "Return t if expunge is needed and desirable.
+If `rmail-confirm-expunge' is non-nil, ask user to confirm."
   (set-buffer rmail-buffer)
-  ;; FIXME shouldn't this return nil if there is nothing to expunge?
-  ;; Eg to save rmail-expunge wasting its time?
-  (or (not (stringp rmail-deleted-vector))
-      (not (string-match "D" rmail-deleted-vector))
-      (if rmail-confirm-expunge
-	  (funcall rmail-confirm-expunge
-		   "Erase deleted messages from Rmail file? ")
-	(progn (rmail-modify-format) t))))
+  (and (stringp rmail-deleted-vector)
+       (string-match "D" rmail-deleted-vector)
+       (if rmail-confirm-expunge
+	   (funcall rmail-confirm-expunge
+		    "Erase deleted messages from Rmail file? ")
+	 t)))
 
 (defun rmail-only-expunge (&optional dont-show)
   "Actually erase all deleted messages in the file."
@@ -3357,6 +3367,7 @@
 does not pop any summary buffer."
   (interactive)
   (when (rmail-expunge-confirmed)
+    (rmail-modify-format)
     (let ((was-deleted (rmail-message-deleted-p rmail-current-message))
 	  (was-swapped (rmail-buffers-swapped-p)))
       (rmail-only-expunge t)