From: Eli Zaretskii Date: Sun, 25 Jun 2017 17:53:05 +0000 (+0300) Subject: Allow to disable display of line numbers beyond EOB X-Git-Tag: emacs-26.0.90~518^2~156^2~20 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=5d1025e7162db46b3c8d7c19facd8f9b9eff6f49;p=emacs.git Allow to disable display of line numbers beyond EOB * src/buffer.c (disable_line_numbers_overlay_at_eob): New function. * src/lisp.h (disable_line_numbers_overlay_at_eob): Add prototype. * src/xdisp.c (should_produce_line_number): When at ZV, call disable_line_numbers_overlay_at_eob to determine whether line numbers should be displayed beyond ZV. --- diff --git a/src/buffer.c b/src/buffer.c index 80dbd3318dc..780e4d7a7d6 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -3054,6 +3054,33 @@ mouse_face_overlay_overlaps (Lisp_Object overlay) return i < n; } +/* Return the value of the 'display-line-numbers-disable' property at + EOB, if there's an overlay at ZV with a non-nil value of that property. */ +Lisp_Object +disable_line_numbers_overlay_at_eob (void) +{ + ptrdiff_t n, i, size; + Lisp_Object *v, tem = Qnil; + Lisp_Object vbuf[10]; + USE_SAFE_ALLOCA; + + size = ARRAYELTS (vbuf); + v = vbuf; + n = overlays_in (ZV, ZV, 0, &v, &size, NULL, NULL); + if (n > size) + { + SAFE_NALLOCA (v, 1, n); + overlays_in (ZV, ZV, 0, &v, &n, NULL, NULL); + } + + for (i = 0; i < n; ++i) + if ((tem = Foverlay_get (v[i], Qdisplay_line_numbers_disable), + !NILP (tem))) + break; + + SAFE_FREE (); + return tem; +} /* Fast function to just test if we're at an overlay boundary. */ diff --git a/src/lisp.h b/src/lisp.h index ff8dde2b825..f5cb6c75706 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -3965,6 +3965,7 @@ extern void syms_of_editfns (void); /* Defined in buffer.c. */ extern bool mouse_face_overlay_overlaps (Lisp_Object); +extern Lisp_Object disable_line_numbers_overlay_at_eob (void); extern _Noreturn void nsberror (Lisp_Object); extern void adjust_overlays_for_insert (ptrdiff_t, ptrdiff_t); extern void adjust_overlays_for_delete (ptrdiff_t, ptrdiff_t); diff --git a/src/xdisp.c b/src/xdisp.c index c318a6954c4..7649b16e974 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -20948,10 +20948,15 @@ should_produce_line_number (struct it *it) #endif /* If the character at current position has a non-nil special - property, disable line numbers for this row. */ - Lisp_Object val = Fget_char_property (make_number (IT_CHARPOS (*it)), - Qdisplay_line_numbers_disable, - it->window); + property, disable line numbers for this row. For ZV, we need to + use a special algorithm that only supports empty overlays at that + point, because get-char-property always returns nil for ZV. */ + Lisp_Object val = Qnil; + if (IT_CHARPOS (*it) >= ZV) + val = disable_line_numbers_overlay_at_eob (); + else + val = Fget_char_property (make_number (IT_CHARPOS (*it)), + Qdisplay_line_numbers_disable, it->window); return NILP (val) ? true : false; }