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
29 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
30 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
25 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
36 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
16 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
vote
0answers
14 views

tide-mode in org-edit-src-code

I want to activate tide-mode when using Javascript soruce code blocks, following this it works well with indium: https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-js.html But I want to use ...
0
votes
4answers
91 views

Problem with org-mode odt exporter for styling exported src code blocks

I try to change the style of src code blocks export with odt exporter but it does not work as expected. I first exported my file to an odt document. Then I changed the style of OrgSrcBlock and saved ...
0
votes
0answers
8 views

org-mode: Use dvisvgm on HTML export of Babel LaTeX blocks

As far as I understand, there are two competing forces when exporting LaTeX to HTML. If it's in the text (including using \begin blocks), then the preview mode of org.el is used, relying on org-...
0
votes
0answers
10 views

Changing the tangling destination

If you call #'org-babel-tangle in a source block beginning with #+begin_src tex :tangle irs.tex The tangled file will normally end up in the current directory, which will be the directory containing ...
1
vote
1answer
33 views

Indent code block in org mode headines

How I can indent code block to align it to the begining of #+BEGIN_SRC ? Right now it looks like this and I would like to be like this
0
votes
0answers
12 views

Unexpected cursor move in org source block when `comment-line`

In an eamcs -q session given the below code (* and % are position indicators) #+begin_src python import IPython %import tabulate class OrgFormatter(IPython.core.formatters.BaseFormatter): ...
2
votes
3answers
66 views

How can I search between the lines with multiline search?

I use C-u 4 M-x helm-swoop for interactive search also show several surrounding lines (this is analogous to grep -C 4). When I find the word I narrow my search interactively, for example, C-u 4 M-x ...
1
vote
1answer
29 views

Error with org-babel-execute-buffer

I'm using Org mode 9.2.3 and Emacs 26.2. When I try to execute all source blocks of an org document with org-babel-execute-buffer (bound to C-C C-v b), I always get the following error message: ...
0
votes
1answer
26 views

yasnippet color

I use yasnippet in orgmode to expand codeblocks of Python and start typing code. My snippet is defined as: # -*- mode: snippet -*- # name: emacs-jupyter code block for python (silent) # key: <spp #...
1
vote
2answers
91 views

org-babel-tangle with function in header arguments

Following this suggestion, I have a function to automatically generate figure names: #+begin_src emacs-lisp :exports none (set (make-local-variable 'i) 0) (fset (make-local-variable 'fig-file) #...
2
votes
2answers
48 views

Clear all code blocks

Say you have an org file with several code blocks like the one below: #+BEGIN_SRC jupyter-python :session py :results silent :async yes stuff more stuff even more stuff #+END_SRC Question: Is there ...
0
votes
1answer
39 views

The difference between (setq shell t) and (shell . t)

