Skip to content

Commit e7cf5e4

Browse files
committed
fix(lisp): Don't assume a list representation in `eask-current-time'
`eask-current-time' rebuilt a seconds count from the first two elements of `current-time'. That representation is not guaranteed: it depends on `current-time-list', which defaults to nil as of Emacs 32, so `current-time' returns a (TICKS . HZ) cons cell rather than a (HIGH LOW USEC PSEC) list. `(cadr now)' then evaluates `(car 1000000000)', and `eask package' aborts with "Wrong type argument: listp, 1000000000", where the number is the HZ value from the cons cell. Use `float-time', which accepts either representation and is available in every Emacs version Eask supports (the declared floor is 26.1, so `time-convert' is not an option). The result is unchanged for the list representation. Fixes #431.
1 parent e777d75 commit e7cf5e4

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

lisp/_prepare.el

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,12 @@ Argument BODY are forms for execution."
311311

312312
;; This is used to creating the directory recipe!
313313
(defun eask-current-time ()
314-
"Return current time."
315-
(let ((now (current-time))) (logior (ash (car now) 16) (cadr now))))
314+
"Return current time, as a count of seconds since the epoch."
315+
;; Don't take `current-time' apart by hand: its representation depends on
316+
;; `current-time-list', which defaults to nil as of Emacs 32 and then yields
317+
;; a (TICKS . HZ) pair rather than a (HIGH LOW USEC PSEC) list. `float-time'
318+
;; accepts either form and exists in every Emacs version Eask supports.
319+
(floor (float-time)))
316320

317321
(defun eask-seq-str-max (sequence)
318322
"Return max length in SEQUENCE of strings."

0 commit comments

Comments
 (0)