In a summary buffer, this holds the RMAIL buffer it is a summary for.")
(put 'rmail-buffer 'permanent-local t)
+(defvar rmail-was-converted nil
+ "Non-nil in an Rmail buffer that was just converted from Babyl format.")
+(put 'rmail-was-converted 'permanent-local t)
+
+(defvar rmail-seriously-modified nil
+ "Non-nil in an Rmail buffer that has been modified in a major way.")
+(put 'rmail-seriously-modified 'permanent-local t)
+
;; Message counters and markers. Deleted flags.
(defvar rmail-current-message nil
(defun rmail-convert-babyl-to-mbox ()
"Convert the mail file from Babyl version 5 to mbox.
This function also reinitializes local variables used by Rmail."
- (unless (y-or-n-p "Babyl mail file detected. Rmail now uses mbox format for mail files.
-Convert Babyl mail file to mbox format? ")
- (error "Aborted"))
(let ((old-file (make-temp-file "rmail"))
(new-file (make-temp-file "rmail")))
(unwind-protect
(rmail-mode-1)
(rmail-perm-variables)
(rmail-variables)
+ (setq rmail-was-converted t)
(goto-char (point-max))
(rmail-set-message-counters))
(message "Replacing BABYL format with mbox format...done"))
(rmail-swap-buffers)
(setq rmail-buffer-swapped nil))))
+(defun rmail-modify-format ()
+ "Warn if important modifications would change Rmail file's format."
+ (with-current-buffer rmail-buffer
+ (and rmail-was-converted
+ ;; If it's already modified, don't warn again.
+ (not rmail-seriously-modified)
+ (not
+ (yes-or-no-p
+ (message "After this, %s would be saved in mbox format. Proceed? "
+ (buffer-name))))
+ (error "Aborted"))
+ (setq rmail-seriously-modified t)))
+
+(defun rmail-dont-modify-format ()
+ (when (and rmail-was-converted (not rmail-seriously-modified))
+ (set-buffer-modified-p nil)
+ (message "Marking buffer unmodified to avoid rewriting Babyl file as mbox file")))
+
(defun rmail-mode-kill-buffer-hook ()
(if (buffer-live-p rmail-view-buffer) (kill-buffer rmail-view-buffer)))
(make-local-variable 'rmail-last-regexp)
(make-local-variable 'rmail-deleted-vector)
(make-local-variable 'rmail-buffer)
+ (make-local-variable 'rmail-was-converted)
+ (setq rmail-was-converted nil)
+ (make-local-variable 'rmail-seriously-modified)
+ (setq rmail-seriously-modified nil)
(setq rmail-buffer (current-buffer))
(set-buffer-multibyte nil)
(with-current-buffer (setq rmail-view-buffer (rmail-generate-viewer-buffer))
;; If we are in a summary buffer, switch to the Rmail buffer.
;; FIXME simpler to swap the contents, not the buffers?
(set-buffer rmail-buffer)
+ (rmail-modify-format)
(let ((buff (current-buffer))
(n rmail-current-message)
(beg (rmail-msgbeg rmail-current-message))
(or (verify-visited-file-modtime (current-buffer))
(find-file (buffer-file-name)))
(set-buffer rmail-buffer)
+ (rmail-modify-format)
(rmail-swap-buffers-maybe)
(rmail-maybe-set-message-counters)
(widen)
If MSGNUM is nil, use the current message. NAME and VALUE are strings.
VALUE may also be nil, meaning to remove the header."
(rmail-apply-in-message msgnum 'rmail-set-header-1 name value)
- ;; Ensure header changes get saved.
- ;; (Note replacing a header with an identical copy modifies.)
- (with-current-buffer rmail-buffer (set-buffer-modified-p t)))
-
+ (with-current-buffer rmail-buffer
+ ;; Ensure header changes get saved.
+ ;; (Note replacing a header with an identical copy modifies.)
+ (set-buffer-modified-p t)
+ ;; However: don't save in mbox format over a Babyl file
+ ;; merely because of this.
+ (rmail-dont-modify-format)))
\f
;;;; *** Rmail Attributes and Keywords ***
(rmail-apply-in-message msgnum 'rmail-set-attribute-1 attr state)
(if (= msgnum rmail-current-message)
(rmail-display-labels)))
- ;; If we made a significant change in an attribute, mark
- ;; rmail-buffer modified, so it will be (1) saved and (2)
- ;; displayed in the mode line.
- (set-buffer-modified-p t)))))
+ ;; Don't save in mbox format over a Babyl file
+ ;; merely because of this.
+ (rmail-dont-modify-format)))))
(defun rmail-message-attr-p (msg attrs)
"Return non-nil if message number MSG has attributes matching regexp ATTRS."
(t (setq rmail-current-message msg)))
(with-current-buffer rmail-buffer
(setq header-style rmail-header-style)
- ;; Mark the message as seen, bracket the message in the mail
- ;; buffer and determine the coding system the transfer encoding.
+ ;; Mark the message as seen
(rmail-set-attribute rmail-unseen-attr-index nil)
+ ;; bracket the message in the mail
+ ;; buffer and determine the coding system the transfer encoding.
(rmail-swap-buffers-maybe)
(setq beg (rmail-msgbeg msg)
end (rmail-msgend msg))
;; Eg to save rmail-expunge wasting its time?
(or (not (stringp rmail-deleted-vector))
(not (string-match "D" rmail-deleted-vector))
- (null rmail-confirm-expunge)
- (funcall rmail-confirm-expunge
- "Erase deleted messages from Rmail file? ")))
+ (if rmail-confirm-expunge
+ (funcall rmail-confirm-expunge
+ "Erase deleted messages from Rmail file? ")
+ (progn (rmail-modify-format) t))))
(defun rmail-only-expunge (&optional dont-show)
"Actually erase all deleted messages in the file."