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
0answers
13 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
13 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
42 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
11 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
21 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
28 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
23 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: #+...
0
votes
1answer
28 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
50 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
28 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
48 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
71 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
25 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
19 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
25 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
10 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
55 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
46 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
37 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
9 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
82 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
39 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
16 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
29 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
23 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
41 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
37 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
115 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
47 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 ${...
1
vote
0answers
81 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
39 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
29 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
62 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
25 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
74 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
28 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 ...
0
votes
1answer
101 views

How to disable certain org-mode blocks from accidental execution

I have some shell code that can be dangerous to run on local machine in a org-mode source code block. Globally, I have configured org-mode to prompt for execution, but I would still like to make sure ...
1
vote
1answer
52 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. ...
2
votes
1answer
84 views

Automatically update a date in tangled files of an .org file?

I'm in the process of writing a LaTeX class using org-babel for the literate programming. In several places of the file .org file, I have to insert the release date of this class, at least in the ...
0
votes
0answers
24 views

olivetti mode with polymode?

I am using olivetti-mode with org-mode, but the screen does not stay fixed to the same width when my cursor moves from the org text to code between #+begin_src ... #+end_src. Is there a simple fix ...
0
votes
0answers
29 views

Session support in org mode babel

I am trying to set up org-mode babel to work with MAGMA. What I have so far is very simple but works well enough. The problem is that it does not support sessions, which would be quite important to ...
3
votes
1answer
124 views

Org mode python code block with session does not return a result

I had been successfully using python code blocks with the :session header argument when I noticed that upon export no result was given. I then simplified my example to the following two: #+...
0
votes
0answers
66 views

(org-babel-load-file (expand-file-name "~/.emacs.d/config.org")) behaves strangely on Windows 7

In my initialization file the line (when (file-readable-p "~/.emacs.d/config.org") (org-babel-load-file (expand-file-name "~/.emacs.d/config.org"))) give me the error: *Warning (...
1
vote
1answer
83 views

Why can't I use rg (ripgrep) in an Org mode source block?

I have the following source block in my Org mode file: #+begin_src sh :results output exec 2>&1 mkdir -p /tmp/example && cd /tmp/example echo "hello" > world rg --...

1
2 3 4 5
14