Questions tagged [org-babel]

feature of Org mode that handles source code for multiple languages. It can execute source code from within Org mode documents, making it convenient for producing literate programming documents and managing reproducible research. Note that Org-babel is now incorporated into Org-mode as 'working with source code' and no longer a separate extension.

Filter by
Sorted by
Tagged with
0
votes
1answer
30 views

What to put into 'init.el' vs 'config.el' in Org-mode?

I'm using Org-mode to configure Emacs in a file 'config.el', which is really unstructured meanwhile. On the other hand, lots of configurations (for exemple the configs made with the menu) are in Emacs'...
0
votes
1answer
21 views

Trouble rendering lilypond source block in org-babel

I am relatively new to org mode and, as someone who enjoys writing about music, i decided to try org-babel-lilypond. I use MacOSx Monterey. I have lilypond installed via Macports, as was recommended ...
0
votes
1answer
31 views

org-babel shell session not starting

I'm trying to write some shell code blocks in a session, but it seems no session has been started, and all the code blocks are run independently. Here is a simple example: * org-babel :PROPERTIES: :...
0
votes
1answer
25 views

Org Babel ignores `org-plantuml-executable-args`

I cannot make plantuml set the UTF-8 charset, I've set '(org-plantuml-executable-args '("-headless -charset UTF-8")) in the init.el, but when I check in the message buffer the command ...
4
votes
1answer
141 views

Is there indentation in org src blocks?

I'm going kinda crazy trying to understand what's going on here... Asked this question on the r/emacs subreddit so apologies if any of you are seeing this again. Do org blocks allow TAB indentation ...
0
votes
1answer
25 views

How to evaluate Python code blocks with pipenv instead of system environment?

I'm trying to use org-mode as an alternative to Jupyter. I'm able to evaluate code blocks with system environment by doing C-c C-c on blocks, but I don't know how to evaluate it through pipenv ...
0
votes
1answer
14 views

Skeleton for org source blocks causing issues

I've tried to setup a skeleton to speed up entering org source blocks (define-skeleton skel-org-block "Insert an org block, querying for type." "Type: " "#+begin_" ...
0
votes
1answer
12 views

conf "language" in org-babel

#+NAME: certfile #+begin_src emacs-lisp (cond ((eq system-type 'gnu/linux) "/etc/ssl/cert.pem") ((eq system-type 'darwin) "~/Mail/certificates/root-certificates.pem")) #+end_src ...
0
votes
0answers
19 views

org-babel how to run d3.js code in code block

Anyone can help direct me about how to run d3.js code to draw graph in org-babel code block? d3.js is a javascript library but it need to output svg to html body. I saw markdown language support it ...
0
votes
0answers
14 views

org-babel named block for static string(constant)

I'm trying to extract a constant that is used by several blocks in my org-babel file. #+name: myconst 6522332123432 Unfortunately it somehow adds a new line symbol to that string which breaks my ...
1
vote
0answers
52 views

How can I generate images from LaTeX without using ghostscript/ImageMagick?

My question here is about generating images from LaTeX source blocks in .org files The following source block (edited down to a simple use case) works fine and produces a .pdf, but this does not ...
0
votes
0answers
13 views

Using sage-shell-mode, ob-sagemath with conda-env

A while back I installed the SageMath package via Anaconda, meaning I have a separate environment that I have to activate before using sage. After getting used to org-mode and org-babel source blocks, ...
1
vote
1answer
24 views

clean weird characters from org source shell

When I run a shell command in Org I sometimes get back weird control characters: #+begin_src sh :results output :session test guix pull #+end_src #+RESULTS: : : Updating channel 'guix' from Git ...
0
votes
0answers
30 views

How to setup the structure of org mode with a known html file?

I want to create an Org file, then export to HTML such that the final site looks something like this: https://html5up.net/dimension. If you go to their index.html file, their structure in HTML looks ...
1
vote
1answer
25 views

org-babel source block language specifier issue

I've installed j-mode and it works. But in an org-babel code block I have a strange issue. Spelling like begin_src J (capital J) allows me to evaluate the block, but has no syntax highlighting: #+...
1
vote
1answer
34 views

Open org-src code edit buffer automatically upon starting edit

Editing src blocks directly in org file is nice but you cannot benefit from all minor modes that would be enabled in dedicated code edit buffer, more then that for a big babel file the performance ...
0
votes
2answers
52 views

Org Tangle if file does not exist

I've been trying to work out if it's possible to tangle a file if it's not existent on the system. I came across Can Org Babel conditionally tangle code blocks based on system-type? which gave me a ...
0
votes
0answers
29 views

Why is the org-babel cache not populated on export

This whole question is an org-mode document that can be pasted into your local Emacs for a type-along question. First evaluate the below code block to enable caching of org-babel results, include ...
0
votes
1answer
53 views

(Org) TikZ for exporting both LaTeX and HTML/MathJax

I'm exporting an Org Mode project both to LaTeX and to HTML (with MatJax). Now I need to add a TikZ picture which can be exported nativelly on LaTeX and must be rendered in svg for HTML. Writing the ...
1
vote
0answers
74 views

Direct inclusion of resulting link file during export in Org mode

I'm preparing static html site with interactive Javascript components visualizing my research data in Org mode. Javascript components are returned by the Org Babel Python script in form of HTML string ...
0
votes
0answers
11 views

org-babel: How do I make tex source blocks show images of the pages produced as their output?

I am thinking of sth like https://xenodium.com/previewing-swiftui-layouts-in-emacs-revisited/ , but for tex source blocks:
0
votes
0answers
29 views

Inline image not showing

I am trying to display images inline in emacs, but for however reason the behaviour is not stable within the same document. Here is the problem: The below chunk works as expected: However, in the ...
1
vote
0answers
29 views

How to output orgmode julia DataFrame as orgtbl?

In the following link, we see that we can use a table package in Python to return in orgtbl format. #+begin_src python :results value raw :output :return tabulate(df, headers=df.columns, tablefmt='...
1
vote
0answers
24 views

org-babel not sourcing remote .bashrc when using tramp

When editing a remote file with tramp, I want org-babel source blocks to source the remote machine's .bashrc. I found this workaround that does what I want: #+BEGIN_SRC bash :preamble ". ~/....
0
votes
0answers
26 views

How to capture the column sort in Org-mode inside a formula?

Let's say, I have a following table: |-------+---------| | NAME | VALUE | |---------+-------| | DAVID | 3.83 | | JULIA | 0.89 | | ALICE | 0.59 | |-------+---------| | SUM | ...
0
votes
0answers
11 views

How to change the size of the popup window from org-edit-special?

When I type C-c ' on an org-babel source block, a horizontal split buffer appears where I can edit the source code. If I want to resize this pane, I can do it with window resizing commands or just ...
1
vote
2answers
64 views

Using yaml src block in following python src block

I am trying to use multiple src blocks to explain a yaml config file usage in python. Below is my org file, #+name: config.yaml #+begin_src yaml name: john why: check # below is a dict example # see ...
2
votes
1answer
47 views

Setting :prologue in header args as elisp has "scope" problems when running (org-sbe), "wrong" `org-element-context`?

To cut down on some repetitive boilerplate, I'm attempting to make my header arguments more "dynamic", but I have run into what I believe is a "scope" issue, that I cannot yet get ...
0
votes
0answers
38 views

How to add ATTR_LATEX to all babel blocks efficiently?

I recently figured out how to make my babel codes to have a border background when export as pdf. I did it by adding the following before the BEGIN_SRC: #+ATTR_LATEX: :options frame=single This ...
0
votes
1answer
10 views

org-babel pass bibtex sample to python code block

Is it possible to pass a sample bibtex document into a python source code block to be evaluated? :PROPERTIES: :ID: d7154890-6d45-44c0-9b0c-9c0f6533c11e :header-args: :session bibtex :END: #+...
0
votes
0answers
93 views

How to use PlantUML Server with Org mode?

plantuml-mode supports execution using a PlantUML server, with (setq plantuml-default-exec-mode 'server). I can set the server location with (setq plantuml-server-url "https://myserver.plantuml....
2
votes
1answer
40 views

How to start a background process from Org?

The following code waits until process is finished, which is unexpected #+begin_src shell perl -wE 'sleep(3)' & disown #+end_src The work-around for that is to close STDIN and STDOUT explicitly #...
1
vote
0answers
14 views

Why does babel insert whitespace after parentheses in :var values?

I am running GNU Emacs 27.2 (build 1, x86_64-w64-mingw32) of 2021-03-26 on Windows 10 with org-mode 8.3.4-102-gebe7aa-elpa. When I #+CALL a code block passing in a var with a parenthesis, a space ...
1
vote
0answers
19 views

Supplying stdin input as a source block for CPP code as in shell script

I am trying to supply code with stdin via a named example block using org-babel, as below (with help): #+NAME: read-to-stdin #+begin_example Hello, World! #+end_example The shell block #+name: shell-...
1
vote
1answer
17 views

How to list all the code blocks in the current buffer with no #+NAME?

Let's say I have a buffer with some code blocks, but I want to know the location of those code blocks that doesn't have #+NAME set.
0
votes
1answer
30 views

Tangle current src block and process it in another

How can I run the test src block without leaving the code src block? Currently I must leave code, goto test, hit C-c C-c , go back to continue work on code #+NAME: code #+BEGIN_SRC sh :tangle /tmp/...
0
votes
0answers
25 views

How to run pytest in org mode babel?

#+begin_src python :results output import pytest def test_func(): assert 1 == 1 pytest.main() #+end Should pass, though the test isn't even collected ============================= test ...
0
votes
0answers
43 views

How to disable babel block indentation?

Is it possible to disable the indentation of new babel source blocks? I played with electric-indent-local-mode and org-src-preserve-indentation without success. Current output: * aa ** bb #+...
0
votes
2answers
38 views

Pandas output in Scimax

In Scimax, when I evaluate a pandas DataFrame (DF) in an Ipython block, #+BEGIN_SRC ipython data = [ ['a', 'foo', 'bar'], ['FOO', 'and', 'BAR'] ] pd.DataFrame(data) #+END_SRC It produces both ...
1
vote
1answer
40 views

How to execute parameterized src block via elisp and get result?

I have a src block to get a value from some table: #+NAME: ref #+BEGIN_SRC emacs-lisp :var name="" table=main (let ((key (if (symbolp name) (symbol-name name) name))) (nth 2 (assoc key ...
2
votes
1answer
126 views

org-mode spreadsheet formula, can one use the result of org-babel block?

I'm trying to find a way to use the output of existing org-babel block in org-mode spreadsheet formulae without rewriting them in emacs-lisp. Is it possible? TBLFM line is pseudo code, it is ...
0
votes
1answer
53 views

org-babel multi-line header var

I'm trying to find a way how to conveniently edit(and pass) multi-line arguments to org-babel block. In the example below, ${name} variable is pretty convenient to edit as inline variable but for ${...
2
votes
0answers
102 views

Jupyter-like setup with org-babel in spacemacs

I've been trying to switch my data-analysis workflow from Jupyter lab/notebook to org-mode + org-babel for quite a while. I'm looking for an emacs setup that will provide all the functionalities of ...
1
vote
0answers
40 views

Set org source block name label as variable

Does someone know if it is possible to set the #+NAME label for source blocks as a variable? E.g.; I would like to be able to set the label with elisp, something like: #+NAME: (concat "name_"...
0
votes
0answers
34 views

Include LaTeX code blocks from another file to generate a "main" file (similar to using \input{} in .tex)

I have a .org file (say exercises.org) in which I put LaTeX exercises in the form of code blocks. The file looks something like this: #+NAME: ex1 #+BEGIN_EXPORT latex Compute $2\cdot 2$. #+END_EXPORT ...
3
votes
1answer
64 views

prevent eval of a single src block

How do I ensure that only the second block never evaluates, while still allowing the first block to be evaluated normally? #+begin_src shell echo "hi" #+end_src #+begin_src python print(&...
0
votes
0answers
27 views

Execute org mode code block without escape codes

When I run a bash code block I get a response which contains a lot of escape codes/sequences, which makes the results output less readable. Example below: How can execute the code block, without the ...
0
votes
0answers
25 views

Babel source block export format customization

I have this #+begin_src haskell :results silent :exports code :{ maximum'' :: (Ord a) => [a] -> a maximum'' = foldl1 (\x acc -> if x > acc then x else acc) :} #+end_src but on export ...
1
vote
1answer
87 views

How to pass org-babel code block as variable to another code block?

I would like to pass the code from code block test_python to script. I do not want test_python to be evaluated, but simply to have the source code inserted into script when I evaluate script. The goal ...
1
vote
1answer
33 views

emacs org mode define a function in src block and call it

is there a method/package to use the following syntax to define and call a function? #+NAME: retX #+BEGIN_SRC python :var x=5 def retX (x): return x #+END_SRC ... Some text later... #+begin_src ...

1
2 3 4 5
14