I'm generating multiple files in one .org file, with multiple source code blocks. For example:
#+begin_src rst :tangle file1.rst :noweb yes
<<file1>>
#+end_src
#+begin_src rst :tangle file2.rst :noweb yes
<<file2>>
#+end_src
Is there any way to only tangle one specific code block without changing the header options?
I'm generating these files for Sphinx and to reduce the compilation time I want to tangle only the file I'm currently working on.
It would be great if there is a command such as org-babel-tangle-current-block
- is there any way to do this?
(This is a related question to Orgmode: how to filter the blocks to be tangle?)
That is possible by calling org-babel-tangle
with a prefix argument.
So C-u C-c C-v t
should do what you want.
From the docstring:
With one universal prefix argument, only tangle the block at point. When two universal prefix arguments, only tangle blocks for the tangle file of the block at point.
Just in case that someone is interested in binding a key to this - my init file includes the following:
(defun org-babel-tangle-block()
(interactive)
(let ((current-prefix-arg '(4)))
(call-interactively 'org-babel-tangle)
))
(eval-after-load "org"
'(progn
(define-key org-mode-map (kbd "C-c b") 'org-babel-tangle-block)
))
and I can tangle the code block under the cursor with C-c b
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With