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.

5
votes
2answers
234 views

Org-mode header properties from .authinfo.gpg?

I was just looking at This literate SQL / org-mode example and see that org-mode supports username and password fields in a SQL source code block. As illustrated there: ** MySQL Analysis :...
6
votes
1answer
1k views

How to execute named code blocks written in any language using a shell script?

History Recently, I cobbled together a shell script that can execute a named code block from inside an org-mode file using the command-line. I copied source code directly from the org-mode manual ...
3
votes
2answers
433 views

Problems with org-ctrl-c-ctrl-c and Org 9.0

I recently installed Org 9.0 and ‘org-ctrl-c-ctrl-c’ often complains about user-error: ‘C-c C-c’ can do nothing useful here. However when I use it repeatedly it works suddenly, although I didn't ...
1
vote
1answer
1k views

Error on using org-babel-load-file

I am trying to write emacs init using Org-mode By using org-babel-load-file function in init.el. My init.el file is (require 'package) (add-to-list 'package-archives '("melpa" . "https:...
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?) ...
6
votes
1answer
1k views

How to add org-babel-execute function for plantuml?

I installed "PlantUML Mode for Emacs" using Melpa successfully, and I am able to switch to Plantuml-mode. However, when I try to evaluate code with C-c C-c, inside of org-mode, I get the error: org-...
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 ...
1
vote
1answer
2k views

Getting Python list output into column table instead of row

I've got some Python source code blocks in my Org mode document and when I print lists as output I get an org table of one row with all elements (regardless of whether I create a session or not): #+...
1
vote
1answer
108 views

Why is org-table-calc-current-TBLFM throwing Wrong type argument: integer-or-marker-p Error?

Why does my code generate the error when used with org-table? No error message when code used outside of org-table #+NAME: get-country-or-area-name #+HEADER: :var iso-alpha2-code="ca" #+HEADER: :...
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-...
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: #...
1
vote
0answers
170 views

How can I format the results of a code block in Org-mode?

Consider for the sake of an example the following code block: #+BEGIN_SRC scheme :exports both (atan 0.0 -1.0) #+END_SRC When I export this file, Org inserts the result (which is the number Pi) ...
3
votes
1answer
170 views

What's the proper new-style form for passing header args to all sql code blocks?

I guess I've been out of the loop for a while. I used to have this at the end of my org-mode SQL files: #+PROPERTY: engine mysql #+PROPERTY: dbhost xx.xx.xx.xx #+PROPERTY: dbuser xxxxxx #+PROPERTY: ...
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 ...
2
votes
0answers
37 views

Org-babel `set` src-block-info?

We have org-babel-get-src-block-info and org-babel-view-src-block-info. Is there anything similar to programatically (or preferably interactively) changing the choices from the src-block-info? If ...
0
votes
1answer
439 views

Evaluating python block at module level

So apparently org-babel is evaluating python code inside its own function, perhaps when calling the interpreter or to be able to return the #+RESULTS: I guess. How to instruct it to evaluate the same ...
2
votes
1answer
258 views

How to get babel code blocks to evaluate parameters when called from a noweb ref?

I have an interesting problem that I am sure there must be a simple answer to if I can find the right syntax. Essentially, as outlined below, I have a simple sh code block that prints a variable that ...
0
votes
1answer
334 views

orgmode: set global BABEL parameters?

I am trying to setup like the following in the top section of my .org file. But it does not work, all the parameters are not passed into the subsequent R code blocks. #+BABEL: :session *R* :cache ...
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.
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) ...
2
votes
1answer
710 views

How to run the tangled file?

How does one run the arbitrary command to execute the tangled code? I use Emacs both on Windows and Linux, but currently I need to run the generated batch file in particular Windows environment. Here ...
0
votes
1answer
36 views

Why do I get random white space in header_arg expansions when running shell scripts from Babel?

Please consider the following org-mode snippet containing code to call "show tables" on a particular database via a sql code block and to dump out the database via mysqldump using an sh code block **...
3
votes
1answer
79 views

Report missing noweb references in org-babel

In org-babel, is there a way for checking for missing noweb references <<...>> or for throwing an error if a reference is missing? For example in the following I have mistyped the name of ...
1
vote
1answer
36 views

How to auto prefix with comment char when inserting code ref label with org-store-link

