emacs-devel
[Top][All Lists]
Advanced

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

Re: master 859190f 2/3: Convert some keymaps to defvar-keymap


From: Gregory Heytings
Subject: Re: master 859190f 2/3: Convert some keymaps to defvar-keymap
Date: Wed, 13 Oct 2021 16:07:42 +0000


No need to apologize. But what do you (and others) think of the idea? It would be a (IMO elegant) way to "phase out strings (where every char represents an event)".

What do you intend to do with the "effectively preload kbd.el" part of my comments? If you indeed intend to preload kbd.el, that could be a bummer, I think. If you have other ideas, please tell.


Well, Lars (and Stefan K) already replied that it's a no go, so I don't think it's useful to explore this further.

To reply to your question anyway: perhaps I'm misunderstanding something, but I don't see why this would in itself imply preloading anything new. The (fboundp 'kbd) check, and checking that the return value of safe_call1 is non-nil (which I didn't do in the proof of concept) means that this would not have any effect until subr.el and edmacro.el (there's no "kbd.el", so I guess you mean "edmacro.el") are loaded. Here's a slightly more elaborate proof of concept:

diff --git a/src/keymap.c b/src/keymap.c
index be45d2be1e..8e0a99a4b0 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -1059,6 +1059,15 @@ DEFUN ("define-key", Fdefine_key, Sdefine_key, 3, 3, 0,
 {
   bool metized = false;

+  Lisp_Object kbd_key;
+  if (STRINGP (key) &&
+      (strstr (SSDATA (key), "C-") || strstr (SSDATA (key), "M-") ||
+       strstr (SSDATA (key), "S-") || strstr (SSDATA (key), "H-") ||
+       strstr (SSDATA (key), "s-")) &&
+      !NILP (Ffboundp (Qkbd)) &&
+      !NILP (kbd_key = safe_call1 (Qkbd, key)))
+    key = kbd_key;
+
   keymap = get_keymap (keymap, 1, 1);

   ptrdiff_t length = CHECK_VECTOR_OR_STRING (key);
@@ -3261,4 +3270,6 @@ syms_of_keymap (void)
   defsubr (&Stext_char_description);
   defsubr (&Swhere_is_internal);
   defsubr (&Sdescribe_buffer_bindings);
+
+  DEFSYM (Qkbd, "kbd");
 }




reply via email to

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