[RESEND- orig has not shown up in
xemacs.org archives after 48 hours..]
I tried to set file-coding-alist to have all files under a certain
directory be raw-text-dos. It worked at first, but then consistently
failed and set all the files to raw-text-unix instead.
Eventually realized that it worked until dired was loaded. When dired
is loaded insert-file-contents recurses on itself (via
insert-file-contents-internal and dired-handler-fn). Something about
this recursion messes up coding-system detection.
Repros for me using 21.5.27 on unix, osx, and cygwin.
Place the following lisp into a file called "bug.el", then:
$ cat /etc/termcap > data
$ xemacs -q -l bug.el -f with-dired -- bad
$ xemacs -q -l bug.el -f without-dired -- good
coding system in *Message-Log* should be raw-text-dos at end. In
'with-dired' case it is raw-text-unix.
---cut--here---
;; causes "insert-file-contents" to be called 2x via recursion
;; insert-file-contents calls insert-file-contents-internal calls
;; (somehow) dired-handler-fn which calls insert-file-contents
(defun with-dired ()
(message "TEST-WITH-DIRED-LOADED")
(require 'dired)
(find-file ".")
(find-file "./data")
(message "CODING SYSTEM: %s" buffer-file-coding-system)
(switch-to-buffer-other-window " *Message-Log*")
)
(defun without-dired ()
(message "TEST-WITHOUT-DIRED")
(find-file "./data")
(message "CODING SYSTEM: %s" buffer-file-coding-system)
(switch-to-buffer-other-window " *Message-Log*")
)
(add-to-list 'file-coding-system-alist '("data" raw-text-dos) t)
---cut--here---
In without-dired case, the calling sequence looks like:
insert-file-contents
insert-file-contents-internal
But in with-dired case it looks like this:
insert-file-contents
insert-file-contents-internal (rtns nil **)
insert-file-contents
insert-file-contents-internal (rtns 'raw-text-dos)
Somehow dired-handler-fn is involved in the recursion, but I don't quite
understand it.
The innermost call to insert-file-contents seems to do the right
thing, but the outer one returns nil which is used to overwrite
coding-system in this line:
(setq coding-system used-codesys)
Changing it to:
(if used-codesys)
(setq coding-system used-codesys))
Seems to fix it...
Also, I was concerned that the file was actually being read 2 times, but
strace seems to indicate that is not happening.
Attaching a version of insert-file-contents with lots of message's
added.
--
--tony
_______________________________________________
XEmacs-Beta mailing list
XEmacs-Beta(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-beta