[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#45134: Add project-switch-project-by-name
From: |
Rudolf Schlatte |
Subject: |
bug#45134: Add project-switch-project-by-name |
Date: |
Wed, 09 Dec 2020 21:21:18 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.1 (darwin) |
Dmitry Gutov <dgutov@yandex.ru> writes:
> On 09.12.2020 17:14, Rudolf Schlatte wrote:
>> Certain “dashboard-type” packages present a list of projects and let the
>> user switch to one of them. In that case, the project root is already
>> known, and project.el only needs to present the dispatch menu of
>> ‘project-switch-commands’.
>
> So the idea is you know the directory in advance and only need to show
> the dispatch menu?
Yes, exactly.
> How about this instead?
Tested and works as expected, both invoked with ‘C-x p p’ where it
prompts for a project first, and from dashboard where it shows the
dispatch menu immediately for the chosen project. Very nice!
> diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
> index 449eadc3de..f7c6a55f44 100644
> --- a/lisp/progmodes/project.el
> +++ b/lisp/progmodes/project.el
> @@ -1275,13 +1275,13 @@ project--keymap-prompt
> " "))
>
> ;;;###autoload
> -(defun project-switch-project ()
> +(defun project-switch-project (dir)
> "\"Switch\" to another project by running an Emacs command.
> The available commands are presented as a dispatch menu
> made from `project-switch-commands'."
> - (interactive)
> - (let ((dir (project-prompt-project-dir))
> - (choice nil))
> + (interactive
> + (list (project-prompt-project-dir)))
> + (let ((choice nil))
> (while (not choice)
> (setq choice (assq (read-event (project--keymap-prompt))
> project-switch-commands)))