[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master e1708697122: Improve behavior with project-switch-use-entire-map=
From: |
Dmitry Gutov |
Subject: |
master e1708697122: Improve behavior with project-switch-use-entire-map=t |
Date: |
Thu, 19 Oct 2023 18:26:13 -0400 (EDT) |
branch: master
commit e170869712295a97815044a89fa4157450f1674d
Author: Dmitry Gutov <dmitry@gutov.dev>
Commit: Dmitry Gutov <dmitry@gutov.dev>
Improve behavior with project-switch-use-entire-map=t
* lisp/progmodes/project.el (project--keymap-prompt): New function.
(project--switch-project-command): Use it when
project-switch-use-entire-map is non-nil. Also check that CHOICE
is not a number (bug#63648). And print incorrect inputs too.
---
lisp/progmodes/project.el | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 4a47b4e94a1..0d6539113cc 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1941,6 +1941,15 @@ Otherwise, use the face `help-key-binding' in the
prompt."
:version "30.1")
(defun project--keymap-prompt ()
+ "Return a prompt for the project switching using the prefix map."
+ (let (keys)
+ (map-keymap
+ (lambda (evt _)
+ (when (characterp evt) (push evt keys)))
+ project-prefix-map)
+ (mapconcat (lambda (key) (help-key-description (string key) nil)) keys "
")))
+
+(defun project--menu-prompt ()
"Return a prompt for the project switching dispatch menu."
(mapconcat
(pcase-lambda (`(,cmd ,label ,key))
@@ -1979,11 +1988,22 @@ Otherwise, use the face `help-key-binding' in the
prompt."
(when-let ((cmd (nth 0 row))
(keychar (nth 2 row)))
(define-key temp-map (vector keychar) cmd)))))
- command)
+ command
+ choice)
(while (not command)
(let* ((overriding-local-map commands-map)
- (choice (read-key-sequence (project--keymap-prompt))))
+ (prompt (if project-switch-use-entire-map
+ (project--keymap-prompt)
+ (project--menu-prompt))))
+ (when choice
+ (setq prompt (concat prompt
+ (format " %s: %s"
+ (propertize "Unrecognized input"
+ 'face 'warning)
+ (help-key-description choice nil)))))
+ (setq choice (read-key-sequence (concat "Choose: " prompt)))
(when (setq command (lookup-key commands-map choice))
+ (when (numberp command) (setq command nil))
(unless (or project-switch-use-entire-map
(assq command commands-menu))
;; TODO: Add some hint to the prompt, like "key not
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master e1708697122: Improve behavior with project-switch-use-entire-map=t,
Dmitry Gutov <=