I'd like to use avy by writing a command that does the following: first, it should ask for a key combination. Then it should call interactively, say, avy-goto-line
to select a position, where it sets the mark. Then it should call avy-goto-line
again to jump to another position, marking the interval between the mark and the new position of point. Then it should apply the command corresponding to the key sequence at the beginning to the selected region. So something like
(defun test (x)
"Test function"
(interactive (list (read-key-sequence-vector "Command: ")))
;; (call-interactively #'avy-goto-line)
;; (call-interactively #'set-mark-command)
;; (call-interactively #'avy-goto-line)
(call-interactively (keymap-lookup global-map x)))
However, if I evaluate that function I get the error
keymap--check: [20] is not a valid key definition; see ‘key-valid-p’
I also tried using read-key-sequence
and read-event
but neither worked, even though read-event
returned a string. I checked key-valid-p
but it didn't say how to convert the output of those read-commands into a form that is valid for it, and the Emacs manual said all other keymap commands use keymap-lookup. Furthermore, a lot of my keys are only representable as vectors. Is there some way I can convert the data into a form suitable for keymap-lookup
or similar?