Subject: Re: 23.1: reverting fails to update line ending mode line

From: Chong Yidong <[email-masked]>
Date: Sat, 13 Nov 2010 17:27:18 -0500

> - Start emacs -Q .
> - C-x C-f ~/foo.txt, creating a new file.
> - Enter text:
> Line 1
> Line 2
>
> - C-x C-s.
> - dos2unix ~/foo.txt
> - M-x revert-buffer
> - C-x k RET
> - C-x C-f ~/foo.txt
> Mode line shows --(Unix)---

The problem is that `C-x C-s' sets buffer-file-coding-system-explicit.
This causes revert-buffer to set coding-system-for-read to that value
(which is now incorrect) when inserting the file contents.  This is why
the revert goes correctly if you omit the `C-x C-s' step.

I think the use of buffer-file-coding-system-explicit in revert-buffer
is bogus, and should be removed---see below.  What do you think?

*** lisp/files.el	2010-11-11 22:19:01 +0000
--- lisp/files.el	2010-11-13 22:22:01 +0000
***************
*** 4906,4916 ****
  		   (let ((coding-system-for-read
  			  ;; Auto-saved file should be read by Emacs'
  			  ;; internal coding.
! 			  (if auto-save-p 'auto-save-coding
! 			    (or coding-system-for-read
! 				(and
! 				 buffer-file-coding-system-explicit
! 				 (car buffer-file-coding-system-explicit))))))
  		     (if (and (not enable-multibyte-characters)
  			      coding-system-for-read
  			      (not (memq (coding-system-base
--- 4906,4914 ----
  		   (let ((coding-system-for-read
  			  ;; Auto-saved file should be read by Emacs'
  			  ;; internal coding.
! 			  (if auto-save-p
! 			      'auto-save-coding
! 			    coding-system-for-read)))
  		     (if (and (not enable-multibyte-characters)
  			      coding-system-for-read
  			      (not (memq (coding-system-base