I recently came across a little-known (to me, anyway) feature of org mode,
thanks to this mailing list reply: conditional tangling. In the :tangle
argument, as
well as the standard values (yes
, no
or a filename string), you can also set it
dynamically, by specifying an elisp expression which evaluates to the
tangle setting.
This is quite useful together with tags. Here’s a function which sets the argument based on which tags are currently set in the file: