From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs 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 Message-ID: References: <8B08E514-B2D5-48F5-BA90-4F5A9492F8F9@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.15\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_CDCDA28F-2083-4B0B-811B-19539BE888AC" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24545"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Alan Mackenzie , 65017@debbugs.gnu.org, Eric Marsden To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Aug 12 12:41:16 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qUm3X-0006E6-Sc for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 12 Aug 2023 12:41:15 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qUm3M-0000TU-8e; Sat, 12 Aug 2023 06:41:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qUm3K-0000TL-Qg for bug-gnu-emacs@gnu.org; Sat, 12 Aug 2023 06:41:02 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qUm3K-0005JG-HE for bug-gnu-emacs@gnu.org; Sat, 12 Aug 2023 06:41:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qUm3K-0005Ks-D5 for bug-gnu-emacs@gnu.org; Sat, 12 Aug 2023 06:41:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 12 Aug 2023 10:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65017 X-GNU-PR-Package: emacs Original-Received: via spool by 65017-submit@debbugs.gnu.org id=B65017.169183681620376 (code B ref 65017); Sat, 12 Aug 2023 10:41:02 +0000 Original-Received: (at 65017) by debbugs.gnu.org; 12 Aug 2023 10:40:16 +0000 Original-Received: from localhost ([127.0.0.1]:48791 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qUm2Z-0005Ia-QM for submit@debbugs.gnu.org; Sat, 12 Aug 2023 06:40:16 -0400 Original-Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]:49230) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qUm2V-0005IJ-Li for 65017@debbugs.gnu.org; Sat, 12 Aug 2023 06:40:14 -0400 Original-Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2b9cdba1228so44055191fa.2 for <65017@debbugs.gnu.org>; Sat, 12 Aug 2023 03:40:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691836805; x=1692441605; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:sender:from:to:cc:subject:date:message-id:reply-to; bh=JuJgGXjfktVEf20BEZ+KhRKrJ/1aN2YQ9qQblCGk8yQ=; b=nkCzWjyj3K7NzBLIOrQ+q4jlLAChLNWiRLmE+jhyvFJs42ELYtUKbEOcsv5XNzJnli XtOWy79yHQCeasGdLIZqTvFFykdluObvxTJjBJ9B6u7lhyegcTETa4y7EcQ+xwmtXJkQ +pjHz0Xg1Vcfjr5SSMJiqVkUNiCeBQA3FJqOR9LVTRQ/SVjRUjO0UYzwCkUpqvFfdNBN zjUaK8Mj/U07uJw62n/a9jH4AQ9Qxb2Q4FIgWdnx8BJsyhmoT6mbZ9GL2Rdw9ZvBsv7d GfFPAADRDJ4ltXZ0hArX6sSrhLcfHBxMX0I8ButpDud7wHcZb1o3ZQXD82Mb8y0rlIfx GKtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691836805; x=1692441605; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=JuJgGXjfktVEf20BEZ+KhRKrJ/1aN2YQ9qQblCGk8yQ=; b=K0MPYZFOY8WueOvwpAGExZtjsMHI+UFNtOj9jXFqlCUFcV1VGpNTArHR4b7EhZt1m/ PDrO5UECTtpUDMN7ULemvf3uMqJhZbT0iPWJDSnZgXGdwpmSVIc7WpCSEf0ZkYsRCmf3 Ass/SLRcl4SBy6T8h47ahFBBtoKhV8E16d6eGke700yDw6Ksh+7I7uaHcUvHjGVFLksj qWPUXIzSM7rb5clOfVooI/iT22aausAlBY361bHwUVkzLR+LLEYyhvviccDdQAMGUUW+ 3tQuoi+wT+gX/8BdFNKghwEGCLFh/LbwYjFGcKfBYaQemBKw7EhvmKdDhYbKNtePbm7T rscg== X-Gm-Message-State: AOJu0Yy2lbq0v6yNwsn0AGdIgENKsd/QbZWgJR07qHj0uje1uQphrAcF vBzhgORPsCZ/DA/TdH7Bp6w= X-Google-Smtp-Source: AGHT+IE7o3UI0Cm6bkg3cM3SxIkJ50x/y/mxUczp7uDvjFi3F3aEr0+9fbLsq4aP7kztGxAP6RhDnA== X-Received: by 2002:a05:6512:3193:b0:4ff:95c:e158 with SMTP id i19-20020a056512319300b004ff095ce158mr147401lfe.64.1691836805057; Sat, 12 Aug 2023 03:40:05 -0700 (PDT) Original-Received: from smtpclient.apple (c188-150-165-235.bredband.tele2.se. [188.150.165.235]) by smtp.gmail.com with ESMTPSA id u7-20020ac243c7000000b004fddb0eb961sm1089445lfl.18.2023.08.12.03.40.04 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 12 Aug 2023 03:40:04 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3654.120.0.1.15) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:267297 Archived-At: --Apple-Mail=_CDCDA28F-2083-4B0B-811B-19539BE888AC Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 12 aug. 2023 kl. 05.28 skrev Stefan Monnier : > 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. --Apple-Mail=_CDCDA28F-2083-4B0B-811B-19539BE888AC Content-Disposition: attachment; filename=macroexp-whole.diff Content-Type: application/octet-stream; x-unix-mode=0644; name="macroexp-whole.diff" Content-Transfer-Encoding: 7bit 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"); } --Apple-Mail=_CDCDA28F-2083-4B0B-811B-19539BE888AC--