#+BEGIN_SRC ipython :tangle (if (eq tangle-tag 'one) "one.py" "no")
print('hello')
#+END_SRC
#+BEGIN_SRC text :tangle (if (eq tangle-tag 'one) "one.dat" "no")
print('hello')
#+END_SRC
#+BEGIN_SRC ipython :tangle (if (eq tangle-tag 'two) "two.py" "no")
print('hello2')
#+END_SRC
#+BEGIN_SRC makefile :tangle (if (eq tangle-tag 'two) "Makefile" "no")
build:
python two.py
#+END_SRC
Now only tangle things with a 'two
#+BEGIN_SRC emacs-lisp
(let ((tangle-tag 'two))
(org-babel-tangle))
#+END_SRC
I didn't see a way to avoid having an intermediate variable to specify what to tangle. This should have a check on if tangle-tag is bound to avoid an error with regular tangle. Maybe it could be cleaned up by a function as you describe, e.g. (selective-tangle 'two filename).
Another way I tried is this:
** example two
#+BEGIN_SRC ipython :tangle "one.py" :one
print('hello')
#+END_SRC
#+BEGIN_SRC text :tangle "one.dat" :one
print('hello')
#+END_SRC
#+BEGIN_SRC ipython :tangle "two.py" :two
print('hello2')
#+END_SRC
#+BEGIN_SRC makefile :tangle "Makefile" :two
build:
python two.py
#+END_SRC
#+BEGIN_SRC emacs-lisp
(org-babel-map-src-blocks (buffer-file-name)
(let ((ha (read (format "(%s)" (substring-no-properties header-args)))))
(when (memq :two ha)
(org-babel-tangle '(4)))))
#+END_SRC
#+RESULTS:
: 5235
I don't have strong feelings yet which way is better.
John
-----------------------------------
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803