From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.devel Subject: Re: 29.0.60; keymap-local-set and keymap-global-set became less strict Date: Tue, 31 Jan 2023 10:05:15 +0100 Message-ID: <87zg9zvzuc.fsf@gmail.com> References: <5876987d-2479-f512-5767-218c8c16a909@daniel-mendler.de> <875ycngyji.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="919"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Daniel Mendler , emacs-devel@gnu.org, Stefan Monnier , Eli Zaretskii To: Lars Ingebrigtsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Jan 31 10:06:21 2023 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 1pMmao-000AVr-JN for ged-emacs-devel@m.gmane-mx.org; Tue, 31 Jan 2023 10:06:18 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMmaA-0000dA-RI; Tue, 31 Jan 2023 04:05:38 -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 1pMmZu-0000cX-Ge for emacs-devel@gnu.org; Tue, 31 Jan 2023 04:05:22 -0500 Original-Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pMmZs-0008KV-FA; Tue, 31 Jan 2023 04:05:21 -0500 Original-Received: by mail-wm1-x332.google.com with SMTP id k16so9813459wms.2; Tue, 31 Jan 2023 01:05:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id :reply-to; bh=ABdpEWUGU3p0WFlOuTM/pv832yBX9rUM7PzjpnauvsQ=; b=JWgMzbUPFhgP8QW1WEBey9Yt2K/q9hfzzK8ZMwBpKN0lH2f9BIjUT2A1r5ekC6/NJT y7G4t5+RO4ECm4jn34g/Qyu6YY6MEOYGpH8LLIaidNj4mabKSuohHB9OGsjhYhRqXwXN W5BB1v6Dd74nht2NLbksSgBtzPAdHegOxBVba257kJv2AhgyiyG6zMJQ2QY3a5uLeFNz Sz6pHncWN3aeExnOLfTuKJYeiTG9b8Mq1tUmIY8m6eOwHqYHL7IQ60rx8+m00bg6NHkR pT5WnRsZK1Tj37AKpzsuBKXHHQ5/rY/Kn2QTR59cEa2IZeANB37H4rt5Hz71GEoLv+1t 7D8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ABdpEWUGU3p0WFlOuTM/pv832yBX9rUM7PzjpnauvsQ=; b=Sy/oKQeBJSODnkQ4Z8xq7tUFyJc7eOeCpz96wnZfsA/5djhjAAAxMunG0Wgr+/4CHo dEHkEupot2BpJUsOWtLQhXO4jsX/+6C6yi+JCi4XUbAHygXjcwQEJ8964eQz/63hus9J D36thU/A5SEOUeyAPhSV19QuoZ5Uvli9uVsExV6JXYwymZOEOxLjQsmHTPsJl1ODhWfX Ghs0U0DnvjQFu9/w2c8tfgdtZ4QtNFsAhS5q1leLPclHFfNUMUs6zJwedHAqeHVzMbKz 3GUSA3WKB/Hn6BAi5bFVTjv/dQ9PBJ1tqew9G7f+u6wlaU01UGC7gi7IqtsJmDxiwcnL 3rkQ== X-Gm-Message-State: AO0yUKX1KnoraeZF6VTUV8LqAQGFC90rqRU0jORZAD6mKaOETPnP77y5 P1TPzAw/mbxMFTZSpMTfKIUrgzMcHBI= X-Google-Smtp-Source: AK7set/9jEs+fNtMFHbLuObz5W1tWEXGXoFerCoQSRbuGACQQSaTlZO4ZizkWfZv/StLyDwLDMet8A== X-Received: by 2002:a1c:7312:0:b0:3dd:62fe:9914 with SMTP id d18-20020a1c7312000000b003dd62fe9914mr1147036wmb.18.1675155917151; Tue, 31 Jan 2023 01:05:17 -0800 (PST) Original-Received: from rltb ([82.66.8.55]) by smtp.gmail.com with ESMTPSA id l21-20020a05600c4f1500b003b47b80cec3sm20585661wmq.42.2023.01.31.01.05.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 01:05:16 -0800 (PST) In-Reply-To: <875ycngyji.fsf@gnus.org> (Lars Ingebrigtsen's message of "Tue, 31 Jan 2023 04:42:25 +0100") Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=rpluim@gmail.com; helo=mail-wm1-x332.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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:302821 Archived-At: Dropping bug-gnu-emacs, adding emacs-devel >>>>> On Tue, 31 Jan 2023 04:42:25 +0100, Lars Ingebrigtsen said: Lars> In addition, having one single syntax allows people to grep for b= indings Lars> etc -- when exploring the source code, they can isearch for `C-c = C-k' Lars> (or whatever) exactly and reliably find the command they're looki= ng for Lars> that way (eventually). We have bindings in emacs currently that are Not Compliant=E2=84=A2, that= =CA=BCs for sure. Lars> So keymap-local-set and keymap-global-set should be fixed to be s= trict Lars> again, otherwise there's not much point to the entire `keymap-*' Lars> exercise. OK. How about this then (why are the `cursor-in-echo-area' shenanigans necessary? I wonder if that=CA=BCs a bug, since without them we either get the cursor not showing in the minibuffer for `read-key-sequence-vector', or we get an extra space displayed by `read-command') diff --git i/lisp/keymap.el w/lisp/keymap.el index caabedd5aec..0c1aa412e35 100644 --- i/lisp/keymap.el +++ w/lisp/keymap.el @@ -76,9 +76,14 @@ keymap-global-set that local binding will continue to shadow any global binding that you make with this function." (declare (compiler-macro (lambda (form) (keymap--compile-check key) form= ))) - (interactive "KSet key globally:\nCSet key %s globally to command: ") - (unless (stringp key) - (setq key (key-description key))) + (interactive + (let* ((menu-prompting nil) + (cursor-in-echo-area t) + (key (key-description (read-key-sequence-vector "Set key globall= y:" nil t)))) + (list key + (let ((cursor-in-echo-area nil)) + (read-command (format "Set key %s to command: " + key)))))) (keymap-set (current-global-map) key command)) =20 (defun keymap-local-set (key command) @@ -91,12 +96,17 @@ keymap-local-set The binding goes in the current buffer's local map, which in most cases is shared with all other buffers in the same major mode." (declare (compiler-macro (lambda (form) (keymap--compile-check key) form= ))) - (interactive "KSet key locally:\nCSet key %s locally to command: ") + (interactive + (let* ((menu-prompting nil) + (cursor-in-echo-area t) + (key (key-description (read-key-sequence-vector "Set key locally= :" nil t)))) + (list key + (let ((cursor-in-echo-area nil)) + (read-command (format "Set key %s to command: " + key)))))) (let ((map (current-local-map))) (unless map (use-local-map (setq map (make-sparse-keymap)))) - (unless (stringp key) - (setq key (key-description key))) (keymap-set map key command)))