Subject: Re: bug#30755: 25.3; Encoding of load-file-name wrong when path to working dir does not contain accented letter

From: Eli Zaretskii <[email-masked]>
Date: Sun, 11 Mar 2018 18:09:35 +0200

> From: Márton Marczell <[email-masked]>
> Date: Fri, 9 Mar 2018 22:41:12 +0100
> 
> > How is load-file-name of the package's .el file related to its inability to load images?
> 
> It loads images like this:
> 
> (defconst neo-dir
>   (expand-file-name (if load-file-name
>                         (file-name-directory load-file-name)
>                       default-directory)))
> ;…
> (defun neo-buffer--get-icon (name)
>   "Get image by NAME."
>   (let ((icon-path (neo-path--join neo-dir "icons"))
>         image)
>     (setq image (create-image
>                  (neo-path--join icon-path (concat name ".xpm"))
>                  'xpm nil :ascent 'center :mask '(heuristic t)))
>     image))
> 
> So the (wrongly encoded) load-file-name path is used to build the path to the image assets. Which makes image loading fail with the error
> Cannot find image file ‘c:/Users/M rton/AppData/Roaming/.emacs.d/elpa/neotree-0.5.2/icons/leaf.xpm’
> 
> > Also, can you please provide a recipe that takes neotree.el out of the
> > equation?  AFAIU, it should be enough to have a .el file that is
> > loaded in .emacs, and have the contents of that file be just
> >   (print load-file-name)
> > Is that correct?
> 
> Yes that is correct.

OK, thanks.

I tried reproducing this problem, but failed.  I guess there are still
important details of the situation that are missing from the
description.  One detail that might be important is how exactly do you
load neotree.el from your init file.  In my reproduction attempt, I
just created a .emacs file with only one line:

  (load "~/foo/foo.el")

where foo.el had this single line:

   (print load-file-name)

This produced the correct file name in the *Messages* buffer when
Emacs was started from a directory that had no non-ASCII characters,
while the home directory did include non-ASCII characters, which I
believe is your case.

Please provide a full description of how you load your file, and
preferably also try reproducing the problem with a simple setup such
as what I used above (modified to match the exact way you load
neotree.el in the real-life use case), and see if you succeed
reproducing it.

Also, if you repeat your original use case, but before starting Emacs
set HOME=c:\Users\Márton\AppData\Roaming in the environment of the
shell from which you invoke Emacs, does the problem reproduce itself?
(Btw, is the shell from which you start Emacs the stock Windows shell
cmd.exe or something else?)

And finally, please keep the bug address on the CC list of your
responses, so that this discussion gets recorded by the bug tracker.

Thanks.