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
28 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-...
0
votes
1answer
26 views

Pandas data frame as table

I'm enjoying learning org-babel to write literate documents and am trying to include summary tables produced by Pandas describe(). I found an old thread with some answers but none of the provided ...
0
votes
0answers
15 views

Spacemacs gg=G replacing tabs with spaces in org-babel makefile block

I'm using Spacemacs, and my org-mode file contains an org-babel block of Makefile code, which I want to "tangle" so it becomes part of the source code while remaining in sync with the ...
0
votes
1answer
25 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 ...
2
votes
1answer
26 views

Hide non-breaking spaces in org-mode, but show them in code blocks

Default Emacs settings show non-breaking spaces as a kind of underscore. This is very useful because these otherwise invisible characters would break code execution in many programming languages, and ...
0
votes
1answer
25 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 ...
0
votes
0answers
18 views

Org source block for Octave session fails with large matrices

Sometimes I have to analyze quite large matrices with octave as part of a documented reproducible work. Org files with Octave source blocks are the ideal format for that purpose. One defines the ...
0
votes
0answers
21 views

org include and export yaml to html

I have an org file where I include a yaml source file: #+INCLUDE: ".myfile.yaml" src yaml This is good when I want to export to pdf or html to be as verbatim code. But is there a simple way ...
1
vote
1answer
53 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, ...
0
votes
1answer
23 views

Org babel remove currency form ledger output

Howto remove the currency from the table or get ledger -j to work so that gnuplot can work with the data? #+NAME: LedgerCli #+BEGIN_SRC ledger :results raw :cmdline reg "Assets:Service Days" --...
1
vote
0answers
20 views

Save output from ob-mermaid to the org-attach director

I have recently started playing with the fantastic ob-mermaid (and its companion mermaid-mode) package. Combined with the mermaid CLI, these let you generate mermaid diagrams from org-babel source ...
2
votes
1answer
59 views

How to activate Coq for Org source blocks?

I have been writing some Coq code in Org, but when I try to run a source block, I get the following message: No org-babel-execute function for coq! I have tried to initialize the coq language in the ...
2
votes
1answer
21 views

Font-lock Yasnippet template from within Org-Babel block

I want to manage my library of snippets from a single org-mode document and tangle these to their respective snippet files, as needed. Now functionally, this works out-of-the box, with the one ...
0
votes
0answers
27 views

Org and EIN (IPython): No output for print

