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, 14 Sep 2024 10:38:04 +0300 Message-ID: <86bk0qit2b.fsf@gnu.org> References: 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="40058"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 72460@debbugs.gnu.org To: hugo@heagren.com, Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Sep 14 09:39:07 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 1spNN5-000AGK-1w for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 14 Sep 2024 09:39:07 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1spNMs-0006S6-9M; Sat, 14 Sep 2024 03:38:54 -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 1spNMq-0006Rh-BU for bug-gnu-emacs@gnu.org; Sat, 14 Sep 2024 03:38:52 -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 1spNMq-0001C5-1k for bug-gnu-emacs@gnu.org; Sat, 14 Sep 2024 03:38:52 -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=HDUUhGNKYPUXiUjLgix1LoVPevKGe3X0W94OOhnuGQE=; b=KP3q9FUThTdf3lhZNMMM9UF/I/J+tsuUItX74lGcLrEPzBJ3AdUTi4d5BDgjoJ9oe5fGKVbqMlfLqHEnO9P2nBYrQSbiEsIxwOh4dcAvURyYy9PVFT6XV+475qmOBO5kjLrHdzIJnUdhzEn8XbmQIq94nL67EqcN5ljPdZ5Ra+kkYAKcdPlxTo1xh4aJX8Vtd3x3Ysy4EWHz0s55HbU55fDGjwmR4xmLa3RlwEvY1fnR1M7Q6U/HQ28TeoNrhF0Lq1jiPDcx6H2JWusujlEjR891ee/K06TraGtbabj4kWT/0802rjNFTiSBwIraJ8C9TwByUv3kEcO+Uy25uQgonw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1spNN0-0002w9-6S for bug-gnu-emacs@gnu.org; Sat, 14 Sep 2024 03:39: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, 14 Sep 2024 07:39: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.172629950611236 (code B ref 72460); Sat, 14 Sep 2024 07:39:02 +0000 Original-Received: (at 72460) by debbugs.gnu.org; 14 Sep 2024 07:38:26 +0000 Original-Received: from localhost ([127.0.0.1]:44668 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1spNMQ-0002v8-0W for submit@debbugs.gnu.org; Sat, 14 Sep 2024 03:38:26 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:46034) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1spNMN-0002uu-Tw for 72460@debbugs.gnu.org; Sat, 14 Sep 2024 03:38:24 -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 1spNM7-0001AY-Vb; Sat, 14 Sep 2024 03:38:08 -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=HDUUhGNKYPUXiUjLgix1LoVPevKGe3X0W94OOhnuGQE=; b=Rg6rGMG2xNRfWPiNF1Qg oW4MRV2ZiV9C2bkDO+oaNxQTReCwp0LNBcfF5w/r5WVuveGFzv0mzATIyB/VwwmTL8mYHhMcQ+1jy C083Xy1gUw60WH08ameDJI+JSqCfqZQWCDEaAa7kBEBABWjgvhBpMDRFQPa9Denpxmd3DbwAlIUoJ iFT314mkDbBW9z/aUuVUnPvYiwQxvUR0OOmfLiGqlE8QEH3qNaMaNBVkovOxr8PgzDh3y4axl9tZy wGBKRTWoSoPWLzaHwHK2EFsGvsP8V8dk9QRAPl5f3cnlcktHsKSh32c9CoXX8o0EM3efj28nu4zYe t9gujzPLdBJscQ==; In-Reply-To: (bug-gnu-emacs@gnu.org) 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:291702 Archived-At: 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 > > > > >