Subject: Re: bug#43830: keyboard layout handling incompatible with rest of the OS

From: Paul Pogonyshev <[email-masked]>
Date: Tue, 6 Oct 2020 19:48:05 +0200

> Do you know how to retrieve the key code corresponding to the English
> keyboard layout when the active layout is something else, like
> Russian?

No, but there must be a way, because both GTK+ and KDE know how to do
this. GTK+ also can do this when run under KDE, so I'm pretty sure the
information itself comes from X (xkb), not e.g. from GNOME configuration.
No idea about the other way round, but I guess it also works.

> Or maybe the keyboard driver can be configured to return ASCII
> characters when the Ctrl key is held, even when the layout is
> non-English?

Not sure what you mean here, but certainly it doesn't need to be configured
by the user. Maybe by the application/framework (i.e. KDE, GTK+ or Emacs).

> A workaround is to bind C-ы to the same command as C-s (and similarly
> with other combinations that matter).

This is not feasible because Emacs has hundreds of shortcuts coming from
all sorts of places (the core, major and minor modes, my config and so on).
It's certainly not just about C-s.

By the way, same goes for shortcuts/keybindings even without modifiers.
E.g. I have my own keybinding <f12 s> to switch to *scratch* buffer.
<f12 ы> is, predictably, "undefined". However, if using Emacs' own Russian
input method, it works just like <f12 s>, even though the key on itself
types "ы".

Paul

On Tue, 6 Oct 2020 at 19:26, Eli Zaretskii <[email-masked]> wrote:

> > From: Paul Pogonyshev <[email-masked]>
> > Date: Tue, 6 Oct 2020 17:34:34 +0200
> >
> > I use English and Russian keyboard layouts. For every single application
> I don't need to care which layout is
> > currently selected for shortcuts, e.g. Ctrl+S and Ctrl+Ы do the same (S
> and Ы are on the same physical
> > key). Of course, in Emacs it doesn't work this way: C-s triggers
> Isearch, but C-ы "is undefined".
>
> Do you know how to retrieve the key code corresponding to the English
> keyboard layout when the active layout is something else, like
> Russian?  Does someone else here know?
>
> Or maybe the keyboard driver can be configured to return ASCII
> characters when the Ctrl key is held, even when the layout is
> non-English?
>
> What Emacs does, AFAICT, when a key press event comes in is call the
> Xlib function that returns the character produced by the keyboard, and
> that character depends on the current keyboard layout.  We then add
> the modifier keys to that character.  I don't see the "original"
> English-layout character available anywhere in that code, but maybe
> I'm missing something.
>
> A workaround is to bind C-ы to the same command as C-s (and similarly
> with other combinations that matter).
>