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
1answer
32 views

The difference between (setq shell t) and (shell . t)

Upon configuring babel, encounter such syntax (require 'ob-ipython) (org-babel-do-load-languages 'org-babel-load-languages '((ipython . t) (python . t) (shell . t) ;; other languages.. )...
0
votes
1answer
33 views

Ditaa source code evaluated with no result

The code below evaluated successfully but ~/Downloads/foo.png is empty. A look at the downloads folder shows that no file has been generated. What went wrong? #+begin_src ditaa :file ~/Downloads/foo....
1
vote
1answer
10 views

What is the equivalent of the org-babel CALL in emacs-lisp?

Let's take this simple Org code, with two Python code blocs (one which returns a list, and the other one which prints the type and the content of the parameter): #+NAME: int #+BEGIN_SRC python :...
1
vote
2answers
27 views

Can Org-mode link to a Babel block?

I would like to have a link that runs a Babel source-code block. Does Org-mode support running something from the library of babel in a link, or a source block via a file+blockname reference? A ...
2
votes
1answer
72 views

org-mode tikz drawing behavior abnormal

In below example, the text should be show on the right side if compile the latex code with pdflatex command. but in org-mode, the right side text missed: #+HEADER: :fit yes :imagemagick yes :...
2
votes
2answers
53 views

How to append an argument to an external command in init.el?

I 1must append a config file to 2package command, required as -p puppeteer-config.json. In my init.el, I tried changing the native command as shown below: From: (setq ob-mermaid-cli-path "~/...
2
votes
1answer
46 views

Jumping from a source block to the tangled file

Is there an inverse of org-babel-tangle-jump-to-org allowing one to jump from a source block to the corresponding place in the tangled file?
0
votes
0answers
29 views

org-babel results with accented characters

I have a problem with the output of org-babel code blocks when this output contains accented characters. For example, if I execute this code block: #+name: test_accented #+begin_src python :results ...
0
votes
0answers
14 views

Obtaining the results of babel evaluation of docker-compose commands

this is an odd behavior which seems to happen for some docker-compose commands but not others. If I try to evaluate certain commands like #+BEGIN_SRC sh dir: . docker-compose exec app rspec #...
0
votes
0answers
11 views

Adding header to a org-mode tangled file

I am generating source code files from an org-mode file using org-babel-tangle. How do I add headers to the files e.g. for python # This is a generated file do not edit for emacs lisp similar ...
0
votes
0answers
17 views

Is diff syntax recognized as a valid org babel src block type?

How can I get syntax coloring after exporting when when the contents of my org babel src block is diff style: #+BEGIN_SRC diff <--- is that even a valid keyword diff --git a/railties/lib/rails/...
1
vote
0answers
21 views

Leave noweb references in Org-Babel unevaluated with variables

I'm currently getting into Literate Programming with org-mode in Emacs. One of the key features to make it tractable as a programming style is macros. I would like to be able to do something like this:...
0
votes
0answers
11 views

Use result of ob-shell block in subsequent ob-shell block

#+BEGIN_SRC sh aws ec2 describe-instances #+END_SRC #+RESULTS: i-0154b911d1f4e0871 #+BEGIN_SRC sh aws ec2 terminate-instances "param1" #+END_SRC How can I use the result of the first block as the ...
0
votes
0answers
18 views

How to tangle conditionally based on hostname?

Why is this block tangled (bar.sh), but not the second (foo.sh)? #+BEGIN_SRC sh :tangle bar.sh echo bla #+END_SRC bla #+BEGIN_SRC emacs-lisp :tangle (when (eq system-name 'arch) "foo.sh") (princ ...
0
votes
1answer
23 views

org-babel for vimscript or most similar language

Since I couldn't find anything as per title, does anyone know what org-babel language could be used as workaround? Currently I surround code blocks with #+begin_src sh, though in particular the ...
2
votes
1answer
70 views

org export processes code blocks even if located in noexport headline

EDIT 1 : a more simple use case For this org file content: * Headline 1 - Something to export * Headline 2 :noexport: #+begin_src python :results none :exports none def foo(): ...
1
vote
1answer
27 views

How write begin_export html blocks in an inline fashion?

A code which takes up several lines of screen realestate can be written as Inline code src_sh[:exports code]{echo -e "test"} foo source: https://stackoverflow.com/a/16193498 Is is possible to write ...
0
votes
0answers
24 views

Use Ruby console session in Org Babel

I'm able to properly start a Ruby on Rails console using inf-ruby-console-auto. Org Babel, when executing a buffer will use inf-ruby. How can I get source blocks in an Org file to invoke inf-ruby-...
2
votes
1answer
56 views

How to use org headers as filenames in tangle

In org mode, how can I tangle to files equally named as the org header? Referring to the examples below, I'd expect two files foo.sh and bar.sh as tangle result: * foo #+BEGIN_SRC sh :tangle yes ls #...
0
votes
0answers
50 views

org-mode code block parentheses mismatch

Here's some emacs-lisp code in a babel block: #+begin_src emacs-lisp (defun factor (number) (labels ((*factor (divisor number) (if (> (* divisor divisor) number) (list ...
2
votes
1answer
29 views

How to use python listdir in org babel?

While the command below returns filenames in the commandline, I somehow can't get the same result using org-babel: #+BEGIN_SRC python :results output import os os.listdir(path='.') #+END_SRC #+...
3
votes
1answer
32 views

Passing variable into a org babel code on export

I can't seem to get the variable to expand into src block #+BEGIN_SRC conf :tangle ~/.config/mine.conf :var argument=abcde setting1 1234 setting2 argument #+END_SRC When I export the file for ...
1
vote
1answer
110 views

Org-mode 9.2:Can' t find the error on my dot emacs [closed]

I recently update my org to the version 9.2 (to be precise: Org mode version 9.2.3 (9.2.3-4-g6ec402-elpaplus @ /home/nanounanue/.emacs.d/elpa/org-plus-contrib-20190408/) I did it because I replaced ...
0
votes
0answers
18 views

How to pass noweb variables to latex blocks

I need to tangle a LaTeχ file from code blocks in an org file. How do I pass variables to the SRC block? In theory I should use :var var1=value, but is there any way to reference var1 in the LaTeχ ...
1
vote
1answer
59 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
39 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
68 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
35 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
39 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
69 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
82 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
57 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
88 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 ...
2
votes
2answers
85 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
50 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
48 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:...
2
votes
0answers
44 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 ...
6
votes
2answers
104 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
15 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
32 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
73 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
26 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.
1
vote
1answer
93 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
133 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
23 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
17 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
62 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
74 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
71 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 ...