emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Morgan Smith <morgan.j.smith@outlook.com>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: emacs-orgmode@gnu.org,  Sanel Zukan <sanelz@gmail.com>
Subject: Re: [PATCH] lisp/org-clock.el (org-clock-sum): Rewrite regex using rx
Date: Wed, 19 Jun 2024 14:24:08 -0400	[thread overview]
Message-ID: <CH3PR84MB34240B172F1EA17489C9DD20C5CF2@CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <87bk3x9bpv.fsf@localhost> (Ihor Radchenko's message of "Wed, 19 Jun 2024 15:46:52 +0000")

Ihor Radchenko <yantar92@posteo.net> writes:

>> Ideally the fix in that commit should be ported to the org-element API.
>> Notably, the malformed clock from the email thread from that commit is
>> parsed a little strangely by org-element.  I'm not sure what effect this
>> has on my rewrite patch but regardless, we should probably fix this.
>> Notice how ":day-end" and ":minute-end" are set but not ":hour-start" or
>> ":minute-start".
>
> That's expected.
> We have the following _syntax_ description for clock lines:
>
> https://orgmode.org/worg/org-syntax.html#Clocks...
> clock: INACTIVE-TIMESTAMP-RANGE DURATION
>
> And [2012-01-01 sun. 00rr:01] is a perfectly valid timestamp without
> time part. Org does allow arbitrary additional text in the timestamps.
> (it is by design, to allow future extensions of the syntax, like the
> planned timezone support)

My specific issue is that the ":*-end" stuff can be set when the
"*-start" stuff is not.

Running the following snippet on the following file results in this:

======= snippet
(org-element-cache-map
 (lambda (clock)
   "Calculate end-time - start-time"
   (let ((timestamp (org-element-property :value clock)))
     (- (float-time (org-timestamp-to-time timestamp t))
        (float-time (org-timestamp-to-time timestamp)))))
 :granularity 'element
 :restrict-elements 'clock)
========


======== file
* Test
CLOCK: [2023-11-15 Wed 15:26]--[2023-11-15 Wed 16:12] =>  0:46
calculated time: 2760.0
CLOCK: [2023-11-15 Wed 15rr:26]--[2023-11-15 Wed 16:12] =>  0:46
calculated time: 58320.0
CLOCK: [2023-11-15 Wed 15:26]--[2023-11-15 Wed 16rr:12] =>  0:46
calculated time: 0.0
CLOCK: [2023-11-15 Wed 15rr:26]--[2023-11-15 Wed 16rr:12] =>  0:46
calculated time: 0.0
=======

======= results
(2760.0 58320.0 0.0 0.0)
======

What this shows is that an invalid end will cause the entry to be
ignored, but an invalid start will not.

We can totally claim that this is a feature, not a bug, if you would
like.  As this essentially treats
"CLOCK: [2023-11-15 Wed 15rr:26]--[2023-11-15 Wed 16:12] =>  0:46"
as
"CLOCK: [2023-11-15 Wed]--[2023-11-15 Wed 16:12] => 16:12"


If this is a feature then my previous patch is actually ready to merge.


  reply	other threads:[~2024-06-19 18:25 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-11 17:20 [PATCH] lisp/org-clock.el (org-clock-sum): Rewrite regex using rx Morgan Smith
2024-04-13 14:49 ` Ihor Radchenko
2024-04-13 16:08   ` Morgan Smith
2024-04-13 16:48     ` Ihor Radchenko
2024-04-13 17:46       ` Morgan Smith
2024-06-18  7:39         ` Ihor Radchenko
2024-06-19 14:57           ` Morgan Smith
2024-06-19 15:46             ` Ihor Radchenko
2024-06-19 18:24               ` Morgan Smith [this message]
2024-06-20  9:07                 ` Ihor Radchenko
2024-06-24 12:09                   ` Parse malformed clocklines (was: Re: [PATCH] lisp/org-clock.el (org-clock-sum): Rewrite regex using rx) Morgan Smith
2024-06-26  9:02                     ` Ihor Radchenko
2024-04-14 12:53       ` [PATCH] lisp/org-clock.el (org-clock-sum): Rewrite regex using rx 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=CH3PR84MB34240B172F1EA17489C9DD20C5CF2@CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM \
    --to=morgan.j.smith@outlook.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=sanelz@gmail.com \
    --cc=yantar92@posteo.net \
    /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).