emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#45134: closed (Add project-switch-project-by-name)


From: GNU bug Tracking System
Subject: bug#45134: closed (Add project-switch-project-by-name)
Date: Wed, 09 Dec 2020 20:58:02 +0000

Your message dated Wed, 9 Dec 2020 22:57:48 +0200
with message-id <c058120f-69c9-2c27-420c-4d9efc03f899@yandex.ru>
and subject line Re: bug#45134: Add project-switch-project-by-name
has caused the debbugs.gnu.org bug report #45134,
regarding Add project-switch-project-by-name
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@gnu.org.)


-- 
45134: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=45134
GNU Bug Tracking System
Contact help-debbugs@gnu.org with problems
--- Begin Message --- Subject: Add project-switch-project-by-name Date: Wed, 09 Dec 2020 16:14:55 +0100
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’.  As an example, see
‘dashboard-projects-switch-function’ at
https://github.com/emacs-dashboard/emacs-dashboard/blob/75f0c46db03b40ec983dbf4aa81e2ccb2e4a16ef/dashboard-widgets.el#L696

This patch adds a function ‘project-switch-project-by-name’, analogous
to ‘projectile-switch-project-by-name’.  I hope the diff makes it
through unmangled..

I have signed papers for emacs, in case this is not a trivial patch.



diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 449eadc3de..f83ad4f6fc 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1280,12 +1280,19 @@ project-switch-project
 The available commands are presented as a dispatch menu
 made from `project-switch-commands'."
   (interactive)
-  (let ((dir (project-prompt-project-dir))
-        (choice nil))
+  (let ((dir (project-prompt-project-dir)))
+    (project-switch-project-by-name dir)))
+
+;;;###autoload
+(defun project-switch-project-by-name (project-root)
+  "\"Switch\" to the project in PROJECT-ROOT and run an Emacs command.
+The available commands are presented as a dispatch menu made from
+`project-switch-commands'."
+  (let ((choice nil))
     (while (not choice)
       (setq choice (assq (read-event (project--keymap-prompt))
                          project-switch-commands)))
-    (let ((default-directory dir)
+    (let ((default-directory project-root)
           (project-current-inhibit-prompt t))
       (call-interactively (nth 2 choice)))))
 



--- End Message ---
--- Begin Message --- Subject: Re: bug#45134: Add project-switch-project-by-name Date: Wed, 9 Dec 2020 22:57:48 +0200 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0
Version: 28.1

On 09.12.2020 22:21, Rudolf Schlatte wrote:
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!

Thanks for checking! Pushed in 5af6a87d51.


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]