emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: William Denton <wtd@pobox.com>, Nicolas Goaziou <mail@nicolasgoaziou.fr>
Cc: emacs-orgmode@gnu.org
Subject: [PATCH] "Cache corruption detected" when editing CLOCK timestamp by hand
Date: Tue, 23 Nov 2021 20:34:27 +0800	[thread overview]
Message-ID: <87v90j2gq4.fsf@localhost> (raw)
In-Reply-To: <87tuh88kjv.fsf@localhost>

[-- Attachment #1: Type: text/plain, Size: 1109 bytes --]

Ihor Radchenko <yantar92@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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-element-Fix-org-element-timestamp-parser-for-inc.patch --]
[-- Type: text/x-diff, Size: 1257 bytes --]

From 91749491eb95cf1088fbe5a479eb30816478dba7 Mon Sep 17 00:00:00 2001
Message-Id: <91749491eb95cf1088fbe5a479eb30816478dba7.1637670436.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@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


  reply	other threads:[~2021-11-23 12:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-22 18:47 "Cache corruption detected" when editing CLOCK timestamp by hand William Denton
2021-10-22 18:56 ` William Denton
2021-10-23  3:34 ` Ihor Radchenko
2021-10-23  3:52   ` Ihor Radchenko
2021-11-23 12:34     ` Ihor Radchenko [this message]
2022-04-30  3:37       ` [PATCH] " Ihor Radchenko
2022-05-30 11:50       ` Ihor Radchenko
2022-10-05  4:55         ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87v90j2gq4.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@nicolasgoaziou.fr \
    --cc=wtd@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).