all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Paul Rankin <hello@paulwrankin.com>
Cc: 29597@debbugs.gnu.org, npostavs@users.sourceforge.net
Subject: bug#29597: 26.0.90; line-number-display-width returns incorrect width
Date: Fri, 08 Dec 2017 17:01:54 +0200	[thread overview]
Message-ID: <838tedw9el.fsf@gnu.org> (raw)
In-Reply-To: <1512700351.3662600.1198017792.20921918@webmail.messagingengine.com> (message from Paul Rankin on Fri, 08 Dec 2017 12:32:31 +1000)

> From: Paul Rankin <hello@paulwrankin.com>
> 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.





  reply	other threads:[~2017-12-08 15:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-07  5:34 bug#29597: 26.0.90; line-number-display-width returns incorrect width Paul Rankin
2017-12-07  8:55 ` Eli Zaretskii
2017-12-08  1:44 ` Paul Rankin
2017-12-08  2:00   ` Noam Postavsky
2017-12-08  2:32     ` Paul Rankin
2017-12-08 15:01       ` Eli Zaretskii [this message]
2017-12-08 15:37         ` Noam Postavsky
2017-12-08 15:53           ` Eli Zaretskii
2017-12-08 15:55           ` Eli Zaretskii
2017-12-08 16:23             ` Noam Postavsky
2017-12-08 16:29               ` Eli Zaretskii
2017-12-08 22:39                 ` Noam Postavsky
2017-12-08 14:22   ` Eli Zaretskii
2017-12-08 14:40     ` Noam Postavsky

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=838tedw9el.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=29597@debbugs.gnu.org \
    --cc=hello@paulwrankin.com \
    --cc=npostavs@users.sourceforge.net \
    /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.