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> #+...
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 ...
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: #+...
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 ~/...
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 ...
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 ...
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: ...
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 ...
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 ...
4
votes
3answers
900 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: #...
3
votes
1answer
2k views

Exporting code blocks to pdf via LaTeX

I am writing a report in org mode and would like to show some code blocks as seen in so many tutorials. Here is some official documentation, however it was written for org-mode 6.xx back in 2011. I ...
2
votes
1answer
1k views

Specify global tangle file for source code export in Org mode 8.x

I want to specify a default output file for all my tangle exports. I'm using Org mode 8.x. (For Org mode ≥9.0, see How to tangle all code blocks to a common file) This works: #+BEGIN_SRC js :tangle "...
1
vote
1answer
66 views

How to pass newline (“\n”) string to noweb <<call>>

Trying to pass multiline argument to Org code block. If make direct call of block then it's Ok. But when call it through noweb ref then Error raised #+NAME: pr #+BEGIN_SRC elisp :results value :var n=...
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 (...
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 ...
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 ...
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))) #+...
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 ...
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 ...
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 ...
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
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 #+...
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 ...
3
votes
1answer
528 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 of buffer global ...
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 ...
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-...
5
votes
1answer
1k views

Org-babel invoking cmd.exe

Is there a simple configuration to get org-babel to invoke cmd.exe that doesn't involve modifying the org-babel source? Googling for ["org-babel" sh "cmd"] finds this email list discussion from 2010: ...
4
votes
2answers
783 views

Org mode converting spaces to tabs when evaluating source?

I am testing out the Babel feature in org-mode, with this small block. #+BEGIN_SRC sh :results verbatim :exports both banner -w 35 e ...
3
votes
0answers
119 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$_{\...
2
votes
2answers
556 views

How do I insert code block header :var in exported code block in org-mode

GNU Emacs 26.0.50.2 (x86_64-pc-linux-gnu, GTK+ Version 3.18.9) of 2016-10-06 Org-mode version 8.3.5 (release_8.3.5-1131-g7eecb2 @ ~/.emacs.d/el-get/org-mode/lisp/) I have come to share my projects as ...
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 #+...
4
votes
1answer
158 views

Org-Mode: Using Source Code Blocks in Table Formulas

I would like to use source code blocks in org-mode table formulas using something similar to: #+NAME: square #+BEGIN_SRC python :var x=0 return x**2 #+END_SRC | 1 | 1 | | 2 | 4 | | 3 | 9 | #+TBLFM: $...
3
votes
1answer
336 views

Buffer-local tangle in org-mode

When using Org-mode 8.2.10, setting the header-args property does not seem to work as expected with Common Lisp code blocks. The following does not tangle the code blocks in the file: #+PROPERTY: ...
2
votes
1answer
34 views

Can I insert a prefix to Org Babel source code lines on export?

Like, say I have a shell script source code block. #+BEGIN_SRC shell echo 'Hello World!' #+END_SRC On export, I want the code text to pick up a dollar sign, so $ echo 'Hello World!'. But I only ...
1
vote
1answer
35 views

How to generate the result file for dot source block and include it with another path in org-mode?

I'm starting to write blogs with org-mode and org-static-blog, but now I'm stuck with a problem respecting exporting graphviz dot file to image file. So I have a code block like this with (setq org-...
1
vote
1answer
186 views

Getting maxima source block to return and display latex equations

I'd like my maxima source blocks to return either valid latex that I can display in the org-buffer, or an image of the results (a la imaxima). Ideally, the pure latex solution would be best. Here is ...
1
vote
1answer
311 views

org-babel-load-file doesn't load entire file

In ~/.emacs.d/init.el I'm calling my annotated configurations file settings.org like so: (require 'ob-tangle) (org-babel-load-file (expand-file-name "~/.emacs.d/settings.org")) This generates ...
1
vote
2answers
101 views

Is there a way to use org-mode to render generated code? [duplicate]

I'm new to org-mode, so I apologize if this is a silly question, but I couldn't find the answer on my own. I have the following block: #+BEGIN_SRC sh :exports both :results output verbatim code sed '...
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-...
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 ...
3
votes
1answer
389 views

Tangling fundamental source blocks with org-header like code

I have a code blocks for a domain specific input files that I want to have in a single org file and tangle them out to separate files (see Tangling non-code files to separate files). However, my ...
2
votes
1answer
139 views

Tangling non-code files to separate files

I have a number of parameter files that my code needs as inputs and I would like them all to be in the same org file in different blocks and have them all tangled to different files. Can I somehow ...
2
votes
1answer
156 views

Does org-babel for groovy take arguments?

I am trying to pass an argument to a groovy babel block but I'm not sure it accepts arguments? The documentation says that it is language-specific but I didn't find any documentation for ob-groovy. ...
1
vote
1answer
458 views

org-edit-src-code Do not pop a new window, use the current one

When I call org-edit-src-code to edit a SRC code on a buffer with the proper major mode, I get a new window configuration. For example, if I have windows 1|2, org-edit-src-code will delete window 2 ...
1
vote
1answer
286 views

org-mode table-formula and code-blocks: function parameter is cut off on whitespace

In Org-mode working with 'src' code blocks and table formulas together, org-mode cuts of the cell strings at the first whitespace character. I.e.: having a cell with Hello World the 'src' code block ...
1
vote
0answers
162 views

How is #+BEGIN_SRC sh :results drawer different to #+BEGIN_SRC sh

While reading http://www.howardism.org/Technical/Emacs/literate-devops.html I saw the author recommending #+BEGIN_SRC sh :results drawer for "time-consuming and verbose" commands. (I do a ...
1
vote
1answer
621 views

No org-babel-execute function for calc?

In org-mode: #+BEGIN_SRC calc :var x=5 :var y=2 2+a*x**y #+END_SRC returns No org-babel-execute function for calc! How do I enable calc for org-babel-execute?
0
votes
1answer
364 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 ...
0
votes
1answer
118 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:/...