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: Nick Dokos
Subject: Re: [O] automatically run code blocks when loading an org-mode document
Date: Fri, 22 Jul 2016 18:11:57 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

"grewil3 ." <address@hidden> writes:

> Hi! When I load the document below, I first need to manually evaluate the 
> code block before I can use
> the links. I would like the code block to be automatically evaluated when I 
> load the document, making
> the links usable at once.
>
> Is there some clever in-buffer-setting I can use, to specify that I want the 
> block called on loading,
> some kind of post-load hook?
>
> #+BEGIN_SRC emacs-lisp
> (defun handy-stuff(arg)
>   (message arg))
> #+END_SRC
>
> [[elisp:(handy-stuff "foo")][foo]]
> [[elisp:(handy-stuff "bar")][bar]]
>

--8<---------------cut here---------------start------------->8---
#  -*- 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]]

--8<---------------cut here---------------end--------------->8---

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).

-- 
Nick




reply via email to

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