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
1 answer
63 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
1 answer
11 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
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
62 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
136 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
28 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
422 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
321 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
24 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
22 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
263 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
84 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
16 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
86 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 vote
1 answer
32 views

dynamic scoping rules work differently after redefining an autoloaded function without changing its code

Evaluate the following code: (package-initialize) (unless package-archive-contents (package-refresh-contents)) (package-install-selected-packages) (org-babel-do-load-languages 'org-babel-load-...
1 vote
0 answers
21 views

org-babel :results header-arg, graphics vs file

The org manual describes how to evaluate a src block and capture the results, using :results <collection> <type> <format> <handling> # i prefer to use this terminology for the ...
0 votes
0 answers
14 views

The same code prints two different results from python

I wrote a sample code to print the same dataframe two times, but the first and second time print two different results: #+begin_src python :results output drawer import pandas as pd data1 = [['1','B',...
0 votes
1 answer
33 views

Is there any org-babel source block that converts to a LaTeX pseudocode algorithm block?

Currently, when I want to add some algorithm's pseudocode to my LaTeX export, I have to manually write LaTeX: ** Pixel-Flipping: A Technique to Assess Faithfulness - Pixel-flipping is a quantitative, ...
0 votes
0 answers
42 views

Using .org to create init.el

I've recently learnt about using a .org file to create init.el and would like to move to this construct to better document my setup. One thing I have thought about is trying to compartmentalise this ...
0 votes
1 answer
20 views

feed python output to sqlite as input sql stement

I would like to feed python output to sqlite input as below: #+NAME: sqlcmd #+begin_src python :results output print("select * from tablename") #+end_src #+RESULTS: sqlcmd : select * from ...
0 votes
1 answer
21 views

org-babel call other python block automatically

I have two python blocks. If I execute blockA, then execute blockB, it works fine. How can I only execute blockB without manually executing blockA? I am thinking add a :var from blockA` but it does ...
2 votes
2 answers
156 views

How do I stop org-babel from trying to edit a source block in a dedicated buffer?

I have org :jupyter in my Doom Emacs init.el, i.e., ob-jupyter, for using Jupyter with org-babel, and there's a really annoying behavior when I'm in an org file, editing a source block that begins ...
0 votes
1 answer
36 views

Org Babel incorrectly displaying Shell output

Org Babel (Shell) in a session ends up truncating output from the shell. MWE: test.py: #!/usr/bin/env python3 print(""" Stats: CPU Busy 24 (100.00%) Stats: IO Busy 15 (62.50%) Stats: ...
0 votes
2 answers
549 views

ledger in org-babel blocks uses incorrect path data in Windows 10

I am trying to include a ledger data file from an org-babel block. I am using Windows10 and the SciMax emacs distribution. #+begin_src ledger :cmdline bal :results output :exports results !include d:/...
1 vote
1 answer
142 views

No comment syntax defined when tangling lua or vimrc code blocks

Resolution With help from commenters, I have things kind of working. I removed :comments link from Properties. I manually added comments to the top of every code block to replicate what :comments ...
7 votes
5 answers
8k views

Setting up Ditaa in Org-mode

I've been having trouble setting up ditaa to work in emacs, I got my copy of the ditaa jar from here And I've been trying to run this code block #+begin_src ditaa :file hello.png :exports results +-...
0 votes
1 answer
26 views

Is there a way to transcode example blocks differently from src results?

I'd like to have #+results: : Hello world export as \begin{results} Hello world \end{results} while I want example blocks to export as... \begin{verbatim} This is an example \end{verbatim} How can ...
0 votes
1 answer
44 views

Export org-mode blocks to a text file

Is there a way to export the contents of org-mode blocks to a text file? The blocks will contain only ascii text. I can export the contents of a source block using Babel with tangling: #+BEGIN_SRC ...
0 votes
0 answers
32 views

How do I pass a variable from a calling buffer to a called buffer?

The process of tangling in org involves, according to https://orgmode.org/manual/Extracting-Source-Code.html, a calling buffer and a called buffer, each of which have their own hooks: org-babel-pre-...
2 votes
1 answer
379 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
65 views

Broken emacs trying to tangle multiple org files into a config.el file

Help! I've broken my emacs configuration. I was trying to sort out my messy config.el file by dividing it into multiple .org files. My init.el file now looks like this (require 'org) (org-babel-load-...
0 votes
1 answer
147 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
2 answers
275 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....
1 vote
0 answers
38 views

‘:colnames yes’ not working?

I tried the example from (info "(org) Environment of a Code Block"): #+NAME: less-cols | a | |---| | b | | c | # I changed the value of ‘:colnames’ to _yes_. #+BEGIN_SRC python :var tab=...
2 votes
1 answer
747 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
253 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
37 views

Tangling fails when using #+PROPERTY instead of manually adding header arguments when using org source blocks

The following code doesn't work, yet adding :tangle tangleobject.org manually to each source block provides us with the expected tangle result. Any clue why? #+PROPERTY: header-args :tangle ...
1 vote
1 answer
96 views

Execute Code with Env Var Set Temporarily

Here's a piece of C++ code (its content is not important) written in an Org file: #+BEGIN_SRC C++ #include <omp.h> #include <iostream> int main() { #pragma omp parallel std::...
0 votes
1 answer
123 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
130 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 ...
0 votes
0 answers
30 views

How to use a dynamic block (column view) as input to a babel function?

I am trying to use the table of an org-mode columnview dynamic block as input to a org-mode babel function. It works fine with static tables, but with the dynamic table, I get a "Reference not ...
0 votes
0 answers
32 views

detangle preserve noweb

I've recently gotten into literate Programming with org-mode. I'd like to be able to write all my functions across multiple Code Blocks, tangle them into a files but also test them from inside the org ...
20 votes
2 answers
4k views

Can I include a common code block in two different code blocks in Org mode?

I have an org-mode file containing a table of data and two Python code blocks to extract different summaries from it. I would like to share some common constants and functions between these two code ...
2 votes
1 answer
327 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
30 views

org can't execute on remote machine

I have a .org file on my laptop that I use to run code on a remote server. However, when I try to execute the code I'm getting Tramp errors. My local org file has the following header: # -*- org-...
0 votes
1 answer
976 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
449 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
190 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 ...
2 votes
1 answer
69 views

Configuring Key-bindings from Org-Table

I use init.org file to configure my emacs, and then tangle it into init.el. Now, I would like to configure my keybindings from org-table (for more readable and printable). Basically, I'd like to only ...

1
2 3 4 5
17