I'm new to emacs lisp. I'm wondering if it's possible in elisp to listen on keyboard events while typing in a buffer. I read about the documentation of read-key-sequence / read-key-sequence-vector / read-event / read-key, turns out these commands block the buffering entering flow because when invoked, subsequent key strokes doesn't show up in the buffer. E.g. If I type "go" into current buffer then call read-key-sequence then type "o", the second "o" is treated as a command sequence not character of the buffer content text.
Though I may have found a way to work around this, that's to insert back the key stroke into the buffer programmatically:
(catch 'break
(while
(progn
(let
((strokes (read-key-sequence-vector nil)))
(if
(equal strokes [27 27 27])
(throw 'break nil)
(insert strokes)))
t)))
I would prefer to see if there are better ways to achieve this. It would be nice if elisp can do the event driven stuff like in javascript
someObject.addEventListener('keydown', function (e) { ... })
That's only my hope of course. :) Thanks.
pre-command-hookandpost-command-hookto do "magical" things. - Lindydancer