emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Self-sufficient Org file with customised export? :eval-when?
@ 2020-04-30 18:55 akater
  2020-05-01 18:14 ` Berry, Charles via General discussions about Org-mode.
  0 siblings, 1 reply; 2+ messages in thread
From: akater @ 2020-04-30 18:55 UTC (permalink / raw)
  To: emacs-orgmode

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
..
#+end_src

#+begin_src emacs-lisp :eval-when tangle
..
#+end_src

#+begin_src emacs-lisp :eval-when export
..
#+end_src

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

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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Self-sufficient Org file with customised export? :eval-when?
  2020-04-30 18:55 Self-sufficient Org file with customised export? :eval-when? akater
@ 2020-05-01 18:14 ` Berry, Charles via General discussions about Org-mode.
  0 siblings, 0 replies; 2+ messages in thread
From: Berry, Charles via General discussions about Org-mode. @ 2020-05-01 18:14 UTC (permalink / raw)
  To: akater; +Cc: emacs-orgmode@gnu.org



> On Apr 30, 2020, at 11:55 AM, akater <nuclearspace@gmail.com> wrote:
> 

[deleted - discussion of html export]

> -----
> 
> 
> 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
> ..
> #+end_src
> 

You can effectively do this by using an elisp expression for the value of an :eval arg like this:


#+begin_src emacs-lisp :eval (or (bound-and-true-p my-eval-flag) "no")
"done"
#+end_src

which honors the value of `my-eval-flag' if there is one.

You can also use a call to a src block. e.g. `:eval my-src-block(a=1,b=2)'

HTH,

Chuck


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-01 18:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-30 18:55 Self-sufficient Org file with customised export? :eval-when? akater
2020-05-01 18:14 ` Berry, Charles via General discussions about Org-mode.

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).