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

Tangling fails when using #+PROPERTY instead of manually adding header arguments when using org source blocks

The following code doesn't work, yet adding :tangle tangleobject.org manually to each source block provides us with the expected tangle result. Any clue why? #+PROPERTY: header-args :tangle ...
shintuku's user avatar
  • 105
0 votes
0 answers
16 views

How to use a dynamic block (column view) as input to a babel function?

I am trying to use the table of an org-mode columnview dynamic block as input to a org-mode babel function. It works fine with static tables, but with the dynamic table, I get a "Reference not ...
Holger Karl's user avatar
0 votes
0 answers
17 views

detangle preserve noweb

I've recently gotten into literate Programming with org-mode. I'd like to be able to write all my functions across multiple Code Blocks, tangle them into a files but also test them from inside the org ...
Tomke Pfoch's user avatar
1 vote
1 answer
79 views

Execute Code with Env Var Set Temporarily

Here's a piece of C++ code (its content is not important) written in an Org file: #+BEGIN_SRC C++ #include <omp.h> #include <iostream> int main() { #pragma omp parallel std::...
shynur's user avatar
  • 4,638
2 votes
1 answer
61 views

Configuring Key-bindings from Org-Table

I use init.org file to configure my emacs, and then tangle it into init.el. Now, I would like to configure my keybindings from org-table (for more readable and printable). Basically, I'd like to only ...
Garid's user avatar
  • 589
0 votes
1 answer
21 views

org can't execute on remote machine

I have a .org file on my laptop that I use to run code on a remote server. However, when I try to execute the code I'm getting Tramp errors. My local org file has the following header: # -*- org-...
Tyler's user avatar
  • 21.9k
1 vote
0 answers
46 views

org-mode latex export of source block with engraved gives error for latex3 code due to missing color-`face` processing

