From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jens Schmidt via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#58396: bug#58148: 29.0.50; Wrong number of arguments in keymap-set--anon-cmacro Date: Sat, 30 Sep 2023 20:44:55 +0200 Message-ID: <877co7bivs.fsf_-_@sappc2.fritz.box> References: <87o7uknkyx.fsf@gnus.org> <87fsfwnkl4.fsf@gnus.org> <87a663kxtz.fsf@gnus.org> <87czaygqqp.fsf@gnus.org> <87fsfte2hf.fsf@gnus.org> <87o7hod6dk.fsf@sappc2.fritz.box> <87v8bwip2h.fsf@sappc2.fritz.box> <87ttrcaqrm.fsf@sappc2.fritz.box> Reply-To: Jens Schmidt Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22642"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) Cc: German Pacenza , 58396@debbugs.gnu.org, Lars Ingebrigtsen , Eli Zaretskii , 58148@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Sep 30 20:46:15 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 1qmeyl-0005b0-Eu for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 30 Sep 2023 20:46:15 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qmeyN-0000us-PT; Sat, 30 Sep 2023 14:45:51 -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 1qmeyJ-0000sm-JX for bug-gnu-emacs@gnu.org; Sat, 30 Sep 2023 14:45:50 -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 1qmeyJ-0007eU-Bn for bug-gnu-emacs@gnu.org; Sat, 30 Sep 2023 14:45:47 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qmeyY-0006uV-RH for bug-gnu-emacs@gnu.org; Sat, 30 Sep 2023 14:46:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jens Schmidt Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 30 Sep 2023 18:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58396 X-GNU-PR-Package: emacs Original-Received: via spool by 58396-submit@debbugs.gnu.org id=B58396.169609954626527 (code B ref 58396); Sat, 30 Sep 2023 18:46:02 +0000 Original-Received: (at 58396) by debbugs.gnu.org; 30 Sep 2023 18:45:46 +0000 Original-Received: from localhost ([127.0.0.1]:59768 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qmeyH-0006tg-EV for submit@debbugs.gnu.org; Sat, 30 Sep 2023 14:45:46 -0400 Original-Received: from mr4.vodafonemail.de ([145.253.228.164]:34702) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qmeyD-0006tJ-BP; Sat, 30 Sep 2023 14:45:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vodafonemail.de; s=vfde-mb-mr2-21dec; t=1696099520; bh=s2Fm6mHlorUUrhvqMr11m5CUk8CGP/7r3Y7Ah7R22Uk=; h=From:To:Subject:References:Date:In-Reply-To:Message-ID:User-Agent: Content-Type:From; b=WF6/5YA7d2zP9DlX7j33YKnO6kE73m7L1p6EcZzAWlS3s5Gdw+jj8M78NCYu6vkTA AEF0bgrLogqzndRSH0ACWCNdRlUeO1taAjPXHhuc1mvRGdBCfF+EPGlzfYnlng0hJg 8odNfG3e6733r8T6aNMnzDOj93WLbaVb6691JRbA= Original-Received: from smtp.vodafone.de (unknown [10.0.0.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by mr4.vodafonemail.de (Postfix) with ESMTPS id 4RybkS0zPyz1y1Y; Sat, 30 Sep 2023 18:45:19 +0000 (UTC) Original-Received: from sappc2 (port-83-236-57-119.dynamic.as20676.net [83.236.57.119]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp.vodafone.de (Postfix) with ESMTPSA id 4Rybk352hNzKm4H; Sat, 30 Sep 2023 18:44:56 +0000 (UTC) In-Reply-To: (Stefan Monnier's message of "Sat, 30 Sep 2023 09:56:09 -0400") X-purgate-type: clean X-purgate: clean X-purgate-size: 7013 X-purgate-ID: 155817::1696099515-21FCD58E-EC5D5CB4/0/0 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:271558 Archived-At: --=-=-= Content-Type: text/plain Stefan Monnier writes: >> + (let ((inhibit-message t) ;[1] >> + (warning-minimum-log-level :emergency)) >> (advice-add 'macroexpand :around macroexpand-advice) >> - (macroexpand-all sexp)) >> + (condition-case nil ;[3] >> + (macroexpand-all sexp) >> + (t sexp))) > > This `t` catches more than errors. Better replace it with `error`. Done plus Eli's comments from that other branch. >> - (let ((warning-minimum-log-level :emergency)) >> + (let ((inhibit-message t) ;[1] >> + (macroexp-inhibit-compiler-macros t) ;[2] >> + (warning-minimum-log-level :emergency)) >> (advice-add 'macroexpand-1 :around macroexpand-advice) >> - (macroexpand-all sexp elisp--local-macroenv)) >> + (condition-case nil ;[3] >> + (macroexpand-all sexp elisp--local-macroenv) >> + (t sexp))) > > What kind of errors are we expecting to catch with this > `condition-case`? The pre-existing advice is supposed to catch macro > expansion errors, and the new let-binding is supposed to catch > compiler-macro errors, so it seems to me there aren't any *expected* > errors left. If so, better remove this `condition-case` (or replace it > with `with-demoted-errors`) since all it has left to do is to hide any > real coding error that may come up and that we'd like to be told about. Done. FWIW, bug#60081 can also be merged into this one. (The other bugs that Zehao mentions in her/his last post are either merged already or typos/not related to this bug.) Technically, I should be able to merge that bug (after having been pointed to admin/notes/bugtracker), but is it OK for me (as a "plain user") to do so? Or should someone with more authority do that? Thanks. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-29-Silence-macro-expansion-during-completion-at-point.patch >From f4184086081b9cf94e87848d33b527c35f78ffdf Mon Sep 17 00:00:00 2001 From: Jens Schmidt Date: Tue, 26 Sep 2023 22:26:15 +0200 Subject: [PATCH] Silence macro expansion during completion at point To keep risk in the current release branch low, do not avoid compiler macros as suggested by Stefan in the bug, but rather suppress all errors. * lisp/progmodes/elisp-mode.el (elisp--local-variables): Silence messages. Suppress all errors during macro expansion. (Bug#58148) Do not merge to master. --- lisp/progmodes/elisp-mode.el | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index bd3916ce108..354d98c50dc 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -447,9 +447,14 @@ elisp--local-variables (error form)))) (sexp (unwind-protect - (let ((warning-minimum-log-level :emergency)) + ;; Silence any macro expansion errors when + ;; attempting completion at point (bug#58148). + (let ((inhibit-message t) + (warning-minimum-log-level :emergency)) (advice-add 'macroexpand :around macroexpand-advice) - (macroexpand-all sexp)) + (condition-case nil + (macroexpand-all sexp) + (error sexp))) (advice-remove 'macroexpand macroexpand-advice))) (vars (elisp--local-variables-1 nil sexp))) (delq nil -- 2.30.2 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-30-Silence-macro-expansion-during-completion-at-point.patch >From cc954764667e23ecc19ae9cc3fb89956a32289ce Mon Sep 17 00:00:00 2001 From: Jens Schmidt Date: Fri, 29 Sep 2023 22:04:43 +0200 Subject: [PATCH] Silence macro expansion during completion at point * lisp/emacs-lisp/macroexp.el (macroexp-inhibit-compiler-macros): Add variable. (macroexp--compiler-macro): Inspect that new variable and, if it is non-nil, return the input form unchanged. * lisp/progmodes/elisp-mode.el (elisp--local-variables): Silence messages. Avoid compiler macros. (Bug#58148) --- lisp/emacs-lisp/macroexp.el | 20 ++++++++++++++------ lisp/progmodes/elisp-mode.el | 6 +++++- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/lisp/emacs-lisp/macroexp.el b/lisp/emacs-lisp/macroexp.el index 3ef924a5c73..6eb670d6dc1 100644 --- a/lisp/emacs-lisp/macroexp.el +++ b/lisp/emacs-lisp/macroexp.el @@ -105,13 +105,21 @@ macroexp--all-clauses (macroexp--all-forms clause skip) clause))) +(defvar macroexp-inhibit-compiler-macros nil + "Inhibit application of compiler macros if non-nil.") + (defun macroexp--compiler-macro (handler form) - (condition-case-unless-debug err - (apply handler form (cdr form)) - (error - (message "Warning: Optimization failure for %S: Handler: %S\n%S" - (car form) handler err) - form))) + "Apply compiler macro HANDLER to FORM and return the result. +Unless `macroexp-inhibit-compiler-macros' is non-nil, in which +case return FORM unchanged." + (if macroexp-inhibit-compiler-macros + form + (condition-case-unless-debug err + (apply handler form (cdr form)) + (error + (message "Warning: Optimization failure for %S: Handler: %S\n%S" + (car form) handler err) + form)))) (defun macroexp--funcall-if-compiled (_form) "Pseudo function used internally by macroexp to delay warnings. diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index 664299df288..ff90a744ea3 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -460,7 +460,11 @@ elisp--local-variables (message "Ignoring macroexpansion error: %S" err) form)))) (sexp (unwind-protect - (let ((warning-minimum-log-level :emergency)) + ;; Silence any macro expansion errors when + ;; attempting completion at point (bug#58148). + (let ((inhibit-message t) + (macroexp-inhibit-compiler-macros t) + (warning-minimum-log-level :emergency)) (advice-add 'macroexpand-1 :around macroexpand-advice) (macroexpand-all sexp elisp--local-macroenv)) (advice-remove 'macroexpand-1 macroexpand-advice))) -- 2.30.2 --=-=-=--