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
2 votes
1 answer
383 views

Org-babel python with session breaks output

If I run the following code block: #+BEGIN_SRC python :results output print(" /|") print(" / |") print(" / |") print("/___|") #+END_SRC I get the result as expected: #+RESULTS: : /|...
0 votes
1 answer
170 views

code execution issue in org mode on windows

I issue emacs -Q yes.org where yes.org is (org-babel-do-load-languages 'org-babel-load-languages '((python . t))) #+begin_src python :results output print(2) #+end_src I first evaluate the loading ...
0 votes
1 answer
13 views

Can I redefine org-babel-execute for specific org-babel blocks?

When I C-c C-c on an org-babel plantuml block, I get the message: Debugger entered--Lisp error: (error "No org-babel-execute function for plantuml!") I have to M-x plantuml-preview-current-...
0 votes
2 answers
288 views

org-mode batch export hangs when using a python session

I have developed a workflow for batch-export of org-mode files, and have come across an issue in which execution halts when using a python session. I'm using emacs 28.1 on MacOS 11.6.5 with Python 3.9....
0 votes
0 answers
21 views

How can I include org-links in org-babel?

I can insert links in plantuml, like this #+begin_src plantuml @startuml actor Bob [[http://plantuml.com/sequence]] actor "This is [[http://plantuml.com/sequence Alice]] actor" as Alice Bob -...
0 votes
1 answer
50 views

How to evaluate python code in org-mode when only python3 is provided by the package manager?

Recently I started to use guix as my operating system. I installed python3 for my user via guix install python3. python itself is not available in the package repository, which I verified by running ...
2 votes
1 answer
759 views

org-mode: How can noweb handle a multiple line output

I have a code chunk in my document that I want to use as a list of patterns to search for with grep. If I were just writing a script without org-babel, I could write. a="ar er ir or ur" printf "...
0 votes
1 answer
257 views

Org and EIN (IPython): No output for print

