From a76cafea0d55cc8df2a2c3556a628dac83762d9a Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Fri, 8 May 2020 13:35:34 +0300 Subject: Fix handling of FROM = t and TO = t by 'window-text-pixel-size' * src/xdisp.c (Fwindow_text_pixel_size): Use byte position for accessing buffer text, not character positions. (Bug#41125) --- src/xdisp.c | 53 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/xdisp.c b/src/xdisp.c index 19f4f326186..c15dd4770ae 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -10442,7 +10442,7 @@ include the height of both, if present, in the return value. */) struct buffer *b; struct it it; struct buffer *old_b = NULL; - ptrdiff_t start, end, pos; + ptrdiff_t start, end, bpos; struct text_pos startp; void *itdata = NULL; int c, max_x = 0, max_y = 0, x = 0, y = 0; @@ -10457,32 +10457,56 @@ include the height of both, if present, in the return value. */) } if (NILP (from)) - start = BEGV; + { + start = BEGV; + bpos = BEGV_BYTE; + } else if (EQ (from, Qt)) { - start = pos = BEGV; - while ((pos++ < ZV) && (c = FETCH_CHAR (pos)) - && (c == ' ' || c == '\t' || c == '\n' || c == '\r')) - start = pos; - while ((pos-- > BEGV) && (c = FETCH_CHAR (pos)) && (c == ' ' || c == '\t')) - start = pos; + start = BEGV; + bpos = BEGV_BYTE; + while (bpos < ZV_BYTE) + { + FETCH_CHAR_ADVANCE (c, start, bpos); + if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r')) + break; + } + while (bpos > BEGV_BYTE) + { + DEC_BOTH (start, bpos); + c = FETCH_CHAR (bpos); + if (!(c == ' ' || c == '\t')) + break; + } } else { CHECK_FIXNUM_COERCE_MARKER (from); start = min (max (XFIXNUM (from), BEGV), ZV); + bpos = CHAR_TO_BYTE (start); } + SET_TEXT_POS (startp, start, bpos); + if (NILP (to)) end = ZV; else if (EQ (to, Qt)) { - end = pos = ZV; - while ((pos-- > BEGV) && (c = FETCH_CHAR (pos)) - && (c == ' ' || c == '\t' || c == '\n' || c == '\r')) - end = pos; - while ((pos++ < ZV) && (c = FETCH_CHAR (pos)) && (c == ' ' || c == '\t')) - end = pos; + end = ZV; + bpos = ZV_BYTE; + while (bpos > BEGV_BYTE) + { + DEC_BOTH (end, bpos); + c = FETCH_CHAR (bpos); + if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r')) + break; + } + while (bpos < ZV_BYTE) + { + FETCH_CHAR_ADVANCE (c, end, bpos); + if (!(c == ' ' || c == '\t')) + break; + } } else { @@ -10499,7 +10523,6 @@ include the height of both, if present, in the return value. */) max_y = XFIXNUM (y_limit); itdata = bidi_shelve_cache (); - SET_TEXT_POS (startp, start, CHAR_TO_BYTE (start)); start_display (&it, w, startp); /* It makes no sense to measure dimensions of region of text that crosses the point where bidi reordering changes scan direction. -- cgit v1.3 From d5c184aa3e2a183144efa5f269e2c70d2681aa0a Mon Sep 17 00:00:00 2001 From: Philipp Stephani Date: Sat, 9 May 2020 10:20:47 +0200 Subject: Refer to fill column indicator Info node in some places. * src/xdisp.c (syms_of_xdisp): Add reference to manual in documentation strings for variables related to fill column indicators. * lisp/display-fill-column-indicator.el (display-fill-column-indicator) (display-fill-column-indicator-mode): Add reference to manual. --- lisp/display-fill-column-indicator.el | 6 ++++-- src/xdisp.c | 9 ++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/lisp/display-fill-column-indicator.el b/lisp/display-fill-column-indicator.el index 1b92fa69d29..3f947bdc1c9 100644 --- a/lisp/display-fill-column-indicator.el +++ b/lisp/display-fill-column-indicator.el @@ -39,7 +39,8 @@ (defgroup display-fill-column-indicator nil "Display a fill column indicator in the buffer." :group 'convenience - :group 'display) + :group 'display + :link '(info-link "(emacs)Displaying Boundaries")) ;;;###autoload @@ -49,7 +50,8 @@ This uses `display-fill-column-indicator' internally. To change the position of the column displayed by default customize `display-fill-column-indicator-column'. You can change the -character for the indicator setting `display-fill-column-indicator-character'." +character for the indicator setting `display-fill-column-indicator-character'. +See Info node `Displaying Boundaries' for details." :lighter nil (if display-fill-column-indicator-mode (progn diff --git a/src/xdisp.c b/src/xdisp.c index c15dd4770ae..b0fbc9936fb 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -34976,7 +34976,8 @@ It has no effect when set to 0, or when line numbers are not absolute. */); Fmake_variable_buffer_local (Qdisplay_line_numbers_offset); DEFVAR_BOOL ("display-fill-column-indicator", Vdisplay_fill_column_indicator, - doc: /* Non-nil means display the fill column indicator. */); + doc: /* Non-nil means display the fill column indicator. +See Info node `Displaying Boundaries' for details. */); Vdisplay_fill_column_indicator = false; DEFSYM (Qdisplay_fill_column_indicator, "display-fill-column-indicator"); Fmake_variable_buffer_local (Qdisplay_fill_column_indicator); @@ -34985,7 +34986,8 @@ It has no effect when set to 0, or when line numbers are not absolute. */); doc: /* Column for indicator when `display-fill-column-indicator' is non-nil. The default value is t which means that the indicator will use the `fill-column' variable. If it is set to an integer the -indicator will be drawn in that column. */); +indicator will be drawn in that column. +See Info node `Displaying Boundaries' for details. */); Vdisplay_fill_column_indicator_column = Qt; DEFSYM (Qdisplay_fill_column_indicator_column, "display-fill-column-indicator-column"); Fmake_variable_buffer_local (Qdisplay_fill_column_indicator_column); @@ -34993,7 +34995,8 @@ indicator will be drawn in that column. */); DEFVAR_LISP ("display-fill-column-indicator-character", Vdisplay_fill_column_indicator_character, doc: /* Character to draw the indicator when `display-fill-column-indicator' is non-nil. The default is U+2502 but a good alternative is (ascii 124) -if the font in fill-column-indicator face does not support Unicode characters. */); +if the font in fill-column-indicator face does not support Unicode characters. +See Info node `Displaying Boundaries' for details. */); Vdisplay_fill_column_indicator_character = Qnil; DEFSYM (Qdisplay_fill_column_indicator_character, "display-fill-column-indicator-character"); Fmake_variable_buffer_local (Qdisplay_fill_column_indicator_character); -- cgit v1.3