ob-R, ob-julia: Use `ess-gen-proc-buffer-name-function' to control session buffer name

* lisp/ob-R.el (org-babel-R-initiate-session):
* lisp/ob-julia.el (org-babel-julia-initiate-session): Do not use the
hack with renaming ESS buffer and instead indicate the session buffer
name to ESS appropriately through `ess-gen-proc-buffer-name-function'.

Link: https://orgmode.org/list/871qb21bp7.fsf@gmail.com
This commit is contained in:
Ihor Radchenko 2024-01-05 14:56:21 +01:00
parent c10a079a2c
commit b6643884cb
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
2 changed files with 17 additions and 21 deletions

View File

@ -265,15 +265,19 @@ Retrieve variables from PARAMS."
(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."
(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))))))
(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)))))
;; Make ESS name the process buffer as SESSION.
(ess-gen-proc-buffer-name-function
(lambda (_) session)))
(if (org-babel-comint-buffer-livep session)
session
(save-window-excursion
@ -286,12 +290,6 @@ Use PARAMS to set default directory when creating a new session."
ess-current-process-name))))
(while (process-get R-proc 'callbacks)
(ess-wait-for-process R-proc)))
(rename-buffer
(if (bufferp session)
(buffer-name session)
(if (stringp session)
session
(buffer-name))))
(current-buffer))))))
(defun org-babel-R-associate-session (session)

View File

@ -178,13 +178,17 @@ end"
(format "%s = %s" name (org-babel-julia-quote-csv-field value))))
(defvar ess-ask-for-ess-directory) ; dynamically scoped
(defvar ess-gen-proc-buffer-name-function) ; defined in ess-inf.el
(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))))))
(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)))))
;; Make ESS name the process buffer as SESSION.
(ess-gen-proc-buffer-name-function
(lambda (_) session)))
(if (org-babel-comint-buffer-livep session)
session
;; FIXME: Depending on `display-buffer-alist', (julia) may end up
@ -198,12 +202,6 @@ end"
(set-buffer session))
(org-require-package 'ess "ESS")
(set-buffer (julia))
(rename-buffer
(if (bufferp session)
(buffer-name session)
(if (stringp session)
session
(buffer-name))))
(current-buffer))))))
(defun org-babel-julia-graphical-output-file (params)