[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 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)))))
- bug#45134: Add project-switch-project-by-name,
Rudolf Schlatte <=