aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2011-07-03 16:51:42 -0700
committerPaul Eggert2011-07-03 16:51:42 -0700
commit7b9430b4506b59298120a08737be9f4ad5b9cd49 (patch)
treeb503af46f63e1bd0e00ac1384f525e76493ba65b
parent1e49bfab49317e46540f13c4091200b211c24ba6 (diff)
downloademacs-7b9430b4506b59298120a08737be9f4ad5b9cd49.tar.gz
emacs-7b9430b4506b59298120a08737be9f4ad5b9cd49.zip
* type-break.el: Accept time formats that the builtins accept.
(timep, type-break-time-difference): Accept any format that float-time accepts, rather than insisting on (HIGH LOW USECS) format. This is simpler and helps future-proof the code. (type-break-time-difference): Round rather than ignoring subseconds components.
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/type-break.el17
2 files changed, 14 insertions, 12 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 5f1f09afb07..0dc4ca5e4ec 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
12011-07-03 Paul Eggert <eggert@cs.ucla.edu>
2
3 * type-break.el: Accept time formats that the builtins accept.
4 (timep, type-break-time-difference): Accept any format that
5 float-time accepts, rather than insisting on (HIGH LOW USECS) format.
6 This is simpler and helps future-proof the code.
7 (type-break-time-difference): Round rather than ignoring
8 subseconds components.
9
12011-07-03 Lars Magne Ingebrigtsen <larsi@gnus.org> 102011-07-03 Lars Magne Ingebrigtsen <larsi@gnus.org>
2 11
3 * info.el (Info-apropos-matches): Make non-interactive, since it 12 * info.el (Info-apropos-matches): Make non-interactive, since it
diff --git a/lisp/type-break.el b/lisp/type-break.el
index 2d6960c77bc..612c8cf4617 100644
--- a/lisp/type-break.el
+++ b/lisp/type-break.el
@@ -47,7 +47,7 @@
47;; or set the variable of the same name to `t'. 47;; or set the variable of the same name to `t'.
48 48
49;; This program can truly cons up a storm because of all the calls to 49;; This program can truly cons up a storm because of all the calls to
50;; `current-time' (which always returns 3 fresh conses). I'm dismayed by 50;; `current-time' (which always returns fresh conses). I'm dismayed by
51;; this, but I think the health of my hands is far more important than a 51;; this, but I think the health of my hands is far more important than a
52;; few pages of virtual memory. 52;; few pages of virtual memory.
53 53
@@ -501,12 +501,9 @@ variable of the same name."
501(defun timep (time) 501(defun timep (time)
502 "If TIME is in the format returned by `current-time' then 502 "If TIME is in the format returned by `current-time' then
503return TIME, else return nil." 503return TIME, else return nil."
504 (and (listp time) 504 (condition-case nil
505 (eq (length time) 3) 505 (progn (float-time time) time)
506 (integerp (car time)) 506 (error nil)))
507 (integerp (nth 1 time))
508 (integerp (nth 2 time))
509 time))
510 507
511(defun type-break-choose-file () 508(defun type-break-choose-file ()
512 "Return file to read from." 509 "Return file to read from."
@@ -993,12 +990,8 @@ FRAC should be the inverse of the fractional value; for example, a value of
993 990
994;; Compute the difference, in seconds, between a and b, two structures 991;; Compute the difference, in seconds, between a and b, two structures
995;; similar to those returned by `current-time'. 992;; similar to those returned by `current-time'.
996;; Use addition rather than logand since that is more robust; the low 16
997;; bits of the seconds might have been incremented, making it more than 16
998;; bits wide.
999(defun type-break-time-difference (a b) 993(defun type-break-time-difference (a b)
1000 (+ (lsh (- (car b) (car a)) 16) 994 (round (float-time (time-subtract b a))))
1001 (- (car (cdr b)) (car (cdr a)))))
1002 995
1003;; Return (in a new list the same in structure to that returned by 996;; Return (in a new list the same in structure to that returned by
1004;; `current-time') the sum of the arguments. Each argument may be a time 997;; `current-time') the sum of the arguments. Each argument may be a time