0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-09-29 20:37:51 +00:00

org-clock: Improve `untilnow' range behavior and performance

* org-clock.el (org-clock-special-range): Set `untilnow' to use the
year -50000, rather than the earliest representable date.
(org-clock--oldest-date): Remove.

The `untilnow' range relied on the constant `org-clock--oldest-date`
to find the earliest representable date, which caused delays when
loading `org-clock' on systems where `most-negative-fixnum' is large.
This change removes that constant in favor of a simpler hack to
produce a range between the current time and before the dawn of human
civilization.  If this breaks your workflow, please report to the Time
Police.

TINYCHANGE
This commit is contained in:
Jack Henahan 2018-01-21 10:40:22 -05:00 committed by Nicolas Goaziou
parent b891e46ccb
commit ffa5f3c519

View file

@ -468,38 +468,6 @@ to add an effort property.")
(defvar org-clock-stored-resume-clock nil
"Clock to resume, saved by `org-clock-load'")
(defconst org-clock--oldest-date
(let* ((dichotomy
(lambda (min max pred)
(if (funcall pred min) min
(cl-incf min)
(while (> (- max min) 1)
(let ((mean (+ (ash min -1) (ash max -1) (logand min max 1))))
(if (funcall pred mean) (setq max mean) (setq min mean)))))
max))
(high
(funcall dichotomy
most-negative-fixnum
0
(lambda (m)
;; libc in macOS 10.6 hangs when decoding times
;; around year -2**31. Limit `high' not to go
;; any earlier than that.
(unless (and (eq system-type 'darwin)
(string-match-p
"10\\.6\\.[[:digit:]]"
(shell-command-to-string
"sw_vers -productVersion"))
(<= m -1034058203135))
(ignore-errors (decode-time (list m 0)))))))
(low
(funcall dichotomy
most-negative-fixnum
0
(lambda (m) (ignore-errors (decode-time (list high m)))))))
(list high low))
"Internal time for oldest date representable on the system.")
;;; The clock for measuring work time.
(defvar org-mode-line-string "")
@ -2261,7 +2229,9 @@ have priority."
;; Format start and end times according to AS-STRINGS.
(let* ((start (pcase key
(`interactive (org-read-date nil t nil "Range start? "))
(`untilnow org-clock--oldest-date)
;; In theory, all clocks started after the dawn of
;; humanity.
(`untilnow (encode-time 0 0 0 0 0 -50000))
(_ (encode-time 0 m h d month y))))
(end (pcase key
(`interactive (org-read-date nil t nil "Range end? "))