aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJimmy Aguilar Mena2019-05-03 19:27:59 +0200
committerJimmy Aguilar Mena2019-05-05 16:27:37 +0200
commita336300ccf024824fbf50298623e04f369952670 (patch)
tree72671b0528a1091d635fc0cb605607ec07f5fbf3 /src
parent5b842bd7820b952d65c480b856354a67d26f5b57 (diff)
downloademacs-a336300ccf024824fbf50298623e04f369952670.tar.gz
emacs-a336300ccf024824fbf50298623e04f369952670.zip
;Corrected display-fill-column-indicator mode.
Small corrections in the documentation and code format to merge into master.
Diffstat (limited to 'src')
-rw-r--r--src/xdisp.c93
1 files changed, 48 insertions, 45 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index 080c40c3f38..17827481447 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -379,11 +379,14 @@ static Lisp_Object list_of_error;
379 || *BYTE_POS_ADDR (IT_BYTEPOS (*it)) == '\t')))) \ 379 || *BYTE_POS_ADDR (IT_BYTEPOS (*it)) == '\t')))) \
380 380
381/* Test all the conditions needed to print the fill column indicator. */ 381/* Test all the conditions needed to print the fill column indicator. */
382#define FILL_COLUMN_INDICATOR_NEEDED(it) \ 382#define FILL_COLUMN_INDICATOR_NEEDED(it) \
383 !NILP (Vdisplay_fill_column_indicator) \ 383 Vdisplay_fill_column_indicator \
384 && (it->continuation_lines_width == 0) \ 384 && (it->continuation_lines_width == 0) \
385 && (!NILP (Vdisplay_fill_column_indicator_column)) \ 385 && (!NILP (Vdisplay_fill_column_indicator_column)) \
386 && FIXNATP (Vdisplay_fill_column_indicator_character) 386 && FIXNATP (Vdisplay_fill_column_indicator_character) \
387 && ((EQ (Vdisplay_fill_column_indicator_column, Qt) \
388 && FIXNATP (BVAR (current_buffer, fill_column))) \
389 || (FIXNATP (Vdisplay_fill_column_indicator_column)))
387 390
388/* True means print newline to stdout before next mini-buffer message. */ 391/* True means print newline to stdout before next mini-buffer message. */
389 392
@@ -20168,17 +20171,16 @@ append_space_for_newline (struct it *it, bool default_face_p)
20168 20171
20169 /* Corner case for when display-fill-column-indicator-mode 20172 /* Corner case for when display-fill-column-indicator-mode
20170 is active and the extra character should be added in the 20173 is active and the extra character should be added in the
20171 same place than the line */ 20174 same place than the line. */
20172 if ((it->w->pseudo_window_p == 0) 20175 if ((it->w->pseudo_window_p == 0)
20173 && FILL_COLUMN_INDICATOR_NEEDED(it)) 20176 && FILL_COLUMN_INDICATOR_NEEDED(it))
20174 { 20177 {
20175 int fill_column_indicator_column = -1; 20178 int fill_column_indicator_column = -1;
20176 20179
20177 if (EQ (Vdisplay_fill_column_indicator_column, Qt) 20180 if (EQ (Vdisplay_fill_column_indicator_column, Qt))
20178 && FIXNATP (BVAR (current_buffer, fill_column)))
20179 fill_column_indicator_column = 20181 fill_column_indicator_column =
20180 XFIXNAT (BVAR (current_buffer, fill_column)); 20182 XFIXNAT (BVAR (current_buffer, fill_column));
20181 else if (FIXNATP (Vdisplay_fill_column_indicator_column)) 20183 else
20182 fill_column_indicator_column = 20184 fill_column_indicator_column =
20183 XFIXNAT (Vdisplay_fill_column_indicator_column); 20185 XFIXNAT (Vdisplay_fill_column_indicator_column);
20184 20186
@@ -20198,7 +20200,7 @@ append_space_for_newline (struct it *it, bool default_face_p)
20198 it->c = it->char_to_display = 20200 it->c = it->char_to_display =
20199 XFIXNAT (Vdisplay_fill_column_indicator_character); 20201 XFIXNAT (Vdisplay_fill_column_indicator_character);
20200 it->face_id = 20202 it->face_id =
20201 merge_faces (it->w, Qfill_column_face, 20203 merge_faces (it->w, Qfill_column_indicator,
20202 0, DEFAULT_FACE_ID); 20204 0, DEFAULT_FACE_ID);
20203 face = FACE_FROM_ID(it->f, it->face_id); 20205 face = FACE_FROM_ID(it->f, it->face_id);
20204 goto produce_glyphs; 20206 goto produce_glyphs;
@@ -20221,8 +20223,8 @@ append_space_for_newline (struct it *it, bool default_face_p)
20221 set. */ 20223 set. */
20222 if (it->glyph_row->reversed_p 20224 if (it->glyph_row->reversed_p
20223 /* But if the appended newline glyph goes all the way to 20225 /* But if the appended newline glyph goes all the way to
20224 the end of the row, there will be no stretch glyph, 20226 the end of the row, there will be no stretch glyph,
20225 so leave the box flag set. */ 20227 so leave the box flag set. */
20226 && saved_x + FRAME_COLUMN_WIDTH (it->f) < it->last_visible_x) 20228 && saved_x + FRAME_COLUMN_WIDTH (it->f) < it->last_visible_x)
20227 it->end_of_box_run_p = false; 20229 it->end_of_box_run_p = false;
20228 20230
@@ -20376,7 +20378,7 @@ extend_face_to_end_of_line (struct it *it)
20376 && !face->stipple 20378 && !face->stipple
20377#endif 20379#endif
20378 && !it->glyph_row->reversed_p 20380 && !it->glyph_row->reversed_p
20379 && NILP (Vdisplay_fill_column_indicator)) 20381 && !Vdisplay_fill_column_indicator)
20380 return; 20382 return;
20381 20383
20382 /* Set the glyph row flag indicating that the face of the last glyph 20384 /* Set the glyph row flag indicating that the face of the last glyph
@@ -20431,17 +20433,16 @@ extend_face_to_end_of_line (struct it *it)
20431 20433
20432 /* Display fill column indicator if not in modeline or 20434 /* Display fill column indicator if not in modeline or
20433 toolbar and display fill column indicator mode is 20435 toolbar and display fill column indicator mode is
20434 active */ 20436 active. */
20435 if ((it->w->pseudo_window_p == 0) 20437 if ((it->w->pseudo_window_p == 0)
20436 && FILL_COLUMN_INDICATOR_NEEDED(it)) 20438 && FILL_COLUMN_INDICATOR_NEEDED(it))
20437 { 20439 {
20438 int fill_column_indicator_column = -1; 20440 int fill_column_indicator_column = -1;
20439 20441
20440 if (EQ (Vdisplay_fill_column_indicator_column, Qt) 20442 if (EQ (Vdisplay_fill_column_indicator_column, Qt))
20441 && FIXNATP (BVAR (current_buffer, fill_column)))
20442 fill_column_indicator_column = 20443 fill_column_indicator_column =
20443 XFIXNAT (BVAR (current_buffer, fill_column)); 20444 XFIXNAT (BVAR (current_buffer, fill_column));
20444 else if (FIXNATP (Vdisplay_fill_column_indicator_column)) 20445 else
20445 fill_column_indicator_column = 20446 fill_column_indicator_column =
20446 XFIXNAT (Vdisplay_fill_column_indicator_column); 20447 XFIXNAT (Vdisplay_fill_column_indicator_column);
20447 20448
@@ -20466,7 +20467,7 @@ extend_face_to_end_of_line (struct it *it)
20466 Lisp_Object save_object = it->object; 20467 Lisp_Object save_object = it->object;
20467 20468
20468 /* The stretch width needs to considet the latter 20469 /* The stretch width needs to considet the latter
20469 added glyph */ 20470 added glyph. */
20470 const int stretch_width = 20471 const int stretch_width =
20471 column_x - it->current_x - char_width; 20472 column_x - it->current_x - char_width;
20472 20473
@@ -20474,34 +20475,35 @@ extend_face_to_end_of_line (struct it *it)
20474 it->avoid_cursor_p = true; 20475 it->avoid_cursor_p = true;
20475 it->object = Qnil; 20476 it->object = Qnil;
20476 20477
20477 /* Only generate a stretch glysph if there is distance 20478 /* Only generate a stretch glyph if there is distance
20478 between current_x and and the indicator position */ 20479 between current_x and and the indicator position. */
20479 if (stretch_width > 0) 20480 if (stretch_width > 0)
20480 { 20481 {
20481 int stretch_ascent = (((it->ascent + it->descent) 20482 int stretch_ascent = (((it->ascent + it->descent)
20482 * FONT_BASE (font)) / FONT_HEIGHT (font)); 20483 * FONT_BASE (font)) / FONT_HEIGHT (font));
20483 append_stretch_glyph (it, Qnil, stretch_width, 20484 append_stretch_glyph (it, Qnil, stretch_width,
20484 it->ascent + it->descent, 20485 it->ascent + it->descent,
20485 stretch_ascent); 20486 stretch_ascent);
20486 } 20487 }
20487 20488
20488 /* Generate the glysph indicator only if 20489 /* Generate the glyph indicator only if
20489 append_space_for_newline didn't already. */ 20490 append_space_for_newline didn't already. */
20490 if (it->current_x < column_x) 20491 if (it->current_x < column_x)
20491 { 20492 {
20492 it->char_to_display = 20493 it->char_to_display =
20493 XFIXNAT (Vdisplay_fill_column_indicator_character); 20494 XFIXNAT (Vdisplay_fill_column_indicator_character);
20494 it->face_id = 20495 it->face_id =
20495 merge_faces (it->w, Qfill_column_face, 20496 merge_faces (it->w, Qfill_column_indicator,
20496 0, DEFAULT_FACE_ID); 20497 0, DEFAULT_FACE_ID);
20497 PRODUCE_GLYPHS (it); 20498 PRODUCE_GLYPHS (it);
20498 } 20499 }
20499 20500
20500 /* Restore the face after the indicator was generated */ 20501 /* Restore the face after the indicator was generated. */
20501 it->face_id = saved_face_id; 20502 it->face_id = saved_face_id;
20502 20503
20503 /* If there is space after the indicator generate an 20504 /* If there is space after the indicator generate an
20504 extra empty glysph to restore the face. */ 20505 extra empty glyph to restore the face. Issue was
20506 observed in X systems. */
20505 it->char_to_display = ' '; 20507 it->char_to_display = ' ';
20506 PRODUCE_GLYPHS (it); 20508 PRODUCE_GLYPHS (it);
20507 20509
@@ -20514,14 +20516,13 @@ extend_face_to_end_of_line (struct it *it)
20514 } 20516 }
20515 } 20517 }
20516#ifdef HAVE_WINDOW_SYSTEM 20518#ifdef HAVE_WINDOW_SYSTEM
20517
20518 if (it->glyph_row->reversed_p) 20519 if (it->glyph_row->reversed_p)
20519 { 20520 {
20520 /* Prepend a stretch glyph to the row, such that the 20521 /* Prepend a stretch glyph to the row, such that the
20521 rightmost glyph will be drawn flushed all the way to the 20522 rightmost glyph will be drawn flushed all the way to the
20522 right margin of the window. The stretch glyph that will 20523 right margin of the window. The stretch glyph that will
20523 occupy the empty space, if any, to the left of the 20524 occupy the empty space, if any, to the left of the
20524 glyphs. */ 20525 glyph. */
20525 struct font *font = face->font ? face->font : FRAME_FONT (f); 20526 struct font *font = face->font ? face->font : FRAME_FONT (f);
20526 struct glyph *row_start = it->glyph_row->glyphs[TEXT_AREA]; 20527 struct glyph *row_start = it->glyph_row->glyphs[TEXT_AREA];
20527 struct glyph *row_end = row_start + it->glyph_row->used[TEXT_AREA]; 20528 struct glyph *row_end = row_start + it->glyph_row->used[TEXT_AREA];
@@ -20635,18 +20636,19 @@ extend_face_to_end_of_line (struct it *it)
20635 else 20636 else
20636 it->face_id = face->id; 20637 it->face_id = face->id;
20637 20638
20638 /* Display fill-column-line if needed. */ 20639 /* Display fill-column indicator if needed. */
20639 if (FILL_COLUMN_INDICATOR_NEEDED(it)) 20640 if (FILL_COLUMN_INDICATOR_NEEDED(it))
20640 { 20641 {
20641 int fill_column_indicator_column = -1; 20642 int fill_column_indicator_column = -1;
20642 20643
20643 /* Vdisplay_fill_column_indicator_column accepts the special 20644 /* Vdisplay_fill_column_indicator_column accepts the special
20644 value t to use the default fill-column variable. */ 20645 value t to use the default fill-column variable. The
20645 if (EQ (Vdisplay_fill_column_indicator_column, Qt) 20646 conditions are all defined in the macro
20646 && FIXNATP (BVAR (current_buffer, fill_column))) 20647 FILL_COLUMN_INDICATOR_NEEDED. */
20648 if (EQ (Vdisplay_fill_column_indicator_column, Qt))
20647 fill_column_indicator_column = 20649 fill_column_indicator_column =
20648 XFIXNAT (BVAR (current_buffer, fill_column)) + it->lnum_pixel_width; 20650 XFIXNAT (BVAR (current_buffer, fill_column)) + it->lnum_pixel_width;
20649 else if (FIXNATP (Vdisplay_fill_column_indicator_column)) 20651 else
20650 fill_column_indicator_column = 20652 fill_column_indicator_column =
20651 XFIXNAT (Vdisplay_fill_column_indicator_column) + it->lnum_pixel_width; 20653 XFIXNAT (Vdisplay_fill_column_indicator_column) + it->lnum_pixel_width;
20652 20654
@@ -20656,7 +20658,7 @@ extend_face_to_end_of_line (struct it *it)
20656 { 20658 {
20657 const int saved_face = it->face_id; 20659 const int saved_face = it->face_id;
20658 it->face_id = 20660 it->face_id =
20659 merge_faces (it->w, Qfill_column_face, 0, DEFAULT_FACE_ID); 20661 merge_faces (it->w, Qfill_column_indicator, 0, DEFAULT_FACE_ID);
20660 it->c = it->char_to_display = 20662 it->c = it->char_to_display =
20661 XFIXNAT (Vdisplay_fill_column_indicator_character); 20663 XFIXNAT (Vdisplay_fill_column_indicator_character);
20662 PRODUCE_GLYPHS (it); 20664 PRODUCE_GLYPHS (it);
@@ -32839,8 +32841,8 @@ be let-bound around code that needs to disable messages temporarily. */);
32839 /* Name of a text property which disables line-number display. */ 32841 /* Name of a text property which disables line-number display. */
32840 DEFSYM (Qdisplay_line_numbers_disable, "display-line-numbers-disable"); 32842 DEFSYM (Qdisplay_line_numbers_disable, "display-line-numbers-disable");
32841 32843
32842 /* Names of the face used to display fill column indicator character. */ 32844 /* Name of the face used to display fill column indicator character. */
32843 DEFSYM (Qfill_column_face, "fill-column-face"); 32845 DEFSYM (Qfill_column_indicator, "fill-column-indicator");
32844 32846
32845 /* Name and number of the face used to highlight escape glyphs. */ 32847 /* Name and number of the face used to highlight escape glyphs. */
32846 DEFSYM (Qescape_glyph, "escape-glyph"); 32848 DEFSYM (Qescape_glyph, "escape-glyph");
@@ -33414,25 +33416,26 @@ either `relative' or `visual'. */);
33414 DEFSYM (Qdisplay_line_numbers_widen, "display-line-numbers-widen"); 33416 DEFSYM (Qdisplay_line_numbers_widen, "display-line-numbers-widen");
33415 Fmake_variable_buffer_local (Qdisplay_line_numbers_widen); 33417 Fmake_variable_buffer_local (Qdisplay_line_numbers_widen);
33416 33418
33417 DEFVAR_LISP ("display-fill-column-indicator", Vdisplay_fill_column_indicator, 33419 DEFVAR_BOOL ("display-fill-column-indicator", Vdisplay_fill_column_indicator,
33418 doc: /* Non-nil means display the fill column indicator. */); 33420 doc: /* Non-nil means display the fill column indicator. */);
33419 Vdisplay_fill_column_indicator = Qnil; 33421 Vdisplay_fill_column_indicator = false;
33420 DEFSYM (Qdisplay_fill_column_indicator, "display-fill-column-indicator"); 33422 DEFSYM (Qdisplay_fill_column_indicator, "display-fill-column-indicator");
33421 Fmake_variable_buffer_local (Qdisplay_fill_column_indicator); 33423 Fmake_variable_buffer_local (Qdisplay_fill_column_indicator);
33422 33424
33423 DEFVAR_LISP ("display-fill-column-indicator-column", Vdisplay_fill_column_indicator_column, 33425 DEFVAR_LISP ("display-fill-column-indicator-column", Vdisplay_fill_column_indicator_column,
33424 doc: /* Column for indicator when `display-fill-column-indicator' is non-nil. 33426 doc: /* Column for indicator when `display-fill-column-indicator'
33425The default value is t which means that the indicator will use the `fill-column' variable. 33427is non-nil. The default value is t which means that the indicator
33426If a numeric value is set, the indicator will be drawn in that column 33428will use the `fill-column' variable. If it is set to an integer the
33427independently of the `fill-column' value. */); 33429indicator will be drawn in that column. */);
33428 Vdisplay_fill_column_indicator_column = Qt; 33430 Vdisplay_fill_column_indicator_column = Qt;
33429 DEFSYM (Qdisplay_fill_column_indicator_column, "display-fill-column-indicator-column"); 33431 DEFSYM (Qdisplay_fill_column_indicator_column, "display-fill-column-indicator-column");
33430 Fmake_variable_buffer_local (Qdisplay_fill_column_indicator_column); 33432 Fmake_variable_buffer_local (Qdisplay_fill_column_indicator_column);
33431 33433
33432 DEFVAR_LISP ("display-fill-column-indicator-character", Vdisplay_fill_column_indicator_character, 33434 DEFVAR_LISP ("display-fill-column-indicator-character", Vdisplay_fill_column_indicator_character,
33433 doc: /* Character to draw the indicator when `display-fill-column-indicator' is non-nil. 33435 doc: /* Character to draw the indicator when
33434The default is U+2502 but a good alternative is (ascii 124) if 33436`display-fill-column-indicator' is non-nil. The default is U+2502 but
33435the font in fill-column-face does not support Unicode characters. */); 33437a good alternative is (ascii 124) if the font in fill-column-indicator
33438face does not support Unicode characters. */);
33436 Vdisplay_fill_column_indicator_character = Qnil; 33439 Vdisplay_fill_column_indicator_character = Qnil;
33437 DEFSYM (Qdisplay_fill_column_indicator_character, "display-fill-column-indicator-character"); 33440 DEFSYM (Qdisplay_fill_column_indicator_character, "display-fill-column-indicator-character");
33438 Fmake_variable_buffer_local (Qdisplay_fill_column_indicator_character); 33441 Fmake_variable_buffer_local (Qdisplay_fill_column_indicator_character);