I'd like to have certain keymap active when the cursor is in a particular highlighted area. For instance, I would like to bind
hl-todo-next to some easy key combination, but only when the cursor is on such a TODO item, as marked by
I understand that a piece of text or an overlay can have its own
keymap property which would work that way.
How do I best augment keymaps for highlighting already put by existing modes, such as
highlight-symbol-mode? Can I e.g. associate it with a particular named face?
Specifically, what would be a good way to:
- Add / update a keymap for a particular already highlighted fragment of text on which the cursor is currently positioned?
- Remove / restore that keymap when the highlighting vanishes (because of the cursor movement or the text being changed).
I definitely can just run a hook at every cursor movement, or character typed, or time elapsed; I wonder if there are nicer ways to do that, and are there any subtleties not immediately obvious from the elisp documentation.