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, 31 Aug 2024 11:08:02 +0300 Message-ID: <86o759cdy5.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34094"; 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 Aug 31 10:09:17 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 1skJAb-0008iN-LV for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 31 Aug 2024 10:09:17 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1skJAQ-0001nU-0i; Sat, 31 Aug 2024 04:09:06 -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 1skJAO-0001mw-5n for bug-gnu-emacs@gnu.org; Sat, 31 Aug 2024 04:09:04 -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 1skJAN-00079k-Sy for bug-gnu-emacs@gnu.org; Sat, 31 Aug 2024 04:09:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=CEAUW5VQJMyuzkM4w5H9wDouzyPli82drfuw/sVr9TU=; b=FEWYDbg5CUASbwtnaUqhbMRDFMWErJI3M9tY3XVbDzG8wGrIkq7/kpesuFSpD+96jllqIGEwJtjX+yzOEeFYA2aQrKSHzu4dpSriVD7hNqDUAgxNpKPTo1m+4R2Nfp3SmdYH6Vj/zzae0RnNPuqDWQNOwH80gtzqvPm4gRMUtVfX6GYhjmDMlZ8W9LkYjWoCDeqYF8r4yqMdxCCeaJHtJmv4Epk+GooS5eXBKQ4qohJ+Cg+XrirOBdYNuv4+f+/FuWbM+lO2lW+ybI2puYQ3gBF8mLRS9LdW84pvkmlkPJ3TWMqRTFDMoheS2yAQAfwS52mee58ekE6g1RW/NzDIbg==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1skJBJ-0006T9-KY for bug-gnu-emacs@gnu.org; Sat, 31 Aug 2024 04:10:01 -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, 31 Aug 2024 08:10:01 +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.172509174924789 (code B ref 72460); Sat, 31 Aug 2024 08:10:01 +0000 Original-Received: (at 72460) by debbugs.gnu.org; 31 Aug 2024 08:09:09 +0000 Original-Received: from localhost ([127.0.0.1]:53868 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1skJAS-0006Rl-S4 for submit@debbugs.gnu.org; Sat, 31 Aug 2024 04:09:09 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:55018) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1skJAR-0006RZ-LG for 72460@debbugs.gnu.org; Sat, 31 Aug 2024 04:09:08 -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 1skJ9Q-000759-6f; Sat, 31 Aug 2024 04:08:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=CEAUW5VQJMyuzkM4w5H9wDouzyPli82drfuw/sVr9TU=; b=cifCirze0ML6 4OE/Kp4QIjH0XheFt4Yf84nuDzA96rAFXCSmN+3dQoVPI1Vz3/vBBOlMvufXR1RSDajLDbiqTlMgG Pj+s58epYvyhcUtebgopIunAuB14VkRqWrKHtOJ40sh/sL9NbxvAsGN0bG2uopTVOaBWcQhEF7Rbo 2djbZNKG/morGs8JbpTXoT1qJQNT2qk+ZSnITEWyrpDq4z5QMAEDUjlyv11Ur04Eggt2RwIBXUu6W A/C6sp/9Txd/S6Ccsk2Wk6leDXCLcyrlPzi3V/YHsb2yDxmtGpZEBTBxI/pHd2ffMOtMhafcj/YFO OWlyeP5pvDbAiqQGQ8qUAQ==; 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:290983 Archived-At: Ping! Hugo, can you please respond to Stefan's review comments, so we could make progress here? > Cc: 72460@debbugs.gnu.org > Date: Mon, 19 Aug 2024 10:42:43 -0400 > From: Stefan Monnier via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > > I find this sort of thing useful for cases where I want to use > > something other than space as a word separator (e.g. when typing lots > > of function names), or when for a long period I want to use the symbol > > which is usually on the shift of a key (i.e. I know I want to type "+" > > a lot, but not "="). > > Interesting. I can see that `keyboard-translate-table` is indeed > a cheap way to implement it. > > [ This said, it applies at a very low level (directly inside > `read-event`) and only to "characters" (e.g. not to the `tab` or > `return` keys), which can make it both maybe too powerful and yet not > flexible enough. ] > > > + (interactive `(,(key-description `[,(read-char "From: ")]) > > + ,(key-description `[,(read-char "To: ")]))) > > [ Personally, I'd add a comment lamenting the fact that `keymap-*` > functions force us to use `key-description` here only for that to be > undone by `key-parse`. ] > > > +(defcustom key-translate-selection-function #'key-select-translation > > Do we need this? > > > +pair in `keyboard-translate-table', and return a vector containing only > > +the FROM key of the selected pair (e.g. if the selected pair translates > > +\"=\" to \"+\", the function should return the vector [61])" > > Why not return just the char rather than a vector containing the char? > > > +(defun key-translate-remove (from) > > + "Remove translation of FROM from `keyboard-translate-table'. > > + > > +FROM must satisfy `key-valid-p'. If FROM has no entry in > > +`keyboard-translate-table', this has no effect." > > + (interactive (list (key-description > > + (funcall key-translate-selection-function)))) > > + (set-char-table-range > > + keyboard-translate-table (aref (key-parse from) 0) nil)) > > If FROM maps to a sequence of length != 1, we'll either signal an ugly > error or silently ignore the rest. > Any reason why you didn't make FROM be a simple character? > > > Stefan > > > > >