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: emacs-28 56026242e4: Explain how to bind keys to non-ASCII sequences Date: Tue, 15 Nov 2022 09:28:17 +0100 Message-ID: <878rkcei5a.fsf@gmail.com> References: <166844275725.4187.2343107623845911514@vcs2.savannah.gnu.org> <20221114161917.7FC8AC00AB5@vcs2.savannah.gnu.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="9967"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Stefan Kangas Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Nov 15 09:29:22 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 1ourJq-0002RD-JL for ged-emacs-devel@m.gmane-mx.org; Tue, 15 Nov 2022 09:29:22 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ourIv-0003QA-9F; Tue, 15 Nov 2022 03:28:25 -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 1ourIu-0003O0-Bb for emacs-devel@gnu.org; Tue, 15 Nov 2022 03:28:24 -0500 Original-Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ourIs-0000sc-LX for emacs-devel@gnu.org; Tue, 15 Nov 2022 03:28:24 -0500 Original-Received: by mail-wr1-x433.google.com with SMTP id g12so22744316wrs.10 for ; Tue, 15 Nov 2022 00:28:21 -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=AeJxDvDI8lR5Oj7iOQPZy1+MAZyCXIY9IgJylF9dRK4=; b=Jkz6cA3+pdjowBHULyjDOjELZ+DOJXce2tkmSafssJv97RD1z3N3Y6R4yPoeJtb9Uc t6GDhoiYgnpTDwIqCnMVn0M9ERG+p6uN0OUiCDOp+J/iM24rBCyE/ftzs923mwWiZZP+ EZARvdbfGilZrurF7PNwYbZN2WJHOwoDiJ8x3zU/IH3/2PqvBVRvNbPL4fXu4qj+eX9f ryWnr6YUHAmeFWBXyJKDWxXG7YSLffka34iLIR6b/XfwDQu6UFZgaUEm5LTXB6R4PePH PYDMiJw0Sj2r6p6Y32rqwwTf08P5dY2zXPK7IY41fSjhBMAxKPKdbz6C+c6NJlUjZM38 j+GA== 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=AeJxDvDI8lR5Oj7iOQPZy1+MAZyCXIY9IgJylF9dRK4=; b=gwiF9MrEaQKNblbPyXTQeCLzkwMz/PIZDjfmssyjoha31jEq9Pw+S0m4aCr+da/nOE rH8yUYX+4mnTr0yC2mBmFBDVLj1uig4Upf+zxfS8BGpWbq4mqjvoYjltgjre1golYvp8 seXsK8874V02578UtqOesLajQjycWATNg8As5oop4t8nwfQvfEjVrltIr5ib3QMSaHPQ +2XH2ptLpGxW0va/xOjEkFxVUIMqTAj3Mf7U9XGI3CvWY0E8D8rzIoHf7EGEZ/tDoa0p gTDV+VtC/9JwGFNU/3DLKjqcecsxlKSbDDxycLpcrvTHCpmZA1kVTP6ocAKUhwvVRxpi z9pA== X-Gm-Message-State: ANoB5pmfCPJjlFBqmHA9OXVS9uBx1m/9lfQXMDOrrp7HF2vvMBGvWl+d nzzycoZ2yNUz08gwxOCA/THnBz7NT0Y= X-Google-Smtp-Source: AA0mqf4Gz8/BKpyoFYLqhWI2WEHxFSn02eToFV76qqlreN0Nj3xOfVBaJMBjiB8S+nXMrDMbx1MrPg== X-Received: by 2002:adf:f009:0:b0:236:657e:757e with SMTP id j9-20020adff009000000b00236657e757emr9909626wro.350.1668500899506; Tue, 15 Nov 2022 00:28:19 -0800 (PST) Original-Received: from rltb ([82.66.8.55]) by smtp.gmail.com with ESMTPSA id bv13-20020a0560001f0d00b0022cce7689d3sm8089398wrb.36.2022.11.15.00.28.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Nov 2022 00:28:18 -0800 (PST) In-Reply-To: (Stefan Kangas's message of "Mon, 14 Nov 2022 19:40:35 -0800") Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=rpluim@gmail.com; helo=mail-wr1-x433.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:299832 Archived-At: >>>>> On Mon, 14 Nov 2022 19:40:35 -0800, Stefan Kangas said: Stefan> This section has changed quite a bit on master, including using Stefan> `keymap-global-set' instead. Unfortunately, I'm not sure what = if Stefan> anything needs adding to the text already on master. Could you= please Stefan> look into it, or even help merge it? Well this has opened a can of worms: Item the first: (keymap-global-set "C-c h" "h") =3D> [104] (keymap-global-set "C-c h" "hello") =3D>=20 Debugger entered--Lisp error: (error "\"hello\" is not a valid key defi= nition; see `key-va...") signal(error ("\"hello\" is not a valid key definition; see `key-va..= .")) error("%S is not a valid key definition; see `key-valid-p..." "hello") keymap--check("hello") keymap-set((keymap #^[nil nil keymap=20 keymap-global-set("C-c h" "hello") (keymap-global-set "C-c h" (kbd "hello")) =3D> same (keymap-global-set "C-c h" "h e l l o") =3D> [104 101 108 108 111] But: (keymap-global-set "C-c h" (kbd "ol=C3=A1")) =3D> [111 108 225] I think it=CA=BCs a bug (and a regression from `global-set-key') to require that what we=CA=BCre binding a key to satifies `key-valid-p' (or we need to change the output of (kbd "hello") =F0=9F=98=BA) (I know that binding keys to strings is not common amongst people who know how to write their own commands, but plenty of people just want to insert commonly used strings) Item the second: Higher up in that texi file is the following text: @findex kbd There are several ways to write a key binding using Lisp. The simplest is to use the @code{kbd} function, which converts a textual representation of a key sequence---similar to how we have written key sequences in this manual---into a form that can be passed as an argument to @code{keymap-global-set}. For example, here's how to bind @kbd{C-z} to the @code{shell} command (@pxref{Interactive Shell}): @example (keymap-global-set "C-z" 'shell) @end example which talks about `kbd' but then never uses it (since `keymap-global-set' doesn=CA=BCt need it). Item the third: But wait, maybe the documentation about `kbd' has been moved, so I look for discussion about non-ASCII, since that=CA=BCs where it=CA=BCs usef= ul, and find the following (in @node Init Non-ASCII): To bind non-@acronym{ASCII} keys, you must use a vector (@pxref{Init Rebinding}). The string syntax cannot be used, since the non-@acronym{ASCII} characters will be interpreted as meta keys. For instance: @example (global-set-key [?@var{char}] 'some-function) @end example @noindent Type @kbd{C-q}, followed by the key you want to bind, to insert @var{ch= ar}. where rather than telling people to write vectors by hand, we could explain how to use `kbd'. Robert --=20