I'd like to extract from an org file a top-level headline and the plain text just under it. I'm new to elisp, but i've tried a bunch of things, and haven't made much progress. I'd really appreciate some pointers.
Suppose we've got the file:
* Test Some descriptive text ** TODO Test Org mode ** TODO Keep testing
I'd like to include just the top headline and the descriptive text just under it in another file. (Not using #+INCLUDE searches, which for some reason I also can't get to work). So I'm trying to extract just a piece of this buffer's AST.
I'm trying to use
org-map-entries because it will be able to look through all my agenda files, each of which relates to a different project.
org-map-entries just not allow me to access children of headlines? (I think the text description is in a
section that's a child of the first headline. Right?)
Assuming that's true, I've tried to
org-element-parse-buffer of the whole buffer when I find a top-level headline. With the whole AST, I think I should be able to get the text just under the top-level headline. But I'm stumped.
(defun get-headline-with-text () (let ((entry (org-element-at-point))) (if (eq 1 (org-element-property :level entry)) (let ((hdl (nth 2 (org-element-parse-buffer)))) (list (org-element-property :raw-value hdl) (org-element-property :value (car (org-element-contents hdl)))) ) nil) ) ) (org-map-entries '(get-headline-with-text) t nil)