Subject: Re: bug#15045: Point jumps inappropriately around time of Semantic lexing

From: Stefan Monnier <[email-masked]>
Date: Tue, 15 Oct 2013 22:57:29 -0400

> of (sit-for 0) doesn't change. It would no longer run timers if only
> input-pending-p changes as described. Currently:

>   (defun sit-for (seconds &optional nodisp obsolete)
>     [...]
>     (cond
>      [...]
>      ((input-pending-p)
>       nil)
>      ((<= seconds 0)
>       (or nodisp (redisplay)))
>      [...]

Indeed, the Elisp version of sit-for is a mess.

> I considered whether (<= seconds 0) could fall through to the t case
> instead.

The easiest solution is to add an optional argument `check-timers' to
input-pending-p, so you can preserve the exact same behavior.
In the long run, we should try and clean up sit-for, but you may not
have the courage to dig into this right now.

> Looking ahead to the concurrency branch, should (sit-for 0 t) and
> (thread-yield) have different behaviors?

Not really.

> I don't see thread-yield checking for timers to run, should it?

Yes, it should.

> (And it didn't look like timers were split out into their own threads
> on the concurrency branch.)

The current state of the concurrency branch is not always
representative of what it should ideally look like ;-)
But even if timers are made to belong to a thread, thread-yield should
probably check timers.

        Stefan