unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#45134: Add project-switch-project-by-name
@ 2020-12-09 15:14 Rudolf Schlatte
  2020-12-09 15:21 ` Lars Ingebrigtsen
  2020-12-09 19:36 ` Dmitry Gutov
  0 siblings, 2 replies; 7+ messages in thread
From: Rudolf Schlatte @ 2020-12-09 15:14 UTC (permalink / raw)
  To: 45134

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)))))
 





^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-12-09 20:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-09 15:14 bug#45134: Add project-switch-project-by-name Rudolf Schlatte
2020-12-09 15:21 ` Lars Ingebrigtsen
2020-12-09 15:42   ` Rudolf Schlatte
2020-12-09 15:47     ` Rudolf Schlatte
2020-12-09 19:36 ` Dmitry Gutov
2020-12-09 20:21   ` Rudolf Schlatte
2020-12-09 20:57     ` Dmitry Gutov

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).