Merge branch 'maint'

This commit is contained in:
Bastien Guerry 2013-01-31 14:18:24 +01:00
commit a2febd2101
1 changed files with 78 additions and 78 deletions

View File

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