# 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.

711 questions
Filter by
Sorted by
Tagged with
21 views

### Executing mit-scheme blocks in org-mode

Using doom emacs in my packages.el: (package! slime) (package! geiser) (package! geiser-mit) (package! scheme) in my config.el: (setq geiser-active-implementations '(mit)) (org-babel-do-load-...
• 1
28 views

### What is the priority of the library of babel' code blocks versus the named code blocks locally in org-babel-expand-noweb-references'?

When tangling my literate files, code blocks from the library of babel, added using org-babel-lob-ingest, are overriding local named code blocks. I'd thought it's supposed to be the other way around. ...
25 views

### org-babel-params-from-properties' with a non-nil no-eval' still evaluating functions

I may be misunderstanding how the no-eval argument works, which is passed to org-babel-parse-header-arguments, and then finally org-read as inhibit-lisp-eval; it seems functions I'm using to pass the :...
52 views

### Getting content of paragraph element using Org Element API

I've been trying to get the content of the paragraph element unsuccessfully using org-element-contents, is there something I am missing here? I have a org document as follows: * world ** China *** ...
• 103
28 views

### HTML Export and "org block"

Using EmacsMac 28.1 (OSX) (started as emacs -q), I'm trying to export a simple org document that contains an org source block: #+begin_src org *Hello* /world/ #+end_src When I export this to a buffer ...
22 views

### Org-mode lists and org-babel "shortcuts" are not working properly

I started using Emacs about a month, and I began to make my configuration yesterday. Everything works fine, but I have some problems with org-mode lists. When I create a new list and then press RET or ...
18 views

### Setting flags such as -n', -r', -l' with org-babel-default-header-args'

As in the title; I'm wondering whether the cell cars will be keywords, strings, or quoted values, and the cdr will be booleans, such as in the following cases: (setq org-babel-default-header-args ...
1 vote
20 views

### Org Mode: Produce Result Block when indirectly calling src block as dependency

Consider the following org mode document: #+NAME: source #+BEGIN_SRC python :cache yes import random return random.randint(3, 300) #+END_SRC #+RESULTS[2314024a531aeb3c9e51cd69e45adf654927e9fa]: ...
• 111
22 views

### Org mode babel hangs with python C-c C-c

When I C-c C-c in a Python code block in Org mode: #+BEGIN_SRC python :results value :session a = 4 a + 13 #+END_SRC It hangs with a message: Warning (python): Your ‘python-shell-interpreter’ ...
• 121
25 views

### Apply :post processing to Rust/Rustic Org Mode Babel Source Block

I'm trying to setup a :post process on a rust code block. For example: #+begin_src rust :post padder(data=*this*) It works fine when I run other languages, but not with rust. The behavior I'm seeing ...
1 vote
33 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/...
• 111
13 views

### How to edit a code snippet in external buffer as with org babel

I would like to create a major mode for editing files that will contain HTML template snippets. The ideal mode for editing these snippets would therefore be web-mode, as it integrates lots of these ...
• 165
31 views

### How do I debug Tangled 0 code blocks?

This is a history of an unsuccessful attempt to fix tangling in my Emacs configuration. In frustration, I have removed the org-mode config and left the file that was a result of previous successful ...
• 327
26 views

### Reference env variable in org babel source block headers

I am setting up an org-mode document to connect to a postgreSQL database and execute+show the results of some queries. I don't want the database password visible in the org document (regardless of ...
• 101
10 views

### How to populate org table with org citations generated by R scr

I am trying to generate a table of org citations with the following R source block (emacs 28.1, org 9.5.3) #+name: test-citation-table #+BEGIN_SRC R :results replace :colnames yes data.frame(...
• 181
42 views

### How can I add a horizontal line (\hline) above the first table row when exporting to latex?

I want a table in org mode to meet two needs: When it is exported as latex, the result table in latex has the top horizontal line. like this: Can be used as input variable for R code blocks But it ...
• 111
23 views

### use org properties as variables in c or python source code

I'm using org-mode to control some charges, using c++ code to balance. But I have to assign the values by hand. And I would like to assign the values via org properties or some other form of ...
• 21
42 views

### Post-process table without changing result of nil (empty table)

If a code-block that is supposed to produce a table return nil, then nothing at all is inserted, as demonstrated by the second example below. #+begin_src emacs-lisp :results table '(("foo" ...
• 24.4k
64 views

### Literate Emacs Configuration Exclusion

When using literate configuration, is there a way to exclude code blocks? Maybe tag the babel blocks to include or exclude? Any great ideas?;)
• 197
40 views

### Org Mode Structure Templates with emacs-lisp

I can insert a src structure template with C-c C-, s , but do I have to write the language every time? Is there some expansion or completion mode that can show the available languages?;)
• 197
84 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....
50 views

### Strange autoindentation in org mode source blocks

I try to use org-mode as a replacement for jupyter notebook, and I was faced with a problem: when I edit a python src block, newlines don't indent properly, so I have to press space 4 times after ...
65 views

### Get filename and line numbers of org SRC block

I'm writing an org babel implementation, and one thing that I'd like is to be able to embed proper line-numbers pointing back to my .org file in my language code. So for example, if I had a file /some/...
• 101
59 views

### How to hide a password in an org mode source block?

For educational purposes I'm using org-mode to explain some python by exporting to html and the :exports both header argument. pw="mypassword" def myFunction(apikey) print("foo&...
• 629
1 vote
56 views

### Org-babel and ESS: Problem with exporting ANSI code to pdf

