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
0answers
24 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
33 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
55 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
29 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
30 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
108 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
24 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
46 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
27 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
85 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
1answer
83 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
32 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
181 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
61 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
25 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
47 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
121 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
62 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
53 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
185 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
9 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
47 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
29 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
54 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
36 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
35 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
50 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 ...
2
votes
1answer
60 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
18 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
69 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
59 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
55 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
128 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
89 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
60 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
23 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 ...
4
votes
1answer
313 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
21 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
25 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
29 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
39 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
16 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 ...
1
vote
1answer
173 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
27 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
vote
2answers
151 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 ...
3
votes
0answers
78 views

org-babel-tangle-file multiple files into a single output

Is there a way to tangle an org file with #+INCLUDE: statements? Or other ways to tangle multiple org files into a single output?
2
votes
1answer
81 views

Error: No org-babel-initiate-session function for bash!

I would like to use the session feature for bash source blocks, and receive the error message. No org-babel-initiate-session function for bash! A simple code is shown below. The code can be executed ...
3
votes
2answers
57 views

Change behaviour of “comment-region” in org-mode tangled source blocks?

I am experimenting with using org-mode for some of my startup config, and adding (org-babel-load-file (concat user-emacs-directory "config.org")) to my .emacs. Then I use a structure like the ...
1
vote
1answer
57 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 ...
1
vote
1answer
56 views

Customize org babel execution command in C

I have the following C code: #include <stdio.h> #include <math.h> int main(){ printf("Square = %d", pow(4,2)); return 0; } Now if I run this in the shell. I would first compile ...

1
2
3 4 5
12