From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Phil Sainty Newsgroups: gmane.emacs.devel Subject: Re: Delegating user-reserved key binding space definition to users Date: Tue, 22 Nov 2022 15:07:46 +1300 Message-ID: <57b69c22e167d429d21bb969feb22887@webmail.orcon.net.nz> References: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10786"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Orcon Webmail Cc: Emacs developers To: Psionic K Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Nov 22 03:08:28 2022 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 1oxIi2-0002bd-S9 for ged-emacs-devel@m.gmane-mx.org; Tue, 22 Nov 2022 03:08:26 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oxIhW-0000qu-Qp; Mon, 21 Nov 2022 21:07:54 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oxIhT-0000ql-MW for emacs-devel@gnu.org; Mon, 21 Nov 2022 21:07:51 -0500 Original-Received: from smtp-4.orcon.net.nz ([60.234.4.59]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oxIhS-0002Ff-4A for emacs-devel@gnu.org; Mon, 21 Nov 2022 21:07:51 -0500 Original-Received: from [10.253.37.70] (port=52192 helo=webmail.orcon.net.nz) by smtp-4.orcon.net.nz with esmtpa (Exim 4.90_1) (envelope-from ) id 1oxIhP-0001B2-1z; Tue, 22 Nov 2022 15:07:47 +1300 Original-Received: from ip-180-148-114-34.kinect.net.nz ([180.148.114.34]) via [10.253.37.253] by webmail.orcon.net.nz with HTTP (HTTP/1.1 POST); Tue, 22 Nov 2022 15:07:46 +1300 In-Reply-To: X-Sender: psainty@orcon.net.nz X-GeoIP: -- Received-SPF: pass client-ip=60.234.4.59; envelope-from=psainty@orcon.net.nz; helo=smtp-4.orcon.net.nz X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:300321 Archived-At: AFAIK... You can't arbitrarily prevent key sequences from being bound in keymaps, because you can't control how or when that happens. You can't control when it happens because that time might be "before you started (or even installed) Emacs". Keymaps are sometimes generated at byte-compilation time, and thus even if you were to take the extreme measure of preventing define-key from doing anything at all, you will still acquire populated keymaps when certain libraries are loaded (although if the libraries were byte-compiled while the neutralised define-key was in place, you would then typically be loading empty keymaps; but you would need to recompile everything to get to that point; and of course most installations of Emacs will include pre-compiled .elc files). Native compilation might preclude even that, as IIRC it compiles everything asynchronously in isolation, so the intended clobbering of define-key might not actually be in effect when the native code was being generated. You would then have to edit the core code to enforce your override irrespective of whether your custom code was loaded. You can't control how it happens because libraries can set bindings without using define-key. In the simplest case `use-local-map' for one of the aforementioned pre-generated keymaps may easily occur; but also a keymap is, after all, just a list, so it can be manipulated in any number of ways. (In practice I think that messing with define-key and recompiling All Of The Things would affect almost all keymaps; but in general there's no guarantee.) I would suggest that your best option is to instead ensure that the key lookup sequence always finds your preferred bindings. Despite your concerns about that approach, it seems more viable to me.