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 Org-babel is now incorporated into Org-mode as 'working with source code' and no longer a separate extension.

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

org-babel SQL How to use SELECT result single result without data cleanup?

I have quite a few SQL org-babel functions for fetching various(single record) IDs from the database. The snippet below works, but is there any way to skip that middle function that converts SQL ...
0
votes
1answer
22 views

orgmode - latex new line in tikz node not work

Below code works fine if copy the tikzpicture to tex file. but in orgmode, looks like the new line not take effect! #+header: :imagemagick yes :iminoptions -density 300 -opaque white -flatten -...
0
votes
1answer
21 views

Org mode exam template with question and results in combination with latex

I would like to use Org mode for creating exam questions and including the templates for the corresponding results for each question. A general template is shown here #+TITLE: Lecture #+AUTHOR: ...
1
vote
3answers
91 views

orgmode - do not export example block

I try to use a example block as input to babel block, I want to export babel results only, in below example, I try to add exports none to example block but it doesn't work, the example content ...
1
vote
1answer
15 views

How do I get org-mode to treat the output of a non-latex code block as latex?

(Emacs: v27.1, Org: v9.5, pdfTeX: v3.14159265-2.6-1.40.21) I am using the following Python code block to print LaTeX code: #+BEGIN_SRC python :session :exports both :results output :wrap math ... #+...
0
votes
0answers
15 views

Noweb references in sh blocks breaks the syntax highlighting

I use noweb references inside sh code blocks, for example: #+begin_src sh echo "test" <<some-ref>> echo "test" #+end_src But this causes syntax highlighting to ...
2
votes
1answer
36 views

Org-mode: disable abbrev-mode in source blocks

I use org-mode to write an executable paper, combining text and code. I make use of abbrev-mode to insert text more efficiently (e.g. type 'bc' to insert 'because') and to correct spelling errors. Is ...
0
votes
0answers
11 views

Dependent state in org-babel :var arguments

I enjoy using org-babel for testing/exploring API HTTP endpoints. #+BEGIN_SRC http :var access-token=select-access-token-from-sql :pretty GET http://localhost:3000/api/items/71 Authorization: Bearer ${...
0
votes
0answers
18 views

How to turn the result returned by `org-sbe an-src-block` into list (of lists)?

In MWE.org, the source blocks list-files, summarize-files-1, and summarize-files-2 are defined to summarize files. The list-files source block gives the filenames. The summarize-files-1 and the ...
0
votes
2answers
40 views

Org Mode evaluate diff code block

I'm writing a programming tutorial. In between the prose I have diff code blocks that show exactly what changes are done to the code on each step. To make sure the diffs are correct I'd like to be ...
0
votes
0answers
13 views

Pass a table's colnames to an R block

I have an org file with this content: #+name: my-table | *Type* | *Value* | |---------+---------| | Web | 744 | | Checks | 520 | | Cash | 105 | |---------+---------| | *Total* | ...
0
votes
1answer
24 views

org-mode org-babel share a global variable across the file

I'm a beginner org-mode user. Is there a way to remove baseUrl being duplicated in each block like the following one? #+NAME: request-something #+HEADER: :var baseUrl="http://localhost:3000" ...
2
votes
0answers
100 views

Emphasize text snippets in source blocks

If one sets org-src-fontify-natively to t org source blocks are fontified according to the associated major-mode. That is fine. But, is it possible to emphasize text snippets within the source blocks, ...
1
vote
1answer
32 views

How to remove indent on left margin and vertical line from src block when exporting org-mode to ascii?

When I export an org file to an ascii file, using org-export-to-ascii, I get some annoying lines on the left margin and an indent ,---- | .class{ | background:red; | } This is what I'm after: ....
0
votes
0answers
13 views

Get rid of “> > > > > > bash-5.1$” prefix in the results of a org babel code block

Anytime I execute a code block with C-c it contains the following prefixed results: #+RESULTS: #+begin_example > > > > > > bash-5.1$ <result-output> #+end_example This is the ...
0
votes
2answers
20 views

Org Babel execute bash via ssh on non-default port; `(wrong-type-argument number-or-marker-p nil)`

