Subject: bug#50865: 28.0.50; Emoji with emoji modifier in Linux console garbles emacs display

From: Aura Kelloniemi <[email-masked]>
Date: Tue, 28 Sep 2021 22:20:58 +0300

On 2021-09-28 at 21:35 +0300, Eli Zaretskii <[email-masked]> wrote:
 > > From: Aura Kelloniemi <[email-masked]>
 > > Cc: [email-masked]
 > > Date: Tue, 28 Sep 2021 20:41:36 +0300
 > > 
 > > utf-8-unix
 > > 
 > > And the Linux console is properly in Unicode mode. (Which means Unicode as it
 > > was understood in 2002 or so.)

 > Which could be too long ago?  Are you saying that the Linux terminal
 > doesn't understand Unicode beyond the year 2002?  That could explain a
 > lot.

More or less. The code point range has been extended to allow for code points
outside of the 16-bit range. Otherwise I haven't seen much development. The
console font can contain at most 512 glyphs, which is a huge limitation.

 > So it sounds like your terminal cannot handle double-width
 > characters.

Yes, that is correct. Sorry, I probably should have said this earlier. The
Linux console does not support extended-width characters.

This is not a problem just with Emacs, but every single program/library that
supports double-width characters, e.g. readline.

 > Those "space characters" you see are padding glyphs
 > output by Emacs when it displays a double-width character.  On my
 > terminal emulator, the results are satisfactory, and I see no
 > artifacts.  Are you sure the spaces you saw aren't just visual
 > surprises, and otherwise don't present any real problems?  If they do
 > present real problems, can you describe them in more detail, including
 > the exact sequence of characters you typed for that?

Cursor movement gets messed up. If I type:

<PERSON WITH FOLDED HANDS> <DIGIT ONE>

the display is correct:

<PERSON WITH FOLDED HANDS> <DIGIT ONE> _cursor_

If I now do C-l, the display looks like:

<PERSON WITH FOLDED HANDS> <DIGIT ONE> <SPACE> _cursor_

If I type BackSpace to delete the digit 1, only the space disappears, so the
display looks like:

<PERSON WITH FOLDED HANDS> <DIGIT ONE> _cursor_

But really the buffer contains only the emoji.

If I now press BackSpace again, both the emoji and the digit disappear, and
the line becomes empty.

If I use arrow keys to move around in the buffer, the cursor is moved by two
columns every time the point moves over a double-width character. But because
the terminal does not show the double-width character as double-wide, the
cursor placement is off by the number of double-width characters on the left
side of the point.

 > > Probably there is no other documentation than the kernel source – or
 > > at least the documentation is outdated. Linux console is kind of
 > > deprecated, but it is still sort of maintained as there is no
 > > alternative being developed.

 > Perhaps you should take this up with the developers, then.  But I'd
 > like to understand better what display problems you saw originally,
 > because all I read there now is that you saw those extra spaces.

I could, but many have done this already. The situation is such that it would
be easier to rewrite the whole console driver from scratch than to try to
extend it with more features. There does not seem to be interest for doing it.

Mostly people use Linux console for emergency maintainance, or then they are
blind and cannot use the graphical desktop, because the accessibility
technology does not support this. I happen to use Linux VT's for both of these
reasons.

I took a look at Emacs's term/linux.el.gz. It sets auto-composition-mode to
"linux". I don't know what this special value does.

-- 
Aura