Hello, James Harkins <jamshar...@gmail.com> writes:
> I've written some emacs-lisp using org-element-map to iterate over > source code blocks in an org buffer and insert them into another > buffer, including a listing number and caption (so it's different from > tangling). > > I was just trying to tweak it to ignore source code blocks in > a comment section. > > More specifically -- I had moved some material into a "Removed" > subtree (with a tag "noexport"). This subtree contains some source > blocks, but I want my function to ignore these. > > I thought I could wrap the entire "Removed" section in > #+begin/end_comment, and then tell org-element-map to skip comment > blocks for recursion. > > (org-element-map tree 'src-block (lambda (element) ...) > nil nil 'comment) > > But this has no effect. I guess the src-block filter erases the > distinction between "live" and commented sections. > > I can work around it by commenting out the captions, but it would be > nicer to have an entire "off-limits" section of the document. This is a reasonable request, indeed. One (backward compatible) solution could be to extend possible values for NO-RECURSION argument, and allow functions on one argument (the current element) in addition to symbols. When the NO-RECURSION function returns a non-nil value for a given element, the main function from `org-element-map' is applied to the element, but not to its contents. What do you think? Regards, -- Nicolas Goaziou