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

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

bug#41890: 28.0.50; [PATCH]: Add bindings for project.el


From: Philip K.
Subject: bug#41890: 28.0.50; [PATCH]: Add bindings for project.el
Date: Wed, 17 Jun 2020 12:51:07 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Juri Linkov <juri@linkov.net> writes:

> I think your choice of keys is better than in project-switch-commands.
> Maybe these keys should be copied to project-switch-commands, so it will to be
> in sync with project-prefix-map?
>
> Or is it possible to use project-prefix-map directly in 
> project-switch-commands?
> For example, by using set-transient-map?

I tried implementig it, and it seems to work. The patch below isn't a
full commit, since I changed the structure of project-switch-commands
(it's now mapping command to description), but didn't update the
docstring.

-- 
        Philip K.

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index c5301dccd3..6cb9811d3d 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -860,12 +879,12 @@ project-prompt-project-dir
 
 ;;;###autoload
 (defvar project-switch-commands
-  '((?f "Find file" project-find-file)
-    (?r "Find regexp" project-find-regexp)
-    (?d "Dired" project-dired)
-    (?v "VC-Dir" project-vc-dir)
-    (?s "Shell" project-shell)
-    (?e "Eshell" project-eshell))
+  '((project-find-file "Find file")
+    (project-find-regexp "Find regexp")
+    (project-dired "Dired")
+    (project-vc-dir "VC-Dir")
+    (project-shell "Shell")
+    (project-eshell "Eshell"))
   "Alist mapping keys to project switching menu entries.
 Used by `project-switch-project' to construct a dispatch menu of
 commands available upon \"switching\" to another project.
@@ -877,9 +896,10 @@ project-switch-commands
 (defun project--keymap-prompt ()
   "Return a prompt for the project swithing dispatch menu."
   (mapconcat
-   (pcase-lambda (`(,key ,label))
+   (pcase-lambda (`(,cmd ,label))
      (format "[%s] %s"
-             (propertize (key-description `(,key)) 'face 'bold)
+             (propertize (key-description (where-is-internal cmd 
project-prefix-map t))
+                         'face 'bold)
              label))
    project-switch-commands
    "  "))
@@ -890,14 +910,10 @@ project-switch-project
 The available commands are picked from `project-switch-commands'
 and presented in a dispatch menu."
   (interactive)
-  (let ((dir (project-prompt-project-dir))
-        (choice nil))
-    (while (not choice)
-      (setq choice (assq (read-event (project--keymap-prompt))
-                         project-switch-commands)))
-    (let ((default-directory dir)
-          (project-current-inhibit-prompt t))
-      (call-interactively (nth 2 choice)))))
+  (let ((default-directory (project-prompt-project-dir))
+        (project-current-inhibit-prompt t))
+    (message "%s" (project--keymap-prompt))
+    (set-transient-map project-prefix-map)))
 
 (provide 'project)
 ;;; project.el ends here

reply via email to

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