[Top][All Lists]

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

Re: [Emacs-diffs] master 3431e82: Ignore directory symlinks in directory

From: Lars Magne Ingebrigtsen
Subject: Re: [Emacs-diffs] master 3431e82: Ignore directory symlinks in directory-files-recursively
Date: Fri, 16 Jan 2015 01:08:00 +0100
User-agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (gnu/linux)

Stefan Monnier <address@hidden> writes:

>>> It can avoid calling expand-file-name only to call file-name-directory
>>> (or file-name-nondirectory) right after.
>> It can, but in the use cases I've typically seen, you wouldn't do that,
>> I think?  You'd say `(directory-name-p file)' and then...  something...
> I don't understand what you mean here.  I'm just pointing out that
> calling expand-file-name only to pass the result to the function
> parameter means that this work may be wasted.
> So passing the two parameters separately is a way to be more lazy.

The typical usage (in the callers that call versions of this function
other places in the Emacs tree) seems to be "give me a list of files
matching this regexp".  Making the callers take a separate directory and
leaf name makes the caller do the work of joining those two things up
before anything can be done, so it's more lazy to have the
`directory-files-recursively' do this work.

If there are callers that also want directories, they will have to do
more work, but that extra work is just calling `directory-name-p', which
is a very cheap function.

So I don't really see any advantage to having two parameters in the
callback function.

>>> Can we reduce the number of arguments?
>> That would be nice, but I'm not sure what to remove.  The canonical,
>> that most of the callers use (from the other versions of this function
>> included in various packages in Emacs) is
>> (directory-files-recursively "~/" "~\\'")
>> or something.  And then there are a couple that want the directories,
>> too.  And then there's `file-tree-walk', which is the new thing.
> Exactly: the use cases are varied, so we need a very generic interface.
> I actually find file-tree-walk not too bad in this respect.
>> Uhm...  we could make MATCH be the predicate if it's not a string?
> But we need 2 answers: whether to include the file in the result, and
> whether to recurse.

Er, huhm, yes, I don't know what I was thinking.

Then I don't really see any practical way to reduce the number of
parameters below four.  We could drop INCLUDE-DIRECTORIES, but then the
somewhat handy `(directory-files-recursively "/tmp/foo" "." t)' (to do
`rm r') wouldn't be as handy any more.

>> Right.  But do we have a word for "string that designates either a file
>> or a directory"?
> Yes, we say "a file name".  A directory is a kind of file.

Ok; I'll rename away.

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

reply via email to

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