Upon configuring babel, encounter such syntax (require 'ob-ipython) (org-babel-do-load-languages 'org-babel-load-languages '((ipython . t) (python . t) (shell . t) ;; other languages.. )...
0
votes
1answer
37 views

Ditaa source code evaluated with no result

The code below evaluated successfully but ~/Downloads/foo.png is empty. A look at the downloads folder shows that no file has been generated. What went wrong? #+begin_src ditaa :file ~/Downloads/foo....
1
vote
1answer
24 views

What is the equivalent of the org-babel CALL in emacs-lisp?

Let's take this simple Org code, with two Python code blocs (one which returns a list, and the other one which prints the type and the content of the parameter): #+NAME: int #+BEGIN_SRC python :...
1
vote
2answers
30 views

Can Org-mode link to a Babel block?

I would like to have a link that runs a Babel source-code block. Does Org-mode support running something from the library of babel in a link, or a source block via a file+blockname reference? A ...
2
votes
1answer
79 views

org-mode tikz drawing behavior abnormal

In below example, the text should be show on the right side if compile the latex code with pdflatex command. but in org-mode, the right side text missed: #+HEADER: :fit yes :imagemagick yes :...
2
votes
2answers
53 views

How to append an argument to an external command in init.el?

I 1must append a config file to 2package command, required as -p puppeteer-config.json. In my init.el, I tried changing the native command as shown below: From: (setq ob-mermaid-cli-path "~/...
2
votes
1answer
47 views

Jumping from a source block to the tangled file

Is there an inverse of org-babel-tangle-jump-to-org allowing one to jump from a source block to the corresponding place in the tangled file?
0
votes
0answers
36 views

org-babel results with accented characters

I have a problem with the output of org-babel code blocks when this output contains accented characters. For example, if I execute this code block: #+name: test_accented #+begin_src python :results ...
0
votes
0answers
16 views

Obtaining the results of babel evaluation of docker-compose commands

this is an odd behavior which seems to happen for some docker-compose commands but not others. If I try to evaluate certain commands like #+BEGIN_SRC sh dir: . docker-compose exec app rspec #...
0
votes
0answers
17 views

Adding header to a org-mode tangled file

I am generating source code files from an org-mode file using org-babel-tangle. How do I add headers to the files e.g. for python # This is a generated file do not edit for emacs lisp similar ...
0
votes
0answers
17 views

Is diff syntax recognized as a valid org babel src block type?

How can I get syntax coloring after exporting when when the contents of my org babel src block is diff style: #+BEGIN_SRC diff <--- is that even a valid keyword diff --git a/railties/lib/rails/...
1
vote
0answers
22 views

Leave noweb references in Org-Babel unevaluated with variables

I'm currently getting into Literate Programming with org-mode in Emacs. One of the key features to make it tractable as a programming style is macros. I would like to be able to do something like this:...
1
vote
0answers
27 views

Use result of ob-shell block in subsequent ob-shell block

#+BEGIN_SRC sh aws ec2 describe-instances #+END_SRC #+RESULTS: i-0154b911d1f4e0871 #+BEGIN_SRC sh aws ec2 terminate-instances "param1" #+END_SRC How can I use the result of the first block as the ...
0
votes
0answers
20 views

How to tangle conditionally based on hostname?

Why is this block tangled (bar.sh), but not the second (foo.sh)? #+BEGIN_SRC sh :tangle bar.sh echo bla #+END_SRC bla #+BEGIN_SRC emacs-lisp :tangle (when (eq system-name 'arch) "foo.sh") (princ ...
0
votes
1answer
31 views

org-babel for vimscript or most similar language

Since I couldn't find anything as per title, does anyone know what org-babel language could be used as workaround? Currently I surround code blocks with #+begin_src sh, though in particular the ...
2
votes
1answer
82 views

org export processes code blocks even if located in noexport headline

EDIT 1 : a more simple use case For this org file content: * Headline 1 - Something to export * Headline 2 :noexport: #+begin_src python :results none :exports none def foo(): ...
1
vote
1answer
28 views

How write begin_export html blocks in an inline fashion?

A code which takes up several lines of screen realestate can be written as Inline code src_sh[:exports code]{echo -e "test"} foo source: https://stackoverflow.com/a/16193498 Is is possible to write ...
0
votes
0answers
32 views

Use Ruby console session in Org Babel

I'm able to properly start a Ruby on Rails console using inf-ruby-console-auto. Org Babel, when executing a buffer will use inf-ruby. How can I get source blocks in an Org file to invoke inf-ruby-...
2
votes
1answer
60 views

How to use org headers as filenames in tangle

In org mode, how can I tangle to files equally named as the org header? Referring to the examples below, I'd expect two files foo.sh and bar.sh as tangle result: * foo #+BEGIN_SRC sh :tangle yes ls #...
0
votes
2answers
67 views

org-mode code block parentheses mismatch

Here's some emacs-lisp code in a babel block: #+begin_src emacs-lisp (defun factor (number) (labels ((*factor (divisor number) (if (> (* divisor divisor) number) (list ...
2
votes
1answer
29 views

How to use python listdir in org babel?

While the command below returns filenames in the commandline, I somehow can't get the same result using org-babel: #+BEGIN_SRC python :results output import os os.listdir(path='.') #+END_SRC #+...
3
votes
1answer
37 views

Passing variable into a org babel code on export

I can't seem to get the variable to expand into src block #+BEGIN_SRC conf :tangle ~/.config/mine.conf :var argument=abcde setting1 1234 setting2 argument #+END_SRC When I export the file for ...
1
vote
1answer
131 views

Org-mode 9.2:Can' t find the error on my dot emacs [closed]

I recently update my org to the version 9.2 (to be precise: Org mode version 9.2.3 (9.2.3-4-g6ec402-elpaplus @ /home/nanounanue/.emacs.d/elpa/org-plus-contrib-20190408/) I did it because I replaced ...
0
votes
0answers
22 views

How to pass noweb variables to latex blocks

I need to tangle a LaTeχ file from code blocks in an org file. How do I pass variables to the SRC block? In theory I should use :var var1=value, but is there any way to reference var1 in the LaTeχ ...
1
vote
1answer
70 views

Naming the result of a source block

The following question has been asked (in slightly different form) in a comment of another answer: Is it possible to name the results of a source block with #+NAME: foobar (or equivalently but old-...
2
votes
1answer
47 views

No comment syntax defined

After calling org-babel-tangle on a certain file containing latex blocks, I see the prompt No comment syntax defined. Use: What is this about? This doesn't happen with another similar file I have....
5
votes
1answer
69 views

Help me avoid “|| true” in org babel bash statements

I'm writing a lot of manuals on how to accomplish things in bash. Often I'm showing people something that doesn't work, and then go on to show what works. When I'm showing something that doesn't work, ...
1
vote
1answer
39 views

org-mode: How can noweb handle a multiple line output

I have a code chunk in my document that I want to use as a list of patterns to search for with grep. If I were just writing a script without org-babel, I could write. a="ar er ir or ur" printf "...
1
vote
1answer
55 views

org-macros in header arguments of org-babel?

Is there a way to specify org-macros that can be used in header arguments of org-babel? One application is to specify the figure path. For instance I want to define: #+macro: folder figures_here in ...
0
votes
1answer
87 views

Org babel gnuplot cannot find or open file with ledger-cli report

Expecting gnuplot to create a png on evaluating a ledgerCli plot report I get the GnuPlot error at the bottom of this post LedgerCli #+NAME: LedgerCli #+BEGIN_SRC ledger :cmdline reg Assets:Cash -J ...
1
vote
1answer
104 views

How to gnuplot a referred evaluated table in org-babel?

Hitting ctrl-c ctrl-c on the gnuplot code block returns: org-babel-ref-resolve: Reference ‘foo’ not found in this buffer #+srcname: foo #+begin_src python :results output raw :exports code import ...
0
votes
1answer
68 views

ob-async issue, seq-random-elt not defined

I would like to asynchronously run code blocks in org mode. My org mode version (org-version output) is: Org mode version 9.2.1 (9.2.1-23-g126a37-elpa @ /home/user/.emacs.d/elpa/org-9.2.2/) I ...
2
votes
1answer
108 views

Global lexical-binding setting?

I've seen ;;; -*- lexical-binding: t; -*- at the top of a file and (setq lexical-binding t) as how to turn on lexical binding for elisp code, but is there a way to tell Emacs to simply always do ...
2
votes
2answers
106 views

Can not refer to RESULTS in org-babel

I need to plot data evaluated in org-mode. Referring to #+RESULTS: returns org-babel-ref-resolve: Reference ‘myResult’ not found in this buffer whereas referring to #+tblname: works. #+RESULTS: ...