Subject: Re: bug#5447: 23.1.91; load-file fails for C:/the-file.el.gz

From: Eli Zaretskii <[email-masked]>
Date: Fri, 22 Jan 2010 12:32:52 +0200

> Date: Fri, 22 Jan 2010 11:01:59 +0200
> From: Eli Zaretskii <[email-masked]>
> Cc: 
> 
>  emacs -Q
>  M-x load-file RET C:/the-file.el.gz RET
> 
> This signals an error: Wrong type argument: consp, nil.  The traceback
> is as follows:
> 
>   Debugger entered--Lisp error: (wrong-type-argument consp nil)
>     jka-compr-load("c:/the-file.el.gz" nil nil t)
>     apply(jka-compr-load ("c:/the-file.el.gz" nil nil t))
>     jka-compr-handler(load "c:/the-file.el.gz" nil nil t)
>     load("c:/the-file.el.gz" nil nil t)
>     load-file("c:/the-file.el.gz")
>     call-interactively(load-file t nil)
>     execute-extended-command(nil)
>     call-interactively(execute-extended-command nil nil)

Fixed with the patch below.  The interesting thing is that
jka-compr-load is not even called if the file is not in the root
directory of a drive.  I will try to look into that now.

Should we perhaps run $TEMP etc. through file-truename when we compute
the value of temporary-file-directory?

2010-01-22  Eli Zaretskii  <[email-masked]>

	* jka-compr.el (jka-compr-load): If load-file is not in
	load-history, try its file-truename version.  (bug#5447)

=== modified file 'lisp/jka-compr.el'
--- lisp/jka-compr.el	2010-01-13 08:35:10 +0000
+++ lisp/jka-compr.el	2010-01-22 10:19:39 +0000
@@ -590,7 +590,14 @@ There should be no more than seven chara
 	  (or nomessage
 	      (message "Loading %s...done." file))
 	  ;; Fix up the load history to point at the right library.
-	  (let ((l (assoc load-file load-history)))
+	  (let ((l (or (assoc load-file load-history)
+		       ;; On MS-Windows, if load-file is in
+		       ;; temporary-file-directory, it will look like
+		       ;; "c:/DOCUME~1/USER/LOCALS~1/foo", whereas
+		       ;; readevalloop will record its truename in
+		       ;; load-history.  Therefore try truename if the
+		       ;; original name is not in load-history.
+		       (assoc (file-truename load-file) load-history))))
 	    ;; Remove .gz and .elc?.
 	    (while (file-name-extension file)
 	      (setq file (file-name-sans-extension file)))