From: John Kitchin <jkitchin@andrew.cmu.edu>
To: Cody Goodman <codygman.consulting@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: How do you get the LOGBOOK information from the current heading at point?
Date: Sun, 05 Aug 2018 15:41:42 -0700 [thread overview]
Message-ID: <m2wot4saft.fsf@andrew.cmu.edu> (raw)
In-Reply-To: <CADq_+R14asL4A0P6z2FJq_g5Lb85W0PqvUDF8Q6nvZ_zOZnBvA@mail.gmail.com>
I think something like this is what you are looking for:
#+BEGIN_SRC emacs-lisp
(defun get-clock-lines ()
"Return org-element representations of clock lines in a logbook drawer."
(interactive)
(save-excursion
(goto-char (org-log-beginning))
(let ((logbook (org-element-at-point))
(clock-entries '())
(current-element))
(goto-char (org-element-property :contents-begin logbook))
(setq current-element (org-element-at-point))
(while (eq 'clock (car current-element))
(push current-element clock-entries)
(forward-line)
(setq current-element (org-element-at-point)))
(reverse clock-entries))))
(get-clock-lines)
#+END_SRC
Cody Goodman <codygman.consulting@gmail.com> writes:
> Given a TODO that looks like this:
>
> *** DONE put into spacemacs file
> CLOSED: [2018-08-04 Sat 21:18]
> :LOGBOOK:
> CLOCK: [2018-08-04 Sat 21:16]--[2018-08-04 Sat 12:18] => 0:02
> :END:
>
> What function will get me the parts in CLOCK: [2018-08-04 Sat
> 21:16]--[2018-08-04 Sat 12:18] => 0:02, preferably in plist format like
> the closed timestamp org-element-at-point gives back of:
>
> (timestamp (:type inactive :raw-value "[2018-08-04 Sat 21:18]" :year-start
> 2018 :month-start 8 :day-start 4 :hour-start 21 :minute-start 18 :year-end
> 2018 :month-end 8 :day-end 4 :hour-end 21 :minute-end 18 :begin 46 :end 68
> :post-blank 0)
>
> Note org-element-at-point doesn't give back logbook information:
>
> (headline (:raw-value "put into spacemacs file" :begin 1 :end 157
> :pre-blank 0 :contents-begin 34 :contents-end 157 :level 3 :priority nil
> :tags nil :todo-keyword #("DONE" 0 4 (fontified t face org-done))
> :todo-type done :post-blank 0 :footnote-section-p nil :archivedp nil
> :commentedp nil :post-affiliated 1 :closed (timestamp (:type inactive
> :raw-value "[2018-08-04 Sat 21:18]" :year-start 2018 :month-start 8
> :day-start 4 :hour-start 21 :minute-start 18 :year-end 2018 :month-end 8
> :day-end 4 :hour-end 21 :minute-end 18 :begin 46 :end 68 :post-blank 0))
> :title "put into spacemacs file"))
>
> Thanks,
>
> Cody
--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu
next prev parent reply other threads:[~2018-08-05 22:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-05 16:48 How do you get the LOGBOOK information from the current heading at point? Cody Goodman
2018-08-05 22:41 ` John Kitchin [this message]
2018-08-06 2:56 ` Cody Goodman
2018-08-06 3:10 ` John Kitchin
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=m2wot4saft.fsf@andrew.cmu.edu \
--to=jkitchin@andrew.cmu.edu \
--cc=codygman.consulting@gmail.com \
--cc=emacs-orgmode@gnu.org \
/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).