emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [babel] Commenting out src blocks for tangling


From: Charles Berry
Subject: Re: [O] [babel] Commenting out src blocks for tangling
Date: Sun, 3 Mar 2013 03:44:07 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Bastien <bzg <at> altern.org> writes:

> 
> Hi Rainer,
> 
> Rainer M Krug <r.m.krug <at> gmail.com> writes:
> 
> > Follow up: would it be possible to have the same mechanism for tangling,
i.e. a tag :notangle:?
> > functioning would be equivalent to property tangle: no but more visible and
consistent with the
> > :noexport:? One could also define properties to be tangled and not tangled
for different scenarios?
> 
> One approach could be to use export filters here.

Why not use the new exporter, rather than org-babel-tangle?

Below, there is a minimal backend called R-src-blocks that only exports
src-blocks for language "R" and the headline titles as comments. 

R-src-blocks backend is just an illustration - I don't intend that anyone
actually use it.

I guess I am suggesting that tangling is just exporting code; with full access
to all the export machinery (like exclude_tags and backend specific options), it
might be better to head toward backends that yield code than to elaborate
org-babel-tangle.

Chuck


#+BEGIN_SRC emacs-lisp
  (require 'ox-ascii)
  (defun comment-headline (headline contents info)
    (concat "### * " (org-element-property :raw-value headline) "\n\n" 
contents))
  
  (org-export-define-backend R-src-blocks
   ((src-block . (lambda (src-block contents info)
                   (and (string= (org-element-property :language src-block) 
"R") 
                        (car (org-export-unravel-code src-block)))))
    (section . org-ascii-section)
    (headline . comment-headline)))
  
#+END_SRC



> 
> I'd rather let (or someone else) find out if this approach is
> easy enough before considering adding a new keyword like :notangle:.
> But if you (or someone else) come up with a patch implementing the
> :notangle: approach, of course we might consider it too.
> 
> Thanks,
> 







reply via email to

[Prev in Thread] Current Thread [Next in Thread]