[Timeline] Add missing case when looking for clocklines in range

Missed case where there is only one clockline covering the whole requested
range.
This commit is contained in:
Daniel - 2018-01-24 20:48:57 +01:00
parent 7399609194
commit 0a5dc32b98
Signed by: dbo
GPG Key ID: 4F63DB96D45AA9C6
1 changed files with 16 additions and 13 deletions

View File

@ -139,8 +139,9 @@ form (START . END), where START and END are the starting and
ending times of a clock line for this task. START and END are ending times of a clock line for this task. START and END are
given as seconds since the epoch, as a floating point number. No given as seconds since the epoch, as a floating point number. No
truncation with respect to TSTART and TEND is done, i.e., START truncation with respect to TSTART and TEND is done, i.e., START
or END may occassionally lie outside of these limits, but it is or END may occassionally lie outside of these limits, as long as
always true that TSTART END TEND or TSTART START TEND." the corresponding clockline has non-empty intersection with the
given bounds."
;; adapted from `org-clock-sum ;; adapted from `org-clock-sum
(when (eq major-mode 'org-mode) (when (eq major-mode 'org-mode)
(let* ((tstart (cond ((stringp tstart) (org-time-string-to-seconds tstart)) (let* ((tstart (cond ((stringp tstart) (org-time-string-to-seconds tstart))
@ -153,25 +154,27 @@ always true that TSTART ≤ END ≤ TEND or TSTART ≤ START ≤ TEND."
(timeline-tools-map-clocklines (timeline-tools-map-clocklines
;; when on clock line, collect times ;; when on clock line, collect times
#'(lambda (start end) #'(lambda (start end)
(let* ((ts (float-time (let* ((ts (org-time-string-to-seconds start))
(apply #'encode-time (org-parse-time-string start)))) (te (org-time-string-to-seconds end)))
(te (float-time (when (or (<= tstart te tend)
(apply #'encode-time (org-parse-time-string end)))) (<= tstart ts tend)
(dt (- (if tend (min te tend) te) (<= ts tstart tend te))
(if tstart (max ts tstart) ts))))
(when (> dt 0)
(push (cons ts te) times)))) (push (cons ts te) times))))
;; when on headlines, store away collected clocklines ;; when on headlines, store away collected clocklines
#'(lambda () #'(lambda ()
;; add currently running clock if wanted
(when (and org-clock-report-include-clocking-task (when (and org-clock-report-include-clocking-task
(eq (org-clocking-buffer) (current-buffer)) (eq (org-clocking-buffer) (current-buffer))
(eq (marker-position org-clock-hd-marker) (point)) (eq (marker-position org-clock-hd-marker) (point))
(or (and tstart ;; fixme: make this test look nicer
(<= tstart (float-time org-clock-start-time) tend)) (or (<= tstart (float-time org-clock-start-time) tend)
(and tend (<= tstart (float-time) tend)
(<= tstart (float-time) tend)))) (<= (float-time org-clock-start-time)
tstart tend
(float-time))))
(push (cons (float-time org-clock-start-time) (float-time)) (push (cons (float-time org-clock-start-time) (float-time))
times)) times))
;; store away clocklines of current headline
(when (not (null times)) (when (not (null times))
(push (cons (point-marker) times) task-clock-times) (push (cons (point-marker) times) task-clock-times)
(setq times nil)))) (setq times nil))))