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
26 views

Get value of a variable from another session in org-mode

How to share variables' values in org-mode between different sessions? Simple example: in session one I create _gpg_tmpdir #+name: make_temporary_directories #+begin_src bash :session *one* ...
1
vote
1answer
37 views

Org Mode: reference an org tree for input in code block

I want to use a (sub)tree of my org file as an imput to a python babel source block to parse it and to stuff with it (in my case generate a folder structure based on the headlines of that tree). I ...
1
vote
0answers
21 views

Org-Babel Unable to Tangle to Write-Protected Folders?

I'm trying to move my OS configuration over to org mode, and in the process I'd like to be able to tangle to write-protected directories like /etc Unfortunately, tangle doesn't seem to work whenever ...
0
votes
0answers
22 views

how to not html export src block result in org-babel

I'm using emacs version 26.3 with org-mode version 9.1. how to stop from exporting #+RESULTS and export only code block. #+BEGIN_SRC python :results output print('hello world') #+...
1
vote
1answer
21 views

“Run all code blocks above this point” in org-babel?

I know you can use org-babel-execute-src-block (C-c C-c) to execute individual code blocks, but is there something akin to "Run all chunks above" that RStudio has for Rmarkdown files?
0
votes
0answers
11 views

Record command into bash source block using asciinema and org-babel

