3

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?

5

Your code is missing one crucial thing, it's not the parsing step that applies keywords locally, it's enabling org-mode that does. Considering that you're in a temporary buffer, you'll have to do this yourself for parsing to return the expected result:

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

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.