Re: [PATCH] "Cache corruption detected" when editing CLOCK timestamp by hand

2022-10-04 Thread Ihor Radchenko
Ihor Radchenko  writes:

>> Should we consider the above CLOCK line as a valid running clock or
>> maybe it should be parsed as a paragraph?
>
> I am still leaving this question open despite applying the above patch.
> At least, we need to get the bug fixed.

I now made Org parse malformed CLOCK lines as paragraphs.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=e305755b1a7ac41c74ebf9a39e8b9d547acb523d

-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92



Re: [PATCH] "Cache corruption detected" when editing CLOCK timestamp by hand

2022-05-30 Thread Ihor Radchenko
Ihor Radchenko  writes:

>> 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) 
>
> The attached is tentative fix for cases like the above.

Applied onto main via 4dda0d7a8. This may also fix
https://list.orgmode.org/8735grjq2e.fsf@no.workgroup/T/#u

> Should we consider the above CLOCK line as a valid running clock or
> maybe it should be parsed as a paragraph?

I am still leaving this question open despite applying the above patch.
At least, we need to get the bug fixed.

Best,
Ihor



Re: [PATCH] "Cache corruption detected" when editing CLOCK timestamp by hand

2022-04-29 Thread Ihor Radchenko
Ihor Radchenko  writes:

> Should we consider the above CLOCK line as a valid running clock or
> maybe it should be parsed as a paragraph?

Nicolas, do you have any comment on this? I am inclined to treat

CLOCK: [2021-10-22 Fri 10:41]--[2021]

as a paragraph, not a clock line.

Best,
Ihor



[PATCH] "Cache corruption detected" when editing CLOCK timestamp by hand

2021-11-23 Thread Ihor Radchenko
Ihor Radchenko  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) 

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 
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