Subject: bug#1853: Trouble with gzipped info files on Windows

From: Eli Zaretskii <[email-masked]>
Date: Sat, 17 Jan 2009 16:05:36 +0200

> Date: Sat, 17 Jan 2009 15:11:14 +0200
> From: Eli Zaretskii <[email-masked]>
> Cc: [email-masked]
> 
> This happened because, on DOS and Windows, file-coding-system-alist
> includes the association `("" . find-buffer-file-type-coding-system)',
> and find-buffer-file-type-coding-system was not ready to see an
> argument whose `car' does not appear to exist because jka-compr
> removed the .gz extension from its name.

Actually, this explains why _visiting_ compressed files might produce
a buffer with ^M characters in it.  The change I made cannot help with
Info files because the buffer name is "*info*" in that case, not
FOO.gz.

After the change, visiting, e.g., emacs-1.gz produces a buffer whose
buffer-file-coding-system is -dos, and there are no ^M characters in
it.  Visiting ccmode-1.gz still produces ^M's (because ccmode-1
includes null characters in the Index node).

> >  2.- Additionally, for info nodes that do NOT contain a Top node:
> > 
> >     cd info
> >     emacs -Q --eval "(progn (set-language-environment \"UTF-8\") (info
> > \"(ccmode)\")"
> >     ;; works OK.
> > 
> >     gzip ccmode*
> >     emacs -Q --eval "(progn (set-language-environment \"UTF-8\") (info
> > \"(ccmode)\")"
> >     ;;  "No such node or anchor: Top"
> 
> This is yet another separate bug: set-language-environment always sets
> default-buffer-file-coding-system to *-unix.  See my other message a
> few minutes ago.

Specifically, I propose the change below for this latter problem.
After that change, visiting compressed files, both regular and Info
files, work correctly for me, both before or after setting a
non-default language environment.

Index: lisp/international/mule-cmds.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/international/mule-cmds.el,v
retrieving revision 1.353
diff -u -r1.353 mule-cmds.el
--- lisp/international/mule-cmds.el	9 Jan 2009 05:01:02 -0000	1.353
+++ lisp/international/mule-cmds.el	17 Jan 2009 14:01:33 -0000
@@ -1936,7 +1936,11 @@
 	 (eol-type (coding-system-eol-type default-buffer-file-coding-system)))
     (when priority
       (set-default-coding-systems
-       (if (memq eol-type '(0 1 2 unix dos mac))
+       ;; Don't use eol-type if default-buffer-file-coding-system is
+       ;; nil, because coding-system-eol-type treats nil as
+       ;; `no-conversion'.
+       (if (and default-buffer-file-coding-system
+		(memq eol-type '(0 1 2 unix dos mac)))
 	   (coding-system-change-eol-conversion default-coding eol-type)
 	 default-coding))
       (setq default-sendmail-coding-system default-coding)