Next: Check for CID, Up: Update Utility Commands
This function looks for an Org file in the present working directory, and if it
finds one returns a parsed tree using org-element-parse-buffer
. It returns
‘nil’ if there is no Org file or if the found file is not in org-mode
.
(defun get-parsed-org-tree (&optional org-dir) "This function takes an optional directory name, changes to that directory if given, otherwise uses the pwd, and finds an Org file and returns its parsed tree, or nil if none found." (when org-dir (cd (file-name-as-directory org-dir))) (let ((buf (car-safe (find-file-noselect "*.org" nil nil t)))) (if buf (with-current-buffer buf (org-element-parse-buffer)) nil)))