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.

4
votes
2answers
318 views

How to export multiple graphs/plots per code block in org-mode?

If my R code, which plots several graphs, is contained within one babel code block in org-mode, is it possible to export all of the graphs and display them in the #+RESULT section after evaluating the ...
2
votes
0answers
236 views

how to expand org-mode macros in HTML blocks in export to HTML?

I'd like to use org-mode macro replacement to expand macros inside HTML blocks in org-mode export to HTML. I'd like this... #+MACRO: event-url bar #+HTML_HEAD: <meta property="og:url" content="...
2
votes
1answer
80 views

The correct way to declare common vars in babel

I'm playing with the idea of "literate devops" with org-mode. To simplify scripts i've extracted common values into :PROPERTIES: drawer, which looks like this: * Scripts ** Subscripts-A *** ...
5
votes
1answer
2k views

Org-babel 9 + Spacemacs: Unable to evaluate org-babel SRC Blocks

I followed every instruction I could here Org-mode 9: unable to eval code-blocks, and I am unable to get org-mode and org-babel to evaluate any code blocks in any language. I am dead in the water and ...
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 ...
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 ...
0
votes
0answers
102 views

Tramp Ipython remote session: Problems with remote paths within code

Here's my setup: * Tramp on remote :PROPERTIES: :header-args: :dir /ssh:me@server.com|ssh:me@remote:/project/ :END: #+BEGIN_SRC ipython :session :results output drawer import pandas as pd data = pd....
0
votes
0answers
248 views

How to evaluate source code block on remote host?

I am working on windows machine. I have last org version (from February 2017). I have a remote host accessible by putty, where i have created org file of the following contents: #+TITLE C language ...
2
votes
1answer
295 views

Org Mode Babel - ensure more than one empty line between tangled code blocks (for python)

Suppose I have two code blocks in my org file #+BEGIN_SRC python :tangle ~/dummy.py class A: pass #+END_SRC #+BEGIN_SRC python :tangle ~/dummy.py class B: pass #+END_SRC After org-babel-...
0
votes
1answer
70 views

Define a new babel src (based in python)

