From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:bcc0::]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id gAgaEkgPemAoZQEAgWs5BA (envelope-from ) for ; Sat, 17 Apr 2021 00:27:20 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id sLb2C0gPemCoIAAAbx9fmQ (envelope-from ) for ; Fri, 16 Apr 2021 22:27:20 +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 DF9D421ACD for ; Sat, 17 Apr 2021 00:27:18 +0200 (CEST) Received: from localhost ([::1]:56640 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lXWvm-0004uw-4E for larch@yhetil.org; Fri, 16 Apr 2021 18:27:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53826) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lXWcF-0001PH-Ip for emacs-orgmode@gnu.org; Fri, 16 Apr 2021 18:07:08 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:55349) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lXWcA-0002DG-Kx for emacs-orgmode@gnu.org; Fri, 16 Apr 2021 18:07:04 -0400 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 4C75610020E; Fri, 16 Apr 2021 18:07:01 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 1EB361000CF; Fri, 16 Apr 2021 18:06:59 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1618610819; bh=Apj8nyUEqZcoTVzZwq9Air3vghpgT4Hab24zqB9LLQ4=; h=From:To:Subject:References:Date:In-Reply-To:From; b=O9wwENL1n5oq/1/l47bnKT771NZQFocpey7HtMefnSboAWhKRLH3v+NzV43HTkwTx sKR1xaI0uKNF3cn6VlT1Vpu4slVNtDFpzPsxVkSQFZiVnrHBZMAOwKI4DbR/YSX1m7 hiHqECtwwAc0/Tp1GVTZunfKNL7NzYuMfCTsxAzPm3tl8cE8h9aWiiWoYI0ybFIw6q 5ev8qTnAwhRiMLTc034KQHKcx+trH0xDFqHnO61mlVCv0BLIan9WItnl5UMJy9Gn0v 3ciTQvzb7Kg/bXb1STZaR5EDAhC0mdcEGXGU2Rglo3lVcv6SLCinhZ2Ob8a67/nHi8 DIamnY+EzGgmw== Received: from alfajor (104-222-126-84.cpe.teksavvy.com [104.222.126.84]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id D2E9A12005B; Fri, 16 Apr 2021 18:06:58 -0400 (EDT) From: Stefan Monnier To: emacs-orgmode@gnu.org Subject: Re: Improving org-macro.el Message-ID: References: <87y2diffqi.fsf@nicolasgoaziou.fr> Date: Fri, 16 Apr 2021 18:06:58 -0400 In-Reply-To: <87y2diffqi.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Fri, 16 Apr 2021 16:47:49 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.017 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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: , 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=1618612039; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=S5JdBp0EYDvgn1zszszd4ckm6I//ZJ07XXnsJgklxec=; b=kf7gS4FAdha+NNsXBzD5e5i0oHY+iBZ20CsA12fU9Z2lGoIFY/lf4CdOjfzJokNzjy0nal J+PPhtU3gyeGxAb878IM9Ezm0qNsz+Z2M0+cQUbjQzVi/LF8yPkBWVvt4N2r0dhXqF9MwT ivN4K7hzBjhwpihJSw6dPzZf9CvjseMVmSfPeoPkUw6ugYYgupbmDTVofRNkHwklfAkv+p V9s+a2VbXB8ElHElPcRD4D/AOW/CYtX9yMlKPy1XFZVHszyXnJjUSJwbO6Mlylo606VJZD lY485zIwfXFidh3TGpfwKj1KqRYV7k/3X9Zr03rRL2B+k6p2zjsLFgCszwzFUQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1618612039; a=rsa-sha256; cv=none; b=MBdXCsilPmHmTrZApTG/5sXKwLVbNp4NAJBScAJYFEn9trZlAim/hnpypX9CVE7jawZF+w OCr947zN9SFavx5zsuTBY1jUXt5sihrGdsFCEWxDLdXLcUeNLwqTcm9qviJ/VQP5gvlhDa u2yQBYDj0FfWloY8wBhwaCrfRMyN8B0m/cZLLKgHp9smoogSG70BGQOZfjgQd1Q+3rqFFM hsmadr9xDO8BMdaNatQvF/7FetCR/ChgUPhSVclBaZ4br7sxu9dSx2M/VSqleIdaof+QA4 vUzfnhYzwXX206ZgPSTXkRcEo8LoaWArrwLAVJoPLSt500b9QTF8xLpq24TWdQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=iro.umontreal.ca header.s=mail header.b=O9wwENL1; 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.14 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=iro.umontreal.ca header.s=mail header.b=O9wwENL1; dmarc=pass (policy=none) header.from=iro.umontreal.ca; 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: DF9D421ACD X-Spam-Score: -2.14 X-Migadu-Scanner: scn0.migadu.com X-TUID: arwFolwYSDY2 > I mentioned it in the ORG-NEWS file, and applied your changes. We'll see > how it goes. I just saw that it burps in Emacs-26 because of a bug when functions are declared with 0 optional arguments like (&optional &rest x). So I suggest the patch below, Stefan diff --git a/lisp/org-macro.el b/lisp/org-macro.el index 0f1dfa2e48..ea4d12133b 100644 --- a/lisp/org-macro.el +++ b/lisp/org-macro.el @@ -91,10 +91,11 @@ directly, use instead: (setq i (match-end 0)) (setq max (max max (string-to-number (match-string 1 template))))) (let ((args '(&rest _))) - (while (> max 0) - (push (intern (format "$%d" max)) args) - (setq max (1- max))) - (cons '&optional args)))) + (if (< max 1) args ;Avoid `&optional &rest', refused by Emacs-26! + (while (> max 0) + (push (intern (format "$%d" max)) args) + (setq max (1- max))) + (cons '&optional args))))) (defun org-macro--set-templates (templates) "Set template for the macro NAME.