Stack Exchange Network

Stack Exchange network consists of 175 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.

0
votes
0answers
1 view

Transparent tangling and detangling?

I'm working on a latex document which I tangle from org mode. With the header argument :comments link, I get a tex file that can be detangled back into the original org file (org-babel-detangle). ...
1
vote
1answer
35 views

Naming the result of a source block

The following question has been asked (in slightly different form) in a comment of another answer: Is it possible to name the results of a source block with #+NAME: foobar (or equivalently but old-...
2
votes
1answer
26 views

No comment syntax defined

After calling org-babel-tangle on a certain file containing latex blocks, I see the prompt No comment syntax defined. Use: What is this about? This doesn't happen with another similar file I have....
5
votes
1answer
54 views

Help me avoid “|| true” in org babel bash statements

I'm writing a lot of manuals on how to accomplish things in bash. Often I'm showing people something that doesn't work, and then go on to show what works. When I'm showing something that doesn't work, ...
1
vote
1answer
26 views

org-mode: How can noweb handle a multiple line output

I have a code chunk in my document that I want to use as a list of patterns to search for with grep. If I were just writing a script without org-babel, I could write. a="ar er ir or ur" printf "...
0
votes
1answer
20 views

org-macros in header arguments of org-babel?

Is there a way to specify org-macros that can be used in header arguments of org-babel? One application is to specify the figure path. For instance I want to define: #+macro: folder figures_here in ...
0
votes
1answer
35 views

Org babel gnuplot cannot find or open file with ledger-cli report

Expecting gnuplot to create a png on evaluating a ledgerCli plot report I get the GnuPlot error at the bottom of this post LedgerCli #+NAME: LedgerCli #+BEGIN_SRC ledger :cmdline reg Assets:Cash -J ...
1
vote
1answer
44 views

How to gnuplot a referred evaluated table in org-babel?

Hitting ctrl-c ctrl-c on the gnuplot code block returns: org-babel-ref-resolve: Reference ‘foo’ not found in this buffer #+srcname: foo #+begin_src python :results output raw :exports code import ...
0
votes
1answer
45 views

ob-async issue, seq-random-elt not defined

I would like to asynchronously run code blocks in org mode. My org mode version (org-version output) is: Org mode version 9.2.1 (9.2.1-23-g126a37-elpa @ /home/user/.emacs.d/elpa/org-9.2.2/) I ...
2
votes
1answer
54 views

Global lexical-binding setting?

I've seen ;;; -*- lexical-binding: t; -*- at the top of a file and (setq lexical-binding t) as how to turn on lexical binding for elisp code, but is there a way to tell Emacs to simply always do ...
1
vote
1answer
57 views

Can not refer to RESULTS in org-babel

I need to plot data evaluated in org-mode. Referring to #+RESULTS: returns org-babel-ref-resolve: Reference ‘myResult’ not found in this buffer whereas referring to #+tblname: works. #+RESULTS: ...
0
votes
1answer
24 views

Haskell code execution in Org-mode give error but in .hs file the code is good and working

i have this code: qs [] = [] qs [x] = [x] qs (x:xs) = qs [a | a <- xs, a < x] ++ [x] ++ qs [b | b <- xs, b >= x] when i save it to some file .hs and load it to ghci i can execute ...
0
votes
1answer
45 views

Org mode export with R failing

I have an org file with R code in it. When I attempt to export to html or pdf I get an error: For example if my file was: #+begin_src R :exports code square <- function(x) { x * x } square(1:...
0
votes
0answers
19 views

org-mode/babel and zsh: Getting shell sessions to work

I've been trying to get shell code blocks with sessions to work, but not entirely succeeding. My setup: emacs 26.1 (spacemacs) org-mode 9.2.2 default shell: zsh 5.7.1 Everything seems to work fine ...
5
votes
2answers
87 views

How to copy org-table to postgresql database?

With sqlite one can easily populate a table in a database via a org-table like so: [EDIT](using only one sqlite-scr-block with org-table variable parameter)[/EDIT] #+NAME: A | val1 | val2 | |------+...
1
vote
1answer
35 views

Unable to run applescript from emacs-lisp

