Compare commits

..

No commits in common. "4706de981b1875f9174100a04ca3bcc57dc0d0d2" and "986ae6873092a76b0eccc83463c6183e616f1b76" have entirely different histories.

View File

@ -59,7 +59,7 @@ Filter are applied in the order they are given in this list."
:group 'timeline-tools
:type 'integer)
(defcustom timeline-tools-headline-time-format "%Y-%m-%d %a %H:%M"
(defcustom timeline-tools-headline-time-format "%Y-%m-%d %H:%M"
"Format of time used in the headline of a timeline."
:group 'timeline-tools
:type 'string)
@ -433,7 +433,8 @@ interactively, this date will be queried with `org-read-date.
When not given, FILES defaults to `org-agenda-files without
archives."
(interactive (list (org-read-date nil nil)))
(let ((timeline-tools-time-format "%H:%M"))
(let ((timeline-tools-time-format "%H:%M")
(timeline-tools-headline-time-format "%Y-%m-%d"))
(timeline-tools-format-timeline (concat date " 00:00")
(org-read-date nil nil "++1d" nil
(org-time-string-to-time date))
@ -457,8 +458,9 @@ current values of the relevant buffer local variables."
timeline-tools--current-files)
(timeline-tools--get-timeline-from-buffer)))))
;; Update categories in all affected buffers to retrieve up-to-date information; find all
;; relevant buffers by checking the markers of all entries.
;; Update categories in all affected buffers to retrieve up-to-date
;; information; find all relevant buffers by checking the markers of all
;; entries.
(dolist (buffer (->> timeline
(mapcar #'timeline-tools-entry-marker)
(mapcar #'marker-buffer)
@ -467,35 +469,11 @@ current values of the relevant buffer local variables."
(org-refresh-category-properties)))
(erase-buffer)
;; Header
(insert (format "Timeline from [%s] to [%s]\n\n"
(insert (format "* Timeline from [%s] to [%s]\n\n"
(format-time-string timeline-tools-headline-time-format
timeline-tools--current-time-start)
(format-time-string timeline-tools-headline-time-format
timeline-tools--current-time-end)))
;; Clocktime summary: booked categories, their total times, and their relative amount
(let* ((data (->> timeline
(-group-by timeline-tools-category-function)
(-map #'(lambda (category-lines)
(list (car category-lines)
(->> category-lines
cdr
(-map #'timeline-tools-entry-duration)
-sum))))))
(total-time (float (-sum (-map #'-second-item data)))))
(insert "| Category | Total | Amount |\n|--|\n")
(dolist (category-lines data)
(insert (format "| %s | %s | %.2f%% |\n"
(-first-item category-lines)
(org-duration-from-minutes (-second-item category-lines))
(* 100 (/ (-second-item category-lines) total-time)))))
(insert (format "|--|\n| | %s | |\n" (org-duration-from-minutes total-time)))
(org-table-align)
(insert "\n"))
;; Actual timeline
(insert "|--|\n")
(insert "| Category | Start | End | Duration | Task |\n")
(let ((last-category nil)