From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nikolay Kudryavtsev Newsgroups: gmane.emacs.bugs Subject: bug#23650: Use of locate-file for directories is underdocumented Date: Mon, 30 May 2016 01:44:11 +0300 Message-ID: <80ca6c90-0bfa-1cc5-c63f-0dc8a5fee83d@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="------------8D5EED40AAFED0D425151702" X-Trace: ger.gmane.org 1464561929 1292 80.91.229.3 (29 May 2016 22:45:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 29 May 2016 22:45:29 +0000 (UTC) To: 23650@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon May 30 00:45:15 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1b79SK-0002Jt-TF for geb-bug-gnu-emacs@m.gmane.org; Mon, 30 May 2016 00:45:13 +0200 Original-Received: from localhost ([::1]:57134 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b79SK-0002CT-1b for geb-bug-gnu-emacs@m.gmane.org; Sun, 29 May 2016 18:45:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60320) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b79SE-00029q-N8 for bug-gnu-emacs@gnu.org; Sun, 29 May 2016 18:45:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b79SA-0002Tt-Dp for bug-gnu-emacs@gnu.org; Sun, 29 May 2016 18:45:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:34358) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b79SA-0002Tp-Af for bug-gnu-emacs@gnu.org; Sun, 29 May 2016 18:45:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1b79SA-0006QS-68 for bug-gnu-emacs@gnu.org; Sun, 29 May 2016 18:45:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Nikolay Kudryavtsev Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 29 May 2016 22:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 23650 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.146456187724644 (code B ref -1); Sun, 29 May 2016 22:45:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 29 May 2016 22:44:37 +0000 Original-Received: from localhost ([127.0.0.1]:46695 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b79Rl-0006PQ-5s for submit@debbugs.gnu.org; Sun, 29 May 2016 18:44:37 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:41039) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b79Rk-0006PE-4A for submit@debbugs.gnu.org; Sun, 29 May 2016 18:44:36 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b79Rd-0002JR-UO for submit@debbugs.gnu.org; Sun, 29 May 2016 18:44:30 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:59136) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b79Rd-0002Hu-Qx for submit@debbugs.gnu.org; Sun, 29 May 2016 18:44:29 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60239) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b79RZ-00028t-8d for bug-gnu-emacs@gnu.org; Sun, 29 May 2016 18:44:26 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b79RV-0002E3-2h for bug-gnu-emacs@gnu.org; Sun, 29 May 2016 18:44:24 -0400 Original-Received: from mail-lb0-x233.google.com ([2a00:1450:4010:c04::233]:34939) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b79RU-0002Dl-K9 for bug-gnu-emacs@gnu.org; Sun, 29 May 2016 18:44:21 -0400 Original-Received: by mail-lb0-x233.google.com with SMTP id mp7so3220337lbb.2 for ; Sun, 29 May 2016 15:44:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:message-id:date:user-agent:mime-version; bh=H++QgP72YU2hQywSV6iKvmCD8K27Zfc0KxNP6g4yYnw=; b=nBI8rE7iGvQeD/+7NPO5i2BC0Yh9rXzS16imcZWyy7cgvd3htzpnfJtmPvOI+b9kCP wTQCLpuTIii1I1IHsTPqyObXiMQMBFvHIoikueU4PTteoMMNINzCn9OR2en4Pm0Tp7F+ ok6D95ZQ9Ov9OxzHr73VAm/RURlLa3kMrCpYvSzYoEBLSbsaDGpMW7O/Mgf0OK2gs7fN lkC0nA0/9kb2aH0oghGqkdNFgR9Pd4XGriwHA8XW2nKWa1MjpxowxpOttn3QhMg4GE/+ NkwX8WPJ5XIDLZYpSmVhKTjzqBMpGnkBb6iFshNT9CMyODBHb4bag7e1lXj+ucaxjU0e NhhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:message-id:date:user-agent :mime-version; bh=H++QgP72YU2hQywSV6iKvmCD8K27Zfc0KxNP6g4yYnw=; b=TCqAi03IzQajkga9EtB/Y0x02T49nwdAUuH6jJg9ifTlI5YTCGIkp93Me7oh98xE7v WI/aW4wT/e5W9JPOQhibXo+eJUV9O5pe3+SiQZ2ujjg/heFJ5ONfu6yvj/jiXcPLpB/7 23o/nDpA4DviWNY36CkY4WwgjnkQpnG4o4FJyVGeMOwuTx+wzib5v5FRwu6zvb3JgwbY /P2bWUrsaU3bWdc+M1CmiIXs/WuWZmE1TzEmgHKQEKvQGobzOjpqupOGHR/EbiVA216p +9iPXRTVuoyFBMwT4IUmwno+R5XkfEzasZ16oWS/lans20pDDt69XlG+lYO+lLhS/zXB 6TLw== X-Gm-Message-State: ALyK8tKmoP9vHGMWPCz0HN3MM3TXQAK4OoaivrfiyqRu3WN1S0LS784Ryvueban/tVGhVg== X-Received: by 10.112.60.198 with SMTP id j6mr4885520lbr.131.1464561858742; Sun, 29 May 2016 15:44:18 -0700 (PDT) Original-Received: from [192.168.199.2] (broadband-95-84-209-126.nationalcablenetworks.ru. [95.84.209.126]) by smtp.gmail.com with ESMTPSA id 72sm1894918ljj.0.2016.05.29.15.44.17 for (version=TLSv1/SSLv3 cipher=OTHER); Sun, 29 May 2016 15:44:17 -0700 (PDT) X-Google-Original-From: Nikolay Kudryavtsev User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:118843 Archived-At: This is a multi-part message in MIME format. --------------8D5EED40AAFED0D425151702 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit 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 --------------8D5EED40AAFED0D425151702 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit

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
--------------8D5EED40AAFED0D425151702--