[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#28844: 26.0.90; display-line-numbers-mode should call window-configu
From: |
Paul Rankin |
Subject: |
bug#28844: 26.0.90; display-line-numbers-mode should call window-configuration-change-hook |
Date: |
Mon, 16 Oct 2017 13:22:00 +1000 |
On Mon, 16 Oct 2017, at 12:59 AM, Eli Zaretskii wrote:
> > From: Paul Rankin <hello@paulwrankin.com>
> > Date: Sun, 15 Oct 2017 23:27:53 +1000
> > Cc: 28844@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).
- bug#28844: 26.0.90; display-line-numbers-mode should call window-configuration-change-hook, Paul Rankin, 2017/10/15
- bug#28844: 26.0.90; display-line-numbers-mode should call window-configuration-change-hook, martin rudalics, 2017/10/15
- bug#28844: 26.0.90; display-line-numbers-mode should call window-configuration-change-hook, Paul Rankin, 2017/10/15
- bug#28844: 26.0.90; display-line-numbers-mode should call window-configuration-change-hook, martin rudalics, 2017/10/15
- bug#28844: 26.0.90; display-line-numbers-mode should call window-configuration-change-hook, Paul Rankin, 2017/10/15
- bug#28844: 26.0.90; display-line-numbers-mode should call window-configuration-change-hook, Eli Zaretskii, 2017/10/15
- bug#28844: 26.0.90; display-line-numbers-mode should call window-configuration-change-hook,
Paul Rankin <=
- bug#28844: 26.0.90; display-line-numbers-mode should call window-configuration-change-hook, Alex, 2017/10/16
- bug#28844: 26.0.90; display-line-numbers-mode should call window-configuration-change-hook, Paul Rankin, 2017/10/16
- bug#28844: 26.0.90; display-line-numbers-mode should call window-configuration-change-hook, Eli Zaretskii, 2017/10/16
- bug#28844: 26.0.90; display-line-numbers-mode should call window-configuration-change-hook, Paul Rankin, 2017/10/16
- bug#28844: 26.0.90; display-line-numbers-mode should call window-configuration-change-hook, Eli Zaretskii, 2017/10/16
- bug#28844: 26.0.90; display-line-numbers-mode should call window-configuration-change-hook, Paul Rankin, 2017/10/17
- bug#28844: 26.0.90; display-line-numbers-mode should call window-configuration-change-hook, Eli Zaretskii, 2017/10/17
- bug#28844: 26.0.90; display-line-numbers-mode should call window-configuration-change-hook, Paul Rankin, 2017/10/17
- bug#28844: 26.0.90; display-line-numbers-mode should call window-configuration-change-hook, Eli Zaretskii, 2017/10/17
- bug#28844: 26.0.90; display-line-numbers-mode should call window-configuration-change-hook, Eli Zaretskii, 2017/10/20