From a20049fc53f4474b3c6d50da08369dbb67af9c38 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Wed, 25 Nov 2020 21:35:01 +0200 Subject: [PATCH] ob-ruby.el: Don't reuse the same buffer among different named sessions * lisp/ob-ruby.el (org-babel-ruby-initiate-session): Instead of run-ruby that always insists on using the existing buffer, use run-ruby-or-pop-to-buffer that allows using the buffer with the same name as :session header arg. Use the existing buffer returned by inf-ruby-buffer only when :session header arg is nil. https://github.com/nonsequitur/inf-ruby/issues/121 --- lisp/ob-ruby.el | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lisp/ob-ruby.el b/lisp/ob-ruby.el index 5ad006429..47548ff7b 100644 --- a/lisp/ob-ruby.el +++ b/lisp/ob-ruby.el @@ -40,6 +40,8 @@ (require 'org-macs) (declare-function run-ruby "ext:inf-ruby" (&optional command name)) +(declare-function run-ruby-or-pop-to-buffer "ext:inf-ruby" (command &optional name buffer)) +(declare-function inf-ruby-buffer "ext:inf-ruby" ()) (declare-function xmp "ext:rcodetools" (&optional option)) (defvar inf-ruby-default-implementation) @@ -163,7 +165,10 @@ org-babel-ruby-initiate-session inf-ruby-implementations)))) (buffer (get-buffer (format "*%s*" session))) (session-buffer (or buffer (save-window-excursion - (run-ruby cmd session) + (run-ruby-or-pop-to-buffer + cmd (or session "ruby") + (unless session + (inf-ruby-buffer))) (current-buffer))))) (if (org-babel-comint-buffer-livep session-buffer) (progn (sit-for .25) session-buffer) -- 2.25.1