all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: martin rudalics <rudalics@gmx.at>
Cc: hello@paulwrankin.com, 28844@debbugs.gnu.org
Subject: bug#28844: 26.0.90; display-line-numbers-mode should call window-configuration-change-hook
Date: Sun, 15 Oct 2017 17:47:52 +0300	[thread overview]
Message-ID: <83po9oh3hj.fsf@gnu.org> (raw)
In-Reply-To: <59E350AE.3060005@gmx.at> (message from martin rudalics on Sun, 15 Oct 2017 14:12:30 +0200)

> Date: Sun, 15 Oct 2017 14:12:30 +0200
> From: martin rudalics <rudalics@gmx.at>
> Cc: 28844@debbugs.gnu.org
> 
> You could use ‘window-scroll-functions’ (remembering the old line number
> widths) for scrolling but this would not handle simple point movements.

Simple point movements (for some value of "simple") don't affect the
width used for line numbers.

> Eli will decide what to do.

I actually don't understand why a hook is needed.  If a Lisp
application wants/needs to be sensitive to the width of the
line-number display, it should simply call line-number-display-width
each time it needs to know the value.  This function is guaranteed to
return zero when display-line-numbers is nil, and it's also guaranteed
(barring bugs ;-) to return the exact same value as what the display
engine will use, provided that the window-start doesn't move between
the call to line-number-display-width and when you need to use the
value.  So it will correctly reflect any changes in the width used for
the line numbers.

What am I missing?

>                           If an existing hook must be chosen, I'd
> rather (mis-)use ‘window-size-change-functions’ - strictly spoken,
> display of line numbers never affects the size of windows (something
> which is not true vice-versa IIUC).

Precisely.  Which IMO makes window-size-change-functions inappropriate
for this purpose.

> But better, provide a separate hook like
> ‘line-number-width-changed-functions’ with the corresponding window
> as argument (and maybe the old line number width as second).

I have hard time imagining how to implement such a hook (or any hook
which needs to be called "when the width changes").  You see, the
display engine doesn't know that the width changed -- it computes the
required width once, when it's about to redisplay a window, keeps the
computed value only as long as it needs to display that window, and
doesn't store it anywhere where it would survive until the next
redisplay.  So implementing such a hook would need some non-trivial
changes, because the previous width will have to be stored in the
window object, and we will need to manage that stored value (e.g.,
invalidate it when we switch buffers in a window).

Moreover, hooks that are to be called by the display engine are
usually a bad idea if they are to be used to affect redisplay, because
they more often than not require an immediate additional cycle of
redisplay, which makes Emacs sluggish.

I provided the line-number-display-width function in the hope that it
will serve any Lisp program that needs to be sensitive to the screen
estate taken by line numbers.  If it somehow doesn't fit this bill,
please tell why, maybe it should be extended.





  parent reply	other threads:[~2017-10-15 14:47 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-15  7:56 bug#28844: 26.0.90; display-line-numbers-mode should call window-configuration-change-hook Paul Rankin
2017-10-15  9:41 ` martin rudalics
2017-10-15 11:08   ` Paul Rankin
2017-10-15 12:12     ` martin rudalics
2017-10-15 13:27       ` Paul Rankin
2017-10-15 14:59         ` Eli Zaretskii
2017-10-16  3:22           ` Paul Rankin
2017-10-16  4:59             ` Alex
2017-10-16  5:14               ` Paul Rankin
2017-10-16 14:48                 ` Eli Zaretskii
2017-10-17  0:35                   ` Paul Rankin
2017-10-17  2:41                     ` Eli Zaretskii
2017-10-17  4:19                       ` Paul Rankin
2017-10-17  5:44                         ` Eli Zaretskii
2017-10-17  7:13                           ` Paul Rankin
2017-10-17  8:33                             ` Eli Zaretskii
2017-10-20  9:42                               ` Eli Zaretskii
2017-12-08  2:43                             ` Noam Postavsky
2017-12-08 14:48                               ` Eli Zaretskii
2017-12-09 15:30                               ` Paul Rankin
2017-12-09 16:01                                 ` Eli Zaretskii
2017-10-15 14:47       ` Eli Zaretskii [this message]
2017-10-16  7:41         ` martin rudalics
2017-10-22  7:20 ` Paul Rankin
2017-10-22 14:27   ` Eli Zaretskii
2017-12-08  2:14 ` Paul Rankin
2017-12-08 15:22   ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83po9oh3hj.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=28844@debbugs.gnu.org \
    --cc=hello@paulwrankin.com \
    --cc=rudalics@gmx.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.