From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#50240: 28.0.50; incorrect handling of ignore files in project-files Date: Mon, 30 Aug 2021 05:22:40 +0300 Message-ID: <960e4fe3-4da6-fff6-0bde-799ad4e0265f@yandex.ru> References: <87r1edpl4f.fsf@omarpolo.com> <87wno48w9d.fsf@omarpolo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32396"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 Cc: 50240@debbugs.gnu.org To: Omar Polo Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Aug 30 04:23:11 2021 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 1mKWx5-0008Di-5i for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 30 Aug 2021 04:23:11 +0200 Original-Received: from localhost ([::1]:36386 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mKWx3-0006Ag-8O for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 29 Aug 2021 22:23:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43668) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mKWww-0006AY-L8 for bug-gnu-emacs@gnu.org; Sun, 29 Aug 2021 22:23:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46308) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mKWww-0007rr-AX for bug-gnu-emacs@gnu.org; Sun, 29 Aug 2021 22:23:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mKWwv-0007JS-Vc for bug-gnu-emacs@gnu.org; Sun, 29 Aug 2021 22:23:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 30 Aug 2021 02:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50240 X-GNU-PR-Package: emacs Original-Received: via spool by 50240-submit@debbugs.gnu.org id=B50240.163029017028080 (code B ref 50240); Mon, 30 Aug 2021 02:23:01 +0000 Original-Received: (at 50240) by debbugs.gnu.org; 30 Aug 2021 02:22:50 +0000 Original-Received: from localhost ([127.0.0.1]:57854 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mKWwj-0007Iq-L2 for submit@debbugs.gnu.org; Sun, 29 Aug 2021 22:22:49 -0400 Original-Received: from mail-wr1-f49.google.com ([209.85.221.49]:34398) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mKWwi-0007Id-3K for 50240@debbugs.gnu.org; Sun, 29 Aug 2021 22:22:48 -0400 Original-Received: by mail-wr1-f49.google.com with SMTP id h13so20268608wrp.1 for <50240@debbugs.gnu.org>; Sun, 29 Aug 2021 19:22:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=/piyI8RRNyPL7BSKXlHCbkz9lRDq5m4+yEDdSSiwbLM=; b=pNaQD7g/wZ9zFNPLVB8P8Q6aewU0Yvc5EaAMlNNR0Hye+4Kh5y1oG5EPSxV1MLE3+d e+Kj9k3BAex7LPj5JB6glb8QKByv7cCC4uA45JDwjWdoVhaKe8zNzjs0d7c0uHna8BO7 7My4FC+8sC2JFmGD6piH9Zum7AaZ2Anbecg03MwgzbTvaBvYFMhFuiSoq5DFDXvNTCL5 /kJLiHkr/9q+YZHxhHsTNIsNqt6durdlMDk5QfTrgR6AfNn0MBcfDlDNVZSqISBLc2Km 2lo4vGd+SZo7MpD7WIgKfmzveUiKsCz3BbmZ2vPGWR1jWPk6e5f8zSoxLUaQNywu2ygW 7STQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=/piyI8RRNyPL7BSKXlHCbkz9lRDq5m4+yEDdSSiwbLM=; b=sXC8pTCByY+pDVhd7CMvV7H1aG6U/irrdrVsmL+E2S/sY9HuQkZIgxnUmI68BZb58b V5aOZZrZZZP4ZEWrmqaDuA+A+JVr1L/hfnR1ZR5usK11hcL9sSK2HtrVZUAHRP8yjdML zvYsK0pPa7fJXX4ouuoj1J/nyZTGpdn7FY6gU0ieQp8Zz2DXxA3q9eQ1pq0CFY86V3Tj DkLmyyrBo5kkKEurLVdtiJd+K6hg1oiHMkC9VwN+SagQFvQqz/KNfyPsyGrMcZ8pL0X8 AdZmb0x2+9CNcVeZzKewiWRX4+4accNEk4Q9C3jtz2/p3VeWF3KRDe83APC2ZgEgb7BD cXsA== X-Gm-Message-State: AOAM533wHdt0h84RhKTrGhzeVyVa3srVT54z8R9K7b4pAdwrdJbz/bi9 PJfxr6JBC2gzYh5/nGVLTHJt1FMWPXo= X-Google-Smtp-Source: ABdhPJyus6p1tjqZNWUR6XKdXmIMNXCe8BMlzpZvlydCkLab38nfvuoLnKFHqaTd/4vzuI6h2WTx7Q== X-Received: by 2002:adf:c104:: with SMTP id r4mr2955665wre.404.1630290162267; Sun, 29 Aug 2021 19:22:42 -0700 (PDT) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id v5sm13715680wrw.44.2021.08.29.19.22.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 29 Aug 2021 19:22:41 -0700 (PDT) In-Reply-To: <87wno48w9d.fsf@omarpolo.com> Content-Language: en-US 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" Xref: news.gmane.io gmane.emacs.bugs:212996 Archived-At: On 29.08.2021 11:30, Omar Polo wrote: > Yes, with "./foo" the issue is resolved, but I think a more general fix > in project.el is warranted. > > It's quite common (at least for C and Go which I use frequently) to > produce a binary in the root directory of the project with the same name > of the project, for example > > /home/op/w/foo/ <- project root > /home/op/w/foo/foo <- the binary produced > > and I expect users to have "foo" in their ignore file, not "./foo", as > they do for e.g. when using git and vc-git. Fair enough. > Also, if one day in the future someone decides to remove the specific > treatment of Git and Hg from project-files this issue will bite > vc-git/hg users too. Unlikely: the special treatment is there foremost for performance. But perhaps we'll get a faster universal method for listing files, who knows. > I guess I can hack something in my custom vc backend to replace an > ignore entry called "" with "./", but this > would probably need to be done on every vc backend, excluding git and > hg. > > For the time being, I'm using the following patch, but I don't > particularly like it. > > > diff --git a/project.el b/project.el > index ae9bf03..176947e 100644 > --- a/project.el > +++ b/project.el > @@ -302,6 +302,12 @@ to find the list of ignores for each directory." > ;; expanded and not left for the shell command > ;; to interpret. > (localdir (file-name-unquote (file-local-name (expand-file-name dir)))) > + (projectname (file-name-nondirectory (directory-file-name dir))) > + (ignores (mapcar (lambda (e) > + (if (string= projectname e) > + (concat "./" e) > + e)) > + ignores)) > (command (format "%s -H %s %s -type f %s -print0" > find-program > (shell-quote-argument Please try this patch instead: diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index ae9bf03571..b267185ab0 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -302,10 +302,9 @@ project--files-in-directory ;; expanded and not left for the shell command ;; to interpret. (localdir (file-name-unquote (file-local-name (expand-file-name dir)))) - (command (format "%s -H %s %s -type f %s -print0" + (dfn (directory-file-name localdir)) + (command (format "%s -H . %s -type f %s -print0" find-program - (shell-quote-argument - (directory-file-name localdir)) ; Bug#48471 (xref--find-ignores-arguments ignores localdir) (if files (concat (shell-quote-argument "(") @@ -324,8 +323,9 @@ project--files-in-directory (unless (zerop status) (error "File listing failed: %s" (buffer-string)))))))) (project--remote-file-names - (sort (split-string output "\0" t) - #'string<)))) + (mapcar (lambda (s) (concat dfn (substring s 1))) + (sort (split-string output "\0" t) + #'string<))))) (defun project--remote-file-names (local-files) "Return LOCAL-FILES as if they were on the system of `default-directory'.