unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: emacs-devel@gnu.org
Subject: Re: expand-file-name, DOS/Windows, and directory separator
Date: Tue, 15 Feb 2022 12:46:43 -0800	[thread overview]
Message-ID: <87k0dvdfik.fsf@ericabrahamsen.net> (raw)
In-Reply-To: 83mtir3mjy.fsf@gnu.org

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Eric Abrahamsen <eric@ericabrahamsen.net>
>> Date: Tue, 15 Feb 2022 12:15:08 -0800
>> 
>> >> (file-name-split (expand-file-name <file> "/"))
>> >
>> > file-name-split is one of the functions that support both styles of
>> > slashes, so you don't need to call expand-file-name at all.  (And "/"
>> > is not really an absolute file name on Windows anyway).
>> 
>> The `expand-file-name' is in there to collapse multiple consecutive
>> directory separators, which happens in the wild, as `file-name-split'
>> doesn't do that by itself.
>
> Then do call expand-file-name, but you don't need to assume anything
> about slashes in the result.

Got it.

>> Just running this, where I've doubled the slashes so as not to raise
>> an error:
>> 
>> (file-name-split "C:\\Users\\eric\\random")
>> 
>> Just returns the whole string.
>
> I bet you did that on Unix?  Because here on MS-Windows it returns the
> expected
>
>    ("" "Users" "eric" "random")

As I was hoping it would! But yes, I only have unix-like boxes to test
on.

>> This code has to handle all the weirdness of different systems and
>> filesystem layouts and search engines, so I'm being a little paranoid
>> about it.
>
> You don't need to be paranoid.  Emacs's file-name related primitives
> are supposed to handle file names on all the supported systems;
> anything else is a bug that should be fixed.

Ignorance breeds magical thinking :) Thanks for the reassurance, I'll go
ahead and update this.




  reply	other threads:[~2022-02-15 20:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-15 17:59 expand-file-name, DOS/Windows, and directory separator Eric Abrahamsen
2022-02-15 18:38 ` Stefan Monnier
2022-02-15 19:39   ` Eric Abrahamsen
2022-02-15 19:57     ` Eli Zaretskii
2022-02-15 20:15       ` Eric Abrahamsen
2022-02-15 20:24         ` Eli Zaretskii
2022-02-15 20:46           ` Eric Abrahamsen [this message]
2022-02-15 21:51             ` Stefan Monnier
2022-02-15 23:03               ` Eric Abrahamsen
2022-02-15 19:15 ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k0dvdfik.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).