emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] selective tangling?


From: Berry, Charles
Subject: Re: [O] selective tangling?
Date: Thu, 29 Nov 2018 16:44:10 +0000


> On Nov 29, 2018, at 5:10 AM, John Kitchin <address@hidden> wrote:
> 
> Are there any ways to selectively tangle blocks?
> 
> By that I mean suppose there are a dozen src blocks in a file, but I want to 
> selectively tangle only a few of them, selecting them by a tag, for example, 
> or some other property. These might have mixed languages, e.g. a config 
> files, a python script, and a makefile.
> 
> The use case here is I have an org document that I use to document a 
> simulation. The simulation has several config files, and a makefile, and 
> there is a python script that does analysis. I like to put all of these in 
> src blocks and then use a sh block to run the actual simulation command. I 
> usually put a :var a=(org-babel-tangle) header in the sh block, which makes 
> sure the files are tangled, and then runs the shell commands. But this 
> tangles all the files in the buffer, which is usually not what I want (there 
> are sometimes multiple simulations described in one file).  The blocks are 
> not always in one subtree, so it isn't a matter of just narrowing, and they 
> are mixed languages (text, make, python, etc.) and target files so I can't 
> just target one file.
> 
> The only mechanism for this i have come up with is to use 
> org-babel-map-src-blocks to run a check on each block to see if it matches my 
> tangle criteria and then run (org-babel-tangle t) on that block. This seems 
> to work fine, but I thought I would check if anyone else has a better 
> solution.
> 
> 

Use the :tangle header arg with your check function and its args:

        :tangle (my-tangle-selector ...)

HTH,

Chuck






reply via email to

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