[Top][All Lists]

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

Self-sufficient Org file with customised export? :eval-when?

From: akater
Subject: Self-sufficient Org file with customised export? :eval-when?
Date: Thu, 30 Apr 2020 18:55:17 +0000

I'd like to write an Org file that would export to a html with fairly
significant tweaks along the way.  The rough idea is, users should be
able to run reasonaly recent vanilla emacs, (require 'ox),
(org-html-export-to-html) and get a fine-tuned html.

I also would like to move relevant Elisp to the end of the Org file
because the text is going to be read by humans, and people with(out)
certain background apparently faint too often when they see Lisp on top
of a text written in markup.

I put an emacs-lisp src block under the last unexported section, with
header arguments :exports none :results none, but it does not seem to be
evaluated on export.  I couldn't find anything relevant in Info directory.

I know that with vanilla emacs one needs to explicitly allow evaluation
of blocks but that can be considred an acceptable preamble.

It would also be great if exporting such a file would not alter the
state of Emacs session too much (wouldn't pollute hooks or add advices,
for example) but that's low priority.  For now, I just want a
self-contained customisation with minimal hassle for users to get the
export result that was intended.  What are my options?


If I may prematurely offer my vision: Common Lisp has special operator
eval-when which specifies when the enclosed code is to be evaluated (or
compiled).  Example:

(eval-when (:compile-toplevel) (defun f () ..))

specifies that function f should be defined during compilation only.

I believe it would be neat if Org-mode widely supported :eval-when
header argument inspired by Common Lisp's eval-when.  Usage examples
would be:

#+begin_src emacs-lisp :eval-when compile load

#+begin_src emacs-lisp :eval-when tangle

#+begin_src emacs-lisp :eval-when export

#+begin_src emacs-lisp :eval-when ()

where the last setting would be equivalent to the (now-supported)
:eval never.

In my case, I'd write a block with header arguments

:eval-when export :results none

if this feature was supported.

I'm currently working on a Common Lisp-specific feature that will
introduce :eval-when (it will be offered to a Common Lisp library
literate-lisp) so I'm interested in opinions on this as well.

reply via email to

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