As you perhaps know, asciinema rec (asciinema rec path/to/file) and generate an asciicast file which contain all commands recorded on terminal. I think using asciinema to replay this file (asciinema ...
2
votes
2answers
31 views

org-mode call python source within latex source block

I have a piece of python code that outputs latex code. I'm trying to call the python source block from within a latex source block so it will format the output as latex when I export. Any idea how ...
1
vote
0answers
28 views

Can I specify tags as a property to avoid cluttering the headline?

Having tags in the headline clutters the view and is quite distracting when the tags are not directly pertinent to it. An example of this is the noexport tag which describes what to do with the ...
1
vote
1answer
77 views

rewrite relative or absolute path from inherited tramp ssh property with org-babel

I define a global remote session for all my sh block code with properties :PROPERTIES :HEADER-ARGS:bash: :dir /ssh:xxx@myvm:/home/xxx/ :END: In my other bash blocks, I inherit this property, but ...
1
vote
1answer
40 views

Org-mode: use result from babel in another programming language

Org and babel in emacs are awesome. Is it possible to have something like this: Here is a C code #+BEGIN_SRC C :output results #include <stdio.h> int main(){ int x = 5.00; int i; ...
0
votes
1answer
27 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 ...
0
votes
1answer
16 views

org-mode capture click event within org-babel code block

I wish to run C-c C-c, then click any code line to trigger my code (print "clicked" in this demo) #+BEGIN_SRC elisp :results output (defun myclick(n) (interactive "p") (print "clicked") ) (add-...
0
votes
1answer
48 views

Managing path for reproductible scientific paper using session, org-babel and org-mode

I'm starting using org-mode and org-babel to support my day by day scientific work and produce reproductibles papers. Lot of people use rMarkdown/jupyter to do that, but i'm interested by investing ...
1
vote
1answer
37 views

Write text between inline exported code and the result of this execution code?

After some search, i don't found example corresponding to my use case. Writing a research text, i'm interested to mix source blocks code and text with results using inline mode, for example this ...
3
votes
1answer
49 views

No graphic output for MATLAB src block in org-mode

In an org file, if I include a MATLAB src block that has a graphic output (a figure is plotted there), for example, the following src block: #+begin_src matlab :session :file tst.png :results ...
0
votes
0answers
18 views

shell blocks chaining with :post-processing calls and using stdin to create “filter” blocks

To increase modularisation of my emacs code blocks I'm attempting to factor out common functionality into separate function blocks. I'm running into difficulties with chaining :post calls, and using :...
1
vote
1answer
24 views

org-babel - Use specific python path and command line option

Since different python version installed on my system, how can I use specific python and option to run it? For example,below test.py file will print hello output. #!/opt/anaconda3/bin/python --...
1
vote
1answer
16 views

Python src block sets tabs

Emacs 26.3, Org 9.3 When using python src block, it changes 8 spaces to tab. When tangling this, python errors with "inconsistent use of tabs and spaces in indentation". How fix it?
0
votes
0answers
8 views

Removing extra blank lines in R output

I noticed than when writing a multiline src code block in Org-mode, and if only the final command line produces an output, the R output includes an extra blank line at the top, like here: #+begin_src ...
0
votes
1answer
54 views

How to disable code blocks in an Emacs org-mode init file

My dot emacs config consists of a short init.el file and a very large org file in which I have created dozens of emacs-lisp code-blocks. This works very well for me, especially in terms of ...
1
vote
1answer
16 views

What is the `'inf-template` file in the ob-template.el file (template for creating new babel language)

Because the options provided by the mathematica.el file in org-contrib are quite limited, I am trying to create a new, extended, mathematica.el file. As explained on the org language development page, ...
0
votes
0answers
32 views

Export comments and babel src results to markdown

When I export to another format like rst from org, the comments #comments and the results from babel src will not be exported. How could I include them to export?
1
vote
1answer
74 views

No org-babel-execute function for js!

I'm using org-mode in Spacemacs and have this code block: #+BEGIN_SRC js :var payload=access-token-payload let parsedPayload = JSON.parse(access-token-payload); return parsedPayload.access_token; #+...
2
votes
1answer
172 views

Efficient workflow to write a book in Org-mode

I plan to write a short statistics textbook using Org-mode. Even if some textbooks have been written using equivalent systems (e.g., the R package bookdown), I have no examples in mind of books ...
2
votes
2answers
56 views

Insert Org or Markdown code blocks with Babel in org-mode?

In org-mode, if I do something like this: #+begin_src org ## What does this PR do? - Updates the Dockerfile to make the `dev` service connect to a shared network at startup - Registers the `...
0
votes
0answers
26 views

Force org-babel-load-file to execute every time emacs is loaded

I have this code in the init.el file: (org-babel-load-file (expand-file-name "myinit.org" user-emacs-directory)) Which used to generate a myinit.el file every time I start emacs. I would ...
1
vote
1answer
33 views

Remove the suffix `^M` when run ls in org src

When run ls to print the file list #+begin_src ipython :session sql :results output ! ls | head -n 5 #+end_src #+RESULTS: : create.txt^M : Lesson 10. Grouping Data.md^M : Lesson 11. Working with ...
0
votes
1answer
24 views

org mode babel use contents of block as file in another block

I'm trying to define some data in json file and use the file name in another bloc as command parameter. Something like that: The data: #+BEGIN_SRC json { "Foo": "Bar" } #+END_SRC ... and the ...
1
vote
1answer
67 views

Best way to make orgmode source code blocks aware of my $PATH and other environment variables?

By default my source code block can't find most executables: #+BEGIN_SRC bash which aws #+END_SRC #+RESULTS: This fixes the problem: #+BEGIN_SRC bash source $HOME/.bash_profile which aws #+END_SRC ...
0
votes
1answer
38 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 ...
0
votes
1answer
33 views

Retrieve the lunar phases to diary.org as a record

I tried to record the sunrise and sunset info to the diary #+begin_src emacs-lisp :tangle yes (sunrise-sunset) ;;(lunar-phases) #+end_src #+RESULTS: : Sunrise 6:57am (CST), sunset 5:00pm (CST) at ...
0
votes
0answers
20 views

Redirect mysql complete ouput to results

I tried sql source code in org mode #+begin_src sql :engine mysql :dbuser org :database grocer select prod_id, prod_name, prod_price from Products; #+end_src #+RESULTS: | prod_id | prod_name ...
0
votes
0answers
63 views

(solved) Error “Tangled 0 code blocks from [file]”

I'm writing a bash script with literate org-mode. The header of the file is: #+TITLE: start-lcs #+AUTHOR: Stahlberg #+EMAIL: stahl at gmail dot com #+DATE: 2019-11-02 #+PROPERTY: header-args:sh :...
1
vote
1answer
64 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: ...
3
votes
1answer
78 views

hlines in bash/sh source code block

How can I insert a horizontal line (hline) in a bash/sh source code block? My goal is to separate the header line from the rest. #+begin_src sh echo "header1,header2" echo "???" # placeholder for ...
0
votes
1answer
19 views

How to get correct list numbering with code blocks items in Org-babel?

Here is a minimal working example of Org file for LaTeX export: #+OPTIONS: toc:nil * A list with R source blocks 1. This is the first item. #+begin_src R :results output :session *R* :exports both x ...
-1
votes
1answer
30 views

Can “kaz-yos/eval-in-repl” use the prexisting “inf-ruby” console started by robe mode

I've been using org babel to execute ruby code, works well but wrapping blocks with begin_src/end_src is cumbersome no live output - i have to wait till the whole process finishes to see output ...
0
votes
0answers
117 views

How to execute a org-babel source block within the working directory?

Say you have the following org-babel source block: #+BEGIN_SRC latex :results raw :file test.pdf \LaTeX #+END_SRC When executing it, org-babel will do the actual compilation in a temporary directory ...
0
votes
0answers
9 views

Missing Code Page

I need a code translation page for a file containing Russian Cyrillic characters in an unknown format, not alternativnyj, not cyrillic-iso-8bit, not cyrillic-koi8, not ruscii. Cyrillic-iso-8bit comes ...
1
vote
1answer
54 views

Org Mode Babel: Is there a way to assert the expected results of evaluation?

Is there a way to assert that the results of evaluating a code block with Babel are equal to an expected text? Ideally, I would use this to stop an export to PDF if one of the assertions does not hold....
1
vote
1answer
61 views

Config is broken when I use load-user-file

This is my config for org-babel: (use-package org :mode (("\\.org$" . org-mode)) :ensure org-plus-contrib :config (org-babel-do-load-languages 'org-babel-load-languages ...
1
vote
0answers
52 views

Org-mode results verbatim not working for Scheme code

I have the following source block of Scheme code: #+BEGIN_SRC scheme :results value verbatim append (define shift (lambda (list-with-sublists) (cond [(pair? (car list-with-sublists)) ...
0
votes
0answers
44 views

How to adjust image size of an org-babel output permanently?

I know I can add html or latex attributes under the #+result: block after executing the block, but when I re-evaluate the block, it is removed.
1
vote
0answers
16 views

Highlighting the currently active org-Babel block

I want to do something similar to hl-line-mode but not sure if it has been implemented already and how it can be implemented. The goal would be to set two color schemes for the #+begin and #+end ...
0
votes
0answers
13 views

shell code block in win10

I wish to run shell code in org sh code block as below: #+BEGIN_SRC sh :results output dir c:\ #+END_SRC #+RESULTS: : c:\>More? The output is not as expected! BTW, I have add below line in my ....
0
votes
1answer
87 views

Evaluate single line of python code from Emacs org-babel

Consider a block of python code in an org-mode document: #+begin_src python num1 = input("Enter a number: ") num2 = input("Enter another number: ") result = float(num1) + float(num2) print(result) #...
1
vote
1answer
58 views

Remove extra prompts in Emacs Babel Python session

When I run the following code block from Emacs org-babel: #+BEGIN_SRC python :session *Python* :results output print("Hello World") #+END_SRC This is what prints out in my *Python* session: >...
1
vote
1answer
73 views

Org-babel python with session breaks output

If I run the following code block: #+BEGIN_SRC python :results output print(" /|") print(" / |") print(" / |") print("/___|") #+END_SRC I get the result as expected: #+RESULTS: : /|...
1
vote
1answer
146 views

Cannot add general block header arguments in org mode

While I'm learning javascript following a book, I Like to take notes with org-mode. I use Indium and followed this instructions to handle it working It works well, and I get my work done, interacting ...
1
vote
0answers
24 views

Spaces get trimmed when I use org table in (R) code block

Please, help! I use literate programming and I want to use org-mode tables as data for my R code blocks. However, when it comes to cell values that have meaningful leading and trading spaces org-mode ...

1 2 3 4 5 10