bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#34513: display-line-numbers in term mode


From: Stefan Monnier
Subject: bug#34513: display-line-numbers in term mode
Date: Wed, 27 Feb 2019 10:26:04 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

> display-line-number-mode produces bad term buffers with extra breaks.
> When using global-display-line-numbers there are some issues in term
> mode because of the extra columns needed by the numbers.
>
> The lines are broken because "tput cols" and $COLUMNS report the total
> width of the window, but it does not take into account the 3/4 (or more)
> chars taken by the line number. So longer lines need to be broken to fit.

So it seems that some of the problems are due to the process not being
told the size of the really usable text area.  This is done normally via
window-adjust-process-window-size-function which in turns calls
window-adjust-process-window-size which then calls
window-max-chars-per-line but that function does not take
display-line-numbers-width into account.

So maybe a simple fix is the patch below, but I'm not sure it's always
the right thing to do (and the width won't be automatically updated when
the (line-number-display-width) changes).


        Stefan


PS: Why is the function called `line-number-display-width` when
everything else seems to use the `display-line-number` prefix?  
It makes it more difficult to find.


diff --git a/lisp/window.el b/lisp/window.el
index 07a0f713c4..906e9012fe 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -2132,7 +2132,7 @@ window-max-chars-per-line
   (with-selected-window (window-normalize-window window t)
     (let* ((window-width (window-body-width window t))
           (font-width (window-font-width window face))
-          (ncols (/ window-width font-width)))
+          (ncols (- (/ window-width font-width) (line-number-display-width))))
       (if (and (display-graphic-p)
               overflow-newline-into-fringe
                (not





reply via email to

[Prev in Thread] Current Thread [Next in Thread]