From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Zehao Hu Newsgroups: gmane.emacs.bugs Subject: bug#60081: 29.0.60; compiler-macros in keymap.el accept wrong number of arguments Date: Thu, 15 Dec 2022 16:54:26 +0800 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000000274f205efda01de" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26880"; mail-complaints-to="usenet@ciao.gmane.io" To: 60081@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Dec 15 09:55:17 2022 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 1p5k1M-0006ir-7x for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 15 Dec 2022 09:55:16 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5k1A-0006Ie-Cn; Thu, 15 Dec 2022 03:55:04 -0500 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 1p5k18-0006I9-Jc for bug-gnu-emacs@gnu.org; Thu, 15 Dec 2022 03:55:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5k18-0008Nd-9g for bug-gnu-emacs@gnu.org; Thu, 15 Dec 2022 03:55:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p5k18-0000Ed-5n for bug-gnu-emacs@gnu.org; Thu, 15 Dec 2022 03:55:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Zehao Hu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 15 Dec 2022 08:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60081 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.1671094491890 (code B ref -1); Thu, 15 Dec 2022 08:55:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 15 Dec 2022 08:54:51 +0000 Original-Received: from localhost ([127.0.0.1]:42541 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p5k0w-0000EI-UU for submit@debbugs.gnu.org; Thu, 15 Dec 2022 03:54:51 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:37766) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p5k0t-0000EC-3y for submit@debbugs.gnu.org; Thu, 15 Dec 2022 03:54:49 -0500 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 1p5k0s-0006Bb-Uj for bug-gnu-emacs@gnu.org; Thu, 15 Dec 2022 03:54:46 -0500 Original-Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5k0q-0008MF-MV for bug-gnu-emacs@gnu.org; Thu, 15 Dec 2022 03:54:46 -0500 Original-Received: by mail-ej1-x635.google.com with SMTP id kw15so50610417ejc.10 for ; Thu, 15 Dec 2022 00:54:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=oszQ4RGjAhQykVvlvs73cq7uAKIywz1HoN8V2APYkN0=; b=CV9sPpjUprIzriZmLFoGzwmPVBzaAmY/yLnUhBqeD1z7EK9BiBDUQWq3PL2Zsnr1l8 S5k3J7/shBy645sWvmFxVnz4MXoU94JqzB5bZcmt+4bwAoeX1ZUpvOc5AvQU/MgQ4eTu eISGfW3BzsboY8gXr7l18WsMvJTfbIOPdSc8LgsqoeZfSEAktoKmqOZCJPqCEWO5kjiG SPbK5MohO0N1RtUNPfj05aBqvQLdAltiDj50DCPss13v/1Xg+vsXUM532K8sfP7lMMk/ FsliqPYGNaB7/1YcZVq4epa0tDPXIu24WrE/1n7QjKt+nYjq8SjnEkUJyHzETEOXLdLj L04A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=oszQ4RGjAhQykVvlvs73cq7uAKIywz1HoN8V2APYkN0=; b=VC07kNQGLf6BASJBlRGBPtQHxZ326Fk/1SnTNE6BZWJjvUZoUSd1d9mKuwWzMrHD3J JGrJA8gVAVU1EPa68xZiN0/wc1X05dtMPfA3ap6fHfwXWD6PPUkTv1/zoF/Wo+rVul8q 7e9s4t0GjZFMLIQEyO5ZZ2OxtWv9v54LpGOXsWzUr2jndikMckAPzM0Z0yit7+Tx4ec8 Xb8+K8/NF+Nl5wIJFSDqA6HRKJkF8SiiNR++h6nBMtLHSKMl+TbHURV8Ppwf/frooyIV ghTnZTnCts4tjdsAvAHbIvBNIRBYyr3cm7b1yg2Gve1KQQXRNbOXRnXbOMwka9/MqOFl Nj3w== X-Gm-Message-State: ANoB5plPnPKT6mXBH/8bO/mikzPlQRI7wuVcY9fAlooHhLhdw94zq0Ga eYmHaEBJycXVkz3gZ49hIpKSK3VWVK62pItSO/0LrFrlPpxxmw== X-Google-Smtp-Source: AA0mqf73d0t3xJ89momkaNx84/GesIHkESdXNeeW13UGQygLrVI2FvXFKmUaLGKcDqL13e9Dmqtga1XXinIFCPTkIDo= X-Received: by 2002:a17:906:3393:b0:7c1:639:6b44 with SMTP id v19-20020a170906339300b007c106396b44mr14280050eja.200.1671094482398; Thu, 15 Dec 2022 00:54:42 -0800 (PST) In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::635; envelope-from=huzehao1998@gmail.com; helo=mail-ej1-x635.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:251039 Archived-At: --0000000000000274f205efda01de Content-Type: text/plain; charset="UTF-8" Hi all, I'm sure that this is the same bug as bug #50043, #58148, #58396 In bug #58356, Stefan Monnier writes: >Lars Ingebrigtsen [2022-10-11 20:27:42] wrote: >> Stefan Monnier writes: >>> Because that's the sort of error you can get if you try to macro-expand >>> code that's syntactically invalid. E.g. try to compile a file with >>> >>> (add-to-list x) >>> >>> and you should see a similar error. For `elisp--local-variables`, >>> syntactically invalid code is the normal case (more or less) both >>> because it's used when we're in the middle of writing the code, and also >>> because of how it works (it takes the code from beginning-of-defun up >>> to point and throws away whatever follows, just adding enough closing >>> parens that the resutling string is `read`able). >> >> I see. >> >> Shouldn't this function then be suppressing all errors while it's doing >> this exploratory macro-expansion stuff? > >Yes (plus silence the messages plus avoid compiler macros). Here is a simple workaround: (require 'loadhist) (defun cmacro-ignore-elisp-witness (oldfn form &rest args) "Add this advicing function around compiler macros to ignore `elisp--witness--lisp'" (unless (eq 'elisp--witness--lisp (car args)) (apply oldfn form args))) (defun cmacro-add-advice (file-or-entry) "Add `cmacro-ignore-elisp-witness' to compiler macros in FILE or in ENTRY from `load-history'" (let ((entry (if (stringp file-or-entry) (file-loadhist-lookup file-or-entry) file-or-entry))) (dolist (cell (cdr entry)) (when-let* (((consp cell)) ((eq 'defun (car cell))) (symbol (cdr cell)) ((symbolp symbol)) (cmacro (get symbol 'compiler-macro)) ((not (advice-member-p #'cmacro-ignore-elisp-witness symbol)))) (advice-add cmacro :around #'cmacro-ignore-elisp-witness))))) ;; Advicing existing compiler macros (dolist (entry load-history) (cmacro-add-advice entry)) ;; And the ones in the future (add-hook 'after-load-functions #'cmacro-add-advice) (dolist (entry load-history) (cmacro-add-advice entry)) (add-hook 'after-load-functions #'cmacro-add-advice) Or maybe edit `byte-run--set-compiler-macro', to change the `*--anon-cmacro' and to advice the `compiler-function'. --0000000000000274f205efda01de Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi all,

