master 35af392aee5 1/2: Keep Rmail collection buffers unibyte
Eli Zaretskii <[email protected]> Sun, 5 Jul 2026 01:05:26 -0400 (EDT)
| Newsgroups | gmane.emacs.diffs |
|---|---|
| Message-ID | <[email protected]> |
branch: master commit 35af392aee538254f92fb2386f1dd69c7d0fb82b Author: Paul Nelson <[email protected]> Commit: Eli Zaretskii <[email protected]> Keep Rmail collection buffers unibyte * lisp/mail/rmail.el (rmail-enable-multibyte): Remove it. (rmail-mode): Do not bind 'rmail-enable-multibyte'. Do not make the collection buffer multibyte. (Bug#81274) (rmail-revert): Default 'coding-system-for-read' to 'no-conversion, as in 'rmail'; remove corresponding FIXME comment. (rmail-get-new-mail): Do not bind 'rmail-enable-multibyte'. * lisp/files.el (auto-mode-alist): Add Rmail file pattern. * lisp/international/mule-conf.el (file-coding-system-alist): Add Rmail file pattern. * doc/emacs/rmail.texi (Rmail Files): Document that "RMAIL" and "*.rmail" files now visit in Rmail mode automatically. * etc/NEWS: Announce the changes. * test/lisp/mail/rmail-tests.el (rmail-mode-makes-collection-buffer-unibyte): New test. --- doc/emacs/rmail.texi | 4 ++++ etc/NEWS | 6 ++++++ lisp/files.el | 1 + lisp/international/mule-conf.el | 2 ++ lisp/mail/rmail.el | 18 +++++------------- test/lisp/mail/rmail-tests.el | 17 +++++++++++++++++ 6 files changed, 35 insertions(+), 13 deletions(-) diff --git a/doc/emacs/rmail.texi b/doc/emacs/rmail.texi index d82cd177fa6..4c3989f51b9 100644 --- a/doc/emacs/rmail.texi +++ b/doc/emacs/rmail.texi @@ -451,6 +451,10 @@ in Rmail mode. You can use @kbd{M-x rmail-input} even when not in Rmail, but it is easier to type @kbd{C-u M-x rmail}, which does the same thing. + Files named @file{RMAIL} or ending in @file{.rmail} are visited in +Rmail mode automatically by ordinary file-visiting commands, such as +@kbd{C-x C-f}. + The file you read with @kbd{i} should normally be a valid mbox file. If it is not, Rmail tries to convert its text to mbox format, and visits the converted text in the buffer. If you save the buffer, that diff --git a/etc/NEWS b/etc/NEWS index ce53ea51f44..c705b5365f4 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -179,6 +179,12 @@ as well as the default nil and arbitrary user functions. The new command 'newsticker-copy-url', bound to 'w', adds the URL of the currently selected item in the list view to the kill-ring. +** Rmail + ++++ +*** Files named "RMAIL" or ending in ".rmail" now visit in Rmail mode. +You can now visit such files in Rmail mode using ordinary file-visiting +commands, such as 'C-x C-f'. * New Modes and Packages in Emacs 32.1 diff --git a/lisp/files.el b/lisp/files.el index 149a3e80866..fa120f5c8ae 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -3155,6 +3155,7 @@ since only a single case-insensitive search through the alist is made." ("\\.srt\\'" . srecode-template-mode) ("\\.prolog\\'" . prolog-mode) ("\\.tar\\'" . tar-mode) + ("\\(?:\\.rmail\\|\\(?:\\`\\|[/\\]\\)RMAIL\\)\\'" . rmail-mode) ;; The list of archive file extensions should be in sync with ;; `auto-coding-alist' with `no-conversion' coding system. ("\\.\\(\ diff --git a/lisp/international/mule-conf.el b/lisp/international/mule-conf.el index 818ae9728ce..f6347d3765c 100644 --- a/lisp/international/mule-conf.el +++ b/lisp/international/mule-conf.el @@ -1644,6 +1644,8 @@ for decoding and encoding files, process I/O, etc." ;; the beginning of a doc string, work. ("\\(\\`\\|/\\)loaddefs.el\\'" . (raw-text . raw-text-unix)) ("\\.tar\\'" . (no-conversion . no-conversion)) + ("\\(?:\\.rmail\\|\\(?:\\`\\|[/\\]\\)RMAIL\\)\\'" + . (no-conversion . no-conversion)) ( "\\.po[tx]?\\'\\|\\.po\\." . po-find-file-coding-system) ("\\.\\(tex\\|ltx\\|dtx\\|drv\\)\\'" . latexenc-find-file-coding-system) ("" . (undecided . nil)))) diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el index c168d6b750e..9f495ddf0f8 100644 --- a/lisp/mail/rmail.el +++ b/lisp/mail/rmail.el @@ -1259,8 +1259,6 @@ The buffer is expected to be narrowed to just the header of the message." (defun rmail-mode-kill-summary () (if rmail-summary-buffer (kill-buffer rmail-summary-buffer))) -(defvar rmail-enable-multibyte) ; dynamically bound - ;;;###autoload (defun rmail-mode () "Rmail Mode is used by \\<rmail-mode-map>\\[rmail] for editing Rmail files. @@ -1317,11 +1315,9 @@ Instead, these commands are available: (rmail-mode-2) (when (and finding-rmail-file (null coding-system-for-read)) - (let ((rmail-enable-multibyte t)) - (rmail-require-mime-maybe) - (rmail-convert-file-maybe) - (goto-char (point-max)) - (set-buffer-multibyte t))) + (rmail-require-mime-maybe) + (rmail-convert-file-maybe) + (goto-char (point-max))) (rmail-set-message-counters) (rmail-show-message rmail-total-messages) (when finding-rmail-file @@ -1504,10 +1500,8 @@ If so restore the actual mbox message collection." (defun rmail-revert (arg noconfirm) (set-buffer rmail-buffer) (let* ((revert-buffer-function (default-value 'revert-buffer-function)) - (rmail-enable-multibyte enable-multibyte-characters) - ;; See similar code in `rmail'. - ;; FIXME needs updating? - (coding-system-for-read (and rmail-enable-multibyte 'raw-text)) + (coding-system-for-read + (or coding-system-for-read 'no-conversion)) (before-revert-hook 'rmail-swap-buffers-maybe)) ;; Call our caller again, but this time it does the default thing. (when (revert-buffer arg noconfirm) @@ -1515,7 +1509,6 @@ If so restore the actual mbox message collection." ;; reparse the messages. (set-buffer rmail-buffer) (rmail-mode-2) - ;; Convert all or part to Babyl file if possible. (rmail-convert-file-maybe) (goto-char (point-max)) (rmail-set-message-counters) @@ -1723,7 +1716,6 @@ not be a new one). It returns non-nil if it got any new messages." (or (eq buffer-undo-list t) (setq buffer-undo-list nil)) (let ((all-files (if file-name (list file-name) rmail-inbox-list)) - (rmail-enable-multibyte t) found) (unwind-protect (progn diff --git a/test/lisp/mail/rmail-tests.el b/test/lisp/mail/rmail-tests.el index 5877c562001..8e888a087fd 100644 --- a/test/lisp/mail/rmail-tests.el +++ b/test/lisp/mail/rmail-tests.el @@ -31,5 +31,22 @@ (symbol-function 'rmail-edit-current-message)))) +(ert-deftest rmail-mode-makes-collection-buffer-unibyte () + (with-temp-buffer + (set-buffer-multibyte nil) + (insert "From [email protected] Tue Jun 9 12:00:00 2026\n" + "From: [email protected]\n" + "To: [email protected]\n" + "Subject: lunch\n" + "Date: Tue, 09 Jun 2026 12:00:00 +0000\n" + "\n" + "Caf\xe9\n" + "\n") + (rmail-mode) + (with-current-buffer (if (rmail-buffers-swapped-p) + rmail-view-buffer + rmail-buffer) + (should-not enable-multibyte-characters)))) + (provide 'rmail-tests) ;;; rmail-tests.el ends here