Skip to content

Commit

Permalink
Prefer Emacs 27 (TICKS . HZ) time values
Browse files Browse the repository at this point in the history
* counsel.el (counsel--async-filter-update-time): New function.
(counsel--async-filter): Use it in place of creating a (HI LO MICRO)
timestamp by hand.
(counsel-file-stale-p): Use time-since in place of time-subtract.
  • Loading branch information
basil-conto committed Feb 29, 2024
1 parent 4546ce0 commit 14c696a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions counsel.el
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,20 @@ caused by spawning too many subprocesses too quickly."
"The amount of microseconds to wait until updating `counsel--async-filter'."
:type 'integer)

(defalias 'counsel--async-filter-update-time
(if (fboundp 'time-convert)
;; Preferred (TICKS . HZ) format since Emacs 27.1.
(lambda () (cons counsel-async-filter-update-time 1000000))
(lambda () (list 0 0 counsel-async-filter-update-time)))
"Return `counsel-async-filter-update-time' as a time value.")

(defun counsel--async-filter (process str)
"Receive from PROCESS the output STR.
Update the minibuffer with the amount of lines collected every
`counsel-async-filter-update-time' microseconds since the last update."
(with-current-buffer (process-buffer process)
(insert str))
(when (time-less-p (list 0 0 counsel-async-filter-update-time)
(when (time-less-p (counsel--async-filter-update-time)
(time-since counsel--async-time))
(let (numlines)
(with-current-buffer (process-buffer process)
Expand Down Expand Up @@ -2677,7 +2684,7 @@ library, which see."

(defun counsel-file-stale-p (fname seconds)
"Return non-nil if FNAME was modified more than SECONDS ago."
(> (float-time (time-subtract nil (nth 5 (file-attributes fname))))
(> (float-time (time-since (nth 5 (file-attributes fname))))
seconds))

(defun counsel--locate-updatedb ()
Expand Down

0 comments on commit 14c696a

Please sign in to comment.