[emacs-berlin] org-babel evaluate elisp for “window changing” functions

Gary Phillips gary.phillips at rolmo.com
Thu Jun 27 00:32:40 UTC 2019


Thanks everyone for a great Emacs night which I found very inspiring.

Tonight we looked at a problem I had hit with running Emacs Lisp code
“interactively” inside an org-mode buffer.

This is the best solution I’ve found so far (not yet tried for my example
but it looks good).
https://emacs.stackexchange.com/questions/42096/running-elisp-within-an-orgmode-code-block?rq=1

We evaluate the following code block and only see the buffer name which
ediff-files creates and not the interactive ediff session we expect.
 #+begin_src elisp
(ediff-files “foo.s” “bar.s”)
 #+end_src

Causing the problem is the Emacs macro ’save-excursion’ which saves and
restores all window settings after executing the code given as its
parameter.
’save-excursion’  is used by org-babel whenever it evaluates code.
In the case of ediff-files, all the correct buffers and windows are created
but when the setup is finished it returns to save-excursion and everything
is put back as before. [I’ve omitted stuff about the Emacs event loop which
may or may not be recursive.]

Lisp macros are executed and expanded at compile-time and so we can’t just
replace save-excursion with a new temporary function of the same name.

The solution shown on stackexchange is quite complicated because it must
rewrite the ’save-excursion’ macro inside  ‘org-babel-execute:emacs-lisp’.
There may be a better solution if we can modify the source code of
‘org-babel-execute:emacs-lisp’.

Cheers
Gary
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailb.org/pipermail/emacs-berlin/attachments/20190627/93e43c2a/attachment.html>


More information about the emacs-berlin mailing list