emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Kyle Meyer <kyle@kyleam.com>
Cc: emacs-orgmode@gnu.org, Aaron Madlon-Kay <aaron@madlon-kay.com>
Subject: Re: [PATCH] ob-ruby.el: Don't reuse the same buffer among different named
Date: Sun, 13 Dec 2020 21:22:50 +0200	[thread overview]
Message-ID: <875z55fr3p.fsf@mail.linkov.net> (raw)
In-Reply-To: <87pn3euzcg.fsf@kyleam.com> (Kyle Meyer's message of "Sun, 13 Dec 2020 04:03:29 GMT")

[-- Attachment #1: Type: text/plain, Size: 742 bytes --]

>> 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:

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ob-ruby.el-Funcall-command-if-it-s-a-function-from-i.patch --]
[-- Type: text/x-diff, Size: 1485 bytes --]

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

* 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
-					 cmd (or session "ruby")
+					 (if (functionp command)
+					     (funcall command)
+					   command)
+					 (or session "ruby")
 					 (unless session

  reply	other threads:[~2020-12-13 19:25 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-20  8:49 Aaron Madlon-Kay
2020-10-20  8:49 ` [PATCH] ob-ruby.el: allow specification of ruby command w/header arg Aaron Madlon-Kay
2020-10-24 11:39   ` Bastien
2020-10-25  1:21     ` Aaron Madlon-Kay
2020-11-10 19:34   ` Juri Linkov
2020-11-14 21:19     ` Kyle Meyer
2020-11-25 19:41       ` Juri Linkov
2020-11-27  6:42         ` [PATCH] ob-ruby.el: Don't reuse the same buffer among different named Kyle Meyer
2020-11-28 22:23           ` Kyle Meyer
2020-12-11  7:23             ` Aaron Madlon-Kay
2020-12-13  4:03               ` Kyle Meyer
2020-12-13 19:22                 ` Juri Linkov [this message]
2020-12-13 20:00                   ` Kyle Meyer
2020-12-14  0:52                     ` Aaron Madlon-Kay

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875z55fr3p.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=aaron@madlon-kay.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=kyle@kyleam.com \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).