From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: dalanicolai Newsgroups: gmane.emacs.bugs Subject: bug#66542: Fix: locate-dominating-file predicate should receive dir not file Date: Sat, 14 Oct 2023 17:11:18 +0200 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="000000000000726c920607ae96e1" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38846"; mail-complaints-to="usenet@ciao.gmane.io" To: 66542@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Oct 14 17:12:56 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qrgK0-0009ql-1k for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 14 Oct 2023 17:12:56 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qrgJn-0000zt-Q3; Sat, 14 Oct 2023 11:12:43 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qrgJj-0000zj-EF for bug-gnu-emacs@gnu.org; Sat, 14 Oct 2023 11:12:40 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qrgJj-00023t-6K for bug-gnu-emacs@gnu.org; Sat, 14 Oct 2023 11:12:39 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qrgK6-0007FR-Be for bug-gnu-emacs@gnu.org; Sat, 14 Oct 2023 11:13:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: dalanicolai Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 14 Oct 2023 15:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 66542 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.169729632727795 (code B ref -1); Sat, 14 Oct 2023 15:13:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 14 Oct 2023 15:12:07 +0000 Original-Received: from localhost ([127.0.0.1]:50165 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qrgJD-0007EE-0E for submit@debbugs.gnu.org; Sat, 14 Oct 2023 11:12:07 -0400 Original-Received: from lists.gnu.org ([2001:470:142::17]:34366) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qrgJ9-0007Dj-Ty for submit@debbugs.gnu.org; Sat, 14 Oct 2023 11:12:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qrgIg-0008Hq-Is for bug-gnu-emacs@gnu.org; Sat, 14 Oct 2023 11:11:34 -0400 Original-Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qrgIe-000209-Qx for bug-gnu-emacs@gnu.org; Sat, 14 Oct 2023 11:11:34 -0400 Original-Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4060b623e64so19278575e9.0 for ; Sat, 14 Oct 2023 08:11:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697296290; x=1697901090; darn=gnu.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=yM+aiPJd/LqBs0juXWN48fLzO8DVj/ehhNKrx12SXvs=; b=a1lj1qzm9lzXcjkogpJXJsdpr+xT0HBt6JFFKlX91qRihhVgAoSgq4l6+KBcDO7NpE 7C4LfE9E3rraFMREJB5Va5ZoAB4+SXUA7j6mVtPHmhc+B6Fn40GNyDAUhT9dn4jCMEJr amgZU1R2J9Mb1J3vGX5gHzmX/5L8oT5dRRSa1LAG2SPA7meio1c54RcbIAzZMUPz4HTg gdEZaxaSOAPdl0rcsRYaikAmjY4xGk1a47YsXNasUV2fgeUzCseE+qfjJ6vBp0JThpMO gRlF5DFJvvzGpqbs7B3vt3uUtfHz3+MYi/ObxVXMkLRVzuWnrucuLeTKTCuh9+YPULLY MXdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697296290; x=1697901090; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=yM+aiPJd/LqBs0juXWN48fLzO8DVj/ehhNKrx12SXvs=; b=DCpUZYgKfRx1ft0WcwyUQP27p9O6Wb1/K6VR/ZAX7/WGbBkebt06i/juMlHaq/vgPG hJxjzsiS6haf4MOK3rBUaVBNGCNjYMMQzNJgBsxSWl06fV/C8LLOgFJesbJfaQg2qpLk vzD+rurtLdvo1t3Yjcm5TNvbk+r03f2S9LciFKYIRz4dAyMgcWuvxbme5PoVof+Z0rtr YDRqpuhKHxQbSHBMdYV5DrrvVBW4ZH8qqxkkso76YM6jIB7b5JXSEmzf+pzG98yRb2b7 Ff56HHMLfHHL0x1LFVKDCExo9sPmQ6DpEtVZImDwiwdwKD2I1IsKTC0oI63T+68/Lmsi hLug== X-Gm-Message-State: AOJu0Yy7+yIOjmEasUQCj7q9XELPIL6GKI7cL+Vh/JBL7aH5VLZdFOrJ 2wRjBYbE7MlCgDjgWLwkMKuATsItnl6efomm9yxSMmXxVdFy1g== X-Google-Smtp-Source: AGHT+IFVuom5lGPNvYYYXlRb9HwOb7N3Whb54xla3XVDS/zSRZYWNUg2440BX/7y2arOaI4FKbSEN1w8bGYBB1pwLTE= X-Received: by 2002:a05:600c:1c8d:b0:401:c8b9:4b86 with SMTP id k13-20020a05600c1c8d00b00401c8b94b86mr2243191wms.9.1697296290035; Sat, 14 Oct 2023 08:11:30 -0700 (PDT) Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=dalanicolai@gmail.com; helo=mail-wm1-x336.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:272431 Archived-At: --000000000000726c920607ae96e1 Content-Type: multipart/alternative; boundary="000000000000726c910607ae96df" --000000000000726c910607ae96df Content-Type: text/plain; charset="UTF-8" Tags: patch Tags: patch The docstring of 'locate-dominating-file' mentions that its NAME argument should be a dir, but currently it simply receives the FILE argument. Therefore, using the function e.g. with the following predicate for NAME (lambda (dir) (seq-filter (apply-partially #'string-match-p "paint") (directory-files dir))) to check if a directory contains a file regexp-matching 'paint', throws an error: (file-error "Opening directory" "Not a directory" "/home/...") This patch simply wraps the FILE argument in the (funcall NAME FILE) with a 'file-name-directory' thereby fixing the function. The commit log entry could read: FIX: ensure that locate-dominating-file predicate recives dir In GNU Emacs 29.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, cairo version 1.17.8) of 2023-08-09 built on 2a02-a45d-af56-1-666c-72af-583a-b92d.fixed6.kpn.net Repository revision: 31cef9a4eac01fff5ff4fcb89d7e2b7815e93bad Repository branch: HEAD System Description: Fedora Linux 38 (Workstation Edition) Configured using: 'configure --with-tree-sitter --with-modules --with-cairo --with-native-compilation --with-json --with-pgtk' --000000000000726c910607ae96df Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Tags: patch

