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

How to write a basic org-babel-execute function for a new language?

What I'm trying to achieve is very simple: take a source block, write it to a temp file, pass the file name as an argument to an executable which will run it, and then include the output in the #...
2
votes
1answer
31 views

Cannot create org-babel matlab source block with vector input arguments

I want to create a re-usable matlab org-babel source block vectsb (say), which takes two vectors from a call statement, performs some operations with them, and returns the result in the call statement....
0
votes
0answers
21 views

How to retrieve specific lines of a “#+RESULTS” block through noweb references?

The context Lately, I've been writing the configurations of all the programs I use in Org Mode because of some features that improves the readibility of such files. The code block below shows a part ...
2
votes
0answers
37 views

Convert orgmode to Rmd

As the title says, I have an orgmode file I have been using with ess and exporting to TeX which has been going very well. However, I need to now export to html for reasons out of my control, and was ...
4
votes
2answers
62 views

Tangle Org file containing #+INCLUDE directives and multiple tangle targets

Context I'm using org-babel-tangle to generate my configuration from an Org file config.org. Recently, I did some clean-up by dispatching config.org to multiple Org files config/*.org; replace the ...
0
votes
1answer
38 views

Limiting the number of lines of org babel result

Is there an easy method to limit the number of lines in org-babel results? For example: I have the following org-babel block: #+begin_src js :exports both :results output for (let i = 1; i <= 100; ...
0
votes
1answer
27 views

Setting the value of a variable in Org babel system-wide header arguments

The context I always experiment with commands in the following path $HOME/trash/experimental. For this reason, I wanted to make all shell code blocks to use that directory as the default directory. I'...
1
vote
1answer
27 views

How to create a initial collapsed/hidden block in org exported HTML?

I'd like to create a collapsible block (examples, quotes, codes, ...) when exporting an org file to HTML. Also I'd like to have a way to show the block(button? keystroks?). How can I do this? Thanks!
0
votes
0answers
33 views

Customize org-babel latex template when evaluating a source block

I'm using latex source blocks to generate images with org-babel using :results file as in the example below #+begin_src latex :results file graphics :file myplot.pdf :fit yes \LaTeX #+end_src When ...
0
votes
0answers
9 views

Broken hightlighting code src block in org-mode 9.4 and org-babel

I found that org-mode org-babel hightlighting is broken by nix line of script. How to reproduce : a) create a nix block #+name: home-manager-section #+begin_src nix home.file."nixpkgs"....
0
votes
0answers
25 views

How to print a separator line at an specific location in the results of a `#+BEGIN_SRC` block whose language is C++?

The context In #+BEGIN_SRC blocks whose language is Python, I can show a separator line in the table that shows the results by using None (see example below) #+begin_src python :results output table ...
0
votes
0answers
18 views

How to replace sections of non-org files from within org-mode?

I am trying to write some notes on django with the help of org babel. Is there a way to replace a block in a file(which was not tangled with org) after I eval a certain src block? Here's what I mean: ...
1
vote
1answer
18 views

`org-babel-load-file` doesn't always tangle source file

I'm on Org 9.3. I run the following test. [OP@localhost bug1]$ ls real.org test.org The contents of real.org are: [OP@localhost bug1]$ cat real.org #+PROPERTY: header-args :tangle yes #+begin_src ...
0
votes
1answer
31 views

Make output of source code blocks be inserted regardless of the exit status of the evaluation

The context When evaluating the following code block, the output is not inserted in the #+RESULTS code block. This happens because of the return 1 statement. #+begin_src cpp :results output #include &...
4
votes
1answer
65 views

Make python code blocks format their results as Org tables

The context In #+BEGIN_SRC code blocks whose language is cpp or sh, the tab character is used as a delimiter for cells when using the :results table header argument (see examples below) #+begin_src ...
3
votes
2answers
64 views

org-babel: Make results always quote the returned value in #+begin_example

Github's org parser has a bug where they mistakenly show #+begin_src bsh.dash :results verbatim :exports both echo | time possiblycat 1000 #+end_src #+RESULTS: : : possiblycat 1000 0.00s user 0.00s ...
0
votes
1answer
20 views

Dealing with strange characters in org babel results

I am playing with SaltStack configured by org babel source blocks. I try to pass output of salt fingerprint to minion configuration file. If I use one command direcly in bash I receive this output: # ...
1
vote
1answer
32 views

Show compilation errors in “#+RESULTS” code blocks

