From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id eJhlG+yuK2acZgAA62LTzQ:P1 (envelope-from ) for ; Fri, 26 Apr 2024 15:41:00 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id eJhlG+yuK2acZgAA62LTzQ (envelope-from ) for ; Fri, 26 Apr 2024 15:41:00 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b="TWCI/X7n"; dmarc=pass (policy=none) header.from=posteo.net; 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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1714138860; 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=dLXxcZKU6CyZyzyk26uT0iI7GN4xF5/jaw5KMUr3axg=; b=FPEqzZ2wnDCBZnw31DwMjyBNhNaZgFs6MIfS/Gb7tktc3e/thfJlB+/XBFjPZ4xWqeyY4l dV6guy1Z4Fa/OGrPTFDQAMuWmVdNdGqaeZFT1YB1cgHQzIjAa6l7giGr3lWf49D5kzWu4k KEZM7I2DfBydT3RVk3cWiQ4AMYiKCRklTDtTAM4+pGnqejfkqYJ3q/cJJMM8+oajHUThbD eaV2iKZ4NFQAUOWX7+EtUBV7iRsURHg/8xImAqfeO2i/IncaeAf92Eq+EXFdoJE+QADc2l 5eDRX9El4v7BewPTvWfUiaHnLK0w1bm6gO28WedlbCbiIyQQu1uI9gNgTUTxVA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1714138860; a=rsa-sha256; cv=none; b=pCCnIyDDdRMePUYbB6XWTeBgUuaOtoHilCYATu+yVrv/IfgpBrUWWqIAO/zxkd+hDmWh0k qWHuBWUHjXoYGbv2azcVhzoT8EHDyHqTs1QjuA4Nt00Ao7jWYl3yxzkJdO6ns/fkMNySqZ wzeTGllfgbdlRQPB/mbj2IYcOKMctdvxXWmbyKFBRPJxHpQ1CSsB2lnAnyZLd+qP9csPih FCvyExfRc8kqRKgpY8Rp7ipBJiUbzc6zyfFf31tykvovvZ/X9TtPDwCUVi0EpKO876woXZ t/5Kkm8Gba43Q+ySWNmM/x7R9u2TEruwXxPDhCmlkmeGk32difMd/dR57IYg+w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b="TWCI/X7n"; dmarc=pass (policy=none) header.from=posteo.net; 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" 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 10B617956 for ; Fri, 26 Apr 2024 15:41:00 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s0Lo2-0006rp-MP; Fri, 26 Apr 2024 09:40:04 -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 1s0Lnw-0006oH-NL for emacs-orgmode@gnu.org; Fri, 26 Apr 2024 09:39:57 -0400 Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s0Lnu-0007xz-1V for emacs-orgmode@gnu.org; Fri, 26 Apr 2024 09:39:56 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 7FE16240027 for ; Fri, 26 Apr 2024 15:39:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1714138790; bh=eIx8zKlCYqc3tOQTYN5OGmw2Jc4aMtt7UUQXoOIF65U=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=TWCI/X7nmv0TLhlr/WAws2vbpMGnRS3UQVy0Ly9ElV75ZkYzGB3UVhfYM82c8aCOG jYsBNyVp3zn5x/XwAwcrToiz1afmVgfx7WnatKlNY9fn9arYS/i9Hq/Tz9uG8GUfgs 1qLgtSOr+pxj4HaC7d228LDWHixb74fVbNsLHHTKNKb0orYJ688n7SNE1AkjKNBRcG RlmoOWcHIGUqn+IpbfwBaUkIPY6t8oyRXOuS557w57feuO5VmX88kc/RP7pAyyRF0Q 4E6Kg4aqaeW+YH3VTOAr2iHj2+UZjllSDusz/SglbvzcRfvtRW+lhTgJPOjFcF/bLK LQcUOYIJhMTVw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4VQv3S4wcCz9rxG; Fri, 26 Apr 2024 15:39:48 +0200 (CEST) From: Ihor Radchenko To: Rudolf =?utf-8?Q?Adamkovi=C4=8D?= Cc: emacs-orgmode@gnu.org Subject: Re: [PATCH] ob-lua: Support all types and multiple values in results In-Reply-To: References: <20240423164458.33702-1-rudolf@adamkovic.org> <8734raewr6.fsf@localhost> Date: Fri, 26 Apr 2024 13:40:49 +0000 Message-ID: <87pluctf6m.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.65; envelope-from=yantar92@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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.29 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -6.60 X-Spam-Score: -6.60 X-Migadu-Queue-Id: 10B617956 X-Migadu-Scanner: mx11.migadu.com X-TUID: 48JfqdHRnBrd --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Rudolf Adamkovi=C4=8D writes: > Ihor Radchenko writes: > >> May you create a test for this with expected failure? > > Sure! Here is one: > > (should > (equal "{B}" > (org-test-with-temp-text > "src_lua{return string.match('A {B} C', '%b{}')}" > (org-babel-execute-src-block)))) > > The return value from 'string.match' is the substring "{B}", which Babel > misjudges to be a list and signals the error: > > (user-error "Inline error: list result cannot be used") Maybe something like the attached. (I am a casual lua user, so better double check) --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: inline; filename=0001-ob-lua-Fix-edge-case-when-output-is-string.patch Content-Transfer-Encoding: quoted-printable >From bfe0fa3d78cc13b84dec33c230755c9f4693a685 Mon Sep 17 00:00:00 2001 Message-ID: From: Ihor Radchenko Date: Fri, 26 Apr 2024 16:39:07 +0300 Subject: [PATCH] ob-lua: Fix edge case when output is {string} MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit * lisp/ob-lua.el (org-babel-lua-wrapper-method): Make sure that string result is enclosed in "...", so that Org mode does not try to guess the output type heuristically. * testing/lisp/test-ob-lua.el (test-ob-lua/types): New test. Co-authored-by: Rudolf Adamkovi=C4=8D --- lisp/ob-lua.el | 2 ++ testing/lisp/test-ob-lua.el | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/lisp/ob-lua.el b/lisp/ob-lua.el index 041abfabc..afe88065d 100644 --- a/lisp/ob-lua.el +++ b/lisp/ob-lua.el @@ -282,6 +282,8 @@ (defvar org-babel-lua-wrapper-method end end return result + elseif type(it) =3D=3D 'string' then + return '\"' .. it .. '\"' else return tostring(it) end diff --git a/testing/lisp/test-ob-lua.el b/testing/lisp/test-ob-lua.el index 0a60c68ca..398ab761d 100644 --- a/testing/lisp/test-ob-lua.el +++ b/testing/lisp/test-ob-lua.el @@ -158,6 +158,12 @@ (ert-deftest test-ob-lua/types () (equal "hello world" (org-test-with-temp-text "src_lua{return 'hello world'}" (org-babel-execute-src-block)))) + ;; Edge case: string matching list syntax. + (should + (equal "{B}" + (org-test-with-temp-text + "src_lua{return string.match('A {B} C', '%b{}')}" + (org-babel-execute-src-block)))) (should (equal 0 (string-match "table: 0x[0-9A-F]+" --=20 2.44.0 --=-=-= Content-Type: text/plain -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at --=-=-=--