emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] ob-ruby.el: Don't reuse the same buffer among different name


From: Juri Linkov
Subject: Re: [PATCH] ob-ruby.el: Don't reuse the same buffer among different named
Date: Sun, 13 Dec 2020 21:22:50 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

>> I'm not sure if it should be org-mode's responsibility to resolve the
>> actual command string, or if it should be done by
>> `run-ruby-or-pop-to-buffer'. (It kind of seems like the latter?)
>>
>> Any thoughts?
>
> Given the current situation, I don't see a good option aside from doing
> the functionp dance in org-babel-ruby-initiate-session as well.  Even if
> inf-ruby's check was moved downstream of run-ruby-or-pop-to-buffer, I
> think it'd be good to fix on ob-ruby's end to work with the current
> inf-ruby.
>
> Juri, what do you think?

Thanks for notifying me.  I completely agree that the most suitable
place to fix would be in org-babel-ruby-initiate-session.  So here
is a patch that I tested with different org header args:

>From 41218eafa9285844ea4e84c52e265b2c0232c1ba Mon Sep 17 00:00:00 2001
From: Juri Linkov <juri@linkov.net>
Date: Sun, 13 Dec 2020 21:21:37 +0200
Subject: [PATCH] ob-ruby.el: Funcall command if it's a function from
 inf-ruby-implementations

* lisp/ob-ruby.el (org-babel-ruby-initiate-session): When 'command'
is a function from 'inf-ruby-implementations', use 'funcall' to get
a command string for the first arg of 'run-ruby-or-pop-to-buffer'.
This is like what 'run-ruby' does.
---
 lisp/ob-ruby.el | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/lisp/ob-ruby.el b/lisp/ob-ruby.el
index 5ed29f889..2e33bfa29 100644
--- a/lisp/ob-ruby.el
+++ b/lisp/ob-ruby.el
@@ -159,13 +159,16 @@ org-babel-ruby-initiate-session
 then create one.  Return the initialized session."
   (unless (string= session "none")
     (require 'inf-ruby)
-    (let* ((cmd (cdr (or (assq :ruby params)
-                        (assoc inf-ruby-default-implementation
-                               inf-ruby-implementations))))
+    (let* ((command (cdr (or (assq :ruby params)
+                            (assoc inf-ruby-default-implementation
+                                   inf-ruby-implementations))))
           (buffer (get-buffer (format "*%s*" session)))
           (session-buffer (or buffer (save-window-excursion
                                        (run-ruby-or-pop-to-buffer
-                                        cmd (or session "ruby")
+                                        (if (functionp command)
+                                            (funcall command)
+                                          command)
+                                        (or session "ruby")
                                         (unless session
                                           (inf-ruby-buffer)))
                                        (current-buffer)))))
-- 
2.25.1


reply via email to

[Prev in Thread] Current Thread [Next in Thread]