GNU bug report logs - #59305
29.0.50; keymap-global-set handling of string bindings different from global-set-key

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Robert Pluim <rpluim@HIDDEN>; dated Wed, 16 Nov 2022 08:48:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 59305 <at> debbugs.gnu.org:


Received: (at 59305) by debbugs.gnu.org; 25 Nov 2022 08:02:09 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Nov 25 03:02:09 2022
Received: from localhost ([127.0.0.1]:33368 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oyTez-0004th-GQ
	for submit <at> debbugs.gnu.org; Fri, 25 Nov 2022 03:02:09 -0500
Received: from mail-wr1-f54.google.com ([209.85.221.54]:40688)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rpluim@HIDDEN>) id 1oyTex-0004tR-7N
 for 59305 <at> debbugs.gnu.org; Fri, 25 Nov 2022 03:02:07 -0500
Received: by mail-wr1-f54.google.com with SMTP id x5so5571953wrt.7
 for <59305 <at> debbugs.gnu.org>; Fri, 25 Nov 2022 00:02:07 -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=VlpSCyI+kmpbjGHKN4mZbQmizEWlfZDMM+CGRnULq3I=;
 b=FI5F2NDusoh/j+B/IDa5LVvxAvfIM90k8bQLdedLkvXwuqWSX5gCO5VfF/+7CaTZs+
 7DFcCBYeWKpr9grC5wTw2NnpR1ntpo+nYsXb70o6aqD7RU1eHhRJj9rv1/06A4vGQgty
 RGNUmhY5WdgwN4IXkJ6I1VoiJ0oh5+zzuaPyG7mtjPHrtEztIghmfIHdP9UV1fqiyR7/
 Y+lvf7TjDYeeCIB3w32pSaXEOJKzXa9k81JAwXOfLqG9EgW1YR6VLoyI/wCjqNdnxgBb
 HucBa5QTsUzbR1y5Zgj0VNwDTibfMi0f4BJWlXngYv5Vld+YMO5TNn7Pd+4zS0n6lZf3
 8XNQ==
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=VlpSCyI+kmpbjGHKN4mZbQmizEWlfZDMM+CGRnULq3I=;
 b=ybU9wNe1Ke9b5w+0sN/q78wMOI4lC2lZRu0ED/xrF/L5MnbINaSfxlbPGNwgYlXtlh
 U5FUrfg38QsBHeExQKoUmZSci4ulMr0SFddUP9fyXDkf5PSugZvzpYS5Bckl3MYu42jC
 1XbJxuSyHoYS9tLtkBfOBjuuPsKaP+9yJ+qoarqoU93OGl97k8Xbj/VWsT87nd/j0MVU
 n6WyF5aL5SlEM29Qn2Yjd3CCAZnXqE5K8k+D2k07LnblQLNahEq3WMGF2D1lDsRBBnv0
 XNIx3j1UKbRUpAP7W5RF4aSxByKq8/iHDlo4/0NAX9UO+0yaUsbnl5mSnZc1tYciE6q5
 XrNA==
X-Gm-Message-State: ANoB5pmJ9k45cnbPLz03N1FNB3tqqpFqfPSw/Uy6tyioAiGAEVwrLY/K
 2OEeCiQJaQvTDUTE6GOaJhE=
X-Google-Smtp-Source: AA0mqf61AfNScu3adWPAKTbAeS5weTypYudC8TiwemkLW3Ya4cSMg4Zvxd71O0qOIrYHx6piYq/mkQ==
X-Received: by 2002:a5d:5507:0:b0:236:8a6d:eaeb with SMTP id
 b7-20020a5d5507000000b002368a6deaebmr22162157wrv.208.1669363321277; 
 Fri, 25 Nov 2022 00:02:01 -0800 (PST)
Received: from rltb ([82.66.8.55]) by smtp.gmail.com with ESMTPSA id
 n11-20020adfe78b000000b0023677fd2657sm3231942wrm.52.2022.11.25.00.02.00
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 25 Nov 2022 00:02:00 -0800 (PST)
From: Robert Pluim <rpluim@HIDDEN>
To: Stefan Kangas <stefankangas@HIDDEN>
Subject: Re: bug#59305: 29.0.50; keymap-global-set handling of string
 bindings different from global-set-key
