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

From: Daniel Mendler <[email-masked]>
Date: Thu, 27 Mar 2025 06:48:15 +0100

Elijah Gabe Pérez <[email-masked]> writes:

> Eli Zaretskii <[email-masked]> writes:
>
>>> From: Juri Linkov <[email-masked]>
>>> Cc: Eli Zaretskii <[email-masked]>,  [email-masked]
>>> Date: Wed, 26 Mar 2025 09:58:06 +0200
>
>>> > I've updated the patch following Juri suggestions.
>>> > Now all the conditions are inside a single defcustom.
>
>>> Thanks!  I tested that everything works nicely.
>>> There is only one small problem for repeat-mode:
>
>>> > +        (add-hook 'post-command-hook #'cursor-indicators--update-indications)
>
>>> It would be better to use a large value DEPTH for add-hook
>>> to add the hook to the end.  The problem is that repeat-mode
>>> also uses the same hook 'post-command-hook'.  So the cursor
>>> indication hook should be called afterwards as the last hook.
>
>> Would it be better to use an idle timer instead?  post-command-hook
>> tends to make Emacs sluggish.
>
> Yeah, that is that what worried me when i decided to use that hook.
>
> I've fixed the patch to use only idle-timer instead.

The problem with the idle timer is that it might not run immediately.
However when the user changes the input method, overwrite mode or
similar, the users expects that the cursor reflects the change
immediately after the last key press and does not lag behind. Therefore
I think there is no alternative to the `post-command-hook'. It seems to
me that only a bunch of mode variables are checked and then
`cursor-type' is set. In CUA the cursor indicator is also updated in the
`post-command-hook'. So this should not be too costly?

Daniel