[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] lisp/org-clock.el (org-clock-sum): Rewrite regex using rx
From: |
Ihor Radchenko |
Subject: |
Re: [PATCH] lisp/org-clock.el (org-clock-sum): Rewrite regex using rx |
Date: |
Sat, 13 Apr 2024 14:49:21 +0000 |
Morgan Smith <Morgan.J.Smith@outlook.com> writes:
> See two attached patches. All tests pass on my computer.
>
> Every once in a while I feel obligated to go back to org-clock-sum to
> try and optimize it. I have a file with 8 clocktables in it and it
> takes forever to update. This time I decided instead of trying to
> optimize, I'm just going to try and understand.
>
> The regex has been altered slightly.
>
> 1. Instead of using "[ \t]", I decided to use [[:blank:]]. No real
> reason. I just think it's easier to read and maybe slightly more
> correct?
>
> 2. For the timestamps, instead of ".*?" (using a non-greedy ".*") I
> decided to use "[^]]*" (accept everything except "]"). I did this simply
> because I'm not used to using non-greedy regex's. Maybe this way
> performs better? I didn't test that.
>
> 3. I used the variable `org-outline-regexp' but that doesn't actually
> change the regex.
Thanks for the patch!
I think that a better approach would be re-using the parser constant
`org-element-clock-line-re'.
> * testing/lisp/test-org-clock.el (test-org-clock/clocktable/insert):
> Add a clock time that does not include timestamps.
> ...
> -
> - (goto-line 2)
> + (insert (org-test-clock-create-clock ". 1:00" ". 2:00")
> + "CLOCK: => 1:00\n")
This is not a valid clock format. Matching such lines is a bug.
See https://list.orgmode.org/orgmode/87wpkkhafc.fsf@saiph.selenimh/
--
Ihor Radchenko // yantar92,
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>