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

From: Eli Zaretskii <[email-masked]>
Date: Thu, 27 Mar 2025 13:14:45 +0200

> From: Daniel Mendler <[email-masked]>
> Cc: [email-masked],  [email-masked],  [email-masked]
> Date: Thu, 27 Mar 2025 10:42:21 +0100
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> >> The problem with the idle timer is that it might not run immediately.
> >
> > That depends on the value of the SECS argument to run-with-idle-timer,
> > doesn't it.
> 
> No, there is no guarantee that the idle timer will run soon enough after
> the given time if Emacs stays busy.

If Emacs is busy, the post-command-hook will not run, either.  When a
command exits, it return to the main loop, and unless the user types
something before that, Emacs then becomes "idle".

> > Sorry, I object to adding stuff to post-command-hook in these cases.
> > Emacs becomes very sluggish, and we should avoid that as much as we
> > can.
> 
> I see your point about sluggishness and I am very careful myself to not
> enable modes which add expensive computations to the
> `post-command-hook'. Nevertheless in this case using the
> `post-command-hook' is the right thing, such that the `cursor-type' is
> changed effective immediately, as had been done before in CUA, see
> `cua--post-command-handler-1'. The computation in this case is not
> expensive.

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.