Commit 5d1025e7 authored by Eli Zaretskii's avatar Eli Zaretskii
Browse files

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.
parent 540669cd
......@@ -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. */
......
......@@ -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);
......
......@@ -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;
}
 
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment