all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* detangling with babel :var header entries
@ 2024-02-16 13:07 Fraga, Eric
  2024-02-17 16:18 ` Ihor Radchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Fraga, Eric @ 2024-02-16 13:07 UTC (permalink / raw)
  To: Emacs Org mode mailing list

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: detangling with babel :var header entries
  2024-02-16 13:07 detangling with babel :var header entries Fraga, Eric
@ 2024-02-17 16:18 ` Ihor Radchenko
  2024-02-19  9:57   ` Fraga, Eric
  0 siblings, 1 reply; 3+ messages in thread
From: Ihor Radchenko @ 2024-02-17 16:18 UTC (permalink / raw)
  To: Fraga, Eric; +Cc: Emacs Org mode mailing list

"Fraga, Eric" <e.fraga@ucl.ac.uk> writes:

> 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...).

I also have no idea. I'm afraid that detangling can only be used in
simple cases as it is implemented now.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: detangling with babel :var header entries
  2024-02-17 16:18 ` Ihor Radchenko
@ 2024-02-19  9:57   ` Fraga, Eric
  0 siblings, 0 replies; 3+ messages in thread
From: Fraga, Eric @ 2024-02-19  9:57 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Emacs Org mode mailing list

On Saturday, 17 Feb 2024 at 16:18, Ihor Radchenko wrote:
> I also have no idea. I'm afraid that detangling can only be used in
> simple cases as it is implemented now.

I had the feeling this would be the case.  No worries.  Thank you.

-- 
: Eric S Fraga, with org release_9.6.18-1158-g8e2ed4 in Emacs 30.0.50

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-02-19 10:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-16 13:07 detangling with babel :var header entries Fraga, Eric
2024-02-17 16:18 ` Ihor Radchenko
2024-02-19  9:57   ` Fraga, Eric

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.