GNU bug report logs -
#28844
26.0.90; display-line-numbers-mode should call window-configuration-change-hook
Previous Next
Reported by: Paul Rankin <hello <at> paulwrankin.com>
Date: Sun, 15 Oct 2017 07:57:01 UTC
Severity: minor
Found in version 26.0.90
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
Message #26 received at 28844 <at> debbugs.gnu.org (full text, mbox):
On Mon, 16 Oct 2017, at 12:59 AM, Eli Zaretskii wrote:
> > From: Paul Rankin <hello <at> paulwrankin.com>
> > Date: Sun, 15 Oct 2017 23:27:53 +1000
> > Cc: 28844 <at> debbugs.gnu.org
> >
> > This is all I should have to do, where WINDOW is the selected window and MARGIN is an integer:
> >
> > - (set-window-margins window margin margin))
> > + (set-window-margins window (if (featurep 'display-line-numbers)
> > + (- margin (line-number-display-width))
> > + margin)
> > + margin))
>
> Exactly. So why do you need a hook? Just call this every time you
> need the value, and you will have the up-to-date one.
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.
> > Cool. As long as there is a hook. I appreciate inclusion of the function line-number-display-width, but introducing compatibility-breaking code then putting the onus on others to work around it is kinda rude. If there is a proper hook it eases the pain a bit.
>
> If that's the problem, then you could provide a wrapper around
> line-number-display-width for older versions of Emacs, which would
> always return zero for those versions. Or even explicitly check for
> display-line-numbers being nil, which it always will be in older
> versions, and return zero even without calling
> line-number-display-width. I believe this is the standard way of
> dealing with these problems.
If you’ve introduced a problem into Emacs without the forethought on how it will adversely affect existing code, the onus is on you to either remove or fix it. Function featurep is enough to know if display-line-numbers is present (as above).
This bug report was last modified 7 years and 166 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.