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

From: Michael Heerdegen <[email-masked]>
Date: Fri, 28 Mar 2025 01:51:03 +0100

Eli Zaretskii <[email-masked]> writes:

> Would it be better to use an idle timer instead?  post-command-hook
> tends to make Emacs sluggish.

post-command-hook is the most general, and thus the simplest way to
implement something like this, but not necessarily a good way.  A
solution using such a general tool like post-command-hook also comes
with problems.  What if something adds something to post-command-hook
that changes one of the conditions that should trigger a cursor type
change?  And yes, obviously, the conditions are checked much too often
when using post-command-hook, and yes, people will complain because they
are will add conditions where checking is not that cheap.

Timers are a bit better, but are also far from optimal.

I would really prefer to use other hooks.  If we miss a hook, let's add
those hooks we miss.

Nearly all uses of hooks could be replaced by adding something to
post-command-hook, but the other hooks are there for a reason.  What's
different in this case that justifies this measure here (the question
does not go to Eli, obviously)?

If we can't use other hooks, are there other alternatives?  Variable
watchers have been mentioned - would using those be possible?  Or, could
we at least try to use the buffer local binding of post-command-hook, at
least for conditions that are buffer local anyway?

Michael.