Subject: Re: bug#27427: 26.0.50; Native line numbers lead to display error in company-mode popup

From: Dmitry Gutov <[email-masked]>
Date: Mon, 26 Jun 2017 01:56:28 +0300

On 6/25/17 8:57 PM, Eli Zaretskii wrote:

> Should be fixed now.

Thanks, both cases are working well now. See below for the third one 
(though it's relatively rare). ;-(

> the fix only works for empty overlays at EOB,
> but that should be enough, right?  Or do you see some other way of
> specifying this property at EOB?

No, it seems plenty enough for me. I doubt we'd ever going to try using 
text properties for the popup without an overlay.

The third case which disrupts popup positioning: horizontal scrolling, 
which we discussed earlier. With native numbers, it breaks our function 
which calculates the "usable" window body width. It looks like this:

(defun company--window-width ()
   (let ((ww (window-body-width)))
     ;; Account for the line continuation column.
     (when (zerop (cadr (window-fringes)))
       (cl-decf ww))
     (unless (or (display-graphic-p)
                 (version< "24.3.1" emacs-version))
       ;; Emacs 24.3 and earlier included margins
       ;; in window-width when in TTY.
       (cl-decf ww
                (let ((margins (window-margins)))
                  (+ (or (car margins) 0)
                     (or (cdr margins) 0)))))
     (when (and word-wrap
                (version< emacs-version "24.4.51.5"))
       ;; http://debbugs.gnu.org/19300
       (cl-decf ww))
     ;; whitespace-mode with newline-mark
     (when (and buffer-display-table
                (aref buffer-display-table ?\n))
       (cl-decf ww (1- (length (aref buffer-display-table ?\n)))))
     ww))

Without going into details, how do I figure out the width which line 
number glyphs are taking up? Any way to do that without calling 
posn-at-point at the beginning-of-visual-line?