emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Improving org-macro.el


From: Stefan Monnier
Subject: Re: Improving org-macro.el
Date: Fri, 16 Apr 2021 18:06:58 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> 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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]