all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "João Távora" <joaotavora@gmail.com>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: Stefan Monnier <monnier@iro.umontreal.ca>,
	 Danny Freeman <danny@dfreeman.email>,
	 Eric Abrahamsen <eric@ericabrahamsen.net>,
	emacs-devel <emacs-devel@gnu.org>
Subject: Subprojects in project.el (Was: Eglot, project.el, and python virtual environments)
Date: Wed, 23 Nov 2022 13:57:22 +0000	[thread overview]
Message-ID: <871qptai4d.fsf_-_@gmail.com> (raw)
In-Reply-To: <0024a67d-b8e5-b35c-1b22-82541a170eb3@yandex.ru> (Dmitry Gutov's message of "Wed, 23 Nov 2022 02:03:57 +0200")

Dmitry Gutov <dgutov@yandex.ru> 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-subprojects))))

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= (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 function
   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ão



  reply	other threads:[~2022-11-23 13:57 UTC|newest]

Thread overview: 139+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-16 18:37 Eglot, project.el, and python virtual environments Eric Abrahamsen
2022-11-16 22:24 ` Danny Freeman
2022-11-16 22:53   ` Eric Abrahamsen
2022-11-17 13:41     ` Danny Freeman
2022-11-17 18:06       ` Eric Abrahamsen
2022-11-17 18:48         ` Yuan Fu
2022-11-17 22:21       ` Tim Cross
2022-11-18  2:38         ` Phil Sainty
2022-11-18  7:43           ` Eli Zaretskii
2022-11-18 13:55             ` Danny Freeman
2022-11-18 15:22               ` Eli Zaretskii
2022-11-18 15:53                 ` Danny Freeman
2022-11-18 19:36               ` Eric Abrahamsen
2022-11-18 15:06             ` Stefan Monnier
2022-11-18 15:17               ` Eli Zaretskii
2022-11-18 15:28                 ` Stefan Monnier
2022-11-19  1:12             ` Dmitry Gutov
2022-11-19  7:42               ` Eli Zaretskii
2022-11-19 13:06                 ` Dmitry Gutov
2022-11-19 13:14                   ` Eli Zaretskii
2022-11-18 18:31   ` João Távora
2022-11-19  1:13     ` Dmitry Gutov
2022-11-19  1:56       ` João Távora
2022-11-19 15:23         ` Dmitry Gutov
2022-11-19 19:17           ` Danny Freeman
2022-11-19 19:49             ` Dmitry Gutov
2022-11-19 21:22               ` Danny Freeman
2022-11-20  1:51                 ` João Távora
2022-11-20 15:36                   ` Dmitry Gutov
2022-11-20 20:35                     ` João Távora
2022-11-20 22:05                       ` Dmitry Gutov
2022-11-21 13:45                         ` João Távora
2022-11-22 15:48                           ` Dmitry Gutov
2022-11-22 21:12                             ` Stefan Monnier
2022-11-22 21:34                               ` João Távora
2022-11-22 22:00                                 ` Dmitry Gutov
2022-11-22 23:23                                   ` João Távora
2022-11-23  0:03                                     ` Dmitry Gutov
2022-11-23 13:57                                       ` João Távora [this message]
2022-11-23 20:33                                         ` Subprojects in project.el (Was: Eglot, project.el, and python virtual environments) João Távora
2022-11-24  2:49                                           ` Dmitry Gutov
2022-11-24  8:42                                             ` João Távora
2022-11-24 22:17                                               ` Dmitry Gutov
2022-11-25 19:56                                                 ` Subprojects in project.el João Távora
2022-11-25 22:33                                                   ` Dmitry Gutov
2022-11-26  0:00                                                     ` João Távora
2022-11-26  1:57                                                       ` Dmitry Gutov
2022-11-26  9:23                                                         ` João Távora
2022-11-26 13:34                                                           ` Dmitry Gutov
2022-11-26 19:36                                                             ` João Távora
2022-11-26  2:01                                                       ` Dmitry Gutov
2022-11-26  9:24                                                         ` João Távora
2022-11-24  2:51                                           ` Subprojects in project.el (Was: Eglot, project.el, and python virtual environments) Dmitry Gutov
2022-11-24  6:23                                           ` Eli Zaretskii
2022-11-24  9:01                                             ` João Távora
2022-11-24 22:11                                             ` Dmitry Gutov
2022-11-25  7:30                                               ` Eli Zaretskii
2022-11-25 17:24                                                 ` Dmitry Gutov
2022-11-25 19:45                                                   ` Eli Zaretskii
2022-11-25 21:57                                                     ` Dmitry Gutov
2022-11-25 23:55                                                       ` Subprojects in project.el João Távora
2022-11-28  0:41                                                         ` Dmitry Gutov
2022-11-26  7:26                                                       ` Subprojects in project.el (Was: Eglot, project.el, and python virtual environments) Eli Zaretskii
2022-12-02  1:32                                                         ` Dmitry Gutov
2022-12-02 14:16                                                           ` Eli Zaretskii
2022-12-02 15:08                                                             ` Dmitry Gutov
2022-12-02 15:37                                                               ` Dmitry Gutov
2022-12-02 15:44                                                               ` Subprojects in project.el Stefan Monnier
2022-12-02 23:26                                                                 ` João Távora
2022-12-06 14:36                                                           ` Subprojects in project.el (Was: Eglot, project.el, and python virtual environments) João Távora
2022-11-24  3:01                                         ` Dmitry Gutov
2022-11-24  8:50                                           ` João Távora
2022-11-24 22:46                                             ` Tim Cross
2022-11-24 23:38                                               ` Dmitry Gutov
2022-11-25  7:07                                                 ` Bozhidar Batsov
2022-11-25 14:58                                                   ` Subprojects in project.el Stefan Monnier
2022-11-25 22:29                                                     ` Dmitry Gutov
2022-11-26  2:59                                                       ` Stefan Monnier
2022-11-26 12:30                                                         ` Dmitry Gutov
2022-11-26 17:32                                                           ` Stefan Monnier
2022-11-27  0:25                                                             ` Dmitry Gutov
2022-11-25 20:32                                                 ` João Távora
2022-11-28  4:10                                                 ` Subprojects in project.el (Was: Eglot, project.el, and python virtual environments) Tim Cross
2022-11-28 17:21                                                   ` Dmitry Gutov
2022-11-29  9:56                                                     ` Subprojects in project.el João Távora
2022-11-29 18:40                                                       ` Dmitry Gutov
2022-11-29 22:21                                                         ` João Távora
2022-11-30  0:39                                                           ` Dmitry Gutov
2022-11-30  0:54                                                             ` João Távora
2022-11-30  0:57                                                               ` Dmitry Gutov
2022-11-30  1:18                                                                 ` João Távora
2022-12-02 22:47                                                                 ` Richard Stallman
2022-12-02 23:46                                                                   ` Dmitry Gutov
2022-12-03  7:09                                                                     ` Eli Zaretskii
2022-11-24 22:58                                             ` Subprojects in project.el (Was: Eglot, project.el, and python virtual environments) Dmitry Gutov
2022-11-25  2:38                                               ` Subprojects in project.el Stefan Monnier
2022-11-25 20:23                                                 ` João Távora
2022-11-25 22:23                                                 ` Dmitry Gutov
2022-11-25  7:42                                               ` Juri Linkov
2022-11-25 20:27                                                 ` Dmitry Gutov
2022-11-25 23:47                                                   ` João Távora
2022-11-25 23:58                                                     ` Dmitry Gutov
2022-11-26  0:46                                                       ` João Távora
2022-11-26  2:07                                                         ` Dmitry Gutov
2022-11-25 20:16                                               ` João Távora
2022-11-25 22:44                                                 ` Dmitry Gutov
2022-11-26  0:37                                                   ` João Távora
2022-11-26  2:05                                                     ` Dmitry Gutov
2022-11-26  9:42                                                       ` João Távora
2022-11-26 12:38                                                         ` Dmitry Gutov
2022-11-29 10:03                                                           ` João Távora
2022-11-29 10:17                                                           ` João Távora
2022-11-29 19:07                                                             ` Dmitry Gutov
2022-11-29 22:52                                                               ` João Távora
2022-11-30  1:10                                                                 ` Dmitry Gutov
2022-11-27 19:25                                                 ` Juri Linkov
2022-11-27 21:43                                                   ` Dmitry Gutov
2022-11-22 23:53                                 ` "Backend completion style" as a first-class library. Re: Eglot, project.el, and python virtual environments João Távora
2022-11-23  1:45                                   ` Stefan Monnier
2022-11-25 13:16                                     ` João Távora
2022-11-22 21:40                             ` João Távora
2022-11-22 22:13                               ` Dmitry Gutov
2022-11-22 23:33                                 ` João Távora
2022-11-21 20:58                     ` Augusto Stoffel
2022-11-23  3:37                       ` Dmitry Gutov
2022-11-20 16:37                   ` João Távora
2022-11-21  7:54                   ` Eric Abrahamsen
2022-11-21 13:36                     ` João Távora
2022-11-21 15:41                       ` Alfred M. Szmidt
2022-11-21 16:49                         ` Eli Zaretskii
2022-11-21 16:49                       ` Eric Abrahamsen
2022-11-21 20:54                     ` Augusto Stoffel
2022-11-19 23:25           ` João Távora
2022-11-19 23:40             ` Dmitry Gutov
2022-11-16 23:18 ` Philip Kaludercic
2022-11-17  1:14   ` Eric Abrahamsen
2022-11-17  6:47 ` North Year
2022-11-17 18:09   ` Eric Abrahamsen
2022-11-19 22:36 ` Stephen Leake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871qptai4d.fsf_-_@gmail.com \
    --to=joaotavora@gmail.com \
    --cc=danny@dfreeman.email \
    --cc=dgutov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    --cc=eric@ericabrahamsen.net \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.