[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: |
Tue, 10 Nov 2020 21:34:13 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) |
> Using the :ruby header arg.
>
> * lisp/ob-ruby.el (org-babel-execute:ruby): Locally set
> `org-babel-ruby-command' using a header argument.
>
> TINYCHANGE
> ---
> lisp/ob-ruby.el | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/lisp/ob-ruby.el b/lisp/ob-ruby.el
> index 669c2eabf..80870c6c0 100644
> --- a/lisp/ob-ruby.el
> +++ b/lisp/ob-ruby.el
> @@ -74,6 +74,9 @@ This function is called by `org-babel-execute-src-block'."
> (cdr (assq :session params))))
> (result-params (cdr (assq :result-params params)))
> (result-type (cdr (assq :result-type params)))
> + (org-babel-ruby-command
> + (or (cdr (assq :ruby params))
> + org-babel-ruby-command))
> (full-body (org-babel-expand-body:generic
> body params (org-babel-variable-assignments:ruby params)))
> (result (if (member "xmp" result-params)
Thanks, this is a much needed change. But currently it is limited only
to non-session code execution. Here is an additional patch that also
supports the same feature for session code execution as well:
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.
diff --git a/lisp/org/ob-ruby.el b/lisp/org/ob-ruby.el
index 1b8088eaee..aa28bf1899 100644
--- a/lisp/org/ob-ruby.el
+++ b/lisp/org/ob-ruby.el
@@ -51,7 +51,8 @@ org-babel-tangle-lang-exts
(defvar org-babel-default-header-args:ruby '())
(defvar org-babel-ruby-command "ruby"
- "Name of command to use for executing ruby code.")
+ "Name of command to use for executing ruby code.
+It's possible to override it by using a header argument `:ruby'")
(defcustom org-babel-ruby-hline-to "nil"
"Replace hlines in incoming tables with this when translating to ruby."
@@ -71,7 +72,7 @@ org-babel-execute:ruby
"Execute a block of Ruby code with Babel.
This function is called by `org-babel-execute-src-block'."
(let* ((session (org-babel-ruby-initiate-session
- (cdr (assq :session params))))
+ (cdr (assq :session params)) params))
(result-params (cdr (assq :result-params params)))
(result-type (cdr (assq :result-type params)))
(full-body (org-babel-expand-body:generic
@@ -147,14 +148,15 @@ org-babel-ruby-table-or-string
res)
res)))
-(defun org-babel-ruby-initiate-session (&optional session _params)
+(defun org-babel-ruby-initiate-session (&optional session params)
"Initiate a ruby session.
If there is not a current inferior-process-buffer in SESSION
then create one. Return the initialized session."
(unless (string= session "none")
(require 'inf-ruby)
- (let* ((cmd (cdr (assoc inf-ruby-default-implementation
- inf-ruby-implementations)))
+ (let* ((cmd (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 cmd session)
- Re: [PATCH] ob-ruby.el: allow specification of ruby command w/header arg,
Juri Linkov <=