Problem In an org file, I have a source code block containing bash code that I want to run on a remote machine: * test :PROPERTIES: :header-args:bash: :dir /ssh:skid@127.0.0.1#2221: :END: #+...
0
votes
1answer
38 views

Can't evaluate plantuml in org-mode blocks

I have this weird error I don't understand : #+begin_src plantuml :file img/example-uml.png @startuml class Example { - value : Integer - other : Double + up() + down() } @enduml #+end_src This fails ...
0
votes
1answer
50 views

Org mode + Gnu Octave session

I interact with the Gnu Octave's inferior mode and everything seems to be working fine there: octave> pkg load symbolic octave> syms x g = (x+1)/sqrt(x^2 - 1) simplify(diff(g,x)) octave> g = (...
1
vote
1answer
38 views

org-babel-tangle error

I am experiencing a very unusual (concerning) error with my org-mode installation, and I am afraid that something might be broken. First, I have this setup in my .emacs file ;; Use my org-mode file as ...
3
votes
2answers
43 views

How to copy the content of the source block at point to the kill ring?

Suppose you're in org mode and working with source code. Your point is currently inside a source block at some random position. Is there an easy way to copy the body of source block (excluding #+...
0
votes
2answers
71 views

How to use C header files in org-mode source code blocks?

I have a C code block in my org-mode document like the following: #+begin_src C :exports both #include "my_header.h" int main(void) { function_from_my_header(); return 0; } #+...
1
vote
1answer
34 views

How can I set frame title to include Babel language when point is in a block

