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 ms0.migadu.com with LMTPS id eBtrGnEu+GAqygAAgWs5BA (envelope-from ) for ; Wed, 21 Jul 2021 16:25:53 +0200 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 WAEnFnEu+GClfwAA1q6Kng (envelope-from ) for ; Wed, 21 Jul 2021 14:25:53 +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 DC65B359D for ; Wed, 21 Jul 2021 16:25:51 +0200 (CEST) Received: from localhost ([::1]:43584 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m6DAR-0006Er-Mk for larch@yhetil.org; Wed, 21 Jul 2021 10:25:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46424) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m6D9z-0006Eg-Js for emacs-orgmode@gnu.org; Wed, 21 Jul 2021 10:25:19 -0400 Received: from smtp6-g21.free.fr ([212.27.42.6]:16806) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m6D9x-0003tj-OZ for emacs-orgmode@gnu.org; Wed, 21 Jul 2021 10:25:19 -0400 Received: from [IPv6:2a01:e35:39f3:4610:ac07:8be0:fb0a:ad17] (unknown [IPv6:2a01:e35:39f3:4610:ac07:8be0:fb0a:ad17]) by smtp6-g21.free.fr (Postfix) with ESMTPS id E939D78034E; Wed, 21 Jul 2021 16:25:13 +0200 (CEST) Subject: Re: [PATCH] bad table formula recorded in some cases To: Timothy References: <43910853-03cb-c226-f46d-4736d0e6cca6@free.fr> <8735s8rld9.fsf@gmail.com> From: tbanelwebmin Message-ID: Date: Wed, 21 Jul 2021 16:25:12 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <8735s8rld9.fsf@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Language: en-US Received-SPF: pass client-ip=212.27.42.6; envelope-from=tbanelwebmin@free.fr; helo=smtp6-g21.free.fr X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, NICE_REPLY_A=-0.117, RCVD_IN_DNSWL_NONE=-0.0001, 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.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: emacs-orgmode@gnu.org 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=1626877552; 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; bh=rjZE1LBUcbhJUVEw9WYalRchb3ybPYIsVcOBfuRxw7A=; b=blrjcMvX0ybaGUa90s+VrDhRdx9Krxe0dUSTGlstDCcsbhXhqn1Pia2BXJ70legaOjmOET fSveJAAiVgBA1MIOumCwGm5IXdOwlCqROeL1B1L9uhdI2ukwZ4seDu+FzPIDerISBYyDM4 hH+k/3ZtzQ5KmtreIaa8gaJ2sh/csPzbl7BUkvncJ61Aj6HcAALDokZOZ3CsmwP3cweWyr pI8UZJzkuvnyYj6dH+FqO5w9PMGF85kZif935J3V6Gsbq6oXw8QmbvuKxt4LUMPo8Az87E McmgxkEcBR/hCKuejrQ+jtGWjRJv2xQw7ZhWLt/lUobZ5RfjITiUa/iWvioTjw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1626877552; a=rsa-sha256; cv=none; b=qb55jI6Dxa43HyrSjaMgvv17LrnR3Niu3i5b/ecF4iDIcc5qdZ039Tn3CFCyIBU2GOt3Rs y0p17kJ3faLg19QRikwhBNgy4I4E5KKuZvCeI9WEsi2cQCLLA54ZN4eNvCb67c1QUx7Eeb A59Y2ItoAcdm4nnDBTUnEvGrpABq1Bbg4upzk4dEBQXj+zQwrx5HH7yW+ozyUbS9GhKXdi rAouY6w4JWtn4i0RO9IZoVd5TmdR/kRaCZPKuan8NCaMqNAM/p9s7FFHvkqZ95+12Ej8Dr 7wgK31x2l0VJCobq0OaLWAq8nw33IV9bwF3zQiGGMeXte2YHFpVGZ+vewtYVdQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=free.fr (policy=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-Migadu-Spam-Score: -0.81 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=free.fr (policy=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-Migadu-Queue-Id: DC65B359D X-Spam-Score: -0.81 X-Migadu-Scanner: scn0.migadu.com X-TUID: ipPYYit1UJbK Hi Timothy I don't know the intention. But the answer may lie in the comment 4 lines above:    ;; Don't overwrite TBLFM, we might use text properties to    ;; store stuff. In this case, the intention would be to keep the original "#+TBLFM:" instead of inserting a fresh new one. But we are in the else branch of (if (looking-at ...)), which means there was no "#+TBLFM:". And no text properties to save. Therefore we may safely remove this (match-string 2). Thanks Timothy for taking this into account so carefully! Best Thierry Le 21/07/2021 à 12:50, Timothy a écrit : > Hi Thierry, > > Thanks for this! Looking at the change you suggest, do you know why the > (match-string 2) bit might have been added in the first place? I'm just > wondering if there might be some edge-case adversely affected by this --- > hence trading one bug for another :P > > -- > Timothy > > tbanelwebmin writes: > >> Small bug, small fix. >> >> Suppose we have a table embedded in a begin-end block. >> >> #+begin: aaa :param value >> | a | b | >> | a | b | >> #+end: >> >> Suppose we want to add a formula, with C-c = >> We end up with an incorrect result: >> >> #+begin: aaa :param value >> | a | 33 | >> | a | b | >> :param value $2=33 >> #+end: >> >> The fix: in org-table.el, line 2177, change >> (insert (or (match-string 2) "#+TBLFM:"))) >> to >> (insert "#+TBLFM:")) >> >> Then we get the correct result: >> >> #+begin: aaa :param value >> | a | 33 | >> | a | b | >> #+TBLFM: $2=33 >> #+end: >> >> Why? Because (match-string 2) is supposed to refer to the (looking-at) >> instruction 7 lines above. But (match-string 2) is in the else branch, >> which means that (looking-at) failed. Therefore (match-string 2) returns >> garbage. >> >> Thanks to Uwe Brauer for pointing to this bug.