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

From: Eli Zaretskii <[email-masked]>
Date: Mon, 04 Oct 2021 16:15:45 +0300

> From: Aura Kelloniemi <[email-masked]>
> Cc: [email-masked]
> Date: Mon, 04 Oct 2021 15:25:23 +0300
> 
> The solution of modifying char-width-table at least worked very well for me.
> Of course I am intetrested in the things that will break, if I use it, but
> most likely those will be smaller annoyances than a garbled display.
> 
> I can document this hack on emacs wiki, if nothing else can be done.

I don't recommend documenting such a "solution", because
char-width-table affects more than just the display of wide
characters, it also affects Lisp programs that use string-width and
similar functions.

>  > Emacs relies on the terminal to display characters correctly, using 2
>  > columns (with padding by empty space) when the character is
>  > double-width.  If the terminal doesn't live up to these expectations,
>  > the display will become garbled.
> 
> Couldn't emacs add a padding space after every two-column character.

It could, but for which characters and under what conditions?  Who can
produce a full comprehensive description of the problems related to
character width that are inherent in the Linux console?

Anyway, patches to cater to the Linux console will be welcome, if
someone can come up with a method to DTRT.  The problem is that the
changes will need to be on the C level, where we currently simply use
fwrite to output the (UTF-8) encoded text to the device.  Padding
would mean we'd need to write it character by character, or introduce
some logic that looks for the problematic characters and outputs them
specially.

> Emacs already kind of adds a padding space if I type characters one at a time
> (because it repositions the cursor after every command)

No, Emacs doesn't add any padding when it writes to the terminal, at
least AFAICS.  It simply relies on the terminal to produce a 2-column
glyph for a wide character, and positions the cursor accordingly.
Positioning the cursor doesn't in general write a space to the device,
it just outputs a terminfo sequence for cursor addressing.