From 765577d9b3c4c6867b49458134dd050c4c2d82a2 Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Thu, 1 Aug 2019 15:59:46 +0300 Subject: [PATCH 01/13] Backport commit 2267110b6 from Emacs * lisp/ob-exp.el (org-babel-exp-process-buffer): * lisp/org-agenda.el (org-agenda-show-new-time): Always pass an explicit plist to remove-text-properties. Fix usage of remove-text-properties 2267110b6f00bbb0ad87f4621e6ecd9dc1bd8581 Basil L. Contovounesios Thu Aug 1 17:04:53 2019 +0300 --- lisp/ob-exp.el | 3 ++- lisp/org-agenda.el | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp/ob-exp.el b/lisp/ob-exp.el index 1a4c49458..177104b0a 100644 --- a/lisp/ob-exp.el +++ b/lisp/ob-exp.el @@ -281,7 +281,8 @@ this template." (set-marker begin nil) (set-marker end nil))))) (kill-buffer org-babel-exp-reference-buffer) - (remove-text-properties (point-min) (point-max) '(org-reference))))))) + (remove-text-properties (point-min) (point-max) + '(org-reference nil))))))) (defun org-babel-exp-do-export (info type &optional hash) "Return a string with the exported content of a code block. diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index d54a6ba01..9b69c3e7a 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -9268,7 +9268,7 @@ Called with a universal prefix arg, show the priority instead of setting it." (goto-char (point-max)) (while (not (bobp)) (when (equal marker (org-get-at-bol 'org-marker)) - (remove-text-properties (point-at-bol) (point-at-eol) '(display)) + (remove-text-properties (point-at-bol) (point-at-eol) '(display nil)) (org-move-to-column (- (window-width) (length stamp)) t) (add-text-properties (1- (point)) (point-at-eol) From 71ce18920a843bc9e4e9dbcba3056eeab98cf6da Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 4 Aug 2019 09:57:27 -0700 Subject: [PATCH 02/13] Backport commit 5f3f3884a from Emacs Improve time function doc 5f3f3884a0d2a88101d330b82ef5b584cfc02aa6 Paul Eggert Sun Aug 4 10:09:25 2019 -0700 --- lisp/org-id.el | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lisp/org-id.el b/lisp/org-id.el index 0d835704d..cbd059402 100644 --- a/lisp/org-id.el +++ b/lisp/org-id.el @@ -413,9 +413,12 @@ The input I may be a character, or a single-letter string." r)) (defun org-id-time-to-b36 (&optional time) - "Encode TIME as a 10-digit string. + "Encode TIME as a 12-digit string. This string holds the time to micro-second accuracy, and can be decoded using `org-id-decode'." + ;; FIXME: If TIME represents N seconds after the epoch, then + ;; this encoding assumes 0 <= N < 110075314176 = (* (expt 36 4) 65536), + ;; i.e., that TIME is from 1970-01-01 00:00:00 to 5458-02-23 20:09:36 UTC. (setq time (or time (org-current-time-as-list))) (concat (org-id-int-to-b36 (nth 0 time) 4) (org-id-int-to-b36 (nth 1 time) 4) @@ -424,7 +427,7 @@ using `org-id-decode'." (defun org-id-decode (id) "Split ID into the prefix and the time value that was used to create it. The return value is (prefix . time) where PREFIX is nil or a string, -and time is the usual three-integer representation of time." +and TIME is a Lisp time value (HI LO USEC)." (let (prefix time parts) (setq parts (org-split-string id ":")) (if (= 2 (length parts)) From 08c7bbbf713839cbf3ff0cc8741faf22d0e0021e Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 4 Aug 2019 11:39:03 -0700 Subject: [PATCH 03/13] Backport commit a5b796a87 from Emacs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * lisp/ob-haskell.el (org-babel-haskell-export-to-lhs): Omit unnecessary ‘?’ after nullable pattern. * lisp/org-capture.el (org-capture-fill-template): Match upper-case as well as lower-case letters. Fix 2019-08-04 regex lint a5b796a8798a809044d847568e6472cc5eca077e Paul Eggert Sun Aug 4 11:39:54 2019 -0700 --- lisp/ob-haskell.el | 2 +- lisp/org-capture.el | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/ob-haskell.el b/lisp/ob-haskell.el index 0346c2d47..a683b1107 100644 --- a/lisp/ob-haskell.el +++ b/lisp/ob-haskell.el @@ -158,7 +158,7 @@ constructs (header arguments, no-web syntax etc...) are ignored." (interactive "P") (let* ((contents (buffer-string)) (haskell-regexp - (concat "^\\([ \t]*\\)#\\+begin_src[ \t]haskell*\\(.*\\)?[\r\n]" + (concat "^\\([ \t]*\\)#\\+begin_src[ \t]haskell*\\(.*\\)[\r\n]" "\\([^\000]*?\\)[\r\n][ \t]*#\\+end_src.*")) (base-name (file-name-sans-extension (buffer-file-name))) (tmp-file (org-babel-temp-file "haskell-")) diff --git a/lisp/org-capture.el b/lisp/org-capture.el index 748cae7b1..f04e9c4a6 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -1646,7 +1646,7 @@ The template may still contain \"%?\" for cursor positioning." ;; Mark %() embedded elisp for later evaluation. (org-capture-expand-embedded-elisp 'mark) ;; Expand non-interactive templates. - (let ((regexp "%\\(:[-a-za-z]+\\|<\\([^>\n]+\\)>\\|[aAcfFikKlntTuUx]\\)")) + (let ((regexp "%\\(:[-A-Za-z]+\\|<\\([^>\n]+\\)>\\|[aAcfFikKlntTuUx]\\)")) (save-excursion (while (re-search-forward regexp nil t) ;; `org-capture-escaped-%' may modify buffer and cripple From 218e6949649229665d6e6e59c7b7389c347a64b0 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 5 Aug 2019 17:37:47 -0700 Subject: [PATCH 04/13] Backport commit c6ba8100e from Emacs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * lisp/org-id.el (org-id-time-to-b36): Remove unnecessary ‘or’. Fix minor Org timestamp inefficiencies c6ba8100ea1db4616d3fe8485430b29143bc3d2e Paul Eggert Mon Aug 5 17:38:15 2019 -0700 --- lisp/org-id.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/org-id.el b/lisp/org-id.el index cbd059402..c8de8dd41 100644 --- a/lisp/org-id.el +++ b/lisp/org-id.el @@ -422,7 +422,7 @@ using `org-id-decode'." (setq time (or time (org-current-time-as-list))) (concat (org-id-int-to-b36 (nth 0 time) 4) (org-id-int-to-b36 (nth 1 time) 4) - (org-id-int-to-b36 (or (nth 2 time) 0) 4))) + (org-id-int-to-b36 (nth 2 time) 4))) (defun org-id-decode (id) "Split ID into the prefix and the time value that was used to create it. From 531f4be2566906988fbfed83e603e445c47b8ef9 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Tue, 13 Aug 2019 22:19:04 -0400 Subject: [PATCH 05/13] org-compat: Define org-xor as alias for xor if available * lisp/org-macs.el (org-xor): Move to ... * lisp/org-compat.el (org-xor): ... here, making it an alias for xor on Emacs 27. This is an alternative to porting Emacs's c676444a43e4634c1f98ec286b5bd9e46b23216b, which targets the code prior to 45a1918ef (Move `org-xor' into "org-macs.el", 2017-10-17). --- lisp/org-compat.el | 7 +++++++ lisp/org-macs.el | 9 --------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/lisp/org-compat.el b/lisp/org-compat.el index ff2f0d3e9..5c30a7392 100644 --- a/lisp/org-compat.el +++ b/lisp/org-compat.el @@ -70,6 +70,13 @@ ;;; Emacs < 27.1 compatibility +(if (fboundp 'xor) + ;; `xor' was added in Emacs 27.1. + (defalias 'org-xor #'xor) + (defsubst org-xor (a b) + "Exclusive `or'." + (if a (not b) b))) + (unless (fboundp 'pcomplete-uniquify-list) ;; The misspelled variant was made obsolete in Emacs 27.1 (defalias 'pcomplete-uniquify-list 'pcomplete-uniqify-list)) diff --git a/lisp/org-macs.el b/lisp/org-macs.el index eaf65a7d6..41b6b36fa 100644 --- a/lisp/org-macs.el +++ b/lisp/org-macs.el @@ -596,15 +596,6 @@ Optional argument REGEXP selects variables to clone." (or (null regexp) (string-match-p regexp (symbol-name name)))) (ignore-errors (set (make-local-variable name) value))))))) - - -;;; Logic - -(defsubst org-xor (a b) - "Exclusive `or'." - (if a (not b) b)) - - ;;; Miscellaneous From 4e3a1b3f5a5e1d5534d94c0b5d2e6e2a5fc724da Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Tue, 13 Aug 2019 23:12:18 -0400 Subject: [PATCH 06/13] org-compat: Move proper-list-p kludge to proper section --- lisp/org-compat.el | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lisp/org-compat.el b/lisp/org-compat.el index 5c30a7392..cae8a05f0 100644 --- a/lisp/org-compat.el +++ b/lisp/org-compat.el @@ -70,6 +70,15 @@ ;;; Emacs < 27.1 compatibility +(unless (fboundp 'proper-list-p) + ;; `proper-list-p' was added in Emacs 27.1. The function below is + ;; taken from Emacs subr.el 200195e824b^. + (defun proper-list-p (object) + "Return OBJECT's length if it is a proper list, nil otherwise. +A proper list is neither circular nor dotted (i.e., its last cdr +is nil)." + (and (listp object) (ignore-errors (length object))))) + (if (fboundp 'xor) ;; `xor' was added in Emacs 27.1. (defalias 'org-xor #'xor) @@ -629,15 +638,6 @@ attention to case differences." (eq t (compare-strings suffix nil nil string start-pos nil ignore-case)))))) -(unless (fboundp 'proper-list-p) - ;; `proper-list-p' was added in Emacs 27.1. The function below is - ;; taken from Emacs subr.el 200195e824b^. - (defun proper-list-p (object) - "Return OBJECT's length if it is a proper list, nil otherwise. -A proper list is neither circular nor dotted (i.e., its last cdr -is nil)." - (and (listp object) (ignore-errors (length object))))) - ;;; Integration with and fixes for other packages From 24ba689506afd11148865e992e507ddc801b2913 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sun, 18 Aug 2019 11:22:36 -0400 Subject: [PATCH 07/13] org-compat: Add time-convert compatibility wrappers * lisp/org-compat.el (org-time-convert-to-integer) (org-time-convert-to-list): New defsubt's to replace common invocations of time-convert (new in Emacs 27). * lisp/org-compat.el (org-current-time-as-list): Drop in favor of org-time-convert-to-list. These will be used to port changes from the Emacs repo. --- lisp/org-compat.el | 16 ++++++++++------ lisp/org-id.el | 4 ++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lisp/org-compat.el b/lisp/org-compat.el index cae8a05f0..2fb623da3 100644 --- a/lisp/org-compat.el +++ b/lisp/org-compat.el @@ -90,12 +90,16 @@ is nil)." ;; The misspelled variant was made obsolete in Emacs 27.1 (defalias 'pcomplete-uniquify-list 'pcomplete-uniqify-list)) -(defun org-current-time-as-list () - "Compatibility wrapper for `current-time'. -As of Emacs 27.1, `current-time' callers should not assume a list -return value." - (or (ignore-errors (encode-time nil 'list)) - (current-time))) +(if (fboundp 'time-convert) + (progn + (defsubst org-time-convert-to-integer (time) + (time-convert time 'integer)) + (defsubst org-time-convert-to-list (time) + (time-convert time 'list))) + (defun org-time-convert-to-integer (time) + (floor (float-time time))) + (defun org-time-convert-to-list (time) + (seconds-to-time (float-time time)))) ;;; Emacs < 26.1 compatibility diff --git a/lisp/org-id.el b/lisp/org-id.el index c8de8dd41..52fce5468 100644 --- a/lisp/org-id.el +++ b/lisp/org-id.el @@ -357,7 +357,7 @@ So a typical ID could look like \"Org:4nd91V40HI\"." "Return string with random (version 4) UUID." (let ((rnd (md5 (format "%s%s%s%s%s%s%s" (random) - (org-current-time-as-list) + (org-time-convert-to-list nil) (user-uid) (emacs-pid) (user-full-name) @@ -419,7 +419,7 @@ using `org-id-decode'." ;; FIXME: If TIME represents N seconds after the epoch, then ;; this encoding assumes 0 <= N < 110075314176 = (* (expt 36 4) 65536), ;; i.e., that TIME is from 1970-01-01 00:00:00 to 5458-02-23 20:09:36 UTC. - (setq time (or time (org-current-time-as-list))) + (setq time (org-time-convert-to-list nil)) (concat (org-id-int-to-b36 (nth 0 time) 4) (org-id-int-to-b36 (nth 1 time) 4) (org-id-int-to-b36 (nth 2 time) 4))) From bdc5861cf726d23cfa6f7f7b0ec2b32219fab99a Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sun, 18 Aug 2019 10:44:41 -0400 Subject: [PATCH 08/13] org-compat: Add kludges for time-related functions * lisp/org-compat.el (org-decode-time, org-format-time-string) (org-time-add, org-time-less-p, org-time-since, org-time-subtract): New compatibility functions. On Emacs 24, these functions are stricter about what they accept for time. These new function will be used to port over changes in the Emacs repo. Don't bother doing a bulk substitution in existing Org code because that would produce a lot of churn and these calls should already be compatible with Emacs 24. --- lisp/org-compat.el | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/lisp/org-compat.el b/lisp/org-compat.el index 2fb623da3..7603f9688 100644 --- a/lisp/org-compat.el +++ b/lisp/org-compat.el @@ -157,6 +157,35 @@ This is a floating point number if the size is too large for an integer." Case is significant." (string< s1 s2))) +;; The time- functions below translate nil to `current-time` and +;; accept an integer as of Emacs 25. `decode-time` and +;; `format-time-string` accept nil on Emacs 24 but don't accept an +;; integer until Emacs 25. +(if (< emacs-major-version 25) + (let ((convert + (lambda (time) + (cond ((not time) (current-time)) + ((numberp time) (seconds-to-time time)) + (t time))))) + (defun org-decode-time (&optional time) + (decode-time (funcall convert time))) + (defun org-format-time-string (format-string &optional time universal) + (format-time-string format-string (funcall convert time) universal)) + (defun org-time-add (a b) + (time-add (funcall convert a) (funcall convert b))) + (defun org-time-subtract (a b) + (time-subtract (funcall convert a) (funcall convert b))) + (defun org-time-since (time) + (time-since (funcall convert time))) + (defun org-time-less-p (t1 t2) + (time-less-p (funcall convert t1) (funcall convert t2)))) + (defalias 'org-decode-time 'decode-time) + (defalias 'org-format-time-string 'format-time-string) + (defalias 'org-time-add 'time-add) + (defalias 'org-time-subtract 'time-subtract) + (defalias 'org-time-since 'time-since) + (defalias 'org-time-less-p 'time-less-p)) + ;;; Obsolete aliases (remove them after the next major release). From a3fcf6dff4cc9efd21ec087e14424f1a3f7b14d5 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 17 Aug 2019 15:39:18 -0700 Subject: [PATCH 09/13] Backport commit 3d1c9a77c from Emacs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * lisp/org-timer.el (org-timer-show-remaining-time): Don’t assume the remaining time is less than one hour. Simplify. The simplification removes the need for a decode-time, and fixes a typo I introduced recently. Fix org-timer-show-remaining-time > 1 hour 3d1c9a77c52664c8c3e4fa1ae25e1d13aab9b2f9 Paul Eggert Sat Aug 17 17:22:25 2019 -0700 Note(km): This replaces porting of Emacs's c90a420779 (Add FIXMEs for subsecond support, 2019-08-17). It's modified to use org-time-subtract and org-time-convert-to-integer for backward compatibility. --- lisp/org-timer.el | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lisp/org-timer.el b/lisp/org-timer.el index aff2853f6..c740e9402 100644 --- a/lisp/org-timer.el +++ b/lisp/org-timer.el @@ -386,16 +386,15 @@ VALUE can be `on', `off', or `paused'." (defun org-timer-show-remaining-time () "Display the remaining time before the timer ends." (interactive) - (require 'time) - (if (not org-timer-countdown-timer) - (message "No timer set") - (let* ((rtime (decode-time - (time-subtract (timer--time org-timer-countdown-timer) - (current-time)))) - (rsecs (nth 0 rtime)) - (rmins (nth 1 rtime))) - (message "%d minute(s) %d seconds left before next time out" - rmins rsecs)))) + (message + (if (not org-timer-countdown-timer) + "No timer set" + (format-seconds + "%m minute(s) %s seconds left before next time out" + ;; Note: Once our minimal require is Emacs 27, we can drop this + ;; org-time-convert-to-integer call. + (org-time-convert-to-integer + (org-time-subtract (timer--time org-timer-countdown-timer) nil)))))) ;;;###autoload (defun org-timer-set-timer (&optional opt) From 74bf99502d1c4c68fd3b903bfa5cc9dffb7c4c47 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 10 Feb 2019 20:25:22 -0800 Subject: [PATCH 10/13] Backport commit 988e37fa0 from Emacs * lisp/org-agenda.el (org-agenda-get-timestamps, org-agenda-get-progress) (org-agenda-show-clocking-issues): * lisp/org-capture.el (org-capture-set-target-location): * lisp/org-clock.el (org-clock-get-sum-start): * lisp/org.el (org-current-time, org-store-link) (org-read-date, org-read-date-display) (org-display-custom-time, org-timestamp-to-time) Simplify use of encode-time. * lisp/org-clock.el (org-clock-in, org-clock-update-time-maybe): * lisp/org-colview.el (org-columns--age-to-minutes): * lisp/org-macs.el (org-2ft): * lisp/org.el (org-get-scheduled-time, org-get-deadline-time) (org-add-planning-info, org-time-string-to-absolute) (org-closest-date): Use org-time-string-to-time instead of doing it by hand with encode-time. * lisp/org.el (org-read-date): Avoid extra trip through encode-time. Simplify use of encode-time 988e37fa0f922b852715671d59a0e3f682373411 Paul Eggert Sun Feb 10 23:54:35 2019 -0800 Note(km): org-current-time has been modified to use org-time-subtract and org-time-less-p for backward compatibility. Some changes from 988e37fa0 have been dropped to keep encode-time's call compatible with older Emacsen. --- lisp/org-agenda.el | 14 +++++------- lisp/org-capture.el | 6 ++--- lisp/org-clock.el | 10 ++++----- lisp/org-colview.el | 2 +- lisp/org-macs.el | 2 +- lisp/org.el | 55 +++++++++++++++++++++------------------------ 6 files changed, 41 insertions(+), 48 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 9b69c3e7a..8342f9e05 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -5500,8 +5500,8 @@ displayed in agenda view." (substring (format-time-string (car org-time-stamp-formats) - (apply #'encode-time ; DATE bound by calendar - (list 0 0 0 (nth 1 date) (car date) (nth 2 date)))) + (encode-time ; DATE bound by calendar + 0 0 0 (nth 1 date) (car date) (nth 2 date))) 1 11)) "\\|\\(<[0-9]+-[0-9]+-[0-9]+[^>\n]+?\\+[0-9]+[hdwmy]>\\)" "\\|\\(<%%\\(([^>\n]+)\\)>\\)")) @@ -5751,8 +5751,8 @@ then those holidays will be skipped." (substring (format-time-string (car org-time-stamp-formats) - (apply 'encode-time ; DATE bound by calendar - (list 0 0 0 (nth 1 date) (car date) (nth 2 date)))) + (encode-time ; DATE bound by calendar + 0 0 0 (nth 1 date) (car date) (nth 2 date))) 1 11)))) (org-agenda-search-headline-for-time nil) marker hdmarker priority category level tags closedp type @@ -5872,10 +5872,8 @@ See also the user option `org-agenda-clock-consistency-checks'." (throw 'next t)) (setq ts (match-string 1) te (match-string 3) - ts (float-time - (apply #'encode-time (org-parse-time-string ts))) - te (float-time - (apply #'encode-time (org-parse-time-string te))) + ts (float-time (org-time-string-to-time ts)) + te (float-time (org-time-string-to-time te)) dt (- te ts)))) (cond ((> dt (* 60 maxtime)) diff --git a/lisp/org-capture.el b/lisp/org-capture.el index f04e9c4a6..d24045fdc 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -1011,9 +1011,9 @@ Store them in the capture property list." (not (= (time-to-days prompt-time) (org-today)))) ;; Use 00:00 when no time is given for another ;; date than today? - (apply #'encode-time - (append `(0 0 ,org-extend-today-until) - (cl-cdddr (decode-time prompt-time))))) + (apply #'encode-time 0 0 + org-extend-today-until + (cl-cdddr (decode-time prompt-time)))) ((string-match "\\([^ ]+\\)--?[^ ]+[ ]+\\(.*\\)" org-read-date-final-answer) ;; Replace any time range by its start. diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 98acdaea9..52f25621d 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -1301,8 +1301,7 @@ the default behavior." (setq ts (concat "[" (match-string 1) "]")) (goto-char (match-end 1)) (setq org-clock-start-time - (apply 'encode-time - (org-parse-time-string (match-string 1)))) + (org-time-string-to-time (match-string 1))) (setq org-clock-effort (org-entry-get (point) org-effort-property)) (setq org-clock-total-time (org-clock-sum-current-item (org-clock-get-sum-start)))) @@ -1439,7 +1438,7 @@ The time is always returned as UTC." (day (nth 3 dt))) (if (< hour org-extend-today-until) (setf (nth 3 dt) (1- day))) (setf (nth 2 dt) org-extend-today-until) - (apply #'encode-time (append (list 0 0) (nthcdr 2 dt))))) + (apply #'encode-time 0 0 (nthcdr 2 dt)))) ((or (equal cmt "all") (and (or (not cmt) (equal cmt "auto")) (not lr))) @@ -1829,7 +1828,7 @@ PROPNAME lets you set a custom text property instead of :org-clock-minutes." (org-parse-time-string (match-string 3))))) (dt (- (if tend (min te tend) te) (if tstart (max ts tstart) ts)))) - (when (> dt 0) (cl-incf t1 (floor (/ dt 60)))))) + (when (> dt 0) (cl-incf t1 (floor dt 60))))) ((match-end 4) ;; A naked time. (setq t1 (+ t1 (string-to-number (match-string 5)) @@ -2910,8 +2909,7 @@ Otherwise, return nil." (<= org-clock-marker (point-at-eol))) ;; The clock is running here (setq org-clock-start-time - (apply 'encode-time - (org-parse-time-string (match-string 1)))) + (org-time-string-to-time (match-string 1))) (org-clock-update-mode-line))) (t (and (match-end 4) (delete-region (match-beginning 4) (match-end 4))) diff --git a/lisp/org-colview.el b/lisp/org-colview.el index 7f2a886ad..27120dd5e 100644 --- a/lisp/org-colview.el +++ b/lisp/org-colview.el @@ -1117,7 +1117,7 @@ as a canonical duration, i.e., using units defined in (cond ((string-match-p org-ts-regexp s) (/ (- org-columns--time - (float-time (apply #'encode-time (org-parse-time-string s)))) + (float-time (org-time-string-to-time s))) 60)) ((org-duration-p s) (org-duration-to-minutes s t)) ;skip user units (t (user-error "Invalid age: %S" s)))) diff --git a/lisp/org-macs.el b/lisp/org-macs.el index 41b6b36fa..43d34b77d 100644 --- a/lisp/org-macs.el +++ b/lisp/org-macs.el @@ -1072,7 +1072,7 @@ nil, just return 0." ((numberp s) s) ((stringp s) (condition-case nil - (float-time (apply #'encode-time (org-parse-time-string s))) + (float-time (org-time-string-to-time s)) (error 0))) (t 0))) diff --git a/lisp/org.el b/lisp/org.el index be9b8d8bf..5217048ab 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -5636,16 +5636,15 @@ When ROUNDING-MINUTES is not an integer, fall back on the car of the rounding returns a past time." (let ((r (or (and (integerp rounding-minutes) rounding-minutes) (car org-time-stamp-rounding-minutes))) - (time (decode-time)) res) + (now (current-time))) (if (< r 1) - (current-time) - (setq res - (apply 'encode-time - (append (list 0 (* r (floor (+ .5 (/ (float (nth 1 time)) r))))) - (nthcdr 2 time)))) - (if (and past (< (float-time (time-subtract (current-time) res)) 0)) - (seconds-to-time (- (float-time res) (* r 60))) - res)))) + now + (let* ((time (decode-time now)) + (res (apply #'encode-time 0 (* r (round (nth 1 time) r)) + (nthcdr 2 time)))) + (if (or (not past) (org-time-less-p res now)) + res + (org-time-subtract res (* r 60))))))) (defun org-today () "Return today date, considering `org-extend-today-until'." @@ -9340,9 +9339,7 @@ non-nil." (setq link (format-time-string (car org-time-stamp-formats) - (apply 'encode-time - (list 0 0 0 (nth 1 cd) (nth 0 cd) (nth 2 cd) - nil nil nil)))) + (encode-time 0 0 0 (nth 1 cd) (nth 0 cd) (nth 2 cd)))) (org-store-link-props :type "calendar" :date cd))) ((eq major-mode 'help-mode) @@ -13044,7 +13041,7 @@ for calling org-schedule with, or if there is no scheduling, returns nil." (let ((time (org-entry-get pom "SCHEDULED" inherit))) (when time - (apply 'encode-time (org-parse-time-string time))))) + (org-time-string-to-time time)))) (defun org-get-deadline-time (pom &optional inherit) "Get the deadline as a time tuple, of a format suitable for @@ -13052,7 +13049,7 @@ calling org-deadline with, or if there is no scheduling, returns nil." (let ((time (org-entry-get pom "DEADLINE" inherit))) (when time - (apply 'encode-time (org-parse-time-string time))))) + (org-time-string-to-time time)))) (defun org-remove-timestamp-with-keyword (keyword) "Remove all time stamps with KEYWORD in the current entry." @@ -13111,7 +13108,7 @@ WHAT entry will also be removed." org-deadline-time-regexp) end t) (setq ts (match-string 1) - default-time (apply 'encode-time (org-parse-time-string ts)) + default-time (org-time-string-to-time ts) default-input (and ts (org-get-compact-tod ts))))))) (when what (setq time @@ -16369,13 +16366,14 @@ user." "range representable on this machine")) (ding)) - ;; One round trip to get rid of 34th of August and stuff like that.... - (setq final (decode-time (apply 'encode-time final))) + (setq final (apply #'encode-time final)) (setq org-read-date-final-answer ans) (if to-time - (apply 'encode-time final) + final + ;; This round-trip gets rid of 34th of August and stuff like that.... + (setq final (decode-time final)) (if (and (boundp 'org-time-was-given) org-time-was-given) (format "%04d-%02d-%02d %02d:%02d" (nth 5 final) (nth 4 final) (nth 3 final) @@ -16405,7 +16403,7 @@ user." (and (boundp 'org-time-was-given) org-time-was-given)) (cdr fmts) (car fmts))) - (txt (format-time-string fmt (apply 'encode-time f))) + (txt (format-time-string fmt (apply #'encode-time f))) (txt (if org-read-date-inactive (concat "[" (substring txt 1 -1) "]") txt)) (txt (concat "=> " txt))) (when (and org-end-time-was-given @@ -17056,7 +17054,7 @@ signaled." (daynr (org-closest-date s daynr prefer)) (t (time-to-days (condition-case errdata - (apply #'encode-time (org-parse-time-string s)) + (org-time-string-to-time s) (error (error "Bad timestamp `%s'%s\nError was: %s" s (if (not (and buffer pos)) "" @@ -17154,12 +17152,12 @@ stamp stay unchanged. In any case, return value is an absolute day number." (if (not (string-match "\\+\\([0-9]+\\)\\([hdwmy]\\)" start)) ;; No repeater. Do not shift time stamp. - (time-to-days (apply #'encode-time (org-parse-time-string start))) + (time-to-days (org-time-string-to-time start)) (let ((value (string-to-number (match-string 1 start))) (type (match-string 2 start))) (if (= 0 value) ;; Repeater with a 0-value is considered as void. - (time-to-days (apply #'encode-time (org-parse-time-string start))) + (time-to-days (org-time-string-to-time start)) (let* ((base (org-date-to-gregorian start)) (target (org-date-to-gregorian current)) (sday (calendar-absolute-from-gregorian base)) @@ -22600,13 +22598,12 @@ return an active timestamp." "Convert TIMESTAMP object into an Emacs internal time value. Use end of date range or time range when END is non-nil. Otherwise, use its start." - (apply #'encode-time - (cons 0 - (mapcar - (lambda (prop) (or (org-element-property prop timestamp) 0)) - (if end '(:minute-end :hour-end :day-end :month-end :year-end) - '(:minute-start :hour-start :day-start :month-start - :year-start)))))) + (apply #'encode-time 0 + (mapcar + (lambda (prop) (or (org-element-property prop timestamp) 0)) + (if end '(:minute-end :hour-end :day-end :month-end :year-end) + '(:minute-start :hour-start :day-start :month-start + :year-start))))) (defun org-timestamp-has-time-p (timestamp) "Non-nil when TIMESTAMP has a time specified." From a23d0225abd829ae031115803749e700bb470278 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sun, 18 Aug 2019 12:26:05 -0400 Subject: [PATCH 11/13] org-time-stamp: Simplify encode-time call * lisp/org.el (org-time-stamp): Use org-time-string-to-time. This should have been applied with a6cead0d2 (Backport commit 476066e89 from Emacs, 2019-02-22). --- lisp/org.el | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 5217048ab..6f42bc7ce 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -16045,8 +16045,7 @@ non-nil." ((org-at-timestamp-p 'lax) (match-string 0)))) ;; Default time is either the timestamp at point or today. ;; When entering a range, only the range start is considered. - (default-time (and ts - (apply #'encode-time (org-parse-time-string ts)))) + (default-time (and ts (org-time-string-to-time ts))) (default-input (and ts (org-get-compact-tod ts))) (repeater (and ts (string-match "\\([.+-]+[0-9]+[hdwmy] ?\\)+" ts) From d72b4af96e1e7a1090616aa73a596ebcc08c7cc9 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sun, 18 Aug 2019 15:40:01 -0400 Subject: [PATCH 12/13] org-clock: Adjust steps calculation for Emacs 24 compatibility * lisp/org-clock.el (org-clocktable-increment-day): Use org-decode-time so that integer can be given for time on Emacs 24. (org-clocktable-steps): Work with a float rather than internal time to avoid "Invalid time specification" error on Emacs 24. This fixes the failure of test-org-clock/clocktable/step on Emacs 24. Note that the version of org-clocktable-steps on master has been reworked and does not share this issue. --- lisp/org-clock.el | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 52f25621d..aa327abad 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -2698,7 +2698,7 @@ LEVEL is an integer. Indent by two spaces per level above 1." "Increment day in TS by N (defaulting to 1). The TS argument has the same type as the return values of `float-time' or `current-time'." - (let ((tsd (decode-time ts))) + (let ((tsd (org-decode-time ts))) (cl-incf (nth 3 tsd) (or n 1)) (setf (nth 8 tsd) nil) ; no time zone: increasing day skips one whole day (apply 'encode-time tsd))) @@ -2736,23 +2736,22 @@ The TS argument has the same type as the return values of (if (eq step0 'week) (let ((dow (nth 6 (decode-time (seconds-to-time ts))))) (if (<= dow ws) ts - (org-clocktable-increment-day ts ; decrement - (- ws dow)))) + (float-time (org-clocktable-increment-day ts ; decrement + (- ws dow))))) ts)) - (while (< (float-time tsb) te) + (while (< tsb te) (unless (bolp) (insert "\n")) - (let* ((start-time (seconds-to-time (max (float-time tsb) ts))) - (dow (nth 6 (decode-time (seconds-to-time tsb)))) + (let* ((start-time (max tsb ts)) + (dow (nth 6 (org-decode-time tsb))) (days-to-skip (cond ((eq step0 'day) 1) ;; else 'week: ((= dow ws) 7) (t (- ws dow))))) - (setq tsb (time-to-seconds (org-clocktable-increment-day tsb - days-to-skip))) + (setq tsb (float-time (org-clocktable-increment-day tsb days-to-skip))) (insert "\n" (if (eq step0 'day) "Daily report: " "Weekly report starting on: ") - (format-time-string (org-time-stamp-format nil t) start-time) + (org-format-time-string (org-time-stamp-format nil t) start-time) "\n") (let ((table-begin (line-beginning-position 0)) (step-time @@ -2761,10 +2760,10 @@ The TS argument has the same type as the return values of params (list :header "" :step nil :block nil - :tstart (format-time-string (org-time-stamp-format t t) - start-time) - :tend (format-time-string (org-time-stamp-format t t) - (seconds-to-time (min te tsb)))))))) + :tstart (org-format-time-string (org-time-stamp-format t t) + start-time) + :tend (org-format-time-string (org-time-stamp-format t t) + (min te tsb))))))) (re-search-forward "^[ \t]*#\\+END:") (when (and stepskip0 (equal step-time 0)) ;; Remove the empty table From 9e1b9fe62779ecbdfd67a971dd3f549c5099e0f2 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sun, 18 Aug 2019 16:47:07 -0400 Subject: [PATCH 13/13] 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. --- lisp/org-agenda.el | 4 +-- lisp/org-clock.el | 61 +++++++++++++++++++++------------------------ lisp/org-element.el | 15 +++++------ lisp/org-habit.el | 4 +-- lisp/org-indent.el | 4 +-- lisp/org-timer.el | 18 +++---------- lisp/org.el | 5 ++-- 7 files changed, 46 insertions(+), 65 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 8342f9e05..76ff2d98a 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -5924,8 +5924,8 @@ See also the user option `org-agenda-clock-consistency-checks'." (throw 'exit t)) ;; We have a shorter gap. ;; Now we have to get the minute of the day when these times are - (let* ((t1dec (decode-time (seconds-to-time t1))) - (t2dec (decode-time (seconds-to-time t2))) + (let* ((t1dec (org-decode-time t1)) + (t2dec (org-decode-time t2)) ;; compute the minute on the day (min1 (+ (nth 1 t1dec) (* 60 (nth 2 t1dec)))) (min2 (+ (nth 1 t2dec) (* 60 (nth 2 t2dec))))) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index aa327abad..d0548d00d 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -729,8 +729,9 @@ menu\nmouse-2 will jump to task")) The time returned includes the time spent on this task in previous clocking intervals." (let ((currently-clocked-time - (floor (- (float-time) - (float-time org-clock-start-time)) 60))) + (floor (org-time-convert-to-integer + (org-time-since org-clock-start-time)) + 60))) (+ currently-clocked-time (or org-clock-total-time 0)))) (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-is-active-clock clock) nil) (t (org-clock-clock-in clock t)))) - ((pred (time-less-p (current-time))) - ;; ^ NOTE: Here and in other `time-less-p' calls, we use - ;; (current-time) rather than nil for Emacs 24 compatibility. + ((pred (org-time-less-p nil)) (error "RESOLVE-TO must refer to a time in the past")) (_ (when restart (error "RESTART is not valid here")) @@ -1046,11 +1045,8 @@ to be CLOCKED OUT.")))) nil 45))) (and (not (memq char-pressed '(?i ?q))) char-pressed))))) (default - (floor (/ (float-time - ;; NOTE: Here and in other `time-subtract' - ;; calls, we use (current-time) rather than nil - ;; for Emacs 24 compatibility. - (time-subtract (current-time) last-valid)) 60))) + (floor (org-time-convert-to-integer (org-time-since last-valid)) + 60)) (keep (and (memq ch '(?k ?K)) (read-number "Keep how many minutes? " default))) @@ -1058,8 +1054,9 @@ to be CLOCKED OUT.")))) (and (memq ch '(?g ?G)) (read-number "Got back how many minutes ago? " default))) (subtractp (memq ch '(?s ?S))) - (barely-started-p (< (- (float-time last-valid) - (float-time (cdr clock))) 45)) + (barely-started-p (org-time-less-p + (org-time-subtract last-valid (cdr clock)) + 45)) (start-over (and subtractp barely-started-p))) (cond ((memq ch '(?j ?J)) @@ -1085,10 +1082,9 @@ to be CLOCKED OUT.")))) (and gotback (= gotback default))) 'now) (keep - (time-add last-valid (seconds-to-time (* 60 keep)))) + (org-time-add last-valid (* 60 keep))) (gotback - (time-subtract (current-time) - (seconds-to-time (* 60 gotback)))) + (org-time-since (* 60 gotback))) (t (error "Unexpected, please report this as a bug"))) (and gotback last-valid) @@ -1118,9 +1114,9 @@ If `only-dangling-p' is non-nil, only ask to resolve dangling (lambda (clock) (format "Dangling clock started %d mins ago" - (floor (- (float-time) - (float-time (cdr clock))) - 60))))) + (floor (org-time-convert-to-integer + (org-time-since (cdr clock))) + 60))))) (or last-valid (cdr clock))))))))))) @@ -1170,7 +1166,7 @@ so long." org-clock-marker (marker-buffer org-clock-marker)) (let* ((org-clock-user-idle-seconds (org-user-idle-seconds)) (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)) (if (> org-clock-user-idle-seconds (* 60 org-clock-idle-time)) (org-clock-resolve @@ -1331,9 +1327,10 @@ the default behavior." (y-or-n-p (format "You stopped another clock %d mins ago; start this one from then? " - (/ (- (float-time - (org-current-time org-clock-rounding-minutes t)) - (float-time leftover)) + (/ (org-time-convert-to-integer + (org-time-subtract + (org-current-time org-clock-rounding-minutes t) + leftover)) 60))) leftover) start-time @@ -1584,14 +1581,12 @@ to, overriding the existing value of `org-clock-out-switch-to-state'." (delete-region (point) (point-at-eol)) (insert "--") (setq te (org-insert-time-stamp (or at-time now) 'with-hm 'inactive)) - (setq s (- (float-time - (apply #'encode-time (org-parse-time-string te))) - (float-time - (apply #'encode-time (org-parse-time-string ts)))) - h (floor (/ s 3600)) - s (- s (* 3600 h)) - m (floor (/ s 60)) - s (- s (* 60 s))) + (setq s (org-time-convert-to-integer + (time-subtract + (org-time-string-to-time te) + (org-time-string-to-time ts))) + h (floor s 3600) + m (floor (mod s 3600) 60)) (insert " => " (format "%2d:%02d" h m)) (move-marker org-clock-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 (>= (float-time org-clock-start-time) tstart) (<= (float-time org-clock-start-time) tend)) - (let ((time (floor (- (float-time) - (float-time org-clock-start-time)) + (let ((time (floor (org-time-convert-to-integer + (org-time-since org-clock-start-time)) 60))) (setq t1 (+ t1 time)))) (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)))) (setq tsb (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 (float-time (org-clocktable-increment-day ts ; decrement (- ws dow))))) diff --git a/lisp/org-element.el b/lisp/org-element.el index e4e704d0d..77b8f95ab 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -4819,13 +4819,13 @@ you want to help debugging the issue.") (defvar org-element-cache-sync-idle-time 0.6 "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. If the synchronization is not over after this delay, the process pauses and resumes after `org-element-cache-sync-break' 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. 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 (run-with-idle-timer (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)) nil #'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." (and time-limit (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) "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)) threshold (and (not threshold) - ;; NOTE: Here and in other `time-add' calls, we use - ;; (current-time) rather than nil for Emacs 24 - ;; compatibility. - (time-add (current-time) - org-element-cache-sync-duration)) + (org-time-add nil + org-element-cache-sync-duration)) future-change) ;; Request processed. Merge current and next offsets and ;; transfer ending position. diff --git a/lisp/org-habit.el b/lisp/org-habit.el index af4520729..d19ab1b8c 100644 --- a/lisp/org-habit.el +++ b/lisp/org-habit.el @@ -406,8 +406,8 @@ current time." "Insert consistency graph for any habitual tasks." (let ((inhibit-read-only t) (buffer-invisibility-spec '(org-link)) - (moment (time-subtract (current-time) - (list 0 (* 3600 org-extend-today-until) 0)))) + (moment (org-time-subtract nil + (* 3600 org-extend-today-until)))) (save-excursion (goto-char (if line (point-at-bol) (point-min))) (while (not (eobp)) diff --git a/lisp/org-indent.el b/lisp/org-indent.el index 2ac431c57..15814e076 100644 --- a/lisp/org-indent.el +++ b/lisp/org-indent.el @@ -333,7 +333,7 @@ stopped." (let* ((case-fold-search t) (limited-re (org-get-limited-outline-regexp)) (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' ;; properties depending on the type of line (headline, inline ;; task, item or other). @@ -346,7 +346,7 @@ stopped." ;; In asynchronous mode, take a break of ;; `org-indent-agent-resume-delay' every DELAY to avoid ;; 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 (run-with-idle-timer (time-add (current-idle-time) org-indent-agent-resume-delay) diff --git a/lisp/org-timer.el b/lisp/org-timer.el index c740e9402..d8319363a 100644 --- a/lisp/org-timer.el +++ b/lisp/org-timer.el @@ -139,9 +139,7 @@ the region 0:00:00." (format "Restart timer with offset [%s]: " def))) (unless (string-match "\\S-" s) (setq s def)) (setq delta (org-timer-hms-to-secs (org-timer-fix-incomplete s))))) - (setq org-timer-start-time - (seconds-to-time - (- (float-time) delta)))) + (setq org-timer-start-time (org-time-since delta))) (setq org-timer-pause-time nil) (org-timer-set-mode-line 'on) (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 (let ((start-secs (float-time org-timer-start-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 (let ((new-secs (- start-secs pause-secs))) (setq org-timer-countdown-timer (org-timer--run-countdown-timer new-secs org-timer-countdown-timer-title)) - (setq org-timer-start-time - (time-add (current-time) (seconds-to-time new-secs)))) + (setq org-timer-start-time (org-time-add nil new-secs))) (setq org-timer-start-time - (seconds-to-time (- (float-time) - (- pause-secs start-secs))))) + (org-time-since (- pause-secs start-secs)))) (setq org-timer-pause-time nil) (org-timer-set-mode-line 'on) (run-hooks 'org-timer-continue-hook) @@ -453,10 +446,7 @@ using three `C-u' prefix arguments." (org-timer--run-countdown-timer secs org-timer-countdown-timer-title)) (run-hooks 'org-timer-set-hook) - ;; Pass `current-time' result to `time-add' (instead of nil) - ;; for for Emacs 24 compatibility. - (setq org-timer-start-time - (time-add (current-time) (seconds-to-time secs))) + (setq org-timer-start-time (org-time-add nil secs)) (setq org-timer-pause-time nil) (org-timer-set-mode-line 'on)))))) diff --git a/lisp/org.el b/lisp/org.el index 6f42bc7ce..af8f03e4c 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -5649,8 +5649,7 @@ the rounding returns a past time." (defun org-today () "Return today date, considering `org-extend-today-until'." (time-to-days - (time-subtract (current-time) - (list 0 (* 3600 org-extend-today-until) 0)))) + (org-time-since (* 3600 org-extend-today-until)))) ;;;; 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) (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)) (or (y-or-n-p (format "%d repeater intervals were not \