Subject: Re: bug#5931: Turning off blink-cursor-mode does not stop blink-cursor-timer immediately

From: Lennart Borgman <[email-masked]>
Date: Tue, 4 May 2010 02:30:19 +0200

On Sun, Apr 11, 2010 at 10:56 PM, Stefan Monnier
<[email-masked]> wrote:
>> Which can lead to some problems.
>
> Could you give us some details of the kinds of problem you encountered?
>
>> Could we please just stop this timer
>> when turning off blink-cursor-mode?
>> Just add a line like
>>       (when (timerp blink-cursor-timer) (cancel-timer blink-cursor-timer))
>
> I'd rather call blink-cursor-end, then.
> And yes, that would seem like a good idea.  But I'd still like to know
> why you think it's important enough.

Perhaps it is not very important but I still think it should be done.
I thought I had a reason, but it turned out that calling
blink-cursor-end does not solve the problem I see.

I see a strange problem where I believe I cancel a timer, but it
somehow survives. At the moment I have no other way to reproduce it
then the example below.

I have a minor mode called h-needed-mode in the package nXhtml. This
try to highlight the current line (and optionally column) when it is
needed. To see the problem do like this:

- set hl-need-mark-column to nil (I have forgotten to change the default)
- set hl-needed-flash-duration to 0.5 (not sure this is needed but
that is what I have)
- turn on hl-needed-mode
- turn on blink-cursor-mode
- visit an elisp file.
- divide the frame in two windows visiting this file.
- jump between them
- wait until the line is highlighted
- then jump again

Now the cursor should blink faster. Examining the timer lists (use M-x
describe-timers in nXhtml) there is now an entry in timer-list:

    2010-05-04 00:16:19.5 0.65  (`blink-cursor-timer-function' nil)

This should not be there. However this does not happen every time.

There is a few lines in hl-needed.el where I call blink-cursor-mode
and blink-cursor-end.

It looks to me like what is happening is that when blink-cursor-timer
is canceled it somehow survives, maybe because it is a repeating
timer.