Questions tagged [tangle]

Use this tag for questions about tangling code in Emacs org-mode. Tangling is the process of extracting source code from code blocks from an org-mode file into programs for execution by a computer.

In literate programming, tangling is the process of exporting code from a file that contains code and the documentation of that code, into external program files which can be executed later by a computer.

In the context of Emacs, tangling usually refers to a more restricted version that is implemented in Org mode.

Resources:

Wikipedia article on Literate Programming

Tangling section in the Org mode manual

53 questions
45
votes
6 answers

Org-mode 9: unable to eval code-blocks

My Emacs config lives inside of a .org file from which I tangle source blocks to a .el file. I could evaluate source blocks with C-c C-c Today I updated to org-mode version 9 from org elpa and now evaluating a source block like #+BEGIN_SRC…
rrogg
  • 595
  • 1
  • 4
  • 7
11
votes
3 answers

How to change Org-mode babel tangle write to file way as append instead of override by default?

By default, Org-mode will override current babel src block content on file original content (when the file already has content). For example, I have an org-mode file content as the bellowing block: #+BEGIN_SRC org ,* config file ,** config…
stardiviner
  • 1,888
  • 26
  • 45
9
votes
1 answer

tangle the same src block to different files

I would like to tangle a single src block to several files, rather than just one. Ideally I would write something like #+BEGIN_SRC conf :tangle one.conf two.conf three.conf but this produces one file names “one.conf two.conf three.conf" I can make…
Wilder
  • 95
  • 6
7
votes
2 answers

It is possible to instrument a literate Org-mode configuration file with a backing Emacs Lisp file?

It is a common practice to write Emacs configuration files using literate-programming style in Org mode. Unfortunately, while improving readability, this comes with significant programming disadvantages. In particular, since there is no backing .el…
Matthew Piziak
  • 5,958
  • 3
  • 29
  • 77
5
votes
1 answer

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 tangling (C-c C-v t), the argument keyword is not…
Mehmet Tekman
  • 183
  • 1
  • 6
5
votes
1 answer

switch-buffer for literate programming

When doing literate programming, I do web development in a single org file, and do org tangle to generate the relevant html and css files. This works, for a few hours/days. When the number of files in the org file becomes more than 20 for example,…
american-ninja-warrior
  • 3,773
  • 2
  • 21
  • 40
5
votes
2 answers

How to disable noweb prefix lines?

This says that Noweb insertions now honor prefix characters that appear before <>. And because of that trying to use #+BEGIN_SRC clojure :noweb-ref dep-cljsbuild [lein-figwheel "0.5.9"] [lein-cljsbuild "1.1.5" :exclusions…
4
votes
1 answer

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 #+END_SRC * bar #+BEGIN_SRC sh :tangle…
jjk
  • 705
  • 4
  • 16
4
votes
4 answers

literate programming: do folks revise tangle blocks or make copies

So I'm making a website using an org document and tangling. I've created the basic structure of the site using * file coolsite.org #+BEGIN_SRC sh rails new coolapp #+END_SRC This creates a app/views/layouts/appication.html.erb file, with basics…
american-ninja-warrior
  • 3,773
  • 2
  • 21
  • 40
3
votes
1 answer

How do I keep the indentation on org-babel-tangle?

In literate programming, I often like to write my code in small snippets and then export them all at once via org-babel-tangle. This works great for non-indentation sensitive code (especially with post-processing), but doesn't work quite well with…
Zeta
  • 1,045
  • 9
  • 18
3
votes
1 answer

Tangled 0 code blocks from ahk file

I am planning to (re)organize my ahk code as code blocks into an org file and tangle this file to obtain the source file. This is my ahk-guivho.org input file, with two code blocks, empty for the sake of this post: #+TITLE: AHK config…
guivho
  • 131
  • 2
3
votes
2 answers

How to specify a directory to tangle all code blocks into

I am writing a report in latex, many of which contain code blocks which will be rendered with asymptote. Since all the scripts will be tangled into the same subdirectory asyscripts, I don't want to have to write code like this #+BEGIN_SRC asy…
smilingbuddha
  • 1,131
  • 10
  • 26
2
votes
1 answer

How to concatenate similar groups of blocks during tangle with noweb syntax?

I used to have a literate configuration file structured as follows: #+BEGIN_SRC emacs-lisp :tangle "/tmp/out.el" :noweb yes ;; requirements <> ;; other <> #+END_SRC * FOO Here goes all the snippets of code related to module…
coredump
  • 166
  • 1
  • 7
2
votes
0 answers

C-c ' for editing all code blocks (to handle imports and variables)?

The Org manual says: C-c ' for editing the current code block. It opens a new major-mode edit buffer containing the body of the ‘src’ code block, ready for any edits. This feature is sweet. However, since only the current code block is edited,…
2
votes
2 answers

ob-tangle or not?

I'm experimenting with Uncle Dave's config which is using a minimum init.el to launch config.org, which is full of elisp babel source blocks. Here's his relevant launching code: (when (file-readable-p "~/.emacs.d/config.org") (org-babel-load-file…
147pm
  • 2,907
  • 1
  • 18
  • 39
1
2 3 4