Skip to main content

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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
20 views

Display custom message after completing org-babel-tangle

I'm using org-babel-tangle to tangle one of my org file into an the emacs config file. After completion, I get a message showing how many blocks have been tangled like Tangled 48 code blocks from My-...
Gangula's user avatar
  • 291
2 votes
2 answers
82 views

replace expressions with output in code-blocks before org-babel-tangle

How to evaluate the expressions or functions in a code-block before tangling a source code block? I generate my init.el file using org-babel-tangle AND I'm using chemacs2 - which allows using ...
Gangula's user avatar
  • 291
0 votes
0 answers
24 views

org-mode passing parameters to code snippets

Suppose, we have a source block that looks like this: #+NAME: result_test #+BEGIN_SRC perl :noweb yes :tangle yes $test_name = "\$result is an array ref"; unless (is(ref $result, 'ARRAY', $...
user4035's user avatar
  • 1,069
1 vote
2 answers
127 views

how to tangle only source code blocks that belong to a specific target file?

Let's say we have the following org file: #+begin_src python :tangle "target1.py" a=11 #+end_src #+begin_src python :tangle "target2.py" a=21 #+end_src #+begin_src python :tangle ...
martinoidar's user avatar
0 votes
0 answers
34 views

How do I pass a variable from a calling buffer to a called buffer?

The process of tangling in org involves, according to https://orgmode.org/manual/Extracting-Source-Code.html, a calling buffer and a called buffer, each of which have their own hooks: org-babel-pre-...
shintuku's user avatar
  • 121
0 votes
1 answer
56 views

Tangling fails when using #+PROPERTY instead of manually adding header arguments when using org source blocks

The following code doesn't work, yet adding :tangle tangleobject.org manually to each source block provides us with the expected tangle result. Any clue why? #+PROPERTY: header-args :tangle ...
shintuku's user avatar
  • 121
0 votes
0 answers
58 views

detangle preserve noweb

I've recently gotten into literate Programming with org-mode. I'd like to be able to write all my functions across multiple Code Blocks, tangle them into a files but also test them from inside the org ...
Tomke Pfoch's user avatar
1 vote
2 answers
226 views

How to tangle code blocks from an org file, compile the output, and open the result, with a single command?

I use org-babel-tangle to generate lilypond and latex documents from org files. These org files have the following first line: #+PROPERTY: header-args :LANG :comments org :tangle PATH/FILE_NAME.EXT ...
crocefisso's user avatar
  • 1,385
0 votes
0 answers
52 views

org-babel-detangle writes duplicated code

I am trying to use org-babel-detangle for a while, but the source code is detangled twice in the main org file. Interestingly, when I run (org-babel-detangle "file_name.cpp") it does not ...
Gabriel Petrini da Silveira's user avatar
0 votes
0 answers
21 views

Can a noweb block be directed to a specific output block?

I know you can give a block the property :noweb-ref give it a reference name like foo and then in another noweb block you can refer to the reference block with <<foo>>. However this means ...
Ian Pringle's user avatar
0 votes
0 answers
22 views

Prevent deletion of blank lines when tangling code blocks

The Python style guide asks for two blank lines surrounding class and function definitions (see PEP 8). When those blank lines are added in Org-Mode source blocks, they are removed during tangling. ...
Ben Bkhdt's user avatar
0 votes
1 answer
46 views

Order of different type blocks in org tangle

I want to create an org file with source blocks of different types and tangle those in a single file (order is important, of course): #+PROPERTY: header-args :tangle test.j2 #+begin_src conf-unix ...
ivgrand's user avatar
0 votes
1 answer
76 views

Add parent heading of source code block as comment in tangled file

If I have something like this: * Function heading #+begin_src racket :var x=3 y=4 :tangle "file.rkt" (define (distance x y) (sqrt (+ (sqr x) (sqr y)))) (distance x y) #+end_src ...
mustaqim's user avatar
1 vote
2 answers
103 views

When tangling, how to reference code-blocks from different file?

When tangling, I want to use/refer to code-blocks from different file. Suppose /tmp/1.org file below that contains code block named code_block_in_1_org (that I want to use later). * This is ~1.org~ ...
Garid's user avatar
  • 686
1 vote
1 answer
132 views

Debug the Tangle (stringp, nil)

I'm tangling my emacs file as usual, but today it broke. There's like no way to figure out where it has problems;) BASHY $ emacs --batch --eval "(require 'org)" --eval '(org-babel-tangle-...
Jason Hunter's user avatar
0 votes
2 answers
169 views

org-tangle, Where is it?

I'm trying to tangle my Emacs configuration file from shell. I asked a question and was told to use org-tangle, but where is that? I also tried ntangle, but that failed silently. Also, I tried this ...
Jason Hunter's user avatar
0 votes
0 answers
45 views

How to tangle a ditaa code block in org mode?

I use org-mode to tangle code blocks in programming languages such as python into their respective code files. But I am not sure how to tangle ditaa code blocks and execute them to generate figures ...
tinlyx's user avatar
  • 1,364
0 votes
1 answer
130 views

How to split long python code into multiple code-blocks in org-mode? (indentation)

Just starting to learn org-mode and tangle to write documentation of my Python source codes. I have a several hundred lines long function. I want to separate this long function into several small code-...
Garid's user avatar
  • 686
0 votes
0 answers
201 views

How do I debug Tangled 0 code blocks?

This is a history of an unsuccessful attempt to fix tangling in my Emacs configuration. In frustration, I have removed the org-mode config and left the file that was a result of previous successful ...
ruby_object's user avatar
0 votes
1 answer
197 views

