[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] (org-entry-get (point) "CLOCK") fails now
From: |
Nicolas Goaziou |
Subject: |
Re: [O] (org-entry-get (point) "CLOCK") fails now |
Date: |
Sun, 30 Aug 2015 20:59:38 +0200 |
Martin Kaffanke <address@hidden> writes:
> I have only one CLOCK property for my entry and I just want to extract
> the start time of that clock entry. I did after the get-entry:
>
> (let*
> (
> ....
> (clockentry (org-entry-get (point) "CLOCK"))
> (clockstart (apply 'encode-time (org-parse-time-string clockentry)))
> ....
> )
> .....
> )
>
>
> So maybe you just know how to rewrite this two lines?
Well, that's an usual pattern: search something using a lax regexp,
discard false positives with parser, and return a specific value:
(let ((clockstart
(org-with-wide-buffer
(org-back-to-heading t)
(let ((end (save-excursion (outline-next-heading)))
(re (concat "^[ \t]*" org-clock-string)))
(catch :found
(while (re-search-forward re end t)
(let ((element (org-element-at-point)))
(when (eq (org-element-type element) 'clock)
(throw :found
(org-timestamp--to-internal-time
(org-element-property :value element)))))))))))
...)
I should probably rename `org-timestamp--to-internal-time' to
`org-timestamp-to-internal-time' if it is useful out of org.el.
Regards,