unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Ergus <spacibba@aol.com>
Cc: 34513@debbugs.gnu.org
Subject: bug#34513: display-line-numbers in term mode
Date: Wed, 27 Feb 2019 10:26:04 -0500	[thread overview]
Message-ID: <jwvbm2xdzx5.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <20190217141940.62v754v46qwfcs2i@Ergus> (Ergus's message of "Sun,  17 Feb 2019 15:19:40 +0100")

> 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	other threads:[~2019-02-27 15:26 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-17 14:19 bug#34513: display-line-numbers in term mode Ergus
2019-02-27 15:26 ` Stefan Monnier [this message]
2019-02-27 16:05   ` Eli Zaretskii
2019-02-27 16:40     ` Stefan Monnier
2019-02-27 17:06       ` Eli Zaretskii
2019-02-27 17:21         ` Stefan Monnier
2019-02-27 17:33           ` Eli Zaretskii
     [not found]           ` <<831s3tkufj.fsf@gnu.org>
2019-02-27 18:00             ` Drew Adams
2019-02-27 18:20               ` Eli Zaretskii
     [not found]           ` <<<831s3tkufj.fsf@gnu.org>
     [not found]             ` <<9f8f0712-1187-4ce3-bd2c-af44cf00927d@default>
     [not found]               ` <<83wolljdpe.fsf@gnu.org>
2019-02-27 19:04                 ` Drew Adams
2020-09-20 18:30   ` Lars Ingebrigtsen
2020-09-20 18:50     ` Eli Zaretskii
2020-09-20 19:56       ` Lars Ingebrigtsen
2020-09-21  2:27         ` Eli Zaretskii
2020-09-21 14:10           ` Lars Ingebrigtsen
2019-02-27 17:46 ` bug#34513: Fwd: " Ergus
2019-02-27 18:15   ` Eli Zaretskii
2019-10-20 22:54 ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2019-10-21  6:51   ` Eli Zaretskii
2019-10-21 21:44     ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2019-10-22 15:11       ` Eli Zaretskii
     [not found] <8736fkaish.fsf@aol.com>
2019-10-22 17:33 ` Eli Zaretskii
2019-10-22 23:06   ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2019-10-23 16:21     ` Eli Zaretskii
2019-10-23 16:50       ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvbm2xdzx5.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=34513@debbugs.gnu.org \
    --cc=spacibba@aol.com \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).