From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: master 859190f 2/3: Convert some keymaps to defvar-keymap Date: Wed, 13 Oct 2021 15:55:33 +0300 Message-ID: <83tuhlnkxm.fsf@gnu.org> References: <20211004081724.6281.11798@vcs0.savannah.gnu.org> <20211004081727.4F24921048@vcs0.savannah.gnu.org> <871r4qcs8s.fsf@gnus.org> <87o87ubcnl.fsf@gnus.org> <87h7dm9en7.fsf@gnus.org> <818f9907c2b1fe8b54b1@heytings.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21205"; mail-complaints-to="usenet@ciao.gmane.io" Cc: larsi@gnus.org, stefankangas@gmail.com, emacs-devel@gnu.org To: Gregory Heytings Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Oct 13 14:59:05 2021 Return-path: Envelope-to: ged-emacs-devel@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 1madqb-0005G7-3p for ged-emacs-devel@m.gmane-mx.org; Wed, 13 Oct 2021 14:59:05 +0200 Original-Received: from localhost ([::1]:58732 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1madqY-0005ij-Qe for ged-emacs-devel@m.gmane-mx.org; Wed, 13 Oct 2021 08:59:02 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51004) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1madnP-0000fB-7g for emacs-devel@gnu.org; Wed, 13 Oct 2021 08:55:47 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:58430) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1madnN-0007pr-OY; Wed, 13 Oct 2021 08:55:46 -0400 Original-Received: from [87.69.77.57] (port=4992 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1madnH-0001NR-66; Wed, 13 Oct 2021 08:55:45 -0400 In-Reply-To: <818f9907c2b1fe8b54b1@heytings.org> (message from Gregory Heytings on Wed, 13 Oct 2021 08:54:20 +0000) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:276886 Archived-At: > Date: Wed, 13 Oct 2021 08:54:20 +0000 > From: Gregory Heytings > Cc: Stefan Kangas , emacs-devel@gnu.org > > 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"); > } If the "kbd" call fails for some reason, safe_call1 will return nil, and what will that do to the rest of the code? Also, I think doing this effectively means preloading kbd.el, because define-key is used in many places in packages we preload. Or am I missing something?