For a long time I've used a common emacs hydra to navigate expressions, along the lines of
(defhydra hydra-word (:color red) "word"
("M-f" forward-word)
("M-b" backward-word)
("f" forward-word)
("b" backward-word)
;; etc..
)
But an annoying issue I always have: pressing a number is interpreted as a prefix argument when I always mean to simply insert a number. I looked through the hydra wiki, but couldn't find an answer to disable prefix interpretation. I know I can write a ("1" self-insert-command nil :exit t)
for each number, but that's dumb and results in a bunch of extra functions created.
How can I disable interpretation of prefix arg during an active hydra? And, I guess more generally is there a way to temporarily disable interpretation of prefix arguments.
After looking through the code I found you can override hydras base map which is like universal-argument-map
. So, to implement the above with only C-u starting a prefix, but all numbers and -
self-inserting, the following works
(defhydra hydra-word (:color red :base-map (make-sparse-keymap)) "word"
("M-f" forward-word)
("M-b" backward-word)
("f" forward-word)
("b" backward-word)
;; etc..
)