Subject: Re: bug#20285: 25.0.50; blink-cursor-mode sometimes stops blinking

From: Tassilo Horn <[email-masked]>
Date: Fri, 10 Apr 2015 16:13:44 +0200

Eli Zaretskii <[email-masked]> writes:

>> But I just verified that the timer function runs pretty regularly.  It
>> might not always be exactly 0.5 seconds between the runs but it's never
>> deferred for a time which would be clearly observable by a user.
>> 
>> In contrast, it's not seldom that redisplay doesn't happen for up to 10
>> seconds when emacs is idle but doing heavy processing in the background.
>> I can easily provoke that situation by compiling a large TeX document
>> with AUCTeX which puts the tex output in a buffer and has a process
>> filter on it.
>
> Maybe we should have a mechanism to force redisplay once in a while
> even if Emacs has something to do, and blink-cursor-mode could then
> activate that mechanism.

I can't read your brain but wouldn't it be possible (but unlikely) that
this mechanism always forces a redisplay when the cursor is in the
invisible state?

What I can imagine is `redisplay' having a second optional argument SECS
which would trigger a redisplay only if there hasn't been one in the
last SECS seconds.  Then `blink-cursor-timer-function' could do

  (internal-show-cursor nil (not (internal-show-cursor-p)))
  (when (internal-show-cursor-p)
    (redisplay 'force 2))

so that toggling the cursor to visible again forces a redisplay every 2
seconds.  Then, the worst situation that can occur is a cycle of cursor
invisible for 2 seconds, cursor visible for 0.5 seconds.  But that would
require that the heavy processing always starts after the redisplay
which made the cursor invisible and stops just after the cursor has been
set to visible again.  I guess that's very unlikely.

Bye,
Tassilo