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

From: Eli Zaretskii <[email-masked]>
Date: Thu, 09 Apr 2015 18:06:01 +0300

> From: Tassilo Horn <[email-masked]>
> Date: Thu, 09 Apr 2015 16:50:56 +0200
> 
> Sometimes it occurs to me that `blink-cursor-mode' stops blinking the
> cursor for some time.  That temporary stop might also occur in the
> off-phase so that there's no visible cursor anymore.  As soon as I press
> some key, the blinking starts again.  But just now in some specific
> buffer, it'll blink twice and then disappear until I press a key again.

It generally means that some other time, probably an idle time, takes
more than 0.5 sec to do its job.

> Then I added a (message "BLINK") as the first form in
> `blink-cursor-timer-function'.  And strangely, when the blinking stops
> for whatever reason, I can still see BLINK [53 times] with increasing
> repetition count in *Messages*.

The contents of "*Messages*" is modified by Lisp code, while to see
the cursor blinking you need to have a redisplay cycle.  Emacs will
not enter redisplay if it has something else to do, like some timer
that is ripe and needs to be run.

> So the problem seems to be that
> 
>   (internal-show-cursor nil (not (internal-show-cursor-p)))
> 
> stops working for some unknown reason.

No, I don't think this conclusion is correct, see above.

> Then I changed my message to
> 
>   (message "BLINK: %s" (internal-show-cursor-p))
> 
> and now I get alternating
> 
>   BLINK: nil
>   BLINK: t
> 
> sequences even though the cursor has stopped blinking already.  So I
> guess the problem is that no redisplay is performed which would make the
> visibility toggle of the cursor effective, and thus don't notice that
> the cursor should have been visible/invisible for the last half of a
> second.

Exactly.

> Of course, that doesn't happen always and I've not been able reproduce
> it using emacs -Q.  I think I get this problem most frequently when
> editing large LaTeX files with AUCTeX but I think I got it also in some
> other buffers already, so this observation might only show that I'm
> writing LaTeX documents a good bit of my time.

Look at your other times, and find the one which takes too much time
for doing its job.