There is a way to link to a specific link of code in org babel src block. with org-store-link. Here is an example: ;;; This is comment | line. | (describe-char | (point)) ; | comment | (message | ...
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 #+...
4
votes
0answers
223 views

Indentation using multiple org src block

So, say I have a literate org file as follows: #+TITLE: Random Scrap * Do something :PROPERTIES: :tangle: scrap.pl :comments: org :END: #+BEGIN_SRC perl sub my_func{ my $var = pop; #+END_SRC ...
0
votes
1answer
46 views

Why is org-mode always uncompressing ob-tangle.el.gz?

I recently shifted over to and wrote a literate init.el in a manner of speaking. Using this technique, I don't (require 'org-mode). Suddenly when I open up my .org file to edit it, it consistently ...
4
votes
0answers
374 views

org-mode babel german

I am trying to export an org file to PDF via LaTeX but in German. I set #+LATEX_HEADER: \usepackage[ngerman]{babel} but when exporting org-mode adds english to the babel options. That causes all the ...
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 ...
2
votes
1answer
464 views

ipython not working in org mode

I've followed everything here in order to set up ipython in org mode. But I keep getting the error: ...executing Ipython code block... apply: Searching for program: no such file or directory, ipython ...
4
votes
1answer
582 views

Using org-babel to enable virtualenv

I hoped to enable a virtualenv with org-babel source block before executing some python. I wanted to do something like pyenv pyvenv-workon before it evaulates my code block. I didn't want to have to ...
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 #+...
1
vote
1answer
820 views

how do I use :var arguments in sh code for ob-shell in org-mode

I want to pass variables / arguments to a shell script in org-mode babel code-block by using the :var tag. Instead of reading the value of the variable, shell is just getting the literal x, which is ...
5
votes
1answer
710 views

No “full service” Haskell org mode?

I'm guessing that since Haskell's ghci is not a full-fledged REPL, you can't really use it for defining functions in orgmode source blocks, i.e., #+begin_src haskell doubleMe x = x + x #+end_src ...
0
votes
1answer
216 views

Org babel caching for R when using session

I have an file which is a research paper (here); it contains numerous R blocks which produce tables and figures. Since these share common data and preliminary calculations, they are run as a org-babel ...
0
votes
2answers
126 views

evaluate sh source code, output is not displayed well

When I evaluate this: #+begin_src sh brew list #+end_src The result is good: However, if I use: #+begin_src sh brew info emacs #+end_src I get something weird: Does anyone know why this happens?
5
votes
1answer
1k 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 ...
2
votes
2answers
870 views

Why org-babel-tangle-file tangles source blocks to different files?

I try to use emacs --batch in Makefile to tangle my .org files. Here's my test org file (t.org) * Another Header #+BEGIN_SRC emacs-lisp (message "Hello") #+END_SRC * Header 1 #+...
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 ...
1
vote
1answer
207 views

Use local variable with concatenation in Org mode

I am trying to somehow use a local variable in org-mode for when I write my R code. So essentially in have this chunk that I want to automatically manage for each file. #+BEGIN_SRC R :file /Users/...
1
vote
0answers
152 views

Compiled configuration cannot find package

I am trying to have configuration byte-compiled to improve performances further. The original code works with no issue. However, adding the optional compile argument: (require 'ob-tangle) (org-babel-...
0
votes
2answers
56 views

How to avoid redundant output from inline orgbabel code?

When using #Begin_Src R blocks one can change the code in blocks and then rerun all the code blocks in a document. Great. However, if one does this with inline src, such as, src_R[:session *...
1
vote
1answer
152 views

Org babel - return results of multiple statements

This must be very simple, but I haven't been able to find an answer. How can I have org-babel output the results of multiple statements? Ex.: #+BEGIN_SRC scheme :exports both (define square (lambda (...
1
vote
0answers
46 views

Can `:exports` be set independently for inline org-babel code blocks?

In my org-mode document I use both src blocks and inline code blocks. When exporting to LaTeX, is there a way to set :exports both for the src blocks, but :exports results for the inline code? Right ...
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 #+...
1
vote
1answer
200 views

How to use “cache” argument in inline-call of org-babel?

My 1st question on Stack (>﹏<)! When I write my homework in org-mode, I want to use the literate programming with org-babel. So I use python as the major language to calculate the results I need in ...
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 ...
2
votes
1answer
126 views

Org babel invoke shell snippet once for each line in input table

Is there a way to get a shell source block to be invoked once for each line in a table? Take for example the following input table: #+tblname: instances-tbl | Instance | Topic | |-------...
2
votes
2answers
178 views

Concatenate ascii/org tables with some different headings

I want to concatenate two ascii tables (one below the other) that share some but not all column headings. e.g. Table 1 Head1 HeadA 1 a 2 b Table 2 HeadA HeadFoo c bar And the result ...
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 ...