In-Reply-To: <CADwFkmmLXvGvdZvo5G=rVGaL71ZQMNc3NXrj7WXaATM0qksSMQ@HIDDEN>
 (Stefan Kangas's message of "Thu, 24 Nov 2022 16:14:05 -0800")
References: <87edu3cml8.fsf@HIDDEN>
 <CADwFkmmLXvGvdZvo5G=rVGaL71ZQMNc3NXrj7WXaATM0qksSMQ@HIDDEN>
Date: Fri, 25 Nov 2022 09:01:59 +0100
Message-ID: <874junfonc.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 59305
Cc: Lars Ingebrigtsen <larsi@HIDDEN>, 59305 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

>>>>> On Thu, 24 Nov 2022 16:14:05 -0800, Stefan Kangas <stefankangas@gmail=
.com> said:

    Stefan> Robert Pluim <rpluim@HIDDEN> writes:
    >> After reading up on `key-valid-p':
    >>=20
    >> 5. (keymap-global-set "C-c h" "h e l l o") =3D> success!
    >>=20
    >> or alternatively
    >>=20
    >> 6. (keymap-global-set "C-c h" [?h ?e ?l ?l ?o]) =3D> success!
    >>=20
    >> Whilst not strictly a regression, this behaviour is confusing and
    >> unhelpful, and the solution is not easily found. I can think of two
    >> solutions:
    >>=20
    >> 1. Change `kbd' to always return a vector even if the input is
    >> ascii-only, which makes [4] work
    >> 2. Change `keymap-set' to convert ascii-only strings to the format in
    >> [5] or [6]. Probably just a call to `string-to-vector' is enough.

    Stefan> I feel like the second alternative goes against the design of
    Stefan> `keymap-global-set', where the idea explicitly was to only supp=
ort a KEY
    Stefan> argument that is `key-valid-p'.

It was? If so, then it should not have been touted as the replacement
for `global-set-key' everywhere without a big warning sign.

    Stefan> Could we perhaps introduce a new optional argument to treat the=
 argument
    Stefan> as a literal string?  Or if really want it to not be `key-valid=
-p', to
    Stefan> at least require it to be something like '(literal "foo") ?

(string-to-vector "foo") will do. But that just highlights the problem
even more: if it=CA=BCs that simple, why can=CA=BCt `keymap-global-set' do =
that
internally instead of forcing users to jump through hoops?

Robert
--=20




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#59305; Package emacs. Full text available.

Message received at 59305 <at> debbugs.gnu.org:


Received: (at 59305) by debbugs.gnu.org; 25 Nov 2022 00:14:21 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Nov 24 19:14:21 2022
Received: from localhost ([127.0.0.1]:60573 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oyMMH-0006Ei-9E
	for submit <at> debbugs.gnu.org; Thu, 24 Nov 2022 19:14:21 -0500
Received: from mail-oi1-f182.google.com ([209.85.167.182]:38479)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <stefankangas@HIDDEN>) id 1oyMM6-0006Dw-Uy
 for 59305 <at> debbugs.gnu.org; Thu, 24 Nov 2022 19:14:11 -0500
Received: by mail-oi1-f182.google.com with SMTP id v81so2935493oie.5
 for <59305 <at> debbugs.gnu.org>; Thu, 24 Nov 2022 16:14:10 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=cc:to:subject:message-id:date:mime-version:references:in-reply-to
 :from:from:to:cc:subject:date:message-id:reply-to;
 bh=lKG54MzIytosaJwrBCRpgRJZMtMp2gvQbMNXDzK33UI=;
 b=HO1DMz0leLb5Z7WZufT5R7rwG4Twvak2M2aSfhdHJGCzgHawH8zVf+7+0Ulxf11owW
 GA6dCgdp25b7J0+rZgx+R0Vq++vQ2TllUIVT96XjmPPTKmhQ3OGmKqHtC/mV10C3Fv9T
 Qzr9I7HqZ6EjHnrAP1F2/kmcyPaXk3jfBlTA/aB9iFIObHz5anpXGfIMHJ0X56U6hvq8
 LS7+5OrxbGR8+33/ZHPj9YU2pFtegJ95YEF/o5G/TEcN6oBeURWWOv3hFa28sRzzqgsl
 skkCty+MhAidAJbpphC5PUKxjxRvYx717QXvVclLOACJYOGfzetg+LEqy0ITWVJLc/y5
 cEiQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=cc:to:subject:message-id:date:mime-version:references:in-reply-to
 :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=lKG54MzIytosaJwrBCRpgRJZMtMp2gvQbMNXDzK33UI=;
 b=V6x4TpFcmtbh4sfc4/w2fms/6vx69IdDCK73YlnDN8XLWVT44i3Pmw7/zXDsXgB3jS
 xF7VliRUctacZyB5xx7WnqI/k513xwRhlhiTI7Shua50dKVoVI+QeawTNjIB0hGHndQQ
 ar+n3ZEWJGKFh9/cremnINJoZVj4N9EvL959BnWQzd7J3Pa6qrD6Ca8wQiat7uZefLel
 zCECDngOJj50iVnEpjnENc2P95yTF5HUukwFVBEAOOMkwssuH2yJxWRil5EdlB7PtOLy
 +jN8ve80XSA6e9xlrJvOqGeZ97M9OxaHcrIPA3hrxtLinnAVF33ZAMGjh0QVfUpaA0kU
 hMzw==
X-Gm-Message-State: ANoB5pls49q3H7zCEHFayIVhWBm8/RSfRUoZQRLOaDhN9K4ZOb1FrZ+q
 gx/xm0GA5mn110GoGG0BJH3Eh49yZDqXLJVzw7Q=
X-Google-Smtp-Source: AA0mqf4Ez1HgVrJIAZX3icd/sF8/UTisH/XzubVlp0SARLk/a9xMLuob6kRwfl9NXFRB5xJSdL7zozpSTkXCf8i8Zeg=
X-Received: by 2002:a05:6808:2229:b0:35b:2b17:af81 with SMTP id
 bd41-20020a056808222900b0035b2b17af81mr7927055oib.199.1669335245428; Thu, 24
 Nov 2022 16:14:05 -0800 (PST)
Received: from 753933720722 named unknown by gmailapi.google.com with
 HTTPREST; Thu, 24 Nov 2022 16:14:05 -0800
From: Stefan Kangas <stefankangas@HIDDEN>
In-Reply-To: <87edu3cml8.fsf@HIDDEN> (Robert Pluim's message of "Wed, 16
 Nov 2022 09:47:31 +0100")
References: <87edu3cml8.fsf@HIDDEN>
X-Hashcash: 1:20:221125:larsi@HIDDEN::ebJcydZyi9qZK+T9:1I9W
MIME-Version: 1.0
Date: Thu, 24 Nov 2022 16:14:05 -0800
Message-ID: <CADwFkmmLXvGvdZvo5G=rVGaL71ZQMNc3NXrj7WXaATM0qksSMQ@HIDDEN>
Subject: Re: bug#59305: 29.0.50; keymap-global-set handling of string bindings
 different from global-set-key
To: Robert Pluim <rpluim@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 59305
Cc: Lars Ingebrigtsen <larsi@HIDDEN>, 59305 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Robert Pluim <rpluim@HIDDEN> writes:

> After reading up on `key-valid-p':
>
> 5. (keymap-global-set "C-c h" "h e l l o") => success!
>
> or alternatively
>
> 6. (keymap-global-set "C-c h" [?h ?e ?l ?l ?o]) => success!
>
> Whilst not strictly a regression, this behaviour is confusing and
> unhelpful, and the solution is not easily found. I can think of two
> solutions:
>
> 1. Change `kbd' to always return a vector even if the input is
> ascii-only, which makes [4] work
> 2. Change `keymap-set' to convert ascii-only strings to the format in
> [5] or [6]. Probably just a call to `string-to-vector' is enough.

I feel like the second alternative goes against the design of
`keymap-global-set', where the idea explicitly was to only support a KEY
argument that is `key-valid-p'.

Could we perhaps introduce a new optional argument to treat the argument
as a literal string?  Or if really want it to not be `key-valid-p', to
at least require it to be something like '(literal "foo") ?

It would be useful to here what Lars thinks (in Cc).




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#59305; Package emacs. Full text available.

Message received at 59305 <at> debbugs.gnu.org:


Received: (at 59305) by debbugs.gnu.org; 22 Nov 2022 16:58:18 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Nov 22 11:58:18 2022
Received: from localhost ([127.0.0.1]:52434 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oxWbC-0002Vs-0b
	for submit <at> debbugs.gnu.org; Tue, 22 Nov 2022 11:58:18 -0500
Received: from mail-wr1-f52.google.com ([209.85.221.52]:33597)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rpluim@HIDDEN>) id 1oxWb9-0002Vd-Gx
 for 59305 <at> debbugs.gnu.org; Tue, 22 Nov 2022 11:58:16 -0500
Received: by mail-wr1-f52.google.com with SMTP id i12so21795218wrb.0
 for <59305 <at> debbugs.gnu.org>; Tue, 22 Nov 2022 08:58:15 -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:to:from:from:to:cc:subject:date:message-id
 :reply-to; bh=R0MgBe4i1TvDCH3d8+BaICfLGkHJCRyBgdxNfU/7i+w=;
 b=lcJYMsyozTast6Hw4QxjpTReD5Vz+JOsoIfH6hh53F7CJEv9YDFtBw/yLb1fhjmQuj
 2pWJIm8knputL21gllPHJ/Cb6hicLbmrL9y1PaQVWZEjx2avEaPX/MKsaPB3cYs4NJXH
 BsNZ4dej2CpOMY+nzhTSWyJRWGolYMVFfY1W5ixhq1Do+63UmyF0JLIvemVahnWoh1Tb
 Uc/N+bfr8spgK7Yo9kGInw7zEUNcaMPk05bANPHUnPdhN4DuHGM/C6Sp7hDSGDn6f09b
 rBwv29XQ7IicDUXATw8Xy/LcDbsj+0DcpZHc7VciHInBtaNPjKHKxKzYgnNFXM00OFvk
 KFfA==
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:to:from:x-gm-message-state:from:to:cc:subject
 :date:message-id:reply-to;
 bh=R0MgBe4i1TvDCH3d8+BaICfLGkHJCRyBgdxNfU/7i+w=;
 b=MRq9XgNG40WXwTpj7tCIPMt04kLrHOma/pYdhLS8U3Yhb230OB3SFPM4PPu+CEuMs0
 F7bAxfiF2w/A+c6Fi4Wc7GS1z0O52NWfcQ4c9cT7iYQ/K0JqCE0gmqktpJNIQJih8d+5
 92YVmBYN/EJEVBWYWGb5fSZ/d7KRIeHPasRom3T2SohjhF9MUxlO7aMWTwaxE3o2aUWW
 ruI1a6HPNy5/iObn8xYCCEyz3fmXgxn2YVzGT3npTMVl3QLanrrWT+KMW03in5nsJKTG
 jscs8MRz6qyNufVqecVd3XO9oWVYNqDyMtEPPc+MaBKk8NNNXR3D+Nnpq8bgwkrwuFO+
 ARxQ==
X-Gm-Message-State: ANoB5plLMuqbC4XkWrAPgNgKTPs3AChWIVtVzL0siuvV5oby5hAFiyZy
 J/78oopP/7lWqFh/hejbgocl+HG1Yl8=
X-Google-Smtp-Source: AA0mqf5CnKlmyIDhFUKizN0XZPVriWs9+7u4IG/bSiUQr2cJQyvtqWAZMIjxFTJePPus64reWaGnTw==
X-Received: by 2002:a05:6000:78d:b0:22e:3d63:80bc with SMTP id
 bu13-20020a056000078d00b0022e3d6380bcmr15548907wrb.30.1669136289004; 
 Tue, 22 Nov 2022 08:58:09 -0800 (PST)
Received: from rltb ([82.66.8.55]) by smtp.gmail.com with ESMTPSA id
 o2-20020a05600c510200b003cf5ec79bf9sm20101263wms.40.2022.11.22.08.58.08
 for <59305 <at> debbugs.gnu.org>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 22 Nov 2022 08:58:08 -0800 (PST)
From: Robert Pluim <rpluim@HIDDEN>
To: 59305 <at> debbugs.gnu.org
Subject: Re: bug#59305: 29.0.50; keymap-global-set handling of string
 bindings different from global-set-key
In-Reply-To: <87edu3cml8.fsf@HIDDEN> (Robert Pluim's message of "Wed, 16
 Nov 2022 09:47:31 +0100")
References: <87edu3cml8.fsf@HIDDEN>
Date: Tue, 22 Nov 2022 17:58:07 +0100
Message-ID: <87h6yrexk0.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 59305
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

>>>>> On Wed, 16 Nov 2022 09:47:31 +0100, Robert Pluim <rpluim@HIDDEN> s=
aid:

    Robert> 1. Change `kbd' to always return a vector even if the input is
    Robert> ascii-only, which makes [4] work

I tried that, and it seems to work, but I guess it=CA=BCs kind of
risky. Just what we need to see if people are testing the pre-test
properly =F0=9F=98=B8

    Robert> 2. Change `keymap-set' to convert ascii-only strings to the for=
mat in
    Robert> [5] or [6]. Probably just a call to `string-to-vector' is enoug=
h.

This is less invasive. Something like this:

diff --git a/lisp/keymap.el b/lisp/keymap.el
index eaeba96644..deb44844fb 100644
--- a/lisp/keymap.el
+++ b/lisp/keymap.el
@@ -61,7 +61,23 @@ keymap-set
   ;; If we're binding this key to another key, then parse that other
   ;; key, too.
   (when (stringp definition)
-    (keymap--check definition)
+    ;; For backwards compatibility, we want people to be able to say
+    ;; "hello" instead of forcing them to say "h e l l o", and to fix
+    ;; the common mistake of specifying a string with non-ascii
+    ;; characters, we convert to a vector instead.
+    (cond
+     ((let ((case-fold-search nil)) ;; no special chars or keywords
+             (not (string-match-p
+                   (rx (or " " "^" "<" ">" "-" "\\"
+                           "NUL" "RET" "TAB" "LFD"
+                           "ESC" "SPC" "DEL")))))
+      (setq definition (string-join (seq-split definition 1) " "))
+      (keymap--check definition))
+     ((string-match-p ;; non-ascii characters
+       "[[:nonascii:]]" definition)
+      (setq definition (string-to-vector definition)))
+     (t ;; kbd syntax
+      (keymap--check definition)))
     (setq definition (key-parse definition)))
   (define-key keymap (key-parse key) definition))


Robert
--=20




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#59305; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 16 Nov 2022 08:47:41 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Nov 16 03:47:41 2022
Received: from localhost ([127.0.0.1]:56012 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ovE57-0005Jk-D3
	for submit <at> debbugs.gnu.org; Wed, 16 Nov 2022 03:47:41 -0500
Received: from lists.gnu.org ([209.51.188.17]:55644)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rpluim@HIDDEN>) id 1ovE53-0005Jb-S8
 for submit <at> debbugs.gnu.org; Wed, 16 Nov 2022 03:47:40 -0500
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 <rpluim@HIDDEN>) id 1ovE53-0001aO-Md
 for bug-gnu-emacs@HIDDEN; Wed, 16 Nov 2022 03:47:37 -0500
Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <rpluim@HIDDEN>) id 1ovE51-00034y-VV
 for bug-gnu-emacs@HIDDEN; Wed, 16 Nov 2022 03:47:37 -0500
Received: by mail-wm1-x32f.google.com with SMTP id v7so11396619wmn.0
 for <bug-gnu-emacs@HIDDEN>; Wed, 16 Nov 2022 00:47:35 -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:subject:to
 :from:from:to:cc:subject:date:message-id:reply-to;
 bh=y2b4RoHbmvunipDHr77pU8JdX5DzIl4IXWtjKnmg99c=;
 b=Bsb+55nlwmdivBLvXrqq/yQWmC71emVTffvVDkb3lRDU6SCJacq9081wTys4C2Akep
 9T2vIhj689445kcChbfDZMJVMqT/mMhOjAqJYiHqS8jJ0LvqcMF8zj3m/9wA8jtcvEf9
 vjkjhkEtOob8QfxXf/c3uBgv+EdaDZLKHvMOzTpBElNxOL+pIiWJ/MxnIb94vgjty7L+
 ExA14v7wv3MQxg8ohDy7b/15ZLGBAlnCTesIPNzQJo/43meDH6RO0zWh7wrFADOW88si
 iYvZq0a2RDhYicWLlCrS3Up5hlXnW5w+WBpoqWzsV0ZZbeie5sbAmFuHDL/hnBdnS+n5
 tjqw==
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:subject:to
 :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=y2b4RoHbmvunipDHr77pU8JdX5DzIl4IXWtjKnmg99c=;
 b=ZoZCEleWKfpAOQ9ZG/HfkxVTr/TKv3IvjuI1GQDNM/v3tcM5IrtSFDatp5n8LECadX
 30b/bkA5TlTrOjFo4BMZJsToiBeaR7idKIzPEJQ0N1lha8z5Md7n9TuqYERSLXhWGOV6
 wfWMPjHxW3dB0slV/jIhZIuUStJSoegmUBLMmC9EnAZfTnRMycSDuqgaetdnz4x54MrO
 ECSgPScj/pu2p7Vjtul1L0VY8mFHP6fAV/F7iRtzQMHMN2Hi8+HAUCP/dQZ+50CDP0LT
 LGGYGkj1rdh7BDqvq9F7bCgB0G70yuz78jw01KWVM48xhpyYIbd4Ra0pYG6tefsG9jRH
 hvCQ==
X-Gm-Message-State: ANoB5pl79FrIDD4CUS/lCAFQrCgmSiUS8kUQGjUVQ/Ml6Ai94XkSG9Ic
 q46IzOL6N+Sw3ZAAX3uQ6SLUNsBxaKs=
X-Google-Smtp-Source: AA0mqf5w0tYQ4HuVevTvLdfjnlzAECcyUwsYamKWv6wjmpmyRiYw5uzoh0SBWuRf7ybR0yoeegBlJQ==
X-Received: by 2002:a05:600c:2057:b0:3cf:6ab3:49ce with SMTP id
 p23-20020a05600c205700b003cf6ab349cemr1337623wmg.137.1668588453398; 
 Wed, 16 Nov 2022 00:47:33 -0800 (PST)
Received: from rltb ([82.66.8.55]) by smtp.gmail.com with ESMTPSA id
 e8-20020adffc48000000b00236863c02f5sm14217922wrs.96.2022.11.16.00.47.32
 for <bug-gnu-emacs@HIDDEN>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 16 Nov 2022 00:47:32 -0800 (PST)
From: Robert Pluim <rpluim@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 29.0.50; keymap-global-set handling of string bindings different
 from global-set-key
X-Debbugs-No-Ack: yes
Date: Wed, 16 Nov 2022 09:47:31 +0100
Message-ID: <87edu3cml8.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass client-ip=2a00:1450:4864:20::32f;
 envelope-from=rpluim@HIDDEN; helo=mail-wm1-x32f.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-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

`global-set-key' allows you to bind keys to strings (or vectors). The
following all succeed without error (although only [1] and [3] match the
expectations of users unfamiliar with Emacs' key representation).

1. (global-set-key (kbd "C-c h") "hello")
2. (global-set-key (kbd "C-c h") "ol=C3=A1")
3. (global-set-key (kbd "C-c h") (kbd "ol=C3=A1"))

Trying to map this to emacs-29's `keymap-global-set', we get the
following issues

(keymap-global-set "C-c h" "hello") =3D> error
(keymap-global-set "C-c h" "ol=C3=A1") =3D> error

OK, maybe we need to wrap the definitions in `kbd' like [3] above.

(keymap-global-set "C-c h" (kbd "ol=C3=A1")) =3D> definition is a vector ->=
 ok

but
4. (keymap-global-set "C-c h" (kbd "hello")) =3D> defn is a string -> error

After reading up on `key-valid-p':

5. (keymap-global-set "C-c h" "h e l l o") =3D> success!

or alternatively

6. (keymap-global-set "C-c h" [?h ?e ?l ?l ?o]) =3D> success!

Whilst not strictly a regression, this behaviour is confusing and
unhelpful, and the solution is not easily found. I can think of two
solutions:

1. Change `kbd' to always return a vector even if the input is
ascii-only, which makes [4] work
2. Change `keymap-set' to convert ascii-only strings to the format in
[5] or [6]. Probably just a call to `string-to-vector' is enough.

Thanks

Robert

In GNU Emacs 29.0.50 (build 43, x86_64-pc-linux-gnu, GTK+ Version
 3.24.24, cairo version 1.16.0) of 2022-11-16 built on rltb
Repository revision: 60f2bb862f834fcb580d839ac79b30a8b4cd4167
Repository branch: master
System Description: Debian GNU/Linux 11 (bullseye)

Configured using:
 'configure -C'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB





Report forwarded to bug-gnu-emacs@HIDDEN:
bug#59305; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 25 Nov 2022 08:15:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.