From: "Mattias Engdegård" <mattias.engdegard@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Alan Mackenzie <acm@muc.de>,
65017@debbugs.gnu.org,
Eric Marsden <eric.marsden@risk-engineering.org>
Subject: bug#65017: 29.1; Byte compiler interaction with cl-lib function objects, removes symbol-function
Date: Sat, 12 Aug 2023 12:40:03 +0200 [thread overview]
Message-ID: <B102D1A8-8F8A-40D2-A3A6-08024CCE9688@gmail.com> (raw)
In-Reply-To: <jwv350pugvs.fsf-monnier+emacs@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 470 bytes --]
12 aug. 2023 kl. 05.28 skrev Stefan Monnier <monnier@iro.umontreal.ca>:
> there's a standard solution from Common Lisp to get rid of this
> hack: implement the `&whole` macro argument.
If we can live without the special `&whole` syntax then it seems rather straightforward (patch), although I'd rather not add the extra specbind until needed for a concrete purpose.
One such purpose, apart from removing the hack, would be better diagnostics in some cases.
[-- Attachment #2: macroexp-whole.diff --]
[-- Type: application/octet-stream, Size: 1681 bytes --]
diff --git a/lisp/emacs-lisp/macroexp.el b/lisp/emacs-lisp/macroexp.el
index 6d5cf8723f9..18eaf005cb4 100644
--- a/lisp/emacs-lisp/macroexp.el
+++ b/lisp/emacs-lisp/macroexp.el
@@ -199,6 +199,15 @@ macroexp--obsolete-warning
(instead (format-message "; use `%s' instead." instead))
(t ".")))))
+(defvar macroexp--whole-form
+ ;; The current form being macroexpanded.
+ )
+
+(defun macroexp-whole-form ()
+ "The current form being macro-expanded.
+Can only be called during macro-expansion (ie, inside a macro)."
+ macroexp--whole-form)
+
(defun macroexpand-1 (form &optional environment)
"Perform (at most) one step of macroexpansion."
(cond
@@ -219,7 +228,8 @@ macroexpand-1
((not (consp def)) form)
(t
(if (eq 'macro (car def))
- (apply (cdr def) (cdr form))
+ (let ((macroexp--whole-form form))
+ (apply (cdr def) (cdr form)))
form))))))))
(t form)))
diff --git a/src/eval.c b/src/eval.c
index 9e54d489a3b..0d32b63bf1d 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1161,7 +1161,9 @@ DEFUN ("macroexpand", Fmacroexpand, Smacroexpand, 1, 2, 0,
break;
}
{
- Lisp_Object newform = apply1 (expander, XCDR (form));
+ specpdl_ref pdl = SPECPDL_INDEX ();
+ specbind (Qmacroexp__whole_form, form);
+ Lisp_Object newform = unbind_to (pdl, apply1 (expander, XCDR (form)));
if (EQ (form, newform))
break;
else
@@ -4462,4 +4464,5 @@ syms_of_eval (void)
defsubr (&Sspecial_variable_p);
DEFSYM (Qfunctionp, "functionp");
defsubr (&Sfunctionp);
+ DEFSYM (Qmacroexp__whole_form, "macroexp--whole-form");
}
next prev parent reply other threads:[~2023-08-12 10:40 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-02 10:28 bug#65017: 29.1; Byte compiler interaction with cl-lib function objects, removes symbol-function Eric Marsden
2023-08-03 9:39 ` Mattias Engdegård
2023-08-03 14:43 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-03 15:37 ` Mattias Engdegård
2023-08-03 16:36 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-03 16:53 ` Mattias Engdegård
2023-08-03 17:30 ` Mattias Engdegård
2023-08-03 16:43 ` Alan Mackenzie
2023-08-03 17:30 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-03 18:22 ` Alan Mackenzie
2023-08-03 21:00 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-03 21:10 ` Alan Mackenzie
2023-08-03 21:46 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-04 9:55 ` Alan Mackenzie
2023-08-05 22:45 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-04 10:14 ` Mattias Engdegård
2023-08-04 11:11 ` Alan Mackenzie
2023-08-04 13:41 ` Mattias Engdegård
2023-08-05 22:40 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-06 10:47 ` Mattias Engdegård
2023-08-08 2:33 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-04 5:35 ` Eli Zaretskii
2023-08-04 14:16 ` Alan Mackenzie
2023-08-05 20:22 ` Alan Mackenzie
2023-08-06 4:49 ` Eli Zaretskii
2023-08-04 13:22 ` Alan Mackenzie
2023-08-04 14:04 ` Eli Zaretskii
2023-08-04 14:49 ` Alan Mackenzie
2023-08-04 15:22 ` Eli Zaretskii
2023-08-04 16:43 ` Alan Mackenzie
2023-08-04 17:54 ` Eli Zaretskii
2023-08-05 22:58 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-05 22:53 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-06 11:59 ` Alan Mackenzie
2023-08-08 2:44 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-08 16:56 ` Alan Mackenzie
2023-08-10 3:41 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-10 14:50 ` Alan Mackenzie
2023-08-12 3:28 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-12 9:59 ` Mattias Engdegård
2023-08-12 18:21 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-12 10:40 ` Mattias Engdegård [this message]
2023-08-12 16:46 ` Alan Mackenzie
2023-08-12 18:28 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-13 10:10 ` Alan Mackenzie
2023-08-13 16:12 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-14 17:10 ` Alan Mackenzie
2023-08-03 16:11 ` Alan Mackenzie
2023-08-03 16:41 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-03 18:48 ` Alan Mackenzie
2023-08-09 12:27 ` Alan Mackenzie
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=B102D1A8-8F8A-40D2-A3A6-08024CCE9688@gmail.com \
--to=mattias.engdegard@gmail.com \
--cc=65017@debbugs.gnu.org \
--cc=acm@muc.de \
--cc=eric.marsden@risk-engineering.org \
--cc=monnier@iro.umontreal.ca \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).