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#65704: 29.1; Most code of `project-ignores' seems to be dead code Date: Mon, 4 Sep 2023 21:30:01 +0300 Message-ID: <93d0f377-7acd-ec0d-0e17-f6d09c4dd23a@yandex.ru> References: <87sf7wlg07.fsf@cassou.me> <874jkakjt3.fsf@cassou.me> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40827"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 To: Damien Cassou , 65704@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Sep 04 20:31:28 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 1qdEMB-000ANa-TG for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 04 Sep 2023 20:31:28 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qdELz-0005I4-B9; Mon, 04 Sep 2023 14:31:16 -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 1qdELp-0005Ho-2W for bug-gnu-emacs@gnu.org; Mon, 04 Sep 2023 14:31:05 -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 1qdELn-0002E2-1v for bug-gnu-emacs@gnu.org; Mon, 04 Sep 2023 14:31:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qdELm-0004jm-HU for bug-gnu-emacs@gnu.org; Mon, 04 Sep 2023 14:31:02 -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, 04 Sep 2023 18:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65704 X-GNU-PR-Package: emacs Original-Received: via spool by 65704-submit@debbugs.gnu.org id=B65704.169385222418159 (code B ref 65704); Mon, 04 Sep 2023 18:31:02 +0000 Original-Received: (at 65704) by debbugs.gnu.org; 4 Sep 2023 18:30:24 +0000 Original-Received: from localhost ([127.0.0.1]:52525 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qdEL9-0004ip-Qr for submit@debbugs.gnu.org; Mon, 04 Sep 2023 14:30:24 -0400 Original-Received: from forward500a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:d500]:34270) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qdEL3-0004iU-Sw for 65704@debbugs.gnu.org; Mon, 04 Sep 2023 14:30:22 -0400 Original-Received: from mail-nwsmtp-smtp-production-main-81.vla.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-81.vla.yp-c.yandex.net [IPv6:2a02:6b8:c18:4001:0:640:bc2:0]) by forward500a.mail.yandex.net (Yandex) with ESMTP id 5EFBD5EA66; Mon, 4 Sep 2023 21:30:10 +0300 (MSK) Original-Received: by mail-nwsmtp-smtp-production-main-81.vla.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id 7Ub38bJWmKo0-GBGDom21; Mon, 04 Sep 2023 21:30:09 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1693852209; bh=1B/n6xyTcc3MR1BmLdXQdO7JlbJkiMJ7SFAa32kkOLw=; h=In-Reply-To:From:Subject:Message-ID:References:Date:To; b=ILrk5+UtEUR5aVEWYhcSiR+sTPmZkLCmRWb3z+KcpA3LEczUPJCbA+AjC1+g2gh/+ aQgA7eOxhCBHdEQZDs3B3y2sGg4B0x+l1lCzpYt4odDk6SUCx7SQI48yjilNqj7E6U Aa9r04F/egqzbhngSPbGv304xR0uL28HoT9XykyY= Authentication-Results: mail-nwsmtp-smtp-production-main-81.vla.yp-c.yandex.net; dkim=pass header.i=@yandex.ru Original-Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailauth.nyi.internal (Postfix) with ESMTP id A862327C0054; Mon, 4 Sep 2023 14:30:07 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Mon, 04 Sep 2023 14:30:07 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudegkedguddviecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefkffggfgfuvfhfhfgjtgfgsehtkeertddtfeejnecuhfhrohhmpeffmhhi thhrhicuifhuthhovhcuoegughhuthhovheshigrnhguvgigrdhruheqnecuggftrfgrth htvghrnhepkeejfedtudefleelteegleevieefffekfeffheekkefhteegffffvefhfefg udffnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepug hguhhtohhvodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqddufeeffeelleeh hedvqddvleegjeejjeejiedqughguhhtohhvpeephigrnhguvgigrdhruhesfhgrshhtmh grihhlrdgtohhm X-ME-Proxy: Feedback-ID: ib1d9465d:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 4 Sep 2023 14:30:05 -0400 (EDT) Content-Language: en-US In-Reply-To: <874jkakjt3.fsf@cassou.me> 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:269270 Archived-At: On 04/09/2023 19:03, Damien Cassou wrote: > Dmitry Gutov writes: >> much. Maybe just that that code path isn't exercised by any in-tree >> function if the backend is Git (with recent enough git installed) > > My Git repository has several .gitignore files in several directories, > something that `project-ignores' (for VC) seems to not support: > > ;; we only support .gitignore at the root. Yes. That's not really the fault of project-vc's implementation, but the way vc-default-ignore-completion-table and vc-git-find-ignore-file are implemented. But again, it shouldn't be a problem for most users/uses. > My project looks like this: > > . > ├── client > │   ├── .gitignore > │   ├── node_modules > │   └── .project > ├── .git > └── .gitignore > > Because I spend most of my time in the client/ directory, I want the > `project' library to consider client/ to be a project on its own. I use > the code below and the client/.project file to do this: Also an aside: you could add ".project" or ".gitignore" to project-vc-extra-root-markers if your project.el is recent enough (e.g. from Emacs 29). > (defconst my/project-root-marker ".project" > "File indicating the root of a project.") > > (defun my/project-find-root (path) > "Search up the PATH for `my/project-root-marker'." > (when-let* ((root (locate-dominating-file path my/project-root-marker))) > (cons 'transient root))) > > (add-to-list 'project-find-functions #'my/project-find-root) > > The client/.gitignore file contains a line "node_modules/" which is a > very large directory. The command `project-find-file' doesn't see my > client/.gitignore and thus suggests 83k files and make the completion UI > very slow. The above customization going against the general recommendation in project.el's Commentary and ends up with Emacs detecting an instance of a different backend: 'transient'. Which doesn't have a dedicaded definition for project-ignores and falls back to the default one (lines 292:307). Naturally, it doesn't scan for ignore files in any VC backend. That's the reason I've added project-vc-extra-root-markers: so that honoring files like .gitignore still makes sense, but the user can split the project into pieces using these markers while keeping the same backend in use. > So I'm not using it but this instead: > > (project-find-file-in (thing-at-point 'filename) > (list "/my/project/client") > (project-current nil "/my/project")) > > The function `project-find-file-in' uses `project-files' which in turn > uses `project--dir-ignores'. Just keep in mind that 'project-files' also has two definition in core (and however many outside of it): one default that always calls project--dir-ignores, and one for 'vc' (lines 609:629) that only calls project--dir-ignores in fallback situations (backend is not Git or Hg, or when Git is older than 1.9, or when DIR is not the project root). The last case might still be reconsidered, but it works for 'C-u M-x project-find-regexp' when you want to search inside an ignored dir (fully or partially). > Am I doing something reasonable? Is there a better way? It looks like a > lot of setup to get Emacs to ignore directories listed .gitignore files. To reiterate: use 'project-vc-extra-root-markers'. And the nested .gitignore should also use used automatically without that too by 'C-x p f' if you remove #'my/project-find-root from project-find-functions. Anyway, thank you for the explanation, it's valuable feedback. If anything is unclear, further question welcome.