GNU bug report logs - #56682
Fix the long lines font locking related slowdowns

Previous Next

Package: emacs;

Reported by: Gregory Heytings <gregory <at> heytings.org>

Date: Thu, 21 Jul 2022 18:01:01 UTC

Severity: normal

Done: Gregory Heytings <gregory <at> heytings.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Gregory Heytings <gregory <at> heytings.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 56682 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: bug#56682: Fix the long lines font locking related slowdowns
Date: Mon, 01 Aug 2022 18:09:07 +0000
[Message part 1 (text/plain, inline)]
>>> Try `M-: (use-global-map (make-keymap)) RET`
>>>
>>> Should we prevent users from doing that?
>>
>> It's a misleading question.  No "user" would ever do that.  Sure, it's 
>> a nice example, but only an Elisp hacker would do that, in the middle 
>> of a debugging session, and they would do that on purpose (although 
>> perhaps without knowing the effect in advance).  Which has nothing to 
>> do with a regular user who just opens a file.
>
> FWIW, the above is my standard example because I ended up doing exactly 
> that by accident, locking myself out of the session I was trying to 
> debug, so in a sense, I'd have been happy (that one time) if Emacs had 
> prevented me from doing it.
>

So... what do you think of the following? 😉

diff --git a/src/keymap.c b/src/keymap.c
index 506b755e5d..e42bc64717 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -1881,6 +1881,17 @@ DEFUN ("use-global-map", Fuse_global_map, 
Suse_global_map, 1, 1, 0,
   (Lisp_Object keymap)
 {
   keymap = get_keymap (keymap, 1, 1);
+
+  /* Prevent locking Emacs if someone inadvertently evaluates
+     (use-global-map (make-keymap)) */
+  if (EQ (Fequal (keymap, Fmake_keymap (Qnil)), Qt))
+    {
+      Lisp_Object meta_colon_key = CALLN (Fvector, make_fixnum (134217786));
+      Lisp_Object default_key = CALLN (Fvector, Qt);
+      Fdefine_key (keymap, meta_colon_key, intern ("eval-expression"), Qnil);
+      Fdefine_key (keymap, default_key, intern ("self-insert-command"), Qnil);
+    }
+
   current_global_map = keymap;

   return Qnil;

This bug report was last modified 2 years and 8 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.