Hot answers tagged

44

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 sees the old macro instead of the new function. As others have pointed out uninstalling org-mode restarting Emacs (without loading org-mode) and reinstalling will ...


38

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.


10

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 a copy of org-babel-tangle-collect-blocks. Only the lines marked with Tobias are modified or added. That would make the modification a good pull request if ...


6

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 in that way. If you copy-paste the full elisp code into your init file behind package-initialize the new function org-babel-tangle-append is bound to the key ...


6

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 / journals where the author is keeping a record of activities performed. While I highly recommend keeping an engineering notebook, keeping a lot of dead code ...


4

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 org file and type M-x list-org-src RET. That creates an org-src buffer with a tabulated list of the source code block entries. Each entry has the following ...


4

for me uninstalling the org-plus-contrib package and reinstalling it solved it.


4

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 time, so I can only guess that you may be running a very old version of org mode. Try to update it from http://orgmode.org/elpa/ using the package manager.


3

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 within a source block. Thereby, the names are themselves names of source blocks that are evaluated to get the results. Applied to your example that could look like ...


3

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 [RET] org-plus-contrib and reinstalling with M-x package-install [RET] org-plus-contrib DID fix it


3

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 Code * config file #+BEGIN_SRC clojure :noweb yes :exports none :mkdirp yes :tangle data/code/tangle-append-test.clj <<configs>> #+END_SRC **...


2

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 (println "hello") #+end_src #+name: hello-world #+begin_src clojure (println "world") #+end_src #+name: goodbye #+begin_src clojure (println "goodbye") #+...


2

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 error is because of the generated elisp code. If you execute the following code you'll see the same error message: #+BEGIN_src elisp a b c #+END_src A ...


2

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 please echo this line date ## but not this one cd test ## this one ls -l ## or this one #+END_SRC Bad source code block, echo prepended to very line: #+...


2

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 unless first line in file (unless (or (string= "no" (cdr (assq :padline (nth 4 spec)))) (= (point) (point-min))) (...


2

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 will only tangle the current code block into the file if C-u C-c C-v t is used. This behavior can be confusing when tangling. In your use case, you created a ...


2

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 can navigate to function definitions with M-. and M-,. You need to refresh the TAGS file with that function as things move around and get added, but maybe that ...


2

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-load-file calls org-babel-tangle which is an autoloaded function, so when it is called, emacs arranges to load the file that defines it (i.e. ob-tange.el[...


2

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 * BAR #+BEGIN_SRC emacs-lisp :noweb-ref require (require 'bar) #+END_SRC #+BEGIN_SRC emacs-lisp :noweb-ref execute (bar-setup) #+END_SRC


2

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 headline above the SRC block. (defun headline-title() (let* ((x (save-mark-and-excursion (org-up-heading-safe) (org-element-property :...


1

Byte-compiling is a CPU-bound activity, unlike with subprocesses and network processes there is no way of doing it asynchronously in the same Emacs instance. What you can do though is launching an Emacs subprocess and making it byte-compile the file. async.el offers support for this, try async-byte-compile-file from async-bytecomp.el.


1

I don't see a clever way to do what you want: you would have to change the org-babel-tangle function itself, or rather write your own function which would be almost the same as the org-babel-tangle function, but not quite. @Tobias's answer in the linked question locally redefines the delete-file function to ignore, so when org-babel-tangle is called, the ...


1

Partial answer: this does it and reduces tangling time by about 40% (subjective). But I'm looking for more ways to speed it up. Compared to eg the C preprocessor cpp, org-tangle is very slow. (defadvice org-babel-tangle-single-block (around inhibit-redisplay activate protect compile) "inhibit-redisplay and inhibit-message to avoid flicker." (let ((...


1

The way I configured my init.el as a init.org is similar to the one you are quoting from Uncle Dave. I am not using ob-tangle for parsing all the src blocks to another file using :tangle as a argument. I just bind org-babel-load-file to a key so as to reload it whenI make changes. (global-set-key (kbd "C-c i") (lambda() (interactive)(org-babel-load-file "~/...


1

One idea is to make copies of the blocks as you go along. But remove the :tangle app/views/layouts/application.html.erb part from the older block(s). So the tangling is done once when pressing C-c v t. This does mean that your coolsite.org file builds up a lot of dead code. For some folks (I'm undecided atm) dead code can be actually useful history, it's ...


1

I address here only the following part of your question: If I choose the latter, an interesting situation can arise in the long run where a single org file has multiple :tangle blocks that output to the same file. After the tangling, which one is left? The org info manual says in Section 14.4 Extracting source code: When Org tangles ‘src’ code ...


1

There are two options you could use, but I imagine that none are exactly what you want: 1) Create derived classes from the template classes #+begin_src ruby :tangle ./app/models/appuser.rb class AppUser < User after_create :create_braintree_customer def create_braintree_customer Braintree.api_key = "bk-54cfa45" self.id = Braintree::...


1

I found the correct variable to set while on an unrelated research dig: coding can be set in a Local Variables block like so: # Local Variables: # mode: org # coding: utf-8-with-signature # End: Note: there is a leading space in each line of the preceding source block. This setting then gets inherited by the tangled files.


1

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 #+STARTUP: showall #+BEGIN_SRC python :tangle yes :noweb tangle import sys import os def main(args): <<initialize-the-game-board>> if ...


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