From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#72460: [patch] add commands for setting keyboard translations interactively Date: Sat, 28 Sep 2024 11:49:20 +0300 Message-ID: <86o7486u3z.fsf@gnu.org> References: <86bk0qit2b.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12615"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 72460@debbugs.gnu.org, monnier@iro.umontreal.ca To: hugo@heagren.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Sep 28 10:50:52 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 1suTAC-00039Y-Df for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 28 Sep 2024 10:50:52 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1suT9u-0006Jc-MM; Sat, 28 Sep 2024 04:50:34 -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 1suT9t-0006J6-8g for bug-gnu-emacs@gnu.org; Sat, 28 Sep 2024 04:50:33 -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 1suT9s-0001Ve-T0 for bug-gnu-emacs@gnu.org; Sat, 28 Sep 2024 04:50:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-version:References:In-Reply-To:From:Date:To:Subject; bh=fr/zAnbam2jDvXzcMtC8ofD+pf5qH5pqZZvzOR8lEuQ=; b=mBp956PhoXBajuzmjuSTtrUbDdbRM9NjBsQo/Hz9O7U08vqvm1Czch8cehy/p1VSkctFaHHswvJDDzfbztGbFK2h3dJkpFJ9bhkC+yAASZ0jFMCHcIKvy1Hm+2fjYO0rVzlIYg0ejG3j2xjL1DYaSLnamu/cOVfEhk6bp51oFQ4m6/bj9jm4p4Y9ipKdrv5QHRI0QNyDMkyx4jArw9MqjrrWLroyBLdzZ699ZkLhyHGBTHwOgI+FtFc1ubsrc5Xk5d1hoTLp8jCo74aAX4CDCMHADZWxczoeY3bXqjeKyq/QHuoqonCWtc4lGQcYGwaw6EqIz8An9uEx71d1rNbWlA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1suTAM-0005Jr-Gt for bug-gnu-emacs@gnu.org; Sat, 28 Sep 2024 04:51:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 28 Sep 2024 08:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72460 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 72460-submit@debbugs.gnu.org id=B72460.172751340419840 (code B ref 72460); Sat, 28 Sep 2024 08:51:02 +0000 Original-Received: (at 72460) by debbugs.gnu.org; 28 Sep 2024 08:50:04 +0000 Original-Received: from localhost ([127.0.0.1]:51769 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1suT9P-00059u-D3 for submit@debbugs.gnu.org; Sat, 28 Sep 2024 04:50:04 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:35592) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1suT9N-000595-6l for 72460@debbugs.gnu.org; Sat, 28 Sep 2024 04:50:01 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1suT8n-0001A7-G5; Sat, 28 Sep 2024 04:49:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=fr/zAnbam2jDvXzcMtC8ofD+pf5qH5pqZZvzOR8lEuQ=; b=kRHfJd8xnrpJTVnRNMZ+ RJ5EeuPV75q3W74QM7XwqECozx7OEGIanpVbuwqGUUL5hB+sCtQcIoVBP0UhuHHlQtLFzvSayAQic fT6ba5Pbs10tEwA8afY11hpCRHrTsK0eQhx7wnExSfvu9ywj/V+mY4kikTTmiyUO6yxWCniNmieCC zZ/5ZT2sC+/YcsHx6+GYrXaRmiKIXXg/81UkDw329tG+UK8T2fKW7YrNNXeejXKUZXGNz9p/kRZS+ qG1kDpHrdvS0/oPIxx6m+kP94q+t/dKHSgoEgrXVYhKAhEwvwUZKPq2QWcfNHkvmQjYknWcOLdNwD I6qEVubbb0WxmQ==; In-Reply-To: <86bk0qit2b.fsf@gnu.org> (message from Eli Zaretskii on Sat, 14 Sep 2024 10:38:04 +0300) 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:292554 Archived-At: Ping! Hugo, please respond. > Cc: 72460@debbugs.gnu.org > Date: Sat, 14 Sep 2024 10:38:04 +0300 > From: Eli Zaretskii > > Hugo, > > Any followups to Stefan's comments? > > > Cc: 72460@debbugs.gnu.org > > Date: Sat, 31 Aug 2024 09:56:58 -0400 > > From: Stefan Monnier via "Bug reports for GNU Emacs, > > the Swiss army knife of text editors" > > > > >> > +(defcustom key-translate-selection-function #'key-select-translation > > >> Do we need this? > > > Short answer: yes. > > > > > > I wanted a way for users to customise how the current translation > > > pairs are presented when they choose one to remove. The initial > > > motivation was that some users might want to customise the formatting > > > of the pairs; "X -> Y" vs "X → Y" vs "X Y" etc. (I'm the sort of user > > > who cares about this sort of thing a lot). > > > > Rewriting a whole new `key-translate-selection-function` function for > > that is not significantly easier than rewriting a whole new > > `key-translate-remove`, so I think this is firmly in the overengineering > > side of the camp. > > > > > I also envisage that many users will want to use/expect > > > completing-read (as in the default) and will want the from/to elements > > > vertically aligned (again, I am this user). > > > > AFAICT, you're the first user to propose this functionality in Emacs's > > 40 years life, so I wouldn't bet on "many users". > > > > BTW, I just noticed: > > > > > + ;; Populate collection > > > + (map-char-table format-func keyboard-translate-table) > > > + (get-text-property 0 'key-translate-from > > > + (completing-read "Key Translation: " collection)))) > > > > You can't trust `get-text-property` here (especially since you don't > > even force `completing-read` to `require-match`). > > Instead you should do something like `key-parse`. > > > > > I think here I was just copying the current calling convention for the > > > existing (non-interactive) `key-translate'. Its docstring reads: > > > > > >> Both FROM and TO should be specified by strings that satisfy > > >> `key-valid-p'. > > > > > > I sort of assumed someone cleverer than me had a good reason. > > > > I suspect this is because we expect this function to be called from > > a `~/.emacs` with a literal constant as argument, and we've tried to > > unify on using the "KBD" syntax for those cases, since it's a friendlier > > syntax than the "vector of events" where you need to distinguish between > > symbols and chars with/without modifiers. > > > > Since the arg of `key-translate` can be only a valid char (rather than > > any arbitrary key potentially with modifiers), the argument is much less > > strong, but my guess is that it was uniformity. > > > > In the case of `key-translate-remove` I don't expect the arg to be > > a literal constant in the code, so "nice/uniform syntax to write the > > argument value" shouldn't be a concern. 🙂 > > > > > > Stefan > > > > > > > > > > > > > >