3

I've been struggling with the basic org-element-parse-buffer (see here) usage. Specifically, how do I make it work? It's not interactive, so it has to be called from within an org-mode buffer, I'm guessing in a source code block. I try this solution:

#+begin_src emacs-lisp
(let ((parsetree (org-element-parse-buffer 'headline))) 
  (org-element-map parsetree 'headline 
                   (lambda (hl) (org-element-property :title hl)))) 
#+end_src 

#+RESULTS: 
| JANUARY | 2018-01-23T16:54:53 | 2018-01-23T19:37:21 | 2018-01-24T02:37:07 |

and get the results in a results table format. Good. But how do I get the whole buffer as an AST (one big nested list) as advertised?

#+begin_src emacs-lisp  
(org-element-parse-buffer)
#+end_src 

I get org-babel-insert-result: Wrong type argument: markerp, nil

I still have hope that some year I'll be productive with Emacs/org-mode....

0

The display of the results you are asking for hides nearly all the output information. The get the full lisp object to be shown use

:results code replace

For example

* Heading

** TODO write something
   SCHEDULED: <2018-01-25 Thu>

** DONE plan something
   CLOSED: [2018-01-24 Wed 13:49] DEADLINE: <2018-01-25 Thu> SCHEDULED: <2018-01-23 Tue>
   :LOGBOOK:
   - CLOSING NOTE [2018-01-24 Wed 13:49]
   :END:

* Another heading

** TODO plan something else
   DEADLINE: <2018-01-31 Wed>

** TODO write something else
   SCHEDULED: <2018-02-14 Wed>

* Code

#+begin_src emacs-lisp :results code replace
(org-element-parse-buffer)
#+end_src

#+RESULTS:

gives a results block too big to post here, but which starts

#+BEGIN_SRC emacs-lisp
(org-data nil
      (headline
       (:raw-value "Heading" :begin 1 :end 244 :pre-blank 1 :contents-begin 12 :contents-end 243 :level 1 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 1 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 1 :title
               (#("Heading" 0 7
              (:parent #1)))
               :parent #0)
       (headline
        (:raw-value "write something" :begin 12 :end 68 :pre-blank 0 :contents-begin 36 :contents-end 67 :level 2 :priority nil :tags nil :todo-keyword
            #("TODO" 0 4
              (fontified t face org-todo))
            :todo-type todo :post-blank 1 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 12 :scheduled
            (timestamp
             (:type active :raw-value "<2018-01-25 Thu>" :year-start 2018 :month-start 1 :day-start 25 :hour-start nil :minute-start nil :year-end 2018 :month-end 1 :day-end 25 :hour-end nil :minute-end nil :begin 50 :end 66 :post-blank 0))
            :title
            (#("write something" 0 15
               (:parent #2)))
            :parent #1)
        (section
         (:begin 36 :end 68 :contents-begin 36 :contents-end 67 :post-blank 1 :post-affiliated 36 :parent #2)
         (planning
          (:closed nil :deadline nil :scheduled
               (timestamp
            (:type active :raw-value "<2018-01-25 Thu>" :year-start 2018 :month-start 1 :day-start 25 :hour-start nil :minute-start nil :year-end 2018 :month-end 1 :day-end 25 :hour-end nil :minute-end nil :begin 50 :end 66 :post-blank 0))
               :begin 36 :end 67 :post-blank 0 :post-affiliated 36 :parent #3))))

Here you see all the heading structure and the information at timestamps, TODO states etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.