Tags: patch

The docstring of = 9;locate-dominating-file' mentions that its NAME argument
should be = a dir, but currently it simply receives the FILE
argument. Therefore, us= ing the function e.g. with the following predicate for NAME

(lambda = (dir)
(seq-filter (apply-partially #'string-ma= tch-p "paint")
(directory-files dir)))

to check if a directory contains a fil= e regexp-matching 'paint', throws
an error:

(file-error &= quot;Opening directory" "Not a directory" "/home/...&qu= ot;)

This patch simply wraps the FILE argument in the (funcall NAME = FILE) with
a 'file-name-directory' thereby fixing the function.<= br>
The commit log entry could read:
FIX: ensure that locate-dominati= ng-file predicate recives dir


In GNU Emacs 29.1 (build 1, x86_64= -pc-linux-gnu, GTK+ Version 3.24.38,
=C2=A0cairo version 1.17.8) of 2023= -08-09 built on
=C2=A02a02-a45d-af56-1-666c-72af-583a-b92d.fixed6.kpn.net
Repository revision: 31cef9a4eac01fff5ff4fcb89d7e2b7815e93bad
Repos= itory branch: HEAD
System Description: Fedora Linux 38 (Workstation Edit= ion)

Configured using:
=C2=A0'configure --with-tree-sitter --= with-modules --with-cairo
=C2=A0--with-native-compilation --with-json --= with-pgtk'
--000000000000726c910607ae96df-- --000000000000726c920607ae96e1 Content-Type: application/octet-stream; name=locate-dominating-file-patch Content-Disposition: attachment; filename=locate-dominating-file-patch Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_lnq6dgio0 ZGlmZiAtLWdpdCBhL2xpc3AvZmlsZXMuZWwgYi9saXNwL2ZpbGVzLmVsCmluZGV4IGUxNDIxYjQw M2JmLi4xOWM4OGU1YmM4YSAxMDA2NDQKLS0tIGEvbGlzcC9maWxlcy5lbAorKysgYi9saXNwL2Zp bGVzLmVsCkBAIC0xMTM4LDcgKzExMzgsNyBAQCBsb2NhdGUtZG9taW5hdGluZy1maWxlCiAgICAg ICAoc2V0cSB0cnkgKGlmIChzdHJpbmdwIG5hbWUpCiAgICAgICAgICAgICAgICAgICAgIChhbmQg KGZpbGUtZGlyZWN0b3J5LXAgZmlsZSkKICAgICAgICAgICAgICAgICAgICAgICAgICAoZmlsZS1l eGlzdHMtcCAoZXhwYW5kLWZpbGUtbmFtZSBuYW1lIGZpbGUpKSkKLSAgICAgICAgICAgICAgICAg IChmdW5jYWxsIG5hbWUgZmlsZSkpKQorICAgICAgICAgICAgICAgICAgKGZ1bmNhbGwgbmFtZSAo ZmlsZS1uYW1lLWRpcmVjdG9yeSBmaWxlKSkpKQogICAgICAgKGNvbmQgKHRyeSAoc2V0cSByb290 IGZpbGUpKQogICAgICAgICAgICAgKChlcXVhbCBmaWxlIChzZXRxIGZpbGUgKGZpbGUtbmFtZS1k aXJlY3RvcnkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoZGlyZWN0b3J5 LWZpbGUtbmFtZSBmaWxlKSkpKQo= --000000000000726c920607ae96e1--