From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:306:2d92::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id 4NC6G9E1vGRB+QAASxT56A (envelope-from ) for ; Sat, 22 Jul 2023 22:02:25 +0200 Received: from aspmx1.migadu.com ([2001:41d0:306:2d92::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id oMWNG9E1vGSrMQEA9RJhRA (envelope-from ) for ; Sat, 22 Jul 2023 22:02:25 +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 0B3353F5A9 for ; Sat, 22 Jul 2023 22:02:25 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=runbox.com header.s=selector1 header.b="0n Vezkf"; 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"; dmarc=pass (policy=quarantine) header.from=runbox.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1690056145; 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=C7hyQn4Yrqa6x8EKiU6Z4D0JuWMetFqtBu2nGjMMiPc=; b=NvI/NiL5Y2/GVXC5Zw+vgB/YwuHCoIoIja6XX5MFfL0a2EpdGQgIwy9xH0zlepGhkHSrV+ 4/dbABviri8NlujtxXQhPe4Nuvm7wzs/CxnwMJOOfAjprRVJ2JkarlUbznpZY2GKyUCTI5 +TYASZcHEGwuMxOmdpat08TGXgWb2fCRYms6wNFeaGk5uwFJUQM+jA5Xkr1IsdhKnS+Hls ZQGxbrySvSNs3ehq+mc9yxqYJeQzakk9O/MVcsgDtxlxYc+3x280Xu2KpN7S6QRM0LZyVZ 0PB8nE/d1gdBtibtozusJjCsO+eri7dPjq1VoCWFzsw0x05jfcFPfX8uC538GQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1690056145; a=rsa-sha256; cv=none; b=ZeCMt7eV55GcH9+ofuddWscJSXXV/RHsYQ9LOIGuX/Fth0i1Hz2rKZG7LKRrnJI9DLhOGO zBzEQPH+trwSOTXDnniw6AsAFJ9Wk3nG/KSNPWGanF2bOF2Fm+x/25JZyBxRzmSuo1iKNg n0oTGCSYHEXt0fCoMx9FVCC5fQeMHXLchYEmX+RvznWNYQOHgm8Nf7yJobFtS1WlBPJkpZ /tD3jxB1mZ0KD0cGTX5h7xC3Ub7d+/trgqkkux3Q+w6zaKxCnBHxXzlpPNQ4xZ6zTUWRhs GESglUzZVZV4P84u1SoqsffSKWmCPlB2Pjpqh0ST68df3RDgZglsO+3YPVd5WA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=runbox.com header.s=selector1 header.b="0n Vezkf"; 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"; dmarc=pass (policy=quarantine) header.from=runbox.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qNIiV-0005ez-5r; Sat, 22 Jul 2023 15:56:39 -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 1qNIiS-0005d3-6T for emacs-orgmode@gnu.org; Sat, 22 Jul 2023 15:56:36 -0400 Received: from mailtransmit04.runbox.com ([2a0c:5a00:149::25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qNIiP-0005nw-R9 for emacs-orgmode@gnu.org; Sat, 22 Jul 2023 15:56:35 -0400 Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit04.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1qNIiJ-008VXY-1F; Sat, 22 Jul 2023 21:56:27 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Type:MIME-Version:Message-ID:In-reply-to:Date:Subject :Cc:To:From:References; bh=C7hyQn4Yrqa6x8EKiU6Z4D0JuWMetFqtBu2nGjMMiPc=; b=0n VezkfxDRJAgtKIzSSWZtiS7hxvbfeXZprmKdIrpMTJF1w4llfO1uF4B1Yt88bOu+U6Q6W8pqS0vEy WENXeLkWeHBO2gZ2E09zaC86J4lYiIETppiuQJQk9B1UhOyxE170kIbKtjULxYH2U2KbIX3ErY4b8 UIZDUyHyYCYkjSLqybnDa4Y8V0CnMuy5l3k2UEU8iy/6YHnMV3MoysL76nJdteVC2rrsCJygs6F0y yy+4Kl/bTm85j2y/N+ijmnsIndeu4Ph0R/I65HZogwh+JEDnYcWbx30rPY6F7OiOt3h3O4hMvcQNC Hp3KAKqJ6UCGQ1fZ69I8tk4Bww5YV9OA==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1qNIiG-00064O-H3; Sat, 22 Jul 2023 21:56:26 +0200 Received: by submission03.runbox with esmtpsa [Authenticated ID (946465)] (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) id 1qNIi4-0003sc-6K; Sat, 22 Jul 2023 21:56:12 +0200 References: <877cqwbpa2.fsf@runbox.com> User-agent: mu4e 1.10.4; emacs 29.0.92 From: Gavin Downard To: Max Nikulin Cc: emacs-orgmode@gnu.org Subject: Re: [PATCH] lisp/org-table.el: Allow named columns on lhs Date: Sat, 22 Jul 2023 11:21:59 -0700 In-reply-to: Message-ID: <87bkg3hga5.fsf@runbox.com> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2a0c:5a00:149::25; envelope-from=gavin.downard@runbox.com; helo=mailtransmit04.runbox.com 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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 X-Migadu-Scanner: mx2.migadu.com X-Migadu-Spam-Score: -10.77 X-Spam-Score: -10.77 X-Migadu-Queue-Id: 0B3353F5A9 X-TUID: pePOenDwVols Max Nikulin writes: > On 19/07/2023 09:36, Gavin Downard wrote: >> +++ b/lisp/org-table.el >> @@ -2253,8 +2253,7 @@ LOCATION is a buffer position, consider the formulas there." >> ((not (match-end 2)) m) >> ;; Is it a column reference? >> ((string-match-p "\\`\\$\\([0-9]+\\|[<>]+\\)\\'" m) m) >> - ;; Since named columns are not possible in >> - ;; LHS, assume this is a named field. >> + ;; This is either a named field or column. >> (t (match-string 2 string))))) >> (rhs (match-string 3 string))) >> (push (cons lhs rhs) eq-alist) > > Notice > "Double definition `%s=' in TBLFM line, please fix by hand" > > below. A bit more code is required to keep this sanity check for named columns. > Oh, good catch. Specifically, I think this should be caught inside of `org-table-recalculate', where it catches conflicting direct column references (eg "$1") and end-relative column references ("$<"). > let* ((rhs (org-table-formula-substitute-names > (org-table-formula-handle-first/last-rc (cdr eq)))) > (old-lhs (car eq)) > (lhs > (org-table-formula-handle-first/last-rc > (cond > ((string-match "\\`@-?I+" old-lhs) > (user-error "Can't assign to hline relative reference")) > ((string-match "\\`\\$[<>]" old-lhs) > (let ((new (org-table-formula-handle-first/last-rc > old-lhs))) > (when (assoc new eqlist) > (user-error "\"%s=\" formula tries to overwrite \ > existing formula for column %s" ^ right here > old-lhs > new)) > new)) > (t old-lhs))))) Also, this should probably be addressed in a different patch, but the above code doesn't catch two different end-relative column references that refer to the same column, such as "$<" and "$>>" in a two-column table. I have also modified the manual to reflect the addition of named columns; I'll send an updated patch after I add the check for double definitions. Max Nikulin writes: > > `if-let' is not available in Emacs-26 > Are you sure? It looks like `if-let' was introduced in Emacs 25.