From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#27798: Documentation of locate-dominating-file is wrong Date: Sun, 23 Jul 2017 18:20:20 +0300 Message-ID: <83bmob89jf.fsf@gnu.org> References: <4e10c630-ed42-8204-815a-384b911bb645@live.com> <83k22z8bs8.fsf@gnu.org> <904757d6-ff93-a543-aa0d-770ddf6a5f22@live.com> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1500823278 2491 195.159.176.226 (23 Jul 2017 15:21:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 23 Jul 2017 15:21:18 +0000 (UTC) Cc: 27798@debbugs.gnu.org To: =?UTF-8?Q?Cl=C3=A9ment?= Pit--Claudel Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jul 23 17:21:12 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dZIgt-0008Qq-0q for geb-bug-gnu-emacs@m.gmane.org; Sun, 23 Jul 2017 17:21:07 +0200 Original-Received: from localhost ([::1]:50731 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZIgy-0005zu-Mq for geb-bug-gnu-emacs@m.gmane.org; Sun, 23 Jul 2017 11:21:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43446) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZIgs-0005zd-7Y for bug-gnu-emacs@gnu.org; Sun, 23 Jul 2017 11:21:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dZIgo-000150-79 for bug-gnu-emacs@gnu.org; Sun, 23 Jul 2017 11:21:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:50903) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dZIgo-00014w-43 for bug-gnu-emacs@gnu.org; Sun, 23 Jul 2017 11:21:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dZIgn-0006IK-RU for bug-gnu-emacs@gnu.org; Sun, 23 Jul 2017 11:21:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 23 Jul 2017 15:21:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27798 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 27798-submit@debbugs.gnu.org id=B27798.150082323624155 (code B ref 27798); Sun, 23 Jul 2017 15:21:01 +0000 Original-Received: (at 27798) by debbugs.gnu.org; 23 Jul 2017 15:20:36 +0000 Original-Received: from localhost ([127.0.0.1]:53580 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dZIgO-0006HW-CY for submit@debbugs.gnu.org; Sun, 23 Jul 2017 11:20:36 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:52395) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dZIgK-0006HG-Sg for 27798@debbugs.gnu.org; Sun, 23 Jul 2017 11:20:35 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dZIgB-0000tC-K3 for 27798@debbugs.gnu.org; Sun, 23 Jul 2017 11:20:27 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:58002) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZIgB-0000sz-GM; Sun, 23 Jul 2017 11:20:23 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:2008 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1dZIgA-0004hY-TF; Sun, 23 Jul 2017 11:20:23 -0400 In-reply-to: <904757d6-ff93-a543-aa0d-770ddf6a5f22@live.com> (message from =?UTF-8?Q?Cl=C3=A9ment?= Pit--Claudel on Sun, 23 Jul 2017 16:52:51 +0200) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] 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:134888 Archived-At: > Cc: 27798@debbugs.gnu.org > From: Clément Pit--Claudel > Date: Sun, 23 Jul 2017 16:52:51 +0200 > > > Actually, FILE _must_ be a directory, because the function does this: > > > > (setq try (if (stringp name) > > (file-exists-p (expand-file-name name file)) > > ^^^^^^^^^^^^^^^^^^^^^^^^^^ > > Ouch. This is a problem, because I'm not the only one who assumed that this had to be a file and not a directory. There are instances of locate-dominating-file being called with file-name in vc, trampver, yasnippet, company, flycheck, proof-general, etc. Github finds 35k matches for (locate-dominating-file buffer-file-name) (https://github.com/search?q=%28locate-dominating-file+buffer-file-name&type=Code&utf8=%E2%9C%93). buffer-file-name could be a directory, couldn't it? But anyway, calling this function with a non-directory file just wastes one iteration through the loop, so perhaps the situation is not as bad as my original response made it sound. > > It's possible that "directory hierarchy from FILE" doesn't convey that > > clearly enough, in which case we could add > > > > FILE should be a directory. > > Yes, this would be great. It would probably be more accurate if we said FILE can be a directory.