Port more time-related changes
* lisp/org-agenda.el (org-agenda-check-clock-gap): * lisp/org-clock.el (org-clock-get-clocked-time) (org-clock-resolve-clock, (org-clock-resolve) (org-resolve-clocks, org-resolve-clocks-if-idle) (org-clock-in, org-clock-out, org-clock-sum, org-clocktable-steps): * lisp/org-element.el (org-element-cache-sync-duration) (org-element--cache-set-timer, org-element--cache-interrupt-p): (org-element--cache-sync): * lisp/org-habit.el (org-habit-insert-consistency-graphs): * lisp/org-indent.el (org-indent-add-properties): * lisp/org-timer.el (org-timer-start): (org-timer-pause-or-continue, org-timer-set-timer): * lisp/org.el (org-today, org-auto-repeat-maybe): Port time-related changes from the Emacs repo by using compatibility wrappers. In the Emacs repo, there has been a lot of changes to Org files involving time-related code. I've ported some of those changes but have largely ignored any changes that break compatibility with older Emacsen that we support. That, however, isn't a good approach because it will be hard to do a systematic update once we bump our minimum Emacs requirement. Instead use the recently added compatibility wrappers where needed, which is ugly but more maintainable. The main time-related changes this leaves unported are changes that replace (apply #'encode-time args) calls with (encode-time args). Until the first form is unsupported, adding a compatibility function doesn't seem worth the churn. Relevant Emacs commits include c75f505dea6a560b825384cf3d277690f86840bf, 57c74793c46c6533b63836f00aecaf3ac2accb6d, 988e37fa0f922b852715671d59a0e3f682373411, 476066e89d6f0bb87220da690b8a476bf9655b80, 89c63b3522b62c0fd725f0b348927a2069238452.
This commit is contained in:
parent
d72b4af96e
commit
9e1b9fe627
|
@ -5924,8 +5924,8 @@ See also the user option `org-agenda-clock-consistency-checks'."
|
||||||
(throw 'exit t))
|
(throw 'exit t))
|
||||||
;; We have a shorter gap.
|
;; We have a shorter gap.
|
||||||
;; Now we have to get the minute of the day when these times are
|
;; Now we have to get the minute of the day when these times are
|
||||||
(let* ((t1dec (decode-time (seconds-to-time t1)))
|
(let* ((t1dec (org-decode-time t1))
|
||||||
(t2dec (decode-time (seconds-to-time t2)))
|
(t2dec (org-decode-time t2))
|
||||||
;; compute the minute on the day
|
;; compute the minute on the day
|
||||||
(min1 (+ (nth 1 t1dec) (* 60 (nth 2 t1dec))))
|
(min1 (+ (nth 1 t1dec) (* 60 (nth 2 t1dec))))
|
||||||
(min2 (+ (nth 1 t2dec) (* 60 (nth 2 t2dec)))))
|
(min2 (+ (nth 1 t2dec) (* 60 (nth 2 t2dec)))))
|
||||||
|
|
|
@ -729,8 +729,9 @@ menu\nmouse-2 will jump to task"))
|
||||||
The time returned includes the time spent on this task in
|
The time returned includes the time spent on this task in
|
||||||
previous clocking intervals."
|
previous clocking intervals."
|
||||||
(let ((currently-clocked-time
|
(let ((currently-clocked-time
|
||||||
(floor (- (float-time)
|
(floor (org-time-convert-to-integer
|
||||||
(float-time org-clock-start-time)) 60)))
|
(org-time-since org-clock-start-time))
|
||||||
|
60)))
|
||||||
(+ currently-clocked-time (or org-clock-total-time 0))))
|
(+ currently-clocked-time (or org-clock-total-time 0))))
|
||||||
|
|
||||||
(defun org-clock-modify-effort-estimate (&optional value)
|
(defun org-clock-modify-effort-estimate (&optional value)
|
||||||
|
@ -945,9 +946,7 @@ CLOCK is a cons cell of the form (MARKER START-TIME)."
|
||||||
(org-clock-clock-out clock fail-quietly))
|
(org-clock-clock-out clock fail-quietly))
|
||||||
((org-is-active-clock clock) nil)
|
((org-is-active-clock clock) nil)
|
||||||
(t (org-clock-clock-in clock t))))
|
(t (org-clock-clock-in clock t))))
|
||||||
((pred (time-less-p (current-time)))
|
((pred (org-time-less-p nil))
|
||||||
;; ^ NOTE: Here and in other `time-less-p' calls, we use
|
|
||||||
;; (current-time) rather than nil for Emacs 24 compatibility.
|
|
||||||
(error "RESOLVE-TO must refer to a time in the past"))
|
(error "RESOLVE-TO must refer to a time in the past"))
|
||||||
(_
|
(_
|
||||||
(when restart (error "RESTART is not valid here"))
|
(when restart (error "RESTART is not valid here"))
|
||||||
|
@ -1046,11 +1045,8 @@ to be CLOCKED OUT."))))
|
||||||
nil 45)))
|
nil 45)))
|
||||||
(and (not (memq char-pressed '(?i ?q))) char-pressed)))))
|
(and (not (memq char-pressed '(?i ?q))) char-pressed)))))
|
||||||
(default
|
(default
|
||||||
(floor (/ (float-time
|
(floor (org-time-convert-to-integer (org-time-since last-valid))
|
||||||
;; NOTE: Here and in other `time-subtract'
|
60))
|
||||||
;; calls, we use (current-time) rather than nil
|
|
||||||
;; for Emacs 24 compatibility.
|
|
||||||
(time-subtract (current-time) last-valid)) 60)))
|
|
||||||
(keep
|
(keep
|
||||||
(and (memq ch '(?k ?K))
|
(and (memq ch '(?k ?K))
|
||||||
(read-number "Keep how many minutes? " default)))
|
(read-number "Keep how many minutes? " default)))
|
||||||
|
@ -1058,8 +1054,9 @@ to be CLOCKED OUT."))))
|
||||||
(and (memq ch '(?g ?G))
|
(and (memq ch '(?g ?G))
|
||||||
(read-number "Got back how many minutes ago? " default)))
|
(read-number "Got back how many minutes ago? " default)))
|
||||||
(subtractp (memq ch '(?s ?S)))
|
(subtractp (memq ch '(?s ?S)))
|
||||||
(barely-started-p (< (- (float-time last-valid)
|
(barely-started-p (org-time-less-p
|
||||||
(float-time (cdr clock))) 45))
|
(org-time-subtract last-valid (cdr clock))
|
||||||
|
45))
|
||||||
(start-over (and subtractp barely-started-p)))
|
(start-over (and subtractp barely-started-p)))
|
||||||
(cond
|
(cond
|
||||||
((memq ch '(?j ?J))
|
((memq ch '(?j ?J))
|
||||||
|
@ -1085,10 +1082,9 @@ to be CLOCKED OUT."))))
|
||||||
(and gotback (= gotback default)))
|
(and gotback (= gotback default)))
|
||||||
'now)
|
'now)
|
||||||
(keep
|
(keep
|
||||||
(time-add last-valid (seconds-to-time (* 60 keep))))
|
(org-time-add last-valid (* 60 keep)))
|
||||||
(gotback
|
(gotback
|
||||||
(time-subtract (current-time)
|
(org-time-since (* 60 gotback)))
|
||||||
(seconds-to-time (* 60 gotback))))
|
|
||||||
(t
|
(t
|
||||||
(error "Unexpected, please report this as a bug")))
|
(error "Unexpected, please report this as a bug")))
|
||||||
(and gotback last-valid)
|
(and gotback last-valid)
|
||||||
|
@ -1118,9 +1114,9 @@ If `only-dangling-p' is non-nil, only ask to resolve dangling
|
||||||
(lambda (clock)
|
(lambda (clock)
|
||||||
(format
|
(format
|
||||||
"Dangling clock started %d mins ago"
|
"Dangling clock started %d mins ago"
|
||||||
(floor (- (float-time)
|
(floor (org-time-convert-to-integer
|
||||||
(float-time (cdr clock)))
|
(org-time-since (cdr clock)))
|
||||||
60)))))
|
60)))))
|
||||||
(or last-valid
|
(or last-valid
|
||||||
(cdr clock)))))))))))
|
(cdr clock)))))))))))
|
||||||
|
|
||||||
|
@ -1170,7 +1166,7 @@ so long."
|
||||||
org-clock-marker (marker-buffer org-clock-marker))
|
org-clock-marker (marker-buffer org-clock-marker))
|
||||||
(let* ((org-clock-user-idle-seconds (org-user-idle-seconds))
|
(let* ((org-clock-user-idle-seconds (org-user-idle-seconds))
|
||||||
(org-clock-user-idle-start
|
(org-clock-user-idle-start
|
||||||
(time-since (seconds-to-time org-clock-user-idle-seconds)))
|
(org-time-since org-clock-user-idle-seconds))
|
||||||
(org-clock-resolving-clocks-due-to-idleness t))
|
(org-clock-resolving-clocks-due-to-idleness t))
|
||||||
(if (> org-clock-user-idle-seconds (* 60 org-clock-idle-time))
|
(if (> org-clock-user-idle-seconds (* 60 org-clock-idle-time))
|
||||||
(org-clock-resolve
|
(org-clock-resolve
|
||||||
|
@ -1331,9 +1327,10 @@ the default behavior."
|
||||||
(y-or-n-p
|
(y-or-n-p
|
||||||
(format
|
(format
|
||||||
"You stopped another clock %d mins ago; start this one from then? "
|
"You stopped another clock %d mins ago; start this one from then? "
|
||||||
(/ (- (float-time
|
(/ (org-time-convert-to-integer
|
||||||
(org-current-time org-clock-rounding-minutes t))
|
(org-time-subtract
|
||||||
(float-time leftover))
|
(org-current-time org-clock-rounding-minutes t)
|
||||||
|
leftover))
|
||||||
60)))
|
60)))
|
||||||
leftover)
|
leftover)
|
||||||
start-time
|
start-time
|
||||||
|
@ -1584,14 +1581,12 @@ to, overriding the existing value of `org-clock-out-switch-to-state'."
|
||||||
(delete-region (point) (point-at-eol))
|
(delete-region (point) (point-at-eol))
|
||||||
(insert "--")
|
(insert "--")
|
||||||
(setq te (org-insert-time-stamp (or at-time now) 'with-hm 'inactive))
|
(setq te (org-insert-time-stamp (or at-time now) 'with-hm 'inactive))
|
||||||
(setq s (- (float-time
|
(setq s (org-time-convert-to-integer
|
||||||
(apply #'encode-time (org-parse-time-string te)))
|
(time-subtract
|
||||||
(float-time
|
(org-time-string-to-time te)
|
||||||
(apply #'encode-time (org-parse-time-string ts))))
|
(org-time-string-to-time ts)))
|
||||||
h (floor (/ s 3600))
|
h (floor s 3600)
|
||||||
s (- s (* 3600 h))
|
m (floor (mod s 3600) 60))
|
||||||
m (floor (/ s 60))
|
|
||||||
s (- s (* 60 s)))
|
|
||||||
(insert " => " (format "%2d:%02d" h m))
|
(insert " => " (format "%2d:%02d" h m))
|
||||||
(move-marker org-clock-marker nil)
|
(move-marker org-clock-marker nil)
|
||||||
(move-marker org-clock-hd-marker nil)
|
(move-marker org-clock-hd-marker nil)
|
||||||
|
@ -1842,8 +1837,8 @@ PROPNAME lets you set a custom text property instead of :org-clock-minutes."
|
||||||
tend
|
tend
|
||||||
(>= (float-time org-clock-start-time) tstart)
|
(>= (float-time org-clock-start-time) tstart)
|
||||||
(<= (float-time org-clock-start-time) tend))
|
(<= (float-time org-clock-start-time) tend))
|
||||||
(let ((time (floor (- (float-time)
|
(let ((time (floor (org-time-convert-to-integer
|
||||||
(float-time org-clock-start-time))
|
(org-time-since org-clock-start-time))
|
||||||
60)))
|
60)))
|
||||||
(setq t1 (+ t1 time))))
|
(setq t1 (+ t1 time))))
|
||||||
(let* ((headline-forced
|
(let* ((headline-forced
|
||||||
|
@ -2734,7 +2729,7 @@ The TS argument has the same type as the return values of
|
||||||
(te (setq te (org-matcher-time te))))
|
(te (setq te (org-matcher-time te))))
|
||||||
(setq tsb
|
(setq tsb
|
||||||
(if (eq step0 'week)
|
(if (eq step0 'week)
|
||||||
(let ((dow (nth 6 (decode-time (seconds-to-time ts)))))
|
(let ((dow (nth 6 (org-decode-time ts))))
|
||||||
(if (<= dow ws) ts
|
(if (<= dow ws) ts
|
||||||
(float-time (org-clocktable-increment-day ts ; decrement
|
(float-time (org-clocktable-increment-day ts ; decrement
|
||||||
(- ws dow)))))
|
(- ws dow)))))
|
||||||
|
|
|
@ -4819,13 +4819,13 @@ you want to help debugging the issue.")
|
||||||
(defvar org-element-cache-sync-idle-time 0.6
|
(defvar org-element-cache-sync-idle-time 0.6
|
||||||
"Length, in seconds, of idle time before syncing cache.")
|
"Length, in seconds, of idle time before syncing cache.")
|
||||||
|
|
||||||
(defvar org-element-cache-sync-duration (seconds-to-time 0.04)
|
(defvar org-element-cache-sync-duration 0.04
|
||||||
"Maximum duration, as a time value, for a cache synchronization.
|
"Maximum duration, as a time value, for a cache synchronization.
|
||||||
If the synchronization is not over after this delay, the process
|
If the synchronization is not over after this delay, the process
|
||||||
pauses and resumes after `org-element-cache-sync-break'
|
pauses and resumes after `org-element-cache-sync-break'
|
||||||
seconds.")
|
seconds.")
|
||||||
|
|
||||||
(defvar org-element-cache-sync-break (seconds-to-time 0.3)
|
(defvar org-element-cache-sync-break 0.3
|
||||||
"Duration, as a time value, of the pause between synchronizations.
|
"Duration, as a time value, of the pause between synchronizations.
|
||||||
See `org-element-cache-sync-duration' for more information.")
|
See `org-element-cache-sync-duration' for more information.")
|
||||||
|
|
||||||
|
@ -5107,7 +5107,7 @@ Assume ELEMENT belongs to cache and that a cache is active."
|
||||||
(setq org-element--cache-sync-timer
|
(setq org-element--cache-sync-timer
|
||||||
(run-with-idle-timer
|
(run-with-idle-timer
|
||||||
(let ((idle (current-idle-time)))
|
(let ((idle (current-idle-time)))
|
||||||
(if idle (time-add idle org-element-cache-sync-break)
|
(if idle (org-time-add idle org-element-cache-sync-break)
|
||||||
org-element-cache-sync-idle-time))
|
org-element-cache-sync-idle-time))
|
||||||
nil
|
nil
|
||||||
#'org-element--cache-sync
|
#'org-element--cache-sync
|
||||||
|
@ -5118,7 +5118,7 @@ Assume ELEMENT belongs to cache and that a cache is active."
|
||||||
TIME-LIMIT is a time value or nil."
|
TIME-LIMIT is a time value or nil."
|
||||||
(and time-limit
|
(and time-limit
|
||||||
(or (input-pending-p)
|
(or (input-pending-p)
|
||||||
(time-less-p time-limit (current-time)))))
|
(org-time-less-p time-limit nil))))
|
||||||
|
|
||||||
(defsubst org-element--cache-shift-positions (element offset &optional props)
|
(defsubst org-element--cache-shift-positions (element offset &optional props)
|
||||||
"Shift ELEMENT properties relative to buffer positions by OFFSET.
|
"Shift ELEMENT properties relative to buffer positions by OFFSET.
|
||||||
|
@ -5172,11 +5172,8 @@ updated before current modification are actually submitted."
|
||||||
(and next (aref next 0))
|
(and next (aref next 0))
|
||||||
threshold
|
threshold
|
||||||
(and (not threshold)
|
(and (not threshold)
|
||||||
;; NOTE: Here and in other `time-add' calls, we use
|
(org-time-add nil
|
||||||
;; (current-time) rather than nil for Emacs 24
|
org-element-cache-sync-duration))
|
||||||
;; compatibility.
|
|
||||||
(time-add (current-time)
|
|
||||||
org-element-cache-sync-duration))
|
|
||||||
future-change)
|
future-change)
|
||||||
;; Request processed. Merge current and next offsets and
|
;; Request processed. Merge current and next offsets and
|
||||||
;; transfer ending position.
|
;; transfer ending position.
|
||||||
|
|
|
@ -406,8 +406,8 @@ current time."
|
||||||
"Insert consistency graph for any habitual tasks."
|
"Insert consistency graph for any habitual tasks."
|
||||||
(let ((inhibit-read-only t)
|
(let ((inhibit-read-only t)
|
||||||
(buffer-invisibility-spec '(org-link))
|
(buffer-invisibility-spec '(org-link))
|
||||||
(moment (time-subtract (current-time)
|
(moment (org-time-subtract nil
|
||||||
(list 0 (* 3600 org-extend-today-until) 0))))
|
(* 3600 org-extend-today-until))))
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(goto-char (if line (point-at-bol) (point-min)))
|
(goto-char (if line (point-at-bol) (point-min)))
|
||||||
(while (not (eobp))
|
(while (not (eobp))
|
||||||
|
|
|
@ -333,7 +333,7 @@ stopped."
|
||||||
(let* ((case-fold-search t)
|
(let* ((case-fold-search t)
|
||||||
(limited-re (org-get-limited-outline-regexp))
|
(limited-re (org-get-limited-outline-regexp))
|
||||||
(level (or (org-current-level) 0))
|
(level (or (org-current-level) 0))
|
||||||
(time-limit (and delay (time-add (current-time) delay))))
|
(time-limit (and delay (org-time-add nil delay))))
|
||||||
;; For each line, set `line-prefix' and `wrap-prefix'
|
;; For each line, set `line-prefix' and `wrap-prefix'
|
||||||
;; properties depending on the type of line (headline, inline
|
;; properties depending on the type of line (headline, inline
|
||||||
;; task, item or other).
|
;; task, item or other).
|
||||||
|
@ -346,7 +346,7 @@ stopped."
|
||||||
;; In asynchronous mode, take a break of
|
;; In asynchronous mode, take a break of
|
||||||
;; `org-indent-agent-resume-delay' every DELAY to avoid
|
;; `org-indent-agent-resume-delay' every DELAY to avoid
|
||||||
;; blocking any other idle timer or process output.
|
;; blocking any other idle timer or process output.
|
||||||
((and delay (time-less-p time-limit (current-time)))
|
((and delay (org-time-less-p time-limit nil))
|
||||||
(setq org-indent-agent-resume-timer
|
(setq org-indent-agent-resume-timer
|
||||||
(run-with-idle-timer
|
(run-with-idle-timer
|
||||||
(time-add (current-idle-time) org-indent-agent-resume-delay)
|
(time-add (current-idle-time) org-indent-agent-resume-delay)
|
||||||
|
|
|
@ -139,9 +139,7 @@ the region 0:00:00."
|
||||||
(format "Restart timer with offset [%s]: " def)))
|
(format "Restart timer with offset [%s]: " def)))
|
||||||
(unless (string-match "\\S-" s) (setq s def))
|
(unless (string-match "\\S-" s) (setq s def))
|
||||||
(setq delta (org-timer-hms-to-secs (org-timer-fix-incomplete s)))))
|
(setq delta (org-timer-hms-to-secs (org-timer-fix-incomplete s)))))
|
||||||
(setq org-timer-start-time
|
(setq org-timer-start-time (org-time-since delta)))
|
||||||
(seconds-to-time
|
|
||||||
(- (float-time) delta))))
|
|
||||||
(setq org-timer-pause-time nil)
|
(setq org-timer-pause-time nil)
|
||||||
(org-timer-set-mode-line 'on)
|
(org-timer-set-mode-line 'on)
|
||||||
(message "Timer start time set to %s, current value is %s"
|
(message "Timer start time set to %s, current value is %s"
|
||||||
|
@ -160,19 +158,14 @@ With prefix arg STOP, stop it entirely."
|
||||||
(org-timer-pause-time
|
(org-timer-pause-time
|
||||||
(let ((start-secs (float-time org-timer-start-time))
|
(let ((start-secs (float-time org-timer-start-time))
|
||||||
(pause-secs (float-time org-timer-pause-time)))
|
(pause-secs (float-time org-timer-pause-time)))
|
||||||
;; Note: We pass the result of `current-time' to `time-add' and
|
|
||||||
;; `float-time' below so that we can easily override the value
|
|
||||||
;; in tests.
|
|
||||||
(if org-timer-countdown-timer
|
(if org-timer-countdown-timer
|
||||||
(let ((new-secs (- start-secs pause-secs)))
|
(let ((new-secs (- start-secs pause-secs)))
|
||||||
(setq org-timer-countdown-timer
|
(setq org-timer-countdown-timer
|
||||||
(org-timer--run-countdown-timer
|
(org-timer--run-countdown-timer
|
||||||
new-secs org-timer-countdown-timer-title))
|
new-secs org-timer-countdown-timer-title))
|
||||||
(setq org-timer-start-time
|
(setq org-timer-start-time (org-time-add nil new-secs)))
|
||||||
(time-add (current-time) (seconds-to-time new-secs))))
|
|
||||||
(setq org-timer-start-time
|
(setq org-timer-start-time
|
||||||
(seconds-to-time (- (float-time)
|
(org-time-since (- pause-secs start-secs))))
|
||||||
(- pause-secs start-secs)))))
|
|
||||||
(setq org-timer-pause-time nil)
|
(setq org-timer-pause-time nil)
|
||||||
(org-timer-set-mode-line 'on)
|
(org-timer-set-mode-line 'on)
|
||||||
(run-hooks 'org-timer-continue-hook)
|
(run-hooks 'org-timer-continue-hook)
|
||||||
|
@ -453,10 +446,7 @@ using three `C-u' prefix arguments."
|
||||||
(org-timer--run-countdown-timer
|
(org-timer--run-countdown-timer
|
||||||
secs org-timer-countdown-timer-title))
|
secs org-timer-countdown-timer-title))
|
||||||
(run-hooks 'org-timer-set-hook)
|
(run-hooks 'org-timer-set-hook)
|
||||||
;; Pass `current-time' result to `time-add' (instead of nil)
|
(setq org-timer-start-time (org-time-add nil secs))
|
||||||
;; for for Emacs 24 compatibility.
|
|
||||||
(setq org-timer-start-time
|
|
||||||
(time-add (current-time) (seconds-to-time secs)))
|
|
||||||
(setq org-timer-pause-time nil)
|
(setq org-timer-pause-time nil)
|
||||||
(org-timer-set-mode-line 'on))))))
|
(org-timer-set-mode-line 'on))))))
|
||||||
|
|
||||||
|
|
|
@ -5649,8 +5649,7 @@ the rounding returns a past time."
|
||||||
(defun org-today ()
|
(defun org-today ()
|
||||||
"Return today date, considering `org-extend-today-until'."
|
"Return today date, considering `org-extend-today-until'."
|
||||||
(time-to-days
|
(time-to-days
|
||||||
(time-subtract (current-time)
|
(org-time-since (* 3600 org-extend-today-until))))
|
||||||
(list 0 (* 3600 org-extend-today-until) 0))))
|
|
||||||
|
|
||||||
;;;; Font-Lock stuff, including the activators
|
;;;; Font-Lock stuff, including the activators
|
||||||
|
|
||||||
|
@ -12868,7 +12867,7 @@ This function is run automatically after each state change to a DONE state."
|
||||||
(let ((nshiftmax 10)
|
(let ((nshiftmax 10)
|
||||||
(nshift 0))
|
(nshift 0))
|
||||||
(while (or (= nshift 0)
|
(while (or (= nshift 0)
|
||||||
(not (time-less-p (current-time) time)))
|
(not (org-time-less-p nil time)))
|
||||||
(when (= nshiftmax (cl-incf nshift))
|
(when (= nshiftmax (cl-incf nshift))
|
||||||
(or (y-or-n-p
|
(or (y-or-n-p
|
||||||
(format "%d repeater intervals were not \
|
(format "%d repeater intervals were not \
|
||||||
|
|
Loading…
Reference in New Issue