I am having some issues with Org mode Babel exporting output with ANSI characters. When I don't specify a session (example 1), everything is OK. When I specify a specific session, the code is garbled (...
• 345
1 vote
44 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 ...
• 111
56 views

### Evaluate src block of org-babel depending on export type

I would like emacs lisp to evaluate a code block like the following, but variablevalue should take on different values depending on whether I'm exporting to html or latex: #+begin_src emacs-lisp :...
• 1,004
12 views

### org babel incorrectly output xml like content

so I have a test.xml with the following content <root> <path>/my/data</path> <paths>/global/data</paths> </root> I then use org-babel to run cat test.xml I ...
1 vote
73 views

### How can I execute an org-babel file from the command line?

Is there a way to execute a whole buffer's worth of code blocks, in an org file, and save them all in that org file, headlessly, from the command line? Here's what I've tried so far, but it's not ...
• 497
1 vote
59 views

### Why does a code block that contains only comments seem to change key bindings?

This is very odd. I have my Emacs config in code blocks in an org-mode file that is called from my init file using (org-babel-load-file "~/.emacs.d/emacs-config.org"). I've tried to assign ...
• 314
41 views

### expand source block from different org file

I followed the example here noweb reference syntax to successfully replicate expansion of source code blocks. However when I move one source block into a different org file, the expansion comes up ...
• 9
90 views

### org-babel: can the plot size be specified?

I was wondering if the output plots resulting from org-babel blocks are customizable in size (how they appear in the org-mode buffer, as in its dimensions X and Y). Thanks!
11 views

### How to use lubridate (R) to transform orgmode date timestamp into R readable dates?

My aim is to plot time against data in a plot in org-babel. However, my data table looks like this: | date | amount |------------------+--------| | <2022-01-30 Sun> | 55.1 | | <...
101 views

### Using org-table data for R block

I'd like to be able to plot in an orgbabel chunk these data I have in a org-table: #+NAME:amount | date | amount |------------------+--------| | <2022-01-30 Sun> | 55.1 | | <...
51 views

### How to implement a "block" (first introduced by roam research) in org mode?

If you are familiar with roam research, you may know that it consists of page and block. Relate it back to org-mode terms: page is equivalent to file, but there is no one-to-one mapping from block to ...
1 vote
34 views

### Babel Lilypond Paper-Size (Preview & Export)

When trying to use babel lilypond for music engraving inside org, I have got the following problem: The paper size used by lilypond is always a full page. But what I want is a minimal, growing paper ...
20 views

### org-babel write python insert tab after press enter

When I try to write python code in org-babel, after press enter,it will insert a tab at the beginning automatically. I try below init.el but looks like not fix this issue! (add-hook 'org-mode-hook ...
• 1,486
23 views

### org-mode babel code color highlight doesn't work in a large file

I am enjoying the org-mode babel code color highlight. I write HTML, Perl, css and js in a single file and the coloring works fine with each languages' mode. This is the org file with some codes. #...
137 views

### DIsplay pandas dataframe (from source block output) inside an org-mode buffer

I'm trying to setup org-mode as a substitute for jupyter notebook using emacs-jupyter. My problem right now is how to display pandas dataframes. When the dataframe contains cells with a lot of text ...
• 27
1 vote
80 views

### execute all org-mode code blocks in a region?

Is there a way to highlight a region of a org file and execute all code blocks in the region? What I was looking for is basically to execute all code blocks up to a certain point, where I am writing ...
• 930
28 views

### HTML publish latex block images

I am trying to export a latex tikzpicture, like the following to html: #+begin_src latex :exports results :results raw file :file ex.png :output-dir ../img/ \begin{tikzpicture} \draw node[circle,...
157 views

### org-babel-insert-result: Wrong type argument: markerp, nil

I use org-mode to structure my emacs configuration files. Recently, I have the following problem: some of my emacs-lisp blocks generate the following error at runtime: org-babel-insert-result: Wrong ...
110 views

### Emacs hangs on org-babel-execute-src-block for Haskell blocks

I have a minimal org file with a Haskell code block: #+begin_src haskell putStrLn "Hello World" #+end_src When I do M-x org-babel-execute-src-block, Emacs hangs with minibuffer saying: ...
1 vote
47 views

### Specify arbitrary attributes for code blocks and keep them when converting with pandoc

Markdown and its different flavours have a number of interesting extensions, notably the [hl_lines attribute][0], which allows to highlight specific lines in a fenced code block, as illustrated here ...
• 11
39 views

### Variable for line-wide colouring in emacs org-mode source blocks

What org-mode variable determines whether or not the org-mode block-background applies line wide like so: instead of like so: I am using the gruvbox-dark theme. I will attach the defface as soon as ...
31 views

### How to indent Org Babel list output with multiline text correctly?

I'm using Babel to generate some text in an Org file. I'm using :results value list header switch described here to format the output in Org's list structure. It doesn't quite format multiline text ...
• 101
102 views

### Use org-babel table results as input to another org-babel snippet

I have a snippet of Python code that outputs an Org mode formatted table. After I'm satisfied with the table, I would like to generate the LaTeX markup via orgtbl-to-latex function. For example, I ...
• 111
21 views

### Disable indentation in sh babel src block on hitting RET

I've implemented many snippets to my init.el (bottom of this post) to no avail. Any other ideas to have RET in an sh block returning the cursor to a new line's beginning instead of giving: Setting up ...
• 629
69 views

### org-babel code block wrong type argument

I'm stumped as to why I can no longer export an org-babel file with R code chunks and can not work out where the error is cropping up. A simple example that doesn't include the graph... #+STARTUP: ...
• 263