unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: Michael Albinus <michael.albinus@gmx.de>
Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org
Subject: Re: master e315544: ; * src/fileio.c (Fdirectory_append): Doc fix.
Date: Sun, 25 Jul 2021 07:19:12 +0200	[thread overview]
Message-ID: <87wnpfynqn.fsf@gnus.org> (raw)
In-Reply-To: <87zgubmt3z.fsf@gmx.de> (Michael Albinus's message of "Sat, 24 Jul 2021 21:04:00 +0200")

Michael Albinus <michael.albinus@gmx.de> writes:

> It's rather a nice to have. Sometimes, I have a list of file name
> fragments, and I hope to avoid the checks for being non-empty strings
> ...
>
> But I can do this in my code.

Thinking about it a bit more, I can see use cases where ignoring nil/""
would be useful (without making the function less difficult to reason
about).  (And it's analogous to `concat', besides.)  So I think I'll go
ahead and make that change...

>>> Furthermore, we have
>>>
>>> (directory-append "foo/" "/bar") => "foo//bar"
>>>
>>> I would expect "foo/bar", meaning that all leading slashes in COMPONENTS
>>> are removed.
>>
>> Well, I think that's over into DWIM-land again (which is what
>> expand-file-name does, and this function deliberately doesn't do).
>
> expand-file-name and file-name-as-directory are functions which call a
> handler, for example Tramp. directory-append is much cheaper, and if it
> could do this string handling, I could avoid those functions. It would
> be more performant.

The reason `directory-append' is useful as a function at all (instead of
just using `concat') is that we're very vague about the difference
between a directory name and a file name in Emacs.  That is, we treat
"/tmp/" and "/tmp" as equivalent in more than 99% of cases when dealing
with directories.  This has naturally led to people setting
`foo-directory' variables etc to something ending with a slash or not
arbitrarily, which again means that you can't just use `concat' to
construct file names.

But "/bar.txt" does not happen naturally as a leaf file name, so I think
it'd be counter-productive to have `directory-append' do anything
particular about the start of file name components.

By the way -- I'm not sure that `directory-append' is the best function
name here...  `file-name-concat' would perhaps be more natural?  But
it's really about directories...  `directory-name-concat'?  Hm.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



  reply	other threads:[~2021-07-25  5:19 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210724171858.1726.43078@vcs0.savannah.gnu.org>
     [not found] ` <20210724171900.4A26D20D0A@vcs0.savannah.gnu.org>
2021-07-24 18:39   ` master e315544: ; * src/fileio.c (Fdirectory_append): Doc fix Michael Albinus
2021-07-24 18:51     ` Lars Ingebrigtsen
2021-07-24 19:04       ` Michael Albinus
2021-07-25  5:19         ` Lars Ingebrigtsen [this message]
2021-07-25  5:27           ` Stefan Monnier
2021-07-25  6:54             ` Lars Ingebrigtsen
2021-07-25 10:01               ` Kévin Le Gouguec
2021-07-25 10:23                 ` Lars Ingebrigtsen
2021-07-25 11:50                 ` Andreas Schwab
2021-07-25 13:05                   ` Kévin Le Gouguec
2021-07-28 15:39                     ` Lars Ingebrigtsen
2021-07-28 17:28                       ` Michael Albinus
2021-07-30 11:36                         ` Lars Ingebrigtsen
2021-07-25  7:59           ` Michael Albinus
2021-07-28 15:36             ` Lars Ingebrigtsen
2021-07-28 17:13               ` Michael Albinus

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=87wnpfynqn.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=michael.albinus@gmx.de \
    /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).