GNU bug report logs - #77224
[PATCH] New minor mode 'cursor-indicators-mode'

Previous Next

Package: emacs;

Reported by: Elijah Gabe Pérez <eg642616 <at> gmail.com>

Date: Sun, 23 Mar 2025 22:59:03 UTC

Severity: normal

Tags: patch

Full log


View this message in rfc822 format

From: Daniel Mendler <mail <at> daniel-mendler.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 77224 <at> debbugs.gnu.org, eg642616 <at> gmail.com, juri <at> linkov.net
Subject: bug#77224: [PATCH] New minor mode 'cursor-indicators-mode'
Date: Thu, 27 Mar 2025 17:04:09 +0100
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Daniel Mendler <mail <at> daniel-mendler.de>
>> Cc: eg642616 <at> gmail.com,  77224 <at> debbugs.gnu.org,  juri <at> linkov.net
>> Date: Thu, 27 Mar 2025 10:42:21 +0100
>> 
>> Eli Zaretskii <eliz <at> gnu.org> 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".

There is a difference. When Emacs executes a command and hangs during
command execution it is expected that the cursor does not update
immediately. The cursor will however update after the command has
finished. The commands which we talk about regarding cursor changes are
usually executed quickly, like enabling some modes like `overwrite-mode'.

>> > 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.

No, 50ms are not acceptable for the user if they except an immediate
response to a key press. I have seen bug reports to my packages where
people complained about latency in the range of 10 to 20ms.

The problem is also that idle timers are not bounded. If the user
continues on typing, Emacs won't become idle and the cursor can change
much later. This would look like a bug then.

Again - CUA also used a `post-command-hook'. Why not preserve this,
given that the mode is essentially extracted from CUA where it works
well? I see your point about using specialized hooks though (e.g.
`overwrite-mode-hook'), but this will make customization much more
difficult, and for some variables there might not be a hook.

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.

Daniel




This bug report was last modified 64 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.