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
104 votes
7 answers
46k 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> #+...
Matthew Piziak's user avatar
56 votes
6 answers
22k views

Can I use org-mode to structure my .emacs or other .el configuration file?

My .emacs configuration file gets bigger and bigger and I'd like to get a better overview and structuring by adding headings, subheadings and being able to hide or show them like I can do with Emacs ...
MostlyHarmless's user avatar
45 votes
6 answers
12k views

Org-mode 9: unable to eval code-blocks

My Emacs config lives inside of a .org file from which I tangle source blocks to a .el file. I could evaluate source blocks with C-c C-c Today I updated to org-mode version 9 from org elpa and now ...
rrogg's user avatar
  • 595
31 votes
4 answers
3k views

Smooth (mouse) scroll for inline images?

I display images in-line with begin_src & result blocks. However, for large-images, when I scroll past the bottom of the image, I get a 'jerk' and the whole image is scrolled away. Similarly if I ...
Leo Ufimtsev's user avatar
  • 4,568
26 votes
2 answers
6k 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-...
Empty_Mind's user avatar
  • 1,371
24 votes
2 answers
8k views

How to specify default header arguments in orgmode code blocks

I'm tying to set default header arguments to the code blocks within my org file, like this: #+PROPERTY: header-args :session *my_python_session* #+PROPERTY: header-args :results silent #+PROPERTY: ...
andreas-h's user avatar
  • 1,569
23 votes
2 answers
21k views

"no org-babel-execute function for c" and "no-org-babel-execute function for c++"

my emacs version is 24.3.1. i understand i have to put the ob-C.el (available from here) in a path where Emacs can read it. i first copy-pasted the code from that .el file to my .emacs file and ...
Arjun J Rao's user avatar
21 votes
2 answers
6k views

Using Org Babel to tangle to a variable file name

If I have a code snippet that I tangle to a file, but I expect the file name to change over time, Is there a cleaner way to change the filename than Query-replace? For example, say I tangle code to ~/...
Gambo's user avatar
  • 939
21 votes
1 answer
6k views

How can I stop the confirmation to evaluate source code when exporting to html?

I have an org document that contains a lot of source code snippets in it. I want the results of the code to be exported when exporting to Html. On export Emacs asks me if I want to evaluate the code ...
Mongus Pong's user avatar
20 votes
2 answers
4k views

Can I include a common code block in two different code blocks in Org mode?

I have an org-mode file containing a table of data and two Python code blocks to extract different summaries from it. I would like to share some common constants and functions between these two code ...
user avatar
19 votes
2 answers
3k views

Does org have any "inverse-tangle" operations e.g. for collaborating with non-org users?

I would like to write my own notes/tests/code in org and then use org-bable-tangle to produce source files. However, all of these files are subject to version control and hence subject to change from ...
RJTK's user avatar
  • 293
19 votes
1 answer
4k 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.
lookyhooky's user avatar
19 votes
2 answers
3k views

Async execution in org babel

Is there a good general customization of org-babel to run asynchronously? Recently I plan to use MATLAB via org-babel, but I would like it in an async manner, since some calculations do take time. I ...
diadochos's user avatar
  • 631
19 votes
1 answer
1k views

Set default language for code-blocks in orgmode

Is there a way to define a default language for org-mode code blocks in the docuement header? Usually, within one org document, I only use one programming language, so it's getting tiresome to always ...
andreas-h's user avatar
  • 1,569
18 votes
2 answers
5k views

Display errors and warnings in an org-mode code block

I would like to be able to report warnings and errors when evaluating a Python code block in an Org file. When a code block has Python syntax errors, Org helpfully pops them up in a separate ...
user avatar
16 votes
3 answers
3k views

Can org-babel results be output as code comments?

In blogs, textbooks, etc, it's really common to display the results of some code as comments, e.g.: (+ 1 1) ;=> 2 Is there a way to display results like this automatically using Org-Mode's Babel ...
parkeristyping's user avatar
16 votes
1 answer
722 views

Generating output in a different language with org mode

Given the following is intended to generate C++ code: #+BEGIN_SRC python :exports both :results output code print "struct Whatever{};" #+END_SRC The result is inserted as follows: #+RESULTS: #+...
Sohail's user avatar
  • 503
16 votes
2 answers
3k views

Debugging code blocks in org mode

