Skip to content

Commit

Permalink
Backport commit dd0727e1e from Emacs
Browse files Browse the repository at this point in the history
* lisp/ol.el (org-store-link):
* lisp/org-clock.el (org-clock-sum)
(org-clock-update-time-maybe):
* lisp/org-colview.el (org-colview-construct-allowed-dates):
* lisp/org-macro.el (org-macro--vc-modified-time):
* lisp/org-macs.el (org-2ft, org-matcher-time):
* lisp/org-table.el (org-table-eval-formula):
* lisp/org.el (org-read-date, org-display-custom-time)
(org-time-string-to-time, org-timestamp-change):
Prefer (encode-time L) to (apply #'encode-time L) where either will do.
* lisp/org-clock.el (org-clocktable-steps):
Prefer (encode-time S M ...) to (apply #'encode-time (list S M ...)).

encode-time simplifications
dd0727e1ec1f535b9b06be88173b4d3ccd55abcb
Paul Eggert
Thu Dec 16 11:17:25 2021 -0800

[ km: Note that these changes will be reverted by the port of Emacs's
  8ef37913d. ]
  • Loading branch information
eggert authored and kyleam committed Oct 4, 2022
1 parent 1a2d2fd commit 772c447
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lisp/ol.el
Original file line number Diff line number Diff line change
Expand Up @@ -1575,7 +1575,7 @@ non-nil."
(setq link
(format-time-string
(car org-time-stamp-formats)
(apply 'encode-time
(encode-time
(list 0 0 0 (nth 1 cd) (nth 0 cd) (nth 2 cd)
nil nil nil))))
(org-link-store-props :type "calendar" :date cd)))
Expand Down
12 changes: 6 additions & 6 deletions lisp/org-clock.el
Original file line number Diff line number Diff line change
Expand Up @@ -1904,11 +1904,11 @@ PROPNAME lets you set a custom text property instead of :org-clock-minutes."
((match-end 2)
;; Two time stamps.
(let* ((ts (float-time
(apply #'encode-time
(encode-time
(save-match-data
(org-parse-time-string (match-string 2))))))
(te (float-time
(apply #'encode-time
(encode-time
(org-parse-time-string (match-string 3)))))
(dt (- (if tend (min te tend) te)
(if tstart (max ts tstart) ts))))
Expand Down Expand Up @@ -2837,7 +2837,7 @@ a number of clock tables."
(pcase (if range (car range) (plist-get params :tstart))
((and (pred numberp) n)
(pcase-let ((`(,m ,d ,y) (calendar-gregorian-from-absolute n)))
(apply #'encode-time (list 0 0 org-extend-today-until d m y))))
(encode-time 0 0 org-extend-today-until d m y)))
(timestamp
(seconds-to-time
(org-matcher-time (or timestamp
Expand All @@ -2847,7 +2847,7 @@ a number of clock tables."
(pcase (if range (nth 1 range) (plist-get params :tend))
((and (pred numberp) n)
(pcase-let ((`(,m ,d ,y) (calendar-gregorian-from-absolute n)))
(apply #'encode-time (list 0 0 org-extend-today-until d m y))))
(encode-time 0 0 org-extend-today-until d m y)))
(timestamp (seconds-to-time (org-matcher-time timestamp))))))
(while (time-less-p start end)
(unless (bolp) (insert "\n"))
Expand Down Expand Up @@ -3042,9 +3042,9 @@ Otherwise, return nil."
(setq ts (match-string 1)
te (match-string 3))
(setq s (- (float-time
(apply #'encode-time (org-parse-time-string te)))
(encode-time (org-parse-time-string te)))
(float-time
(apply #'encode-time (org-parse-time-string ts))))
(encode-time (org-parse-time-string ts))))
neg (< s 0)
s (abs s)
h (floor (/ s 3600))
Expand Down
2 changes: 1 addition & 1 deletion lisp/org-colview.el
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ around it."
(setq time-after (copy-sequence time))
(setf (nth 3 time-before) (1- (nth 3 time)))
(setf (nth 3 time-after) (1+ (nth 3 time)))
(mapcar (lambda (x) (format-time-string fmt (apply #'encode-time x)))
(mapcar (lambda (x) (format-time-string fmt (encode-time x)))
(list time-before time time-after)))))

(defun org-columns-open-link (&optional arg)
Expand Down
2 changes: 1 addition & 1 deletion lisp/org-macro.el
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ Return value as a string."
(buffer-substring
(point) (line-end-position)))))
(when (cl-some #'identity time)
(setq date (apply #'encode-time time))))))))
(setq date (encode-time time))))))))
(let ((proc (get-buffer-process buf)))
(while (and proc (accept-process-output proc .5 nil t)))))
(kill-buffer buf))
Expand Down
4 changes: 2 additions & 2 deletions lisp/org-macs.el
Original file line number Diff line number Diff line change
Expand Up @@ -1185,7 +1185,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 (encode-time (org-parse-time-string s)))
(error 0)))
(t 0)))

