From 03bab768bee56377677b5ff0e49c4cd03972a01a Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Tue, 29 Dec 2020 05:16:25 +0100 Subject: [PATCH] Add a parameter to display_string to allow not ignoring text props * src/xdisp.c (display_string): Add a parameter to allow not ignoring text properties (bug#45520). Adjust callers throughout xdisp.c. --- src/xdisp.c | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/src/xdisp.c b/src/xdisp.c index 6606e49e428..f7b87dcce18 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -1114,7 +1114,8 @@ static ptrdiff_t display_count_lines (ptrdiff_t, ptrdiff_t, ptrdiff_t, static void pint2str (register char *, register int, register ptrdiff_t); static int display_string (const char *, Lisp_Object, Lisp_Object, - ptrdiff_t, ptrdiff_t, struct it *, int, int, int, int); + ptrdiff_t, ptrdiff_t, struct it *, int, int, int, + int, bool); static void compute_line_metrics (struct it *); static void run_redisplay_end_trigger_hook (struct it *); static bool get_overlay_strings (struct it *, ptrdiff_t); @@ -13154,12 +13155,13 @@ display_tab_bar (struct window *w) if (it.current_x < it.last_visible_x) display_string (NULL, string, Qnil, 0, 0, &it, - SCHARS (string), 0, 0, STRING_MULTIBYTE (string)); + SCHARS (string), 0, 0, STRING_MULTIBYTE (string), + TRUE); } /* Fill out the line with spaces. */ if (it.current_x < it.last_visible_x) - display_string ("", Qnil, Qnil, 0, 0, &it, -1, 0, 0, -1); + display_string ("", Qnil, Qnil, 0, 0, &it, -1, 0, 0, -1, TRUE); /* Compute the total height of the lines. */ compute_line_metrics (&it); @@ -25136,12 +25138,13 @@ display_menu_bar (struct window *w) /* Display the item, pad with one space. */ if (it.current_x < it.last_visible_x) display_string (NULL, string, Qnil, 0, 0, &it, - SCHARS (string) + 1, 0, 0, STRING_MULTIBYTE (string)); + SCHARS (string) + 1, 0, 0, STRING_MULTIBYTE (string), + TRUE); } /* Fill out the line with spaces. */ if (it.current_x < it.last_visible_x) - display_string ("", Qnil, Qnil, 0, 0, &it, -1, 0, 0, -1); + display_string ("", Qnil, Qnil, 0, 0, &it, -1, 0, 0, -1, TRUE); /* Compute the total height of the lines. */ compute_line_metrics (&it); @@ -25245,21 +25248,22 @@ display_tty_menu_item (const char *item_text, int width, int face_id, it.paragraph_embedding = L2R; /* Pad with a space on the left. */ - display_string (" ", Qnil, Qnil, 0, 0, &it, 1, 0, FRAME_COLS (f) - 1, -1); + display_string (" ", Qnil, Qnil, 0, 0, &it, 1, 0, FRAME_COLS (f) - 1, -1, + TRUE); width--; /* Display the menu item, pad with spaces to WIDTH. */ if (submenu) { display_string (item_text, Qnil, Qnil, 0, 0, &it, - item_len, 0, FRAME_COLS (f) - 1, -1); + item_len, 0, FRAME_COLS (f) - 1, -1, TRUE); width -= item_len; /* Indicate with " >" that there's a submenu. */ display_string (" >", Qnil, Qnil, 0, 0, &it, width, 0, - FRAME_COLS (f) - 1, -1); + FRAME_COLS (f) - 1, -1, TRUE); } else display_string (item_text, Qnil, Qnil, 0, 0, &it, - width, 0, FRAME_COLS (f) - 1, -1); + width, 0, FRAME_COLS (f) - 1, -1, TRUE); row->used[TEXT_AREA] = max (saved_used, row->used[TEXT_AREA]); row->truncated_on_right_p = saved_truncated; @@ -25469,8 +25473,9 @@ display_mode_line (struct window *w, enum face_id face_id, Lisp_Object format) && window_body_width (XWINDOW (selected_window), FALSE) >= SCHARS (mode_string)) { - display_string (SSDATA (mode_string), Qnil, Qnil, 0, 0, &it, 0, 0, 0, - STRING_MULTIBYTE (mode_string)); + display_string (SSDATA (mode_string), mode_string, Qnil, + 0, 0, &it, 0, 0, 0, + STRING_MULTIBYTE (mode_string), FALSE); } else { @@ -25490,7 +25495,7 @@ display_mode_line (struct window *w, enum face_id face_id, Lisp_Object format) *s = 0; display_string (string, Qnil, Qnil, 0, 0, &it, 0, 0, 0, - STRING_MULTIBYTE (mode_string)); + STRING_MULTIBYTE (mode_string), TRUE); xfree (string); } } @@ -25499,7 +25504,7 @@ display_mode_line (struct window *w, enum face_id face_id, Lisp_Object format) unbind_to (count, Qnil); /* Fill up with spaces. */ - display_string (" ", Qnil, Qnil, 0, 0, &it, 10000, -1, -1, 0); + display_string (" ", Qnil, Qnil, 0, 0, &it, 10000, -1, -1, 0, TRUE); compute_line_metrics (&it); it.glyph_row->full_width_p = true; @@ -25703,7 +25708,7 @@ display_mode_element (struct it *it, int depth, int field_width, int precision, break; case MODE_LINE_DISPLAY: n += display_string (NULL, elt, Qnil, 0, 0, it, - 0, prec, 0, STRING_MULTIBYTE (elt)); + 0, prec, 0, STRING_MULTIBYTE (elt), TRUE); break; } @@ -25765,7 +25770,7 @@ display_mode_element (struct it *it, int depth, int field_width, int precision, nchars = string_byte_to_char (elt, offset) - charpos; n += display_string (NULL, elt, Qnil, 0, charpos, it, 0, nchars, 0, - STRING_MULTIBYTE (elt)); + STRING_MULTIBYTE (elt), TRUE); } break; } @@ -25837,7 +25842,7 @@ display_mode_element (struct it *it, int depth, int field_width, int precision, nwritten = display_string (spec, string, elt, charpos, 0, it, field, prec, 0, - multibyte); + multibyte, TRUE); /* Assign to the glyphs written above the string where the `%x' came from, position @@ -26044,7 +26049,7 @@ display_mode_element (struct it *it, int depth, int field_width, int precision, break; case MODE_LINE_DISPLAY: n += display_string ("", Qnil, Qnil, 0, 0, it, field_width - n, - 0, 0, 0); + 0, 0, 0, TRUE); break; } } @@ -27114,7 +27119,8 @@ display_count_lines (ptrdiff_t start_byte, static int display_string (const char *string, Lisp_Object lisp_string, Lisp_Object face_string, ptrdiff_t face_string_pos, ptrdiff_t start, struct it *it, - int field_width, int precision, int max_x, int multibyte) + int field_width, int precision, int max_x, int multibyte, + bool ignore_text_properties) { int hpos_at_start = it->hpos; int saved_face_id = it->face_id; @@ -27125,7 +27131,8 @@ display_string (const char *string, Lisp_Object lisp_string, Lisp_Object face_st with index START. */ reseat_to_string (it, NILP (lisp_string) ? string : NULL, lisp_string, start, precision, field_width, multibyte); - if (string && STRINGP (lisp_string)) + + if (string && STRINGP (lisp_string) && ignore_text_properties) /* LISP_STRING is the one returned by decode_mode_spec. We should ignore its text properties. */ it->stop_charpos = it->end_charpos; -- 2.39.5