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
1
vote
1answer
28 views

How to execute parameterized src block via elisp and get result?

I have a src block to get a value from some table: #+NAME: ref #+BEGIN_SRC emacs-lisp :var name="" table=main (let ((key (if (symbolp name) (symbol-name name) name))) (nth 2 (assoc key ...
1
vote
1answer
61 views

org-mode spreadsheet formula, can one use the result of org-babel block?

I'm trying to find a way to use the output of existing org-babel block in org-mode spreadsheet formulae without rewriting them in emacs-lisp. Is it possible? TBLFM line is pseudo code, it is ...
0
votes
1answer
27 views

org-babel multi-line header var

I'm trying to find a way how to conveniently edit(and pass) multi-line arguments to org-babel block. In the example below, ${name} variable is pretty convenient to edit as inline variable but for ${...
1
vote
0answers
35 views

Jupyter-like setup with org-babel in spacemacs

I've been trying to switch my data-analysis workflow from Jupyter lab/notebook to org-mode + org-babel for quite a while. I'm looking for an emacs setup that will provide all the functionalities of ...
1
vote
0answers
36 views

Set org source block name label as variable

Does someone know if it is possible to set the #+NAME label for source blocks as a variable? E.g.; I would like to be able to set the label with elisp, something like: #+NAME: (concat "name_"...
0
votes
0answers
23 views

Include LaTeX code blocks from another file to generate a “main” file (similar to using \input{} in .tex)

I have a .org file (say exercises.org) in which I put LaTeX exercises in the form of code blocks. The file looks something like this: #+NAME: ex1 #+BEGIN_EXPORT latex Compute $2\cdot 2$. #+END_EXPORT ...
3
votes
1answer
56 views

prevent eval of a single src block

How do I ensure that only the second block never evaluates, while still allowing the first block to be evaluated normally? #+begin_src shell echo "hi" #+end_src #+begin_src python print(&...
0
votes
0answers
23 views

Execute org mode code block without escape codes

When I run a bash code block I get a response which contains a lot of escape codes/sequences, which makes the results output less readable. Example below: How can execute the code block, without the ...
0
votes
0answers
25 views

Babel source block export format customization

I have this #+begin_src haskell :results silent :exports code :{ maximum'' :: (Ord a) => [a] -> a maximum'' = foldl1 (\x acc -> if x > acc then x else acc) :} #+end_src but on export ...
1
vote
1answer
55 views

How to pass org-babel code block as variable to another code block?

I would like to pass the code from code block test_python to script. I do not want test_python to be evaluated, but simply to have the source code inserted into script when I evaluate script. The goal ...
1
vote
1answer
25 views

emacs org mode define a function in src block and call it

is there a method/package to use the following syntax to define and call a function? #+NAME: retX #+BEGIN_SRC python :var x=5 def retX (x): return x #+END_SRC ... Some text later... #+begin_src ...
0
votes
1answer
39 views

How to disable certain org-mode blocks from accidental execution

I have some shell code that can be dangerous to run on local machine in a org-mode source code block. Globally, I have configured org-mode to prompt for execution, but I would still like to make sure ...
1
vote
1answer
46 views

Why is electric-indent-mode adding extra indentation after pressing return twice in org source blocks?

When I try to write code in source block in Org mode, pressing return once acts as expected while hitting it a second time increases the indentation to two levels if it's currently less than that. ...
2
votes
1answer
71 views

Automatically update a date in tangled files of an .org file?

I'm in the process of writing a LaTeX class using org-babel for the literate programming. In several places of the file .org file, I have to insert the release date of this class, at least in the ...
0
votes
0answers
18 views

olivetti mode with polymode?

I am using olivetti-mode with org-mode, but the screen does not stay fixed to the same width when my cursor moves from the org text to code between #+begin_src ... #+end_src. Is there a simple fix ...
0
votes
0answers
25 views

Session support in org mode babel

I am trying to set up org-mode babel to work with MAGMA. What I have so far is very simple but works well enough. The problem is that it does not support sessions, which would be quite important to ...
3
votes
1answer
52 views

Org mode python code block with session does not return a result

