susam / devil

Emacs minor mode that intercepts and translates keystrokes to provide a modifier-free non-modal editing experience
https://susam.github.io/devil/
Other
167 stars 9 forks source link

Add optional repeat suppression #24

Open morganwillcock opened 7 months ago

morganwillcock commented 7 months ago

This change introduces an option which allows translated key bindings to avoid being repeated, to be used by Devil or by other packages where the Devil repeat map should not be activated.

Repeat suppression is configured by maintaining a list of functions which are treated as repeat suppression predicates. Interactive functions will not be repeated when their symbol is a list member. Non-interactive functions are called with the binding as the argument and should return a non-nil value when the repeat should be suppressed.

By default the predicate list contains the symbol devil--isearch-suppress-repeat-p which suppresses the repeat of isearch-forward while the isearch specific mode map is not active. This fixes initiating an isearch with the default list of repeatable keys and trying to enter the letter 's' as the search criteria.


I have ended up with this solution as a way to fix problems I was having with C-s being repeated after the isearch search is activated, i.e. it didn't seem possible to enter a search string which began with the letter 's'. I'm not particularly sure on how efficient the test of the active keymap is, but I've not noticed any issues with it so far.

There may be other solutions or more efficient ways to solve this particular problem, but using the list of predicates would also allow other packages to opt their key presses out of being repeated where the activation of the repeat map is problematic.