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
3answers
36 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
40 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
29 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
12 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
76 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
17 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
13 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
23 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
20 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
12 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
27 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
18 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
1answer
47 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 ...
2
votes
0answers
24 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
19 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
43 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
36 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
21 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 ...
2
votes
2answers
95 views

Org-Babel Javascript error

I am having trouble getting the simplest Javascript source block in org-mode to run. #+begin_src js console.log("Hello"); #+end_src I always get this error: /tmp/babel-8kqQwQ/js-script-...
1
vote
1answer
31 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
83 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
1answer
42 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
29 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
25 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
14 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
37 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
31 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
88 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
51 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
30 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
18 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
49 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
38 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
77 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
19 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
27 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
20 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
63 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
17 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
35 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
137 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; #+...
3
votes
1answer
243 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
68 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
27 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
28 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
83 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
45 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
34 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 ...

1
2 3 4 5
11