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
2 votes
0 answers
257 views

Format <<<target links>>> in org-mode for printing

Is there a way to format target links created by org-mode when using radio targets such as the following: <<<some text>>> where that some text is linked back When outputting to ...
Emacs User's user avatar
  • 5,643
2 votes
0 answers
405 views

How do I get comments in a noweb expansion?

Given the org-mode file * File Description :PROPERTIES: :comments: org :tangle: file.sh :noweb: yes :END: ** A function call This is foo #+BEGIN_SRC sh :noweb-ref myfunction :tangle no ...
Gambo's user avatar
  • 929
2 votes
1 answer
204 views

Org entry found only from its own buffer [duplicate]

I tried to detangle (org-babel-detangle) a latex file and got the error message Cannot find entry with ID "......." with the ID of the subtree of the first block. But the entry does exist in the ...
Toothrot's user avatar
  • 3,264
1 vote
3 answers
923 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 ...
lucky1928's user avatar
  • 1,666
1 vote
2 answers
733 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 ...
Tad Lispy's user avatar
  • 133
1 vote
2 answers
1k views

How to make Org-Babel support tangel to su/sudo file with tramp-sudo?

I hope to let org-babel can tangle to root permission file with tramp-sudo support like the following format: #+BEGIN_SRC clojure :dir /sudo:: :tangle "/etc/kk.clj" ... #+END_SRC But it does not ...
stardiviner's user avatar
  • 1,908
1 vote
2 answers
4k views

Error on using org-babel-load-file

