[Timeline] Extend ‘timeline-tools-timeline’ to also work on buffers
This commit is contained in:
parent
95219e1b6b
commit
9fa7662867
|
@ -287,23 +287,35 @@ or END will always be in the interval [TSTART,TEND]."
|
||||||
(setq times nil))))
|
(setq times nil))))
|
||||||
task-clock-times))
|
task-clock-times))
|
||||||
|
|
||||||
;; XXX: make this work on buffers instead of files
|
(defun timeline-tools-timeline (tstart tend &optional files-or-buffers)
|
||||||
(defun timeline-tools-timeline (tstart tend &optional files)
|
"Return timeline between TSTART and TEND from FILES-OR-BUFFERS.
|
||||||
"Return timeline between TSTART and TEND from FILES.
|
|
||||||
|
|
||||||
Each entry consists of a START-TIME, END-TIME, and MARKER are as
|
Each entry consists of a START-TIME, END-TIME, and MARKER are as
|
||||||
returned by `timeline-tools-clocklines-in-range’, which see.
|
returned by `timeline-tools-clocklines-in-range’, which see.
|
||||||
Entries in the resulting list are sorted by START, ascending. If
|
Entries in the resulting list are sorted by START, ascending.
|
||||||
not given, FILES defaults to `org-agenda-files’ including all
|
TSTART and TEND must be valid time specifiers for
|
||||||
|
`timeline-tools-clocklines-in-range’. If not given,
|
||||||
|
FILES-OR-BUFFERS defaults to `org-agenda-files’ including all
|
||||||
archives."
|
archives."
|
||||||
(let (timeline-of-files turned-around-timeline)
|
(let (timeline-of-files turned-around-timeline)
|
||||||
(setq timeline-of-files
|
(setq timeline-of-files
|
||||||
(->> (or files (org-agenda-files t t))
|
(->> (or files-or-buffers (org-agenda-files t t))
|
||||||
(cl-remove-if-not #'file-exists-p)
|
(cl-mapcan #'(lambda (file-or-buffer)
|
||||||
(cl-mapcan #'(lambda (file)
|
(let ((buffer (cond
|
||||||
(with-current-buffer (or (get-file-buffer file)
|
((bufferp file-or-buffer)
|
||||||
(find-file-noselect file))
|
file-or-buffer)
|
||||||
(timeline-tools-clocklines-in-range tstart tend))))))
|
((not (stringp file-or-buffer))
|
||||||
|
(warn "Neither valid file nor buffer: %s" file-or-buffer)
|
||||||
|
nil)
|
||||||
|
((not (file-exists-p file-or-buffer))
|
||||||
|
(warn "File does not exist: %s" file-or-buffer)
|
||||||
|
nil)
|
||||||
|
(t (or (get-file-buffer file-or-buffer)
|
||||||
|
(find-file-noselect file-or-buffer))))))
|
||||||
|
(when buffer
|
||||||
|
(with-current-buffer buffer
|
||||||
|
(timeline-tools-clocklines-in-range tstart tend))))))))
|
||||||
|
|
||||||
;; collect clock-lines in timeline and convert them to proper entries
|
;; collect clock-lines in timeline and convert them to proper entries
|
||||||
(dolist (entry timeline-of-files)
|
(dolist (entry timeline-of-files)
|
||||||
(dolist (clock-time (cdr entry))
|
(dolist (clock-time (cdr entry))
|
||||||
|
|
Loading…
Reference in New Issue