Next: org-element-parsed-keywords, Previous: org-element-map, Up: Tools [Index]
This function allows applying a function on elements or objects matching some type, and accumulating the resulting values, and can be used to find specific elements or objects within the parse tree.
This function can be used to collect data from an AST.
&optional
org-element-map
won’t enter recursively
Assume TREE is a variable containing an Org buffer parse tree.
#'identity
(org-element-map tree '(example-block src-block) #'identity)
org-element-property
member
It will return its beginning position:
(org-element-map tree 'headline (lambda (hl) (and (= (org-element-property :level hl) 1) (member "phone" (org-element-property :tags hl)) (org-element-property :begin hl))) nil t)
This example makes use of the NO-RECURSION optional argument.
org-element-map
will not recurse into any ‘plain-list’ types.
#'identity
function
(org-element-map tree 'plain-list #'identity nil nil 'plain-list)
even looking into captions. This example uses org-element-map
inside of itself to further examine the current object.
(org-element-map tree 'bold (lambda (b) (and (org-element-map b 'latex-snippet #'identity nil t) b)) nil nil nil t)
org-element-property
org-element-type
org-element-contents
first-child
(org-element-map (org-element-parse-buffer) 'paragraph (lambda (paragraph) (let ((parent (org-element-property :parent paragraph))) (and (eq (org-element-type parent) 'section) (let ((first-child (car (org-element-contents parent)))) (eq first-child paragraph)) ;; Return value. paragraph))))
The following snippet returns a non-nil value when the document contains a checked item.
(org-element-map (org-element-parse-buffer) 'item (lambda (item) (eq (org-element-property :checkbox item) 'on)) nil t)
Next: org-element-parsed-keywords, Previous: org-element-map, Up: Tools [Index]