Skip to main content
1 of 2
Jesse
  • 267
  • 3
  • 10

Parsing an Orgmode file with org-element-parse-buffer

I am trying to get the ast of an orgmode file and it does not seem like the todo-keyword or todo-type keywords are being set properly.

I have the following orgmode file:

#+TITLE: Org Test File
#+AUTHOR: Jesse Millwood
#+TODO: TODO WAITING | DONE

* Some Time Stamps
  - An appointment: <2017-08-21 Mon>
  - Something done: [2017-08-21 Mon]
* List of things I need to get done
** TODO Parse an org file
** WAITING Look at the AST
** WAITING Verify the AST
   - And make sure the ast contains the right info

I am trying to get the ast by simply running

(setq org-ast (with-temp-buffer
        (insert-file-contents "~/Playground/elisp/orgfile.org")
        (org-element-parse-buffer)))

I then just print it out in the buffer to look at it and the ast looks good except the section that represents the TODO items.

The section that represents the first todo point is:

(headline (:raw-value "TODO Parse an org file"
                      :begin 207 :end 233
                      :pre-blank 0
                      :contents-begin nil
                      :contents-end nil
                      :level 2
                      :priority nil
                      :tags nil
                      :todo-keyword nil
                      :todo-type nil
                      :post-blank 0
                      :footnote-section-p nil
                      :archivedp nil
                      :commentedp nil
                      :post-affiliated 207
                      :title (#("TODO Parse an org file" 0 22 (:parent #2))) :parent #1))

I did make sure to run 'C-c C-c' on the '#+TODO' line at the top. So I figured the keywords in the the ast would be something other than nil. Am I missing something here?

Jesse
  • 267
  • 3
  • 10