[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How do you name your code blocks?
From: |
Rodrigo Morales |
Subject: |
Re: How do you name your code blocks? |
Date: |
Wed, 17 Feb 2021 15:31:18 -0500 |
User-agent: |
mu4e 1.4.14; emacs 27.1 |
Greg Minshall <minshall@umich.edu> writes:
> Right now, names of source blocks are global to the .org file, and i
> don't suspect that will (or should) change.
Yep, I understand that. I explained a workaround for using short names
for code blocks and avoid name conflicts in
[[https://lists.gnu.org/archive/html/emacs-orgmode/2021-02/msg00281.html][this
answer]].
Greg Minshall <minshall@umich.edu> writes:
> i apologize for bringing it up, but the one thing that jumps out at the
> programmer part of me is that the python blocks in your code don't
> "know" what main.txt actually contains when they are executed, as there
> is no dependency on the correct "create-file" source block. possibly,
> though, if you created some dummy :var (on the python "begin_src" lines)
> to express this dependency, it would help? or, maybe it doesn't really
> matter?
I understand your point. I am currently expressing that dependency by
putting a =#+CALL= statement with =:results silent= above the Python
code block. However, doing that doesn't really express a dependency
because I need to execute the =#+CALL= statement first and then the
Python code block. It would be nice if we could associate a code block
(B) to another code block (A) so that (B) is execute before (A) is
executed. I created
[[https://lists.gnu.org/archive/html/emacs-orgmode/2021-02/msg00245.html][this
thread]] in the mailing list asking this. One of the solutions mentioned
in that thread is to use the =:var= header argument which you mentioned
and works great.
>From now on, I will be using the ID of the current subtreeas the suffix
(not prefix) of code block names so that name conflicts doesn't occur
between different subtrees and will express dependency between code
blocks by using the =:var= header argument.
Perhaps, having a =:pre= header argument, just as the =:post= header
argument exist, would help expressing depdency between code blocks in a
clearer way. I consider the =:var= header argument a hacky way to
associate two code blocks.
--
Rodrigo Morales.