]> git.eshelyaron.com Git - emacs.git/commitdiff
Minor improvement in 'rmail-redecode-body'
authorEli Zaretskii <eliz@gnu.org>
Sun, 14 Jul 2024 08:41:30 +0000 (11:41 +0300)
committerEshel Yaron <me@eshelyaron.com>
Wed, 17 Jul 2024 17:39:38 +0000 (19:39 +0200)
* lisp/mail/rmail.el (rmail-redecode-body): Signal user-error if
'rmail-enable-mime' is non-nil; doc fix.

(cherry picked from commit 159f3f59b1d6ca57cff6f0628458908b62639e30)

lisp/mail/rmail.el

index 5e3633d221cb742cf4a521d625e50cae5758d24a..e38ab12fae6961ea509dd949776cfc5d78ba2aed 100644 (file)
@@ -2955,51 +2955,56 @@ charset= headers.
 This function assumes that the current message is already decoded
 and displayed in the RMAIL buffer, but the coding system used to
 decode it was incorrect.  It then decodes the message again,
-using the coding system CODING."
+using the coding system CODING.
+
+This function does nothing (except reporting a user-error)
+if `rmail-enable-mime' is non-nil."
   (interactive "zCoding system for re-decoding this message: ")
-  (when (not rmail-enable-mime)
-    (with-current-buffer rmail-buffer
-      (rmail-swap-buffers-maybe)
-      (save-restriction
-       (widen)
-       (let ((msgbeg (rmail-msgbeg rmail-current-message))
-             (msgend (rmail-msgend rmail-current-message))
-             (buffer-read-only nil)
-             body-start x-coding-header old-coding)
-         (narrow-to-region msgbeg msgend)
-         (goto-char (point-min))
-         (unless (setq body-start (search-forward "\n\n" (point-max) 1))
-           (error "No message body"))
-
-         (save-restriction
-           ;; Narrow to headers
-           (narrow-to-region (point-min) body-start)
-           (setq x-coding-header (goto-char (point-min)))
-           (if (not (re-search-forward "^X-Coding-System: *\\(.*\\)$" nil t))
-               (setq old-coding (rmail-get-coding-system))
-             (setq old-coding (intern (match-string 1)))
-             (setq x-coding-header (point)))
-           (check-coding-system old-coding)
-           ;; Make sure the new coding system uses the same EOL
-           ;; conversion, to prevent ^M characters from popping up
-           ;; all over the place.
-           (let ((eol-type (coding-system-eol-type old-coding)))
-             (if (numberp eol-type)
-                 (setq coding
-                       (coding-system-change-eol-conversion coding eol-type))))
-           (when (not (coding-system-equal
-                       (coding-system-base old-coding)
-                       (coding-system-base coding)))
-             ;; Rewrite the coding-system header.
-             (goto-char x-coding-header)
-             (if (> (point) (point-min))
-                 (delete-region (line-beginning-position) (point))
-               (forward-line)
-               (insert "\n")
-               (forward-line -1))
-             (insert "X-Coding-System: "
-                     (symbol-name coding))))
-         (rmail-show-message))))))
+  (if (not rmail-enable-mime)
+      (with-current-buffer rmail-buffer
+        (rmail-swap-buffers-maybe)
+        (save-restriction
+         (widen)
+         (let ((msgbeg (rmail-msgbeg rmail-current-message))
+               (msgend (rmail-msgend rmail-current-message))
+               (buffer-read-only nil)
+               body-start x-coding-header old-coding)
+           (narrow-to-region msgbeg msgend)
+           (goto-char (point-min))
+           (unless (setq body-start (search-forward "\n\n" (point-max) 1))
+             (error "No message body"))
+
+           (save-restriction
+             ;; Narrow to headers
+             (narrow-to-region (point-min) body-start)
+             (setq x-coding-header (goto-char (point-min)))
+             (if (not (re-search-forward "^X-Coding-System: *\\(.*\\)$" nil t))
+                 (setq old-coding (rmail-get-coding-system))
+               (setq old-coding (intern (match-string 1)))
+               (setq x-coding-header (point)))
+             (check-coding-system old-coding)
+             ;; Make sure the new coding system uses the same EOL
+             ;; conversion, to prevent ^M characters from popping up
+             ;; all over the place.
+             (let ((eol-type (coding-system-eol-type old-coding)))
+               (if (numberp eol-type)
+                   (setq coding
+                         (coding-system-change-eol-conversion coding eol-type))))
+             (when (not (coding-system-equal
+                         (coding-system-base old-coding)
+                         (coding-system-base coding)))
+               ;; Rewrite the coding-system header.
+               (goto-char x-coding-header)
+               (if (> (point) (point-min))
+                   (delete-region (line-beginning-position) (point))
+                 (forward-line)
+                 (insert "\n")
+                 (forward-line -1))
+               (insert "X-Coding-System: "
+                       (symbol-name coding))))
+           (rmail-show-message))))
+    (user-error
+     (substitute-quotes "`rmail-enable-mime' is non-nil; disable it first"))))
 
 (defun rmail-highlight-headers ()
   "Highlight the headers specified by `rmail-highlighted-headers'.