Hello all,

I'm looking for some advice.  I do most (if not all) of my coding within
org, using src blocks which are tangled to create the actual code to
run.  Although I usually edit the code from within the org file, using
org-edit-special, I sometimes, when debugging, edit the tangled code
file directly.  If I do this, it's very convenient to detangle that
source file to get the original src blocks updated.  Very nice indeed.

However, if I have, as an example, a code block like this which has a
:var variable to be incorporated into the tangled code:

--8<---------------cut here---------------start------------->8---
#+name: init
#+begin_src julia :var version=(org-sbe tomlversion)
  lastchange = "[2024-02-16 12:54+0000]"
  function __init__()
      println("# My Package v$version, last change $lastchange")
  end
#+end_src
--8<---------------cut here---------------end--------------->8---

this gets tangled to something like this:

--8<---------------cut here---------------start------------->8---
# [[file:../code.org::init][init]]
version = "0.2024.211"
lastchange = "[2024-02-16 12:54+0000]"
function __init__()
    println("# My Package v$version, last change $lastchange")
end
# init ends here
--8<---------------cut here---------------end--------------->8---

When I detangle, the original src block now has that version line in the
src block.  So next time I tangle, I get another version line added, ad
infinitum if I keep on tangling and detangling.

Can anybody suggest a workaround that allows me to incorporate a :var
data field in a src block but still allow to tangling/detangling to work
as it should?  I cannot think of any way and can obviously live with it
(I just have to remember to delete the spurious version lines
periodically...).

If there is no way, a feature request might be to have some way to
indicate blocks that should not be detangled?  Alternatively, a hash of
some sort on the tangled file blocks that allow detangling to easily
identify those blocks that have changed and need updating in the
original src block?  The latter might (? maybe not) make detangling a
lot faster as well... but both options are beyond my elisp-foo so cannot
implement these myself unfortunately.

Thank you,
eric

-- 
: Eric S Fraga, with org release_9.6.13-1003-g872c1b in Emacs 30.0.50

Reply via email to