bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#24387: 25.1.50; w32-convert-standard-filenames no longer works


From: Eli Zaretskii
Subject: bug#24387: 25.1.50; w32-convert-standard-filenames no longer works
Date: Wed, 07 Sep 2016 17:26:31 +0300

retitle 24387 w32-convert-standard-filenames no longer mirrors slashes
thanks

> From: Richard Copley <rcopley@gmail.com>
> Date: Wed, 7 Sep 2016 10:52:32 +0100
> 
> commit 438b98e5b70c55129453870b870a139c4a4a77fd
> Author: Eli Zaretskii <address@hidden>
> Date:   Mon Apr 25 11:50:37 2016 +0300
> 
>     Don't mirror slashes in convert-standard-filename on MS-Windows
> 
>     * lisp/w32-fns.el (w32-convert-standard-filename): Don't mirror
>     slashes into backslashes.  This avoids producing ugly file names,
>     and is deemed no longer necessary, and should certainly be
>     unrelated to which shell is in use.
> 
> I for one /did/ use filenames created by this function in shell
> commands.

Why did you do that?  It's a mistake: that function's purpose is
entirely different, as the ELisp manual documents:

  24.8.7 Standard File Names
  --------------------------

  Sometimes, an Emacs Lisp program needs to specify a standard file name
  for a particular use—typically, to hold configuration data specified by
  the current user.
  [...]
     A lower-level function for standardizing file names, which
  ‘locate-user-emacs-file’ uses as a subroutine, is
  ‘convert-standard-filename’.

   -- Function: convert-standard-filename filename
       This function returns a file name based on FILENAME, which fits the
       conventions of the current operating system.
  [...]
       The recommended way to use this function is to specify a name which
       fits the conventions of GNU and Unix systems, and pass it to
       ‘convert-standard-filename’.

IOW, this function is for Lisp programs that need to specify a fixed
standardized file name.  It has no relation whatsoever to shell
commands.

> It was explicitly documented that it would work,
> and it still is (see the docstring for `convert-standard-filename').

Oops!  Will fix, thanks.

> Now I need to take time out to roll my own version and review
> all my callers

Do you really need to mirror slashes in shell commands?  Most Windows
applications understand forward slashes just fine.  What problems do
you have with forward slashes in shell commands on MS-Windows?

> Please will you change it back?

That would bring back the ugliness I fixed by the commit in question.
And the use case for which you want the feature is simply wrong, you
are not supposed to use convert-standard-filename for such purposes.

> If not, when that docstring gets fixed, can it document what people
> should use instead?

I'm not sure what to say in the doc string.  On the one hand, the
function is not to be used in preparation of shell commands, so
talking about shell commands there would be wrong, IMO.  OTOH,
replacing one character with another is a trivial operation in Emacs,
something like

        (setq start 0)
        (while (string-match "/" name start)
          (aset name (match-beginning 0) ?\\)
          (setq start (match-end 0))))

should be all you need.

I could add the above snippet to the NEWS entry that announces the
change; would that be good enough?





reply via email to

[Prev in Thread] Current Thread [Next in Thread]