The problem I'm currently writing notes on C++ classes. Sometimes I annotate what I shouldn't do (because they cause compilation errors) so it would be really helpful if I could automatically insert ...
0
votes
0answers
42 views

Multiple source code blocks with the same name

The context Lately, I've been using the =:noweb= feature which has been of great help. Consider this minimal working example * Using =std::cout= #+NAME: a #+begin_src cpp std::cout << "a&...
0
votes
0answers
26 views

Typescript Indentation in org-babel (ob-typescript)

I've setup org-babel for Typescript and the indentation is all over the place. What exactly controls this indentation?;) I basically just have this code in my configuration: (defun org-babel-execute:...
0
votes
0answers
6 views

Getting rid of `nil` generated by R when having spaces in table cells

I have this very simple org file that generates nil values for apparently no good reason: #+name: table | | 2014 | |-----+------| | A B | 1 | | C | 2 | #+name: linechart #+begin_src R :...
2
votes
1answer
30 views

Nested noweb in org src blocks

I have the following code blocks: Block 1 is just one line. This is a MWE. In reality, I have several lines in block 1. #+name: block1 #+begin_src python :noweb no :exports none print("Block 1&...
1
vote
1answer
26 views

Pass a subset of the columns of a table to a script

I would like to pass only some columns of a table to a script: #+name: table #+RESULTS: | Col0 | Col1 | Col2 | Col3 | |-------+------+------+------| | Line1 | 1 | 2 | 3 | | Line2 | 4 | ...
0
votes
0answers
27 views

Org Babel is returning the results of a cached file instead of the output of any org-babel blocks

NOTE: After restarting the python session and deleting all of the cache files about five separate times, everything started working as expected and I can't replicate the problem. I would still be ...
1
vote
1answer
24 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. ...
1
vote
0answers
22 views

Exporting JPG image from LaTeX SRC-block with :async header

I like to generate JPG images from my LaTeX/tikz drawings in my org files. For this, I use constructs like #+NAME: my image #+HEADER: :file my-image.jpg #+BEGIN_SRC latex :results file raw :...
1
vote
0answers
44 views

org-babel: zsh sessions use bash

#+BEGIN_SRC zsh :session z1 echo $HOME $0 #+END_SRC #+RESULTS: : /Users/evar /bin/bash I am thinking of trying the workaround outlined here, but shouldn't this work out of the box? Update: I couldn'...
0
votes
0answers
32 views

Show stderr, by default, in the output section of evaluated code blocks [duplicate]

The context I'm currently using org-mode to take notes on the grep command. The grep version I have on my system doesn't support searching multiple patterns when the -P (i.e. --perl-regexp) flag has ...
2
votes
1answer
33 views

Include lines in tangled source code but not in executed code block

The title might be slightly confusing. What I mean is this. Let's say I have a code block which has some error checking code. If there is an error, the (tangled) program should not continue past that ...
3
votes
4answers
100 views

org-mode and babel export - setting tangled (exported) files as readonly

I want to maintain a single org file which contained a plethora of different init files (.bashrc, .profile, .tmux etc that type of thing). Here's a portion:- #+PROPERTY: header-args :tangle yes :...
0
votes
0answers
11 views

Handle notes and documentation in long source blocks (split variable definition in org-babel)

I discovered the feature of literate config files with org-babel. Some variable definitions can get pretty long, for example org-agenda-custom-commands if there are many custom agendas. At the moment ...
0
votes
0answers
28 views

How can I kill a runaway/hung remote shell process from Org-Babel

I am using org-babel for literate programming and enjoying it so far. The major issue I have run into so far though is killing a runaway/hung remote shell command (short of exiting Emacs altogether). ...
4
votes
1answer
111 views

Org Src Block does not return any output

TL;DR: How do I get the stderr of my source block to be part of the #+RESULTS block, without changing the contents of the block? I can only get stdout to appear. [Long and winding explanation] While ...
0
votes
0answers
29 views

How to not display environment variable in org-babel src block?

I want the effect of this: #+BEGIN_SRC shell :dir src CC=gcc-9 make #+END_SRC But I don't want CC=gcc-9 to show up in the output. Is there a way to somehow include the environment variable in the ...
0
votes
1answer
63 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
76 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 ...
1
vote
1answer
34 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
28 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
47 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
47 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
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
32 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
25 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
96 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
45 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
75 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 :...

1
2 3 4 5
12