I have the following code block, which I am trying to execute from org-babel: #+BEGIN_SRC emacs-lisp (let ((h (nth 5 (org-heading-components)))) (do-applescript (format "tell application \"...
0
votes
1answer
14 views

Grant Applescript via Emacs Lisp permission for UI scripting [closed]

I have a simple applescript, embeded in emacs-lisp, which uses the current org-mode heading to create a calendar event in Apple Calender. However... because scripting Calendar directly is painfully ...
0
votes
1answer
25 views

How to change org-babel interpreter location

Say I have my ditaa interpreter pointed to at /home/user/.emacs.d/elpa/contrib/scripts/ditaa.jar, how would I set it so it points to a different location?
2
votes
0answers
52 views

Print output from org code block immediately

I have an org mode file I use to run some moderately long analyses. Evaluating individual blocks may take 15 minutes to an hour or so. I usually wrap longer bits with calls to date, so I can later ...
0
votes
1answer
24 views

org src block php formatting adding commas to phpDoc

In the editing mode (C-c ') I formatted php code using TAB button. But in org mode src block it adds 2 comma to phpDoc.
0
votes
0answers
56 views

tramp gcloud compute ssh not working

I wanted to be able to ssh into my google cloud instances with spacemacs. I found: https://github.com/dustinfreeman/dustinfreeman.emacs.d/blob/master/init.el#L50 which is based off of: https://...
3
votes
1answer
91 views

org-export latex pdf output does not render svg

I tried out this section of code from this repo #+LATEX_HEADER_EXTRA: \usepackage{svg} ... #+PROPERTY: header-args :eval never-export :file-ext svg ... #+NAME: sequence12422 #+BEGIN_SRC plantuml :...
0
votes
0answers
18 views

Prevent parsing of text inside verbatim org results block

How do I tell emacs to not not apply treatments to text within a block like this. My issue is that, the * foo at the end causes the export to go bad. I'm using something similar to carl's setup -> ...
0
votes
0answers
14 views

Rmarkdown-like export of Leaflet for R webmap to html from org-mode

With RMarkdown it's easy to embed an interactive webmap. E.g.: --- title: Some title output: rmarkdown::html_document --- ```{r} library(leaflet) leaflet(width = "100%", height = "650px") %>%...
1
vote
1answer
42 views

use js2-mode instead of js-mode in org babel source

I want to use js2-mode instead of js-mode inside org-babel sources. Is there a way to define a mode for JavaScript inside those chunks? #+begin_src js console.log(1+1) #+end_src
0
votes
0answers
48 views

How to export org-babel document with ox-pandoc?

I want to export an org-babel document to html with bibliographies from a .bib file. The org-file is the following: #+TITLE: Test #+AUTHOR: Your Name #+EMAIL: your-email@server.com #+PANDOC_OPTIONS: ...
1
vote
1answer
57 views

How to export org-babel document?

In my .emacs file, I have the following variables: (custom-set-variables '(org-babel-load-languages (quote ((emacs-lisp . t) (R . t)))) '(org-confirm-babel-evaluate nil)) I save this example to a ...
1
vote
2answers
89 views

Babel + Python function definition with for loop causes IndentationError

I am using orgmode and Babel to run Python source code blocks. I noticed that if I define a function that returns a value, and if this function has a for loop inside it, then evaluating it with Babel ...
1
vote
1answer
47 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-...
0
votes
1answer
45 views

eval elisp code to fill org-babel header arguments

I use many org files with figures generated by source code blocks. By example, in an org mode file long/path/document.org I have: #+BEGIN_SRC dot :file my_fig.png :exports results digraph { A->...
2
votes
0answers
27 views

How to set a tangled parent directory for each subtree in org mode?

Base on this, one can set a global tangled file. However, I'd like to set one directory for each subtree, e.g. for a * Python subtree, in every code block I can set :tangle a.py or :tangle b.py ...
1
vote
0answers
34 views

With org-babel how can I read a result block and pass arguments?

I asked a similar question a few years ago but I never did figure out how to proceed. I ended up aborting my excursion into org-babel. However, I can see how this would be really valuable, to ...
2
votes
1answer
47 views

Setting :stdin with #+call in org-mode shell code block

I've got the following code: #+NAME: example-block1 #+BEGIN_EXAMPLE Lorem ipsum dolor sit amet, consectetur adipisicing elit. #+END_EXAMPLE #+NAME: example-block2 #+BEGIN_EXAMPLE Sed do eiusmod ...
1
vote
1answer
204 views

No org-babel execute function for go

#+Begin_SRC go package main import ("fmt") func main(){ fmt.Println("emacs") } #+End_Src ~/.emacs.d/init.el: (when (memq window-system '(mac ns)) (exec-path-from-shell-initialize) (exec-path-...
1
vote
1answer
58 views

Export an orgmode buffer without expanding noweb references?

Normally, when I use orgmode's export function on a buffer that contains noweb references, they get expanded, resulting in lots of duplicated code throughout the exported HTML document. Is there a ...
0
votes
1answer
300 views

org-babel-execute-src-block: No org-babel-execute function for R!

In org-mode, attempting to execute the following block... #+BEGIN_SRC R 1+2 #+END_SRC ...gives the error message org-babel-execute-src-block: No org-babel-execute function for R!. I have followed ...
4
votes
1answer
465 views

Using File Local Variables in org-mode

Is there a way to use file local variables set in an org-mode file in the following contexts: Simply expanding the variable when text is exported (eg: to LaTeX) Passing the value to :var in a babel ...
1
vote
1answer
22 views

Org babel R: why is 'NA' replaced with 'nil'

When using R in org mode source blocks, any NA (i.e. missing) values in tables get replaced with nil. Why is this? And is there a way to change this (globally, or at the file level)? I regularly ...
0
votes
1answer
38 views

is there something like org-babel for arbitrary major modes? [duplicate]

org-babel allows editing source code of arbitrary modes inside an .org file. I'd like to do this (with different syntactic markers) inside my major mode, but org-babel is very specific to org. Is ...
4
votes
1answer
34 views

How to display intermediate code block results?

Here is an example to let me explain what I would like to achieve: #+NAME: heavy_computation #+BEGIN_SRC shell :results table echo -e "A\t32\nB\t17" #+END_SRC #+BEGIN_SRC python :var data=...
0
votes
1answer
30 views

Catching warnings from sh source block

I've started on Learn C The Hard Way and want to collect my work in org mode. Executing rm ex1 && CFLAGS="-Wall" make ex1 in the terminal returns cc -Wall ex1.c -o ex1 ex1.c: In ...
0
votes
0answers
61 views

Why the difference when executing a shell script from a :session

I'm trying to do some git archeology but I've run into some weirdness with orb-babel and sub-shell expressions: #+name: get-aggregate-stats-debug #+header: :dir ~/lsrc/qemu/qemu.git #+begin_src shell ...
0
votes
1answer
65 views

Exit hook for org-src-mode

org-src-mode-hook is run upon editing a source block using org-edit-src-mode. Is there a way to set behaviour upon exiting editing a source block? In particular I would like to run blacken-buffer ...
9
votes
1answer
231 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 ...
2
votes
1answer
448 views

Org-babel Python with :session

I don't know what happened with org-babel and Python recently. My intuition and my experience with preparing lectures last year was that the :session option would cause Org Mode to capture all the ...
7
votes
2answers
216 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 ...
2
votes
1answer
50 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 ...
0
votes
1answer
134 views

Choose individual startup visibility of org-mode's source blocks

In org-mode, how could one specify the visibility state of individual SRC_BLOCKs when a file is opened? org-mode provides the variable org-hide-block-startup to specify if all source blocks are shown ...
0
votes
1answer
107 views

How do I ensure org-sbe is consistently passed a string when copying tables

I'm trying to transform the data from one table to another however I can't do it with built in functions so I have to use org-sbe to call some elisp: #+tblname: clues | 02a8 | 0050 | 5012 | 2225 |...
1
vote
1answer
59 views

org-babel-execute:sql: reciving erros and no returns

#+name: Part 1 Task 1 #+header: :engine mysql #+header: :dbhost localhost #+header: :dbuser subject #+header: :dbpassword 1234 #+header: :database hmsec #+begin_src sql SELECT sensorId, type, ...