Subject: bug#72460: [patch] add commands for setting keyboard translations interactively

From: Eli Zaretskii <[email-masked]>
Date: Sat, 31 Aug 2024 11:08:02 +0300

Ping! Hugo, can you please respond to Stefan's review comments, so we
could make progress here?

> Cc: [email-masked]
> 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" <[email-masked]>
> 
> > 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
> 
> 
> 
> 
>