I'm sure that this is the same bug= as bug #50043, #58148, #58396

In bug #58356,
Stefan Monnier <= monnier@iro.umontreal.ca>= ; writes:
>Lars Ingebrigtsen [2022-10-11 20:27:42] wrote:
>>= Stefan Monnier <monnier@iro= .umontreal.ca> writes:
>>> Because that's the sort o= f error you can get if you try to macro-expand
>>> code that= 9;s syntactically invalid.=C2=A0 E.g. try to compile a file with
>>= ;>
>>> =C2=A0 =C2=A0 (add-to-list x)
>>>
>= >> and you should see a similar error.=C2=A0 For `elisp--local-variab= les`,
>>> syntactically invalid code is the normal case (more o= r less) both
>>> because it's used when we're in the mi= ddle of writing the code, and also
>>> because of how it works = (it takes the code from beginning-of-defun up
>>> to point and = throws away whatever follows, just adding enough closing
>>> pa= rens that the resutling string is `read`able).
>>
>> I se= e.
>>
>> Shouldn't this function then be suppressing = all errors while it's doing
>> this exploratory macro-expansio= n stuff?
>
>Yes (plus silence the messages plus avoid compiler = macros).

Here is a simple workaround:

(require 'loadhist)=

(defun cmacro-ignore-elisp-witness (oldfn form &rest args)
= =C2=A0 "Add this advicing function around compiler macros to ignore `e= lisp--witness--lisp'"
=C2=A0 (unless (eq 'elisp--witness--l= isp (car args))
=C2=A0 =C2=A0 (apply oldfn form args)))

(defun cm= acro-add-advice (file-or-entry)
=C2=A0 "Add `cmacro-ignore-elisp-wi= tness' to compiler macros in FILE or in ENTRY from `load-history'&q= uot;
=C2=A0 (let ((entry (if (stringp file-or-entry)
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(file-loadhist-looku= p file-or-entry)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0file-or-entry)))
=C2=A0 =C2=A0 (dolist (cell (cdr entry))
=C2= =A0 =C2=A0 =C2=A0 (when-let*
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (((consp= cell))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0((eq 'defun (car ce= ll)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(symbol
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 (cdr cell))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0((symbolp symbol))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(c= macro
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (get symbol 'compile= r-macro))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0((not (advice-member-= p #'cmacro-ignore-elisp-witness symbol))))
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 (advice-add cmacro :around #'cmacro-ignore-elisp-witness)))))
;; Advicing existing compiler macros
(dolist (entry load-history)
= =C2=A0 (cmacro-add-advice entry))

;; And the ones in the future
(= add-hook 'after-load-functions #'cmacro-add-advice)
(dolist (ent= ry load-history)
=C2=A0 (cmacro-add-advice entry))

(add-hook '= ;after-load-functions #'cmacro-add-advice)

Or maybe edit `byte-r= un--set-compiler-macro', to change the `*--anon-cmacro'
and to a= dvice the `compiler-function'.


<= /div> --0000000000000274f205efda01de--