From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: How do you get the LOGBOOK information from the current heading at point? Date: Sun, 05 Aug 2018 15:41:42 -0700 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:42561) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmRik-00068U-0t for emacs-orgmode@gnu.org; Sun, 05 Aug 2018 18:41:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fmRie-000873-FB for emacs-orgmode@gnu.org; Sun, 05 Aug 2018 18:41:54 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]:35936) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fmRie-00085Y-7s for emacs-orgmode@gnu.org; Sun, 05 Aug 2018 18:41:48 -0400 Received: by mail-pf1-x436.google.com with SMTP id b11-v6so5880364pfo.3 for ; Sun, 05 Aug 2018 15:41:47 -0700 (PDT) In-reply-to: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Cody Goodman Cc: emacs-orgmode@gnu.org 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 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