From f5467b53ec9be02ceaca8494e58090b3972fe2ac Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Fri, 4 Aug 2023 09:30:47 +0300 Subject: [PATCH] lisp/ob-shell.el: Fix sessions for generic "shell" blocks * lisp/ob-shell.el (org-babel-prompt-command): Remove variable. (org-babel-sh-initiate-session): Set prompt according to `shell-file-name' - either the value set in let-binding provided by `org-babel-shell-initialize' or using the default Emacs value of `shell-file-name'. (org-babel-shell-initialize): Do not set `org-babel-prompt-command'. Only let-bind `shell-file-name' according to shell variant in src block. --- lisp/ob-shell.el | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lisp/ob-shell.el b/lisp/ob-shell.el index ae86ee4c2..6c69c2884 100644 --- a/lisp/ob-shell.el +++ b/lisp/ob-shell.el @@ -67,8 +67,6 @@ that will be called with a single additional argument: prompt string. The fallback association template is defined in (t . \"template\") alist element.") -(defvar org-babel-prompt-command) - (defun org-babel-shell-initialize () "Define execution functions associated to shell names. This function has to be called whenever `org-babel-shell-names' @@ -80,10 +78,7 @@ is modified outside the Customize interface." (lambda (body params) (:documentation (format "Execute a block of %s commands with Babel." name)) - (let ((shell-file-name name) - (org-babel-prompt-command - (or (cdr (assoc name org-babel-shell-set-prompt-commands)) - (alist-get t org-babel-shell-set-prompt-commands)))) + (let ((shell-file-name name)) (org-babel-execute:shell body params)))) (put fname 'definition-name 'org-babel-shell-initialize)) (defalias (intern (concat "org-babel-variable-assignments:" name)) @@ -259,7 +254,11 @@ var of the same value." (org-babel-comint-wait-for-output (current-buffer)) (org-babel-comint-input-command (current-buffer) - (format org-babel-prompt-command org-babel-sh-prompt)) + (format + (or (cdr (assoc (file-name-nondirectory shell-file-name) + org-babel-shell-set-prompt-commands)) + (alist-get t org-babel-shell-set-prompt-commands)) + org-babel-sh-prompt)) (setq-local comint-prompt-regexp (concat "^" (regexp-quote org-babel-sh-prompt) " *"))