Skip to main content
47 votes
Accepted

Org-mode 9: unable to eval code-blocks

I think this problem is caused by the change of org-babel-check-confirm-evaluate from a macro to a function. If you have org-mode (and thus the old macro) loaded when you compile the new code, it ...
erikstokes's user avatar
  • 12.9k
38 votes

Org-mode 9: unable to eval code-blocks

To elaborate on @erikstokes: rm ~/.emacs.d/elpa/ORGDIRNAME/*.elc where ORGDIRNAME is the name of the core ogrmode directory. Restart emacs and you can now run org-babel code blocks.
בנימן הגלילי's user avatar
11 votes
Accepted

tangle the same src block to different files

Below you find an :override advice for org-babel-tangle-collect-blocks of org-mode 9.1.6 that allows lists of tangle file names instead of just one tangle file name. The code of the advice is largely ...
Tobias's user avatar
  • 33.3k
11 votes

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

I recommend using the builtin org-mode :noweb-ref header to concatenate the code blocks because doing so will resolve the block tangling issue and will allow more flexibility in the future. Updated ...
Melioratus's user avatar
  • 4,688
7 votes
Accepted

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

The following elisp code defines a new function org-babel-tangle-append appending the current source block to the tangle file. In org-mode 9.1.6 there is no user option to configure org-babel-tangle ...
Tobias's user avatar
  • 33.3k
6 votes
Accepted

Passing variable into a org babel code on export

Built-in approach The noweb approach is built in to Org-mode but I believe it is a bit clumsy for your purpose. Therewith you can substitute marked names in source blocks with their result values ...
Tobias's user avatar
  • 33.3k
6 votes

literate programming: do folks revise tangle blocks or make copies

For literate programming, revise the existing tangle block and rely on your version control system to maintain the history. The examples you're referring to sound more like engineering notebooks / ...
Tad Ashlock's user avatar
5 votes
Accepted

switch-buffer for literate programming

You can try the command list-org-src from the following elisp code. It is tested with emacs 25.3.1 and org-mode 9.1.6. Install the source in your init file (after (package-initialize)). Open your ...
Tobias's user avatar
  • 33.3k
4 votes
Accepted

How to use org headers as filenames in tangle

Define a new function in elisp using Org Element API to that returns :title property of headline element. For this answer, I wrote a headline-title function that returns the :title of the nearest ...
Melioratus's user avatar
  • 4,688
4 votes

Org-mode 9: unable to eval code-blocks

for me uninstalling the org-plus-contrib package and reinstalling it solved it.
zeltak's user avatar
  • 1,745
4 votes

How to get values of :var arguments in ob-shell assigned when tangling?

In my emacs 25.1.1. + org version 9.0.4 the tangled a.out file correctly contains value='1234' echo "value = " $value I have used these kind of functions and tangling extensively and for a long ...
dfeich's user avatar
  • 1,904
4 votes

Tangled 0 code blocks from ahk file

I'm pretty sure the problem here is that you did not refresh the buffer before tangling. You can do that by pressing C-c C-c on one of the keyword lines (a line starting with #+), because then Org ...
NickD's user avatar
  • 31k
4 votes

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

You can use the variable org-src-preserve-indentation. If you set it to t before tangling like this: #+begin_src emacs-lisp (setq org-src-preserve-indentation t) #+end_src then the tangle will work ...
NickD's user avatar
  • 31k
3 votes

Org-mode 9: unable to eval code-blocks

On Emacs 25.2 (9.0) and using org-plus-contrib: org-babel-execute-src-block gave me the same error as C-c C-c deleting the .emacs.d/elpa folder and reinstalling did not fix it but M-x package-delete [...
rdcdr's user avatar
  • 63
3 votes

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

What I do is I specify a single block per output file, and use noweb references to collect what goes into it: Here are the blocks with the source you want: #+name: hello-world #+begin_src clojure (...
Andrea Reina's user avatar
3 votes
Accepted

Org Mode Babel - ensure more than one empty line between tangled code blocks (for python)

In the original org-babel-tangle function (C-h k org-babel-tangle), found in ob-tangle.el, a space is inserted between two lines unless the argument to :padline is no: ;; Handle :padlines ...
Daniel's user avatar
  • 3,653
3 votes
Accepted

:noweb :tangle just not working

I agree that the specification is slightly finicky. The following should do what you want: #+TITLE: Console Tic Tac Toe #+SUBTITLE: A Literate Program in EMACS Org-Mode #+AUTHOR: Charlie Martin #+...
aplaice's user avatar
  • 2,206
3 votes

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

I understand your confusion. The good news is that your code is already passing new lines correctly into your noweb call. The reason you're seeing the eval: Symbol’s value as variable is void: a ...
Melioratus's user avatar
  • 4,688
3 votes
Accepted

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

Here's an implementation using org-babel-post-tangle-hook as I hinted in my comment: #+PROPERTY: header-args:yasnippet :mkdirp yes :padline no * foo #+begin_src yasnippet :tangle ./snippets/a # key: ...
NickD's user avatar
  • 31k
3 votes
Accepted

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

To include the preceding text of a source block in a tangled file, you can use the header argument with the following option :comments org. Per heading * Function heading :PROPERTIES: :header-args: :...
grszkthfr's user avatar
3 votes
Accepted

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

The answer can be found in the docstring of org-babel-tangle, it says When two universal prefix arguments, only tangle blocks for the tangle file of the block at point. So you should just place the ...
dalanicolai's user avatar
  • 7,880
2 votes
Accepted

How to avoid multiplying of a string which precedes <<noweb reference>> in code block?

I think you're asking how to prefix only the first line of the noweb block. It will probably depend on the language your using, but I came up with this hack for bash: #+NAME: example #+BEGIN_SRC text ...
Tyler's user avatar
  • 22.4k
2 votes

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

For navigation and symbol definition see https://github.com/jkitchin/scimax/blob/master/scimax-literate-programming.el You can generate a TAGS file with M-x scimax-lp-generate-tags. After this, I ...
John Kitchin's user avatar
  • 11.9k
2 votes

ob-tangle or not?

Here's what Nick Dokos (who has helped me often) over at the org-mode mail list says: ...tangling does not run code blocks: it just writes them out to (one or many) different file(s). org-babel-...
147pm's user avatar
  • 2,979
2 votes

literate programming: do folks revise tangle blocks or make copies

Short Answer - Update the original code block and tangle again. Adding the same :tangle header to separate code blocks will concatenate the code when tangling the entire buffer with C-c C-v t but ...
Melioratus's user avatar
  • 4,688
2 votes
Accepted

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

Apparently this can be fixed by using :noweb-ref instead: * FOO #+BEGIN_SRC emacs-lisp :noweb-ref require (require 'foo) #+END_SRC #+BEGIN_SRC emacs-lisp :noweb-ref execute (foo-setup) #+END_SRC * ...
coredump's user avatar
  • 166
2 votes
Accepted

Adding header to a org-mode tangled file

You could use something this: (defun add-tangle-headers () (message "running in %s" (buffer-file-name)) (cond ((f-ext? (buffer-file-name) "py") (goto-char (point-min)) (insert "# This ...
John Kitchin's user avatar
  • 11.9k
2 votes

how to speed up org-babel-tangle?

I have a growing org file of 5000 lines, 200 headings and 150 noweb references. I tangle a 3000 lines file. Using the built-in org-babel-tangle takes over 10 minutes. I wrote ob-tangle.pl to do - ...
Jerry Leibold's user avatar
2 votes

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

Create a template file, template.el, with these contents (this is the backquoted form of what you show above): `(("default" . ((user-emacs-directory . "~/emacs-configs/my-config") ...
NickD's user avatar
  • 31k
2 votes

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

With the help of @NickD, I was able to figure this out. org-babel-tangle allows you to extract source code from other source code blocks. During this tangling process, Org expands variables in the ...
Gangula's user avatar
  • 275

Only top scored, non community-wiki answers of a minimum length are eligible