# HG changeset patch # User Eli Zaretskii # Date 1000626919 0 # Node ID 2b67bb3275f8d5dd55fc353675b701c6329cbbaa # Parent aff361cfdccb85bc80db81f40c5d1f5cb6c678a5 (top-level): Require mule-utils when compiling. (rmail-decode-babyl-format): Use detect-coding-with-priority instead of detect-coding-region, to favor detection of emacs-mule encoded Babyl files written by rmailout.el etc. Suggested by Kenichi Handa . diff -r aff361cfdccb -r 2b67bb3275f8 lisp/mail/rmail.el --- a/lisp/mail/rmail.el Sat Sep 15 08:00:07 2001 +0000 +++ b/lisp/mail/rmail.el Sun Sep 16 07:55:19 2001 +0000 @@ -40,6 +40,7 @@ ;; (require 'mail-utils) +(eval-when-compile (require 'mule-util)) ; for detect-coding-with-priority ; These variables now declared in paths.el. ;(defvar rmail-spool-directory "/usr/spool/mail/" @@ -621,7 +622,7 @@ (rmail-require-mime-maybe) (let* ((file-name (expand-file-name (or file-name-arg rmail-file-name))) (existed (get-file-buffer file-name)) - ;; This binding is necessary because we much decide if we + ;; This binding is necessary because we must decide if we ;; need code conversion while the buffer is unibyte ;; (i.e. enable-multibyte-characters is nil). (rmail-enable-multibyte @@ -772,7 +773,16 @@ (setq to (point)) (unless (and coding-system (coding-system-p coding-system)) - (setq coding-system (detect-coding-region from to t))) + (setq coding-system + ;; Emacs 21.1 and later writes RMAIL files in emacs-mule, but + ;; earlier versions did that with the current buffer's encoding. + ;; So we want to favor detection of emacs-mule (whose normal + ;; priority is quite low), but still allow detection of other + ;; encodings if emacs-mule won't fit. The call to + ;; detect-coding-with-priority below achieves that. + (car (detect-coding-with-priority + from to + '((coding-category-emacs-mule . emacs-mule)))))) (unless (memq coding-system '(undecided undecided-unix)) (set-buffer-modified-p t) ; avoid locking when decoding