aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2011-07-03 23:31:40 -0700
committerPaul Eggert2011-07-03 23:31:40 -0700
commit396cec7251b26e5d37e9359dbf6a1b63c8f3a9e2 (patch)
tree9c07e4d3f64cca4127ad08dc278a20f0c816d18d
parent3ca74e5368a1022e332a0601d9be2418dbe8c083 (diff)
parent08235028a6a355a4b4afe993ac0939137aae5976 (diff)
downloademacs-396cec7251b26e5d37e9359dbf6a1b63c8f3a9e2.tar.gz
emacs-396cec7251b26e5d37e9359dbf6a1b63c8f3a9e2.zip
Merge: timer.el: Use time-date fns rather than rolling our own.
This is simpler and helps future-proof the code. * emacs-lisp/timer.el (timer-until): Use time-subtract and float-time. (timer--time-less-p): Use time-less-p.
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/emacs-lisp/timer.el14
2 files changed, 9 insertions, 12 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 93cf3c44033..b5d9005c510 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
12011-07-04 Paul Eggert <eggert@cs.ucla.edu>
2
3 * emacs-lisp/timer.el: Use time-date fns rather than rolling our own.
4 This is simpler and helps future-proof the code.
5 (timer-until): Use time-subtract and float-time.
6 (timer--time-less-p): Use time-less-p.
7
12011-07-04 Juanma Barranquero <lekktu@gmail.com> 82011-07-04 Juanma Barranquero <lekktu@gmail.com>
2 9
3 * type-break.el (timep): Use the value of `float-time' to avoid a 10 * type-break.el (timep): Use the value of `float-time' to avoid a
diff --git a/lisp/emacs-lisp/timer.el b/lisp/emacs-lisp/timer.el
index 27fd79a6ad2..0e007ff7176 100644
--- a/lisp/emacs-lisp/timer.el
+++ b/lisp/emacs-lisp/timer.el
@@ -119,14 +119,7 @@ SECS may be either an integer or a floating point number."
119 119
120(defun timer--time-less-p (t1 t2) 120(defun timer--time-less-p (t1 t2)
121 "Say whether time value T1 is less than time value T2." 121 "Say whether time value T1 is less than time value T2."
122 ;; FIXME just use time-less-p. 122 (time-less-p (timer--time t1) (timer--time t2)))
123 (destructuring-bind (high1 low1 micro1) (timer--time t1)
124 (destructuring-bind (high2 low2 micro2) (timer--time t2)
125 (or (< high1 high2)
126 (and (= high1 high2)
127 (or (< low1 low2)
128 (and (= low1 low2)
129 (< micro1 micro2))))))))
130 123
131(defun timer-inc-time (timer secs &optional usecs) 124(defun timer-inc-time (timer secs &optional usecs)
132 "Increment the time set in TIMER by SECS seconds and USECS microseconds. 125 "Increment the time set in TIMER by SECS seconds and USECS microseconds.
@@ -258,10 +251,7 @@ how many will really happen.")
258 "Calculate number of seconds from when TIMER will run, until TIME. 251 "Calculate number of seconds from when TIMER will run, until TIME.
259TIMER is a timer, and stands for the time when its next repeat is scheduled. 252TIMER is a timer, and stands for the time when its next repeat is scheduled.
260TIME is a time-list." 253TIME is a time-list."
261 ;; FIXME: (float-time (time-subtract (timer--time timer) time)) 254 (float-time (time-subtract time (timer--time timer))))
262 (let ((high (- (car time) (timer--high-seconds timer)))
263 (low (- (nth 1 time) (timer--low-seconds timer))))
264 (+ low (* high 65536))))
265 255
266(defun timer-event-handler (timer) 256(defun timer-event-handler (timer)
267 "Call the handler for the timer TIMER. 257 "Call the handler for the timer TIMER.