From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 6GmmIMmarl8seQAA0tVLHw (envelope-from ) for ; Fri, 13 Nov 2020 14:40: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 mp0 with LMTPS id +BSpHMmarl9eOAAA1q6Kng (envelope-from ) for ; Fri, 13 Nov 2020 14:40: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 88FD594014A for ; Fri, 13 Nov 2020 14:40:08 +0000 (UTC) Received: from localhost ([::1]:57208 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kdaFC-0007P6-11 for larch@yhetil.org; Fri, 13 Nov 2020 09:40:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43454) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kdaEo-0007NS-39 for emacs-orgmode@gnu.org; Fri, 13 Nov 2020 09:39:42 -0500 Received: from grinta.net ([109.74.203.128]:53078) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kdaEl-0006pJ-Et for emacs-orgmode@gnu.org; Fri, 13 Nov 2020 09:39:41 -0500 Received: from black.local (ip-109-41-67-228.web.vodafone.de [109.41.67.228]) (Authenticated sender: daniele) by grinta.net (Postfix) with ESMTPSA id 8F8BBEE0D0 for ; Fri, 13 Nov 2020 14:39:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=grinta.net; s=2020; t=1605278375; bh=lxy9ZqbsYuWyuw7FxxANmjMs/4WV7Vl94JA2qbhYL2U=; h=To:From:Subject:Date:From; b=Trbhk8SSCcDghdmTBwVgy08j9HSVL6CvYLaqpTfXk15Jn4wCdp1+PdllOJykD1BCU kJnCl6dNnhSLWSjvQQDIzXw3vgfqA4GkOMbfN2Iflw+FuiRhlNrkVeJXuGepGaR6U0 QuRrXRRpMK4T2AmXl8CKhBhGCvgQI8e0UFpBjYF/LdWSFQPkAMJ0deyEWhoIYnltxm JcKnSvnmdoDrZYU4AfG3UwYSFYN4z9mjrVjM20N06b0gaSejhmqzzICU1qfDclbDx8 EqGD2A7W60FK/ZEWW3dZs2PR1u1iezYefKELtGuGKopmtISxIxwKM7+gSpfIXw6/t2 lF1ppU0w/R1ww== To: Org Mode List From: Daniele Nicolodi Subject: How is org-sbe supposed to work? Message-ID: <7de3bd69-4604-302a-b6d4-4e190f23bdb8@grinta.net> Date: Fri, 13 Nov 2020 15:39:33 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.12.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=109.74.203.128; envelope-from=daniele@grinta.net; helo=grinta.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/13 09:39:36 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-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: , 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=fail (headers rsa verify failed) header.d=grinta.net header.s=2020 header.b=Trbhk8SS; 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: 0.99 X-TUID: ufHnGaVkPihH Hello, I am trying to use the org-sbe macro to execute a code block with input from an org table, however it does not work as I would expect it to work and the code is cryptic enough for me to not being able to understand what the intent was when it was written. I searched for tests in the codebase that exercise this functionality, but I haven't found any: daniele@black:~/src/org-mode$ grep org-sbe * -r lisp/ob-table.el:;; `org-sbe' as so... lisp/ob-table.el:;; #+TBLFM: $2='(org-sbe "fibbd" (n $1)) lisp/ob-table.el:(defmacro org-sbe (source-block &rest variables) lisp/ob-table.el:So this `org-sbe' construct lisp/ob-table.el: (org-sbe \"source-block\" (n $2) (m 3)) lisp/ob-table.el:#+TBLFM: @1$4=\\='(org-sbe test-sbe $3 (x $1) (y $2))" How are variables passed to the code block supposed to be handled? The macro docstring does not mention anything particular, thus I would imagine they are handled just like in any other lisp code. However, this does not seem to be the case. In the case that the values are integers, all works as expected: #+name: example #+begin_src emacs-lisp :var x=1 (format "x:%S" x) #+end_src #+call: example(x=2) #+RESULTS: : x:2 | 1 | x:2 | #+TBLFM: $2='(org-sbe "example" (x 2)) However, strings are not handled correctly: #+call: example(x="baz") #+RESULTS: : x:"baz" | 1 | #ERROR | #+TBLFM: $2='(org-sbe "example" (x "baz")) unless "double quoted": | 1 | x:"baz" | #+TBLFM: $2='(org-sbe "example" (x "\"baz\"")) and becomes an exercise in code injection if the string needs to come from a table cell: | baz | x:"baz" | x:"baz" | #+TBLFM: $2='(org-sbe "example" (x \"$1\"));L #+TBLFM: $3='(format "x:%S" $1) Things get even more fun if the string value is the name of a code block: #+name: foo #+begin_src emacs-lisp :var x=1 nil #+end_src #+call: example(x="foo") #+RESULTS: : x:"foo" | 1 | | #+TBLFM: $2='(org-sbe "example" (x "foo")) as in this case, org-sbe actually tries to execute that code block instead than using the literal string. Should we come up with some tests highlighting the expected behavior of org-sbe and make the implementation work accordingly? Thank you. Cheers, Dan