[Timeline] Allow clustering by same entry

The corresponding function shares a lot of code with the one for clustering by
same category, but for now it’s not worth the effort to refactor this.
This commit is contained in:
Daniel - 2018-08-03 20:14:57 +02:00
parent f2475711b7
commit db0d3e726a
Signed by: dbo
GPG Key ID: 4F63DB96D45AA9C6
1 changed files with 19 additions and 0 deletions

View File

@ -293,6 +293,25 @@ Markers to org mode tasks are combined into a list."
(-mapcat #'timeline-tools-entry-markers cluster)))
new-timeline)))
(defun timeline-tools-cluster-same-entry (timeline)
"Cluster TIMELINE into consecutive entries with equal marker.
This only works if every entry in timeline consists of a
singleton marker only. In case this is not satisfied, this
function will throw an error."
(assert (-all-p #'(lambda (entry)
(null (cdr (timeline-tools-entry-markers entry))))
timeline)
"Timeline must not contain entries with more than one marker.")
(let ((new-timeline (-partition-by #'(lambda (entry)
(-first-item (timeline-tools-entry-markers entry)))
timeline)))
(mapcar (lambda (cluster)
(timeline-tools-make-entry
(timeline-tools-entry-start-time (-first-item cluster))
(timeline-tools-entry-end-time (-last-item cluster))
(-mapcat #'timeline-tools-entry-markers cluster)))
new-timeline)))
(defun timeline-tools-remove-short-entries (timeline &optional threshold)
"Remove entries from TIMELINE shorter than THRESHOLD.