[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#27798: Documentation of locate-dominating-file is wrong
From: |
Clément Pit--Claudel |
Subject: |
bug#27798: Documentation of locate-dominating-file is wrong |
Date: |
Sun, 23 Jul 2017 11:49:36 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 |
The docs of locate-dominating-file say this:
(locate-dominating-file FILE NAME)
Look up the directory hierarchy from FILE for a directory containing NAME.
Stop at the first parent directory containing a file NAME,
and return the directory. Return nil if not found.
Instead of a string, NAME can also be a predicate taking one argument
(a directory) and returning a non-nil value if that directory is the one for
which we’re looking.
This part is wrong, because locate-dominating-file also accepts directories:
Look up the directory hierarchy from FILE
This part is wrong, because the predicate is called with the initial file name,
too:
NAME can also be a predicate taking one argument (a directory)
Indeed, the following form:
(locate-dominating-file "/usr/local/bin/emacs" (lambda (x) (ignore (message
"%s" x))))
prints this:
/usr/local/bin/emacs
/usr/local/bin/
/usr/local/
/usr/
/
(not the file name passed into the first call.
I think the fix is to update the docs in both places, as there might be callers
relying on the existing behavior. It's important to also document that passing
a directory name is OK, though, because that's the only way to use
locate-dominating-file reliably with a directory-only predicate — otherwise,
the predicate needs to handle both files and folders.
Cheers,
Clément.
signature.asc
Description: OpenPGP digital signature
- bug#27798: Documentation of locate-dominating-file is wrong,
Clément Pit--Claudel <=