From: Ihor Radchenko <yantar92@posteo.net>
To: "João Távora" <joaotavora@gmail.com>
Cc: "T.V Raman" <raman@google.com>, emacs-devel <emacs-devel@gnu.org>
Subject: &allow-other-keys + &rest body in cl-defmacro (was: Permanently fix org versioning breakage during builds?)
Date: Mon, 25 Dec 2023 11:26:29 +0000 [thread overview]
Message-ID: <87a5pya5ga.fsf@localhost> (raw)
In-Reply-To: <CALDnm53p7nXdnbA2PuH-VHL7EeGQUXYy3x_87hp3oj2pkyWS9Q@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 501 bytes --]
João Távora <joaotavora@gmail.com> writes:
>> Hmm... It actually looks like a problem with `cl-defmacro' rather than
>> with macro definition itself.
>
> No, Common Lisp's DEFMACRO works exactly like this. You need to understand
> how &rest works with &key and &allow-other-keys. It _also_ keeps the keys.
> That's just how it works.
Now I feel a bit like RMS when he complained about CL-lib introducing
alien concepts to Elisp :)
What about non-breaking change like the attached?
[-- Attachment #2: 0001-org-element-with-buffer-copy-org-export-with-buffer-.patch --]
[-- Type: text/x-patch, Size: 2253 bytes --]
From 3ebf5565196e2dfa3548564cf5a266e51e35cd9d Mon Sep 17 00:00:00 2001
Message-ID: <3ebf5565196e2dfa3548564cf5a266e51e35cd9d.1703503500.git.yantar92@posteo.net>
From: Ihor Radchenko <yantar92@posteo.net>
Date: Mon, 25 Dec 2023 12:20:10 +0100
Subject: [PATCH] org-element-with-buffer-copy, org-export-with-buffer-copy:
Fix expansion
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* lisp/org-element.el (org-element-with-buffer-copy):
* lisp/ox.el (org-export-with-buffer-copy): Make sure that keyword
arguments in the macro are not duplicated into BODY, which happens for
&rest body + &allow-other-keys in `cl-defmacro'.
Reported-by: João Távora <joaotavora@gmail.com>
Link: https://yhetil.org/emacs-devel/CALDnm53p7nXdnbA2PuH-VHL7EeGQUXYy3x_87hp3oj2pkyWS9Q@mail.gmail.com/
---
lisp/org-element.el | 3 +++
lisp/ox.el | 3 +++
2 files changed, 6 insertions(+)
diff --git a/lisp/org-element.el b/lisp/org-element.el
index 0924c56fe..842cf8857 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -669,6 +669,9 @@ (cl-defmacro org-element-with-buffer-copy ( &rest body
copy. TO-BUFFER, DROP-VISIBILITY, DROP-NARROWING, DROP-CONTENTS, and
DROP-LOCALS are passed as arguments to `org-element-copy-buffer'."
(declare (debug t))
+ ;; Drop keyword arguments from BODY.
+ (while (memq (car body) '(:to-buffer :drop-visibility :drop-narrowing :drop-contents :drop-locals))
+ (pop body) (pop body))
(org-with-gensyms (buf-copy)
`(let ((,buf-copy (org-element-copy-buffer
:to-buffer ,to-buffer
diff --git a/lisp/ox.el b/lisp/ox.el
index b661b59c3..a54b3d809 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -2599,6 +2599,9 @@ (cl-defmacro org-export-with-buffer-copy ( &rest body
In addition, buffer-local variables are set according to #+BIND:
keywords."
(declare (debug t))
+ ;; Drop keyword arguments from BODY.
+ (while (memq (car body) '(:to-buffer :drop-visibility :drop-narrowing :drop-contents :drop-locals))
+ (pop body) (pop body))
(org-with-gensyms (bind-variables)
`(let ((,bind-variables (org-export--list-bound-variables)))
(org-element-with-buffer-copy
--
2.42.0
[-- Attachment #3: Type: text/plain, Size: 224 bytes --]
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
next prev parent reply other threads:[~2023-12-25 11:26 UTC|newest]
Thread overview: 82+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-22 17:27 Permanently fix org versioning breakage during builds? T.V Raman
2023-12-23 17:58 ` João Távora
2023-12-23 18:06 ` Ihor Radchenko
2023-12-23 18:44 ` João Távora
2023-12-24 11:50 ` Ihor Radchenko
2023-12-24 14:13 ` João Távora
2023-12-24 14:48 ` Ihor Radchenko
2023-12-24 16:32 ` João Távora
2023-12-24 16:36 ` T.V Raman
2023-12-24 17:00 ` Eli Zaretskii
2023-12-24 17:04 ` João Távora
2023-12-24 17:16 ` Ihor Radchenko
2023-12-24 17:48 ` João Távora
2023-12-24 18:13 ` T.V Raman
2023-12-24 18:52 ` Eli Zaretskii
2023-12-24 18:13 ` Ihor Radchenko
2023-12-24 23:11 ` João Távora
2023-12-25 11:26 ` Ihor Radchenko [this message]
2023-12-25 12:09 ` &allow-other-keys + &rest body in cl-defmacro (was: Permanently fix org versioning breakage during builds?) João Távora
2023-12-25 12:21 ` Ihor Radchenko
2023-12-25 19:00 ` Ihor Radchenko
2023-12-25 13:58 ` Permanently fix org versioning breakage during builds? Ihor Radchenko
2023-12-25 17:42 ` João Távora
2023-12-25 18:24 ` Ihor Radchenko
2023-12-24 17:05 ` Ihor Radchenko
2023-12-24 17:12 ` João Távora
2023-12-24 17:18 ` Ihor Radchenko
2023-12-24 17:24 ` Ihor Radchenko
2023-12-24 17:54 ` João Távora
2023-12-24 18:10 ` Ihor Radchenko
2023-12-24 18:16 ` João Távora
2023-12-24 18:23 ` Ihor Radchenko
2023-12-24 18:47 ` Eli Zaretskii
2023-12-24 18:56 ` Ihor Radchenko
2023-12-24 18:57 ` Eli Zaretskii
2023-12-24 18:42 ` Eli Zaretskii
2023-12-24 14:56 ` Eli Zaretskii
2023-12-24 23:14 ` João Távora
2023-12-24 2:43 ` T.V Raman
2023-12-24 6:51 ` Eli Zaretskii
2023-12-24 16:29 ` T.V Raman
2023-12-24 16:56 ` Eli Zaretskii
2023-12-24 11:00 ` Ihor Radchenko
2023-12-24 12:32 ` Po Lu
2023-12-24 12:50 ` Ihor Radchenko
2023-12-24 12:57 ` Po Lu
2023-12-24 14:11 ` Stefan Kangas
2023-12-24 14:51 ` Ihor Radchenko
2023-12-24 14:58 ` Eli Zaretskii
2023-12-24 16:59 ` Ihor Radchenko
2023-12-24 17:26 ` T.V Raman
2023-12-24 17:44 ` Ihor Radchenko
2023-12-24 18:01 ` João Távora
2023-12-24 18:12 ` Ihor Radchenko
2023-12-24 18:16 ` T.V Raman
2023-12-24 18:25 ` Ihor Radchenko
2023-12-24 18:53 ` Eli Zaretskii
2023-12-24 18:48 ` Eli Zaretskii
2023-12-24 19:23 ` Stefan Kangas
2023-12-24 18:45 ` Eli Zaretskii
2023-12-24 18:11 ` T.V Raman
2023-12-24 18:17 ` Ihor Radchenko
2023-12-24 19:31 ` T.V Raman
2023-12-24 18:51 ` Eli Zaretskii
2023-12-24 17:56 ` João Távora
2023-12-24 18:36 ` Eli Zaretskii
2023-12-24 18:32 ` Eli Zaretskii
2023-12-24 18:50 ` Ihor Radchenko
2023-12-24 18:55 ` Eli Zaretskii
2023-12-24 19:05 ` Ihor Radchenko
2023-12-24 23:23 ` João Távora
2023-12-24 19:16 ` Stefan Kangas
2023-12-24 19:24 ` Ihor Radchenko
2023-12-24 16:32 ` T.V Raman
2023-12-24 16:39 ` João Távora
2023-12-24 16:58 ` Eli Zaretskii
2023-12-24 17:05 ` João Távora
2023-12-24 18:34 ` Eli Zaretskii
2023-12-25 18:59 ` Ihor Radchenko
2023-12-25 19:27 ` Eli Zaretskii
2023-12-25 20:02 ` Ihor Radchenko
2023-12-25 20:03 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a5pya5ga.fsf@localhost \
--to=yantar92@posteo.net \
--cc=emacs-devel@gnu.org \
--cc=joaotavora@gmail.com \
--cc=raman@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.