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 ms0.migadu.com with LMTPS id EG6zN6jSkmBG5AAAgWs5BA (envelope-from ) for ; Wed, 05 May 2021 19:15:20 +0200 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 GGxcM6jSkmBLIQAAbx9fmQ (envelope-from ) for ; Wed, 05 May 2021 17:15:20 +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 05FB9CE75 for ; Wed, 5 May 2021 19:14:56 +0200 (CEST) Received: from localhost ([::1]:39380 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leL6s-00031d-N4 for larch@yhetil.org; Wed, 05 May 2021 13:14:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49722) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leKwW-0000b3-BH for emacs-orgmode@gnu.org; Wed, 05 May 2021 13:04:12 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:46680) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1leKwU-0003kv-Ba for emacs-orgmode@gnu.org; Wed, 05 May 2021 13:04:12 -0400 Received: by mail-wr1-x42a.google.com with SMTP id x5so2614151wrv.13 for ; Wed, 05 May 2021 10:04:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=XiroXcUgDN6EuavrJDawxBuk1WieWyqv4kGr2eGz6F8=; b=tYdYHJtEcwm+KOsCyw2gitaR9aYDPC/KeO4iTfUkwidaJyfXkj87Ok+tNE3mx6s2zO onqFGfmX6dBv90Z4AmmJAh+bO7kqjAxuNNZESE9dWD3v3JUrzIGIz55ZJYNl9jDNU9mX N4FRI1SpLNlb0AO071gWemFq7yC7z37diFNoLayvaK8noXO3Wnpz7qionrPmwmKK0TkA 41eZF3Q7zuA6O93Asb1LtCi0incLE8jUhZhbqYANbD1mKcHW/5jJRr4xLXTRkK53yE/o FSoCKbCV0R/418gzFeOD4rjPc+S+GJ37B5DsAd2ORDLPVJK8tMfrJQmSbdoOl7Z1Q04l swww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=XiroXcUgDN6EuavrJDawxBuk1WieWyqv4kGr2eGz6F8=; b=erCai6BQAGm3Nc8djiid5wOTRE+e6YR1WH/26rpT7tJmeOxqQ7DooRZRQ4WrsZVZd6 iPGYeANP/j+A6MUQcYpuqPziTwezjrJya1/2OcyFB64tqE7SRjTL2W0QM26mGfzMrXdD bAI/jSMcRp3Ll9xQo6Vk6dienA+58r4BTbS09rbc9xY22qJZK2zgKkUhK5X2HKwxfQ2h +GQT1FBObbkmh8+kUNdb/YiUVbNXgX/kLRnMekib0yrL0uWpiM8LdPXBmNUBdnu3+db8 THRtbjVxe6b1BQY0FhjZ/xkqouO+ZwZXXKvEh5zDRQh5+/DFL3MgFysPM7+y6tp7GCHy bAmg== X-Gm-Message-State: AOAM531/du8MTLgVE9svFC9u1Xz1DpkJ9gUF/Uo6zY7g+aUWFZFZmZSu fA0bJggYA2BtXsG9IBP8sOTaH8LATmlQIN6iFno= X-Google-Smtp-Source: ABdhPJxr4rR/svR+sx4htssHFHWiaA9+ZIl9msW5oG5o1JCchauUmggU6Wb7SuYOiv5WKWEYuE0sb/8ApVrjl/wx1CM= X-Received: by 2002:adf:fb07:: with SMTP id c7mr63677wrr.88.1620234248730; Wed, 05 May 2021 10:04:08 -0700 (PDT) MIME-Version: 1.0 References: <871ral7kq8.fsf@ucl.ac.uk> <87eeelrv6s.fsf@ucl.ac.uk> In-Reply-To: <87eeelrv6s.fsf@ucl.ac.uk> From: Tom Gillespie Date: Wed, 5 May 2021 10:03:56 -0700 Message-ID: Subject: Re: Multiple calc commands with orgbabel To: pietru@caramail.com Content-Type: multipart/mixed; boundary="000000000000d9874005c1982e33" Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=tgbugs@gmail.com; helo=mail-wr1-x42a.google.com 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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: Org Mode List Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1620234896; 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=XiroXcUgDN6EuavrJDawxBuk1WieWyqv4kGr2eGz6F8=; b=Ro5ce0DCqcUw1B6d5ZEefr5nsySGXs4diPx7rduvsOTaMauwhIhPj7LNamXU6J39zP3nuc uQoLkWnvC+jg6VHx2t/DEkdykAjAkj0UmLxWwUToMvJ1GoAvTzTsfchUeWfT6O1i+WidEa BwlbtoP4Lj39ypYISE8k7stCUVq6/QIiat20bqQuyoJXPEb94WotC6N9m71vpEZ6TD0dVQ WaNS/H7QehelGtIFax4tfS8CcML2L/D8ERoO3iV7yvQ2+Y6lb4avc1LY02pP4FUP9QxcpM itbWG6P23M34kD2UgmMKA0ndMOxF0j2kXG+dDxK0jLGXyFX9o3KR4J2uh76GrA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1620234896; a=rsa-sha256; cv=none; b=b7iy8yspw3GaphheFcfCP2VsJdVn+UCxoRln2SVkb/XdYMBJbsJSnQMlH17t4x4Q0dJxNu WRyhiP7VeQM1GGk8NyT9usz/wCfAgMH/gGONOJGsXCnwwpGNkfUVD8qo4D7+RAHRwIcAVu wbsjmmKCMs0sE4DBzvxO0KR2H++4PDu5VWWN1FRh/TOFM9slRQsG/UZlTdPtgbZ6G+vBTw HzV7SqrAYQstiabMKWUsn6eXuRYCzLABu6jV79vn4e2lS89JSISl2Qyo0GPXa+gCQwsi5g I7UmWXLfAYAHNiBDchb7Ct4BalvfQVvvUzPicMGFTYJO4ATCcPEbHchlOP2Z2A== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=tYdYHJtE; dmarc=pass (policy=none) header.from=gmail.com; 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-Migadu-Spam-Score: -2.07 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=tYdYHJtE; dmarc=pass (policy=none) header.from=gmail.com; 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-Migadu-Queue-Id: 05FB9CE75 X-Spam-Score: -2.07 X-Migadu-Scanner: scn0.migadu.com X-TUID: 0Raf41UU2/tE --000000000000d9874005c1982e33 Content-Type: text/plain; charset="UTF-8" Here is a quick and dirty implementation that more or less does what you want (I think). The if t would probably need to be replaced by a value that corresponded to an option that indicated that ob-calc should resolve all expressions on the stack. This isn't really an issue of return value, it is due to the fact that ob-calc makes stateful modifications to calc. If you want a stateless (idempotent?) ob-calc block you would need to do something like this as well, and then you would need an option to discard the additional values instead of retruning them as I do here. Best! Tom --000000000000d9874005c1982e33 Content-Type: text/x-patch; charset="US-ASCII"; name="ob-calc-multi-return.patch" Content-Disposition: attachment; filename="ob-calc-multi-return.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_kobpj7u40 ZGlmZiAtLWdpdCBhL2xpc3Avb2ItY2FsYy5lbCBiL2xpc3Avb2ItY2FsYy5lbAppbmRleCAzOWVi Y2UxMDAuLmUyMTAyZmVjYSAxMDA2NDQKLS0tIGEvbGlzcC9vYi1jYWxjLmVsCisrKyBiL2xpc3Av b2ItY2FsYy5lbApAQCAtNDgsNiArNDgsNyBAQAogICAiRXhlY3V0ZSBhIGJsb2NrIG9mIGNhbGMg Y29kZSB3aXRoIEJhYmVsLiIKICAgKHVubGVzcyAoZ2V0LWJ1ZmZlciAiKkNhbGN1bGF0b3IqIikK ICAgICAoc2F2ZS13aW5kb3ctZXhjdXJzaW9uIChjYWxjKSAoY2FsYy1xdWl0KSkpCisgIChsZXQg KCh1bnBvcHBlZCAwKSkKICAgKGxldCogKCh2YXJzIChvcmctYmFiZWwtLWdldC12YXJzIHBhcmFt cykpCiAJIChvcmctLXZhci1zeW1zIChtYXBjYXIgIydjYXIgdmFycykpCiAJICh2YXItbmFtZXMg KG1hcGNhciAjJ3N5bWJvbC1uYW1lIG9yZy0tdmFyLXN5bXMpKSkKQEAgLTU4LDEyICs1OSwxNCBA QAogICAgICB2YXJzKQogICAgIChtYXBjCiAgICAgIChsYW1iZGEg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LXRvcCAxKSkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgZG8gKGNhbGMt cG9wIDEpKSkpCisgICAgICAgICAgICAobWVzc2FnZSAiJVMiIG91dCkKKyAgICAgICAgICAgICht YXBjYXIgIydsaXN0IChyZXZlcnNlIG91dCkpKQorICAgICAgICAocHJvZzEKKyAgICAgICAgICAg IChjYWxjLWV2YWwgKGNhbGMtdG9wIDEpKQorICAgICAgICAgICAgKGNhbGMtcG9wIDEpKSkpKSkp CiAKIChkZWZ1biBvcmctYmFiZWwtY2FsYy1tYXliZS1yZXNvbHZlLXZhciAoZWwpCiAgIChpZiAo Y29uc3AgZWwpCg== --000000000000d9874005c1982e33--