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.

Filter by
Sorted by
Tagged with
1
vote
0answers
22 views

How to pass through variables through src blocks to other src blocks

I am using Emacs version 26.3 and Org Mode version 9.3.6. My goal is to have several different #+CALL: lines, each using a different value of some header argument (in the example below, that is inarg)...
0
votes
0answers
18 views

Org babel: Use variable to set a figure caption

This is what I want to do: In some-file.org: * Table 1 #+NAME: table-1-title Characteristcs of Data #+BEGIN_SRC R :file table-1.svg :results output graphics file ( ggplot(mtcars, aes(mpg, cyl)...
2
votes
1answer
79 views

How can emacs org-mode execute shell code remotely as sudo?

My self-documenting maintainance scripts, where I document how systems have been setup, I need to execute stuff as sudo/root and want the results automatically added to the document. But for safety ...
0
votes
3answers
38 views

Org-babel loads different Python

I'm very new to org-mode and org-babel. After installing oh-my-zsh I noticed that I cannot run the source code in my org files like before. My code is like follows #+BEGIN_SRC python :results output ...
1
vote
2answers
41 views

Why does org mode elisp evaluation not print text properties?

With no special header argument values, I have #+BEGIN_SRC emacs-lisp (propertize "abc" 'face 'italic) #+END_SRC #+RESULTS: : abc whereas C-x C-e on the form gives me #("abc" 0 3 (face italic)) ...
1
vote
1answer
12 views

Org mode evaluating propertized string removes properties

See the following code block: #+BEGIN_SRC emacs-lisp (setq s #("abc" 0 3 (face (:foreground "red")))) (pp s) #+END_SRC #+RESULTS: : #("abc" 0 3 : (face : (:foreground "red"))) which is as ...
0
votes
1answer
29 views

org-mode: link to tag/target inside a source code block

I'd like to place a link to a tag or target inside a source code block. #+BEGIN_SRC emacs-lisp (use-package evil :ensure t :config ; enable per default (evil-mode ...
0
votes
0answers
17 views

Enable trace-function from org-mode

I test the following procedure from org-mode #+name: case-2.1.1-factorial.el #+BEGIN_SRC elisp (defun factorial(n) (if (= n 1) 1 (* n (factorial (- n 1))))) (trace-function #'factorial) ...
1
vote
0answers
16 views

org-babel python :session names matter

For example, I get #+BEGIN_SRC python :session sdfjkl :results output import numpy #+END_SRC #+RESULTS: : Python 3.8.0 (default, Oct 23 2019, 18:51:26) : [GCC 9.2.0] on linux : Type "help", "...
0
votes
0answers
25 views

Maxima org code blocks on windows

I'm new to emacs, coming from vim, using spacemacs atm. My problem is that when I try to evaluate maxima code blocks in emacs, for example: #+begin_src maxima a: 1+1; print(a); #+end_src I get the ...
2
votes
2answers
121 views

Org-Babel Javascript error

I am having trouble getting the simplest Javascript source block in org-mode to run. #+begin_src js console.log("Hello"); #+end_src I always get this error: /tmp/babel-8kqQwQ/js-script-...
0
votes
2answers
53 views

Adding header to a org-mode tangled file

I am generating source code files from an org-mode file using org-babel-tangle. How do I add headers to the files e.g. for python # This is a generated file do not edit for emacs lisp similar ...
3
votes
3answers
255 views

org-mode code block parentheses mismatch

Here's some emacs-lisp code in a babel block: #+begin_src emacs-lisp (defun factor (number) (labels ((*factor (divisor number) (if (> (* divisor divisor) number) (list ...
0
votes
1answer
22 views

How to change Org-mode babel tangle write to file way as prepend instead of override by default?

There's an answer here for appending the current code block to an existing file. I want to do the opposite, which is to prepend the current code block to an existing file. Could you please help?
0
votes
0answers
12 views

org-agenda loaded from init.el but not configuration.el (babel)

