From 62831e7c3ff97c00474d2fcf41866d45afb3a153 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Tue, 22 Sep 2015 19:33:47 +0300 Subject: [PATCH] Fix 'current-column' in presence of :relative-width * src/indent.c (check_display_width): Support ':relative-width' in a display spec that specifies a stretch glyph. (Bug#21533) --- src/indent.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/indent.c b/src/indent.c index ded18439fd9..584f2179bc5 100644 --- a/src/indent.c +++ b/src/indent.c @@ -485,7 +485,9 @@ check_display_width (ptrdiff_t pos, ptrdiff_t col, ptrdiff_t *endpos) : MOST_POSITIVE_FIXNUM); if ((prop = Fplist_get (plist, QCwidth), - RANGED_INTEGERP (0, prop, INT_MAX))) + RANGED_INTEGERP (0, prop, INT_MAX)) + || (prop = Fplist_get (plist, QCrelative_width), + RANGED_INTEGERP (0, prop, INT_MAX))) width = XINT (prop); else if (FLOATP (prop) && 0 <= XFLOAT_DATA (prop) && XFLOAT_DATA (prop) <= INT_MAX) @@ -504,6 +506,18 @@ check_display_width (ptrdiff_t pos, ptrdiff_t col, ptrdiff_t *endpos) *endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); else get_property_and_range (pos, Qdisplay, &val, &start, endpos, Qnil); + + /* For :relative-width, we need to multiply by the column + width of the character at POS, if it is greater than 1. */ + if (!NILP (Fplist_get (plist, QCrelative_width)) + && !NILP (BVAR (current_buffer, enable_multibyte_characters))) + { + int b, wd; + unsigned char *p = BYTE_POS_ADDR (CHAR_TO_BYTE (pos)); + + MULTIBYTE_BYTES_WIDTH (p, buffer_display_table (), b, wd); + width *= wd; + } return width; } } -- 2.39.2