* org-element-map no-recursion argument?
@ 2014-01-30 2:26 James Harkins
2014-01-30 10:39 ` Nicolas Goaziou
0 siblings, 1 reply; 2+ messages in thread
From: James Harkins @ 2014-01-30 2:26 UTC (permalink / raw)
To: orgmode
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.
hjh
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: org-element-map no-recursion argument?
2014-01-30 2:26 org-element-map no-recursion argument? James Harkins
@ 2014-01-30 10:39 ` Nicolas Goaziou
0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Goaziou @ 2014-01-30 10:39 UTC (permalink / raw)
To: James Harkins; +Cc: orgmode
Hello,
James Harkins <jamshark70@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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-01-30 10:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-30 2:26 org-element-map no-recursion argument? James Harkins
2014-01-30 10:39 ` Nicolas Goaziou
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.