Ihor Radchenko <yanta...@gmail.com> writes: > This looks like a bug in org-element-timestamp-parser > > Minimal reproducer: > > 1. Create an empty org file and open it > 2. Yank the following string: "CLOCK: [2021-10-22 Fri 10:41]--[2021]" > 3. M-: (org-element-at-point) <RET>
The attached is tentative fix for cases like the above. It gets rid of the observed error, however I am not sure if the clock line parser returns a reasonable value is such case. With the patch, org-element-at-point returns (clock (:status running :value (timestamp ( :type inactive :raw-value "[2021-10-22 Fri 10:41]" :year-start 2021 :month-start 10 :day-start 22 :hour-start 10 :minute-start 41 :year-end 2021 :month-end 10 :day-end 22 :hour-end 10 :minute-end 41 :begin 301 :end 323 :post-blank 0)) :duration nil :begin 294 :end 331 :post-blank 0 :post-affiliated 294)) Should we consider the above CLOCK line as a valid running clock or maybe it should be parsed as a paragraph? Best, Ihor
>From 91749491eb95cf1088fbe5a479eb30816478dba7 Mon Sep 17 00:00:00 2001 Message-Id: <91749491eb95cf1088fbe5a479eb30816478dba7.1637670436.git.yanta...@gmail.com> From: Ihor Radchenko <yanta...@gmail.com> Date: Tue, 23 Nov 2021 20:25:41 +0800 Subject: [PATCH] org-element: Fix org-element-timestamp-parser for incomplete ranges * lisp/org-element.el (org-element-timestamp-parser): Use more strict regexp to match second timestamp in timestamp--timestamp range. Fixes https://list.orgmode.org/orgmode/87tuh88kjv.fsf@localhost/ --- lisp/org-element.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/org-element.el b/lisp/org-element.el index b47fba9eb..b40ff2d33 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -3900,7 +3900,9 @@ (defun org-element-timestamp-parser () (activep (eq (char-after) ?<)) (raw-value (progn - (looking-at "\\([<[]\\(%%\\)?.*?\\)[]>]\\(?:--\\([<[].*?[]>]\\)\\)?") + (looking-at (concat "\\([<[]\\(%%\\)?.*?\\)[]>]\\(?:--\\(" + org-ts-regexp-both + "\\)\\)?")) (match-string-no-properties 0))) (date-start (match-string-no-properties 1)) (date-end (match-string 3)) -- 2.32.0