From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs 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 Message-ID: <83po9oh3hj.fsf@gnu.org> References: <1508054203.3504379.1139170720.0D0E99E9@webmail.messagingengine.com> <59E32D49.4030007@gmx.at> <1508065717.3534312.1139251176.600E646A@webmail.messagingengine.com> <59E350AE.3060005@gmx.at> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1508078971 17201 195.159.176.226 (15 Oct 2017 14:49:31 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 15 Oct 2017 14:49:31 +0000 (UTC) Cc: hello@paulwrankin.com, 28844@debbugs.gnu.org To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Oct 15 16:49:26 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e3kDz-00017t-Ih for geb-bug-gnu-emacs@m.gmane.org; Sun, 15 Oct 2017 16:49:07 +0200 Original-Received: from localhost ([::1]:57467 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e3kE5-0005Gx-HI for geb-bug-gnu-emacs@m.gmane.org; Sun, 15 Oct 2017 10:49:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47541) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e3kDz-0005Gf-2I for bug-gnu-emacs@gnu.org; Sun, 15 Oct 2017 10:49:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e3kDu-0006TF-Ia for bug-gnu-emacs@gnu.org; Sun, 15 Oct 2017 10:49:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:33085) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e3kDu-0006Sz-Fd for bug-gnu-emacs@gnu.org; Sun, 15 Oct 2017 10:49:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1e3kDu-0000Gv-9F for bug-gnu-emacs@gnu.org; Sun, 15 Oct 2017 10:49:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 15 Oct 2017 14:49:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 28844 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 28844-submit@debbugs.gnu.org id=B28844.1508078889977 (code B ref 28844); Sun, 15 Oct 2017 14:49:02 +0000 Original-Received: (at 28844) by debbugs.gnu.org; 15 Oct 2017 14:48:09 +0000 Original-Received: from localhost ([127.0.0.1]:41766 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e3kD2-0000Fh-KJ for submit@debbugs.gnu.org; Sun, 15 Oct 2017 10:48:08 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:56243) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e3kD0-0000F5-7o for 28844@debbugs.gnu.org; Sun, 15 Oct 2017 10:48:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e3kCq-0005BU-5R for 28844@debbugs.gnu.org; Sun, 15 Oct 2017 10:48:00 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:38099) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e3kCq-0005BI-1e; Sun, 15 Oct 2017 10:47:56 -0400 Original-Received: from [176.228.60.248] (port=4632 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1e3kCp-0007bp-Fp; Sun, 15 Oct 2017 10:47:55 -0400 In-reply-to: <59E350AE.3060005@gmx.at> (message from martin rudalics on Sun, 15 Oct 2017 14:12:30 +0200) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:138460 Archived-At: > Date: Sun, 15 Oct 2017 14:12:30 +0200 > From: martin rudalics > 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.