Browse Source

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
Juri Linkov 4 years ago
parent
commit
f7e286ab96
1 changed files with 6 additions and 2 deletions
  1. 6 2
      lisp/ob-ruby.el

+ 6 - 2
lisp/ob-ruby.el

@@ -39,7 +39,8 @@
 (require 'ob)
 (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 +164,10 @@ then create one.  Return the initialized 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)