Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

2
votes
0answers
35 views

Is there a way to time babel code blocks?

Is there a way to do something like the example below to time the execution of any babel code block ? #+BEGIN_SRC sql :timeit #+END_SRC #+results 40s results here #+BEGIN_SRC python :timeit #+...
0
votes
1answer
89 views

#+NAME: in a property drawer

I want to be able to add a #+NAME to a property drawer that would name a code block thats split between sub org headers. Im at loss on how this is done? this is a current example of a tmux conf thats ...
1
vote
1answer
106 views

key binding to invoke more than two commands

I'm in org-mode and would like to have C-c C-c ' run org-edit-special then mark-whole-buffer then indent-region then org-edit-special to get back out again. I've tried (defun my-run-org-babel-...
1
vote
1answer
66 views

How to pass newline (“\n”) string to noweb <<call>>

Trying to pass multiline argument to Org code block. If make direct call of block then it's Ok. But when call it through noweb ref then Error raised #+NAME: pr #+BEGIN_SRC elisp :results value :var n=...
0
votes
0answers
23 views

Is it possible to define codepage for tangled file while Org-mode tangle?

Subj. I want to tangle file to be in different codepage than viewed Org file. Didn't find any header agruments for encoding :(
1
vote
0answers
46 views

Problem execution scope org-babel in shell on windows 8

I just discovered that in order to run a sequence of shell commands under the same scope (same shell session) I have to add a hash at the end of the line. Example When I try to run the following ...
1
vote
1answer
173 views

Font lock of inline code in org-mode?

When using org-mode as a front-end to LaTeX, I'm making heavy use of inline code like @@latex:\textit{something italic}@@. Right now, this is mainly displayed as normal text (with proportional font ...
1
vote
2answers
887 views

How to run C/C++ code in Org Babel?

I'm trying to execute C and/or C++ snippets in Org Babel. For example, I want to be able to execute the following snippet with C-c C-c: #+begin_src C printf ("Hello World!"); #+end_src The ...
2
votes
0answers
174 views

org-mode: Can I use a custom mode for org-src-lang-modes and still get syntax highlighting?

I'm trying to get syntax highlighting with org-mode source blocks using a custom language mode for editing JavaScript. I use js2-mode with a bunch of minor modes, rather than js-mode, which is what ...
2
votes
1answer
56 views

Why does the example with two echo statements output a table instead of the expected string?

In the second example of the code snippet I am expecting foo are you I am emacs but get a table instead. What sort of commands or options are required to get the expected output. What is the ...
1
vote
1answer
458 views

org-edit-src-code Do not pop a new window, use the current one

When I call org-edit-src-code to edit a SRC code on a buffer with the proper major mode, I get a new window configuration. For example, if I have windows 1|2, org-edit-src-code will delete window 2 ...
0
votes
1answer
56 views

How to insert a result of an org-mode source block as part of the document's syntax?

Say I have the following source block: #+NAME: heading #+BEGIN_SRC python :exports none return "** Some outline" #+END_SRC And I insert it inlined in my buffer by using * Another outline ...
1
vote
0answers
48 views

How do I associate org-mode source buffer to appropriate session?

I want to execute org-babel code blocks associated with a session without locking up Emacs. I found the ob-async package, but it doesn't have support for sessions yet. I've found that opening the code ...
0
votes
1answer
354 views

org babel :exports always exporting both code and results

It seems that :exports option has no influence when exporting to HTML or PDF. I am using Org 9.0.9 and Emacs 25.1.1. The following code, for example, even with :exports=none both code and results ...
0
votes
2answers
253 views

Cannot Execute Org-Babel Haskell Block

In an org-mode file: #+BEGIN_SRC haskell let x = "test" putStrLn x #+END_SRC yields: executing Haskell code block... if: ‘org-babel-script-escape’ expects a string
3
votes
1answer
74 views

Evaluating `org-babel-clojure` blocks returns all form evaluations

I'm trying to set up babel for use with Clojure according to http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-clojure.html#org85bc1ec and I can evaluate code but when I evaluate a block with ...
3
votes
2answers
167 views

Babel src block inside src block

I'm trying to post a babel src block that contains a babel definition since I am documenting some babel source blocks in a Hugo post written in org mode. What I want to do is the following: #+...
2
votes
0answers
173 views

