From aabcfcad06b24709a4d80de99b6c2c9a287c4a30 Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Fri, 8 Nov 2024 21:15:23 +0100 Subject: [PATCH] Make actual timeline appear first in main display When I copy over the timeline into the actual time sheet application, I like to focus on the first line of the remaining report, moving it to the top of the window. Having the clocktime summary on top this hard, because after redrawing, the summary will be on top and not the actual timeline. Changing the positions may help here. --- site-lisp/timeline-tools.el | 49 ++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/site-lisp/timeline-tools.el b/site-lisp/timeline-tools.el index 8568567..f3b7a28 100644 --- a/site-lisp/timeline-tools.el +++ b/site-lisp/timeline-tools.el @@ -475,6 +475,32 @@ current values of the relevant buffer local variables." (format-time-string timeline-tools-headline-time-format timeline-tools--current-time-end))) + ;; Actual timeline + (insert "|--|\n") + (insert "| Category | Start | End | Duration | Task |\n") + (let ((last-category nil) + (current-category nil)) + (dolist (line timeline) + (setq current-category (funcall timeline-tools-category-function + line + timeline-tools--current-time-start + timeline-tools--current-time-end)) + (when (not (equal last-category current-category)) + (insert "|--|\n") + (setq last-category current-category)) + (insert + (propertize (format "| %s | %s | %s | %s min | %s | \n" + current-category + (timeline-tools-format-entry-time line 'start) + (timeline-tools-format-entry-time line 'end) + (timeline-tools-entry-duration line) + (timeline-tools-entry-headline line)) + 'entry line)))) + (insert "|--|\n") + (org-table-align) + + (insert "\n") + ;; Clocktime summary: booked categories, their total times, and their relative amount (let* ((data (->> timeline (-group-by #'(lambda (entry) ; group by category @@ -501,29 +527,6 @@ current values of the relevant buffer local variables." (org-table-align) (insert "\n")) - ;; Actual timeline - (insert "|--|\n") - (insert "| Category | Start | End | Duration | Task |\n") - (let ((last-category nil) - (current-category nil)) - (dolist (line timeline) - (setq current-category (funcall timeline-tools-category-function - line - timeline-tools--current-time-start - timeline-tools--current-time-end)) - (when (not (equal last-category current-category)) - (insert "|--|\n") - (setq last-category current-category)) - (insert - (propertize (format "| %s | %s | %s | %s min | %s | \n" - current-category - (timeline-tools-format-entry-time line 'start) - (timeline-tools-format-entry-time line 'end) - (timeline-tools-entry-duration line) - (timeline-tools-entry-headline line)) - 'entry line)))) - (insert "|--|\n") - (org-table-align) (goto-char (point-min)) (timeline-tools-next-line))))