Skip to main content
Share Your Experience: Take the 2024 Developer Survey

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
0 answers
10 views

Prevent empty line in first output of org-babel bash session

In Emacs 28.2 with org-mode 9.5.5 and --no-init-file on Debian 12 the output of the first evaluation of a bash session is polluted by an empty newline. #+begin_src bash :session c ...
Rovanion's user avatar
  • 987
0 votes
1 answer
23 views

Is there an org-mode code block that echoes its content back?

Is there a code block type in org-mode that can echo its context (text) back when executed? So, in pseudo-code, the code block: #+begin_src echo { "id": 1, "name": "James ...
tinlyx's user avatar
  • 1,364
0 votes
0 answers
28 views

Can identical example and source blocks be made to look different in a PDF export?

I use both #+begin_src and #+begin_example blocks in my org-mode markup that gets exported to PDF. If I put identical text in to these blocks, then they look identical in the PDF export. Is there any ...
J. Mini's user avatar
  • 177
0 votes
1 answer
20 views

Using File Input in Org Source Block?

I'm trying to run this C source block using input from a text file. #+BEGIN_SRC C :includes <stdio.h> int c; c = getchar(); while (c != EOF) { putchar(c); c = getchar(); } #+...
Eli Rusk's user avatar
1 vote
1 answer
29 views

How can I return/print all of my code's results with the code in Org-Mode?

Suppose that I type the following code in to a REPL. (+ 1 2) (+ 1 3) At the end, my REPL looks like * (+ 1 2) 3 * (+ 1 3) 4 I want the same when exporting org-mode to PDF, but I don't get it. This ...
J. Mini's user avatar
  • 177
2 votes
1 answer
23 views

Org Babel with language with angle brackets in use

I wanted to write an Org Babel file with some CUDA code, where they use the <<<...>>> syntax in the language. This confuses Org Babel because it's the syntax for including code ...
Eric Auld's user avatar
0 votes
0 answers
17 views

Elisp in properties header args

I use this: #+property: header-args:R :session (concat "*R:" (f-base (buffer-file-name)) "*") Is it possible to evaluate Elisp code by putting it inside back ticks or something ...
Arktik's user avatar
  • 972
1 vote
0 answers
17 views

can org-babel-tangle only change in-place with a pre-existing file with link

Say I have 2 files, file1.org and file2.org, both tangling to source.el, which I arranged to look like this: ;; [[file:file1.org::ha][ha]] (defun the-first-block() ) ;; ha ends here ;; [[file:...
Herman He's user avatar
0 votes
1 answer
16 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-...
Jason Hunter's user avatar
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 -...
Jason Hunter's user avatar
0 votes
1 answer
60 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 ...
Eldinur's user avatar
  • 13
1 vote
1 answer
24 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?
Jason Hunter's user avatar
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 ...
Peter Petigru's user avatar
0 votes
0 answers
21 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 ...
ADS_Fibonacci's user avatar
1 vote
1 answer
36 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 ...
hintze's user avatar
  • 113
1 vote
2 answers
42 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 ...
Addlai's user avatar
  • 121
0 votes
0 answers
27 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 ...
Carl's user avatar
  • 1
0 votes
0 answers
40 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 '(&...
Fangquan Shi's user avatar
0 votes
0 answers
27 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 ...
Tiberius's user avatar
  • 113
0 votes
1 answer
22 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 ...
Rovanion's user avatar
  • 987
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 ...
Rovanion's user avatar
  • 987
0 votes
1 answer
52 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 :...
Eric Auld's user avatar
0 votes
0 answers
34 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 | ...
Saravana's user avatar
  • 2,071
0 votes
1 answer
23 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 ...
Eric Auld's user avatar
0 votes
0 answers
17 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!...
user42475's user avatar
1 vote
2 answers
108 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 ...
martinoidar's user avatar
1 vote
1 answer
34 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-...
user615536's user avatar
1 vote
0 answers
28 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 ...
user615536's user avatar
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',...
lucky1928's user avatar
  • 1,668
0 votes
0 answers
57 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 ...
balanga's user avatar
  • 135
0 votes
1 answer
27 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 ...
RichieHH's user avatar
  • 873
0 votes
1 answer
25 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 ...
lucky1928's user avatar
  • 1,668
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. ...
Edward Doolittle's user avatar
0 votes
1 answer
30 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 ...
user41177's user avatar
  • 121
0 votes
1 answer
61 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 ...
Snelephant's user avatar
0 votes
0 answers
34 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-...
shintuku's user avatar
  • 121
0 votes
1 answer
93 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-...
Lindsay's user avatar
  • 37
0 votes
1 answer
43 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, ...
HappyFace's user avatar
  • 830
1 vote
0 answers
39 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=...
shynur's user avatar
  • 5,318
0 votes
1 answer
21 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 ...
lucky1928's user avatar
  • 1,668
0 votes
1 answer
48 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 ...
shintuku's user avatar
  • 121
0 votes
0 answers
43 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 ...
Holger Karl's user avatar
0 votes
0 answers
50 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 ...
Tomke Pfoch's user avatar
1 vote
1 answer
100 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::...
shynur's user avatar
  • 5,318
2 votes
1 answer
80 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 ...
Garid's user avatar
  • 641
0 votes
1 answer
33 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-...
Tyler's user avatar
  • 22.3k
1 vote
0 answers
136 views

org-mode latex export of source block with engraved gives error for latex3 code due to missing color-`face` processing

I want to export my source blocks from org-mode to pdf through latex with the export backend engraved. I installed the package engraved-faces, set the variable with (setq org-latex-src-block-backend '...
lukeflo's user avatar
  • 195
0 votes
1 answer
52 views

Why does adding a return value to my Python code stop it from printing?

Load up Emacs in the default modes, i.e. emacs -Q. After this, make a new .Org file with the following contents and run the Emacs Lisp code. (setq org-babel-python-command "python3") (setq ...
J. Mini's user avatar
  • 177
0 votes
2 answers
65 views

How to jump to #+RESULTS: when point is at Org source block?

When point is on a source block, I want to be able to jump to the #+RESULTS section of that source block. If the source block does not have a #+RESULTS: section, I want to do nothing: I don't want to ...
fuch your face's user avatar
3 votes
0 answers
73 views

org-babel python code block - not showing errors during execution

I have a python code block in an org-file that when executed results in some error. I was expecting to see that error in the #+RESULTS: block, but it doesn't show up. I have to navigate to the python ...
skittish's user avatar

1
2 3 4 5
17