emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] automatically run code blocks when loading an org-mode document


From: Eric S Fraga
Subject: Re: [O] automatically run code blocks when loading an org-mode document
Date: Sun, 24 Jul 2016 09:27:27 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.94 (gnu/linux)

On Friday, 22 Jul 2016 at 22:11, Nick Dokos wrote:

[...]

> #  -*- find-file-hook: org-babel-execute-buffer -*-
> #+BEGIN_SRC emacs-lisp
> (defun handy-stuff(arg)
>  (message arg))
> #+END_SRC
>
> [[elisp:(handy-stuff "foo")][foo]]
> [[elisp:(handy-stuff "bar")][bar]]
>
> will do that (but you get a question re. "safe" local variables when
> you open the file). It also executes *every* code block in the buffer
> which you might not want to do (although it does not matter in this
> case).

For the OP, instead of evaluating every code block, it is possible to
evaluate just one code block.  I have:

# Local Variables:
# eval: (esf/execute-startup-block)
# End:

in my org file with

#+begin_src emacs-lisp
  (defun esf/execute-startup-block ()
    (interactive)
    (org-babel-goto-named-src-block "startup")
    (org-babel-execute-src-block))
#+end_src

and so only a block named startup will be executed.

-- 
: Eric S Fraga (0xFFFCF67D), Emacs 25.0.94.1, Org release_8.3.4-1049-g481709



reply via email to

[Prev in Thread] Current Thread [Next in Thread]