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 ...
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.
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 ...
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 ...
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 ...
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 ...
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 / ...
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 ...
5
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 ...
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 ...
4
votes
Org-mode 9: unable to eval code-blocks
for me uninstalling the org-plus-contrib package and reinstalling it solved it.
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 ...
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 ...
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 [...
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
(...
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 ...
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
#+...
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 ...
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: ...
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: :...
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 ...
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
...
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 ...
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-...
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 ...
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
* ...
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 ...
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 - ...
2
votes
How to specify a directory to tangle all code blocks into
I could not find any header args to do this (I thought that :dir would be the one, but it does not make any difference in tangling). But you can use the post-tangle hook, org-babel-post-tangle-hook, ...
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")
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
tangle × 58org-mode × 42
org-babel × 32
literate-programming × 15
noweb × 4
python × 3
buffers × 2
babel × 2
org-export × 1
latex × 1
init-file × 1
indentation × 1
debugging × 1
hooks × 1
yasnippet × 1
character-encoding × 1
unicode × 1
comment × 1
doom × 1
byte-compilation × 1
bash × 1
config × 1
org-ref × 1
directories × 1
async × 1