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

From: Daniel Mendler <[email-masked]>
Date: Thu, 27 Mar 2025 17:39:59 +0100

Eli Zaretskii <[email-masked]> writes:

>> From: Daniel Mendler <[email-masked]>
>> Cc: [email-masked],  [email-masked],  [email-masked]
>> Date: Thu, 27 Mar 2025 17:04:09 +0100
>> 
>> Eli Zaretskii <[email-masked]> writes:
>> 
>> > I disagree that the cursor must change "immediately", in the rigorous
>> > sense of that word.  I think if it changes after 10 or 20 or 50
>> > milliseconds, that's "immediately" for any practical purpose.
>> 
>> No, 50ms are not acceptable for the user if they except an immediate
>> response to a key press.
>
> 50ms was just an example, and it is actually quite improbable to be
> that large.
>
> post-command-hook is run by the same loop that decides that Emacs is
> idle and runs timers, so the difference in practice should be very
> small if at all.

The `post-command-hook' is guaranteed to run after a command while the
idle timer is delayed until no new events are in the queue. This is why
I argue that the delay can be too large, such that it will become
noticeable.

>> Regarding Emacs sluggishness, the `cursor-indicators-mode' is an
>> optional mode. If it increases sluggishness unnacceptably (which it
>> won't), users can turn it off.
>
> Experience shows that many users turn on a lot of features which rely
> on post-command-hook, and then complain that Emacs is slow to respond.
> Telling them to turn off features they like doesn't really work.

I agree that this is a problem. However in this case the PCH will not
cause problems, as has also been noted by Drew and as has been shown by
CUA over the years. In contrast the idle timer will cause problems. I am
actually looking forward to using `cursor-indicators-mode', but if it
operates with an idle timer, I don't think it will indicate the editing
status reliably enough.

> Anyway, I think making the cursor change from a mode hook is a better
> solution.

As has been mentioned, the problem is that not every scenario is covered
by hooks, while the PCH is a potentially universal solution which can
check arbitrary conditions. But if hooks work sufficiently well for most
scenarios, then why not.

I think Stefan and Juri should chime in with their experience about
this, since as I've seen, they both want to replace some custom cursor
code with the new mode in their configuration.

Daniel