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


Message #104 received at 77224 <at> debbugs.gnu.org (full text, mbox):

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: Re: bug#77224: [PATCH] New minor mode 'cursor-indicators-mode'
Date: Thu, 27 Mar 2025 21:17:25 +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 17:39:59 +0100
>> 
>> Eli Zaretskii <eliz <at> gnu.org> writes:
>> 
>> > 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.
>
> No, the idle time is run immediately if there's no input.  Emacs
> doesn't wait or delay the timer.

We are saying the same thing here. Yes, if there is no input, the idle
timer will run immediately. But if the user continues typing and events
are in the queue, then the timer will not run for some time. A delay
also occurs when an asynchronous process runs and fills a buffer in the
background like the *compilation* buffer. Then the cursor update will
lag behind.

I am with you that one should not carelessly add `post-command-hooks'. I
use various modes which use `post-command-hooks', idle timers and
regular timers, each for their proper use case. For example
`post-command-hooks' lead to sluggishness if they were used for auto
completion, spell checking or help at point (like Eldoc). For such use
cases idle timers or regular timers are the better tool since they defer
the expensive computation of completion strings, talking to a language
server, completion backend or a spell checker.

Here we discuss changing only the color of the cursor, a much much less
complex operation. The `cursor-type' update and checking a few variables
to find the color is a cheap operation which will not lead to
sluggishness. If this were an expensive operation, I would look
elsewhere for places to optimize, but avoiding `post-command-hook' is
not the solution.

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.