My frame title is currently set as (setq frame-title-format '(buffer-file-name "%f" ("%b"))), or for example /path/to/file.org. I'd like to set my frame title to include the ...
0
votes
0answers
10 views

How to not include newlines in strip-export

I'm using the following snippet #+NAME: save-file #+BEGIN_SRC python :results silent :var filename="filename" plt="plt" :exports none return f"\nfname = 'assets/' + filename + ...
0
votes
1answer
30 views

Output of shell command in source block is displayed as table

The output of the shell commands is displayed as table. How can I have it displayed as "simple" lines of text ?
1
vote
1answer
49 views

How to generate a PNG from a TikZ figure with org-babel?

I'm try to use org-babel to generate images from tikz code. The first code (take from this example) works perfectly, but when y want to export the tikz figure in a png (or a jpg) I have an error like ...
1
vote
2answers
117 views

Defining variables in org mode using tables

I often want to define a whole bunch of variables at the top of an org file. In some cases I think it would be really nice to define all the variables in a table. So far, the best solution I've come ...
3
votes
0answers
43 views

How to embed pgfplots picture in org-mode

I want to include tikz/pgfplots pictures in an org-mode document both for inline visualisation and export. I have tried approaches given in this emacs-orgmode thread and in the worg documentation ...
1
vote
0answers
43 views

orgmode - adjust tikz picture width for beamer output

In this example, the first column width adjust works but the second column doesn't. * topic ** column1 - first - second :PROPERTIES: :BEAMER_col: 0.5 :BEAMER_env: block :END: #+ATTR_LATEX: :...
0
votes
1answer
47 views

Cannot evaluate matplotlib in Python code block

These are my first attempts to plot graph in Python. Following this example , I tried a very simple graph import matplotlib.pyplot as plt import matplotlib as mpl import numpy as np x = np.linspace(0,...
1
vote
1answer
52 views

library for code execution for markdown via org-babel

Are there any libraries out there that can take the markdown code fence block and execute it via org babel? Ie, something like '''js var a = 1 var b = 2 return a + b ''' Reasoning: I don't see not ...
1
vote
1answer
40 views

Find org babel header arguments documentation for shell language

The org manual specifies in the this link: https://orgmode.org/manual/Languages.html#Languages the language it supports (including shell). It mentions this: Additional documentation for some ...
0
votes
1answer
46 views

org-babel: define commands for all named source blocks in given set of files

This answer shows how to define a command that executes a named org-babel source block. If you want to do this for all named source blocks in a file, you could define one command per block. That's ...
0
votes
1answer
59 views

Is there a way to call M-x my-org-babel-block?

I have a named org-babel source block like this: #+NAME: my-org-babel-block #+BEGIN_SRC elisp :results output (print org-babel-load-languages) #+END_SRC Is there any way to call this block with M-x ...
0
votes
0answers
21 views

org mode evaluate code blocks up to the current cursor?

Is there a way to execute all code blocks in an org file up to the current cursor point? I know that there is C-c C-v C-b for evaluating all code blocks. But often times, I'd like to resume from a ...
0
votes
1answer
57 views

org export with interleaved output

I have an Org mode file with the following source block in it: #+begin_src sh :exports both echo "first line" echo "second line" #+end_src #+RESULTS: | first | line | | second | ...
0
votes
1answer
17 views

wrap each line with a function and collect each value outputs from an org src block

How do I wrap each line with a function and collect all value outputs from an org src block and collect all value outputs from an org src block? For example, If I have #+begin_src python 3492-134.2 ...
1
vote
1answer
111 views

How can I enable lexical binding for Elisp code in org-mode?

I have the following code: #+begin_src elisp (setq lexical-binding t) (let ((a 1)) ; binding (1) (let ((f (lambda () (print a)))) (let ((a 2)) ; ...
0
votes
0answers
85 views

Syntax highlighting not working in src blocks (org babel)

I'm having some trouble with org src blocks and syntax highlighting - the highlighting is not present in the block, but does appear in the new window that appears when running org-edit-special. org-...
0
votes
0answers
67 views

Emacs 27 Win 10 with WSL2 in org-mode, #+BEGIN_SRC bash, block appending \r newline character

Windows 10, now has WSL2, which enables one to use linux bash shell. I have Ubuntu 20.04 installed as my default linux distribution in WSL. What can I do to tell org-babel, in a src code block, what ...
2
votes
1answer
42 views

How can I actually evaluate a #+CALL statement?

I have several named source blocks in an .org file. I can execute each of them by pressing C-c C-c when point is on (or in) them. Now I want to call them in a row. So I added some call statements: #+...
1
vote
2answers
51 views

Why is the matplotlib plot produced by executing `org-babel-execute-src-block` contain errors?

The context Consider the following Emacs configuration $ cat ~/.emacs.d/init.el (org-babel-do-load-languages 'org-babel-load-languages '((python . t))) $ and the ...
0
votes
0answers
53 views

How to replace raw code block output

I would like to execute a python code block to produce new headlines (i.e. modify the current org file programmatically). If I produce raw results with a replace argument, the replace argument seems ...
0
votes
0answers
16 views

Org babel code block does not italicize fonts

I set my comment style to be italic, this is done via customizing the variable font-lock-comment-face. For regular code files, this works-> comments are italic. This does not work for an Org code ...
2
votes
1answer
70 views

How to write a basic org-babel-execute function for a new language?

What I'm trying to achieve is very simple: take a source block, write it to a temp file, pass the file name as an argument to an executable which will run it, and then include the output in the #...
2
votes
1answer
52 views

Cannot create org-babel matlab source block with vector input arguments

I want to create a re-usable matlab org-babel source block vectsb (say), which takes two vectors from a call statement, performs some operations with them, and returns the result in the call statement....
0
votes
0answers
28 views

How to retrieve specific lines of a “#+RESULTS” block through noweb references?

The context Lately, I've been writing the configurations of all the programs I use in Org Mode because of some features that improves the readibility of such files. The code block below shows a part ...
2
votes
0answers
60 views

Convert orgmode to Rmd

As the title says, I have an orgmode file I have been using with ess and exporting to TeX which has been going very well. However, I need to now export to html for reasons out of my control, and was ...
5
votes
2answers
166 views

Tangle Org file containing #+INCLUDE directives and multiple tangle targets

Context I'm using org-babel-tangle to generate my configuration from an Org file config.org. Recently, I did some clean-up by dispatching config.org to multiple Org files config/*.org; replace the ...
0
votes
1answer
88 views

Limiting the number of lines of org babel result

Is there an easy method to limit the number of lines in org-babel results? For example: I have the following org-babel block: #+begin_src js :exports both :results output for (let i = 1; i <= 100; ...
0
votes
1answer
105 views

Setting the value of a variable in Org babel system-wide header arguments

The context I always experiment with commands in the following path $HOME/trash/experimental. For this reason, I wanted to make all shell code blocks to use that directory as the default directory. I'...

1
2 3 4 5
13