From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id INIXNyALcmRlUwAASxT56A (envelope-from ) for ; Sat, 27 May 2023 15:52:33 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id mBw4NiALcmSY9wAAG6o9tA (envelope-from ) for ; Sat, 27 May 2023 15:52:32 +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 71AB81D180 for ; Sat, 27 May 2023 15:52:32 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2uKT-0004LJ-4x; Sat, 27 May 2023 09:51:33 -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 1q2uKQ-0004L2-KO for emacs-orgmode@gnu.org; Sat, 27 May 2023 09:51:30 -0400 Received: from netyu.xyz ([152.44.41.246] helo=mail.netyu.xyz) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2uKO-0006OX-Re for emacs-orgmode@gnu.org; Sat, 27 May 2023 09:51:30 -0400 Received: from fw.net.yu.netyu.xyz ( [222.248.4.98]) by netyu.xyz (OpenSMTPD) with ESMTPSA id a1940041 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sat, 27 May 2023 13:51:26 +0000 (UTC) References: User-agent: mu4e 1.9.22; emacs 30.0.50 To: Sergei Kosyrev Cc: emacs-orgmode@gnu.org Subject: Re: [PATCH] org-id: implement arbitrary cross-file references In-reply-to: Date: Sat, 27 May 2023 21:51:11 +0800 Message-ID: MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=152.44.41.246; envelope-from=ruijie@netyu.xyz; helo=mail.netyu.xyz X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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: , Reply-to: Ruijie Yu From: Ruijie Yu via "General discussions about Org-mode." Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1685195552; a=rsa-sha256; cv=none; b=I/3jEZAatRMpOCqEyUNaIbg8oZUzxifeOfCGYla3YPznhiYOfzCR8OmEf11tCGs+5Jp8Ag 7aQIwNul03dd3pTnm4SAHwWfnrmQ3wb7Y7SNucpJfKCQqW+Z/yY+VuNWPRmuKIQqc3L8ZU Ph9SBEQG1ylYZwfjRFbSiRErxdlLddLnfhIOTzoIMWLzLW4V6a0v+dq3RHF37u8nry5FXq cFTSi++MJ/8eRsHfNpYLAUfAbUEIbYx7tZ172JoJjx4/bzRmtasPE1OIt7DIiQgZgIJsyy GxqhjWOhW3PFETOpCm+QGjOtBv1y79kv+3TDqKictJirikMg+P5oDDDT7NDPYw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; 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=1685195552; h=from:from:sender:sender:reply-to: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; bh=LcNMfRtdrA4u+lgeg6gd3b+qmECSIRSE7zgID+G/57Y=; b=jpdoHXvV2YbQcWWhW+v1Lg19f5YdLEeD7lnZr1/S2pKNjEyTG6Mz2UPdIioljghiO9ipbk KBqb/a5YE+UfHb2fq3Je5n9Hoh4OiIIiUKxsbXlT64I2Q/ftBOcJDwsLUcT6h5BY5r39kF qag2NEDFnOHFIP/tRGuz3Jftw6Z1Rgl73FgLl8ScWiujuwG99774i9bQZ1CzZQSEkOjI82 KaRbw5OLurlqUJ7hPc+wo++MoewyjJpVM7QklDn3xITZ1cYAJHX/fK5xSPQ9t4SGwgTJpD u0LDbwf5/oq0x1HjL1Mwx4H9HijAJKF0YVWtLFbetM0a8ixSIibDVWRcP0wwTg== X-Migadu-Spam-Score: -0.91 X-Spam-Score: -0.91 X-Migadu-Queue-Id: 71AB81D180 X-Migadu-Scanner: scn0.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; 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-TUID: wTGCKRyr5tkG Thanks for the patch. Some in-line comments below. Sergei Kosyrev writes: > From f712fa57a90c68d3d9066b10f49822ea0337b923 Mon Sep 17 00:00:00 2001 > From: Kosyrev Serge > Date: Thu, 25 May 2023 19:30:01 +0800 > Subject: [PATCH] org-id: implement arbitrary cross-file references > > * Table formulae can now refer to data from tables in other files. > > TINYCHANGE First of all, I believe this is not within the scope of TINYCHANGE, because as you see below, you added 58 lines and removed 11. In this case, the very first thing required before Org maintainers can consider its inclusion is that you sign the FSF copyright assignment. If you need more details, Ihor or Bastien could probably elaborate and/or send you the form. > --- > etc/ORG-NEWS | 10 +++++++++ > lisp/org-id.el | 57 ++++++++++++++++++++++++++++++++++++++--------- > lisp/org-table.el | 2 +- > 3 files changed, 58 insertions(+), 11 deletions(-) > > diff --git a/lisp/org-id.el b/lisp/org-id.el > index aa9610f16..2fcecbb50 100644 > --- a/lisp/org-id.el > +++ b/lisp/org-id.el > @@ -337,6 +337,40 @@ Move the cursor to that entry in that buffer." > (move-marker m nil) > (org-fold-show-context))) > > +(defun org-id-parse-remote-table-ref (refstr) > + (let ((match (string-match "^file:\\([^:]+\\)\\(\\|:.+\\)$" refstr))) > + (unless (null match) > + (let* ((m1 (match-string 1 refstr)) > + (m2 (match-string 2 refstr)) > + (filename (cl-remove-if (lambda (c) (member c '(40 41))) > + (org-table-formula-substitute-names m1))) > + (table-name (org-table-formula-substitute-names m2))) > + (list filename table-name))))) First, do we need to wrap it with `save-match-data'? In my personal code I almost always do, but I need a second opinion on that. Second, instead of the let-unless-null combination, you can just do this instead: (when-let ((match ...)) (let* (...) ...)) And, if those values can't ever be nil, you could even combine the entirety of the `let*' form into the `when-let' form (and turn it into a `when-let*' form). No comments on the rest, so I didn't quote them from my response to save bandwidth. -- Best, RY