unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#23650: Use of locate-file for directories is underdocumented
@ 2016-05-29 22:44 Nikolay Kudryavtsev
  2018-01-31  3:40 ` Noam Postavsky
  0 siblings, 1 reply; 2+ messages in thread
From: Nikolay Kudryavtsev @ 2016-05-29 22:44 UTC (permalink / raw)
  To: 23650

[-- Attachment #1: Type: text/plain, Size: 853 bytes --]

Hello.

Let's say I have a list of folders A, B, C. I want to find which one of 
them contains subfolder D.

My first idea was using locate-file. While doing so I've found that the 
Elisp reference for it is incomplete and confusing:

1. According to the docstring it would only return a directory if 
PREDICATE returns 'dir-ok. This is not mentioned in the Elisp reference.

2. The reference suggests file-directory-p as a useful predicate and 
this would fail due to 1.

3. It's probably a good idea to mention that there are no bundled 
predicates that return dir-ok, and suggest to use a lamda like this: 
(lambda (f) (and (file-directory-p f) 'dir-ok)) as a PREDICATE.


Here's a working example, just in case:

(locate-file "Git" '("c:/Program Files/") nil (lambda (f) (and 
(file-directory-p f) 'dir-ok)))

-- 
Best Regards,
Nikolay Kudryavtsev


[-- Attachment #2: Type: text/html, Size: 1214 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#23650: Use of locate-file for directories is underdocumented
  2016-05-29 22:44 bug#23650: Use of locate-file for directories is underdocumented Nikolay Kudryavtsev
@ 2018-01-31  3:40 ` Noam Postavsky
  0 siblings, 0 replies; 2+ messages in thread
From: Noam Postavsky @ 2018-01-31  3:40 UTC (permalink / raw)
  To: Nikolay Kudryavtsev; +Cc: 23650

tags 23650 fixed
close 23650 26.1
quit

Nikolay Kudryavtsev <nikolay.kudryavtsev@gmail.com> writes:

> 1. According to the docstring it would only return a directory if
> PREDICATE returns 'dir-ok. This is not mentioned in the Elisp
> reference.
>
> 2. The reference suggests file-directory-p as a useful predicate and
> this would fail due to 1.
>
> 3. It's probably a good idea to mention that there are no bundled
> predicates that return dir-ok, and suggest to use a lamda like this:
> (lambda (f) (and (file-directory-p f) 'dir-ok)) as a PREDICATE.
>
>
> Here's a working example, just in case:
>
> (locate-file "Git" '("c:/Program Files/") nil (lambda (f) (and
> (file-directory-p f) 'dir-ok)))

Added a clarifiction and a similar example (though not one with w32
path) in emacs-26.

[1: f706c59093]: 2018-01-30 22:14:02 -0500
  Update manual description of locate-file (Bug#23650)
  https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=f706c59093645a6306dd907833d597884e69c0ac





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-01-31  3:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-29 22:44 bug#23650: Use of locate-file for directories is underdocumented Nikolay Kudryavtsev
2018-01-31  3:40 ` Noam Postavsky

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).