From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id uOU5KD2NRWQkWQEASxT56A (envelope-from ) for ; Sun, 23 Apr 2023 21:55:41 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id MMOAJz2NRWTBxAAAG6o9tA (envelope-from ) for ; Sun, 23 Apr 2023 21:55:41 +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 6F2BB8F32 for ; Sun, 23 Apr 2023 21:55:41 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqfnF-0000GX-HJ; Sun, 23 Apr 2023 15:54:41 -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 1pqfnC-0000GF-T3 for emacs-orgmode@gnu.org; Sun, 23 Apr 2023 15:54:38 -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 1pqfnA-00048S-QS for emacs-orgmode@gnu.org; Sun, 23 Apr 2023 15:54:38 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 8009D2400A7 for ; Sun, 23 Apr 2023 21:54:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1682279674; bh=pZTf88PtFDiNLq8PkP8Fm+V2bvSicE0S9quLBVn9FNo=; h=From:To:Cc:Subject:Date:From; b=rMiJdogWD2OxUUWLxyX6fvyIkKETrMMCmz/ovqfpd1L6JkUrz8Gr/vIHBSIuoD9D9 ka0PYAm0x4ZjsuaxTrXPiN6eKrMlRwrDVS2nhkp3UM8zAiqkwySCMsHYmtYJGDIpHO VS86Q7wKwirddxJBqFB38srXAOiXSlYwbx2vkOrqCnW46wWBwD+KgyZEiKHaulb0Q5 x5aZf6m3KsoyHNjn+B3m3TjDY7y3kzpVPkcB8b50Zr7BhHptPowVl7ewbHuvtBsebO 3kourME/mCF3MOYxdyFeA77lvJes0KYypccsiUzS7d815y2nOcr3If8ANbKtilj3fV 7xPn8r6M/SU+Q== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Q4Jr974S9z6twp; Sun, 23 Apr 2023 21:54:33 +0200 (CEST) From: Ihor Radchenko To: Jeff Trull Cc: emacs-orgmode@gnu.org Subject: Re: [BUG] text cell contents have extra parentheses when used in formulas [9.6.4 ( @ /home/jet/.config/emacs/elpa/org-9.6.4/)] In-Reply-To: <87leiiub1o.fsf@localhost> References: <87leiiub1o.fsf@localhost> Date: Sun, 23 Apr 2023 19:57:25 +0000 Message-ID: <875y9mwevu.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 ARC-Seal: i=1; s=key1; d=yhetil.org; t=1682279741; a=rsa-sha256; cv=none; b=ByIGq+VOWUH52gkaV0E1zR7UPviziJWIR8lORYmkT0Z5azbxu5ZDQ1IgCnRlYmpqCVDtpM LVE5by7gsk9P6mS50xtockITV82izzEf9X368dvafhFAe13Nh4tBTsQruCACpGAFW+X6JJ 3mHFQmV/4CI6j6F7UGhol2OXXZHhG4Ht5TgmR+exeJUKaR28BzNre/8oWz3XS4bVIIMe6g CJobR5eeFqGUDv+SIGm9qDm/ExqnmuDCVUijFWuXOw953V74RAhxbPbvbLBH0riMoz/tQw svOnDDoDli9lamgCVfNistuX4D6+4yTrsXy4GIMHlvk0/u/jmexHeFy/oTuQuA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=rMiJdogW; 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=1682279741; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=0W6zoXtdFcxVipqj8hSdNTnIjBEO3TlfF/K1gjaAb0s=; b=nJhVBn0l1I4DoqGowZ+6b27q4RyhY1c0SD8sFn8WgFfPkLJw4RjoUH09FpvKPR73SeXOsW 4uM68xn3WJ+miwXfccYh3tXRh/ILvbigfsX2gGhQpbLZrVZ1U3EtoCfPGQuG+13wnOfBgT VCuuLS/tOsDRuKAPpI4vKukwx/JXGrH0K1vGBX8ZiuN5UvrA5sRdHJTpGHMaf8jblTJaEe aerp1Ev9EXd33bKZ53AbzbyGGEKGtAEnZgtmUZKG2NaLXsS67rGrupeKLwKBR6pS+suDgd qvb6tMtuZOh1dZtUQoIAOiDZ3fbZwwZL4quz++Kh01SwvAn73A+vVPSB6P057w== X-Migadu-Scanner: scn1.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=rMiJdogW; 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" X-Migadu-Spam-Score: -6.20 X-Spam-Score: -6.20 X-Migadu-Queue-Id: 6F2BB8F32 X-TUID: 3z7M/LdHAmCV Ihor Radchenko writes: >> #+TITLE: text formula repro >> >> | Key | Value | >> |-----+--------------| >> | A | [40, 65, 41] | >> | B | [40, 66, 41] | >> #+TBLFM: $2=3D"$1" >> >> Here you can see that the contents of the Key column were wrapped in >> parentheses (ASCII 40 and 41) when turned into strings. > > If you turn formula debugger on (M-x org-table-toggle-formula-debugger), > you will see the following (I also added extra explanations): > ... > $1-> "(A)" ;; after handling column references; the (...) is added > ;; because of Calc syntax to ensure that values inside > ;; cell are grouped. There is no notion of strings in GNU > ;; Calc (AFAIK). So, (...) grouping always represents > ;; algebraic Calc expression. > Result: [40, 65, 41] ;; (calc-eval "\"(A)\"") After looking closer, the code wrapping cell value into (...) is actually not necessarily correct. The parenthesis wrapping has been introduced in e7e5e25100246e5eab3a36034ac2de578dabd02f Author: Carsten Dominik Fix bug with algebraic evaluation in tables. There was a problem that complex fields need a pair of parentheses around them. For example, if one field is "a a" and another field is "a+b", multiplication of the two gave "a^3+b" instead of "a^3+a^2 b". Now variable replacement puts extra parenthesis around values. ---- However, in a way, unconditional wrapping of cell value in parentheses is against how Org table formulas intuitively work - references are replaced by appropriate cell values. Wrapping a cell value in (...) only makes sense as long as algebraic operations are considered. However, when cell value is intentionally treated as string (explicit vector of character codes in GNU Calc conventions), extra (...) will introduce the observed 40 ... 41 into the vector. It might be tricky to remove the existing behaviour though - removing the parenthesis will likely break the existing use cases with genuine algebraic computations. We might, however, use "L" flag, described in "3.5.2 Formula syntax for Calc": =E2=80=98L=E2=80=99 Literal, for Lisp formulas only. See the next section. Now, it is only used for Lisp formulas, but we can make use of it in Calc formulas as well, preventing this (...) wrap. Or maybe others have better ideas. --=20 Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at