Skip to main content

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
16 views

Org-mode babel shell async evaluation not working with named sessions

I'm trying to use shell asynchronously with named sessions, but it doesn't work: #+begin_src sh echo "a" #+end_src #+RESULTS: : a #+begin_src sh :async echo "a" #+end_src #+...
vslavkin's user avatar
2 votes
2 answers
54 views

Org babel add extra "," after indent for no reason

Insert the following text in an org buffer with electric-indent-mode on. #+begin_src python s=''' #+1 #+1''' #+end_src add a newline to s, and the buffer will become: #+begin_src python s=''' ,#+...
godblessfq's user avatar
  • 1,259
1 vote
1 answer
44 views

Python Org Babel producing garbled result

I have the following settings on for org-babel #+PROPERTY: header-args:python :python ~/env/pt/bin/python :session a :results drawer output replace When I evaluate a code block, the results are some ...
Eric Auld's user avatar
  • 103
0 votes
1 answer
24 views

How can I make this section-level Org-Mode header work at the top-level?

I find that the following org-mode header works just fine if I put it in a section * SQL world :PROPERTIES: :header-args:sql: :exports both :header-args:sql+: :cmdline -S 123.45.0.6,1999 -U sa -P &...
J. Mini's user avatar
  • 133
2 votes
1 answer
105 views

How can I make SQL output readable?

I'm trying to find an Emacs replacement for SQL Server Management Studio (SSMS). I have managed to query my Microsoft SQL Server from Emacs – and what a task that was! – through SQL Mode. However, the ...
J. Mini's user avatar
  • 133
0 votes
0 answers
22 views

Display custom message after completing org-babel-tangle

I'm using org-babel-tangle to tangle one of my org file into an the emacs config file. After completion, I get a message showing how many blocks have been tangled like Tangled 48 code blocks from My-...
Gangula's user avatar
  • 293
2 votes
2 answers
91 views

replace expressions with output in code-blocks before org-babel-tangle

How to evaluate the expressions or functions in a code-block before tangling a source code block? I generate my init.el file using org-babel-tangle AND I'm using chemacs2 - which allows using ...
Gangula's user avatar
  • 293
0 votes
0 answers
19 views

org-babel: Pass flags when filtering source code blocks?

I'm currently using org-mode to make some beamer slides, where I'm generating some code blocks and results using org-bable. I'm currently using org-export-filter-src-block-functions to modify the ...
Joey Eremondi's user avatar
0 votes
1 answer
56 views

lexical binding in a tangled init.el file

How can I enable lexical binding in an init.el file that is tangled from an org mode file? I have an org mode file called Emacs.org which is used to tangle the init.el file using the command M-x org-...
Gangula's user avatar
  • 293
0 votes
1 answer
49 views

Org-mode code blocks and results side-by-side in beamer export?

I'm using org-mode to generate slides for a class I'm teaching, and one of the things I do is use org-babel to show code snippets, run them and display the results. However, in the generated Beamer ...
Joey Eremondi's user avatar
0 votes
1 answer
28 views

Org-babel ignores RESULTS when generating beamer?

I'm using Org-babel to generate a bunch of pdfs from a single Org-mode file, compiling using Beamer. Each subtree starts something like this: * Introduction :PROPERTIES: :EXPORT_FILE_NAME: pdf/...
Joey Eremondi's user avatar
0 votes
1 answer
38 views

Conditionally evaluate scattered source code blocks in org mode

I have an org document with various source code blocks. Some of blocks should be evaluated conditionally on org-babel-execute-buffer; however, these blocks are scattered throughout the document, which ...
kozina-adjacent's user avatar
0 votes
0 answers
18 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
  • 1,017
0 votes
1 answer
32 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,374
0 votes
0 answers
32 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
  • 133
0 votes
1 answer
31 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
41 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
  • 133
2 votes
1 answer
29 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
  • 103
0 votes
0 answers
21 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
  • 992
1 vote
0 answers
20 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
20 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
26 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
137 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
29 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
30 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
2 votes
1 answer
59 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
  • 123
1 vote
2 answers
56 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
  • 131
0 votes
0 answers
40 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
1 answer
67 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
33 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
30 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
  • 1,017
0 votes
0 answers
14 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
  • 1,017
0 votes
1 answer
147 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
  • 103
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,081
0 votes
1 answer
57 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
  • 103
0 votes
0 answers
18 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
136 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
37 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
32 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
16 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,688
0 votes
0 answers
83 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
33 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
  • 883
0 votes
1 answer
26 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,688
1 vote
1 answer
32 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
35 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
82 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
35 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
126 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
58 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
  • 900

1
2 3 4 5
17