forked from mirrors/org-mode
org-clock-update-time-maybe: Fix return value
* lisp/org-clock.el: Ensure that we return expected value. * testing/lisp/test-org-clock.el (test-org-clok/org-clock-update-time-maybe): Add new test.
This commit is contained in:
parent
2993f482c1
commit
08077812ef
|
@ -3062,6 +3062,7 @@ PROPERTIES: The list properties specified in the `:properties' parameter
|
||||||
Otherwise, return nil."
|
Otherwise, return nil."
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((origin (point))) ;; `save-excursion' may not work when deleting.
|
(let ((origin (point))) ;; `save-excursion' may not work when deleting.
|
||||||
|
(prog1
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(beginning-of-line 1)
|
(beginning-of-line 1)
|
||||||
(skip-chars-forward " \t")
|
(skip-chars-forward " \t")
|
||||||
|
@ -3112,7 +3113,7 @@ Otherwise, return nil."
|
||||||
;; Move back to initial position, but never beyond updated
|
;; Move back to initial position, but never beyond updated
|
||||||
;; clock.
|
;; clock.
|
||||||
(unless (< (point) origin)
|
(unless (< (point) origin)
|
||||||
(goto-char origin))))
|
(goto-char origin)))))
|
||||||
|
|
||||||
(defun org-clock-save ()
|
(defun org-clock-save ()
|
||||||
"Persist various clock-related data to disk.
|
"Persist various clock-related data to disk.
|
||||||
|
|
|
@ -113,6 +113,20 @@ the buffer."
|
||||||
(org-clock-timestamps-change 'up 1)
|
(org-clock-timestamps-change 'up 1)
|
||||||
(buffer-string)))))
|
(buffer-string)))))
|
||||||
|
|
||||||
|
(ert-deftest test-org-clok/org-clock-update-time-maybe ()
|
||||||
|
"Test `org-clock-update-time-maybe' specifications."
|
||||||
|
(should
|
||||||
|
(equal
|
||||||
|
"CLOCK: [2023-04-29 Sat 00:00]--[2023-05-04 Thu 01:00] => 121:00"
|
||||||
|
(org-test-with-temp-text
|
||||||
|
"CLOCK: [2023-04-29 Sat 00:00]--[2023-05-04 Thu 01:00]"
|
||||||
|
(should (org-clock-update-time-maybe))
|
||||||
|
(buffer-string))))
|
||||||
|
(should-not
|
||||||
|
(org-test-with-temp-text
|
||||||
|
"[2023-04-29 Sat 00:00]--[2023-05-04 Thu 01:00]"
|
||||||
|
(org-clock-update-time-maybe))))
|
||||||
|
|
||||||
|
|
||||||
;;; Clock drawer
|
;;; Clock drawer
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue