diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 92293d0e2d..54bacc598e 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -805,15 +805,11 @@ project-switch-commands command to run when KEY is pressed. LABEL is used to distinguish the choice in the dispatch menu.") -(defun project--keymap-prompt () - "Return a prompt for the project swithing dispatch menu." - (mapconcat +(defun project--switch-choices () + (mapcar (pcase-lambda (`(,key ,label)) - (format "[%s] %s" - (propertize (key-description `(,key)) 'face 'bold) - label)) - project-switch-commands - " ")) + (list (aref key 0) label)) + project-switch-commands)) ;;;###autoload (defun project-switch-project () @@ -822,17 +818,12 @@ project-switch-project and presented in a dispatch menu." (interactive) (let ((dir (project-prompt-project-dir)) - (choice nil)) - (while (not (and choice - (or (equal choice (kbd "C-g")) - (assoc choice project-switch-commands)))) - (setq choice (read-key-sequence (project--keymap-prompt)))) - (if (equal choice (kbd "C-g")) - (message "Quit") - (let ((default-directory dir) - (project-current-inhibit-prompt t)) - (call-interactively - (nth 2 (assoc choice project-switch-commands))))))) + (choice (read-multiple-choice "Action:" + (project--switch-choices)))) + (let ((default-directory dir) + (project-current-inhibit-prompt t)) + (call-interactively + (nth 2 (assoc (string choice) project-switch-commands)))))) (provide 'project) ;;; project.el ends here