Org sql header args dont seem to work why?

Can anyone explain why this does not work, i want to set the parameters global to the current document using PROPERTY but this does not work and results in this error. (wrong-type-argument stringp ...
2
votes
0answers
109 views

How do I attach a custom function to process org-mode babel shell output?

I have a a function (defun display-ansi-colors () (interactive) (let ((inhibit-read-only t)) (ansi-color-apply-on-region (point-min) (point-max)))) that I got from here: http://stackoverflow....
9
votes
1answer
1k views

What is the difference between sh and shell for org-babel?

I'm experimenting with sourcing data from org-mode into my shell scripts and I've run across a weirdness: #+tblname: simple-table | 1 | | 2 | | 3 | | 4 | | 5 | #+name: work-with-simple-list-shell #+...
1
vote
1answer
385 views

org-babel-execute:shell: Wrong number of arguments

I'm running org-mode 9.0.9 which I downloaded off of the official org-mode website. When I execute a shell code block I get the following error. executing Shell code block... org-babel-execute:shell: ...
2
votes
4answers
322 views

orgmode - summary table as different group from input table

I need to summary a table according to one column and sum the specific rows of another column. e.g. The summary table is generated from the input table. input table column 1 grouped to IN and OUT, ...
1
vote
1answer
276 views

Pass variable from src block to org-edit-src-code

I have a table in org-mode that I want to pass into an R source block and then plot from it. When I write everything in org-mode and execute it, I get the results that I expect. However, when I enter ...
4
votes
1answer
153 views

Are there any disadvantages to moving init.el to org-mode?

I've noticed some people have their init files in org-mode, using org-babel-load-file. Are there significant performance penalties or other disadvantages to doing this?
2
votes
1answer
83 views

How can I replace outside of org-babel blocks?

I am using a command which affects the entire buffer, replacing all the ocurrences of a given expression (goto-char (point-min)) (replace-string "foo" "bar") Is it possible to apply a command like ...
3
votes
0answers
94 views

Eval SQL in Org Babel using sql-connection-alist for credentials

I would like to evaluate SQL source blocks in Org Babel using the connections I have set up in sql-connection-alist from sql-mode. This way I can save database credentials in a private (Elisp) file ...
3
votes
1answer
486 views

org - How to reference var in CALL

#+NAME: fun1 #+BEGIN_SRC elisp :var var1="val1" (format "%s" var1) #+END_SRC #+NAME: fun2 #+HEADER: :var var2="val2" #+CALL: fun1(var2) #+NAME: fun3 #+BEGIN_SRC elisp :var var2="val2" var3=fun1(var2)...
2
votes
1answer
128 views

Pass an expression to an org babel code block

Consider the followig python code block #+name: whatever #+header: :var x="2*np.pi" #+BEGIN_SRC python import numpy as np 1+x #+END_SRC # . The code will break, because x is passed to the ...
1
vote
1answer
123 views

Ignore code evaluation output in org-mode

Is it possible to set a header setting in a org file to indicate that when I eval any source code block in the file it shouldn't change the file contents? I don't want that default #+RESULTS: block ...
4
votes
2answers
287 views

org-src-mode send commands to repl in named python :session, not *Python*

Is there a method to set what buffer python-mode looks to for a running python process? I have a babel block in org-mode like #+BEGIN_SRC python :session session1 import os os.uname() #+END_SRC I ...
1
vote
1answer
94 views

Generate text blob using emacs-lisp in org-mode

I am trying to write some org-mode text (a bulleted list in this case), and then reuse it at several points in my document when exporting. I managed to get this working by putting my text inside a ...
1
vote
0answers
83 views

Export HTML inline image results for Jekyll

I'm trying to follow the recipe for exporting Org-mode documents for processing by Jekyll. My publishing org-publish-project-alist is configured to place exported html in my _posts directory and take ...
7
votes
1answer
406 views

Org-mode code blocks do not inherit variable properties from enclosing nodes

When playing with the literate aspects of Org-mode I found a description here of how you can set up a var property of a node and how this would then be inherited by enclosed code blocks as a variable ...
0
votes
1answer
163 views

Why is my use-package not installing packages properly? (Using org-mode init file and babel)

I'm new to emacs and I'm trying to setup my init file using a .org file with org-babel-load-file. I've read that it's a good idea to use package use-package to configure packages and to make sure they ...
3
votes
1answer
53 views

How to stop main wrapping when tangling C in org-babel?

Please consider the following self-contained, minimal example org file: #+name: zepto-c #+CAPTION: A tiny C file #+begin_src C++ :tangle zepto.c #include "zepto.h" void foo (void) {} #+end_src #+...
1
vote
0answers
89 views

Elpy Autocomplete in org-edit-special

I'm using org-babel with python source blocks to put break my code into sections. The issue I'm having is I don't get any autocomplete suggestions based on the code in other blocks. Is there any ...
0
votes
0answers
161 views

org-mode babel progress indicator?

When I run a process in the Mac Terminal, it gives me an indication of its progress. Here we see that I am 31% complete on downloading the latest org-mode: How can I get this same sort of progress ...
2
votes
0answers
86 views

Literate agda programming in org-mode

How could I write literate (and exportable to latex) Agda code in org-mode? Org-babel would be a great option, but there is no ob-agda2 (I think?). I have tried defining an org-babel-execute function ...
1
vote
1answer
95 views

org-babel captions on results don't export to LaTeX?

I hope the following complete minimal example is self-explanatory. It contains my question. It should run without error messages in org-babel. I looked at the six related suggested questions on the ...
1
vote
0answers
166 views

org babel exports code blocks even if I tell it to export results instead

How can I make org-babel only export results, not code? The only way I've found to suppress code from appearing in the output is to comment out all the code blocks manually. I tried adding :exports ...
1
vote
1answer
621 views

No org-babel-execute function for calc?

In org-mode: #+BEGIN_SRC calc :var x=5 :var y=2 2+a*x**y #+END_SRC returns No org-babel-execute function for calc! How do I enable calc for org-babel-execute?
4
votes
1answer
1k views

How to word wrap within code blocks

I'm trying to get the formatting right for an org-mode file being exported to pdf. I set 'org-startup-truncated' to nil and that has resolved my word wrapping issues for non code blocks. But I ...
1
vote
1answer
128 views

Python org-mode babel output: column headers misaligned

I'm trying to view some rows of a pandas data frame. Is there a way to prevent the ">>> ..." from appearing before the headers, so that column names are aligned with the data? #+NAME: simulate-data #...
1
vote
1answer
286 views

org-mode table-formula and code-blocks: function parameter is cut off on whitespace

In Org-mode working with 'src' code blocks and table formulas together, org-mode cuts of the cell strings at the first whitespace character. I.e.: having a cell with Hello World the 'src' code block ...
0
votes
1answer
87 views

Is it a default keybinding to insert #+BEGIN_SRC […] #+END_SRC?

I've searched the manual and I didn't find anything useful. It's annoying to write every time the tags to surround the code, and I'm surprised that org doesn't provide a macro to avoid a so boring ...
2
votes
2answers
178 views

org-babel problem printing separator rows to org-mode table

I found here in the org manual how to output from an org-babel source-code block to an org-mode table, namely through something like #+header :results output table I have had some trouble getting ...
1
vote
2answers
164 views

How to feed range from org-table filled with strings to code-block via tblfm?

Following Situation: I would like to calculate some fields from an org-table filled with strings. There are many tables which all could share the same lisp-code. The lisp-code is rather complex and ...
2
votes
1answer
352 views

execute named org-bable source block from elisp

I want to execute selected source blocks in the active buffer. For example for the following org-mode file, #+NAME: snippet1 #+BEGIN_SRC emacs-lisp (message "snippet 1") #+END_SRC #+NAME: ...
4
votes
1answer
65 views

How to append header arguments to result code src block?

For example, I have an src code block which can generate another code block: #+BEGIN_SRC sh :results code :wrap systemd systemctl --user cat rslsync.service #+END_SRC #+RESULTS: #+BEGIN_systemd # /...
1
vote
2answers
308 views

How to make Org-Babel support tangel to su/sudo file with tramp-sudo?

I hope to let org-babel can tangle to root permission file with tramp-sudo support like the following format: #+BEGIN_SRC clojure :dir /sudo:: :tangle "/etc/kk.clj" ... #+END_SRC But it does not ...