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#28248: 26.0.50; display-line-numbers does not affect window-width / window-text-width Date: Tue, 17 Oct 2017 19:33:28 +0300 Message-ID: <834lqxg2ef.fsf@gnu.org> References: <834lst5bep.fsf@gnu.org> <83d15mfqoj.fsf@gnu.org> <785ae770-ea0a-ec74-c986-fde32a48ab0f@yandex.ru> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1508258596 12522 195.159.176.226 (17 Oct 2017 16:43:16 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 17 Oct 2017 16:43:16 +0000 (UTC) Cc: steve@sanityinc.com, 28248@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Oct 17 18:43:11 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 1e4UxA-0000Sx-Nd for geb-bug-gnu-emacs@m.gmane.org; Tue, 17 Oct 2017 18:42:52 +0200 Original-Received: from localhost ([::1]:40509 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4UxI-0007Eq-5Q for geb-bug-gnu-emacs@m.gmane.org; Tue, 17 Oct 2017 12:43:00 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42250) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4Uoh-00088n-0X for bug-gnu-emacs@gnu.org; Tue, 17 Oct 2017 12:34:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e4Uoe-0008Bd-C6 for bug-gnu-emacs@gnu.org; Tue, 17 Oct 2017 12:34:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:37836) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e4Uoe-0008BR-7l for bug-gnu-emacs@gnu.org; Tue, 17 Oct 2017 12:34:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1e4Uoe-0006sL-0T for bug-gnu-emacs@gnu.org; Tue, 17 Oct 2017 12:34:04 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 17 Oct 2017 16:34:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 28248 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 28248-submit@debbugs.gnu.org id=B28248.150825803426397 (code B ref 28248); Tue, 17 Oct 2017 16:34:03 +0000 Original-Received: (at 28248) by debbugs.gnu.org; 17 Oct 2017 16:33:54 +0000 Original-Received: from localhost ([127.0.0.1]:46516 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e4UoU-0006rh-8B for submit@debbugs.gnu.org; Tue, 17 Oct 2017 12:33:54 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:51199) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e4UoS-0006rQ-FM for 28248@debbugs.gnu.org; Tue, 17 Oct 2017 12:33:53 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e4UoK-0007q4-OJ for 28248@debbugs.gnu.org; Tue, 17 Oct 2017 12:33:47 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:51234) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4UoK-0007pw-Kr; Tue, 17 Oct 2017 12:33:44 -0400 Original-Received: from [176.228.60.248] (port=2879 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1e4UoK-0005r8-2a; Tue, 17 Oct 2017 12:33:44 -0400 In-reply-to: <785ae770-ea0a-ec74-c986-fde32a48ab0f@yandex.ru> (message from Dmitry Gutov on Tue, 17 Oct 2017 11:23:56 +0300) 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:138628 Archived-At: > Cc: steve@sanityinc.com, 28248@debbugs.gnu.org > From: Dmitry Gutov > Date: Tue, 17 Oct 2017 11:23:56 +0300 > > On 10/17/17 5:34 AM, Eli Zaretskii wrote: > > >> Should I always use (+ 2 (line-number-display-width)) instead? > > > > If you need it in columns, yes. This is for consistency with the > > value of display-line-numbers-width, which you can set. > > > >> That would be the actual amount of "screen estate used up for > >> line-number display". > >> > >> Can I rely on the extra value always being 2? > > > > As long as we don't change the implementation, yes. Alternatively, > > you can call line-number-display-width with the optional argument and > > get the result in pixels, in which case it includes everything (you > > can divide by frame-char-width to get the result back in columns). > > Thanks, but isn't that more inconsistent? I would expect both return > values of this function to measure the same thing, and there's nothing > in the docstring to explain that difference. They are used for 2 different purposes, which are contradictory to some degree. The value in column units is primarily meant to be used for setting display-line-numbers-width (see, e.g., how display-line-numbers.el uses that), and also for users, so burdening them with anything that is not directly related to the value of the largest visible line number would be a nuisance. OTOH, the column-unit value is of limited utility for layout calculations, because the columns are of the line-number face, which could be smaller or larger than the default face. Therefore, layout calculations should use the function's pixelwise variety, and convert into columns by dividing by the width of the font used for buffer text. (Which btw means my response to you earlier -- see above -- was incomplete: you should use the function in pixel-unit mode, if you need to account for the screen space eaten by line numbers, and then you don't have to add anything to the value it returns.) And I just noticed that we do use the column-unit values in some of the places in Emacs that need this, so I will be fixing them soon. > On the other hand, the return value of the function can differ from what > a variable is set to. I think that'd be a nuisance; again, see what display-line-numbers.el does. I agree that this is not ideal, to say the least, but I hope you at least understand the issues now. If there's a better solution, I'm all ears. > the function's docstring needs updating. Done. Thanks. P.S. I'd still like to hear your opinions on the related questions I asked here: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=28855#8