diff options
| author | Richard M. Stallman | 2009-04-09 16:43:51 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2009-04-09 16:43:51 +0000 |
| commit | 9aadce2568555d286f03a5b8863e29bf84002e7e (patch) | |
| tree | bad2cffd2ee83450e3000de713a09404e2589fb3 | |
| parent | caf9510cb8a9923e6bab6be7fd9ff0ff156b572c (diff) | |
| download | emacs-9aadce2568555d286f03a5b8863e29bf84002e7e.tar.gz emacs-9aadce2568555d286f03a5b8863e29bf84002e7e.zip | |
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.
| -rw-r--r-- | lisp/ChangeLog | 19 | ||||
| -rw-r--r-- | lisp/mail/rmail.el | 66 | ||||
| -rw-r--r-- | lisp/mail/rmailout.el | 1 |
3 files changed, 70 insertions, 16 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index de1235576e6..d59d7577f7f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,24 @@ | |||
| 1 | 2009-04-09 Richard M Stallman <rms@gnu.org> | 1 | 2009-04-09 Richard M Stallman <rms@gnu.org> |
| 2 | 2 | ||
| 3 | * mail/rmailout.el (rmail-output-to-rmail-buffer): | ||
| 4 | Call rmail-modify-format.. | ||
| 5 | |||
| 6 | Don't query before visiting a Babyl file. | ||
| 7 | Instead, query before modifications that would save it. | ||
| 8 | |||
| 9 | * mail/rmail.el (rmail-was-converted): New variable. | ||
| 10 | (rmail-seriously-modified): New variable. | ||
| 11 | (rmail-perm-variables): Set them to nil. | ||
| 12 | (rmail-convert-babyl-to-mbox): Don't query about converting Babyl file. | ||
| 13 | Instead, set rmail-was-converted. | ||
| 14 | (rmail-modify-format): New function. Query if save will change format. | ||
| 15 | (rmail-dont-modify-format): New function. | ||
| 16 | (rmail-duplicate-message, rmail-get-new-mail): | ||
| 17 | Call rmail-modify-format. | ||
| 18 | (rmail-set-header): Call rmail-dont-modify-format. | ||
| 19 | (rmail-set-attribute): Likewise. | ||
| 20 | (rmail-expunge-confirmed): Call rmail-modify-format. | ||
| 21 | |||
| 3 | * mail/sendmail.el (sendmail-send-it): Replace any | 22 | * mail/sendmail.el (sendmail-send-it): Replace any |
| 4 | pre-existing Content-type header if we insert one. | 23 | pre-existing Content-type header if we insert one. |
| 5 | 24 | ||
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el index a950f903f70..868cdffc620 100644 --- a/lisp/mail/rmail.el +++ b/lisp/mail/rmail.el | |||
| @@ -544,6 +544,14 @@ In an RMAIL buffer, this holds the RMAIL buffer itself. | |||
| 544 | In a summary buffer, this holds the RMAIL buffer it is a summary for.") | 544 | In a summary buffer, this holds the RMAIL buffer it is a summary for.") |
| 545 | (put 'rmail-buffer 'permanent-local t) | 545 | (put 'rmail-buffer 'permanent-local t) |
| 546 | 546 | ||
| 547 | (defvar rmail-was-converted nil | ||
| 548 | "Non-nil in an Rmail buffer that was just converted from Babyl format.") | ||
| 549 | (put 'rmail-was-converted 'permanent-local t) | ||
| 550 | |||
| 551 | (defvar rmail-seriously-modified nil | ||
| 552 | "Non-nil in an Rmail buffer that has been modified in a major way.") | ||
| 553 | (put 'rmail-seriously-modified 'permanent-local t) | ||
| 554 | |||
| 547 | ;; Message counters and markers. Deleted flags. | 555 | ;; Message counters and markers. Deleted flags. |
| 548 | 556 | ||
| 549 | (defvar rmail-current-message nil | 557 | (defvar rmail-current-message nil |
| @@ -939,9 +947,6 @@ MSGNUM, if present, indicates the malformed message." | |||
| 939 | (defun rmail-convert-babyl-to-mbox () | 947 | (defun rmail-convert-babyl-to-mbox () |
| 940 | "Convert the mail file from Babyl version 5 to mbox. | 948 | "Convert the mail file from Babyl version 5 to mbox. |
| 941 | This function also reinitializes local variables used by Rmail." | 949 | This function also reinitializes local variables used by Rmail." |
| 942 | (unless (y-or-n-p "Babyl mail file detected. Rmail now uses mbox format for mail files. | ||
| 943 | Convert Babyl mail file to mbox format? ") | ||
| 944 | (error "Aborted")) | ||
| 945 | (let ((old-file (make-temp-file "rmail")) | 950 | (let ((old-file (make-temp-file "rmail")) |
| 946 | (new-file (make-temp-file "rmail"))) | 951 | (new-file (make-temp-file "rmail"))) |
| 947 | (unwind-protect | 952 | (unwind-protect |
| @@ -961,6 +966,7 @@ Convert Babyl mail file to mbox format? ") | |||
| 961 | (rmail-mode-1) | 966 | (rmail-mode-1) |
| 962 | (rmail-perm-variables) | 967 | (rmail-perm-variables) |
| 963 | (rmail-variables) | 968 | (rmail-variables) |
| 969 | (setq rmail-was-converted t) | ||
| 964 | (goto-char (point-max)) | 970 | (goto-char (point-max)) |
| 965 | (rmail-set-message-counters)) | 971 | (rmail-set-message-counters)) |
| 966 | (message "Replacing BABYL format with mbox format...done")) | 972 | (message "Replacing BABYL format with mbox format...done")) |
| @@ -1334,6 +1340,24 @@ If so restore the actual mbox message collection." | |||
| 1334 | (rmail-swap-buffers) | 1340 | (rmail-swap-buffers) |
| 1335 | (setq rmail-buffer-swapped nil)))) | 1341 | (setq rmail-buffer-swapped nil)))) |
| 1336 | 1342 | ||
| 1343 | (defun rmail-modify-format () | ||
| 1344 | "Warn if important modifications would change Rmail file's format." | ||
| 1345 | (with-current-buffer rmail-buffer | ||
| 1346 | (and rmail-was-converted | ||
| 1347 | ;; If it's already modified, don't warn again. | ||
| 1348 | (not rmail-seriously-modified) | ||
| 1349 | (not | ||
| 1350 | (yes-or-no-p | ||
| 1351 | (message "After this, %s would be saved in mbox format. Proceed? " | ||
| 1352 | (buffer-name)))) | ||
| 1353 | (error "Aborted")) | ||
| 1354 | (setq rmail-seriously-modified t))) | ||
| 1355 | |||
| 1356 | (defun rmail-dont-modify-format () | ||
| 1357 | (when (and rmail-was-converted (not rmail-seriously-modified)) | ||
| 1358 | (set-buffer-modified-p nil) | ||
| 1359 | (message "Marking buffer unmodified to avoid rewriting Babyl file as mbox file"))) | ||
| 1360 | |||
| 1337 | (defun rmail-mode-kill-buffer-hook () | 1361 | (defun rmail-mode-kill-buffer-hook () |
| 1338 | (if (buffer-live-p rmail-view-buffer) (kill-buffer rmail-view-buffer))) | 1362 | (if (buffer-live-p rmail-view-buffer) (kill-buffer rmail-view-buffer))) |
| 1339 | 1363 | ||
| @@ -1342,6 +1366,10 @@ If so restore the actual mbox message collection." | |||
| 1342 | (make-local-variable 'rmail-last-regexp) | 1366 | (make-local-variable 'rmail-last-regexp) |
| 1343 | (make-local-variable 'rmail-deleted-vector) | 1367 | (make-local-variable 'rmail-deleted-vector) |
| 1344 | (make-local-variable 'rmail-buffer) | 1368 | (make-local-variable 'rmail-buffer) |
| 1369 | (make-local-variable 'rmail-was-converted) | ||
| 1370 | (setq rmail-was-converted nil) | ||
| 1371 | (make-local-variable 'rmail-seriously-modified) | ||
| 1372 | (setq rmail-seriously-modified nil) | ||
| 1345 | (setq rmail-buffer (current-buffer)) | 1373 | (setq rmail-buffer (current-buffer)) |
| 1346 | (set-buffer-multibyte nil) | 1374 | (set-buffer-multibyte nil) |
| 1347 | (with-current-buffer (setq rmail-view-buffer (rmail-generate-viewer-buffer)) | 1375 | (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." | |||
| 1483 | ;; If we are in a summary buffer, switch to the Rmail buffer. | 1511 | ;; If we are in a summary buffer, switch to the Rmail buffer. |
| 1484 | ;; FIXME simpler to swap the contents, not the buffers? | 1512 | ;; FIXME simpler to swap the contents, not the buffers? |
| 1485 | (set-buffer rmail-buffer) | 1513 | (set-buffer rmail-buffer) |
| 1514 | (rmail-modify-format) | ||
| 1486 | (let ((buff (current-buffer)) | 1515 | (let ((buff (current-buffer)) |
| 1487 | (n rmail-current-message) | 1516 | (n rmail-current-message) |
| 1488 | (beg (rmail-msgbeg rmail-current-message)) | 1517 | (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." | |||
| 1629 | (or (verify-visited-file-modtime (current-buffer)) | 1658 | (or (verify-visited-file-modtime (current-buffer)) |
| 1630 | (find-file (buffer-file-name))) | 1659 | (find-file (buffer-file-name))) |
| 1631 | (set-buffer rmail-buffer) | 1660 | (set-buffer rmail-buffer) |
| 1661 | (rmail-modify-format) | ||
| 1632 | (rmail-swap-buffers-maybe) | 1662 | (rmail-swap-buffers-maybe) |
| 1633 | (rmail-maybe-set-message-counters) | 1663 | (rmail-maybe-set-message-counters) |
| 1634 | (widen) | 1664 | (widen) |
| @@ -2049,10 +2079,13 @@ VALUE nil means to remove NAME altogether." | |||
| 2049 | If MSGNUM is nil, use the current message. NAME and VALUE are strings. | 2079 | If MSGNUM is nil, use the current message. NAME and VALUE are strings. |
| 2050 | VALUE may also be nil, meaning to remove the header." | 2080 | VALUE may also be nil, meaning to remove the header." |
| 2051 | (rmail-apply-in-message msgnum 'rmail-set-header-1 name value) | 2081 | (rmail-apply-in-message msgnum 'rmail-set-header-1 name value) |
| 2052 | ;; Ensure header changes get saved. | 2082 | (with-current-buffer rmail-buffer |
| 2053 | ;; (Note replacing a header with an identical copy modifies.) | 2083 | ;; Ensure header changes get saved. |
| 2054 | (with-current-buffer rmail-buffer (set-buffer-modified-p t))) | 2084 | ;; (Note replacing a header with an identical copy modifies.) |
| 2055 | 2085 | (set-buffer-modified-p t) | |
| 2086 | ;; However: don't save in mbox format over a Babyl file | ||
| 2087 | ;; merely because of this. | ||
| 2088 | (rmail-dont-modify-format))) | ||
| 2056 | 2089 | ||
| 2057 | ;;;; *** Rmail Attributes and Keywords *** | 2090 | ;;;; *** Rmail Attributes and Keywords *** |
| 2058 | 2091 | ||
| @@ -2188,10 +2221,9 @@ change; nil means current message." | |||
| 2188 | (rmail-apply-in-message msgnum 'rmail-set-attribute-1 attr state) | 2221 | (rmail-apply-in-message msgnum 'rmail-set-attribute-1 attr state) |
| 2189 | (if (= msgnum rmail-current-message) | 2222 | (if (= msgnum rmail-current-message) |
| 2190 | (rmail-display-labels))) | 2223 | (rmail-display-labels))) |
| 2191 | ;; If we made a significant change in an attribute, mark | 2224 | ;; Don't save in mbox format over a Babyl file |
| 2192 | ;; rmail-buffer modified, so it will be (1) saved and (2) | 2225 | ;; merely because of this. |
| 2193 | ;; displayed in the mode line. | 2226 | (rmail-dont-modify-format))))) |
| 2194 | (set-buffer-modified-p t))))) | ||
| 2195 | 2227 | ||
| 2196 | (defun rmail-message-attr-p (msg attrs) | 2228 | (defun rmail-message-attr-p (msg attrs) |
| 2197 | "Return non-nil if message number MSG has attributes matching regexp ATTRS." | 2229 | "Return non-nil if message number MSG has attributes matching regexp ATTRS." |
| @@ -2564,9 +2596,10 @@ The current mail message becomes the message displayed." | |||
| 2564 | (t (setq rmail-current-message msg))) | 2596 | (t (setq rmail-current-message msg))) |
| 2565 | (with-current-buffer rmail-buffer | 2597 | (with-current-buffer rmail-buffer |
| 2566 | (setq header-style rmail-header-style) | 2598 | (setq header-style rmail-header-style) |
| 2567 | ;; Mark the message as seen, bracket the message in the mail | 2599 | ;; Mark the message as seen |
| 2568 | ;; buffer and determine the coding system the transfer encoding. | ||
| 2569 | (rmail-set-attribute rmail-unseen-attr-index nil) | 2600 | (rmail-set-attribute rmail-unseen-attr-index nil) |
| 2601 | ;; bracket the message in the mail | ||
| 2602 | ;; buffer and determine the coding system the transfer encoding. | ||
| 2570 | (rmail-swap-buffers-maybe) | 2603 | (rmail-swap-buffers-maybe) |
| 2571 | (setq beg (rmail-msgbeg msg) | 2604 | (setq beg (rmail-msgbeg msg) |
| 2572 | end (rmail-msgend msg)) | 2605 | end (rmail-msgend msg)) |
| @@ -3179,9 +3212,10 @@ See also user-option `rmail-confirm-expunge'." | |||
| 3179 | ;; Eg to save rmail-expunge wasting its time? | 3212 | ;; Eg to save rmail-expunge wasting its time? |
| 3180 | (or (not (stringp rmail-deleted-vector)) | 3213 | (or (not (stringp rmail-deleted-vector)) |
| 3181 | (not (string-match "D" rmail-deleted-vector)) | 3214 | (not (string-match "D" rmail-deleted-vector)) |
| 3182 | (null rmail-confirm-expunge) | 3215 | (if rmail-confirm-expunge |
| 3183 | (funcall rmail-confirm-expunge | 3216 | (funcall rmail-confirm-expunge |
| 3184 | "Erase deleted messages from Rmail file? "))) | 3217 | "Erase deleted messages from Rmail file? ") |
| 3218 | (progn (rmail-modify-format) t)))) | ||
| 3185 | 3219 | ||
| 3186 | (defun rmail-only-expunge (&optional dont-show) | 3220 | (defun rmail-only-expunge (&optional dont-show) |
| 3187 | "Actually erase all deleted messages in the file." | 3221 | "Actually erase all deleted messages in the file." |
diff --git a/lisp/mail/rmailout.el b/lisp/mail/rmailout.el index 4f753f1e0f0..cb34ff4705a 100644 --- a/lisp/mail/rmailout.el +++ b/lisp/mail/rmailout.el | |||
| @@ -366,6 +366,7 @@ Do what is necessary to make Rmail know about the new message. then | |||
| 366 | display message number MSG." | 366 | display message number MSG." |
| 367 | (save-excursion | 367 | (save-excursion |
| 368 | (rmail-swap-buffers-maybe) | 368 | (rmail-swap-buffers-maybe) |
| 369 | (rmail-modify-format) | ||
| 369 | ;; Turn on Auto Save mode, if it's off in this buffer but enabled | 370 | ;; Turn on Auto Save mode, if it's off in this buffer but enabled |
| 370 | ;; by default. | 371 | ;; by default. |
| 371 | (and (not buffer-auto-save-file-name) | 372 | (and (not buffer-auto-save-file-name) |