emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Aaron Madlon-Kay <aaron@madlon-kay.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] ob-ruby.el: allow specification of ruby command w/header arg
Date: Tue, 10 Nov 2020 21:34:13 +0200	[thread overview]
Message-ID: <87y2j9j9ai.fsf@mail.linkov.net> (raw)
In-Reply-To: <20201020084956.61337-2-aaron@madlon-kay.com> (Aaron Madlon-Kay's message of "Tue, 20 Oct 2020 17:49:56 +0900")

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

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: ob-ruby-session-command.patch --]
[-- Type: text/x-diff, Size: 1805 bytes --]

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)

  parent reply	other threads:[~2020-11-10 19:45 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 [this message]
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
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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  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=87y2j9j9ai.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=aaron@madlon-kay.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* 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

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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).