I had been successfully using python code blocks with the :session header argument when I noticed that upon export no result was given. I then simplified my example to the following two: #+...
0
votes
0answers
38 views

(org-babel-load-file (expand-file-name “~/.emacs.d/config.org”)) behaves strangely on Windows 7

In my initialization file the line (when (file-readable-p "~/.emacs.d/config.org") (org-babel-load-file (expand-file-name "~/.emacs.d/config.org"))) give me the error: *Warning (...
1
vote
1answer
67 views

Why can't I use rg (ripgrep) in an Org mode source block?

I have the following source block in my Org mode file: #+begin_src sh :results output exec 2>&1 mkdir -p /tmp/example && cd /tmp/example echo "hello" > world rg --...
1
vote
0answers
59 views

Trying to run Scheme in org mode

I installed geiser, set my default scheme to guile, and enabled scheme support but I can't seem to get it to work. I am getting this output and am not sure what to make of it. #+begin_src scheme :...
2
votes
2answers
77 views

org-mode source block: conditional header

How can I modify the header of a source block dynamically, based on the backend used to export my org-mode document? Specifically, I want the header to include :results output html when the file is ...
0
votes
0answers
41 views

Evaluate JavaScript source block in org-mode

If I attempt to evaluate a JavaScript source block then I have to return a value to get a result. For example: #+begin_src js return 1 + 2; #+end_src #+RESULTS: : 3 That's a bit unusual. I guess ...
0
votes
0answers
9 views

How to output the tangle property as comment as in org babel?

Tangling this: #+begin_src sh :tangle /home/user/foo.txt echo hi #+end_src Should become this: $ cat foo.txt #/home/user/foo.txt echo hi Can I maybe lisp evaluate the org babel :comment e.g. (...
0
votes
0answers
49 views

How to get JSON response only from an ob-restclient block

I'm trying to construct an Org-based pipeline for some DevOps activities. Part of this requires making REST API calls and proceeding based on the results of those calls. I'm using ob-restclient for ...
0
votes
0answers
32 views

`org-sbe` in block A cannot find block B defined in the same file if A is called externally

Calling uutil.org:summarize-files() in the other file prj_sum.org triggers (error "Reference ‘list-files’ not found in this buffer"), even though both summarize-files and list-files reside ...
0
votes
0answers
34 views

Skip noweb reference at export when org-export-babel-evaluate is set to nil

I have an org-mode document with many code blocks that I do not want to be evaluated at each export so I set the org-export-babel-evaluate to nil to avoid these evaluations which works as expected. ...
0
votes
0answers
24 views

How to Implement Column Wrap in org-mode Tables Programmatically

Note: This question is not well suited for standard emacs StackExchange format but I believe the discourse and exchange of techniques would be valuable for the community because the wrapping cells ...
0
votes
1answer
20 views

Org-babel: Notify if the result of execution differs from the previous recorded result

I want to use my org-mode documentation as a sort of quasi-unittest; I want to execute the whole buffer, and be notified if marked cells' new results differ from their previous results. E.g, #+...
0
votes
0answers
18 views

Using web-mode “localized” in babel

I am using org-mode babel to take notes. I am using source code blocks to write down examples of html interspersed with javascript. I take the notes in a subtree within a pretty big document. Now, ...
0
votes
0answers
30 views

Evaluate shell source block on spacemacs

I'm new to spacemacs. I did a fresh install following these instructions. When i try to evaluate a shell src block, i get the following message: org-babel-execute-src-block: No org-babel-execute ...
0
votes
0answers
14 views

Is it possible to use org-babel for periodic automated calls?

Is it possible to have an org-babel snippet that calls itself periodically e.g. every second and updates its RESULTS output? #+BEGIN_SRC emacs-lisp (current-time-string) #+END_SRC The following ...
0
votes
1answer
25 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
37 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
36 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
169 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
19 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 ... #+...
2
votes
0answers
86 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
44 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
15 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
28 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
102 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
15 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
76 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
128 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
53 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
14 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
28 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
132 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
78 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
117 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 ...

1
2 3 4 5
13