bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#58396: 29.0.50; Optimization failure for add-to-list


From: Jens Schmidt
Subject: bug#58396: 29.0.50; Optimization failure for add-to-list
Date: Tue, 26 Sep 2023 22:30:47 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>
>> Yes (plus silence the messages plus avoid compiler macros).
>
> Any chance that...  someone...  will do that?  😇
>

Hit this issue today.  How about the attached patch, which seems to fix
it?  I hope I understood Stefan's directions correctly.

BTW, bug#60081 could also be merged with this one.

>From 83387466cfb7fe859b227fb00148ee7f6cd288a5 Mon Sep 17 00:00:00 2001
From: Jens Schmidt <jschmidt4gnu@vodafonemail.de>
Date: Tue, 26 Sep 2023 22:26:15 +0200
Subject: [PATCH] Silence macro expansion during completion-at-point

* lisp/progmodes/elisp-mode.el (elisp--local-variables): Silence
messages.  Avoid compiler macros.  Suppress all errors during macro
expansion.  (Bug#58396)
---
 lisp/progmodes/elisp-mode.el | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index bd3916ce108..809df64a536 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -445,11 +445,23 @@ elisp--local-variables
                                    (condition-case nil
                                        (apply expander form args)
                                      (error form))))
+             (macroexp--c-m-advice (lambda (_handler form) form))
+             ;; Avoid any macro expansion errors when attempting
+             ;; completion at point (bug#58148).  As Stefan suggested
+             ;; there: Silence messages [1], avoid compiler macros
+             ;; [2], and suppress all errors [3].
              (sexp
               (unwind-protect
-                  (let ((warning-minimum-log-level :emergency))
+                  (let ((inhibit-message t)     ;[1]
+                        (warning-minimum-log-level :emergency))
                     (advice-add 'macroexpand :around macroexpand-advice)
-                    (macroexpand-all sexp))
+                    (advice-add 'macroexp--compiler-macro :override
+                                macroexp--c-m-advice) ;[2]
+                    (condition-case nil
+                        (macroexpand-all sexp)
+                      (t sexp)))                ;[3]
+                (advice-remove 'macroexp--compiler-macro
+                               macroexp--c-m-advice)
                 (advice-remove 'macroexpand macroexpand-advice)))
              (vars (elisp--local-variables-1 nil sexp)))
         (delq nil
-- 
2.30.2


reply via email to

[Prev in Thread] Current Thread [Next in Thread]