[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Persisting the current working directory in an org-babel session
From: |
Adam Sneller |
Subject: |
Persisting the current working directory in an org-babel session |
Date: |
Sun, 1 Jan 2023 12:34:17 +0000 |
For some reason, I am unable to make changes to my working directory persist,
from one emacs-lisp SRC block to the next.
For example, consider the following:
* Literate programming in a single session
:PROPERTIES:
:header-args: :var DIR="/Users/adam/Desktop/test"
:END:
#+BEGIN_SRC emacs-lisp :session *elisp*
(cd DIR)
#+END_SRC
#+RESULTS:
: /Users/adam/Desktop/test/
#+BEGIN_SRC emacs-lisp :session *elisp*
(cd ".")
#+END_SRC
#+RESULTS:
: /Users/adam/org/
The :header-args: define a starting directory (DIR="/Users/adam/Desktop/test").
The first block establishes the *elisp* session and navigates into DIR, using
(cd DIR). Confirmation is then seen in the #+RESULTS.
A second block is then created in the same *elisp* session. This simply echos
the current working directory with (cd "."). BUT... the #+RESULTS show that the
working directory has not persisted from our first block and has instead,
defaulted to the default org-mode directory.
Now, I realise that I could have used :dir in my initial :header-args: to set
the same working directory for all blocks. But what I am interested in is why
my changes are not persisting, when (if I am not mistaken) this is the entire
point of establishing a session?
Thanks!
Adam Sneller
- Persisting the current working directory in an org-babel session,
Adam Sneller <=