Function: embark-keymap-prompter
embark-keymap-prompter is a byte-compiled function defined in
embark.el.
Signature
(embark-keymap-prompter KEYMAP UPDATE)
Documentation
Let the user choose an action using the bindings in KEYMAP.
Besides the bindings in KEYMAP, the user is free to use all their
key bindings and even M-x (execute-extended-command) to select a command.
UPDATE is the indicator update function.
Source Code
;; Defined in ~/.emacs.d/elpa/embark-20260610.302/embark.el
(defvar embark-indicators) ; forward declaration
(defun embark-keymap-prompter (keymap update)
"Let the user choose an action using the bindings in KEYMAP.
Besides the bindings in KEYMAP, the user is free to use all their
key bindings and even \\[execute-extended-command] to select a command.
UPDATE is the indicator update function."
(let* ((keys (let ((overriding-terminal-local-map keymap))
(embark--read-key-sequence update)))
(cmd (let ((overriding-terminal-local-map keymap))
(key-binding keys 'accept-default))))
;; Set last-command-event as it would be from the command loop.
;; Previously we only set it locally for digit-argument and for
;; the mouse scroll commands handled in this function. But other
;; commands can need it too! For example, electric-pair-mode users
;; may wish to bind ( to self-insert-command in embark-region-map.
;; Also, as described in issue #402, there are circumstances where
;; you might run consult-narrow through the embark-keymap-prompter.
(setq last-command-event (aref keys (1- (length keys))))
(pcase cmd
((or 'embark-keymap-help
(and 'nil ; cmd is nil but last key is help-char
(guard (eq help-char (aref keys (1- (length keys)))))))
(let ((embark-indicators
(cl-set-difference embark-indicators
'(embark-verbose-indicator
embark-mixed-indicator)))
(prefix-map
(if (eq cmd 'embark-keymap-help)
keymap
(let ((overriding-terminal-local-map keymap))
(key-binding (seq-take keys (1- (length keys)))
'accept-default))))
(prefix-arg prefix-arg)) ; preserve prefix arg
(when-let* ((win (get-buffer-window embark--verbose-indicator-buffer
'visible)))
(quit-window 'kill-buffer win))
(embark-completing-read-prompter prefix-map update)))
((or 'universal-argument 'universal-argument-more
'negative-argument 'digit-argument 'embark-toggle-quit)
;; prevent `digit-argument' from modifying the overriding map
(let ((overriding-terminal-local-map overriding-terminal-local-map))
(command-execute cmd))
(embark-keymap-prompter
(make-composed-keymap universal-argument-map keymap)
update))
((or 'minibuffer-keyboard-quit 'abort-recursive-edit 'abort-minibuffers)
nil)
((guard (let ((def (lookup-key keymap keys))) ; if directly
; bound, then obey
(and def (not (numberp def))))) ; number means "invalid prefix"
cmd)
((and (pred symbolp)
(guard (string-suffix-p "self-insert-command" (symbol-name cmd))))
(minibuffer-message "Not an action")
(embark-keymap-prompter keymap update))
((or 'scroll-other-window 'scroll-other-window-down)
(let ((minibuffer-scroll-window
;; NOTE: Here we special case the verbose indicator!
(or (get-buffer-window embark--verbose-indicator-buffer 'visible)
minibuffer-scroll-window)))
(ignore-errors (command-execute cmd)))
(embark-keymap-prompter keymap update))
((or 'scroll-bar-toolkit-scroll 'mwheel-scroll
'mac-mwheel-scroll 'pixel-scroll-precision)
(funcall cmd last-command-event)
(embark-keymap-prompter keymap update))
('execute-extended-command
(let ((prefix-arg prefix-arg)) ; preserve prefix arg
(intern-soft (read-extended-command))))
((or 'keyboard-quit 'keyboard-escape-quit)
nil)
(_ cmd))))