unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dmitry@gutov.dev>
To: Spencer Baugh <sbaugh@janestreet.com>
Cc: sbaugh@catern.com, 69584@debbugs.gnu.org
Subject: bug#69584: 29.2.50; project-find-functions should have access to maybe-prompt
Date: Wed, 3 Apr 2024 02:10:56 +0300	[thread overview]
Message-ID: <86952e0e-3856-4370-8e0b-08788e929811@gutov.dev> (raw)
In-Reply-To: <ierbk6rfy6c.fsf@janestreet.com>

On 02/04/2024 20:54, Spencer Baugh wrote:
> Spencer Baugh <sbaugh@janestreet.com> writes:
>> So when you open up a branch overview, you'll usually assume there's a
>> local copy, and so your first action will probably some command which
>> uses project-current.  But if there's no working copy, then you'll get
>> dropped to a prompt to choose a project, instead of (say) a
>> project-find-file prompt, which you might not immediately notice, which
>> is confusing, and you'll have to C-g out of it, and then run some other
>> command to create the working copy.  All that is a hassle.
> 
> Oh, I've thought of a different resolution to this which may be better.
> 
> When project-current fails to find a project in default-directory, if
> maybe-prompt=t, project-current will run project-prompter.
> 
> So I can just have a buffer-local project-prompter in the branch
> overview buffer.  And that project-prompter knows it's in a branch
> overview buffer, and can prompt "Would you like to make a working copy
> for [some branch]?".
> 
> That's elegant and doesn't change the semantics of project-current at
> all: project-prompter already can return an arbitrary directory.
> 
> Except... I suppose this would make project-switch-project behave worse,
> because hitting C-x p p in a branch overview buffer would now prompt to
> create a working copy for that branch, when what you probably want to do
> is switch to a different project entirely.
> 
> I guess there are two use cases for project-prompter: one is "fallback
> for project-current" and the other is "switch to a different project".
> Maybe we could support them being different?

I'm not sure how we'd do that. A new, optional, argument to 
project-prompter? Two different variables?

Right now we have two well-defined steps:

- Run a hook, where the current project can be detected,
- Or call the prompter, which will let the user choose a project 
manually (from the history, or from the file system).

That helps the prompter have a compact, focused interface. If it can 
also ask about other things, that makes things more complicated.

But for your own system, I suppose you could implement the described 
workflow right now with the current tools, using add-function: your 
project-find-functions element would itself return nil but add an 
around-advice for project-prompter, which would do more work, prompt the 
user, and ultimately return the intended object. And remove the advice 
as the first step, of course. What could require further testing - is 
the scenario where the prompter is called twice (when you invoke 
project-switch-project), but it'll probably work too, since the calls 
are not recursive.

To take a step back, I wonder if you have tried using the newly added 
binding for 'non-essential' yet. It seems like it should allow a simpler 
implementation.





      reply	other threads:[~2024-04-02 23:10 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-06 14:23 bug#69584: 29.2.50; project-find-functions should have access to maybe-prompt Spencer Baugh
2024-03-15  1:41 ` Dmitry Gutov
2024-03-16 13:31   ` sbaugh
2024-03-18 21:59     ` Dmitry Gutov
2024-03-22 13:05       ` Spencer Baugh
2024-03-28  3:44         ` Dmitry Gutov
2024-04-04 14:29           ` Spencer Baugh
2024-04-05  0:33             ` Dmitry Gutov
2024-04-02 17:54         ` Spencer Baugh
2024-04-02 23:10           ` Dmitry Gutov [this message]

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=86952e0e-3856-4370-8e0b-08788e929811@gutov.dev \
    --to=dmitry@gutov.dev \
    --cc=69584@debbugs.gnu.org \
    --cc=sbaugh@catern.com \
    --cc=sbaugh@janestreet.com \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).