From: Eli Zaretskii Date: Fri, 2 Aug 2024 06:48:55 +0000 (+0300) Subject: Fix display of empty margins when default face is remapped X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=fb3364f7ab2165a9b740c1784d7824837f9ad742;p=emacs.git Fix display of empty margins when default face is remapped * src/xdisp.c (display_line): Append space glyphs to margin areas if the default face is remapped and nothing is written to the margin area of this screen line. (produce_special_glyphs): If the truncation/continuation glyphs do not specify a face, use the remapped default face, not the original frame-global default face. Reported by Nicolas P. Rougier in https://lists.gnu.org/archive/html/emacs-devel/2024-07/msg01217.html. (cherry picked from commit 80108438e5e2e95ca75e59212fb1669a723241b5) --- diff --git a/src/xdisp.c b/src/xdisp.c index a8f9f59b654..491ce9cc970 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -25961,6 +25961,18 @@ display_line (struct it *it, int cursor_vpos) } it->hpos = hpos_before; } + /* If the default face is remapped, and the window has + display margins, and no glyphs were written yet to the + margins on this screen line, we must add one space + glyph to the margin area to make sure the margins use + the background of the remapped default face. */ + if (lookup_basic_face (it->w, it->f, DEFAULT_FACE_ID) + != DEFAULT_FACE_ID /* default face is remapped */ + && ((WINDOW_LEFT_MARGIN_WIDTH (it->w) > 0 + && it->glyph_row->used[LEFT_MARGIN_AREA] == 0) + || (WINDOW_RIGHT_MARGIN_WIDTH (it->w) > 0 + && it->glyph_row->used[RIGHT_MARGIN_AREA] == 0))) + extend_face_to_end_of_line (it); } else if (IT_OVERFLOW_NEWLINE_INTO_FRINGE (it)) { @@ -32179,6 +32191,8 @@ produce_special_glyphs (struct it *it, enum display_element_type what) struct it temp_it; Lisp_Object gc; GLYPH glyph; + /* Take face-remapping into consideration. */ + int face_id = lookup_basic_face (it->w, it->f, DEFAULT_FACE_ID); temp_it = *it; temp_it.object = Qnil; @@ -32188,27 +32202,27 @@ produce_special_glyphs (struct it *it, enum display_element_type what) { /* Continuation glyph. For R2L lines, we mirror it by hand. */ if (it->bidi_it.paragraph_dir == R2L) - SET_GLYPH_FROM_CHAR (glyph, '/'); + SET_GLYPH (glyph, '/', face_id); else - SET_GLYPH_FROM_CHAR (glyph, '\\'); + SET_GLYPH (glyph, '\\', face_id); if (it->dp && (gc = DISP_CONTINUE_GLYPH (it->dp), GLYPH_CODE_P (gc))) { /* FIXME: Should we mirror GC for R2L lines? */ SET_GLYPH_FROM_GLYPH_CODE (glyph, gc); - spec_glyph_lookup_face (XWINDOW (it->window), &glyph); + spec_glyph_lookup_face (it->w, &glyph); } } else if (what == IT_TRUNCATION) { /* Truncation glyph. */ - SET_GLYPH_FROM_CHAR (glyph, '$'); + SET_GLYPH (glyph, '$', face_id); if (it->dp && (gc = DISP_TRUNC_GLYPH (it->dp), GLYPH_CODE_P (gc))) { /* FIXME: Should we mirror GC for R2L lines? */ SET_GLYPH_FROM_GLYPH_CODE (glyph, gc); - spec_glyph_lookup_face (XWINDOW (it->window), &glyph); + spec_glyph_lookup_face (it->w, &glyph); } } else