org-babel-execute-src-block: Force :dir according to live session

* lisp/ob-core.el (org-babel-execute-src-block): Force eval directory
to follow live session buffer, if any.  This is consistent with what
we promise in the manual section "16.4 Environment of a Code
Block">Choosing a working directory.

Link: https://orgmode.org/list/87mssi8ht2.fsf@gmail.com
This commit is contained in:
Ihor Radchenko 2024-02-03 16:47:57 +01:00
parent cbfe1354b3
commit 13d0f8bf8e
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 11 additions and 8 deletions

View File

@ -842,6 +842,9 @@ guess will be made."
(default-directory
(cond
((not dir) default-directory)
((when-let ((session (cdr (assq :session params))))
(when (org-babel-comint-buffer-livep session)
(buffer-local-value 'default-directory (get-buffer session)))))
((member mkdirp '("no" "nil" nil))
(file-name-as-directory (expand-file-name dir)))
(t