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#41572: 28.0.50; [PATCH] Support plain project marked with file .emacs-project Date: Wed, 6 Oct 2021 03:11:04 +0300 Message-ID: References: <87pnahjgdr.fsf@linkov.net> <87ftb92u8q.fsf@thornhill.no> <0ab90cf2-eab2-6fea-6698-4164d7753cd7@yandex.ru> <87d06ck2b0.fsf@thornhill.no> <2fbe5d5d-03a1-212b-9dd7-4723e168ad06@yandex.ru> <5EpzudgjedeKADsX4_Tq-2WtNm3XKXmZjnEI7Y1lmw-Pcn_KrzKPD1o31Ele0JOIrZ1ITDdeQrOsJTHfGVPJlzyLhmqjxP3rmVVzou8KEBo=@thornhill.no> <2a70c748-e250-2f96-5d74-712b6d71e8be@yandex.ru> <871riitzch.fsf@gnus.org> <11e8e147-092d-d840-4d55-005654ff603c@gmail.com> <290a72b8-1e00-2e61-5665-a9bc2ca4289b@yandex.ru> <54c4b3c5-6142-2d2e-b531-a5e3d5a25e3a@gmail.com> <6f237243-8cd6-a22c-a5f5-d241d76ddd53@yandex.ru> <0895f33c-dfff-135e-657a-fbcf4730b799@gmail.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="36416"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 Cc: Zhu Zihao , Theodor Thornhill , 41572@debbugs.gnu.org, Juri Linkov To: Nikolay Kudryavtsev , Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Oct 06 02:12:15 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 1mXuXf-0009Gy-0K for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 06 Oct 2021 02:12:15 +0200 Original-Received: from localhost ([::1]:34802 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXuXd-0002gL-0n for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 05 Oct 2021 20:12:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41228) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXuXU-0002gB-EO for bug-gnu-emacs@gnu.org; Tue, 05 Oct 2021 20:12:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58816) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mXuXS-00057X-GA for bug-gnu-emacs@gnu.org; Tue, 05 Oct 2021 20:12:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mXuXR-0005EV-Ui for bug-gnu-emacs@gnu.org; Tue, 05 Oct 2021 20:12: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: Wed, 06 Oct 2021 00:12:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41572 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 41572-submit@debbugs.gnu.org id=B41572.163347907520057 (code B ref 41572); Wed, 06 Oct 2021 00:12:01 +0000 Original-Received: (at 41572) by debbugs.gnu.org; 6 Oct 2021 00:11:15 +0000 Original-Received: from localhost ([127.0.0.1]:42129 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mXuWg-0005DR-Th for submit@debbugs.gnu.org; Tue, 05 Oct 2021 20:11:15 -0400 Original-Received: from mail-lf1-f41.google.com ([209.85.167.41]:41737) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mXuWe-0005DD-Fa for 41572@debbugs.gnu.org; Tue, 05 Oct 2021 20:11:13 -0400 Original-Received: by mail-lf1-f41.google.com with SMTP id j5so2814922lfg.8 for <41572@debbugs.gnu.org>; Tue, 05 Oct 2021 17:11:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=aBWTrtEPWT7rHU68L0X/kj2aKile47hvVZ+OK0dtoCA=; b=p/rPw4aYO01UcCWJ978nT3HwLEVdCGphhAkSMWdHK76XHpCN3GaeE47TIL9y/0j/Fi QO3j5Bq9ruNJfHoYszfsh6re5S4O9QhLPy8vA2jbRXx5BJjWiqF79qlSuqno8LslWBR9 Qlsyz8LGiX8WnCVo9CYKvRa2Q/Sw5klBGACGavzeTOVAqYfcj0QNIBXwVuy9cRxtAR+x n240fEtqwwnde0WTJXfarDgDS7HgmL18nRKoK7A1g9iN4glzmZnypxRWEBBBCOk/+r2o n321Di7oLt6UAfvwvknNbFSuzKRYa14QgRjaJv0czTytqQQ4GHvVAkc5MNrVq0XoV0PM u3Ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=aBWTrtEPWT7rHU68L0X/kj2aKile47hvVZ+OK0dtoCA=; b=eX4kj23jlzo/VbJ827EMKHc9+OEJX64yOwUQpq2Egeaj9Z4dakQwpUCahOiCAtKSfE JkDu90eM4nsrK08cUO6Frkcr7c8wLAibVGSpEnrKhvROSA8SoNYoeVyLon6rD0mL7CuV WA6B+SZ7Jmyhb1jsI7DsCtmwl6uh9herbt0vkf2C0pEkAaOsbv7HF372cKclapSFD827 YiGZjcb8Gk1rc4ov3Vsr57vjj3F0Z2LLTy/moB3yZ/ilarkjWBxJ/P3nTrEB0e7tWAP8 QqNtzYaO3NQ+9o8kL1ARD5yD+sCbtJ1RVC8yaHxdZ4ftqM7y2MIKBM5ZvT9utyO6TLtz S7Pg== X-Gm-Message-State: AOAM530llL0fsnaUi/OsiCq67I3KMLYA6IHfaU83nMYld/8BdlwwYqgG wn/b8FgHFnBVEtHd8T0rjgg= X-Google-Smtp-Source: ABdhPJxJ2WNNc3nrR0AnA5bL156z/URrwzT48ZEmOoGx6sHLhq2GBxioaM5mrl4UAIATRl9y9jAlkQ== X-Received: by 2002:a05:6512:6d2:: with SMTP id u18mr6318789lff.453.1633479066385; Tue, 05 Oct 2021 17:11:06 -0700 (PDT) Original-Received: from [192.168.1.113] ([178.252.127.239]) by smtp.googlemail.com with ESMTPSA id n19sm2104640ljc.11.2021.10.05.17.11.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 05 Oct 2021 17:11:05 -0700 (PDT) In-Reply-To: <0895f33c-dfff-135e-657a-fbcf4730b799@gmail.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:216507 Archived-At: On 05.10.2021 21:19, Nikolay Kudryavtsev wrote: > I currently have a very basic real use case on my hands. There's a > particular programming language that has it's own project file type. > Since it's a project type, it makes sense to plug it in as project > backend. And then on top of this I can implement project target actions > like build, compile and debug(this is actually another matter that > probably needs to be implemented in(or over) project.el at some point, > I'll probably open a discussion about it later). Right, we are yet to consider this functionality properly. > So it all makes sense so far, at least conceptually. But here you're > saying "you should not add a new file-based backend until you really > think about the project file list optimization first". This violates the > classic rule of doing the right thing first, then optimizing second. So > while I feel this a real issue, it IMHO should be filed and discussed > separately and is a nonblocker for this particular task. Let's talk about correctness. The "right thing". Suppose we have a large Git repo, which contains a "foo project" (as you might see it), marked by Foofile in its 'foo' subdirectory. And suppose we allow the project-foo backend to come first before the VC backend. When we are inside the directory ./project/foo, that's the current project. File listing shows ("./project/foo/a", "./project/foo/b", etc). But when we go up a directory, "./project/". And when asked to list its files, how do we avoid including "./project/foo/a" in that list? It would make sense to exclude any nested projects, right? But we can't do that if the project detection logic is so flexible that the project-vc backend couldn't find out about subprojects inside it except by visiting every subdirectory and querying for the current project there, which would obviously be too slow. So it's a correctness issue as well. Hence the simpler-but-easier-to-get-right approach in the other patch (with the project-vc-subprojects variable). Even if it might require more effort from the end user, unfortunately. > Now to contradict myself, lets continue discussing this issue. I think > this is a local version of a more global multiple backends problem. Lets > say we have the same project(more precisely, a set of files) that is > served by multiple backends. Roughly we order project-find-functions in > this order: major-mode backends, tool backends(eg. GNU Global), generic > backends(VC). The preference for the major mode backends over others is > due to that "VC has different root" use case. Tool backends are > preferred to VC due to that you can start a new Global project as sort > of a custom project hack. Setting project-find-functions in a major mode is a questionable thing to do, because then you end up with Emacs where files in the same directory belong to different projects. As we say in the commentary: ;; It is a good idea to depend on the ;; directory only, and not on the current major mode, for example. ;; Because the usual expectation is that all files in the directory ;; belong to the same project (even if some/most of them are ignored). We want to support even backends where this approach is violated (on a best-effort basis), but let's not make this the common scenario. > And here we run into the problem: our major mode while it provides a > backend, does not optimize file listing, but there's a backend that > does. I think TRT is project.el choosing a different secondary backend > in this case as long as it has the same project root. If there is a next backend which indicates the same root, why do we need the first one? > For this it needs > to have some rules, to know which backend better fits a particular > situation, which does not. Why do you need so many backends, anyway? One per language, one per tool, etc. That seems to reduce the concept of a project to "this one parent directory containing a file some tool cares about". What would be the meaning of the value (project-current) returns? Suppose I call project-find-file, meaning to jump to another file in the same Git repository. And instead I am shown only a list of files in the current subdirectory because it contains, say, a Makefile. Is that a good idea to enact this kind of behavior automatically? Or suppose we add a backend that looks for 'Makefile', another for 'Gemfile', another for 'Rakefile', etc. What user-level commands are going to benefit from this setup? A command that shows the available Makefile tasks? It can just as well call 'locate-dominating-file' to find the nearest directory containing it. Same for 'M-x rake', and so on.