1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2025-01-22 19:47:07 +00:00

org-clock-update-time-maybe: Update the containing timestamps as well

* lisp/org-clock.el (org-clock-update-time-maybe): Update the
containing timestamps inside the clock, not only the clock sum.

Reported-by: Bruce E. Robertson <brucer42@gmail.com>
Link: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=53393
This commit is contained in:
Ihor Radchenko 2022-11-01 15:52:25 +08:00
parent 9987451252
commit 5bc6741a5a
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B

View File

@ -3066,18 +3066,31 @@ Otherwise, return nil."
(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)))
(end-of-line 1)
(setq ts (match-string 1)
te (match-string 3))
(setq s (- (org-time-string-to-seconds te)
;; Prevent recursive call from `org-timestamp-change'.
(cl-letf (((symbol-function 'org-clock-update-time-maybe) #'ignore))
;; Update timestamps.
(save-excursion
(goto-char (match-beginning 1)) ; opening timestamp
(save-match-data (org-timestamp-change 0 'day)))
;; Refresh match data.
(looking-at re)
(save-excursion
(goto-char (match-beginning 3)) ; closing timestamp
(save-match-data (org-timestamp-change 0 'day))))
;; Refresh match data.
(looking-at re)
(and (match-end 4) (delete-region (match-beginning 4) (match-end 4)))
(end-of-line 1)
(setq ts (match-string 1)
te (match-string 3))
(setq s (- (org-time-string-to-seconds te)
(org-time-string-to-seconds ts))
neg (< s 0)
s (abs s)
h (floor (/ s 3600))
s (- s (* 3600 h))
m (floor (/ s 60))
s (- s (* 60 s)))
neg (< s 0)
s (abs s)
h (floor (/ s 3600))
s (- s (* 3600 h))
m (floor (/ s 60))
s (- s (* 60 s)))
(insert " => " (format (if neg "-%d:%02d" "%2d:%02d") h m))
t))))))