Subject: Re: bug#77224: [PATCH] New minor mode 'cursor-indicators-mode'

From: Juri Linkov <[email-masked]>
Date: Fri, 28 Mar 2025 09:30:03 +0200

> I've updated the patch which should use the mode hook instead using
> post-command-hook or idle timers (and allows (implicitly) to user use
> post-command-hook (but that is user responsibility add it or not)).
>
> Also this should refresh the cursor while switching windows.
>
> However I've deleted the function/lambdas support as conditions because
> i found it problematic.
>
> I've test it only for overwrite-mode, I ask if anyone wants to give it a
> try.

Please note that this is insufficient for 'repeat-mode'.
Currently it requires adding an advice to update the cursor
on the repeat timer events:

  (add-function :after repeat-echo-function #'cursor-indicators--update-indications)

since need to update the cursor when the timer is fired:

  (run-with-idle-timer timeout nil #'repeat-exit)
  (defun repeat-exit ()
    (setq repeat-in-progress nil)
    (funcall repeat-echo-function nil))

This problem can be solved by adding a hook:

  (defun repeat-exit ()
    (setq repeat-in-progress nil)
    (funcall repeat-echo-function nil)
    (run-hooks 'repeat-exit-hook))

Then 'cursor-indicators-mode' needs to add this hook:

  (define-minor-mode cursor-indicators-mode
    ...
    (add-hook 'repeat-exit-hook #'cursor-indicators--update-indications)

Then maybe it's possible to add more hooks for other features as well.

The drawback of this approach is that specific hooks make the cursor updating
less reliable than with using post-command-hook.