Merge branch 'maint'

This commit is contained in:
Kyle Meyer 2019-08-18 17:44:08 -04:00
commit c7c04b0447
14 changed files with 163 additions and 154 deletions

View File

@ -280,7 +280,8 @@ this template."
(set-marker begin nil) (set-marker begin nil)
(set-marker end nil))))) (set-marker end nil)))))
(kill-buffer org-babel-exp-reference-buffer) (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) (defun org-babel-exp-do-export (info type &optional hash)
"Return a string with the exported content of a code block. "Return a string with the exported content of a code block.

View File

@ -158,7 +158,7 @@ constructs (header arguments, no-web syntax etc...) are ignored."
(interactive "P") (interactive "P")
(let* ((contents (buffer-string)) (let* ((contents (buffer-string))
(haskell-regexp (haskell-regexp
(concat "^\\([ \t]*\\)#\\+begin_src[ \t]haskell*\\(.*\\)?[\r\n]" (concat "^\\([ \t]*\\)#\\+begin_src[ \t]haskell*\\(.*\\)[\r\n]"
"\\([^\000]*?\\)[\r\n][ \t]*#\\+end_src.*")) "\\([^\000]*?\\)[\r\n][ \t]*#\\+end_src.*"))
(base-name (file-name-sans-extension (buffer-file-name))) (base-name (file-name-sans-extension (buffer-file-name)))
(tmp-file (org-babel-temp-file "haskell-")) (tmp-file (org-babel-temp-file "haskell-"))

View File

@ -5521,8 +5521,8 @@ displayed in agenda view."
(substring (substring
(format-time-string (format-time-string
(car org-time-stamp-formats) (car org-time-stamp-formats)
(apply #'encode-time ; DATE bound by calendar (encode-time ; DATE bound by calendar
(list 0 0 0 (nth 1 date) (car date) (nth 2 date)))) 0 0 0 (nth 1 date) (car date) (nth 2 date)))
1 11)) 1 11))
"\\|\\(<[0-9]+-[0-9]+-[0-9]+[^>\n]+?\\+[0-9]+[hdwmy]>\\)" "\\|\\(<[0-9]+-[0-9]+-[0-9]+[^>\n]+?\\+[0-9]+[hdwmy]>\\)"
"\\|\\(<%%\\(([^>\n]+)\\)>\\)")) "\\|\\(<%%\\(([^>\n]+)\\)>\\)"))
@ -5772,8 +5772,8 @@ then those holidays will be skipped."
(substring (substring
(format-time-string (format-time-string
(car org-time-stamp-formats) (car org-time-stamp-formats)
(apply 'encode-time ; DATE bound by calendar (encode-time ; DATE bound by calendar
(list 0 0 0 (nth 1 date) (car date) (nth 2 date)))) 0 0 0 (nth 1 date) (car date) (nth 2 date)))
1 11)))) 1 11))))
(org-agenda-search-headline-for-time nil) (org-agenda-search-headline-for-time nil)
marker hdmarker priority category level tags closedp type marker hdmarker priority category level tags closedp type
@ -5893,10 +5893,8 @@ See also the user option `org-agenda-clock-consistency-checks'."
(throw 'next t)) (throw 'next t))
(setq ts (match-string 1) (setq ts (match-string 1)
te (match-string 3) te (match-string 3)
ts (float-time ts (float-time (org-time-string-to-time ts))
(apply #'encode-time (org-parse-time-string ts))) te (float-time (org-time-string-to-time te))
te (float-time
(apply #'encode-time (org-parse-time-string te)))
dt (- te ts)))) dt (- te ts))))
(cond (cond
((> dt (* 60 maxtime)) ((> dt (* 60 maxtime))
@ -5947,8 +5945,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)))))
@ -9306,7 +9304,7 @@ Called with a universal prefix arg, show the priority instead of setting it."
(goto-char (point-max)) (goto-char (point-max))
(while (not (bobp)) (while (not (bobp))
(when (equal marker (org-get-at-bol 'org-marker)) (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) (org-move-to-column (- (window-width) (length stamp)) t)
(add-text-properties (add-text-properties
(1- (point)) (point-at-eol) (1- (point)) (point-at-eol)

View File

@ -1018,9 +1018,9 @@ Store them in the capture property list."
(not (= (time-to-days prompt-time) (org-today)))) (not (= (time-to-days prompt-time) (org-today))))
;; Use 00:00 when no time is given for another ;; Use 00:00 when no time is given for another
;; date than today? ;; date than today?
(apply #'encode-time (apply #'encode-time 0 0
(append `(0 0 ,org-extend-today-until) org-extend-today-until
(cl-cdddr (decode-time prompt-time))))) (cl-cdddr (decode-time prompt-time))))
((string-match "\\([^ ]+\\)--?[^ ]+[ ]+\\(.*\\)" ((string-match "\\([^ ]+\\)--?[^ ]+[ ]+\\(.*\\)"
org-read-date-final-answer) org-read-date-final-answer)
;; Replace any time range by its start. ;; Replace any time range by its start.
@ -1625,7 +1625,7 @@ The template may still contain \"%?\" for cursor positioning."
;; Mark %() embedded elisp for later evaluation. ;; Mark %() embedded elisp for later evaluation.
(org-capture-expand-embedded-elisp 'mark) (org-capture-expand-embedded-elisp 'mark)
;; Expand non-interactive templates. ;; Expand non-interactive templates.
(let ((regexp "%\\(:[-a-za-z]+\\|<\\([^>\n]+\\)>\\|[aAcfFikKlntTuUx]\\)")) (let ((regexp "%\\(:[-A-Za-z]+\\|<\\([^>\n]+\\)>\\|[aAcfFikKlntTuUx]\\)"))
(save-excursion (save-excursion
(while (re-search-forward regexp nil t) (while (re-search-forward regexp nil t)
;; `org-capture-escaped-%' may modify buffer and cripple ;; `org-capture-escaped-%' may modify buffer and cripple

View File

@ -732,8 +732,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)
@ -948,9 +949,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"))
@ -1049,11 +1048,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)))
@ -1061,8 +1057,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))
@ -1088,10 +1085,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)
@ -1121,9 +1117,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)))))))))))
@ -1173,7 +1169,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
@ -1304,8 +1300,7 @@ the default behavior."
(setq ts (concat "[" (match-string 1) "]")) (setq ts (concat "[" (match-string 1) "]"))
(goto-char (match-end 1)) (goto-char (match-end 1))
(setq org-clock-start-time (setq org-clock-start-time
(apply 'encode-time (org-time-string-to-time (match-string 1)))
(org-parse-time-string (match-string 1))))
(setq org-clock-effort (org-entry-get (point) org-effort-property)) (setq org-clock-effort (org-entry-get (point) org-effort-property))
(setq org-clock-total-time (org-clock-sum-current-item (setq org-clock-total-time (org-clock-sum-current-item
(org-clock-get-sum-start)))) (org-clock-get-sum-start))))
@ -1335,9 +1330,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
@ -1443,7 +1439,7 @@ The time is always returned as UTC."
(day (nth 3 dt))) (day (nth 3 dt)))
(if (< hour org-extend-today-until) (setf (nth 3 dt) (1- day))) (if (< hour org-extend-today-until) (setf (nth 3 dt) (1- day)))
(setf (nth 2 dt) org-extend-today-until) (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") ((or (equal cmt "all")
(and (or (not cmt) (equal cmt "auto")) (and (or (not cmt) (equal cmt "auto"))
(not lr))) (not lr)))
@ -1597,14 +1593,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,7 +1836,7 @@ PROPNAME lets you set a custom text property instead of :org-clock-minutes."
(org-parse-time-string (match-string 3))))) (org-parse-time-string (match-string 3)))))
(dt (- (if tend (min te tend) te) (dt (- (if tend (min te tend) te)
(if tstart (max ts tstart) ts)))) (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) ((match-end 4)
;; A naked time. ;; A naked time.
(setq t1 (+ t1 (string-to-number (match-string 5)) (setq t1 (+ t1 (string-to-number (match-string 5))
@ -1856,8 +1850,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
@ -2932,8 +2926,7 @@ Otherwise, return nil."
(<= org-clock-marker (point-at-eol))) (<= org-clock-marker (point-at-eol)))
;; The clock is running here ;; The clock is running here
(setq org-clock-start-time (setq org-clock-start-time
(apply 'encode-time (org-time-string-to-time (match-string 1)))
(org-parse-time-string (match-string 1))))
(org-clock-update-mode-line))) (org-clock-update-mode-line)))
(t (t
(and (match-end 4) (delete-region (match-beginning 4) (match-end 4))) (and (match-end 4) (delete-region (match-beginning 4) (match-end 4)))

View File

@ -1114,7 +1114,7 @@ as a canonical duration, i.e., using units defined in
(cond (cond
((string-match-p org-ts-regexp s) ((string-match-p org-ts-regexp s)
(/ (- org-columns--time (/ (- org-columns--time
(float-time (apply #'encode-time (org-parse-time-string s)))) (float-time (org-time-string-to-time s)))
60)) 60))
((org-duration-p s) (org-duration-to-minutes s t)) ;skip user units ((org-duration-p s) (org-duration-to-minutes s t)) ;skip user units
(t (user-error "Invalid age: %S" s)))) (t (user-error "Invalid age: %S" s))))

View File

@ -70,16 +70,36 @@
;;; Emacs < 27.1 compatibility ;;; 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)
(defsubst org-xor (a b)
"Exclusive `or'."
(if a (not b) b)))
(unless (fboundp 'pcomplete-uniquify-list) (unless (fboundp 'pcomplete-uniquify-list)
;; The misspelled variant was made obsolete in Emacs 27.1 ;; The misspelled variant was made obsolete in Emacs 27.1
(defalias 'pcomplete-uniquify-list 'pcomplete-uniqify-list)) (defalias 'pcomplete-uniquify-list 'pcomplete-uniqify-list))
(defun org-current-time-as-list () (if (fboundp 'time-convert)
"Compatibility wrapper for `current-time'. (progn
As of Emacs 27.1, `current-time' callers should not assume a list (defsubst org-time-convert-to-integer (time)
return value." (time-convert time 'integer))
(or (ignore-errors (encode-time nil 'list)) (defsubst org-time-convert-to-list (time)
(current-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 ;;; Emacs < 26.1 compatibility
@ -141,6 +161,35 @@ This is a floating point number if the size is too large for an integer."
Case is significant." Case is significant."
(string< s1 s2))) (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). ;;; Obsolete aliases (remove them after the next major release).
@ -713,15 +762,6 @@ attention to case differences."
(eq t (compare-strings suffix nil nil (eq t (compare-strings suffix nil nil
string start-pos nil ignore-case)))))) 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 ;;; Integration with and fixes for other packages

View File

@ -4868,13 +4868,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.")
@ -5156,7 +5156,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
@ -5167,7 +5167,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.
@ -5221,11 +5221,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.

View File

@ -420,8 +420,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))

View File

@ -386,7 +386,7 @@ So a typical ID could look like \"Org:4nd91V40HI\"."
"Return string with random (version 4) UUID." "Return string with random (version 4) UUID."
(let ((rnd (md5 (format "%s%s%s%s%s%s%s" (let ((rnd (md5 (format "%s%s%s%s%s%s%s"
(random) (random)
(org-current-time-as-list) (org-time-convert-to-list nil)
(user-uid) (user-uid)
(emacs-pid) (emacs-pid)
(user-full-name) (user-full-name)
@ -442,18 +442,21 @@ The input I may be a character, or a single-letter string."
r)) r))
(defun org-id-time-to-b36 (&optional time) (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 This string holds the time to micro-second accuracy, and can be decoded
using `org-id-decode'." using `org-id-decode'."
(setq time (or time (org-current-time-as-list))) ;; 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 (org-time-convert-to-list nil))
(concat (org-id-int-to-b36 (nth 0 time) 4) (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 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) (defun org-id-decode (id)
"Split ID into the prefix and the time value that was used to create it. "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, 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) (let (prefix time parts)
(setq parts (org-split-string id ":")) (setq parts (org-split-string id ":"))
(if (= 2 (length parts)) (if (= 2 (length parts))

View File

@ -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)

View File

@ -585,15 +585,6 @@ Optional argument REGEXP selects variables to clone."
(or (null regexp) (string-match-p regexp (symbol-name name)))) (or (null regexp) (string-match-p regexp (symbol-name name))))
(ignore-errors (set (make-local-variable name) value))))))) (ignore-errors (set (make-local-variable name) value)))))))
;;; Logic
(defsubst org-xor (a b)
"Exclusive `or'."
(if a (not b) b))
;;; Miscellaneous ;;; Miscellaneous
@ -1107,7 +1098,7 @@ nil, just return 0."
((numberp s) s) ((numberp s) s)
((stringp s) ((stringp s)
(condition-case nil (condition-case nil
(float-time (apply #'encode-time (org-parse-time-string s))) (float-time (org-time-string-to-time s))
(error 0))) (error 0)))
(t 0))) (t 0)))