I am trying to write emacs init using Org-mode By using org-babel-load-file function in init.el. My init.el file is (require 'package) (add-to-list 'package-archives '("melpa" . "https:...
Nithin Varghese's user avatar
1 vote
1 answer
823 views

org-mode: link to tag/target inside a source code block

I'd like to place a link to a tag or target inside a source code block. #+BEGIN_SRC emacs-lisp (use-package evil :ensure t :config ; enable per default (evil-mode ...
AWG's user avatar
  • 13
1 vote
1 answer
1k views

Attempting to use org-babel to write “literate” Rust

I'm playing around with writing Rust snippets in my editor. I can get org mode to format my things nicely and play nicely with rust-mode. But I can't evaluate my code snippets. I think that may be ...
cryptograthor's user avatar
1 vote
1 answer
791 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://...
donnaworriaboutit's user avatar
1 vote
1 answer
805 views

org-mode table-formula and code-blocks: function parameter is cut off on whitespace

In Org-mode working with 'src' code blocks and table formulas together, org-mode cuts of the cell strings at the first whitespace character. I.e.: having a cell with Hello World the 'src' code block ...
jue's user avatar
  • 4,566
1 vote
2 answers
247 views

How can I make Org-mode's code-block output into another code-block in a different language?

I'm using a Python code-block (the middle part of the code below) to convert the table (top part) into an Emacs Lisp code-block (the bottom part). #+NAME: tmp_table | key | trans | description ...
Garid's user avatar
  • 641
1 vote
3 answers
49 views

use org properties as variables in c or python source code

I'm using org-mode to control some charges, using c++ code to balance. But I have to assign the values by hand. And I would like to assign the values via org properties or some other form of ...
Levo's user avatar
  • 47
1 vote
1 answer
218 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 --...
Zeta's user avatar
  • 1,093
1 vote
1 answer
898 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" ...
Nikita Fedyashev's user avatar
1 vote
2 answers
493 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 ...
doltes's user avatar
  • 587
1 vote
2 answers
148 views

Is there a way to use org-mode to render generated code? [duplicate]

I'm new to org-mode, so I apologize if this is a silly question, but I couldn't find the answer on my own. I have the following block: #+BEGIN_SRC sh :exports both :results output verbatim code sed '...
Alex R's user avatar
  • 239
1 vote
2 answers
90 views

how to tangle only source code blocks that belong to a specific target file?

Let's say we have the following org file: #+begin_src python :tangle "target1.py" a=11 #+end_src #+begin_src python :tangle "target2.py" a=21 #+end_src #+begin_src python :tangle ...
martinoidar's user avatar
1 vote
1 answer
78 views

In executing code block in org-mode, how to use result of different code block, where result is a file?

So, I need to pass the content of one Org source block into another. There are a couple of ways. One can use :noweb header and reference content in the second block using <<first-block-content&...
iLemming's user avatar
  • 1,253
1 vote
2 answers
193 views

Babel Lilypond Paper-Size (Preview & Export)

When trying to use babel lilypond for music engraving inside org, I have got the following problem: The paper size used by lilypond is always a full page. But what I want is a minimal, growing paper ...
Oma Paloma's user avatar
1 vote
1 answer
79 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 ...
Sibi's user avatar
  • 3,683
1 vote
1 answer
314 views

use org-mode babel execution to generate templates for org-mode execution

Background I want to use org-mode to create a WBS to then create JIRA issues. org-babel looks like the right option as I can use shell to invoke curl commands to invoke the JIRA API for create issues. ...
Bae's user avatar
  • 222
1 vote
2 answers
678 views

Add timestamp to file name in org export

How can I create a time stamped file name with the org header arg: #+export_file_name: <timestamp-var> + File name There is a variable org-time-stamp, is there a way to append it to the static ...
Gaurav's user avatar
  • 115
1 vote
1 answer
167 views

How to switch org-babel-execute-src-block to use y-or-n-p?

In short, I want org-babel's prompt to accept a single y/n keypress instead of typing it out and pressing enter, but I don't want to replace all such prompts globally. I've seen information on ...
Digicrat's user avatar
  • 187
1 vote
1 answer
680 views

Disable indenting on org-babel restclient edits

Despite I am not a new Emacs user, my elisp is nearly not existent. I want to present some REST API stuff with epresent and org babel restclient. This is working fine until I want to edit a source ...
Plurax's user avatar
  • 13
1 vote
2 answers
572 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: ...
Vladimir Alexiev's user avatar
1 vote
1 answer
356 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....
Sati's user avatar
  • 775
1 vote
1 answer
513 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 ...
nanounanue's user avatar
1 vote
1 answer
411 views

eval elisp code to fill org-babel header arguments

I use many org files with figures generated by source code blocks. By example, in an org mode file long/path/document.org I have: #+BEGIN_SRC dot :file my_fig.png :exports results digraph { A->...
Picaud Vincent's user avatar
1 vote
1 answer
708 views

Interpreter discrepancy in org-babel-python and python-mode

(Emacs version 26.1, Org version 9.1.9) I have tried numerous solutions to get working in org-mode source blocks. This solution works to change python-mode to utilize the Python3 interpreter, which I ...
ch-pub's user avatar
  • 220
1 vote
1 answer
364 views

How to add hline and column sum to bottom of table using a src block?

I want to (non-interactively) add (one hline and) a last line to a table in which the last column is summed. Like so: #+name: mytable | p | q | |---+---| | a | 5 | | b | 2 | #+begin_src emacs-...
Werner's user avatar
  • 355
1 vote
1 answer
273 views

Why is my output of this org doc with lilypond code different than shown?

This page about ob-lilypond has an example of PDF output of this org file. The PDF looks great--small sheet music snippets under explanatory text. The whole thing fits on 2 pages. However, when I grab ...
Steven Arntson's user avatar
1 vote
1 answer
134 views

org-babel not concatenating strings before sending to code block variable

I have just started using org-mode and org-babel as a lab notebook. I am trying to use a code block to fill in two columns of a table. The code block seems to work for the first column because those ...
Darwin's user avatar
  • 119
1 vote
1 answer
30 views

How to save org-mode file without results of source code block

I'm preparing a presentation in org-mode and I'd like to demonstrate live the execution of code. So I'd like to start the presentation without any result block. How can I remove (strip) the results on ...
hintze's user avatar
  • 113
1 vote
1 answer
98 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
  • 5,192
1 vote
2 answers
100 views

Set org babel results section to folded

Is it possible to set #+RESULTS section for specific source blocks to folded? Just like you would add visibility folded property to a heading.
Arktik's user avatar
  • 972
1 vote
1 answer
55 views

Copy org-babel Source Block

I have this great piece of code to copy the contents of a code block: (defun copy-org-babel-source-block-at-point () (interactive) (kill-new (plist-get (cadr (org-element-at-point)) :value)) ) ...
Jason Hunter's user avatar
1 vote
1 answer
83 views

Cannot set R :session in file property for interactive use

I would like all R src blocks in an org file to use the same session interactively and have included a minimal example below. I added the #+PROPERTY line as in the manual and ran C-c C-c as suggested ...
ejneer's user avatar
  • 13
1 vote
1 answer
149 views

File-local variables do not affect org-babel-execute

I am trying to compile a org block with latex using org-babel and I set some local variables # local variables: # org-latex-pdf-process: ("lualatex -output-directory=%o %f") # org-format-...
Massimo2013's user avatar
1 vote
1 answer
249 views

Difference in emacs org-mode for bash/shell

Among other parameters, the Emacs setup I'm using contains the instruction (org-babel-do-load-languages 'org-babel-load-languages '((emacs-lisp . t) (python . t) (shell . t) (ditaa . t))) ...
Buttonwood's user avatar
1 vote
1 answer
234 views

How to evaluate Python code blocks with pipenv instead of system environment?

I'm trying to use org-mode as an alternative to Jupyter. I'm able to evaluate code blocks with system environment by doing C-c C-c on blocks, but I don't know how to evaluate it through pipenv ...
crocefisso's user avatar
  • 1,274
1 vote
1 answer
75 views

How to list all the code blocks in the current buffer with no #+NAME?

Let's say I have a buffer with some code blocks, but I want to know the location of those code blocks that doesn't have #+NAME set.
rdrg109's user avatar
  • 408
1 vote
1 answer
86 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 ...
andreoss's user avatar
  • 159
1 vote
1 answer
44 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 ...
mankoff's user avatar
  • 4,196
1 vote
1 answer
209 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 ...
lecodesportif's user avatar
1 vote
1 answer
86 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 | ...
Sibi's user avatar
  • 3,683
1 vote
1 answer
344 views

switch-to-buffer from org mode code block

Evaluating a code block containing (switch-to-buffer "test-buffer") does not display test-buffer. It creates the buffer, but it does not switch to it. #+BEGIN_SRC emacs-lisp (switch-to-...
Reverse_Polish's user avatar
1 vote
1 answer
529 views

Execute source block without output

I use the package ryo-modal-mode and for the key assignment I have long code blocks in an org-file. If I execute the code block I get a very long table under #+RESULTS. Is it possible to execute a ...
breathe_in_breathe_out's user avatar
1 vote
1 answer
762 views

org-mode text expansion macro in src block

Is it possible to use an org-mode #+MACRO: in an org-babel block? I'm getting this in the #+RESULTS: block when I evaluate the src block with C-c C-c: #+MACRO: COMPILE_FLAGS -std=c99 -Wall -Werror ...
Alex Shroyer's user avatar
1 vote
2 answers
324 views

Org-mode: different key bindings for different types of code blocks

Is is possible to define key bindings for org-mode that: Only work inside code blocks; Are specific to the programming language of the code block. For example: if my source code block is for Python, ...
Guilherme Salomé's user avatar

1
7 8
9
10 11
17