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#29597: 26.0.90; line-number-display-width returns incorrect width Date: Fri, 08 Dec 2017 17:01:54 +0200 Message-ID: <838tedw9el.fsf@gnu.org> References: <1512624891.1385920.1196858744.3908725A@webmail.messagingengine.com> <1512697446.3649570.1197990904.2822A9C1@webmail.messagingengine.com> <87d13qf07e.fsf@users.sourceforge.net> <1512700351.3662600.1198017792.20921918@webmail.messagingengine.com> 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 1512745606 4169 195.159.176.226 (8 Dec 2017 15:06:46 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 8 Dec 2017 15:06:46 +0000 (UTC) Cc: 29597@debbugs.gnu.org, npostavs@users.sourceforge.net To: Paul Rankin Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Dec 08 16:06:37 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 1eNKEX-0000qE-0l for geb-bug-gnu-emacs@m.gmane.org; Fri, 08 Dec 2017 16:06:37 +0100 Original-Received: from localhost ([::1]:37664 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eNKEe-00043Q-2c for geb-bug-gnu-emacs@m.gmane.org; Fri, 08 Dec 2017 10:06:44 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52266) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eNKB8-000145-8T for bug-gnu-emacs@gnu.org; Fri, 08 Dec 2017 10:03:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eNKB5-00080X-5U for bug-gnu-emacs@gnu.org; Fri, 08 Dec 2017 10:03:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:44004) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eNKB5-00080G-26 for bug-gnu-emacs@gnu.org; Fri, 08 Dec 2017 10:03:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eNKB3-00018E-PT for bug-gnu-emacs@gnu.org; Fri, 08 Dec 2017 10:03:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 08 Dec 2017 15:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 29597 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: notabug Original-Received: via spool by 29597-submit@debbugs.gnu.org id=B29597.15127453474310 (code B ref 29597); Fri, 08 Dec 2017 15:03:01 +0000 Original-Received: (at 29597) by debbugs.gnu.org; 8 Dec 2017 15:02:27 +0000 Original-Received: from localhost ([127.0.0.1]:52685 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eNKAT-00017Q-Fs for submit@debbugs.gnu.org; Fri, 08 Dec 2017 10:02:27 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:60991) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eNKAR-00017D-OV for 29597@debbugs.gnu.org; Fri, 08 Dec 2017 10:02:24 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eNKAJ-0007Lq-CF for 29597@debbugs.gnu.org; Fri, 08 Dec 2017 10:02:18 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:39969) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eNKAJ-0007Ll-8P; Fri, 08 Dec 2017 10:02:15 -0500 Original-Received: from [176.228.60.248] (port=3206 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1eNKAI-0003yA-Ik; Fri, 08 Dec 2017 10:02:15 -0500 In-reply-to: <1512700351.3662600.1198017792.20921918@webmail.messagingengine.com> (message from Paul Rankin on Fri, 08 Dec 2017 12:32:31 +1000) 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:140817 Archived-At: > From: Paul Rankin > Cc: 29597@debbugs.gnu.org, eliz@gnu.org > Date: Fri, 08 Dec 2017 12:32:31 +1000 > > - Why does an argument PIXELWISE take a symbol “columns”? > - Why does PIXELWISE then return characters? This is a very widely used size unit in display- and layout-related APIs in Emacs: the width of the frame's canonical character. We call this "columns" because when the face used for display is the default face, and the font is fixed-pitch, that is what you get. This is explained in the subsection "Frame Font" in the ELisp manual: Each frame has a “default font” which specifies the default character size for that frame. This size is meant when retrieving or changing the size of a frame in terms of columns or lines (*note Size Parameters::). It is also used when resizing (*note Window Sizes::) or splitting (*note Splitting Windows::) windows. The terms “line height” and “canonical character height” are sometimes used instead of “default character height”. Similarly, the terms “column width” and “canonical character width” are used instead of “default character width”. > - Still, why would the function not just return the width of the line numbers *with* the 2 columns for padding? Because it returns the number of _digits_ used for line-number display, omitting the padding. The reason why this value is returned is to some extent historical: there are users of that in display-line-numbers.el. > I mean, we’re not dealing with some deeply entrenched internal function where these sorts of mental contortions are required to maintain backwards compatibility, this is a *new* feature. The function is new, but the notion of measuring width in "canonical columns" is not, it is very old and goes back to Emacs 21, which introduced support for variable fonts and non-text display elements (such as images) shown in a window. > I understand that this function is also used internally for specific purposes, so it needs to behave a specific way to appease the initial writer of the code. But for the sake of sanity, I strongly suggest either fixing this function or creating a separate “public” function that operates vaguely in line with user expectation for those of us wanting to accommodate display-line-numbers-mode. Sorry, I don't understand what is missing. If you wanted the value of 4 in your case, you need to call this function like this: (line-number-display-width 'columns) as documented.