From c0f2d5d0bfffb35233b35b606438ed1797c09b23 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sun, 3 Mar 2019 22:17:05 -0500 Subject: [PATCH 1/4] org-archive: Make substring call compatible with Emacs 24 * lisp/org-archive.el (org-archive--compute-location): Pass 0 rather than nil for FROM for Emacs 24 compatibility. --- lisp/org-archive.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/org-archive.el b/lisp/org-archive.el index 206a76a08..827c9c84b 100644 --- a/lisp/org-archive.el +++ b/lisp/org-archive.el @@ -164,7 +164,7 @@ an error if LOCATION is not a valid archive location." (unless (string-match "::" location) (error "Invalid archive location: %S" location)) (let ((current-file (buffer-file-name (buffer-base-buffer))) - (file-fmt (substring location nil (match-beginning 0))) + (file-fmt (substring location 0 (match-beginning 0))) (heading-fmt (substring location (match-end 0)))) (cons ;; File part. From 6b5695aabd365b34495c6388e0125c3fd7e34e27 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 16 Feb 2019 11:20:09 -0800 Subject: [PATCH 2/4] Backport commit b5e66f46a from Emacs * lisp/org-id.el: Update RFC citations. Update citations of Internet RFCs b5e66f46a6f33f9d633e6cc3e0770a566bdfcf6b Paul Eggert Sat Feb 16 12:00:02 2019 -0800 --- lisp/org-id.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lisp/org-id.el b/lisp/org-id.el index f4c737f0e..e3265db86 100644 --- a/lisp/org-id.el +++ b/lisp/org-id.el @@ -161,9 +161,9 @@ to have no space characters in them." (defcustom org-id-include-domain nil "Non-nil means add the domain name to new IDs. This ensures global uniqueness of IDs, and is also suggested by -RFC 2445 in combination with RFC 822. This is only relevant if -`org-id-method' is `org'. When uuidgen is used, the domain will never -be added. +the relevant RFCs. This is relevant only if `org-id-method' is +`org'. When uuidgen is used, the domain will never be added. + The default is to not use this because we have no really good way to get the true domain, and Org entries will normally not be shared with enough people to make this necessary." From 1b15d5ef8e5237582fde1b7230d148f31aa8fde2 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 22 Feb 2019 13:24:16 -0800 Subject: [PATCH 3/4] Backport commit eba66c1ea from Emacs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * lisp/ox-publish.el (org-publish-sitemap): Simplify and remove assumptions about timestamp format. Don’t assume that current-time and plain encode-time return timestamps in (HI LO US PS) format. Remove some timestamp format assumptions eba66c1eafeef6512259c9b46face2b03c7433b8 Paul Eggert Fri Feb 22 13:31:01 2019 -0800 --- lisp/ox-publish.el | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lisp/ox-publish.el b/lisp/ox-publish.el index 8eb6d6c4f..38488a1a4 100644 --- a/lisp/ox-publish.el +++ b/lisp/ox-publish.el @@ -793,13 +793,11 @@ Default for SITEMAP-FILENAME is `sitemap.org'." (not (string-lessp B A)))))) ((or `anti-chronologically `chronologically) (let* ((adate (org-publish-find-date a project)) - (bdate (org-publish-find-date b project)) - (A (+ (ash (car adate) 16) (cadr adate))) - (B (+ (ash (car bdate) 16) (cadr bdate)))) + (bdate (org-publish-find-date b project))) (setq retval - (if (eq sort-files 'chronologically) - (<= A B) - (>= A B))))) + (not (if (eq sort-files 'chronologically) + (time-less-p bdate adate) + (time-less-p adate bdate)))))) (`nil nil) (_ (user-error "Invalid sort value %s" sort-files))) ;; Directory-wise wins: From a6cead0d21fc59aa93d97230e197633326406138 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 22 Feb 2019 18:32:31 -0800 Subject: [PATCH 4/4] Backport commit 476066e89 from Emacs * lisp/org-clock.el (org-clock-out): * lisp/org.el (org-evaluate-time-range): Avoid double-rounding of time-related values. Simplify. * lisp/org-clock.el (org-resolve-clocks-if-idle): Use time-since instead of open-coding most of it. * lisp/org-agenda.el (org-agenda-show-clocking-issues): * lisp/org-capture.el (org-capture-set-target-location): * lisp/org-table.el (org-table-sum): * lisp/org.el (org-babel-load-file, org-2ft, org-time-stamp) (org-read-date-analyze, org-time-stamp-to-now): Simplify. Note(km): Many of the changes from 476066e89 have been dropped for compatibility with older Emacsen. Avoid some double-rounding of Lisp timestamps 476066e89d6f0bb87220da690b8a476bf9655b80 Paul Eggert Fri Feb 22 18:33:57 2019 -0800 --- lisp/org-agenda.el | 4 ++-- lisp/org-capture.el | 3 +-- lisp/org-clock.el | 10 ++++----- lisp/org-duration.el | 9 +++------ lisp/org-macs.el | 4 ++-- lisp/org-table.el | 4 ++-- lisp/org.el | 48 +++++++++++++++++++++----------------------- 7 files changed, 37 insertions(+), 45 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 40de26c0d..572a42ce7 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -5879,12 +5879,12 @@ See also the user option `org-agenda-clock-consistency-checks'." ((> dt (* 60 maxtime)) ;; a very long clocking chunk (setq issue (format "Clocking interval is very long: %s" - (org-duration-from-minutes (floor (/ dt 60.)))) + (org-duration-from-minutes (floor dt 60))) face (or (plist-get pl :long-face) face))) ((< dt (* 60 mintime)) ;; a very short clocking chunk (setq issue (format "Clocking interval is very short: %s" - (org-duration-from-minutes (floor (/ dt 60.)))) + (org-duration-from-minutes (floor dt 60))) face (or (plist-get pl :short-face) face))) ((and (> tlend 0) (< ts tlend)) ;; Two clock entries are overlapping diff --git a/lisp/org-capture.el b/lisp/org-capture.el index debf1808c..cb5b1581b 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -1003,8 +1003,7 @@ Store them in the capture property list." (equal current-prefix-arg 1)) ;; Prompt for date. (let ((prompt-time (org-read-date - nil t nil "Date for tree entry:" - (current-time)))) + nil t nil "Date for tree entry:"))) (org-capture-put :default-time (cond ((and (or (not (boundp 'org-time-was-given)) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 8de232f18..4a1956f5d 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -1169,8 +1169,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-subtract (current-time) - (seconds-to-time org-clock-user-idle-seconds))) + (time-since (seconds-to-time 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 @@ -1179,9 +1178,8 @@ so long." (lambda (_) (format "Clocked in & idle for %.1f mins" (/ (float-time - (time-subtract (current-time) - org-clock-user-idle-start)) - 60.0))) + (time-since org-clock-user-idle-start)) + 60))) org-clock-user-idle-start))))) (defvar org-clock-current-task nil "Task currently clocked in.") @@ -1600,7 +1598,7 @@ to, overriding the existing value of `org-clock-out-switch-to-state'." ;; Possibly remove zero time clocks. However, do not add ;; a note associated to the CLOCK line in this case. (cond ((and org-clock-out-remove-zero-time-clocks - (= (+ h m) 0)) + (= 0 h m)) (setq remove t) (delete-region (line-beginning-position) (line-beginning-position 2))) diff --git a/lisp/org-duration.el b/lisp/org-duration.el index e93ef3f12..e350bc74b 100644 --- a/lisp/org-duration.el +++ b/lisp/org-duration.el @@ -316,11 +316,10 @@ When optional argument CANONICAL is non-nil, ignore Raise an error if expected format is unknown." (pcase (or fmt org-duration-format) (`h:mm - (let ((minutes (floor minutes))) - (format "%d:%02d" (/ minutes 60) (mod minutes 60)))) + (format "%d:%02d" (/ minutes 60) (mod minutes 60))) (`h:mm:ss (let* ((whole-minutes (floor minutes)) - (seconds (floor (* 60 (- minutes whole-minutes))))) + (seconds (mod (* 60 minutes) 60))) (format "%s:%02d" (org-duration-from-minutes whole-minutes 'h:mm) seconds))) @@ -401,9 +400,7 @@ Raise an error if expected format is unknown." (pcase-let* ((`(,unit . ,required?) units) (modifier (org-duration--modifier unit canonical))) (cond ((<= modifier minutes) - (let ((value (if (integerp modifier) - (/ (floor minutes) modifier) - (floor (/ minutes modifier))))) + (let ((value (floor minutes modifier))) (cl-decf minutes (* value modifier)) (format " %d%s" value unit))) (required? (concat " 0" unit)) diff --git a/lisp/org-macs.el b/lisp/org-macs.el index 4658d5764..eaf65a7d6 100644 --- a/lisp/org-macs.el +++ b/lisp/org-macs.el @@ -1082,8 +1082,8 @@ nil, just return 0." ((stringp s) (condition-case nil (float-time (apply #'encode-time (org-parse-time-string s))) - (error 0.))) - (t 0.))) + (error 0))) + (t 0))) (defun org-time= (a b) (let ((a (org-2ft a)) diff --git a/lisp/org-table.el b/lisp/org-table.el index 07903873f..d13a2c38b 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -2198,8 +2198,8 @@ If NLAST is a number, only the NLAST fields will actually be summed." (sres (if (= org-timecnt 0) (number-to-string res) (setq diff (* 3600 res) - h (floor (/ diff 3600)) diff (mod diff 3600) - m (floor (/ diff 60)) diff (mod diff 60) + h (floor diff 3600) diff (mod diff 3600) + m (floor diff 60) diff (mod diff 60) s diff) (format "%.0f:%02.0f:%02.0f" h m s)))) (kill-new sres) diff --git a/lisp/org.el b/lisp/org.el index 87b9120a4..f4fe64b33 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -253,10 +253,10 @@ file to byte-code before it is loaded." (interactive "fFile to load: \nP") (let* ((age (lambda (file) (float-time - (time-subtract (current-time) - (file-attribute-modification-time - (or (file-attributes (file-truename file)) - (file-attributes file))))))) + (time-since + (file-attribute-modification-time + (or (file-attributes (file-truename file)) + (file-attributes file))))))) (base-name (file-name-sans-extension file)) (exported-file (concat base-name ".el"))) ;; tangle if the Org file is newer than the elisp file @@ -16049,8 +16049,8 @@ 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 (if (not ts) (current-time) - (apply #'encode-time (org-parse-time-string ts)))) + (default-time (and ts + (apply #'encode-time (org-parse-time-string ts)))) (default-input (and ts (org-get-compact-tod ts))) (repeater (and ts (string-match "\\([.+-]+[0-9]+[hdwmy] ?\\)+" ts) @@ -16058,13 +16058,13 @@ non-nil." org-time-was-given org-end-time-was-given (time - (and (if (equal arg '(16)) (current-time) - ;; Preserve `this-command' and `last-command'. - (let ((this-command this-command) - (last-command last-command)) - (org-read-date - arg 'totime nil nil default-time default-input - inactive)))))) + (if (equal arg '(16)) (current-time) + ;; Preserve `this-command' and `last-command'. + (let ((this-command this-command) + (last-command last-command)) + (org-read-date + arg 'totime nil nil default-time default-input + inactive))))) (cond ((and ts (memq last-command '(org-time-stamp org-time-stamp-inactive)) @@ -16434,7 +16434,7 @@ user." (when (string-match "\\`[ \t]*\\.[ \t]*\\'" ans) (setq ans "+0")) - (when (setq delta (org-read-date-get-relative ans (current-time) org-def)) + (when (setq delta (org-read-date-get-relative ans nil org-def)) (setq ans (replace-match "" t t ans) deltan (car delta) deltaw (nth 1 delta) @@ -16782,7 +16782,7 @@ Don't touch the rest." If SECONDS is non-nil, return the difference in seconds." (let ((fdiff (if seconds #'float-time #'time-to-days))) (- (funcall fdiff (org-time-string-to-time timestamp-string)) - (funcall fdiff (current-time))))) + (funcall fdiff nil)))) (defun org-deadline-close-p (timestamp-string &optional ndays) "Is the time in TIMESTAMP-STRING close to the current date?" @@ -16964,10 +16964,8 @@ days in order to avoid rounding problems." (match-end (match-end 0)) (time1 (org-time-string-to-time ts1)) (time2 (org-time-string-to-time ts2)) - (t1 (float-time time1)) - (t2 (float-time time2)) - (diff (abs (- t2 t1))) - (negative (< (- t2 t1) 0)) + (diff (abs (float-time (time-subtract time2 time1)))) + (negative (time-less-p time2 time1)) ;; (ys (floor (* 365 24 60 60))) (ds (* 24 60 60)) (hs (* 60 60)) @@ -16978,14 +16976,14 @@ days in order to avoid rounding problems." (fh "%02d:%02d") y d h m align) (if havetime - (setq ; y (floor (/ diff ys)) diff (mod diff ys) + (setq ; y (floor diff ys) diff (mod diff ys) y 0 - d (floor (/ diff ds)) diff (mod diff ds) - h (floor (/ diff hs)) diff (mod diff hs) - m (floor (/ diff 60))) - (setq ; y (floor (/ diff ys)) diff (mod diff ys) + d (floor diff ds) diff (mod diff ds) + h (floor diff hs) diff (mod diff hs) + m (floor diff 60)) + (setq ; y (floor diff ys) diff (mod diff ys) y 0 - d (floor (+ (/ diff ds) 0.5)) + d (round diff ds) h 0 m 0)) (if (not to-buffer) (message "%s" (org-make-tdiff-string y d h m))