Skip to content

Clarify Function Behavior: Root Node Transformation in org-ml-match-map Functions #58

Description

@eagerchatterjee

Docs state that -match functions apply to children of node. Since the root node is not a child of itself it does not get transformed when using org-ml-match-map functions for instance.

Often when working on subtrees, though I want to transform both the root node and its children subject to a match condition, so I am currently using a workaround along the lines below. However most likely there is a more elegant way to do this by using a proper wrapper or parameter which includes the root node in the processing:

(defun my--match-map-incl-root(node-type fun node)
  (->> (if (org-ml-is-type node-type node)
           (funcall fun node)
           node)
       (org-ml-match-map `(,node-type) fun)))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions