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.

Filter by
Sorted by
Tagged with
0
votes
1answer
12 views

Retrieve the lunar phases to diary.org as a record

I tried to record the sunrise and sunset info to the diary #+begin_src emacs-lisp :tangle yes (sunrise-sunset) ;;(lunar-phases) #+end_src #+RESULTS: : Sunrise 6:57am (CST), sunset 5:00pm (CST) at ...
0
votes
0answers
15 views

Redirect mysql complete ouput to results

I tried sql source code in org mode #+begin_src sql :engine mysql :dbuser org :database grocer select prod_id, prod_name, prod_price from Products; #+end_src #+RESULTS: | prod_id | prod_name ...
0
votes
0answers
37 views

(solved) Error “Tangled 0 code blocks from [file]”

I'm writing a bash script with literate org-mode. The header of the file is: #+TITLE: start-lcs #+AUTHOR: Stahlberg #+EMAIL: stahl at gmail dot com #+DATE: 2019-11-02 #+PROPERTY: header-args:sh :...
0
votes
1answer
23 views

how to speed up org-babel-tangle?

I have an org file of 470 lines, 20 headings and 15 noweb references. From it I tangle 2 files that are 250 lines and differ very little. Tangling takes over a minute and a lot of painful redisplay: ...
3
votes
1answer
56 views

hlines in bash/sh source code block

How can I insert a horizontal line (hline) in a bash/sh source code block? My goal is to separate the header line from the rest. #+begin_src sh echo "header1,header2" echo "???" # placeholder for ...
0
votes
1answer
15 views

How to get correct list numbering with code blocks items in Org-babel?

Here is a minimal working example of Org file for LaTeX export: #+OPTIONS: toc:nil * A list with R source blocks 1. This is the first item. #+begin_src R :results output :session *R* :exports both x ...
0
votes
1answer
11 views

Can “kaz-yos/eval-in-repl” use the prexisting “inf-ruby” console started by robe mode

I've been using org babel to execute ruby code, works well but wrapping blocks with begin_src/end_src is cumbersome no live output - i have to wait till the whole process finishes to see output ...
0
votes
0answers
61 views

How to execute a org-babel source block within the working directory?

Say you have the following org-babel source block: #+BEGIN_SRC latex :results raw :file test.pdf \LaTeX #+END_SRC When executing it, org-babel will do the actual compilation in a temporary directory ...
0
votes
0answers
8 views

Missing Code Page

I need a code translation page for a file containing Russian Cyrillic characters in an unknown format, not alternativnyj, not cyrillic-iso-8bit, not cyrillic-koi8, not ruscii. Cyrillic-iso-8bit comes ...
1
vote
1answer
34 views

Org Mode Babel: Is there a way to assert the expected results of evaluation?

Is there a way to assert that the results of evaluating a code block with Babel are equal to an expected text? Ideally, I would use this to stop an export to PDF if one of the assertions does not hold....
1
vote
1answer
39 views

Config is broken when I use load-user-file

This is my config for org-babel: (use-package org :mode (("\\.org$" . org-mode)) :ensure org-plus-contrib :config (org-babel-do-load-languages 'org-babel-load-languages ...
1
vote
0answers
33 views

Org-mode results verbatim not working for Scheme code

I have the following source block of Scheme code: #+BEGIN_SRC scheme :results value verbatim append (define shift (lambda (list-with-sublists) (cond [(pair? (car list-with-sublists)) ...
0
votes
0answers
34 views

How to adjust image size of an org-babel output permanently?

I know I can add html or latex attributes under the #+result: block after executing the block, but when I re-evaluate the block, it is removed.
1
vote
0answers
13 views

Highlighting the currently active org-Babel block

I want to do something similar to hl-line-mode but not sure if it has been implemented already and how it can be implemented. The goal would be to set two color schemes for the #+begin and #+end ...
0
votes
0answers
12 views

shell code block in win10

I wish to run shell code in org sh code block as below: #+BEGIN_SRC sh :results output dir c:\ #+END_SRC #+RESULTS: : c:\>More? The output is not as expected! BTW, I have add below line in my ....
0
votes
1answer
41 views

Evaluate single line of python code from Emacs org-babel

Consider a block of python code in an org-mode document: #+begin_src python num1 = input("Enter a number: ") num2 = input("Enter another number: ") result = float(num1) + float(num2) print(result) #...
1
vote
1answer
41 views

Remove extra prompts in Emacs Babel Python session

When I run the following code block from Emacs org-babel: #+BEGIN_SRC python :session *Python* :results output print("Hello World") #+END_SRC This is what prints out in my *Python* session: >...
1
vote
1answer
49 views

Org-babel python with session breaks output

If I run the following code block: #+BEGIN_SRC python :results output print(" /|") print(" / |") print(" / |") print("/___|") #+END_SRC I get the result as expected: #+RESULTS: : /|...
1
vote
1answer
72 views

Cannot add general block header arguments in org mode

While I'm learning javascript following a book, I Like to take notes with org-mode. I use Indium and followed this instructions to handle it working It works well, and I get my work done, interacting ...
1
vote
0answers
20 views

Spaces get trimmed when I use org table in (R) code block

Please, help! I use literate programming and I want to use org-mode tables as data for my R code blocks. However, when it comes to cell values that have meaningful leading and trading spaces org-mode ...
1
vote
0answers
17 views

tide-mode in org-edit-src-code

I want to activate tide-mode when using Javascript soruce code blocks, following this it works well with indium: https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-js.html But I want to use ...
0
votes
4answers
138 views

Problem with org-mode odt exporter for styling exported src code blocks

I try to change the style of src code blocks export with odt exporter but it does not work as expected. I first exported my file to an odt document. Then I changed the style of OrgSrcBlock and saved ...
0
votes
0answers
21 views

org-mode: Use dvisvgm on HTML export of Babel LaTeX blocks

As far as I understand, there are two competing forces when exporting LaTeX to HTML. If it's in the text (including using \begin blocks), then the preview mode of org.el is used, relying on org-...
0
votes
0answers
11 views

Changing the tangling destination

If you call #'org-babel-tangle in a source block beginning with #+begin_src tex :tangle irs.tex The tangled file will normally end up in the current directory, which will be the directory containing ...
1
vote
1answer
40 views

Indent code block in org mode headines

How I can indent code block to align it to the begining of #+BEGIN_SRC ? Right now it looks like this and I would like to be like this
0
votes
0answers
13 views

Unexpected cursor move in org source block when `comment-line`

In an eamcs -q session given the below code (* and % are position indicators) #+begin_src python import IPython %import tabulate class OrgFormatter(IPython.core.formatters.BaseFormatter): ...
2
votes
3answers
70 views

How can I search between the lines with multiline search?

I use C-u 4 M-x helm-swoop for interactive search also show several surrounding lines (this is analogous to grep -C 4). When I find the word I narrow my search interactively, for example, C-u 4 M-x ...
1
vote
1answer
38 views

Error with org-babel-execute-buffer

I'm using Org mode 9.2.3 and Emacs 26.2. When I try to execute all source blocks of an org document with org-babel-execute-buffer (bound to C-C C-v b), I always get the following error message: ...
0
votes
1answer
31 views

yasnippet color

I use yasnippet in orgmode to expand codeblocks of Python and start typing code. My snippet is defined as: # -*- mode: snippet -*- # name: emacs-jupyter code block for python (silent) # key: <spp #...
1
vote
2answers
118 views

org-babel-tangle with function in header arguments

Following this suggestion, I have a function to automatically generate figure names: #+begin_src emacs-lisp :exports none (set (make-local-variable 'i) 0) (fset (make-local-variable 'fig-file) #...
2
votes
2answers
53 views

Clear all code blocks

Say you have an org file with several code blocks like the one below: #+BEGIN_SRC jupyter-python :session py :results silent :async yes stuff more stuff even more stuff #+END_SRC Question: Is there ...
0
votes
1answer
55 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
40 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
38 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
97 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
57 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
60 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
43 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
17 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
24 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
24 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
24 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:...
1
vote
0answers
29 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
24 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
36 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
131 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
31 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
48 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
65 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 #...
3
votes
3answers
151 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 ...