From d8e35ab9637ef0b2640b68e8fa0325bb9e1a8b48 Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Fri, 21 Jul 2023 13:10:11 +0200 Subject: [PATCH] Fix timestamp formatting in timeline-tools for Org 9.6 The values in the variable `org-time-stamp-formats` do not contain angle brackets anymore. Using the function `org-time-stamp-format` is more robust anyway and is also the official way to retrieve this format. --- site-lisp/timeline-tools.el | 43 ++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/site-lisp/timeline-tools.el b/site-lisp/timeline-tools.el index c760921..33c7657 100644 --- a/site-lisp/timeline-tools.el +++ b/site-lisp/timeline-tools.el @@ -200,30 +200,6 @@ unpredictable behavior." (save-mark-and-excursion (funcall headline-fn)))))))) -(defvar timeline-tools-org-inactive-timestamp-format - (concat "[" (substring (cdr org-time-stamp-formats) 1 -1) "]") - "Format of inactive `org-mode’ timestamps. -Can be used as format string for `format-time’.") - -(defun timeline-tools-insert-clockline (time-1 time-2) - "Insert new clock line from TIME-1 to TIME-2. - -Insertion will be done at the beginning of the current line. -TIME-1 and TIME-2 must be given in a format understandable by -`format-time-string’, which see. Saves mark and point. If -TIME-2 is nil, insert dangling clock line." - (save-mark-and-excursion - (beginning-of-line) - (indent-according-to-mode) - (insert "CLOCK: ") - (insert (format-time-string timeline-tools-org-inactive-timestamp-format - time-1)) - (unless (null time-2) - (insert "--") - (insert (format-time-string timeline-tools-org-inactive-timestamp-format - time-2)) - (org-clock-update-time-maybe)))) - (defun timeline-tools-clocklines-of-task (pom) "Return list of all clock lines of task under POM. @@ -735,6 +711,25 @@ See `timeline-tools-swap-line-with-next' for more details." ;;; Manipulating Clocklines in Org Files +(defun timeline-tools-insert-clockline (time-1 time-2) + "Insert new clock line from TIME-1 to TIME-2. + +Insertion will be done at the beginning of the current line. +TIME-1 and TIME-2 must be given in a format understandable by +`format-time-string’, which see. Saves mark and point. If +TIME-2 is nil, insert dangling clock line." + (save-mark-and-excursion + (beginning-of-line) + (indent-according-to-mode) + (insert "CLOCK: ") + (insert (format-time-string (org-time-stamp-format :with-time :inactive) + time-1)) + (unless (null time-2) + (insert "--") + (insert (format-time-string (org-time-stamp-format :with-time :inactive) + time-2)) + (org-clock-update-time-maybe)))) + ;; XXX: All this needs some autoloadable frontend (defun timeline-tools-clockline-no-conflict (start end &rest buffers)