Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

51
votes
4answers
11k 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> #+...
47
votes
5answers
10k 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 ...
44
votes
6answers
8k 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 ...
22
votes
3answers
851 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 ...
16
votes
1answer
2k 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: ...
15
votes
1answer
2k 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 ~/...
13
votes
1answer
396 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: #+...
13
votes
1answer
793 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.
13
votes
2answers
1k 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 ...
12
votes
3answers
711 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 ...
12
votes
1answer
736 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 (...
11
votes
2answers
2k 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 ...
10
votes
3answers
971 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 ...
10
votes
2answers
757 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))) #+...
10
votes
1answer
7k 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 ...
10
votes
4answers
960 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 ...
10
votes
3answers
2k 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?
10
votes
1answer
481 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 ...
10
votes
1answer
832 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 ...
9
votes
3answers
2k 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 ...
9
votes
1answer
361 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 ...
9
votes
2answers
961 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 ...
9
votes
2answers
764 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 #+...
9
votes
1answer
1k 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 #+...
9
votes
1answer
781 views

Code blocks that produce org tables to be later consumed by other code blocks

I am having a bit of trouble with code blocks that produce org tables to be later consumed by other code blocks. For example: #+NAME: upper_air #+BEGIN_SRC clojure :results output raw (clojure....
9
votes
1answer
767 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 ...
9
votes
1answer
333 views

Edit multiple occurences of the same tangled file 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 ...
9
votes
1answer
289 views

Make consistent syntax highlighting of LaTeX source blocks

Org manual's solution for syntax highlighting of org-babel code blocks is to turn on native fontification with (setq org-src-fontify-natively t) works well for LaTeX code enclosed in blocks with #+...
8
votes
4answers
1k 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) ...
8
votes
2answers
2k 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-...
8
votes
1answer
424 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 ...
8
votes
1answer
1k 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 ...
8
votes
1answer
117 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 ...
8
votes
2answers
526 views

How to automatically tangle another source block to file when evaluate a source block in org-mode?

The source block what I want to evaluate (src2) need to source a file which should be the tangle result of another source block (src1). How could it make the tangle to file automatically everything ...
8
votes
1answer
998 views

How to force an org-babel session to reset or initialize?

If I run the following babel shell blocks #+BEGIN_SRC sh :session one :results output ssh staging #+END_SRC #+BEGIN_SRC sh :session one :results output hostname #+END_SRC Org creates a shell ...
8
votes
0answers
391 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 ...
7
votes
3answers
696 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-...
7
votes
2answers
1k 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 ...
7
votes
2answers
1k 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 ...
7
votes
1answer
406 views

Org-mode code blocks do not inherit variable properties from enclosing nodes

When playing with the literate aspects of Org-mode I found a description here of how you can set up a var property of a node and how this would then be inherited by enclosed code blocks as a variable ...
7
votes
1answer
774 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. ...
7
votes
1answer
2k views

Execute src block on org mode export

I have some sort of fundamental confusion about using src blocks in org mode. I define a custom latex class in an emacs-lisp src block at the top of my org file. Export fails however, unless I ...
7
votes
2answers
170 views

Insert noweb references with completion

I have discovered the noweb syntax, and in particular how it can be used in org source blocks, very recently, and I have grown quite fond of it. But inserting the references (is there a better term?) ...
7
votes
1answer
227 views

One-liner org source tangle

At times, especially when taking notes, a literate org file can contain one-line source blocks, as follows: * Taking notes :PROPERTIES: :tangle: whatever.pl :comments: org :END: Perl set command #+...
7
votes
1answer
2k 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] = ...
7
votes
1answer
562 views

Returning org-babel results from an asynchronous call

I'm currently experimenting with moving more of my development workflow into org-mode so I can keep better track of what testing I've done. However some of the steps involve asynchronous calls to RPC ...
7
votes
1answer
691 views

working setup for ipython in babel

Can someone point me to a working setup for using babel with IPython? I'm witnessing strange indentation behavior when I try to define functions. This happens whether or not I specify the --classic ...
7
votes
1answer
173 views

Converting cURL command to ob-http

I have a whole series of curl commands that I would like convert into ob-http code blocks in a org file (second choice would be to do them in restclient). Here is a simplified sample command: curl -...
7
votes
2answers
177 views

It is possible to instrument a literate Org-mode configuration file with a backing Emacs Lisp file?

It is a common practice to write Emacs configuration files using literate-programming style in Org mode. Unfortunately, while improving readability, this comes with significant programming ...
6
votes
1answer
2k views

Centered figures in org-mode LaTeX export

When org-mode exports figures to LaTeX, the figure shows up left justified. Is there an easy way to have all the figures centered? I want to avoid having to type #+ATTR_LATEX: :float t above each ...