Let's say I want to write a mode which updates the display (e.g. adds some annotation) when the user edits the buffer or just moves around.
What is the recommended way to implement this?
sit-for, so my function does its work when the user becomes idle after a command:
(defun my-post-command ()
(when (sit-for 0.3)
Or an idle timer:
(run-with-idle-timer 0.3 t 'my-post-command)
The drawback of
post-command-hook is that it holds up the hook with the delay if some other hook function comes after it.
The drawback of idle timer is that it's global, so there can be no buffer local timer, so if one implements some minor mode then the timer has to be deactivated/activated when the user switches buffers.
Is there a better/recommended method for this?