all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to associate a code block to another one so that it is executed beforehand?
@ 2021-02-15 20:54 Rodrigo Morales
  2021-02-15 21:52 ` John Kitchin
  0 siblings, 1 reply; 3+ messages in thread
From: Rodrigo Morales @ 2021-02-15 20:54 UTC (permalink / raw)
  To: emacs-orgmode


Is it possible to associate a code block (A) to another code block (B)
so that when (A) is executed (B) is executed beforehand? I'm asking this
because I have a bash code block (B) that creates a file that is then
processed by a python code block (A) so before executing (A) block, the
file needs to be created by (B).

I managed to accomplish this only with shell code blocks by creating a
function that gets a code block as an string but now that code blocks
have different languages (bash and python) I can't use this same
approach. Recall that ":prologue" inserts an string at the beginning of
the code block (see minimal working example of this idea below.)

#+NAME: create-file
#+begin_src bash :results silent
cat << EOF > main.txt
foo
bar
EOF
#+end_src

#+HEADER: :prologue (org-babel-get-block-as-string "create-file")
#+begin_src bash
cat main.txt
#+end_src

#+RESULTS:
#+begin_example
foo
bar
#+end_example

-- 
Rodrigo Morales.
IRC: rdrg109 (freenode)


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

end of thread, other threads:[~2021-02-16  2:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-15 20:54 How to associate a code block to another one so that it is executed beforehand? Rodrigo Morales
2021-02-15 21:52 ` John Kitchin
2021-02-16  2:39   ` Rodrigo Morales

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.