From b952504c81022898e2832ece53816f54e012106d Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Thu, 30 Sep 2021 15:35:18 +0200 Subject: [PATCH] Fix org mode category refresh when redisplaying timelines Iterating over the current set of file names may not work when no files are given (in which case all agenda files should be visisted). However, instead of fixing the set of files, it should be more robust to find all referenced buffers by iterating over the markers of the entries. In that case, even if a file is visited by multiple buffers, we can be sure that the right buffers are referesh before the timeline is redrawn. --- site-lisp/timeline-tools.el | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/site-lisp/timeline-tools.el b/site-lisp/timeline-tools.el index 2915315..ace5fd5 100644 --- a/site-lisp/timeline-tools.el +++ b/site-lisp/timeline-tools.el @@ -474,6 +474,7 @@ current values of the relevant buffer local variables." (interactive) (if (not (eq major-mode 'timeline-tools-mode)) (user-error "Not in Timeline buffer") + (let ((timeline (timeline-tools-transform-timeline (if force (timeline-tools-timeline @@ -481,6 +482,17 @@ current values of the relevant buffer local variables." timeline-tools--current-time-end 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. + (dolist (buffer (->> timeline + (mapcar #'timeline-tools-entry-marker) + (mapcar #'marker-buffer) + (cl-remove-duplicates))) + (with-current-buffer buffer + (org-refresh-category-properties))) + (erase-buffer) (insert (format "* Timeline from [%s] to [%s]\n\n" (format-time-string timeline-tools-headline-time-format @@ -563,9 +575,6 @@ as it is done by `timeline-tools-redraw-timeline'." "Parse timeline from files again and redraw current display. Updates category properties before constructing the new timeline." (interactive) - (dolist (file timeline-tools--current-files) - (with-current-buffer (get-file-buffer file) - (org-refresh-category-properties))) (timeline-tools-redraw-timeline 'force)) (defun timeline-tools-forward-day ()