Merge branch 'maint'
This commit is contained in:
commit
a2febd2101
|
@ -1719,84 +1719,84 @@ which HEADLINE-FILTER returns nil are excluded from the clock summation.
|
|||
PROPNAME lets you set a custom text property instead of :org-clock-minutes."
|
||||
(interactive)
|
||||
(org-unmodified
|
||||
(let* ((re (concat "^\\(\\*+\\)[ \t]\\|^[ \t]*"
|
||||
org-clock-string
|
||||
"[ \t]*\\(?:\\(\\[.*?\\]\\)-+\\(\\[.*?\\]\\)\\|=>[ \t]+\\([0-9]+\\):\\([0-9]+\\)\\)"))
|
||||
(lmax 30)
|
||||
(ltimes (make-vector lmax 0))
|
||||
(t1 0)
|
||||
(level 0)
|
||||
ts te dt
|
||||
time)
|
||||
(if (stringp tstart) (setq tstart (org-time-string-to-seconds tstart)))
|
||||
(if (stringp tend) (setq tend (org-time-string-to-seconds tend)))
|
||||
(if (consp tstart) (setq tstart (org-float-time tstart)))
|
||||
(if (consp tend) (setq tend (org-float-time tend)))
|
||||
(remove-text-properties (point-min) (point-max)
|
||||
`(,(or propname :org-clock-minutes) t
|
||||
:org-clock-force-headline-inclusion t))
|
||||
(save-excursion
|
||||
(goto-char (point-max))
|
||||
(while (re-search-backward re nil t)
|
||||
(cond
|
||||
((match-end 2)
|
||||
;; Two time stamps
|
||||
(setq ts (match-string 2)
|
||||
te (match-string 3)
|
||||
ts (org-float-time
|
||||
(apply 'encode-time (org-parse-time-string ts)))
|
||||
te (org-float-time
|
||||
(apply 'encode-time (org-parse-time-string te)))
|
||||
ts (if tstart (max ts tstart) ts)
|
||||
te (if tend (min te tend) te)
|
||||
dt (- te ts)
|
||||
t1 (if (> dt 0) (+ t1 (floor (/ dt 60))) t1)))
|
||||
((match-end 4)
|
||||
;; A naked time
|
||||
(setq t1 (+ t1 (string-to-number (match-string 5))
|
||||
(* 60 (string-to-number (match-string 4))))))
|
||||
(t ;; A headline
|
||||
;; Add the currently clocking item time to the total
|
||||
(when (and org-clock-report-include-clocking-task
|
||||
(equal (org-clocking-buffer) (current-buffer))
|
||||
(equal (marker-position org-clock-hd-marker) (point))
|
||||
tstart
|
||||
tend
|
||||
(>= (org-float-time org-clock-start-time) tstart)
|
||||
(<= (org-float-time org-clock-start-time) tend))
|
||||
(let ((time (floor (- (org-float-time)
|
||||
(org-float-time org-clock-start-time)) 60)))
|
||||
(setq t1 (+ t1 time))))
|
||||
(let* ((headline-forced
|
||||
(get-text-property (point)
|
||||
:org-clock-force-headline-inclusion))
|
||||
(headline-included
|
||||
(or (null headline-filter)
|
||||
(save-excursion
|
||||
(save-match-data (funcall headline-filter))))))
|
||||
(setq level (- (match-end 1) (match-beginning 1)))
|
||||
(when (or (> t1 0) (> (aref ltimes level) 0))
|
||||
(when (or headline-included headline-forced)
|
||||
(if headline-included
|
||||
(loop for l from 0 to level do
|
||||
(aset ltimes l (+ (aref ltimes l) t1))))
|
||||
(setq time (aref ltimes level))
|
||||
(goto-char (match-beginning 0))
|
||||
(put-text-property (point) (point-at-eol)
|
||||
(or propname :org-clock-minutes) time)
|
||||
(if headline-filter
|
||||
(save-excursion
|
||||
(save-match-data
|
||||
(while
|
||||
(> (funcall outline-level) 1)
|
||||
(outline-up-heading 1 t)
|
||||
(put-text-property
|
||||
(point) (point-at-eol)
|
||||
:org-clock-force-headline-inclusion t))))))
|
||||
(setq t1 0)
|
||||
(loop for l from level to (1- lmax) do
|
||||
(aset ltimes l 0)))))))
|
||||
(setq org-clock-file-total-minutes (aref ltimes 0))))))
|
||||
(let* ((re (concat "^\\(\\*+\\)[ \t]\\|^[ \t]*"
|
||||
org-clock-string
|
||||
"[ \t]*\\(?:\\(\\[.*?\\]\\)-+\\(\\[.*?\\]\\)\\|=>[ \t]+\\([0-9]+\\):\\([0-9]+\\)\\)"))
|
||||
(lmax 30)
|
||||
(ltimes (make-vector lmax 0))
|
||||
(t1 0)
|
||||
(level 0)
|
||||
ts te dt
|
||||
time)
|
||||
(if (stringp tstart) (setq tstart (org-time-string-to-seconds tstart)))
|
||||
(if (stringp tend) (setq tend (org-time-string-to-seconds tend)))
|
||||
(if (consp tstart) (setq tstart (org-float-time tstart)))
|
||||
(if (consp tend) (setq tend (org-float-time tend)))
|
||||
(remove-text-properties (point-min) (point-max)
|
||||
`(,(or propname :org-clock-minutes) t
|
||||
:org-clock-force-headline-inclusion t))
|
||||
(save-excursion
|
||||
(goto-char (point-max))
|
||||
(while (re-search-backward re nil t)
|
||||
(cond
|
||||
((match-end 2)
|
||||
;; Two time stamps
|
||||
(setq ts (match-string 2)
|
||||
te (match-string 3)
|
||||
ts (org-float-time
|
||||
(apply 'encode-time (org-parse-time-string ts)))
|
||||
te (org-float-time
|
||||
(apply 'encode-time (org-parse-time-string te)))
|
||||
ts (if tstart (max ts tstart) ts)
|
||||
te (if tend (min te tend) te)
|
||||
dt (- te ts)
|
||||
t1 (if (> dt 0) (+ t1 (floor (/ dt 60))) t1)))
|
||||
((match-end 4)
|
||||
;; A naked time
|
||||
(setq t1 (+ t1 (string-to-number (match-string 5))
|
||||
(* 60 (string-to-number (match-string 4))))))
|
||||
(t ;; A headline
|
||||
;; Add the currently clocking item time to the total
|
||||
(when (and org-clock-report-include-clocking-task
|
||||
(equal (org-clocking-buffer) (current-buffer))
|
||||
(equal (marker-position org-clock-hd-marker) (point))
|
||||
tstart
|
||||
tend
|
||||
(>= (org-float-time org-clock-start-time) tstart)
|
||||
(<= (org-float-time org-clock-start-time) tend))
|
||||
(let ((time (floor (- (org-float-time)
|
||||
(org-float-time org-clock-start-time)) 60)))
|
||||
(setq t1 (+ t1 time))))
|
||||
(let* ((headline-forced
|
||||
(get-text-property (point)
|
||||
:org-clock-force-headline-inclusion))
|
||||
(headline-included
|
||||
(or (null headline-filter)
|
||||
(save-excursion
|
||||
(save-match-data (funcall headline-filter))))))
|
||||
(setq level (- (match-end 1) (match-beginning 1)))
|
||||
(when (or (> t1 0) (> (aref ltimes level) 0))
|
||||
(when (or headline-included headline-forced)
|
||||
(if headline-included
|
||||
(loop for l from 0 to level do
|
||||
(aset ltimes l (+ (aref ltimes l) t1))))
|
||||
(setq time (aref ltimes level))
|
||||
(goto-char (match-beginning 0))
|
||||
(put-text-property (point) (point-at-eol)
|
||||
(or propname :org-clock-minutes) time)
|
||||
(if headline-filter
|
||||
(save-excursion
|
||||
(save-match-data
|
||||
(while
|
||||
(> (funcall outline-level) 1)
|
||||
(outline-up-heading 1 t)
|
||||
(put-text-property
|
||||
(point) (point-at-eol)
|
||||
:org-clock-force-headline-inclusion t))))))
|
||||
(setq t1 0)
|
||||
(loop for l from level to (1- lmax) do
|
||||
(aset ltimes l 0)))))))
|
||||
(setq org-clock-file-total-minutes (aref ltimes 0))))))
|
||||
|
||||
(defun org-clock-sum-current-item (&optional tstart)
|
||||
"Return time, clocked on current item in total."
|
||||
|
|
Loading…
Reference in New Issue