emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Berry, Charles" <ccberry@ucsd.edu>
To: John Kitchin <jkitchin@andrew.cmu.edu>
Cc: org-mode-email <emacs-orgmode@gnu.org>
Subject: Re: selective tangling?
Date: Thu, 29 Nov 2018 16:44:10 +0000	[thread overview]
Message-ID: <D3958E6C-028C-4813-8064-50E4386D6F7F@ucsd.edu> (raw)
In-Reply-To: <CAJ51ETqd6z49kpV=_+QzA5hipbBbuW96ge9ZArXTez3hFjMWAw@mail.gmail.com>



> On Nov 29, 2018, at 5:10 AM, John Kitchin <jkitchin@andrew.cmu.edu> 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	other threads:[~2018-11-29 16:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-29 13:10 selective tangling? John Kitchin
2018-11-29 16:44 ` Berry, Charles [this message]
2018-11-29 17:18   ` John Kitchin
2018-11-29 20:32 ` Eric S Fraga

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D3958E6C-028C-4813-8064-50E4386D6F7F@ucsd.edu \
    --to=ccberry@ucsd.edu \
    --cc=emacs-orgmode@gnu.org \
    --cc=jkitchin@andrew.cmu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).