From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Newsgroups: gmane.emacs.devel Subject: Subprojects in project.el (Was: Eglot, project.el, and python virtual environments) Date: Wed, 23 Nov 2022 13:57:22 +0000 Message-ID: <871qptai4d.fsf_-_@gmail.com> References: <87zgcq68zp.fsf@ericabrahamsen.net> <878rkale3l.fsf@dfreeman.email> <4c5f4b07-3df6-d700-83f8-9a9d1b684afc@yandex.ru> <84781346-5b88-2be5-38bb-02696fcf1364@yandex.ru> <87o7t2vj19.fsf@dfreeman.email> <877czqtyfy.fsf@dfreeman.email> <87zgcml7g7.fsf@gmail.com> <2ba04533-097a-a1da-ff3f-2c9506fd488e@yandex.ru> <875yf9bbzb.fsf@gmail.com> <87wn7oa0aw.fsf@gmail.com> <7a5b76fd-fb15-8c1e-ea29-bf11f7e0d2ae@yandex.ru> <87bkoya815.fsf@gmail.com> <0024a67d-b8e5-b35c-1b22-82541a170eb3@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26461"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Stefan Monnier , Danny Freeman , Eric Abrahamsen , emacs-devel To: Dmitry Gutov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Nov 23 14:56:54 2022 Return-path: Envelope-to: ged-emacs-devel@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 1oxqFB-0006gl-VB for ged-emacs-devel@m.gmane-mx.org; Wed, 23 Nov 2022 14:56:54 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oxqEZ-0003oS-3j; Wed, 23 Nov 2022 08:56:15 -0500 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 1oxqEW-0003ma-KN for emacs-devel@gnu.org; Wed, 23 Nov 2022 08:56:12 -0500 Original-Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oxqEU-0006nL-5F for emacs-devel@gnu.org; Wed, 23 Nov 2022 08:56:12 -0500 Original-Received: by mail-wr1-x42f.google.com with SMTP id i12so25636823wrb.0 for ; Wed, 23 Nov 2022 05:56:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TD21yJ850rm8u0MssbkwW/hweALwmWwwpjWRmFZszkY=; b=LdgNO6IJHp8Yt2bveJ/6H9Xkf4wvGHe39+pm/HoeJenabZNm5Yd3mLCXq05pRx+upL a29R5Fkai6WpF9EWPZdmHfkxPvCTGkwCqnNMM70dbI93AEjWnLFNXWdOq0qYTvTLMxyt ej8eDmoZmpa4fvETs/tDV20Ikl4fuw6nP3bZBZXP/Sr2jJStuNVCTPnWJZUZlCDuchb8 52OgnkOUI2iKK2GoCkjxZnW4wbo9fL2dw/xP6EsOzVjG5vMexrLWQfLQNGuk4kiWVnaN jn5HO5+zmG4SMKac73ATBLObyeffcUTvTrj2+W7tTUsqQMCDX3I1zjGc7CPNEWqquueD AfHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=TD21yJ850rm8u0MssbkwW/hweALwmWwwpjWRmFZszkY=; b=r5QZYvQhVLYcPJz4QsogY0ppnnt/gkceYfM/z63H0zawBUqUxe6OtG4Yl9i/WFw6Qt BWCyzC6KLN+Rlm1QF3hVLgoq2Te+5wQslM3MqxjPDQBMTkRXCqtY46rYo4FAAIw//lb3 nQh8R0FJjGGJWhWL78+kFfy+nPg3/k5vWhJtwiUFMWha6xV1iLF+UxamqOyD5xarsEO1 xrj8ICI6u6rd84iO1XdzV0Gt+2IJkBj3XTMNlV8kFTgR+X3IFYTtqGSvQsKrS6Bsh90l dIVSTNXefKRbZ3zoZ6xy97+uFwV3uWhYSrKn+xeeq4OGk3Fcb2/6WvmBPJaPZVHSqrgT L9/Q== X-Gm-Message-State: ANoB5pk7mo8h4IRPhQisadVRPZjYs/Z/1TNB+U0GWoapw6el57rhqPzu k7is9C4zmnw7n9oQfL2wNlycUEDW7Fg= X-Google-Smtp-Source: AA0mqf4tWW6TMRhizd39ERRvnR29h5exnFqAL3qKBM500tKocIfM3yEy2sCijizJt+d5M1Mv/6+Rag== X-Received: by 2002:adf:ea50:0:b0:241:d7b1:b405 with SMTP id j16-20020adfea50000000b00241d7b1b405mr8855174wrn.53.1669211767457; Wed, 23 Nov 2022 05:56:07 -0800 (PST) Original-Received: from krug (87-196-72-177.net.novis.pt. [87.196.72.177]) by smtp.gmail.com with ESMTPSA id t7-20020a05600001c700b00241e5b917d0sm4803204wrx.36.2022.11.23.05.56.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Nov 2022 05:56:07 -0800 (PST) In-Reply-To: <0024a67d-b8e5-b35c-1b22-82541a170eb3@yandex.ru> (Dmitry Gutov's message of "Wed, 23 Nov 2022 02:03:57 +0200") Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=joaotavora@gmail.com; helo=mail-wr1-x42f.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, 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: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:300394 Archived-At: Dmitry Gutov writes: >> I've just described in the other thread that I would like to have >> finding references and finding files to be able to operate on either >> sub-projects or super-projects on demand. This is the problem I'm >> facing, and it's not new. For example, there is only: find file in the >> very large project, and find file in the current directory. There is no >> "find file in this section of the repo, which is a sub-project in >> itself". > > It would be much more helpful in a dedicated bug report where we could > discuss the details, collect the votes and see what kind of design > will ultimately satisfy the requirements. Instead of drowning it all > in this thread, which is only moderately related. I think we're doing fine here but I've changed the subject line to "unbury" it from the thread. >> IMO, it's not "improper" to describe problems and use cases: in fact I >> prefer that people describe over jumping to vapourware solutions. But >> if you're really looking for a suggestion as to _how_ to design it, I >> suppose my problem would be well dealt with a negative prefix on C-x p g >> and C-x p f giving me a choice of which project to operate on. But that >> is only one possibility: new commands are also acceptable. > > Note that you can more-or-less do this now: press 'C-x p p', select > the parent project from the list, then choose 'f' or 'g' to run the > command there. So to justify the added complexity one should say that > they do want to use this feature frequently enough to justify the > added complexity (which will reduce the number of keystrokes). Both cases -- focus on super-project/focus on sub-project -- are definitely common. I have no problem in using an existing interface, even if it idiosyncratic. So if the inner-most sub-project is the default but somehow I can explicitly call up a "project picker" that shows me the super-project as one of the first options, that probably works fine. > And even if we do, we might not need the additional notion of > sub-projects. E.g. 'search in the parent project (if any)' might work > as "take the root, go up a directory, search for a project there; if > it exists, use it". Though Stephen L. might want a generic for that, > since his projects do not correlate with directory tree. And in my case, sub-projects don't necessarily exist exactly one-level down super-project's root. Sometimes they do, but now always. Of course, just as data point, I've been solving all my problems outside project.el for a good long while now, even before I was faced with this gigantic monorepo and even before project.el was a thing. I use Leo Liu's ack-el.el, which greps from the super-project's root by default, and from wherever I want given enough C-u. And I have a similar separate command for finding files from arbitrary points in the hierarchy. And I have a similar command for compiling. I just happen to think having this in project.el would make a lot of sense. I've recently experimented with it and found the new project.el features pleasant to work in smaller or well-behaved projects. It's not powerful enough for the big stuff, but it ought to be. > OTOH, if one of the operations will require a step "get all > subprojects of the current project", then a separate notion might be > required, with a separate hook. > >> As to how one defines sub-projects, I think having >> project-find-functions be used to compose a list of projects (as opposed >> to to stopping after finding one) would be a nice way. It would be nice >> if the elements of project-find-functions could be informed of the >> projects found so far. But keeping the "stop after first" behaviour and >> having members return a more complex object is maybe also good. I >> really don't care much what you eventually choose, as long as I can >> solve my problem. > > If we wanted to define projects and subprojects through the same hook, > the step "get all subprojects of the current project" might not be > feasible to implement. Because of performance-related considerations. Those remain to be seen, I can't guess what things you're imagining. I'm not sure we need that step at all. After all there is no "get me all the projects in my hard drive" either, and at least I haven't missed it. Anyway, from my POV this type of sub-project definition would not be very nice. (add-hook 'some-new-subproject-find-hook (lambda (dir) (cons 'super-project (some-code-which-scans-and-returns-a-list-of-subproject= s)))) I would prefer this, which I think is more readable and in-line with current project.el: (add-hook 'project-find-functions (lambda (dir) (let ((super (project-current))) (when (and super (string=3D (file-name-directory (directory-file-name dir)) (project-root super)) (my-special-condition dir)) (cons 'transient dir))))) Maybe 'my-special-condition' could read a directory local variable to decide if sub-projects are enabled or not. For my idea to work, project-current would have to be changed to 1. Call all members of project-find-functions: return the innermost project found thus far. 2. Not call project-find-functions recursively when called from within a fu= nction in project-find-functions, just return the innermost project found thus far. I don't see any big performance problems in this alternative. But, again, the above are suggestions: _any_ alternative that lets me define inner sub-projects within a larger super-project and let me choose where I want to grep, find-file, compile, would be an improvement. Jo=C3=A3o