Specifying a subdirectory in the argument of :tangle: effect only non-interactively

Recently, I added to this answer to the question “How to specify a directory to tangle all code blocks into”, the following comment: “AFAICS, specifying a subdirectory in the argument of :tangle ...
Denis Bitouzé's user avatar
1 vote
1 answer
177 views

No comment syntax defined when tangling lua or vimrc code blocks

Resolution With help from commenters, I have things kind of working. I removed :comments link from Properties. I manually added comments to the top of every code block to replicate what :comments ...
Jason's user avatar
  • 111
1 vote
0 answers
125 views

import source code file into org-mode file?

I'd like to import a source code file (for a language such as e.g. python) into an org-mode file so that the comments in the source file become org-mode text (markdown) and the codes between comments ...
tinlyx's user avatar
  • 1,364
1 vote
1 answer
171 views

Tangle babel code to specific location in source file?

Let's say I'm creating many babel code blocks in a growing org-mode buffer and I'm tangling them all to a single file. However, I want certain blocks to appear above others. For example, #+begin_src ...
147pm's user avatar
  • 2,979
0 votes
1 answer
73 views

Tangle current src block and process it in another

How can I run the test src block without leaving the code src block? Currently I must leave code, goto test, hit C-c C-c , go back to continue work on code #+NAME: code #+BEGIN_SRC sh :tangle /tmp/...
jjk's user avatar
  • 746
0 votes
1 answer
401 views

How to use Org mode for i3/sway config files

I use the swaywm. It's similar to i3. The Emacs distribution I use is doom-emacs I recently learnt about literate config files. But how make literate configs for something like this. The text is not ...
Sujay R's user avatar
1 vote
1 answer
367 views

Manage JSON (comments) with org literate programming and tangle

I would like to manage a JSON config file with added comments on some key-value-pairs and explain options. Since it is not possible to comment in JSON, I thought about using org-mode literate ...
breathe_in_breathe_out's user avatar
3 votes
1 answer
989 views

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 ...
Zeta's user avatar
  • 1,103
3 votes
1 answer
417 views

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 ...
guivho's user avatar
  • 131
4 votes
2 answers
2k views

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 ...
smilingbuddha's user avatar
1 vote
1 answer
759 views

Make :tangle don't add a newline at the end of the file

The context I'm storing all my custom defined yasnippet snippets in an Org file (see below) $ cat ~/.emacs.d/snippets/snippets.org #+PROPERTY: header-args:yasnippet :mkdirp yes #+begin_src yasnippet :...
doltes's user avatar
  • 587
1 vote
0 answers
39 views

How to replace sections of non-org files from within org-mode?

I am trying to write some notes on django with the help of org babel. Is there a way to replace a block in a file(which was not tangled with org) after I eval a certain src block? Here's what I mean: ...
Sarthak Adhikari's user avatar
0 votes
0 answers
45 views

eval: Symbol’s function definition is void: org-macro--get-property

I am trying to tangle an org file, but this error shows up even if I invoke the command with an emacs -Q instance. Google does not seem to yield anything useful here. Can anyone help me get to the ...
CD86's user avatar
  • 573
0 votes
1 answer
123 views

How to byte-compile a file in the background?

To cut time on untangling my org setup file, I now only compile on save. However it is somewhat annoying to have the compile buffer popup on every save. ;; Only untangle on a change/save (defun ...
SFbay007's user avatar
  • 584
0 votes
0 answers
56 views

condition on "if the source code block is tangled"

is there a way to query if the current source code block is tangled and if so, to execute e.g. shell stuff depending on if it was or not? I know I can make tangling conditional, but can one also do ...
CD86's user avatar
  • 573
0 votes
1 answer
186 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?
reFORtEM's user avatar
  • 101
1 vote
2 answers
596 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: ...
Vladimir Alexiev's user avatar
2 votes
1 answer
120 views

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 <<require>> ;; other <<execute>> ...
coredump's user avatar
  • 166
0 votes
2 answers
661 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 ...
mmmmmm's user avatar
  • 525
0 votes
0 answers
259 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 ...
user3166159's user avatar
4 votes
1 answer
958 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 #...
jjk's user avatar
  • 746
5 votes
1 answer
2k 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 ...
Mehmet Tekman's user avatar
0 votes
1 answer
78 views

Set tangle-mode 444 for all source blocks in buffer

How can I tangle all source blocks write protected? The first line of this example is ignored instead of being applied to all blocks as expected: #+PROPERTY: header-args:conf :comments link :...
user3166159's user avatar
7 votes
2 answers
689 views

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 ...
Matthew Piziak's user avatar
2 votes
0 answers
69 views

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. ...
kuzcoTheGreat's user avatar
2 votes
2 answers
1k views

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-...
147pm's user avatar
  • 2,979
9 votes
1 answer
2k views

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 ...
Wilder's user avatar
  • 95
4 votes
4 answers
1k views

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/...
american-ninja-warrior's user avatar
5 votes
1 answer
294 views

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 ...
american-ninja-warrior's user avatar
2 votes
1 answer
156 views

Can tangling embed code in external files? instead of recreating files

I'm building a web application using the literate programming style. At least trying to. I wanted to "hit the ground running", so I decided "make a copy" of one of the many "starter apps" https://...
american-ninja-warrior's user avatar
1 vote
1 answer
271 views

Org tangle source blocks to a file with byte-order-mark (BOM) from org mode

Because Firefox doesn't load local files with UTF8 characters like '📞, …, 🖥' in the HTML or the CSS correctly, since it does not receive a <meta charset="utf8" /> header, I need to tangle ...
Alex Stragies's user avatar