From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Charalampos Mitrodimas Newsgroups: gmane.emacs.bugs Subject: bug#70139: [PATCH] Improve key-translate to support removing translations Date: Tue, 9 Apr 2024 11:14:34 +0000 Message-ID: <68b807b9-1fa4-4430-87f4-e684a50f0bbe@posteo.net> References: <87v850t7nz.fsf@gmail.com> <20240402190246.1824023-1-charmitro@posteo.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------mN4fmpNvgLnf0zMcU3BMoCuH" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30070"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 70139@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Apr 09 13:15:20 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1ru9Rf-0007bR-8m for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 09 Apr 2024 13:15:19 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ru9RJ-0005KR-7M; Tue, 09 Apr 2024 07:14:57 -0400 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 1ru9RH-0005Jl-0U for bug-gnu-emacs@gnu.org; Tue, 09 Apr 2024 07:14:55 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ru9RG-000766-Od for bug-gnu-emacs@gnu.org; Tue, 09 Apr 2024 07:14:54 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ru9RO-0000Xd-Ao for bug-gnu-emacs@gnu.org; Tue, 09 Apr 2024 07:15:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Charalampos Mitrodimas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 09 Apr 2024 11:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70139 X-GNU-PR-Package: emacs Original-Received: via spool by 70139-submit@debbugs.gnu.org id=B70139.17126612932041 (code B ref 70139); Tue, 09 Apr 2024 11:15:02 +0000 Original-Received: (at 70139) by debbugs.gnu.org; 9 Apr 2024 11:14:53 +0000 Original-Received: from localhost ([127.0.0.1]:48468 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ru9RE-0000Wq-Th for submit@debbugs.gnu.org; Tue, 09 Apr 2024 07:14:53 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:33177) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ru9RC-0000Vl-Pm for 70139@debbugs.gnu.org; Tue, 09 Apr 2024 07:14:51 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 3D2A8240104 for <70139@debbugs.gnu.org>; Tue, 9 Apr 2024 13:14:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1712661276; bh=im9FGk0OxfbKvEmQy95OU0cwFVZxiKR/qpBgrn3/mus=; h=Content-Type:Message-ID:Date:MIME-Version:Subject:To:Cc:From: From; b=c7SKOXrYxulHRiHqioDW25eChsvZN1PzhKeILL+NZU67GdJAtT3WGqgy3F1mxB7tS /s1U+7V7fdBVSYk89FdoJUfGu0ca0p6g/+FPNMZEte59Yvt4lXl0XWYujVkuc+seZS lAnIZ8IRAdA6w7wBqs47XzTb+RMeqsDmnf7mz2T1LhtOc+0g9YU2NRQf9Zhmwguksd cwPwu9ZOhNR+TCxPRwK9eYNQ7eORxRjTzjv3+1RJVOs0mzq8f9KTjP8O6OTvihXi5p CB63+ajAsLxUSpRVmVFhTPt05B+4S4LVizOLrf3YNikQN2dSlDd2NCM4LvCbajkZ9R 0ZmARM5sJIzSA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4VDNdl1rNZz6tvb; Tue, 9 Apr 2024 13:14:34 +0200 (CEST) Content-Language: en-US In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:282986 Archived-At: This is a multi-part message in MIME format. --------------mN4fmpNvgLnf0zMcU3BMoCuH Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 4/7/24 17:45, Stefan Monnier wrote: >> + (lambda (form) (keymap--compile-check from (and to to)) form))) > ^^^^^^^^^^^ > ?? > >> (keymap--check from) >> - (keymap--check to) >> - (or (char-table-p keyboard-translate-table) >> - (setq keyboard-translate-table >> - (make-char-table 'keyboard-translate-table nil))) >> - (aset keyboard-translate-table >> - (aref (key-parse from) 0) >> - (aref (key-parse to) 0))) >> + (when to >> + (keymap--check to)) >> + (let ((from-key (key-parse from)) >> + (to-key (and to (key-parse to)))) >> + (when (> (length from-key) 1) >> + (error "FROM key %s is not a single key" from)) >> + (when (and to (> (length to-key) 1)) >> + (error "TO key %s is not a single key" to)) > I'd check `=` while at it (if length is 0 the error is caught by > `aref`, but it's a less helpful error). > > > Stefan Updated & attached. -- Charalampos --------------mN4fmpNvgLnf0zMcU3BMoCuH Content-Type: text/x-patch; charset=UTF-8; name="0001-Improve-key-translate-to-support-removing-translatio.patch" Content-Disposition: attachment; filename*0="0001-Improve-key-translate-to-support-removing-translatio.pa"; filename*1="tch" Content-Transfer-Encoding: base64 RnJvbSAzMGNiZTc3MjJhNjc3YTUzYWU5YzlmNjZiMTMxNTMyNzUzMjRhZGM2IE1vbiBTZXAg MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBDaGFyYWxhbXBvcyBNaXRyb2RpbWFzIDxjaGFybWl0 cm9AcG9zdGVvLm5ldD4KRGF0ZTogVHVlLCAyIEFwciAyMDI0IDE5OjAyOjQ2ICswMDAwClN1 YmplY3Q6IFtQQVRDSF0gSW1wcm92ZSBrZXktdHJhbnNsYXRlIHRvIHN1cHBvcnQgcmVtb3Zp bmcgdHJhbnNsYXRpb25zCgpUaGlzIHBhdGNoIGVuaGFuY2VzIHRoZSBrZXktdHJhbnNsYXRl IGZ1bmN0aW9uIHRvIGFsbG93IHJlbW92aW5nCmtleWJvYXJkIHRyYW5zbGF0aW9ucyBieSBw YXNzaW5nIG5pbCBhcyB0aGUgc2Vjb25kIGFyZ3VtZW50IChUTykuCgpJZiBUTyBpcyBuaWws IGFueSBleGlzdGluZyB0cmFuc2xhdGlvbiBmb3IgdGhlIEZST00ga2V5IHdpbGwgYmUgcmVt b3ZlZC4KVGhlIGNvbXBpbGVyIG1hY3JvIGlzIHVwZGF0ZWQgdG8gb25seSBjaGVjayBUTyB3 aGVuIGl0IGlzIG5vbi1uaWwuCgpUaGlzIGNoYW5nZSBtYWtlcyBrZXktdHJhbnNsYXRlIG1v cmUgY29uc2lzdGVudCB3aXRoIHRoZSBiZWhhdmlvciBvZgprZXlib2FyZC10cmFuc2xhdGUs IHByb3ZpZGluZyBhIHdheSB0byByZW1vdmUgdH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wKQorICAgICAgKGVycm9yICJGUk9NIGtleSBp cyBlbXB0eSIpKQorICAgICAoKD4gKGxlbmd0aCBmcm9tLWtleSkgMSkKKyAgICAgIChlcnJv ciAiRlJPTSBrZXkgJXMgaXMgbm90IGEgc2luZ2xlIGtleSIgZnJvbSkpKQorICAgIChjb25k CisgICAgICgoYW5kIHRvICg9IChsZW5ndGggdG8ta2V5KSAwKSkKKyAgICAgIChlcnJvciAi VE8ga2V5IGlzIGVtcHR5IikpCisgICAgICgoYW5kIHRvICg+IChsZW5ndGggdG8ta2V5KSAx KSkKKyAgICAgIChlcnJvciAiVE8ga2V5ICVzIGlzIG5vdCBhIHNpbmdsZSBrZXkiIHRvKSkp CisgICAgKG9yIChjaGFyLXRhYmxlLXAga2V5Ym9hcmQtdHJhbnNsYXRlLXRhYmxlKQorICAg ICAgICAoc2V0cSBrZXlib2FyZC10cmFuc2xhdGUtdGFibGUKKyAgICAgICAgICAgICAgKG1h a2UtY2hhci10YWJsZSAna2V5Ym9hcmQtdHJhbnNsYXRlLXRhYmxlIG5pbCkpKQorICAgIChh c2V0IGtleWJvYXJkLXRyYW5zbGF0ZS10YWJsZQorICAgICAgICAgIChhcmVmIGZyb20ta2V5 IDApCisgICAgICAgICAgKGFuZCB0byAoYXJlZiB0by1rZXkgMCkpKSkpCiAKIChkZWZ1biBr ZXltYXAtbG9va3VwIChrZXltYXAga2V5ICZvcHRpb25hbCBhY2NlcHQtZGVmYXVsdCBuby1y ZW1hcCBwb3NpdGlvbikKICAgIlJldHVybiB0aGUgYmluZGluZyBmb3IgY29tbWFuZCBLRVkg aW4gS0VZTUFQLgotLSAKMi4zOS4yCgo= --------------mN4fmpNvgLnf0zMcU3BMoCuH--