From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id yG3hBsejeWBpPwAAgWs5BA (envelope-from ) for ; Fri, 16 Apr 2021 16:48:39 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id WPufAsejeWAfIQAAB5/wlQ (envelope-from ) for ; Fri, 16 Apr 2021 14:48:39 +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 8297C1A1E1 for ; Fri, 16 Apr 2021 16:48:38 +0200 (CEST) Received: from localhost ([::1]:39418 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lXPls-00029I-Ke for larch@yhetil.org; Fri, 16 Apr 2021 10:48:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50830) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lXPlI-000299-FJ for emacs-orgmode@gnu.org; Fri, 16 Apr 2021 10:48:00 -0400 Received: from relay9-d.mail.gandi.net ([217.70.183.199]:32937) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lXPlD-00039o-6e for emacs-orgmode@gnu.org; Fri, 16 Apr 2021 10:48:00 -0400 X-Originating-IP: 185.131.40.67 Received: from localhost (40-67.ipv4.commingeshautdebit.fr [185.131.40.67]) (Authenticated sender: admin@nicolasgoaziou.fr) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 63514FF80E; Fri, 16 Apr 2021 14:47:49 +0000 (UTC) From: Nicolas Goaziou To: Stefan Monnier Subject: Re: Improving org-macro.el References: Mail-Followup-To: Stefan Monnier , emacs-orgmode@gnu.org Date: Fri, 16 Apr 2021 16:47:49 +0200 In-Reply-To: (Stefan Monnier's message of "Sun, 11 Apr 2021 13:17:54 -0400") Message-ID: <87y2diffqi.fsf@nicolasgoaziou.fr> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=217.70.183.199; envelope-from=mail@nicolasgoaziou.fr; helo=relay9-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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=1618584518; 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; bh=TQ2nofBUpbkagdDv95gejYoQ0C5K3PHUrLJHgKKBlQo=; b=Ef6yA/seVblPp59pmBW55nSZ64FMDjGBzU9BM7YwRpTJ49VBsIhBE5ujAOYmoFuvMHEjxQ xs9wAu5cPkglpNRcUNP7B2k99i28lHoPMkW1ffDicrocUOdV1uigLWrLbrlmilmQGs95zg Bfn1KOhVme9408B9EKR4jLT1yxGvtt3McfnEbtCwy3hl3w43XXg8r6+ecWEONqYdyFx6b7 TLipQ0xx9hAW8sQgoRe+f0FQgnlfniaGH1A+R8yLAJP5OE+kuujS8wkuQeqLsQ5gY6W/qh fxY9Sk07uBePZur4Y2jlr06Gi1XIveoBX38gYlw6Qxck06dEI1jmb8l7vNswMQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1618584518; a=rsa-sha256; cv=none; b=nIbmRrAyzaZXvl6hsBgzdI/CoVe+nl7R6VdLJOh46bnu0Tq/ebRjLlrZyQGCsdl8o4FNYa QouOiArgZwtsgBh/svR2dfEwHweOx/y2GWoeR5IhwvYGX/vAP16Gq+eGl0UliCYsb29aKD v/BUgZM5DCNiDl7AlUU2KL7uPvN8YRE/ADImRiZkNO/SFgEDrHFsBljd2OdD5z3zKkxGdD qHcJJk2YmKHb9Ggcj/eDrrDlpwSIMrKgeH8dXedDOUrNonoCJkZKzBCtY6OW/0EF7Rohd9 tOHhy0HUgBPvYV4xpT0W7EBGkCaVfopy4aLxkPCu/vuAeyVlDKs8ZVUP6sfOgA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=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: -2.44 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=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: 8297C1A1E1 X-Spam-Score: -2.44 X-Migadu-Scanner: scn0.migadu.com X-TUID: I4t178vrO38b Hello, Stefan Monnier writes: > In any case, the code struck me as quite inefficient since it > reparses the macro definition every time the macro is called. Indeed. > I came up with the tentative patch below. Thank you. > It seems to work on Org's own manual, but other than that I haven't gone > out of my way to test it. There were a few problems reported by the test suite that I tried to address. I also updated `org-lint', which didn't handle macro definitions as functions. > - It also changes the behavior when $N appears elsewhere than an > "expression context". E.g.: > > #+macro: (eval (let (($1 foo)) (bar))) This is not a valid macro definition anyway since placeholders are strings. > #+macro: (eval (fun-with "code $1")) I don't think this was valid previously either, for the same reason. > I don't think it requires changes to the manual because the semantics > described in the manual is sufficiently incomplete that both the old and > the new semantics satisfy it. One noticeable effect is that empty or missing placeholders in macro call are now nil, instead of the empty string. This broke our internal macros (e.g., {{{n}}} and {{{property}}}) so I updated them. I mentioned it in the ORG-NEWS file, and applied your changes. We'll see how it goes. Regards, -- Nicolas Goaziou