Are there any tools available to make tracing errors in org-mode blocks easier? (I'm working with python specifically) My current workflow is to copy code that works to a source block, and try to ...
user2699's user avatar
  • 2,251
15 votes
2 answers
4k views

Is there a way to make Org mode ignore src blocks when exporting to html?

I have an org document with scattered with source blocks that I'd like excluded when I export the file to html. Is there a variable or option I can set which will ignore the src blocks? I have tried ...
Grassdog's user avatar
  • 153
14 votes
1 answer
7k views

What is the difference between sh and shell for org-babel?

I'm experimenting with sourcing data from org-mode into my shell scripts and I've run across a weirdness: #+tblname: simple-table | 1 | | 2 | | 3 | | 4 | | 5 | #+name: work-with-simple-list-shell #+...
stsquad's user avatar
  • 4,661
14 votes
2 answers
3k views

How to execute sudo command in org-babel in relative path under current working directory

I want to execute sudo command in org-babel like this: #+begin_src shell :dir "/sudo::" :cache no make sudo make install #+end_src It works fine. It use TRAMP /sudo: method. But I need to execute ...
stardiviner's user avatar
  • 1,948
14 votes
3 answers
3k views

Code-block specific interpreter in Org Babel

Is it possible to have, in the same org file, two code blocks in the same language that are run in different interpreters by specifying different options at the top of the code block?
cefstat's user avatar
  • 251
14 votes
1 answer
1k 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 ...
atevm's user avatar
  • 948
13 votes
5 answers
4k views

Org Mode Babel - Interactive code block evaluation in Python

Similarly to this question I would like to evaluate (in org mode) Python source code blocks containing "input" instructions but I can't find a way to have an interactive evaluation (with user input) ...
Lgen's user avatar
  • 1,420
13 votes
5 answers
3k views

Org-mode: pipe source block output as stdin to next source block

I try to pipe the output of one source block to the next source block as standard input. Here an example of what I have so far: Create stdin data: #+header: :exports code #+header: :results output #+...
theldoria's user avatar
  • 1,845
13 votes
3 answers
2k views

Syncing changes on a tangled file back to the original org file

I am using org-mode with fountain mode to write a screenplay. Org for organization and fountain for screenplay formatting. This is the code I use for this purpose : Settings for working with (...
curious-scribbler's user avatar
13 votes
1 answer
4k views

How to get org-babel source block working with ES6-7?

I'm having difficulty getting org-babel to evaluate this block of code with emacs v24.5 node v5.0.0 babel-node v.6.6.5 #+BEGIN_SRC js :cmd "babel-node" let arr = [1, 2]; let [x, y] = ...
Johnathan Foong's user avatar
12 votes
4 answers
3k views

Org Mode Babel - Interactive code block evaluation

I would like to evaluate in org mode source code blocks in C++ containing "cin" instructions but I can't find a way to have an interactive evaluation (with user input) during evaluation. Example of ...
Lgen's user avatar
  • 1,420
12 votes
2 answers
1k views

Generating tables with headers from code block

I would like to generate tables that have headers from code blocks. Something like this: #+BEGIN_SRC emacs-lisp :results value table :table-header | First | Second | (identity '((a b) (c d))) #+...
tarsius's user avatar
  • 25.8k
12 votes
4 answers
2k views

Clojure code evaluation in org-mode produces no output

I am trying to run clojure code from my org file in order to do some literate programming. What is not working: When I execute the source code block I get No output produced. Sample src code block ...
Jeel Shah's user avatar
  • 195
12 votes
0 answers
1k 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 ...
Tobias's user avatar
  • 33.3k
11 votes
3 answers
5k views

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

By default, Org-mode will override current babel src block content on file original content (when the file already has content). For example, I have an org-mode file content as the bellowing block: #...
stardiviner's user avatar
  • 1,948
11 votes
1 answer
2k views

How to turn off `emacs-lisp-checkdoc` of flycheck when edit source block in org-mode file?

I have a emacs-lisp block in org-mode and when I try to edit it by press C-c ', flycheck always report errors as below: 0 warning The first line should be of the form: ";;; package --- ...
Enze Chi's user avatar
  • 1,470
11 votes
3 answers
5k views

With org-babel, how to name the results of a function call and reuse them

In org-mode, I am trying to define a function, a variable, and then assigning to another variable the result of the function call on the first variable. However, then it seems that I cannot use this ...
T. Verron's user avatar
  • 4,293
11 votes
1 answer
2k views

Is it possible to read user input from STDIN while tangling a source block?

Is it possible to read user input from STDIN while tangling a source block with org-babel-tangle? I am aware of this: Org Mode Babel - Interactive code block evaluation. That doesn't help solve this ...
gsl's user avatar
  • 1,772
10 votes
2 answers
2k 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 ...
Daniel's user avatar
  • 3,653
10 votes
2 answers
3k views

org-babel result to a separate buffer

I use org-babel to generate some reports which can't be automatically processed, and since org is a good outline format, I print the results in org to represent them as trees. I've noticed that ...
Roman Grazhdan's user avatar
10 votes
1 answer
2k views

Can Org Babel conditionally tangle code blocks based on system-type?

Edit: While I'm still learning the ropes of Babel, I've read about the system-type, emacs-version, and window-system variables, which sound like they contain all the information I need to get the ...
Dan's user avatar
  • 243
10 votes
2 answers
3k views

org-babel and remote sql commands

I'm using org-babel to do litterate programming and I find it very convenient. I am able to execute shell commands on remote hosts, and local database commands with the postgres client. To open a file ...
KookieMonster's user avatar
10 votes
3 answers
704 views

Editing multiple source blocks in one buffer

I've got multiple source blocks which are all tangled to the same file. When I invoke C-c ' inside one block, only this specific block is shown in a new buffer. Is there a possibility to show all ...
beyeran's user avatar
  • 231
10 votes
1 answer
1k views

Using org-src-preserve-indentation only on specific code blocks (or buffers, or anything beyond the global context, really)

I've been Googling and digging through the org-babel docs, but it's coming out with not a lot. The thing is, one of things I'm working on is using org-babel to tangle Makefile source. In it, the ...
Tariq Kamal's user avatar
10 votes
1 answer
3k views

How to pass environment variables to org source BASH script block?

I have an org-mode file that contains a BASH script in an org-babel source block. I would like to pass environmental variable values to it through :var. something like: #+begin_src sh :var VAR1="~...
Enze Chi's user avatar
  • 1,470
9 votes
3 answers
2k views

Is it possible to enable minor modes in org babel blocks?

I use org-edit-special and it's really convenient, when editing source code, that's stored in org files. However I often only want to copy some code and I'm used to the highlighting of highlight-...
bertfred's user avatar
  • 1,729
9 votes
2 answers
2k views

Programmatically read and set buffer-wide org-mode property

How one can programmatically read and set a buffer-wide org-mode property? I am aware of this, which points to (org-entry-put POM "PWE-1" "47") but it does not seem useful in case ...
gsl's user avatar
  • 1,772
9 votes
2 answers
3k views

Can org-babel replace code with code output on html export?

I'm using org-mode to generate web pages of my notes. Can I embed code to generate additional HTML, etc? org-babel will generate results but it seems to show the results in addition to the code. I ...
h4labs's user avatar
  • 269
9 votes
1 answer
3k views

Efficient workflow to write a book in Org-mode

I plan to write a short statistics textbook using Org-mode. Even if some textbooks have been written using equivalent systems (e.g., the R package bookdown), I have no examples in mind of books ...
Philopolis's user avatar
  • 1,134
9 votes
1 answer
3k views

How to display both output and value results in org mode for a source code block?

I have the following: #+BEGIN_SRC lisp :results value (dolist (x '(1 2 3)) (print x)) #+END_SRC #+RESULTS: : NIL I want my results block to contain both the output and the value for my ...
Allama's user avatar
  • 93
9 votes
2 answers
3k views

live refresh of inline images with org-display-inline-images

Recently I've noticed the function I had been using to do refresh had stopped working and I had to change to a simpler call. I used to have: (defun k/org-babel-refresh-inline-images () (org-...
wdkrnls's user avatar
  • 3,707
9 votes
1 answer
837 views

Can I alias a language for org-babel SRC blocks?

I've got a new language I'm working on that I'm documenting in an Org file. Code samples for this language can be written in lisp-mode, but I want to use the new language's name for the SRC blocks ...
Sean Allred's user avatar
  • 6,951
9 votes
1 answer
2k views

Automatically tangle org files in a specific directory

I'm converting my dotfiles to org-babel files because I really enjoyed rewriting my Emacs configuration in it, and I have a function for the init.org that automatically tangles it whenever I save. ...
Sondre Nilsen's user avatar

1
2 3 4 5
17