1
#+BEGIN_SRC emacs-lisp :results silent :session first
  (setq one 1)
#+END_SRC

#+BEGIN_SRC emacs-lisp :results output :session second
  (print one)
#+END_SRC

#+RESULTS:
:
: 1

If org mode supports :session argument for emacs-lisp source block, could you point out why the second session mentioned above prints 1 as output instead of giving error for variable is void

3

The :session argument sets up a language interpreter that is shared among code blocks. If it is not used, a new interpreter is created for each code block and code is not shared. This is equivalent of having two terminal windows both running independent python interactive interpreters.

In case of elisp, the :session argument is simply ignored. You are already running one session of elisp inside emacs and all elisp code blocks are executed under that session. In other words, all elisp code blocks directly modify the emacs environment. In your example, variable one is in set and accessed from this shared lisp process.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.