Commit 9aadce25 authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

Don't query before visiting a Babyl file.

Instead, query before modifications that would save it.

* mail/rmail.el (rmail-was-converted): New variable.
(rmail-seriously-modified): New variable.
(rmail-perm-variables): Set them to nil.
(rmail-convert-babyl-to-mbox): Don't query about converting Babyl file.
Instead, set rmail-was-converted.
(rmail-modify-format): New function.  Query if save will change format.
(rmail-dont-modify-format): New function.
(rmail-duplicate-message, rmail-get-new-mail):
Call rmail-modify-format.
(rmail-set-header): Call rmail-dont-modify-format.
(rmail-set-attribute): Likewise.
(rmail-expunge-confirmed): Call rmail-modify-format.

* mail/rmailout.el (rmail-output-to-rmail-buffer):
Call rmail-modify-format.
parent caf9510c
2009-04-09 Richard M Stallman <rms@gnu.org>
 
* mail/rmailout.el (rmail-output-to-rmail-buffer):
Call rmail-modify-format..
Don't query before visiting a Babyl file.
Instead, query before modifications that would save it.
* mail/rmail.el (rmail-was-converted): New variable.
(rmail-seriously-modified): New variable.
(rmail-perm-variables): Set them to nil.
(rmail-convert-babyl-to-mbox): Don't query about converting Babyl file.
Instead, set rmail-was-converted.
(rmail-modify-format): New function. Query if save will change format.
(rmail-dont-modify-format): New function.
(rmail-duplicate-message, rmail-get-new-mail):
Call rmail-modify-format.
(rmail-set-header): Call rmail-dont-modify-format.
(rmail-set-attribute): Likewise.
(rmail-expunge-confirmed): Call rmail-modify-format.
* mail/sendmail.el (sendmail-send-it): Replace any
pre-existing Content-type header if we insert one.
 
......
......@@ -544,6 +544,14 @@ In an RMAIL buffer, this holds the RMAIL buffer itself.
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
......@@ -939,9 +947,6 @@ MSGNUM, if present, indicates the malformed message."
(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
......@@ -961,6 +966,7 @@ Convert Babyl mail file to mbox format? ")
(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"))
......@@ -1334,6 +1340,24 @@ If so restore the actual mbox message collection."
(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)))
......@@ -1342,6 +1366,10 @@ If so restore the actual mbox message collection."
(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))
......@@ -1483,6 +1511,7 @@ The duplicate copy goes into the Rmail file just after the original."
;; 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))
......@@ -1629,6 +1658,7 @@ not be a new one). It returns non-nil if it got any new messages."
(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)
......@@ -2049,10 +2079,13 @@ VALUE nil means to remove NAME altogether."
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)))
;;;; *** Rmail Attributes and Keywords ***
......@@ -2188,10 +2221,9 @@ change; nil means current message."
(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."
......@@ -2564,9 +2596,10 @@ The current mail message becomes the message displayed."
(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))
......@@ -3179,9 +3212,10 @@ See also user-option `rmail-confirm-expunge'."
;; 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."
......
......@@ -366,6 +366,7 @@ Do what is necessary to make Rmail know about the new message. then
display message number MSG."
(save-excursion
(rmail-swap-buffers-maybe)
(rmail-modify-format)
;; Turn on Auto Save mode, if it's off in this buffer but enabled
;; by default.
(and (not buffer-auto-save-file-name)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment