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

From: Drew Adams <[email-masked]>
Date: Thu, 27 Mar 2025 15:45:44 +0000

> > > 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.
> 
> Btw, a possibly even better way is to modify the cursor looks from the
> hooks of the relevant commands, like overwrite-mode.  If some of them
> don't have a hook, we could add a hook.  This is better because it
> doesn't unnecessarily "punish" Emacs anywhere else, only the commands
> that could affect the cursor.
> 
> Does this make sense?

It does make sense, to me.
However, FWIW (haven't read all of this thread):

Based on input from Juri and others many moon ago, library `cursor-chg.el' has used pre(post)-command-hook since 2006 to optionally change the cursor shape for overwrite/read-only, idleness, and/or use of an input method. Minor mode `change-cursor-mode' does all but the idleness, which is done by `curchg-toggle-cursor-when-idle'.

I agree with the general motivation not to overuse pre(post)-command-hook, but FWIW I haven't noticed any problems with the use made of it in this case.

https://www.emacswiki.org/emacs/ChangingCursorDynamically

https://www.emacswiki.org/emacs/download/cursor-chg.el