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 [tag:org-babel] is now incorporated into [tag:orgmode] as `working with source code` and no longer a separate extension.

107 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
9
votes
0answers
456 views

Edebug orgmode source code blocks with input variables

What is the standard method to debug emacs-lisp orgmode source code blocks with input variables as header arguments? I found the hacky solution to insert the following snipped in front of a source ...
5
votes
1answer
43 views

How to display intermediate code block results?

Here is an example to let me explain what I would like to achieve: #+NAME: heavy_computation #+BEGIN_SRC shell :results table echo -e "A\t32\nB\t17" #+END_SRC #+BEGIN_SRC python :var data=...
4
votes
0answers
214 views

Org-babel and anaconda-mode in src blocks

I practice python literate programming with tangling to generate a full project structure. There are dependencies between modules and packages, and so I will say in the C-c ': #+begin_src python ...
4
votes
0answers
256 views

Indentation using multiple org src block

So, say I have a literate org file as follows: #+TITLE: Random Scrap * Do something :PROPERTIES: :tangle: scrap.pl :comments: org :END: #+BEGIN_SRC perl sub my_func{ my $var = pop; #+END_SRC ...
4
votes
0answers
94 views

Get describe-key links to bring me to org-mode config files, not .el config files?

For my Emacs configuration, I use a literate programming setup. My config files are in org-mode format, and my init.el file consists mostly of org-babel lines like (org-babel-load-file "~/emacs/...
3
votes
1answer
218 views

org-export latex pdf output does not render svg

I tried out this section of code from this repo #+LATEX_HEADER_EXTRA: \usepackage{svg} ... #+PROPERTY: header-args :eval never-export :file-ext svg ... #+NAME: sequence12422 #+BEGIN_SRC plantuml :...
3
votes
0answers
36 views

How to set a tangled parent directory for each subtree in org mode?

Base on this, one can set a global tangled file. However, I'd like to set one directory for each subtree, e.g. for a * Python subtree, in every code block I can set :tangle a.py or :tangle b.py ...
3
votes
0answers
133 views

Apply ANSI color escape sequences for Org Babel results

Feature There is a nice built-in Emacs feature to colorize strings with ANSI color escape sequences. So evaluating the following Elisp code, will insert the "Test text" at the point with proper ...
3
votes
0answers
87 views

Prevent Org mode from raising Emacs frame while exporting to PDF

Some of my org mode files take a long time to export because they include code for number crunching that is executed during export (via Org Babel) . I usually minimize the Emacs frame while the ...
3
votes
1answer
130 views

Evaluating `org-babel-clojure` blocks returns all form evaluations

I'm trying to set up babel for use with Clojure according to http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-clojure.html#org85bc1ec and I can evaluate code but when I evaluate a block with ...
3
votes
1answer
188 views

How do I attach a custom function to process org-mode babel shell output?

I have a a function (defun display-ansi-colors () (interactive) (let ((inhibit-read-only t)) (ansi-color-apply-on-region (point-min) (point-max)))) that I got from here: http://stackoverflow....
3
votes
0answers
129 views

Literate agda programming in org-mode

How could I write literate (and exportable to latex) Agda code in org-mode? Org-babel would be a great option, but there is no ob-agda2 (I think?). I have tried defining an org-babel-execute function ...
3
votes
1answer
132 views

How to disable noweb prefix lines?

This says that Noweb insertions now honor prefix characters that appear before <<reference>>. And because of that trying to use #+BEGIN_SRC clojure :noweb-ref dep-cljsbuild [lein-...
3
votes
0answers
182 views

Curly braces inside a body of the org-mode inline source block

I would like to use curly braces inside a body of the org-mode inline source block. Since the body itself is delimited with curly braces it seems impossible. The problem occurs when additional pairs ...
3
votes
0answers
129 views

Org-babel noweb expansion when sending C-c ' buffer to python shell

I'm doing literate programming with Python. In my workflow I like to test the block with python-shell-send-buffer and ipdb debugger. However if the block contains a noweb reference then the code is ...
3
votes
0answers
516 views

org-mode babel german

I am trying to export an org file to PDF via LaTeX but in German. I set #+LATEX_HEADER: \usepackage[ngerman]{babel} but when exporting org-mode adds english to the babel options. That causes all the ...
3
votes
0answers
148 views

Prevent Org from escaping latex results

During export, Org generates this: \begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=2.8cm, semithick] \node[initial,state] (A) \{\$q$_{\...
3
votes
0answers
113 views

Org-mode Babel: Evaluating code in header of code block for tangling

Is there a straightforward way to use a variable for the tangle file? For example, I want to tanlge my file into the directory files. For multiple files I could do #+begin_src python :tangle files/...
3
votes
0answers
136 views

Jump sequence for placeholders in yasnippet not working in org-property blocks

I use the yasnippet bundle and it works like charm. When I want to include placeholders in a PROPERTIES section of an org-document it is not working. Here's the snipper: #type: snippet # -- :...
3
votes
0answers
164 views

Launching in daemon mode crashes emacs while loading configuration from .org file

I've been using literate programming using org-mode for my initialization file. I've a init.el which loads a org file converts it to .el and uses it as startup file. Here is my configuration files. ...
2
votes
1answer
53 views

Jumping from a source block to the tangled file

Is there an inverse of org-babel-tangle-jump-to-org allowing one to jump from a source block to the corresponding place in the tangled file?
2
votes
0answers
109 views

org-mode/babel and zsh: Getting shell sessions to work

I've been trying to get shell code blocks with sessions to work, but not entirely succeeding. My setup: emacs 26.1 (spacemacs) org-mode 9.2.2 default shell: zsh 5.7.1 Everything seems to work fine ...
2
votes
0answers
131 views

Print output from org code block immediately

I have an org mode file I use to run some moderately long analyses. Evaluating individual blocks may take 15 minutes to an hour or so. I usually wrap longer bits with calls to date, so I can later ...
2
votes
0answers
54 views

C-c ' for editing all code blocks (to handle imports and variables)?

The Org manual says: C-c ' for editing the current code block. It opens a new major-mode edit buffer containing the body of the ‘src’ code block, ready for any edits. This feature is sweet. ...
2
votes
0answers
92 views

Setting org-babel-load-languages in .dir-locals.el

As per the title, I'd like to set the org-babel-load-languages (to contain ditaa and calc languages) for a specific project only. The only solution I found so far is this one ( (org-mode . ...
2
votes
0answers
39 views

Re-apply table formulas on org-mode export

I'm using an org-mode file to do some filesystem monitoring. To that purpose I have a table in which I'm calling code blocks through org-sbe in the formulas. It looks like this: #+NAME: part-size #+...
2
votes
0answers
39 views

Is there a way to time babel code blocks?

Is there a way to do something like the example below to time the execution of any babel code block ? #+BEGIN_SRC sql :timeit #+END_SRC #+results 40s results here #+BEGIN_SRC python :timeit #+...
2
votes
0answers
216 views

org-mode: Can I use a custom mode for org-src-lang-modes and still get syntax highlighting?

I'm trying to get syntax highlighting with org-mode source blocks using a custom language mode for editing JavaScript. I use js2-mode with a bunch of minor modes, rather than js-mode, which is what ...
2
votes
0answers
233 views

Org sql header args dont seem to work why?

Can anyone explain why this does not work, i want to set the parameters global to the current document using PROPERTY but this does not work and results in this error. (wrong-type-argument stringp ...
2
votes
0answers
283 views

how to expand org-mode macros in HTML blocks in export to HTML?

I'd like to use org-mode macro replacement to expand macros inside HTML blocks in org-mode export to HTML. I'd like this... #+MACRO: event-url bar #+HTML_HEAD: <meta property="og:url" content="...
2
votes
0answers
99 views

noweb reference aware org-edit-special

Is there a way of splitting a src block into several blocks while keeping them together with noweb reference syntax and editing them using org-edit-special in such a way that would take into account ...
2
votes
0answers
604 views

use local tikz library in org-mode

would like to use a custom tikz library with org-mode. https://github.com/jluttine/tikz-bayesnet The following example works fine. :) #+begin_src latex :file fsa.pdf :packages '(("" "tikz")) :border ...
2
votes
0answers
41 views

Org-babel `set` src-block-info?

We have org-babel-get-src-block-info and org-babel-view-src-block-info. Is there anything similar to programatically (or preferably interactively) changing the choices from the src-block-info? If ...
2
votes
0answers
99 views

How to specify number of digits to print from a table using babel?

New to org/babel, so forgive me if this doesn't make sense. I have some code (in R) that produces a table. I also specify (in R) the number of digits that I want with options(digits = 2). When I run ...
2
votes
0answers
226 views

org-babel evaluation of code block always creates new window

Running org-ctrl-c-ctrl-c to evaluate a src block in an org file behaves strangely with windows. With a single window in the frame, it spawns a new window looking at the same buffer in a split and ...
2
votes
0answers
229 views

Stopping a runaway process using C-c C-c

When i evaluate some source code blocks using C-c C-c sometimes i might have an error and the system hangs on me . The only way to exit at this point is by quitting emacs. Are there any solutions to ...
2
votes
0answers
217 views

Format <<<target links>>> in org-mode for printing

Is there a way to format target links created by org-mode when using radio targets such as the following: <<<some text>>> where that some text is linked back When outputting to ...
2
votes
0answers
304 views

How do I get comments in a noweb expansion?

Given the org-mode file * File Description :PROPERTIES: :comments: org :tangle: file.sh :noweb: yes :END: ** A function call This is foo #+BEGIN_SRC sh :noweb-ref myfunction :tangle no ...
1
vote
0answers
28 views

Org-mode results verbatim not working for Scheme code

I have the following source block of Scheme code: #+BEGIN_SRC scheme :results value verbatim append (define shift (lambda (list-with-sublists) (cond [(pair? (car list-with-sublists)) ...
1
vote
0answers
12 views

Highlighting the currently active org-Babel block

I want to do something similar to hl-line-mode but not sure if it has been implemented already and how it can be implemented. The goal would be to set two color schemes for the #+begin and #+end ...
1
vote
1answer
37 views

Remove extra prompts in Emacs Babel Python session

When I run the following code block from Emacs org-babel: #+BEGIN_SRC python :session *Python* :results output print("Hello World") #+END_SRC This is what prints out in my *Python* session: >...
1
vote
1answer
39 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: : /|...
1
vote
1answer
68 views

Cannot add general block header arguments in org mode

While I'm learning javascript following a book, I Like to take notes with org-mode. I use Indium and followed this instructions to handle it working It works well, and I get my work done, interacting ...
1
vote
0answers
20 views

Spaces get trimmed when I use org table in (R) code block

Please, help! I use literate programming and I want to use org-mode tables as data for my R code blocks. However, when it comes to cell values that have meaningful leading and trading spaces org-mode ...
1
vote
0answers
17 views

tide-mode in org-edit-src-code

I want to activate tide-mode when using Javascript soruce code blocks, following this it works well with indium: https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-js.html But I want to use ...
1
vote
0answers
24 views

Leave noweb references in Org-Babel unevaluated with variables

I'm currently getting into Literate Programming with org-mode in Emacs. One of the key features to make it tractable as a programming style is macros. I would like to be able to do something like this:...
1
vote
0answers
29 views

Use result of ob-shell block in subsequent ob-shell block

#+BEGIN_SRC sh aws ec2 describe-instances #+END_SRC #+RESULTS: i-0154b911d1f4e0871 #+BEGIN_SRC sh aws ec2 terminate-instances "param1" #+END_SRC How can I use the result of the first block as the ...
1
vote
1answer
53 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 "...
1
vote
2answers
122 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 ...
1
vote
0answers
36 views

With org-babel how can I read a result block and pass arguments?

I asked a similar question a few years ago but I never did figure out how to proceed. I ended up aborting my excursion into org-babel. However, I can see how this would be really valuable, to ...