unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Paul Pogonyshev <pogonyshev@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 43830@debbugs.gnu.org, Juri Linkov <juri@linkov.net>
Subject: bug#43830: keyboard layout handling incompatible with rest of the OS
Date: Wed, 28 Oct 2020 01:43:04 +0100	[thread overview]
Message-ID: <CAG7BpaoPi96irUWr4SPvNLKmTeknxpOEZiX4wzMge8=L8uEKQQ@mail.gmail.com> (raw)
In-Reply-To: <CAG7Bpao-jS-m4ufTzf1zHbWJj0_iPxUsS+BWh-YQQ74wB0YGcg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3683 bytes --]

Apparently what Java does internally is calling function
XkbTranslateKeyCode() to translate 'keycode' that corresponds
to a physical key into a character using the current XKB layout.
And then passes on its own KeyEvent object that contains both
the character and the physical typed key, with downstream
code using either of the two, depending on situation (i.e. when
text is being typed, character is used, when bindings like Alt+X
are activated X states for the physical key, which can also e.g.
type Ч in Russian layout).

However, in Elisp this is further complicated by there being no
real KeyEvent structure, instead it's a single integer as far as I
can see. Since this is not OOP, changing anything here would
mean a thousand incompatibilities all over the place, so it's
easier to just give up and live with the non-perfect workaround
of reverse-im as suggested.

Paul


On Thu, 8 Oct 2020 at 15:58, Paul Pogonyshev <pogonyshev@gmail.com> wrote:

> > The issue is more general than just a single character with a
> > modifier, because key sequences such as "C-x z" will still not
> > work: the 'z' will become the corresponding non-ASCII character
> > when a non-US keyboard layout is used.  Therefore, the only general
> > solution is for Emacs to be aware of the keyboard layout in use,
> > and map the characters internally to their ASCII equivalents using
> > that layout.
>
> Probably yes, I don't know how other applications do it internally.
> As I mentioned, LibreOffice and IDEA (both are probably Java) do
> it somehow, so there is a way. Maybe I'll try to dig through it later,
> since I'm very familiar with Java.
>
> By the way, what I forgot to mention, is that Emacs input modes
> perform exactly like I want (i.e. bind to physical keys, so that C-.
> in Russian works as C-/ in English; also e.g. C-ч й is translated to
> C-x q, so even non-modified characters inside bindings work), but
> they have the advantage of knowing the layout, of course. And,
> as I mentioned, there are two problems with them: 1) I have to
> use C-\ to switch and 2) configuration of `xkb' is bypassed.
>
> Paul
>
>
>
> On Thu, 8 Oct 2020 at 10:49, Eli Zaretskii <eliz@gnu.org> wrote:
>
>> > From: Juri Linkov <juri@linkov.net>
>> > Cc: pogonyshev@gmail.com,  43830@debbugs.gnu.org
>> > Date: Wed, 07 Oct 2020 22:01:47 +0300
>> >
>> > >> We already discussed this 10 years ago, and the conclusion was that
>> > >> it would require too fundamental changes in how Emacs processes
>> keystrokes.
>> > >
>> > > Can you point me to that discussion?
>> >
>> > https://lists.gnu.org/archive/html/emacs-devel/2005-11/msg01237.html
>>
>> Thanks.
>>
>> My take out of that discussion:
>>
>>  . There's a patch in
>>    https://lists.gnu.org/archive/html/emacs-devel/2005-11/msg01384.html
>>    which seems to allow what Paul wanted with single characters with
>>    modifiers, such as C-z or M-s.  That patch has a disadvantage that
>>    it disables AltGr, but if we install that patch as an optional
>>    feature, perhaps the disadvantage is not so bad?
>>
>>  . The issue is more general than just a single character with a
>>    modifier, because key sequences such as "C-x z" will still not
>>    work: the 'z' will become the corresponding non-ASCII character
>>    when a non-US keyboard layout is used.  Therefore, the only general
>>    solution is for Emacs to be aware of the keyboard layout in use,
>>    and map the characters internally to their ASCII equivalents using
>>    that layout.
>>
>> (The discussions also included LEIM features, but I think that is a
>> separate issue.)
>>
>

[-- Attachment #2: Type: text/html, Size: 5263 bytes --]

  reply	other threads:[~2020-10-28  0:43 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-06 15:34 bug#43830: keyboard layout handling incompatible with rest of the OS Paul Pogonyshev
2020-10-06 17:26 ` Eli Zaretskii
2020-10-06 17:48   ` Paul Pogonyshev
2020-10-06 18:00     ` Eli Zaretskii
2020-10-06 18:46 ` Juri Linkov
2020-10-06 18:59   ` Paul Pogonyshev
2020-10-06 20:34     ` Juri Linkov
2020-10-06 21:05       ` Paul Pogonyshev
2020-10-07  8:16         ` Juri Linkov
2020-10-07  8:51           ` Eli Zaretskii
2020-10-07 19:01             ` Juri Linkov
2020-10-08  8:50               ` Eli Zaretskii
2020-10-08 13:58                 ` Paul Pogonyshev
2020-10-28  0:43                   ` Paul Pogonyshev [this message]
2020-10-28 15:06                     ` Eli Zaretskii
2020-10-28 16:16                       ` Paul Pogonyshev
2020-10-28 16:31                         ` Eli Zaretskii
2020-11-01  0:19                           ` Paul Pogonyshev
2020-11-01 15:09                             ` Eli Zaretskii
2020-11-01  7:53                         ` Juri Linkov
2020-11-01 15:11                           ` Eli Zaretskii
2020-11-01 18:27                             ` Juri Linkov
2020-11-01 18:49                               ` Eli Zaretskii
2020-11-01 16:51                           ` Paul Pogonyshev
2020-11-01 17:24                             ` Eli Zaretskii
2020-11-01 18:56                               ` Paul Pogonyshev
2020-11-01 19:32                                 ` Eli Zaretskii
2020-11-01 20:06                                   ` Paul Pogonyshev
2020-11-02  4:41                                   ` Arthur Miller
2020-11-02 15:38                                     ` Eli Zaretskii
2020-11-01  7:48                   ` Juri Linkov
2020-10-07 10:37           ` Paul Pogonyshev
2020-10-07 19:04             ` Juri Linkov
2020-10-07 20:08               ` Paul Pogonyshev
2020-10-07 20:25                 ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAG7BpaoPi96irUWr4SPvNLKmTeknxpOEZiX4wzMge8=L8uEKQQ@mail.gmail.com' \
    --to=pogonyshev@gmail.com \
    --cc=43830@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=juri@linkov.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).