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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 23650 in the body.
You can then email your comments to 23650 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#23650; Package emacs. (Sun, 29 May 2016 22:45:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Nikolay Kudryavtsev <nikolay.kudryavtsev <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 29 May 2016 22:45:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Nikolay Kudryavtsev <nikolay.kudryavtsev <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 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)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#23650; Package emacs. (Wed, 31 Jan 2018 03:42:02 GMT) Full text and rfc822 format available.

Message #8 received at 23650 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> users.sourceforge.net>
To: Nikolay Kudryavtsev <nikolay.kudryavtsev <at> gmail.com>
Cc: 23650 <at> debbugs.gnu.org
Subject: Re: bug#23650: Use of locate-file for directories is underdocumented
Date: Tue, 30 Jan 2018 22:40:59 -0500
tags 23650 fixed
close 23650 26.1
quit

Nikolay Kudryavtsev <nikolay.kudryavtsev <at> 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




Added tag(s) fixed. Request was from Noam Postavsky <npostavs <at> users.sourceforge.net> to control <at> debbugs.gnu.org. (Wed, 31 Jan 2018 03:42:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 26.1, send any further explanations to 23650 <at> debbugs.gnu.org and Nikolay Kudryavtsev <nikolay.kudryavtsev <at> gmail.com> Request was from Noam Postavsky <npostavs <at> users.sourceforge.net> to control <at> debbugs.gnu.org. (Wed, 31 Jan 2018 03:42:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 28 Feb 2018 12:24:04 GMT) Full text and rfc822 format available.

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.