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
60
votes
4answers
16k 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
101 views

org-babel not concatenating strings before sending to code block variable

I have just started using org-mode and org-babel as a lab notebook. I am trying to use a code block to fill in two columns of a table. The code block seems to work for the first column because those ...
2
votes
1answer
180 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. ...
3
votes
1answer
110 views

org-babel for Jython?

Is there an org-babel for the Jython (not Python, it must be Jython) programming language? I am especially interested in session based evaluation for Jython. I am considering writing my own ob-jython....
1
vote
0answers
141 views

How to get org-mode to stop prompting me to save org-mode files that contain Babel blocks?

When I open an org-mode file that has a babel block in emacs-lisp format, afterwards, whenever I run save-some-buffers, I get the File to save in: prompt for the current org-mode file. I get this ...
9
votes
3answers
3k 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 ...
3
votes
2answers
759 views

Wrap org src block results

I'd like to include a custom latex wrapper around src blocks result. For example, given: #+BEGIN_SRC sh :results latex which awk #+END_SRC I'd like to generate #+RESULTS: #+BEGIN_LaTeX \begin{...
0
votes
1answer
445 views

Why is Org adding a label in custom Babel environment?

I can't tell in what update exactly did this happen but since not so long ago Org adds a label{orgsrcblock#} to custom listings environments. Unfortunately, I can't find a way to tell listings to ...
3
votes
0answers
135 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 # -- :...
2
votes
0answers
216 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 ...
10
votes
3answers
385 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 ...
23
votes
3answers
1k 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 ...
2
votes
1answer
133 views

Problem with add-to-list in babel src block

When I execute a babel src block with add-to-list function like this: #+begin_src emacs-lisp (add-to-list 'org-src-lang-modes (quote ("plantuml" . fundamental))) #+end_src I will get this error ...
5
votes
1answer
198 views

Support to refactor/convert source into literate programming with org-mode/babel?

I'm thinking of using literate programming to investigate large amount, or hard to understand source code. For the purpose, I'd like refactor the source code into literate programming text with org-...
7
votes
1answer
984 views

How to allow org-babel to play with python virtual environment?

I have virtual environment set on my system (actually virtualenvwrapper). I would like to direct org babel to use a specific environment in a single code block or on the whole buffer. How can I do it?
0
votes
1answer
279 views

Can org-babel 'result' not insert a newline at the end?

When I run a snippet of code (C-c C-c) (e.g. for making a PlantUML diagram), there is a trailing new line in the results, e.g.: #+BEGIN_SRC plantuml file hello.png ... #+END_SRC #+results [[img] &...
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 ...
3
votes
1answer
149 views

clockreport, total productivity by day?

With clock reports, one can set :step day, and then I have a list of totals by day. Like: #+BEGIN: clocktable :tstart "<-1w>" :tend "<+1d>" :step day :scope ("dev.org" "tst.org") :...
1
vote
1answer
650 views

Exporting the results of code evaluation in org-babel by default

I have these settings for evaluating emacs lisp code in babel: ELISP> org-babel-default-header-args:emacs-lisp ((:eval . "never-export") (:exports . "both") (:hlines . "yes") (:colnames . "no"))...
12
votes
1answer
601 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 ...
4
votes
1answer
437 views

org-mode: have flycheck resolve relative config while editing code blocks

Desired behaviour While editing code blocks with org-mode by pressing C-c ' I'd like Flycheck to resolve relevant configuration the same way it does for normal files. I'm using JavaScript, and these ...
4
votes
1answer
266 views

Export results of codeblock, then later export the source block (e.g. as for a code-listing in a document appendix)

I have a document in which I have named R source code blocks. These blocks are set to export the results only in the text narrative. However, I would like to include the code for these blocks in an ...
14
votes
1answer
489 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: #+...
2
votes
2answers
630 views

Linking to c++ libraries in babel code block

The title says it all, and I've included the relevant sections of my file below. I'm trying to create a src block that uses some functionality of the boost libraries, the first src block sets up the ...
7
votes
2answers
2k 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 ...
5
votes
1answer
2k views

Variables in Babel evaluation with SQL blocks

According to the org-mode manual, you can set variables in code blocks as follows: #+HEADERS: :var foo="blah" #+BEGIN_SRC elisp (message foo) #+END_SRC #+RESULTS: : blah However, when I try to do ...
2
votes
2answers
366 views

Is there a variable with a list of languages supported by Org-mode src-blocks?

In org-mode, is there a variable/const/whatever containing a list of all languages supported in "BEGIN/END_SRC" blocks? Are there any other methods to list them? (except parsing a list of ob-*.el ...
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 ...
8
votes
1answer
1k 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 ...
0
votes
1answer
414 views

*Org Src file.org[ R ]*: C-c ' is undefined

I'm trying to edit a code snippet in org-mode. When I type C-c ' in org mode buffer, it opens up the editor window in R-mode, but it doesn't know about C-c ' and cannot be killed by C-x k since when I ...
7
votes
1answer
720 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 ...
6
votes
1answer
1k views

Org code block receives table without header

I'm trying to send an Org table as a lisp object to a code block for further processing with an elisp function. For testing I set up two code blocks, one that generates the table and another that ...
19
votes
1answer
3k 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: ...
0
votes
1answer
163 views

How to bash command output that isn't STDOUT from babel shell command

Is this possible? For example, determining the version of anaconda: #+BEGIN_SRC sh :results output conda -V | grep "conda" #+END_SRC If I remove the grep part I get no output at all, with it I at ...
3
votes
0answers
163 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
0answers
301 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 ...
5
votes
1answer
2k 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-...
48
votes
6answers
11k 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 ...
4
votes
2answers
445 views

apostrophe in org-babel export to latex and beamer

How can I get org-babel to properly render ' and not ’ when exporting to LaTeX and to Beamer? I didn't find any good solution yet, and I would like the code to be copy-pasteable.
4
votes
2answers
380 views

Greek characters in graphs produced by org-babel and gnuplot

I can generate plots using gnuplot source blocks with org-babel like the following: #+begin_src gnuplot :file plot.png plot x w l t "$\epsilon$ = 1", \ 1-x w l t "ε = 0.1" #+end_src which ...
9
votes
1answer
2k 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 ...
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 ...
3
votes
2answers
2k views

org babel eval with no confirmation is explicit: :eval yes

According to fniessen's babel reference I should be able to set :eval yes on a babel header line to make a source block evaluate without confirmation. However, this doesn't seem to work for me on ...
2
votes
1answer
542 views

Calling the calc stack from babel: displaying percentages

Calc supports displaying results as percentages with c %. How can I make babel return this? I tried: #+BEGIN_SRC calc 1 2 '/ 'c% #+END_SRC But this just gives an error. I also tried with a space ...
1
vote
1answer
330 views

Babel doesn't wrap results in verbatim

Here's an example: #+NAME: sys5 #+HEADER: :exports both #+BEGIN_SRC maxima :results raw programmode: false; solution: triangularize(coefmatrix( [ -3*x - 11*y + 7*z = 0, ...
7
votes
2answers
381 views

Controlling the order of output with Org-Babel

Consider the following Org file: #+PROPERTY: tangle "init.el" #+PROPERTY: noweb yes * A #+begin_src elisp ; initialization code ; this *must* come first #+end_src * B #+begin_src emacs-lisp <<...
5
votes
2answers
1k views

Referring to the org-babel src block name from within the script

This is tangentially related to my previous question on dealing with asynchronous babel scripts. Currently I have to manually specify the name of the src block the babel function is in: #+name: elisp-...
7
votes
1answer
596 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 ...
12
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?
16
votes
2answers
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 ~/...