I structure my configuration with an (org-babel-load-file "~/.emacs.d/configuration.org") so I write my code in the configuration.org and then a configuration.el gets generated. It works with the ...
1
vote
1answer
49 views

Add timestamp to file name in org export

How can I create a time stamped file name with the org header arg: #+export_file_name: <timestamp-var> + File name There is a variable org-time-stamp, is there a way to append it to the static ...
0
votes
1answer
29 views

Attempting to use org-babel to write “literate” Rust

I'm playing around with writing Rust snippets in my editor. I can get org mode to format my things nicely and play nicely with rust-mode. But I can't evaluate my code snippets. I think that may be ...
1
vote
0answers
19 views

Multiple insert point org source code insert

I know that we can customize the source code expansion <s TAB using something like this (add-to-list 'org-structure-template-alist '("s" "#+BEGIN_SRC ? :results raw replace drawer ...
2
votes
0answers
26 views

org-babel-tangle-file multiple files into a single output

Is there a way to tangle an org file with #+INCLUDE: statements? Or other ways to tangle multiple org files into a single output?
2
votes
1answer
19 views

Error: No org-babel-initiate-session function for bash!

I would like to use the session feature for bash source blocks, and receive the error message. No org-babel-initiate-session function for bash! A simple code is shown below. The code can be executed ...
3
votes
2answers
43 views

Change behaviour of “comment-region” in org-mode tangled source blocks?

I am experimenting with using org-mode for some of my startup config, and adding (org-babel-load-file (concat user-emacs-directory "config.org")) to my .emacs. Then I use a structure like the ...
4
votes
1answer
58 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 ...
1
vote
1answer
36 views

How to switch org-babel-execute-src-block to use y-or-n-p?

In short, I want org-babel's prompt to accept a single y/n keypress instead of typing it out and pressing enter, but I don't want to replace all such prompts globally. I've seen information on ...
1
vote
1answer
21 views

Customize org babel execution command in C

I have the following C code: #include <stdio.h> #include <math.h> int main(){ printf("Square = %d", pow(4,2)); return 0; } Now if I run this in the shell. I would first compile ...
3
votes
1answer
359 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 :...
1
vote
1answer
42 views

Org-Babel Unable to Tangle to Write-Protected Folders?

I'm trying to move my OS configuration over to org mode, and in the process I'd like to be able to tangle to write-protected directories like /etc Unfortunately, tangle doesn't seem to work whenever ...
2
votes
2answers
39 views

org-mode call python source within latex source block

I have a piece of python code that outputs latex code. I'm trying to call the python source block from within a latex source block so it will format the output as latex when I export. Any idea how ...
2
votes
1answer
86 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?
16
votes
2answers
3k views

Python org-mode source block output is always ': None'

This is my source block: #+BEGIN_SRC python print "hello" #+END_SRC The output is always: #+RESULTS: : None This is my org-babel configuration: (org-babel-do-load-languages 'org-babel-load-...
1
vote
1answer
31 views

Get value of a variable from another session in org-mode

How to share variables' values in org-mode between different sessions? Simple example: in session one I create _gpg_tmpdir #+name: make_temporary_directories #+begin_src bash :session *one* ...
1
vote
1answer
100 views

Org Mode: reference an org tree for input in code block

I want to use a (sub)tree of my org file as an imput to a python babel source block to parse it and to stuff with it (in my case generate a folder structure based on the headlines of that tree). I ...
0
votes
1answer
49 views

Managing path for reproductible scientific paper using session, org-babel and org-mode

I'm starting using org-mode and org-babel to support my day by day scientific work and produce reproductibles papers. Lot of people use rMarkdown/jupyter to do that, but i'm interested by investing ...
69
votes
5answers
20k views

Quickly insert source blocks in org mode

org-mode has the ability to render source code, with blocks of the following syntax: #+NAME: <name> #+BEGIN_SRC <language> <switches> <header arguments> <body> #+...
1
vote
1answer
19 views

What is the `'inf-template` file in the ob-template.el file (template for creating new babel language)

Because the options provided by the mathematica.el file in org-contrib are quite limited, I am trying to create a new, extended, mathematica.el file. As explained on the org language development page, ...
0
votes
0answers
30 views

how to not html export src block result in org-babel

I'm using emacs version 26.3 with org-mode version 9.1. how to stop from exporting #+RESULTS and export only code block. #+BEGIN_SRC python :results output print('hello world') #+...
9
votes
2answers
580 views

Config, examples and use cases of Library Of Babel

I want to understand how org-babel's Library Of Babel works. Seems like a powerful yet underused tool. The documentation says that I can add code to the library, by first saving the code in ...
4
votes
1answer
244 views

Is it possible to have shared #+PROPERTY: between multiple org files?

I'm working with org-mode and org-babel to query a PostgreSQL database. It's pretty cool setup and I love it. At the moment, I have multiple org files with the same database property configuration ...
1
vote
1answer
88 views

rewrite relative or absolute path from inherited tramp ssh property with org-babel

I define a global remote session for all my sh block code with properties :PROPERTIES :HEADER-ARGS:bash: :dir /ssh:xxx@myvm:/home/xxx/ :END: In my other bash blocks, I inherit this property, but ...
0
votes
0answers
14 views

Record command into bash source block using asciinema and org-babel

As you perhaps know, asciinema rec (asciinema rec path/to/file) and generate an asciicast file which contain all commands recorded on terminal. I think using asciinema to replay this file (asciinema ...
-1
votes
1answer
106 views

ob-async issue, seq-random-elt not defined

I would like to asynchronously run code blocks in org mode. My org mode version (org-version output) is: Org mode version 9.2.1 (9.2.1-23-g126a37-elpa @ /home/user/.emacs.d/elpa/org-9.2.2/) I ...
1
vote
1answer
26 views

“Run all code blocks above this point” in org-babel?

I know you can use org-babel-execute-src-block (C-c C-c) to execute individual code blocks, but is there something akin to "Run all chunks above" that RStudio has for Rmarkdown files?
0
votes
2answers
306 views

ledger in org-babel blocks uses incorrect path data in Windows 10

I am trying to include a ledger data file from an org-babel block. I am using Windows10 and the SciMax emacs distribution. #+begin_src ledger :cmdline bal :results output :exports results !include d:/...
1
vote
0answers
32 views

Can I specify tags as a property to avoid cluttering the headline?

Having tags in the headline clutters the view and is quite distracting when the tags are not directly pertinent to it. An example of this is the noexport tag which describes what to do with the ...
0
votes
1answer
31 views

Org entry found only from its own buffer [duplicate]

I tried to detangle (org-babel-detangle) a latex file and got the error message Cannot find entry with ID "......." with the ID of the subtree of the first block. But the entry does exist in the ...
15
votes
1answer
1k views

Is it possible to org-bable-tangle an org file from the command line?

I would like to manage the tangling my org files with a Makefile. Though I can not find any information of how to tangle files from the command line.
1
vote
1answer
51 views

Org-mode: use result from babel in another programming language

Org and babel in emacs are awesome. Is it possible to have something like this: Here is a C code #+BEGIN_SRC C :output results #include <stdio.h> int main(){ int x = 5.00; int i; ...
0
votes
1answer
18 views

org-mode capture click event within org-babel code block

I wish to run C-c C-c, then click any code line to trigger my code (print "clicked" in this demo) #+BEGIN_SRC elisp :results output (defun myclick(n) (interactive "p") (print "clicked") ) (add-...
1
vote
1answer
70 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
38 views

Write text between inline exported code and the result of this execution code?

After some search, i don't found example corresponding to my use case. Writing a research text, i'm interested to mix source blocks code and text with results using inline mode, for example this ...
1
vote
1answer
92 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
2 3 4 5
11