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.

1
vote
2answers
24 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
68 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 :...
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 ~/...
2
votes
1answer
309 views

Org-babel: Set root dir for tangled files

I have started using org-babel for a larger project, and have found the readthedocs to be a great resource. I have been using tangling to generate code from documentation, however setting the export ...
2
votes
2answers
51 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
41 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?
10
votes
2answers
361 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 ...
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 ...
1
vote
1answer
92 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://...
0
votes
0answers
13 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 ...
4
votes
1answer
126 views

Eval SQL in Org Babel using sql-connection-alist for credentials

I would like to evaluate SQL source blocks in Org Babel using the connections I have set up in sql-connection-alist from sql-mode. This way I can save database credentials in a private (Elisp) file ...
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 ...
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(): ...
3
votes
1answer
123 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-...
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 ...
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 "...
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-...
0
votes
1answer
200 views

ledger in org-babel blocks uses incorrect path data in Windows 10

I am trying to include a ledger data file from an org-babel block. I am using Windows10 and the SciMax emacs distribution. #+begin_src ledger :cmdline bal :results output :exports results !include d:/...
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
1answer
222 views

Code block evaluated when exporting, not when publishing

I have this basic org publishing project to test that code blocks evaluation is triggered by publishing in html (org-html-publish-to-html). While exporting through org-mode export dispatcher does ...
2
votes
1answer
28 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 #+...
0
votes
0answers
49 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 ...
0
votes
1answer
52 views

How to prevent org-mode loading babel's major mode stuffs unless entering `org-src-mode`?

I have some Java's scripts in a org file. And I use meghanada-mode in java-mode. Each time I open this org file and do nothing, I get the following error since the mehanada server loaded by java-mode ...
2
votes
2answers
84 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
2answers
352 views

Cannot Execute Org-Babel Haskell Block

In an org-mode file: #+BEGIN_SRC haskell let x = "test" putStrLn x #+END_SRC yields: executing Haskell code block... if: ‘org-babel-script-escape’ expects a string
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
109 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 ...
3
votes
1answer
99 views

Evaluating `org-babel-clojure` blocks returns all form evaluations

I'm trying to set up babel for use with Clojure according to http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-clojure.html#org85bc1ec and I can evaluate code but when I evaluate a block with ...
4
votes
1answer
37 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
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χ ...
0
votes
1answer
224 views

Tangle only selected src blocks using org-babel on export

I have a document with only several source code blocks that should be tangled. So the structure is: # Some main.org ... #+BEGIN_SRC awk :tangle file1.awk ... #+END_SRC awk ... ...
2
votes
1answer
38 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....
1
vote
1answer
55 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-...
3
votes
1answer
474 views

ob-ipython error message while evaluating SRC block

I am getting this error when executing any source ipython block such as this one: #+BEGIN_SRC ipython :session :results output drawer # Compute areas and colors import numpy as np import matplotlib....
5
votes
1answer
67 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, ...
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 ...
0
votes
1answer
52 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 ...
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
68 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
79 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 ...
2
votes
1answer
84 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
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
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:...
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 ...
2
votes
0answers
41 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 ...