Expand Down Expand Up @@ -1252,7 +1252,7 @@ following special strings: \"<now>\", \"<today>\",
\"<tomorrow>\", and \"<yesterday>\".
Return 0. if S is not recognized as a valid value."
(let ((today (float-time (apply #'encode-time
(let ((today (float-time (encode-time
(append '(0 0 0) (nthcdr 3 (decode-time)))))))
(save-match-data
(cond
Expand Down
2 changes: 1 addition & 1 deletion lisp/org-table.el
Original file line number Diff line number Diff line change
Expand Up @@ -2606,7 +2606,7 @@ location of point."
(format-time-string
(org-time-stamp-format
(string-match-p "[0-9]\\{1,2\\}:[0-9]\\{2\\}" ts))
(apply #'encode-time
(encode-time
(save-match-data (org-parse-time-string ts))))))
form t t))

Expand Down
8 changes: 4 additions & 4 deletions lisp/org.el
Original file line number Diff line number Diff line change
Expand Up @@ -13987,7 +13987,7 @@ user."
(when (< (nth 2 org-defdecode) org-extend-today-until)
(setf (nth 2 org-defdecode) -1)
(setf (nth 1 org-defdecode) 59)
(setq org-def (apply #'encode-time org-defdecode))
(setq org-def (encode-time org-defdecode))
(setq org-defdecode (decode-time org-def)))
(let* ((timestr (format-time-string
(if org-with-time "%Y-%m-%d %H:%M" "%Y-%m-%d")
Expand Down Expand Up @@ -14471,7 +14471,7 @@ The command returns the inserted time stamp."
time (org-fix-decoded-time t1)
str (org-add-props
(format-time-string
(substring tf 1 -1) (apply 'encode-time time))
(substring tf 1 -1) (encode-time time))
nil 'mouse-face 'highlight))
(put-text-property beg end 'display str)))

Expand Down Expand Up @@ -14726,7 +14726,7 @@ days in order to avoid rounding problems."

(defun org-time-string-to-time (s)
"Convert timestamp string S into internal time."
(apply #'encode-time (org-parse-time-string s)))
(encode-time (org-parse-time-string s)))

(defun org-time-string-to-seconds (s)
"Convert a timestamp string S into a number of seconds."
Expand Down Expand Up @@ -15166,7 +15166,7 @@ When SUPPRESS-TMP-DELAY is non-nil, suppress delays like
(setcar time0 (or (car time0) 0))
(setcar (nthcdr 1 time0) (or (nth 1 time0) 0))
(setcar (nthcdr 2 time0) (or (nth 2 time0) 0))
(setq time (apply 'encode-time time0))))
(setq time (encode-time time0))))
;; Insert the new time-stamp, and ensure point stays in the same
;; category as before (i.e. not after the last position in that
;; category).
Expand Down

0 comments on commit 772c447

Please sign in to comment.