I would like to write pieces of code (I don't need to evaluate it---yet---) of Cadabra see the web page which is based in python. However, it uses the symbol # as part of the code. How could I define ...
6
votes
1answer
129 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 ...
1
vote
0answers
151 views

How can I use #+CALL with multiple arguments?

I'm trying to learn how to use the noweb syntax and advance my knowledge on the possibilities of org babel. For that, I'm trying to get the following an example to work that 1. uses noweb syntax and 2....
1
vote
0answers
89 views

noweb reference aware org-edit-special

Is there a way of splitting a src block into several blocks while keeping them together with noweb reference syntax and editing them using org-edit-special in such a way that would take into account ...
2
votes
2answers
317 views

Elisp code output style in org mode

I want to print elisp code result as original but currently it will output with "|" separated. for example: #+BEGIN_SRC emacs-lisp (setq my-list '(apple orange peach)) #+END_SRC The code block will ...
1
vote
0answers
217 views

Can I write to a local file from a remote session using an Org-babel R code block?

I'd like to find a way to evaluate my R code remotely, but insert images into my local org file. I use R code blocks in my org files and insert images into the org file with something like this: #+...
3
votes
1answer
106 views

How to disable noweb prefix lines?

This says that Noweb insertions now honor prefix characters that appear before <<reference>>. And because of that trying to use #+BEGIN_SRC clojure :noweb-ref dep-cljsbuild [lein-...
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 ...
3
votes
0answers
308 views

How to generate inline plot result for ob-clojure?

Question: How to generate inline plot image result in Org-mode babel clojure src block? I tried some ways: First way: use :results file :file "clojure-babel-figure-result.png" #+BEGIN_SRC clojure :...
5
votes
1answer
189 views

In org-mode, can I include a horizontal separator in a result table generated by an Emacs Lisp code block?

I have some Emacs Lisp code blocks in an Org file which I evaluate to get tables of results. It would be nice if I could include horizontal separators to separate individual lines of data from ...
0
votes
2answers
181 views

How can I start a server in the background from a source code block without freezing emacs?

I am creating several org-mode documents to track code example and would like to be able to view the results of tangling or executing these code blocks in a browser. In the example below, I've created ...
3
votes
1answer
2k views

export R code results in org-mode?

I want to execute R code blocks in org-mode and export the results to a PDF/html. Here is an example: Some text here... #+begin_src R :results output latex library(xtable) x <- rnorm(100) y <...
1
vote
1answer
48 views

Org-babel variables argument reading twice

I am executing a src block on a table that is determined by a prompt. A minimal example: #+NAME: a-table | Value | #+begin_src emacs-lisp :var (princ (format "table=a-table" (read-string "Select: ")...
3
votes
1answer
123 views

Selectively Highlight lines in source code block

I use emacs org-mode and find feature of source code blocks extremely useful. However, If I want to say highlight a couple of lines in my source code block, is it possible to achieve? e.g. #+...
2
votes
0answers
503 views

Emacs org-mode and Haskell? [closed]

I've got melpa-bleeding haskell-mode installed on Emacs 25.1 with org-mode 9.0.3. If I load an orgmode file with this, and run it (C-c C-c) #+begin_src haskell tripleMe x = x + x + x #+end_src a ...
4
votes
2answers
420 views

Access and adjust global variable from org-mode as local buffer variable

I'm currently working with a lot of javascript in my org files. Therefore I introduce a local buffer variable that will automatically insert javascript as language identifier in my file whenever I ...
1
vote
1answer
263 views

Org-mode only export LaTex Source Blocks

I'm looking to use org-mode to typeset homework for a math class I'm taking and was wondering if there is a way to export only certain LaTex blocks to the final PDF using org-babel. As an example ...
1
vote
3answers
490 views

Outputting figure from R to LaTeX in source block with caption

I am trying to run a source code block and have the outputted figure go into a LaTeX document as a figure. Basically I am doing this in a way slightly similar to Jupyter notebooks, but with the ...
3
votes
0answers
141 views

Curly braces inside a body of the org-mode inline source block

I would like to use curly braces inside a body of the org-mode inline source block. Since the body itself is delimited with curly braces it seems impossible. The problem occurs when additional pairs ...
2
votes
1answer
919 views

C/C++ coding in Emacs org-mode's babel

I'm not finding a lot of examples/documentation for the non-REPL world of C/C++ in Emacs org-mode babel. For example, is there a way to break a program up into separate source code blocks, i.e., a ...
1
vote
2answers
669 views

Running :noexport: code on export

According to the org-mode manual (emphasis added by me): The tags that exclude a tree from export (org-export-exclude-tags). The default value is :noexport:. Entries with the :noexport: tag will be ...
2
votes
1answer
384 views

How to return an org mode table with headings and hline from Ruby

I have the same question as this question except that I don't see how to do so other than in elisp. I am using Ruby, but I suppose the question applies to other languages as well. If I return an ...
2
votes
0answers
406 views

use local tikz library in org-mode

would like to use a custom tikz library with org-mode. https://github.com/jluttine/tikz-bayesnet The following example works fine. :) #+begin_src latex :file fsa.pdf :packages '(("" "tikz")) :border ...
1
vote
1answer
105 views

Ignoring subtrees with a certain tag

I want to ignore a subtree temporarily. I can do this by setting the property :header-args: to :tangle no, but this is not usually visible. Could I have this property set automatically by all ...
1
vote
1answer
383 views

svg pictures from tikz in html export in windows

I want to create both PDF and HTML figures using Tikz for both purposes. I am doing as it is explained in here, answer of nberth. To do this, I installed imagemagick for windows because this solution ...
0
votes
1answer
65 views

Face of org-mode source block changes when returning from edit buffer

A strange thing happens when editing source blocks within an extra buffer with C-c ': the face of just this source block changes upon returning, i.e. the face settings are not used any more. I'm ...
1
vote
1answer
136 views

Ouput Of Org Src Block Is Squeezed Into A Table

I'm using org-mode + org-babel to execute Bash commands that execute Docker commands. Here's an example: #+BEGIN_SRC sh :exports both :dir ~/Dev/Docker/sample sudo docker build -t tompurl/nginx . #+...
1
vote
0answers
184 views

Choosing which font for html export syntax highlighting?

Exporting org mode documents to html with (setq org-src-fontify-natively t) will carry syntax highlighting into the exported code blocks. Zenburn looks awful exported while Leuven/others looks ...
3
votes
0answers
157 views

Org-babel and anaconda-mode in src blocks

I practice python literate programming with tangling to generate a full project structure. There are dependencies between modules and packages, and so I will say in the C-c ': #+begin_src python ...
1
vote
1answer
52 views

Can I make the latex extension .tex rather than .latex?

When tangling latex source from pie.org, the resulting file is by default pie.latex. Is it possible to change the extension for latex code to .tex?
0
votes
1answer
113 views

How to initialize Racket libraries, environment at org-mode buffer startup

As the title says, I want a number of things to happen when I open an org-mode file: I want a Racket REPL session to start (as in a code block :session mysess1) and I want various Racket environment-...
3
votes
0answers
112 views

Org-babel noweb expansion when sending C-c ' buffer to python shell

I'm doing literate programming with Python. In my workflow I like to test the block with python-shell-send-buffer and ipdb debugger. However if the block contains a noweb reference then the code is ...
0
votes
1answer
55 views

How to use ,var-name (defvar) syntax in org-publish-project-alist? Init file is in form of org-mode

I have following function as part of my emacs configuration.org settings for publishing org to html. (defvar website-html-preamble "<nav> <ul class="nav nav-tabs"> <li role="...
4
votes
1answer
421 views

modify default org babel default headers

I would like to have more control on the R session in org-mode so that I only have to chage the session name in one place for the modification to affect the whole buffer. The only way I could think ...
1
vote
2answers
470 views

Get values of an inline result in org-mode

I like the short notation of org-babel function calls. E.g. you can define a named code block like this #+name: get_date #+begin_src http GET http://date.jsontest.com #+end_src and then hit C-c C-c ...
5
votes
2answers
356 views

Get contents of a named source block

The other day I wanted to put the contents of a source code block into a header argument of another block. I couldn't find any ready to use function to do that though, so I came up with this: (defun ...
2
votes
1answer
266 views

Error at init.el and orgmode export

I reinstalled my whole system and after trying to load my previous Emacs config that works in the past, I always obtain an error: org-define-error and I follow de conflict line what is (require 'ox-...
0
votes
1answer
257 views

Exporting a figure generated with org-babel and noweb reference syntax

Wanting to export a figure generated by matplotlib to LaTeX (as described here) I've encountered the following issue (which ultimately I was able to solve as described here). My source block has two ...
2
votes
2answers
171 views

Org-mode code block evaluation error

For some reason, evaluating code blocks stopped working for me. Example from the manual: #+BEGIN_SRC emacs-lisp (defun org-xor (a b) "Exclusive or." (if a (not b) b)) #+END_SRC ...
4
votes
3answers
219 views

How to remove ^M from org-babel code block executing on Linux from Windows OS?

My problem is that every line executing on the remote Linux machine seems to be including a trailing ^M (as is shown as ? in the file name apa? below). Content of my .org document: * Test #+...
6
votes
3answers
949 views

Get pandas data-frame as a table in org-babel

In the following example, I create a very simple pandas DataFrame and export results verbatim: #+BEGIN_SRC python :exports both :results verbatim :return test import pandas as pd test = pd.DataFrame({...