I want to export my source blocks from org-mode to pdf through latex with the export backend engraved. I installed the package engraved-faces, set the variable with (setq org-latex-src-block-backend '...
lukeflo's user avatar
  • 195
0 votes
1 answer
40 views

Why does adding a return value to my Python code stop it from printing?

Load up Emacs in the default modes, i.e. emacs -Q. After this, make a new .Org file with the following contents and run the Emacs Lisp code. (setq org-babel-python-command "python3") (setq ...
J. Mini's user avatar
  • 103
0 votes
2 answers
47 views

How to jump to #+RESULTS: when point is at Org source block?

When point is on a source block, I want to be able to jump to the #+RESULTS section of that source block. If the source block does not have a #+RESULTS: section, I want to do nothing: I don't want to ...
Vitalij Chepelev's user avatar
2 votes
0 answers
33 views

org-babel python code block - not showing errors during execution

I have a python code block in an org-file that when executed results in some error. I was expecting to see that error in the #+RESULTS: block, but it doesn't show up. I have to navigate to the python ...
skittish's user avatar
0 votes
0 answers
15 views

Org-mode: Adding Attributes and Captions to Babel Table Results

Given the following org-mode file: #+TITLE: Tests #+LATEX_HEADER: \usepackage[outputdir=build]{minted} * Export Configuration #+name: Configuration #+begin_src emacs-lisp :results silent :exports ...
Xaldew's user avatar
  • 1,201
1 vote
0 answers
34 views

Can :var NAME=ASSIGN in org mode work if ASSIGN includes a colon?

I use org-ref in org-mode to handle cross references, and I use labels like tab:one, fig:two, etc., to identify label types and format them accordingly (using cleveref in LaTeX export). I then have ...
Stefano's user avatar
  • 141
0 votes
1 answer
39 views

org-mode: How to define then call a Java method using source blocks

I have a super simple example where I have a list, a Java method and a call to this method. It looks like this: #+name: animals - dog - cat - guinea pig - horse #+name: does-contains-cat #+begin_src ...
Nicryc's user avatar
  • 147
0 votes
1 answer
57 views

Fish and org-babel

I am having troubles with the output of a fish session in org-babel. It seems to be related to the bracketed paste, but only happens when :session is used. I was wondering if there is any way to clean ...
barbacoa's user avatar
1 vote
1 answer
59 views

Help me get Scala source blocks working in org mode

UPDATE: This issue was fixed for me by changing my version of scala from scala 3 to 2.13, as recommended by NickD in the comments below. END UPDATE When I attempt to evaluate Scala source blocks in ...
Duncan Britt's user avatar
1 vote
2 answers
115 views

run check-parens or similar when saving or tangling literate configuration?

I use org babel to load my literate configuration file "config.org". But sometimes when editing that org file, I introduce some error -- say, a missed parenthesis -- and then restart emacs. ...
Dan Drake's user avatar
  • 573
0 votes
0 answers
31 views

Use an org-mode code block to execute other code blocks

I want to use a code block to execute other code blocks with a given language. For example, in my document I want to validate every HTML block using the W3 validator. Currently I do it as follows. ...
Tad Lispy's user avatar
  • 133
2 votes
0 answers
18 views

Stop producing excess whitespace in .png files from TikZ code

I've been using Org src blocks like the following to generate .png images of TikZ diagrams. #+name: tikz-functions #+header: :file tikz-functions.png #+header: :imagemagick t :iminoptions -density 800 ...
nonreligious's user avatar
0 votes
0 answers
25 views

org-mode: How do I insert correctly escaped text using elisp?

I want to insert some code using elisp into org-babel source blocks. This needs some escaping, such as replacing * with ,*. Is there a builtin insert function that handles these escape rules ...
HappyFace's user avatar
  • 791
0 votes
0 answers
17 views

Need help using a custom tcblistings environment for src blocks

I'm trying to advise the function org-latex-src-block--listings to use a tcblistings environment that I like. In LaTeX the environment is used like... \begin{code}[title=TITLE, language=LANGUAGE, file=...
user41177's user avatar
  • 121
1 vote
0 answers
21 views

How to remove results drawer from emacs jupyter?

I am using emacs-jupyter (commit - 16cbda79167b4e2f2c6b61b218658f0f660d97f9 [otherwise I get an error]) on emacs-29.1 and org-9.7pre. My default header arguments are... org-babel-default-header-args:...
user41177's user avatar
  • 121
1 vote
0 answers
52 views

How To Tangle Org Src Code Block Under Conditions

I'm using .org files to keep track of my system configuration across different machines and I want certain code blocks to be tangled only if certain conditions are met. Let's say I have something like ...
thanosapollo's user avatar
0 votes
0 answers
26 views

org-babel-detangle writes duplicated code

I am trying to use org-babel-detangle for a while, but the source code is detangled twice in the main org file. Interestingly, when I run (org-babel-detangle "file_name.cpp") it does not ...
Gabriel Petrini da Silveira's user avatar
0 votes
0 answers
72 views

How to make org-babel evaluate noweb reference only once?

To get user input for a shell script, I prepared an emacs-lisp source block. #+name: get_text_from_user #+begin_src emacs-lisp (let ((text (read-from-minibuffer "Enter some text> "))) ...
lecodesportif's user avatar
0 votes
1 answer
75 views

How can I use the JSON result of org-babel in curl?

I first define #+NAME: 01H7T457WEWS07WD5T05BS5CN9 #+begin_src shell :results verbatim replace drawer :wrap src json echo "foo" #+end_src #+RESULTS: 01H7T457WEWS07WD5T05BS5CN9 #+...
Jason Hunter's user avatar
0 votes
0 answers
40 views

In Elisp, how can I insert an org-babel JSON block into a variable with noweb?

In Elisp, I want to insert the contents of the "gazonk" JSON block into a variable. #+name: gazonk #+begin_src json { xyzzy " } #+end_src , but I just get "End of file during ...
Jason Hunter's user avatar
0 votes
0 answers
16 views

Why does org-babel hang when piping to xsel?

It doesn't hang if I open eshell;) #+begin_src shell echo "ehlo" |xsel -b #+end_src
Jason Hunter's user avatar
2 votes
0 answers
24 views

How can I limit the scope of org-babel named code blocks?

Is it possible to limit the scope of named code blocks to subtrees for example? For example, if I have a code block named foo, can I limit this "foo" to only be available for subheadings and ...
Jason Hunter's user avatar
0 votes
0 answers
41 views

With org-babel, how can I reference a JSON code block with noweb?

Using noweb, I'm trying to reference a JSON block #+name: gazonk #+begin_src json { xyzzy " } #+end_src #+begin_src shell :results verbatim :noweb yes gazonk="${<<gazonk>>@Q}&...
Jason Hunter's user avatar
0 votes
1 answer
24 views

Org Babel incorrectly displaying Shell output

Org Babel (Shell) in a session ends up truncating output from the shell. MWE: test.py: #!/usr/bin/env python3 print(""" Stats: CPU Busy 24 (100.00%) Stats: IO Busy 15 (62.50%) Stats: ...
mon's user avatar
  • 23
0 votes
1 answer
58 views

How to collapse the output of code evaluation in org mode?

I would like to evaluate the code blocks in org-mode. However, when the output is lengthy, I want the output result to be collapsed. When I export the org file to the html, I want to see the result. ...
virtual_mind's user avatar
0 votes
0 answers
20 views

Prevent deletion of blank lines when tangling code blocks

The Python style guide asks for two blank lines surrounding class and function definitions (see PEP 8). When those blank lines are added in Org-Mode source blocks, they are removed during tangling. ...
Ben Bkhdt's user avatar
0 votes
0 answers
24 views

`:output-dir` is buggy and what is the usage difference between `:dir` and `:output-dir` header arguments?

The manual says :dir is working directory and :output-dir is output directory. It is a a bit confusing. If I don't set output dir, shouldn't it generate output files in the working directory? For ...
RNA's user avatar
  • 368
0 votes
1 answer
39 views

Using numpy array with Org Babel

I want to pass in 2 arrays and have python process them. The babel block works when I put the arrays directly in but if I try to pass them in via headers, they don't appear as arrays to numpy. My ...
user1625344's user avatar
0 votes
0 answers
36 views

Org Babel generated graphics and GitHub display

I'd like to build README.org files with graphics that properly render on GitHub. Currently I find that, for example, emacs-jupyter babel blocks render images locally via file:./path/to/file.png. ...
mankoff's user avatar
  • 4,138
0 votes
0 answers
21 views

Polymode in org-edit-special

I use (add-hook 'python-mode-hook 'poly-python-sql-mode) where poly-python-sql-mode is a special polymode that correctly highlights SQL queries that are used within strings in a Python file. When this ...
guibor's user avatar
  • 121
0 votes
1 answer
94 views

(wrong-type-argument stringp nil) error when calling tangle

As the title says, I get this error whenever I, or the function I'll show below, call org-babel-tangle. I'm using a org file to configure emacs, which tangles every time it is saved to my init.el. The ...
Felipe Canteiro's user avatar
2 votes
0 answers
52 views

watch ouput of src block execution in real time?

When I type, e.g. #+begin_src shell :session *foo* echo 1 sleep 5 echo 2 sleep 5 echo 3 #+end_src , hit C-c C-c inside the code block and then C-x b RET *foo* RET, I have to wait 5 + 5 ...
toomas's user avatar
  • 183
0 votes
1 answer
28 views

how can I update the org-mode header-args from the output of an org-babel code block?

I have a code block with a shell scripts that asks for a token. I want to insert this token into the header-args, so that I can reference this from other code blocks. I usually copy it, but can this ...
Jason Hunter's user avatar
0 votes
0 answers
21 views

Why does a named org-mode source code block get used when it was only declared and not used in another source block?

it's required to have #lang racket to use the substring procedure. So I defined it like this: #+NAME: directive #+begin_src racket #lang racket #+end_src #+begin_src racket :var directive=directive (...
mustaqim's user avatar
0 votes
1 answer
58 views

Add parent heading of source code block as comment in tangled file

If I have something like this: * Function heading #+begin_src racket :var x=3 y=4 :tangle "file.rkt" (define (distance x y) (sqrt (+ (sqr x) (sqr y)))) (distance x y) #+end_src ...
mustaqim's user avatar
0 votes
0 answers
75 views

lsp-org, lsp-format-buffer

In a csharp org-babel block, is lsp-format-buffer supposed to work? #+begin_src csharp :tangle "11dde4eb-97fe-c7a0-78b7-b38c1b4a1e02.cs" System.Console.WriteLine("Hello World..."); ...
Jason Hunter's user avatar
0 votes
1 answer
27 views

org-babel closing RESULTS tag

For a RESULTS in org-babel, is there an option to close it? For a src block, we have a closing #+end_src, but there is no end results type of tag;)
Jason Hunter's user avatar
0 votes
1 answer
44 views

Can I find snippets using yasnippet for the mode of an org-babel block (e.g. python / bash)?

I like snippets. I use yassnippet a lot. I also use babel in org mode. I would quite like to be able to use my snippets in org babel blocks, but they don't work because I am in the wrong mode. Is ...
Att Righ's user avatar
  • 745
0 votes
1 answer
35 views

org-insert-structure-template on non empty line

When I insert a code block, I usually first mark the current line, before I issue org-insert-structure-template, but can I encapsulate the current line, without selecting it? Something like this, but ...
Jason Hunter's user avatar
0 votes
0 answers
38 views

Display Pillow image object in Babel Org Mode directly without saving into a file?

I wonder if there is any way for Babel in Org Mode to display images (from libraries like Pillow or matplotlib) "directly" without saving them into a file: #+begin_src python from PIL import ...
Daniel Krajnik's user avatar
0 votes
1 answer
156 views

Header arguments in Org mode properties: how to activate them locally?

I do C-c C-c on the property ("local set up refrehsed") and C-u M-x org-babel-tangle on the code block: * foo #+PROPERTY: header-args:latex :var val=1 #+name: foo #+begin_src latex :noweb ...
user avatar
0 votes
2 answers
67 views

How to pass a variable to a LaTeX code block?

I'd like to set a variable to be expanded in several LaTeX code blocks. For the sake of simplicity, there is only one in this case, foo. :header-args :var is ignored: I presume because LaTeX does not ...
user avatar
1 vote
1 answer
21 views

org-babel latex picture resolution very low

I try below code in ubuntu 22.04 but the output image resolution very low: #+HEADER: :file /media/sf_work/demo.jpg #+HEADER: :results file graphics #+HEADER: :headers '("\\usepackage{tikz}")...
lucky1928's user avatar
  • 1,644
0 votes
1 answer
52 views

How can I maintain invisible solutions to exercises within an org-file?

Running code within an Org file greatly simplifies writing. It's possible to see the output and confirm everything works as expected. ** Exercises Implement the following function. #+BEGIN_SRC ...
Sam7919's user avatar
  • 339

1
2 3 4 5
17