[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org 62b88d613e 2/2: ob-R, ob-julia: Obey babel working
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org 62b88d613e 2/2: ob-R, ob-julia: Obey babel working dir conventions with session |
Date: |
Tue, 6 Aug 2024 06:59:16 -0400 (EDT) |
branch: externals/org
commit 62b88d613e9a5c49b78e8bbc358e410a95d1ba7f
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>
ob-R, ob-julia: Obey babel working dir conventions with session
* lisp/ob-R.el (org-babel-R-initiate-session):
* lisp/ob-julia.el (org-babel-julia-initiate-session): Force using
`default-directory' as working directory for ESS sessions.
* etc/ORG-NEWS (~ob-R~ and ~ob-julia~ no longer use ESS settings for
working directory): Announce the breaking change.
Link: https://orgmode.org/list/871q4izpr4.fsf@localhost
---
etc/ORG-NEWS | 13 +++++++++++++
lisp/ob-R.el | 28 +++++++++++++++++-----------
lisp/ob-julia.el | 28 ++++++++++++++++++----------
3 files changed, 48 insertions(+), 21 deletions(-)
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index e7e3c02503..86bc94208c 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -114,6 +114,19 @@ to dynamically generate the content of the resulting
~<head>~ tag in
the resulting HTML document.
** Miscellaneous
+*** ~ob-R~ and ~ob-julia~ no longer use ESS settings for working directory
+
+Previously, without =:dir= parameter, R and Julia code blocks could
+query for working directory during evaluation. This was because
+~ess-ask-for-ess-directory~ setting was obeyed.
+
+Now, ~ess-ask-for-ess-directory~, ~ess-directory-function~, and
+~ess-directory~ are all ignored during code block evaluation (except
+when session is already running). In other words, R and Julia code
+blocks now conform to the "16.4 Environment of a Code Block" section
+of Org mode manual that prescribes Org buffer directory or ~:dir~
+value to be used as working dir to run the code blocks.
+
*** ~org-cancel-repeater~ now cancels all the repeaters under inside entry
Previously, ~org-cacnel-repeater~ only canceled repeater in the first
diff --git a/lisp/ob-R.el b/lisp/ob-R.el
index de2d27a9a7..4812122024 100644
--- a/lisp/ob-R.el
+++ b/lisp/ob-R.el
@@ -43,6 +43,14 @@
(declare-function ess-wait-for-process "ext:ess-inf"
(&optional proc sec-prompt wait force-redisplay))
+(defvar ess-current-process-name) ; ess-custom.el
+(defvar ess-local-process-name) ; ess-custom.el
+(defvar ess-ask-for-ess-directory) ; ess-custom.el
+(defvar ess-directory-function) ; ess-custom.el
+(defvar ess-directory) ; ess-custom.el
+(defvar ess-gen-proc-buffer-name-function) ; ess-custom.el
+(defvar ess-eval-visibly) ; ess-custom.el
+
(defconst org-babel-header-args:R
'((width . :any)
(height . :any)
@@ -254,19 +262,17 @@ Retrieve variables from PARAMS."
(t (format "%s <- %S" name (prin1-to-string value))))))
-(defvar ess-current-process-name) ; dynamically scoped
-(defvar ess-local-process-name) ; dynamically scoped
-(defvar ess-ask-for-ess-directory) ; dynamically scoped
-(defvar ess-gen-proc-buffer-name-function) ; defined in ess-inf.el
-(defun org-babel-R-initiate-session (session params)
- "Create or return the current R SESSION buffer.
-Use PARAMS to set default directory when creating a new session."
+(defun org-babel-R-initiate-session (session _params)
+ "Create or return the current R SESSION buffer."
(unless (string= session "none")
(let* ((session (or session "*R*"))
- (ess-ask-for-ess-directory
- (and (boundp 'ess-ask-for-ess-directory)
- ess-ask-for-ess-directory
- (not (cdr (assq :dir params)))))
+ ;; Force using `default-directory', as we promise in the
+ ;; manual. The caller should have taken care about setting
+ ;; it according to :dir if necessary.
+ ;;
https://ess.r-project.org/Manual/ess.html#Changing-the-startup-actions
+ (ess-ask-for-ess-directory nil)
+ (ess-directory-function nil)
+ (ess-directory nil)
;; Make ESS name the process buffer as SESSION.
(ess-gen-proc-buffer-name-function
(lambda (_) session)))
diff --git a/lisp/ob-julia.el b/lisp/ob-julia.el
index 10a331e54d..f4a0f0cb3a 100644
--- a/lisp/ob-julia.el
+++ b/lisp/ob-julia.el
@@ -46,6 +46,15 @@
(declare-function ess-wait-for-process "ext:ess-inf"
(&optional proc sec-prompt wait force-redisplay))
+(defvar ess-current-process-name) ; ess-custom.el
+(defvar ess-local-process-name) ; ess-custom.el
+(defvar ess-eval-visibly) ; ess-custom.el
+(defvar ess-local-customize-alist); ess-custom.el
+(defvar ess-gen-proc-buffer-name-function) ; ess-custom.el
+(defvar ess-ask-for-ess-directory) ; ess-custom.el
+(defvar ess-directory-function) ; ess-custom.el
+(defvar ess-directory) ; ess-custom.el
+
(defvar org-babel-header-args:julia
'((width . :any)
(horizontal . :any)
@@ -66,11 +75,6 @@
:group 'org-babel
:type 'string)
-(defvar ess-current-process-name) ; dynamically scoped
-(defvar ess-local-process-name) ; dynamically scoped
-(defvar ess-eval-visibly-p) ; dynamically scoped
-(defvar ess-local-customize-alist); dynamically scoped
-(defvar ess-gen-proc-buffer-name-function) ; defined in ess-inf.el
(defun org-babel-julia-associate-session (session)
"Associate R code buffer with an R session.
Make SESSION be the inferior ESS process associated with the
@@ -181,13 +185,17 @@ end"
(format "%s = %s" name (org-babel-julia-quote-csv-field value))))
(defvar ess-ask-for-ess-directory) ; dynamically scoped
-(defun org-babel-julia-initiate-session (session params)
+(defun org-babel-julia-initiate-session (session _params)
"If there is not a current julia process then create one."
(unless (string= session "none")
(let* ((session (or session "*Julia*"))
- (ess-ask-for-ess-directory
- (and (bound-and-true-p ess-ask-for-ess-directory)
- (not (cdr (assq :dir params)))))
+ ;; Force using `default-directory', as we promise in the
+ ;; manual. The caller should have taken care about setting
+ ;; it according to :dir if necessary.
+ ;;
https://ess.r-project.org/Manual/ess.html#Changing-the-startup-actions
+ (ess-ask-for-ess-directory nil)
+ (ess-directory-function nil)
+ (ess-directory nil)
;; Make ESS name the process buffer as SESSION.
(ess-gen-proc-buffer-name-function
(lambda (_) session)))
@@ -293,7 +301,7 @@ last statement in BODY, as elisp."
(let ((ess-local-customize-alist t)
(ess-local-process-name
(process-name (get-buffer-process session)))
- (ess-eval-visibly-p nil))
+ (ess-eval-visibly nil))
(ess-eval-buffer nil)))
(let ((tmp-file (org-babel-temp-file "julia-")))
(org-babel-comint-eval-invisibly-and-wait-for-file