[Top][All Lists]

[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 08:54:20 +0000

Aha. Now I understand the argument. But surely that's pretty minor, given that we can just document this difference? People might appreciate the easier to read syntax many times more than they will struggle with this minor additional complexity.

Well, we have a bunch of different key syntaxes, and two of them are strings and therefore aren't marked as syntactically different.

But their syntaxes are different, aren't they?

It seems somewhat unfortunate to me that we are effectively doubling down on the mistakes of the past. I'd rather take one step forward now, in the hope that we can do something about "define-key" later.

I don't think that's a forlorn hope. We'd have to introduce a new function.

Is this not possible as follows (it's a POC), without introducing a new function?

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

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

   ptrdiff_t length = CHECK_VECTOR_OR_STRING (key);
@@ -3261,4 +3266,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]