Subject: bug#28844: 26.0.90; display-line-numbers-mode should call window-configuration-change-hook

From: Alex <[email-masked]>
Date: Sun, 15 Oct 2017 22:59:35 -0600

Paul Rankin <[email-masked]> writes:

> Because this doesn’t work. If it did I wouldn’t be posting it. Think about it;
> your mode updates the display on its own without notifying Emacs. The basic
> conceptual problem is that “every time you need the value” is predicated on when
> display-line-numbers-mode changes the value. There’s no way for another lisp
> program to know when that is.

I agree that Emacs should present a way to specify width that
automatically takes line numbers into account.

> Function featurep is enough to know if display-line-numbers is present (as
> above).

Actually, I'd recommend (boundp 'display-line-numbers), since the
feature `display-line-numbers' isn't loaded automatically in Emacs. It
should be noted that `display-line-numbers-mode' is just a minor mode
wrapper around the variable `display-line-numbers', which actually does
the work.

This also means that the hook `display-line-numbers-hook' isn't actually
enough to determine whether or not line numbers have been toggled (since
one can just toggle the variable instead). I'd say its main use is in
user configurations.

To see if line numbers are present in a buffer (and to make it
compatible with older Emacsen), you should use something like:

(bound-and-true-p display-line-numbers)