From 9ab5d552371a06266b4d22a8d3dc86a064de11cd Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Fri, 10 Jan 2020 18:12:50 +0100 Subject: [PATCH] Remove visibility cycling from general clock mapping function It's only necessary when editing the buffer, not when only traversing it. Moved it to the only function where this is actually done, and added a comment to the docstring of `timeline-tools-map-clocklines' to remind everyone that editing the buffer through this function may yield funny surprises :) --- site-lisp/timeline-tools.el | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/site-lisp/timeline-tools.el b/site-lisp/timeline-tools.el index a959746..b8784ae 100644 --- a/site-lisp/timeline-tools.el +++ b/site-lisp/timeline-tools.el @@ -166,14 +166,13 @@ ending time as arguments and point on the beginning of the line. For each headline, call HEADLINE-FN with no arguments and point on the start of the headline. Traversal will be done from the end of the file upwards. If the buffer is narrowed, only this -region will be traversed." +region will be traversed. If either CLOCKLINE-FN or HEADLINE-FN +edit the current buffer, make sure to use `org-show-all' to show +all insivible elements; otherwise editing may result in +unpredictable behavior." (unless (eq major-mode 'org-mode) (user-error "Not in Org mode buffer, cannot parse clocklines")) - ;; Make sure everything is visible, as otherwise editing may produce odd - ;; results - (org-show-all) - (let* ((re (concat "^\\(\\*+\\)[ \t]\\|^[ \t]*" org-clock-string "[ \t]*\\(\\[.*?\\]\\)-+\\(\\[.*?\\]\\)"))) @@ -642,6 +641,10 @@ clock line." (new-end (float-time end))) (dolist (buffer buffers) (with-current-buffer buffer + ;; Make sure everything is visible, as otherwise editing may produce odd + ;; results + (org-show-all) + (timeline-tools-map-clocklines (lambda (timestamp-1 timestamp-2) (let ((current-start (org-time-string-to-seconds timestamp-1))