I am using EIN in Org blocks, as explained on the GitHub page for EIN. So I use ein-python as the language for Org blocks (instead of python). All seems to work well (for example displaying data from ...
0
votes
0answers
25 views

How to export the tangled filename as comment?

I often add #Content of sample.script as top line in my org-babel scripts. Thus the reader knows the name of the tangled file: #+begin_src sh :tangle sample.script #Content of sample.script echo ...
1
vote
1answer
54 views

ein org mode results raw drawer

I am trying to use ein with org-mode in emacs but I am having problems with exporting the results. Here is a very simple example: #+BEGIN_SRC ein-python :session localhost :results raw drawer :...
0
votes
0answers
57 views

Long running jobs in emacs org mode

When I execute a long running script within the org mode, emacs freezes. Is there a way to see the (running) output of the script? Alternatively, is there a way to run script asynchronously, and then ...
1
vote
1answer
27 views

Can org-babel filter code blocks?

I have a general emacs.org file that I load at init time with org-babel. It's made for desktop use, and I load a bunch of IDE features, face customizations, powerline and so on. However, I also ...
0
votes
2answers
68 views

Executing code within Org mode `begin_src` … `end_src` blocks

How to configure Emacs to run code in different languages as shown in this post? Specifically, how to run these type of code blocks #+begin_src shell :results list ? After 9 years of vim, that post ...
2
votes
2answers
55 views

stop stripping result of :session for python print statement

Since default value for :result header is value print statement will only show with :result output #+BEGIN_SRC python :results output print(' hello') #+END_SRC #+RESULTS: : hello but same ...
1
vote
0answers
19 views

Modifying syntax so as to grey out the non-source part of an org file

I thought a nice alternative to (org-edit-special) (which becomes cumbersome with many small blocks), and to tangling-and-untangling (which is incompatible with noweb references), might be simply to ...
0
votes
0answers
27 views

Org babel with noweb syntax and untangling

I just stumbled upon the possibility of using noweb syntax with org-babel, so that named source blocks can be referred to from other blocks, as in #+name: hullo #+begin_src hullo there, ...
0
votes
2answers
58 views

Add-advice :before org-edit-special

I want to advise org-edit-special so that a function runs before Emacs enters org-src-mode. I am not particularly tied to org-edit-special. If there is a hook like org-src-mode-hook (but that triggers ...
0
votes
2answers
53 views

Extract value from org-babel-get-src-block-info

I have this elisp code: #+BEGIN_SRC emacs-lisp :dir ~/org/test (defun test () (setq args '(org-babel-get-src-block-info)) (cdr (assoc ':dir args))) (test) #+END_SRC But when I execute the code ...
0
votes
0answers
43 views

Pass org-babel header arguments to elisp function

I have an org-babel code block like so: #+BEGIN_SRC R :var a=~/path/to/project Do something here #+END_SRC How can I reference variable a without having to evaluate the block?
1
vote
1answer
76 views

Display inline eps images in Org mode

Maybe quite a noob question, but I can't figure out how to display inline eps images in an org file. There is no problem with png (or jpeg, ...) images, but I can't preview eps images. Here is a ...
0
votes
0answers
7 views

ESS/Org-babel - remove long prompt

Consider the following org-babel code block: #+BEGIN_SRC R :session *R* getwd() #+END_SRC If I first enter org-edit-special and then ess-eval-line my *R* buffer displays as expected: > getwd() ...
0
votes
2answers
25 views

Set ESS working directory from header-args with org-babel sessions

I am experiencing a very strange behavior with org-babel code blocks. When I operate without the :session tag, I am free to use :dir to set my working directory. As you can see, the following code ...
0
votes
0answers
21 views

Evaluate org-babel header arguments consistently

Consider the following org-babel code block: #+BEGIN_SRC R :session *R* :dir ~/_test getwd() #+END_SRC When I C-c C-c on my source block, I get the following result, as expected: #+RESULTS: : /...
0
votes
1answer
25 views

Auto evaluate org mode source block on file save

For example, whenever I edit my config, I run this block to reload the config: #+begin_src emacs-lisp :tangle no :var data=replace-symlink :results none (org-babel-load-file (locate-user-emacs-file "/...
0
votes
0answers
18 views

Byte-compile org-babel code blocks when tangled

I want to override org-babel-tangle-file to byte compile any org-babel code block where a compile: t flag is set in header-args. Here is the idea: * Sample code block :PROPERTIES: :header-args: :...
1
vote
1answer
33 views

Babel equivalent for other modes

Babel lets you include code blocks of different programming languages inside an Org-mode document, which can be printed and executed. Is there something similar for other modes as well? For example, I ...
1
vote
1answer
45 views

Relative file paths in included begin_src blocks

I have this file structure: . ├── main.org └── part1 ├── img/ └── part.org main.org: * Main file ** Part 1 #+include:part1/part.org part1.org: #+begin_src gnuplot :exports none :results ...
1
vote
1answer
35 views

How to set image size in result of src block in Org mode

I've got a src block that has an image file as a result and I want that image file to be exported as a certain size. I know I could apply the property #+ATTR_HTML: :width 100px, but I can't figure ...
0
votes
0answers
17 views

how to check if a babel block finished the execution

I am searching for a piece of emacs-lisp code that checks if an emacs-babel block finished its execution. I am trying to write smth like (while (babel-block not finished its execution) (sleep-...
0
votes
1answer
29 views

org-babel's matlab (session) output is malformed

I'm trying to evaluate some Matlab code using org-babel in a session: #+BEGIN_SRC matlab :session :results output a = 1:10; b = a + 3 c = a - 3 #+END_SRC And following the org-babel documentation, ...
2
votes
1answer
53 views

How to pass through variables through src blocks to other src blocks

I am using Emacs version 26.3 and Org Mode version 9.3.6. My goal is to have several different #+CALL: lines, each using a different value of some header argument (in the example below, that is inarg)...
1
vote
1answer
47 views

Org babel: Use variable to set a figure caption

This is what I want to do: In some-file.org: * Table 1 #+NAME: table-1-title Characteristcs of Data #+BEGIN_SRC R :file table-1.svg :results output graphics file ( ggplot(mtcars, aes(mpg, cyl)...
0
votes
3answers
74 views

Org-babel loads different Python

I'm very new to org-mode and org-babel. After installing oh-my-zsh I noticed that I cannot run the source code in my org files like before. My code is like follows #+BEGIN_SRC python :results output ...
1
vote
2answers
48 views

Why does org mode elisp evaluation not print text properties?

With no special header argument values, I have #+BEGIN_SRC emacs-lisp (propertize "abc" 'face 'italic) #+END_SRC #+RESULTS: : abc whereas C-x C-e on the form gives me #("abc" 0 3 (face italic)) ...
0
votes
1answer
46 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 ...
1
vote
1answer
18 views

Org mode evaluating propertized string removes properties

See the following code block: #+BEGIN_SRC emacs-lisp (setq s #("abc" 0 3 (face (:foreground "red")))) (pp s) #+END_SRC #+RESULTS: : #("abc" 0 3 : (face : (:foreground "red"))) which is as ...
2
votes
1answer
151 views

How can emacs org-mode execute shell code remotely as sudo?

My self-documenting maintainance scripts, where I document how systems have been setup, I need to execute stuff as sudo/root and want the results automatically added to the document. But for safety ...
0
votes
0answers
18 views

Enable trace-function from org-mode

I test the following procedure from org-mode #+name: case-2.1.1-factorial.el #+BEGIN_SRC elisp (defun factorial(n) (if (= n 1) 1 (* n (factorial (- n 1))))) (trace-function #'factorial) ...
1
vote
0answers
24 views

org-babel python :session names matter

For example, I get #+BEGIN_SRC python :session sdfjkl :results output import numpy #+END_SRC #+RESULTS: : Python 3.8.0 (default, Oct 23 2019, 18:51:26) : [GCC 9.2.0] on linux : Type "help", "...
0
votes
0answers
27 views

Maxima org code blocks on windows

I'm new to emacs, coming from vim, using spacemacs atm. My problem is that when I try to evaluate maxima code blocks in emacs, for example: #+begin_src maxima a: 1+1; print(a); #+end_src I get the ...
0
votes
1answer
34 views

How to change Org-mode babel tangle write to file way as prepend instead of override by default?

There's an answer here for appending the current code block to an existing file. I want to do the opposite, which is to prepend the current code block to an existing file. Could you please help?
0
votes
0answers
14 views

org-agenda loaded from init.el but not configuration.el (babel)

I structure my configuration with an (org-babel-load-file "~/.emacs.d/configuration.org") so I write my code in the configuration.org and then a configuration.el gets generated. It works with the ...
0
votes
1answer
78 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 ...
1
vote
0answers
25 views

Multiple insert point org source code insert

I know that we can customize the source code expansion <s TAB using something like this (add-to-list 'org-structure-template-alist '("s" "#+BEGIN_SRC ? :results raw replace drawer ...

1
2 3 4 5
11