[email protected] writes:
> I found this blog post: https://rgoswami.me/posts/org-arb-tex/ and
> wanted to use the trick with an Elisp source block to add something to
> `org-latex-classes' (and make some other adjustments).  However, I can't
> get it to work.  I suspect I'm making some stupid mistake, but can't
> find it...
>
> Here is my Org file, exported on `emacs -Q':
>
> --8<---------------cut here---------------start------------->8---
> * Preamble
> #+begin_src elisp :exports none :results none :eval yes
>   (setq my-var (format-time-string "%FT%T"))
> #+end_src
>
> * Contents
> Lorem ipsum.
> --8<---------------cut here---------------end--------------->8---
>
> When I export it, say, to LaTeX (`C-c C-e l l'), the code is not
> evaluated - `M-: my-var' results in `(void-variable my-var)' error.
>
> What am I missing?

Hi, Marcin,

I think you're missing the bit where Goswami explains that the block is
expected to be manually evaluated, not evaluated on export, then goes on
to automate "manual" execution (blog post section "Automating with
hooks").

With =:exports none= the code is not evaluated. As the manual now states
more clearly than it used to


  If results of evaluation are not marked for export (=:exports code= or
  =:exports none=), Org will not evaluate them, even for =:eval yes=.
  The only exception is when a code block uses =:session= - such blocks
  are evaluated according to their =:eval= header argument.
  (https://orgmode.org/manual/Exporting-Code-Blocks.html)

However, the exception for sessions would not apply in your case, since
ob-emacs-lisp does not support sessions and will throw an error if you
try to add one. (Philosophically, I think ob-emacs-lisp /always/ runs in
a session called Emacs, but...)

To get evaluation on export, changing your header to =:exports results=
should do the trick, with =:results none= still suppressing output.

Regards,
Christian




Reply via email to