From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Martin Kaffanke <martin@kaffanke.at>
Cc: emacs-orgmode@gnu.org
Subject: Re: (org-entry-get (point) "CLOCK") fails now
Date: Sun, 30 Aug 2015 20:59:38 +0200 [thread overview]
Message-ID: <87io7w38md.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <87h9ngdbyv.fsf@kaffanke.at> (Martin Kaffanke's message of "Sun, 30 Aug 2015 17:37:12 +0200")
Martin Kaffanke <martin@kaffanke.at> 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,
prev parent reply other threads:[~2015-08-30 18:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-30 11:41 (org-entry-get (point) "CLOCK") fails now Martin Kaffanke
2015-08-30 12:25 ` Nicolas Goaziou
2015-08-30 13:06 ` Marcin Borkowski
2015-08-30 15:21 ` Nicolas Goaziou
2015-08-30 20:18 ` Marcin Borkowski
2015-08-30 15:37 ` Martin Kaffanke
2015-08-30 18:59 ` Nicolas Goaziou [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87io7w38md.fsf@nicolasgoaziou.fr \
--to=mail@nicolasgoaziou.fr \
--cc=emacs-orgmode@gnu.org \
--cc=martin@kaffanke.at \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.