[Timeline] Extract gap-filling into separate function
This commit is contained in:
parent
f2db1f5b5e
commit
62ac9a887b
@ -44,7 +44,7 @@
|
|||||||
:group 'applications)
|
:group 'applications)
|
||||||
|
|
||||||
(defcustom timeline-tools-filter-functions
|
(defcustom timeline-tools-filter-functions
|
||||||
(list #'timeline-tools-remove-short-entries
|
(list #'timeline-tools-fill-gaps
|
||||||
#'timeline-tools-cluster-same-entries)
|
#'timeline-tools-cluster-same-entries)
|
||||||
"List of functions to apply when formatting timelines.
|
"List of functions to apply when formatting timelines.
|
||||||
Filter are applied in the order they are given in this list."
|
Filter are applied in the order they are given in this list."
|
||||||
@ -332,7 +332,9 @@ function will throw an error."
|
|||||||
A slot is short if it is not longer than THRESHOLD seconds.
|
A slot is short if it is not longer than THRESHOLD seconds.
|
||||||
Resulting gaps are distributed evenly among adjacent slots.
|
Resulting gaps are distributed evenly among adjacent slots.
|
||||||
THRESHOLD defaults to the value of
|
THRESHOLD defaults to the value of
|
||||||
`timeline-tools-short-task-threshold’ if not supplied."
|
`timeline-tools-short-task-threshold’ if not supplied.
|
||||||
|
|
||||||
|
This function destructively modifies its first argument."
|
||||||
(unless (null timeline)
|
(unless (null timeline)
|
||||||
(let ((start (timeline-tools-entry-start-time (-first-item timeline)))
|
(let ((start (timeline-tools-entry-start-time (-first-item timeline)))
|
||||||
(end (timeline-tools-entry-end-time (-last-item timeline)))
|
(end (timeline-tools-entry-end-time (-last-item timeline)))
|
||||||
@ -352,9 +354,18 @@ THRESHOLD defaults to the value of
|
|||||||
(setf (timeline-tools-entry-end-time (-last-item new-timeline)) end)
|
(setf (timeline-tools-entry-end-time (-last-item new-timeline)) end)
|
||||||
|
|
||||||
;; distribute gaps evenly among adjacent slots
|
;; distribute gaps evenly among adjacent slots
|
||||||
|
(timeline-tools-fill-gaps new-timeline))))
|
||||||
|
|
||||||
|
(defun timeline-tools-fill-gaps (timeline)
|
||||||
|
"Fill gaps in TIMELINE evenly.
|
||||||
|
|
||||||
|
This is achieved by extending the start time and the end time of
|
||||||
|
the surrounding entries equally.
|
||||||
|
|
||||||
|
This function destructively modifies its first argument."
|
||||||
(cl-do
|
(cl-do
|
||||||
((sub-timeline new-timeline (cdr sub-timeline)))
|
((sub-timeline timeline (cdr sub-timeline)))
|
||||||
((null (cdr sub-timeline)))
|
((null (cdr sub-timeline)) timeline)
|
||||||
(let* ((entry-1 (-first-item sub-timeline))
|
(let* ((entry-1 (-first-item sub-timeline))
|
||||||
(entry-2 (-second-item sub-timeline))
|
(entry-2 (-second-item sub-timeline))
|
||||||
(end-1 (timeline-tools-entry-end-time entry-1))
|
(end-1 (timeline-tools-entry-end-time entry-1))
|
||||||
@ -362,9 +373,7 @@ THRESHOLD defaults to the value of
|
|||||||
(when (not (= end-1 start-2))
|
(when (not (= end-1 start-2))
|
||||||
(let ((middle (/ (+ end-1 start-2) 2)))
|
(let ((middle (/ (+ end-1 start-2) 2)))
|
||||||
(setf (timeline-tools-entry-end-time entry-1) middle)
|
(setf (timeline-tools-entry-end-time entry-1) middle)
|
||||||
(setf (timeline-tools-entry-start-time entry-2) middle)))))
|
(setf (timeline-tools-entry-start-time entry-2) middle))))))
|
||||||
|
|
||||||
new-timeline)))
|
|
||||||
|
|
||||||
(defun timeline-tools-transform-timeline (timeline)
|
(defun timeline-tools-transform-timeline (timeline)
|
||||||
"Return timeline from files, after application of
|
"Return timeline from files, after application of
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user