From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: org-element-map no-recursion argument? Date: Thu, 30 Jan 2014 11:39:00 +0100 Message-ID: <87r47pda9n.fsf@gmail.com> References: <4e38543e-3fe5-47f2-a166-abe4a7a8d98a@dewdrop-world.net> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49357) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8p1E-00020C-KA for emacs-orgmode@gnu.org; Thu, 30 Jan 2014 05:38:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W8p16-00041r-6H for emacs-orgmode@gnu.org; Thu, 30 Jan 2014 05:38:48 -0500 Received: from mail-wg0-x22d.google.com ([2a00:1450:400c:c00::22d]:63286) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8p15-00041U-W0 for emacs-orgmode@gnu.org; Thu, 30 Jan 2014 05:38:40 -0500 Received: by mail-wg0-f45.google.com with SMTP id n12so5755291wgh.0 for ; Thu, 30 Jan 2014 02:38:38 -0800 (PST) In-Reply-To: <4e38543e-3fe5-47f2-a166-abe4a7a8d98a@dewdrop-world.net> (James Harkins's message of "Thu, 30 Jan 2014 10:26:14 +0800") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: James Harkins Cc: orgmode Hello, James Harkins 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