forked from mirrors/org-mode
org-clock-sum: Do not err when have malformed clock lines
* lisp/org-clock.el: Only consider proper clock elements when calculating clock sum. Do not rely on crude regexp. Reported-by: Gregor Zattler <grfz@gmx.de> Link: https://orgmode.org/list/87y1yecmgb.fsf@localhost
This commit is contained in:
parent
0e4874f17c
commit
3790bf8ea1
|
@ -1914,8 +1914,12 @@ PROPNAME lets you set a custom text property instead of :org-clock-minutes."
|
|||
(save-excursion
|
||||
(goto-char (point-max))
|
||||
(while (re-search-backward re nil t)
|
||||
(let ((element-type
|
||||
(org-element-type
|
||||
(save-match-data
|
||||
(org-element-at-point)))))
|
||||
(cond
|
||||
((match-end 2)
|
||||
((and (eq element-type 'clock) (match-end 2))
|
||||
;; Two time stamps.
|
||||
(let* ((ss (match-string 2))
|
||||
(se (match-string 3))
|
||||
|
@ -1928,7 +1932,7 @@ PROPNAME lets you set a custom text property instead of :org-clock-minutes."
|
|||
;; A naked time.
|
||||
(setq t1 (+ t1 (string-to-number (match-string 5))
|
||||
(* 60 (string-to-number (match-string 4))))))
|
||||
(t ;A headline
|
||||
((memq element-type '(headline inlinetask)) ;A headline
|
||||
;; Add the currently clocking item time to the total.
|
||||
(when (and org-clock-report-include-clocking-task
|
||||
(eq (org-clocking-buffer) (current-buffer))
|
||||
|
@ -1969,7 +1973,7 @@ PROPNAME lets you set a custom text property instead of :org-clock-minutes."
|
|||
:org-clock-force-headline-inclusion t))))))
|
||||
(setq t1 0)
|
||||
(cl-loop for l from level to (1- lmax) do
|
||||
(aset ltimes l 0)))))))
|
||||
(aset ltimes l 0))))))))
|
||||
(setq org-clock-file-total-minutes (aref ltimes 0))))))
|
||||
|
||||
(defun org-clock-sum-current-item (&optional tstart)
|
||||
|
|
Loading…
Reference in a new issue