View File

@ -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)
@ -386,16 +379,15 @@ VALUE can be `on', `off', or `paused'."
(defun org-timer-show-remaining-time () (defun org-timer-show-remaining-time ()
"Display the remaining time before the timer ends." "Display the remaining time before the timer ends."
(interactive) (interactive)
(require 'time) (message
(if (not org-timer-countdown-timer) (if (not org-timer-countdown-timer)
(message "No timer set") "No timer set"
(let* ((rtime (decode-time (format-seconds
(time-subtract (timer--time org-timer-countdown-timer) "%m minute(s) %s seconds left before next time out"
(current-time)))) ;; Note: Once our minimal require is Emacs 27, we can drop this
(rsecs (nth 0 rtime)) ;; org-time-convert-to-integer call.
(rmins (nth 1 rtime))) (org-time-convert-to-integer
(message "%d minute(s) %d seconds left before next time out" (org-time-subtract (timer--time org-timer-countdown-timer) nil))))))
rmins rsecs))))
;;;###autoload ;;;###autoload
(defun org-timer-set-timer (&optional opt) (defun org-timer-set-timer (&optional opt)
@ -456,10 +448,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))))))

View File

@ -4994,22 +4994,20 @@ When ROUNDING-MINUTES is not an integer, fall back on the car of
the rounding returns a past time." the rounding returns a past time."
(let ((r (or (and (integerp rounding-minutes) rounding-minutes) (let ((r (or (and (integerp rounding-minutes) rounding-minutes)
(car org-time-stamp-rounding-minutes))) (car org-time-stamp-rounding-minutes)))
(time (decode-time)) res) (now (current-time)))
(if (< r 1) (if (< r 1)
(current-time) now
(setq res (let* ((time (decode-time now))
(apply 'encode-time (res (apply #'encode-time 0 (* r (round (nth 1 time) r))
(append (list 0 (* r (floor (+ .5 (/ (float (nth 1 time)) r))))) (nthcdr 2 time))))
(nthcdr 2 time)))) (if (or (not past) (org-time-less-p res now))
(if (and past (< (float-time (time-subtract (current-time) res)) 0)) res
(seconds-to-time (- (float-time res) (* r 60))) (org-time-subtract res (* r 60)))))))
res))))
(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
@ -10839,7 +10837,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 \
@ -11012,7 +11010,7 @@ for calling org-schedule with, or if there is no scheduling,
returns nil." returns nil."
(let ((time (org-entry-get pom "SCHEDULED" inherit))) (let ((time (org-entry-get pom "SCHEDULED" inherit)))
(when time (when time
(apply 'encode-time (org-parse-time-string time))))) (org-time-string-to-time time))))
(defun org-get-deadline-time (pom &optional inherit) (defun org-get-deadline-time (pom &optional inherit)
"Get the deadline as a time tuple, of a format suitable for "Get the deadline as a time tuple, of a format suitable for
@ -11020,7 +11018,7 @@ calling org-deadline with, or if there is no scheduling, returns
nil." nil."
(let ((time (org-entry-get pom "DEADLINE" inherit))) (let ((time (org-entry-get pom "DEADLINE" inherit)))
(when time (when time
(apply 'encode-time (org-parse-time-string time))))) (org-time-string-to-time time))))
(defun org-remove-timestamp-with-keyword (keyword) (defun org-remove-timestamp-with-keyword (keyword)
"Remove all time stamps with KEYWORD in the current entry." "Remove all time stamps with KEYWORD in the current entry."
@ -11079,7 +11077,7 @@ WHAT entry will also be removed."
org-deadline-time-regexp) org-deadline-time-regexp)
end t) end t)
(setq ts (match-string 1) (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))))))) default-input (and ts (org-get-compact-tod ts)))))))
(when what (when what
(setq time (setq time
@ -14025,8 +14023,7 @@ non-nil."
((org-at-timestamp-p 'lax) (match-string 0)))) ((org-at-timestamp-p 'lax) (match-string 0))))
;; Default time is either the timestamp at point or today. ;; Default time is either the timestamp at point or today.
;; When entering a range, only the range start is considered. ;; When entering a range, only the range start is considered.
(default-time (and ts (default-time (and ts (org-time-string-to-time ts)))
(apply #'encode-time (org-parse-time-string ts))))
(default-input (and ts (org-get-compact-tod ts))) (default-input (and ts (org-get-compact-tod ts)))
(repeater (and ts (repeater (and ts
(string-match "\\([.+-]+[0-9]+[hdwmy] ?\\)+" ts) (string-match "\\([.+-]+[0-9]+[hdwmy] ?\\)+" ts)
@ -14274,13 +14271,14 @@ user."
"range representable on this machine")) "range representable on this machine"))
(ding)) (ding))
;; One round trip to get rid of 34th of August and stuff like that.... (setq final (apply #'encode-time final))
(setq final (decode-time (apply 'encode-time final)))
(setq org-read-date-final-answer ans) (setq org-read-date-final-answer ans)
(if to-time (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) (if (and (boundp 'org-time-was-given) org-time-was-given)
(format "%04d-%02d-%02d %02d:%02d" (format "%04d-%02d-%02d %02d:%02d"
(nth 5 final) (nth 4 final) (nth 3 final) (nth 5 final) (nth 4 final) (nth 3 final)
@ -14310,7 +14308,7 @@ user."
(and (boundp 'org-time-was-given) org-time-was-given)) (and (boundp 'org-time-was-given) org-time-was-given))
(cdr fmts) (cdr fmts)
(car 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 (if org-read-date-inactive (concat "[" (substring txt 1 -1) "]") txt))
(txt (concat "=> " txt))) (txt (concat "=> " txt)))
(when (and org-end-time-was-given (when (and org-end-time-was-given
@ -14961,7 +14959,7 @@ signaled."
(daynr (org-closest-date s daynr prefer)) (daynr (org-closest-date s daynr prefer))
(t (time-to-days (t (time-to-days
(condition-case errdata (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" (error (error "Bad timestamp `%s'%s\nError was: %s"
s s
(if (not (and buffer pos)) "" (if (not (and buffer pos)) ""
@ -15059,12 +15057,12 @@ stamp stay unchanged. In any case, return value is an absolute
day number." day number."
(if (not (string-match "\\+\\([0-9]+\\)\\([hdwmy]\\)" start)) (if (not (string-match "\\+\\([0-9]+\\)\\([hdwmy]\\)" start))
;; No repeater. Do not shift time stamp. ;; 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))) (let ((value (string-to-number (match-string 1 start)))
(type (match-string 2 start))) (type (match-string 2 start)))
(if (= 0 value) (if (= 0 value)
;; Repeater with a 0-value is considered as void. ;; 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)) (let* ((base (org-date-to-gregorian start))
(target (org-date-to-gregorian current)) (target (org-date-to-gregorian current))
(sday (calendar-absolute-from-gregorian base)) (sday (calendar-absolute-from-gregorian base))
@ -20063,13 +20061,12 @@ return an active timestamp."
"Convert TIMESTAMP object into an Emacs internal time value. "Convert TIMESTAMP object into an Emacs internal time value.
Use end of date range or time range when END is non-nil. Use end of date range or time range when END is non-nil.
Otherwise, use its start." Otherwise, use its start."
(apply #'encode-time (apply #'encode-time 0
(cons 0 (mapcar
(mapcar (lambda (prop) (or (org-element-property prop timestamp) 0))
(lambda (prop) (or (org-element-property prop timestamp) 0)) (if end '(:minute-end :hour-end :day-end :month-end :year-end)
(if end '(:minute-end :hour-end :day-end :month-end :year-end) '(:minute-start :hour-start :day-start :month-start
'(:minute-start :hour-start :day-start :month-start :year-start)))))
:year-start))))))
(defun org-timestamp-has-time-p (timestamp) (defun org-timestamp-has-time-p (timestamp)
"Non-nil when TIMESTAMP has a time specified." "Non-nil when TIMESTAMP has a time specified."