[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] ob-ruby.el: allow specification of ruby command w/header arg
From: |
Juri Linkov |
Subject: |
Re: [PATCH] ob-ruby.el: allow specification of ruby command w/header arg |
Date: |
Wed, 25 Nov 2020 21:41:53 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) |
>> ob-ruby.el: allow specification of session ruby command w/header arg
>>
>> * lisp/ob-ruby.el (org-babel-ruby-initiate-session): Use a header argument
>> to get ruby command.
>
> I've ported it to the Org repo, but please avoid doing this in the
> future. The preferred method is for development to happen through
> Org's list and repo.
Thanks, point taken.
Now in https://github.com/nonsequitur/inf-ruby/issues/121
we came to the conclusion that another patch is needed for ob-ruby.el.
This patch should allow sharing the same :session among code blocks
for the same root dir only when :session is nil. But in case of
a named :session, its commands always should be encapsulated
within the buffer with the same name as :session.
Therefore I'm submitting the patch here for inclusion
to the Org repo. Thanks in advance.
>From a20049fc53f4474b3c6d50da08369dbb67af9c38 Mon Sep 17 00:00:00 2001
From: Juri Linkov <juri@linkov.net>
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