Subject: Re: bug#24585: 25.1; avoid hack in ggtags.el to run compilation-auto-jump timer

From: Stefan Monnier <[email-masked]>
Date: Sun, 02 Oct 2016 16:35:57 -0400

> I think the hack in ggtags.el may be removed by the following patch to
> correct the said mistake:

IIUC this patch just changes the ordering for same-time timers.
Relying on either ordering is itself a hack.  We need a better solution.

What are those two timers whose relative execution order matters?
Why do they care in which order they're run?

        Stefan

> diff --git a/lisp/emacs-lisp/timer.el b/lisp/emacs-lisp/timer.el
> index c01ea497..337e1049 100644
> --- a/lisp/emacs-lisp/timer.el
> +++ b/lisp/emacs-lisp/timer.el
> @@ -130,9 +130,9 @@ floating point number."
>  	(setq delta (time-add delta (list 0 0 (or usecs 0) (or psecs 0)))))
>      (time-add time delta)))
 
> -(defun timer--time-less-p (t1 t2)
> +(defun timer--time-less-or-equal-p (t1 t2)
>    "Say whether time value T1 is less than time value T2."
> -  (time-less-p (timer--time t1) (timer--time t2)))
> +  (not (time-less-p (timer--time t2) (timer--time t1))))
 
>  (defun timer-inc-time (timer secs &optional usecs psecs)
>    "Increment the time set in TIMER by SECS seconds, USECS microseconds,
> @@ -172,7 +172,7 @@ fire repeatedly that many seconds apart."
>        (let ((timers (if idle timer-idle-list timer-list))
>  	    last)
>  	;; Skip all timers to trigger before the new one.
> -	(while (and timers (timer--time-less-p (car timers) timer))
> +	(while (and timers (timer--time-less-or-equal-p (car timers) timer))
>  	  (setq last timers
>  		timers (cdr timers)))
>  	(if reuse-cell