emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Fraga, Eric" <e.fraga@ucl.ac.uk>
To: Emacs Org mode mailing list <emacs-orgmode@gnu.org>
Subject: detangling with babel :var header entries
Date: Fri, 16 Feb 2024 13:07:59 +0000	[thread overview]
Message-ID: <87bk8gk15d.fsf@ucl.ac.uk> (raw)

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	other threads:[~2024-02-16 13:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-16 13:07 Fraga, Eric [this message]
2024-02-17 16:18 ` detangling with babel :var header entries Ihor Radchenko
2024-02-19  9:57   ` Fraga, Eric

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=87bk8gk15d.fsf@ucl.ac.uk \
    --to=e.fraga@ucl.ac.uk \
    --cc=emacs-orgmode@gnu.org \
    /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).