I am using EIN in Org blocks, as explained on the GitHub page for EIN. So I use ein-python as the language for Org blocks (instead of python). All seems to work well (for example displaying data from ...
0 votes
1 answer
136 views

(wrong-type-argument stringp nil) error when calling tangle

As the title says, I get this error whenever I, or the function I'll show below, call org-babel-tangle. I'm using a org file to configure emacs, which tangles every time it is saved to my init.el. The ...
1 vote
1 answer
131 views

How to prevent org-mode loading babel's major mode stuffs unless entering `org-src-mode`?

I have some Java's scripts in a org file. And I use meghanada-mode in java-mode. Each time I open this org file and do nothing, I get the following error since the mehanada server loaded by java-mode ...
1 vote
1 answer
22 views

How can I tangle all org-babel blocks under the current org-heading?

How can I tangle all source code blocks under the current org-heading?
0 votes
0 answers
11 views

Adding PS1's "user@machine" to the exported version of an org-babel shell block

I am using org-babel for running shell commands. I'd like to export the code block as if it was running from the terminal, so adding "user@machine" before each command. When I export the org ...
2 votes
1 answer
337 views

Problem evaluating a `sage-shell-mode` function through `ob-sagemath`

I'm trying to use sage-math within an org-mode file. So far I've been able to configure the sage-shell-mode package (I'm impressed that sagemath can be installed in Debian using the package manager), ...
0 votes
1 answer
19 views

In org-mode, undo the effects of :results pp

In my org-files I usually always enable pretty-printing at the top because I find it preferrable to Org's default of trying to fit output into tables and whatnot. But I have now hit a snag. In a clean ...
0 votes
0 answers
19 views

Org Mode Code Sessions Scope

I'm trying to use sessions within an org file to keep the code workspace as I need something similar in style to the Jupyter Notebooks. The issue I'm having is this isn't restricting the session to ...
0 votes
1 answer
992 views

Tangle only selected src blocks using org-babel on export

I have a document with only several source code blocks that should be tangled. So the structure is: # Some main.org ... #+BEGIN_SRC awk :tangle file1.awk ... #+END_SRC awk ... ...
1 vote
3 answers
453 views

Babel + Python function definition with for loop causes IndentationError

I am using orgmode and Babel to run Python source code blocks. I noticed that if I define a function that returns a value, and if this function has a for loop inside it, then evaluating it with Babel ...
0 votes
1 answer
197 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
1 answer
33 views

how can I update the org-mode header-args from the output of an org-babel code block?

I have a code block with a shell scripts that asks for a token. I want to insert this token into the header-args, so that I can reference this from other code blocks. I usually copy it, but can this ...
1 vote
1 answer
31 views

How to save org-mode file without results of source code block

I'm preparing a presentation in org-mode and I'd like to demonstrate live the execution of code. So I'd like to start the presentation without any result block. How can I remove (strip) the results on ...
0 votes
1 answer
239 views

Org mode exam template with question and results in combination with latex

I would like to use Org mode for creating exam questions and including the templates for the corresponding results for each question. A general template is shown here #+TITLE: Lecture #+AUTHOR: ...
0 votes
0 answers
29 views

Multi-File org-babel Projects?

I'm attempting to use org-babel to do literate and meta-programming, but running into very puzzling limitations. I have numerous files that need similar functionality, so naturally, I'd like to factor ...
2 votes
1 answer
176 views

How do I associate org-mode source buffer to appropriate session?

I want to execute org-babel code blocks associated with a session without locking up Emacs. I found the ob-async package, but it doesn't have support for sessions yet. I've found that opening the code ...
0 votes
1 answer
196 views

Org Babel Redirect stderr (-c option requires an argument)

Reading about how to redirect stderr, but it does not work for me. $ cat bash-redir-stderr.sh #!/usr/bin/env bash { bash $1 } 2>&1 I get: bash: -c: option requires an argument ..no matter ...
2 votes
1 answer
530 views

How to replace raw code block output

I would like to execute a python code block to produce new headlines (i.e. modify the current org file programmatically). If I produce raw results with a replace argument, the replace argument seems ...
2 votes
1 answer
506 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....
0 votes
1 answer
93 views

Babel C++ blocks have incorrect indentation

When using a C++ source block in org-mode, the indentation doesn't match that of the C++ major mode. Viewing the source block in the org file: Viewing the same code in a C++ mode buffer or using org-...
0 votes
0 answers
113 views

Importing org-mode table into R using `read.table()`

I see a related question has already been asked, but it misses my particular use case. If I have an org-mode table with some data, and I want to import it into an R session, using read.table. However, ...
0 votes
0 answers
23 views

MetaPost figures in Org-mode?

I use org-mode to write reports and export them to LaTeX (and later to PDF). I am looking for a way to write MetaPost in the same file as the rest of the text, to preview them (preferably the same way ...
0 votes
1 answer
29 views

org-babel closing RESULTS tag

For a RESULTS in org-babel, is there an option to close it? For a src block, we have a closing #+end_src, but there is no end results type of tag;)
0 votes
1 answer
63 views

Can I find snippets using yasnippet for the mode of an org-babel block (e.g. python / bash)?

I like snippets. I use yassnippet a lot. I also use babel in org mode. I would quite like to be able to use my snippets in org babel blocks, but they don't work because I am in the wrong mode. Is ...
0 votes
0 answers
33 views

Org code evaluate: Preserve table headers when evaluating awk code

There is a table of savings account balances in my org file as follows: #+NAME: accounts | Person | Balance | |----------+---------| | Babur | 1000 | | Humayun | 2000 | | Akbar | ...
0 votes
0 answers
32 views

Org mode LaTeX block fails to invoke gnuplot for pgfplots?

I've copied a configuration from the internet that allows me to generate images from LaTeX code blocks in Org mode. Here's the setup: #+PROPERTY: header-args:latex :results file raw drawer :headers '(&...
0 votes
0 answers
23 views

Org-babel-mermaid: image file not found

I am new to Emacs. I have tried to set up ob-mermaid on my system. From what I can see, Emacs seems to be evaluating the code fine when running a quick test, but no image file is generated. I would ...
0 votes
1 answer
41 views

org-insert-structure-template on non empty line

When I insert a code block, I usually first mark the current line, before I issue org-insert-structure-template, but can I encapsulate the current line, without selecting it? Something like this, but ...
0 votes
1 answer
57 views

org-mode: How to define then call a Java method using source blocks

I have a super simple example where I have a list, a Java method and a call to this method. It looks like this: #+name: animals - dog - cat - guinea pig - horse #+name: does-contains-cat #+begin_src ...
0 votes
1 answer
74 views

Fish and org-babel

I am having troubles with the output of a fish session in org-babel. It seems to be related to the bracketed paste, but only happens when :session is used. I was wondering if there is any way to clean ...
0 votes
0 answers
10 views

Reference a header-arg :var from within a header argument?

As the title states, is it possible to reference header argument variables in the value part of other header arguments? Something along the lines of #+PROPERTY: header-args :var session-name="The ...
0 votes
1 answer
63 views

In Elisp, how can I insert an org-babel JSON block into a variable with noweb?

In Elisp, I want to insert the contents of the "gazonk" JSON block into a variable. #+name: gazonk #+begin_src json { xyzzy " } #+end_src , but I just get "End of file during ...
1 vote
1 answer
146 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
1 answer
47 views

Org mode shell blocks output with "raw" and "replace"

In Org Babel, in a bash code block, it seems impossible to get both :results header arg with both raw and replace. Is that expected? The docs for shell Babel seem to suggest the only options for :...
1 vote
1 answer
451 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 ...
4 votes
2 answers
347 views

macos org-babel python with session output give __PYTHON_EL_eval

#+begin_src python :session :results output print("yes") #+end_src With org-babel-execute-src-block command, the result is: #+RESULTS: : __PYTHON_EL_eval("try:\n with open('/var/...
1 vote
1 answer
25 views

Org babel javascript using incorrect path names

I am trying to run javascript code blocks in Org Babel. My system is Cygwin on Windows 10 with Cygwin emacs-w32. (Beautiful setup in general, I love it. Makes Windows Unix-like and bearable to me. ...
0 votes
1 answer
26 views

How to find the org babel src code block type

When point is inside an org src code block, how can I determine the code type/mode of that block? org-babel does mode specific syntax highlighting for emacs-lisp but I can't quite grep how to know I'm ...
1 vote
1 answer
269 views

Why is electric-indent-mode adding extra indentation after pressing return twice in org source blocks?

When I try to write code in source block in Org mode, pressing return once acts as expected while hitting it a second time increases the indentation to two levels if it's currently less than that. ...
1 vote
2 answers
95 views

how to tangle only source code blocks that belong to a specific target file?

Let's say we have the following org file: #+begin_src python :tangle "target1.py" a=11 #+end_src #+begin_src python :tangle "target2.py" a=21 #+end_src #+begin_src python :tangle ...
0 votes
1 answer
18 views

Org Babel: Possible to get Python shell with session?

When I make an Org Babel shell code block with for instance a :session a header argument, it automatically makes a buffer a with the shell for this session, so I can explore it interactively. This is ...
0 votes
0 answers
16 views

Org Babel: Open Python shell on session?

When I run an Org Babel shell code block with e.g. :session a header argument, it automatically opens a buffer a with the shell for this session, so I can explore it interactively. I love this feature!...
0 votes
1 answer
96 views

Remove empty line between source code and results block in org babel automatically

Is there a variable in org I can use to specify the number of empty lines before the results block; it defaults to 1, but I want to set it to 0.

1
2 3 4 5
17