From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id mPWUMsXtql98dAAA0tVLHw (envelope-from ) for ; Tue, 10 Nov 2020 19:45:09 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id qF06LsXtql+pbwAAbx9fmQ (envelope-from ) for ; Tue, 10 Nov 2020 19:45:09 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 5FD15940538 for ; Tue, 10 Nov 2020 19:45:09 +0000 (UTC) Received: from localhost ([::1]:53712 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kcZZk-0001wE-9O for larch@yhetil.org; Tue, 10 Nov 2020 14:45:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52264) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcZR1-0002Xt-5T for emacs-orgmode@gnu.org; Tue, 10 Nov 2020 14:36:08 -0500 Received: from relay12.mail.gandi.net ([217.70.178.232]:49667) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcZQx-0000ca-Tr for emacs-orgmode@gnu.org; Tue, 10 Nov 2020 14:36:06 -0500 Received: from mail.gandi.net (m91-129-97-46.cust.tele2.ee [91.129.97.46]) (Authenticated sender: juri@linkov.net) by relay12.mail.gandi.net (Postfix) with ESMTPSA id 1657B200008; Tue, 10 Nov 2020 19:35:58 +0000 (UTC) From: Juri Linkov To: Aaron Madlon-Kay Subject: Re: [PATCH] ob-ruby.el: allow specification of ruby command w/header arg Organization: LINKOV.NET References: <20201020084956.61337-1-aaron@madlon-kay.com> <20201020084956.61337-2-aaron@madlon-kay.com> Date: Tue, 10 Nov 2020 21:34:13 +0200 In-Reply-To: <20201020084956.61337-2-aaron@madlon-kay.com> (Aaron Madlon-Kay's message of "Tue, 20 Oct 2020 17:49:56 +0900") Message-ID: <87y2j9j9ai.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=217.70.178.232; envelope-from=juri@linkov.net; helo=relay12.mail.gandi.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/10 14:36:00 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: ns3122888.ip-94-23-21.eu Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -1.01 X-TUID: +o796zDRM9Mv --=-=-= Content-Type: text/plain > 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. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=ob-ruby-session-command.patch 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) --=-=-=--