Re: [PATCH] emoji on TUI emacs
Kai Ma <[email protected]> Sun, 09 Aug 2026 22:08:15 +0200
| Newsgroups | gmane.emacs.devel |
|---|---|
| Message-ID | <[email protected]> |
Kai Ma <[email protected]> writes: > Thanks. Please find the updated patch series below. > > Eli Zaretskii <[email protected]> writes: > >>> However, the column number change due to C-f, C-b, etc. is still the >>> total sum of CHARACTER_WIDTH (not necessarily 2). Do we want to change >>> it as well? >> >> Yes, definitely. current-column and move-to-column should both work >> correctly in these cases. > > Fixed. Previously in composition_update_it, the width is computed by > summing character widths. I'm not entirely sure whether it's correct to > sum glyph widths here. Apparently, this is incorrect, and it crashes for me occasionally because nglyphs != nchars in general. Here is a new patch that supersedes the wrong one. It reuses 'composition_gstring_width' as cmp_it->width for automatic compositions.
0005-Use-the-gstring-width-as-the-width-of-an-automatic-c.patch
(text/x-diff, 1.1 KB)
From 0dc2fe4c982a2681d13cbf0c6d1f2a10ac0151a0 Mon Sep 17 00:00:00 2001 From: Kai Ma <[email protected]> Date: Sun, 9 Aug 2026 19:44:49 +0200 Subject: [PATCH 5/6] Use the gstring width as the width of an automatic composition. * src/composite.c (composition_update_it): set the width of an automatic composition using composition_gstring_width. --- src/composite.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/composite.c b/src/composite.c index 55841d08cb5..b4706015c32 100644 --- a/src/composite.c +++ b/src/composite.c @@ -1535,12 +1535,12 @@ composition_update_it (struct composition_it *cmp_it, ptrdiff_t charpos, ptrdiff glyph = LGSTRING_GLYPH (gstring, cmp_it->from); cmp_it->nchars = LGLYPH_TO (glyph) + 1 - from; cmp_it->nbytes = 0; - cmp_it->width = 0; + cmp_it->width = composition_gstring_width (gstring, cmp_it->from, cmp_it->to, NULL); + for (i = cmp_it->nchars - 1; i >= 0; i--) { c = XFIXNUM (LGSTRING_CHAR (gstring, from + i)); cmp_it->nbytes += CHAR_BYTES (c); - cmp_it->width += CHARACTER_WIDTH (c); } } return c; -- 2.53.0