From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 6FDQMjCTWmM8yQAAbAwnHQ (envelope-from ) for ; Thu, 27 Oct 2022 16:18:24 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id qAjCMjCTWmMC+AAA9RJhRA (envelope-from ) for ; Thu, 27 Oct 2022 16:18:24 +0200 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 5CC7A383EE for ; Thu, 27 Oct 2022 16:18:24 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oo3hD-0004Pu-Ob; Thu, 27 Oct 2022 10:17:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oo3h5-00049R-TF for emacs-orgmode@gnu.org; Thu, 27 Oct 2022 10:17:16 -0400 Received: from mout-p-202.mailbox.org ([80.241.56.172]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1oo3h1-0007fj-AV; Thu, 27 Oct 2022 10:17:15 -0400 Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4Mynmw1Psgz9scT; Thu, 27 Oct 2022 16:17:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kraus.my; s=MBO0001; t=1666880224; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6PFGB9RUiJoYZw1HhD109uXQr0I+c7SEgGr7ixMO3jc=; b=JyafWpkhu7lUkAlYv9PCAPWubUfJXu+20iGU9nxNNL0dlDX/sptSA9xkn49jYo3q57nccx QUcZljDtXdxH930WOqmGbPo5AYVRyJT6TTLLyIioHVr3XhWOkj1GAek0D/LOyclBG51ONO eC/Zu4AsWHFIAr0wBPv+rMm6WWkGYTO61USlLSBmdYsyXEkVmfudBAhMuTEyzZ7hAkdEr5 p2L6IYQQUz28XhCcvi4updXCeSrg3apSGxgykKnerCah3W9aFWtW0q+kByXHdjnJvxGqEo bEj37ugNtRk33XMqkTx/GD3Ogi54CGJqTCC/SMz34KkVJSSCPWmm8Ln9c4MQNA== References: <62520bbc.1c69fb81.d855b.549fSMTPIN_ADDED_BROKEN@mx.google.com> <87r0yvoycr.fsf@localhost> From: Daniel Kraus To: Ihor Radchenko Cc: numbchild@gmail.com, Bastien , emacs-orgmode@gnu.org Subject: Re: [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list Date: Thu, 27 Oct 2022 16:09:34 +0200 In-reply-to: <87r0yvoycr.fsf@localhost> Message-ID: <874jvp9wsg.fsf@kraus.my> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: none client-ip=80.241.56.172; envelope-from=daniel@kraus.my; helo=mout-p-202.mailbox.org X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Emacs-orgmode" Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1666880304; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=6PFGB9RUiJoYZw1HhD109uXQr0I+c7SEgGr7ixMO3jc=; b=AjfKcVvOv5xv6aMO/ms99TXHqj9Sydc85V9N+hnjtskmAdRHi22Dco6XUg7XIN2PUdRQko UjtQqkhcNtnkpEU7PW3mNkrrKEZX8h/rwo3n+hgmYiNhIVeibQIUWJffmHed07J+3ZYnfV /Yw08D2YilZWG3Rz1P1cPI7YnNOQltmDIBVunnmTV8YtBvqBtTRF8NvUfxJQ3d/Wss5/E0 n+gILm3Xibc7ZKxhSyEZGlV95KbieTZ3y71KkzFdMvrjjKrkb6AfRIyYa+AQ5DG2aPCT26 s4lr5OQw8AZr53kbmEuQISED4Yr5v7g+buCPjf16eqVh9tSn5OAHqB2yG7Cg4A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1666880304; a=rsa-sha256; cv=none; b=OT0O+degBFrLtpY8ActHoVM4awaTakWdRktzUzfzo3eAZJBMFIPru6hexy6rp3ZZQwKYEM EfLrPB+MnkPdssgWmQrCYGYPt/+Kw/zpyWWaus44yaUUvY9T0TKed9Qr0psfN3rV18C5nd Cmpb9gZiAPXjlG0ofguak2Ixv7QNoZQUmXkeBS1JbcdES7nRmdko6TQIyFoi2Fig2x7sVe NNmcXWo/34okiI0Kwpq7+KHXM942SxFZw6+0i81pGhWu/dBNzreC/RhZPC0HzW5fB9HrMc kYzk1KNpBJWX3aNkxaxiTu8vkvgavCo9n3cw5qbGccLNiyegfqw09RpIp4OA4w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=kraus.my header.s=MBO0001 header.b=JyafWpkh; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.92 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=kraus.my header.s=MBO0001 header.b=JyafWpkh; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 5CC7A383EE X-Spam-Score: -3.92 X-Migadu-Scanner: scn0.migadu.com X-TUID: FoIZsQ6LO+fu --=-=-= Content-Type: text/plain Hi! Ihor Radchenko writes: > "Christopher M. Miles" writes: >> Without this patch, it will report error "class java.lang.ClassCastException" from CIDER. > > Bastien, could you please take a look? I was unable to setup clojure dev > environment on my machine for testing. So, I am not able to confirm if > the issue exists. Just in case you want to play around with Clojure, installing babashka (https://github.com/babashka/babashka) is a single binary and very simple to install. >> ;; Variables binding. >> (if (null vars) (org-trim body) >> - (format "(let [%s]\n%s)" >> - (mapconcat >> - (lambda (var) >> - (format "%S %S" (car var) (cdr var))) >> - vars >> - "\n ") >> - body)))))) >> + ;; variable's value is a list from org-mode passed table or list. >> + (if (listp (cdr (car vars))) > > This test is fishy. It only tests for the first variable assignment. > What if you have multiple vars some being tables and some not? I looked at `ob-lisp.el` and simply always quoting seems to be working. See attached patch and here's my test (based from Chrisophers example): --cut-- #+NAME: ob-clojure-table-test | a | b | c | |---+---+---| | 1 | 2 | 3 | #+NAME: ob-clojure-table-test-2 | a | b | c | |---+---+---| | 1 | 2 | 3 | | 4 | 5 | 6 | #+begin_src clojure :var v1=42 :var v2="foobar" :var v3=ob-clojure-table-test :var v4=ob-clojure-table-test-2 :results output (prn (+ v1 5)) (prn v2) (prn v3) (prn v4) #+end_src #+RESULTS: : 47 : "foobar" : ((1 2 3)) : ((1 2 3) (4 5 6)) --cut-- Cheers, Daniel --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-lisp-ob-clojure.el-Fix-header-argument-var-binding.patch >From 1a2fa382e7a5925d4b85d90f1fe4ac7c012f81a4 Mon Sep 17 00:00:00 2001 From: Daniel Kraus Date: Thu, 27 Oct 2022 16:04:02 +0200 Subject: [PATCH] lisp/ob-clojure.el: Fix header argument :var binding * lisp/ob-clojure.el (org-babel-expand-body:clojure): Always quote the variables passed from org-mode in clojure let binding. When a variable is a table or list, it's value is is "(..data..)" and without quotes, clojure would try to execute the first value as a function. --- lisp/ob-clojure.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el index 0649469b3..c76a3f013 100644 --- a/lisp/ob-clojure.el +++ b/lisp/ob-clojure.el @@ -132,7 +132,7 @@ or set the `:backend' header argument")))) (format "(let [%s]\n%s)" (mapconcat (lambda (var) - (format "%S %S" (car var) (cdr var))) + (format "%S '%S" (car var) (cdr var))) vars "\n ") body)))))) -- 2.38.1 --=-=-=--