GNU bug report logs - #23650
Use of locate-file for directories is underdocumented

Previous Next

Package: emacs;

Reported by: Nikolay Kudryavtsev <nikolay.kudryavtsev <at> gmail.com>

Date: Sun, 29 May 2016 22:45:02 UTC

Severity: minor

Tags: fixed

Fixed in version 26.1

Done: Noam Postavsky <npostavs <at> users.sourceforge.net>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Nikolay Kudryavtsev <nikolay.kudryavtsev <at> gmail.com>
To: 23650 <at> debbugs.gnu.org
Subject: bug#23650: Use of locate-file for directories is underdocumented
Date: Mon, 30 May 2016 01:44:11 +0300
[Message part 1 (text/plain, inline)]
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

[Message part 2 (text/html, inline)]

This bug report was last modified 7 years and 116 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.