Say I am using org-babel to tangle code blocks from an org document. I have several blocks with random code in them.
My goal is to dynamically tangle (or not) individual blocks following a condition, for example, contents of first line of block, text in above heading, tag in heading, etc.
More generally, I want to pass the same defun as an argument to :tangle in the header arguments of all code blocks, avoiding the use of heading or buffer properties. Similarly, I try to avoid setting the same identical form in all my code blocks. Instead, I try to define a default header argument to be set programatically, or similar in the example
* First :maybe:
#+begin_src emacs-lisp
;; First : not to be tangled
#+end_src
* Second :no:
#+begin_src emacs-lisp
;; Second : not to be tangled
;; This code doesn't do it but it should !!
(setq-local org-babel-default-header-args
(cons `(:tangle . ,(test))
(assq-delete-all :tangle org-babel-default-header-args)))
#+end_src
* Third :yes:
#+begin_src emacs-lisp
;; Third : this code is to be tangled
(defun test ()
(if (let ((mytags (org-get-tags-at (point) t)))
(or (member "yes" mytags)
(null mytags)))
(format "%s.el" (file-name-base
(buffer-file-name))) "no"))
#+end_src
So my question is, is it possible to assign a function to the :tangle (or :prologue) header arguments in org-babel code blocks without using properties or explicitly put the form in all code blocks ?