summaryrefslogtreecommitdiff
path: root/src/character.c
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2021-05-26 20:08:47 +0300
committerEli Zaretskii <eliz@gnu.org>2021-05-26 20:08:47 +0300
commit85da7b57bc204c4cc6953156c1a9a4dc6e875541 (patch)
treeb61286d21ea2c58ec76ea4c058beeb9d8d95428b /src/character.c
parentd5d4e826919d4d09a12ecb92dc8658243bdd87ad (diff)
downloademacs-85da7b57bc204c4cc6953156c1a9a4dc6e875541.tar.gz
emacs-85da7b57bc204c4cc6953156c1a9a4dc6e875541.tar.bz2
emacs-85da7b57bc204c4cc6953156c1a9a4dc6e875541.zip
Make 'string-width' auto-composition aware
* src/composite.c (find_automatic_composition): Now extern. (char_composable_p): Don't assume 'unicode-category-table' is always available. * src/composite.h (find_automatic_composition): Add prototype. * src/character.c (lisp_string_width): Support automatic compositions; call 'find_automatic_composition' when 'auto-composition-mode' is ON.
Diffstat (limited to 'src/character.c')
-rw-r--r--src/character.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/character.c b/src/character.c
index 41abb83a48b..e0978bb39fa 100644
--- a/src/character.c
+++ b/src/character.c
@@ -361,6 +361,23 @@ lisp_string_width (Lisp_Object string, ptrdiff_t from, ptrdiff_t to,
chars = end - i;
bytes = string_char_to_byte (string, end) - i_byte;
}
+ else if (!NILP (BVAR (current_buffer, enable_multibyte_characters))
+ && ! NILP (Vauto_composition_mode)
+ && find_automatic_composition (i, -1, &ignore, &end, &val, string)
+ && end > i)
+ {
+ int j;
+ for (thiswidth = 0, j = 0; j < LGSTRING_GLYPH_LEN (val); j++)
+ {
+ Lisp_Object g = LGSTRING_GLYPH (val, j);
+
+ if (NILP (g))
+ break;
+ thiswidth += char_width (LGLYPH_CHAR (g), dp);
+ }
+ chars = end - i;
+ bytes = string_char_to_byte (string, end) - i_byte;
+ }
else
{
int c;