mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 18:40:39 -08:00
Allow complex key bindings in project-switch-project
* lisp/progmodes/project.el (project-switch-project): Replace read-event with an overriding local map and read-key-sequence to allow for complex key bindings to be read (bug#47620).
This commit is contained in:
parent
c105017c44
commit
5d293f4f74
1 changed files with 20 additions and 16 deletions
|
|
@ -1338,23 +1338,27 @@ made from `project-switch-commands'.
|
||||||
When called in a program, it will use the project corresponding
|
When called in a program, it will use the project corresponding
|
||||||
to directory DIR."
|
to directory DIR."
|
||||||
(interactive (list (project-prompt-project-dir)))
|
(interactive (list (project-prompt-project-dir)))
|
||||||
(let ((commands-menu
|
(let* ((commands-menu
|
||||||
(mapcar
|
(mapcar
|
||||||
(lambda (row)
|
(lambda (row)
|
||||||
(if (characterp (car row))
|
(if (characterp (car row))
|
||||||
;; Deprecated format.
|
;; Deprecated format.
|
||||||
;; XXX: Add a warning about it?
|
;; XXX: Add a warning about it?
|
||||||
(reverse row)
|
(reverse row)
|
||||||
row))
|
row))
|
||||||
project-switch-commands))
|
project-switch-commands))
|
||||||
command)
|
(commands-map
|
||||||
|
(let ((temp-map (make-sparse-keymap)))
|
||||||
|
(set-keymap-parent temp-map project-prefix-map)
|
||||||
|
(dolist (row commands-menu temp-map)
|
||||||
|
(when-let ((cmd (nth 0 row))
|
||||||
|
(keychar (nth 2 row)))
|
||||||
|
(define-key temp-map (vector keychar) cmd)))))
|
||||||
|
command)
|
||||||
(while (not command)
|
(while (not command)
|
||||||
(let ((choice (read-event (project--keymap-prompt))))
|
(let ((overriding-local-map commands-map)
|
||||||
(when (setq command
|
(choice (read-key-sequence (project--keymap-prompt))))
|
||||||
(or (car
|
(when (setq command (lookup-key commands-map choice))
|
||||||
(seq-find (lambda (row) (equal choice (nth 2 row)))
|
|
||||||
commands-menu))
|
|
||||||
(lookup-key project-prefix-map (vector choice))))
|
|
||||||
(unless (or project-switch-use-entire-map
|
(unless (or project-switch-use-entire-map
|
||||||
(assq command commands-menu))
|
(assq command commands-menu))
|
||||||
;; TODO: Add some hint to the prompt, like "key not
|
;; TODO: Add some hint to the prompt, like "key not
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue