From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#34513: display-line-numbers in term mode Date: Wed, 27 Feb 2019 10:26:04 -0500 Message-ID: References: <20190217141940.62v754v46qwfcs2i@Ergus> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="269747"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 34513@debbugs.gnu.org To: Ergus Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Feb 27 16:27:41 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gz17U-00184H-GZ for geb-bug-gnu-emacs@m.gmane.org; Wed, 27 Feb 2019 16:27:40 +0100 Original-Received: from localhost ([127.0.0.1]:46108 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gz17T-0005V2-Ah for geb-bug-gnu-emacs@m.gmane.org; Wed, 27 Feb 2019 10:27:39 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:51195) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gz16w-0005Fb-KM for bug-gnu-emacs@gnu.org; Wed, 27 Feb 2019 10:27:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gz16v-0001sF-Op for bug-gnu-emacs@gnu.org; Wed, 27 Feb 2019 10:27:06 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:40612) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gz16s-0001of-IQ for bug-gnu-emacs@gnu.org; Wed, 27 Feb 2019 10:27:04 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gz16s-0000kK-C1 for bug-gnu-emacs@gnu.org; Wed, 27 Feb 2019 10:27:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 27 Feb 2019 15:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34513 X-GNU-PR-Package: emacs Original-Received: via spool by 34513-submit@debbugs.gnu.org id=B34513.15512811722807 (code B ref 34513); Wed, 27 Feb 2019 15:27:02 +0000 Original-Received: (at 34513) by debbugs.gnu.org; 27 Feb 2019 15:26:12 +0000 Original-Received: from localhost ([127.0.0.1]:54156 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gz162-0000jB-Q6 for submit@debbugs.gnu.org; Wed, 27 Feb 2019 10:26:11 -0500 Original-Received: from pruche.dit.umontreal.ca ([132.204.246.22]:49393) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gz15z-0000j2-Ve for 34513@debbugs.gnu.org; Wed, 27 Feb 2019 10:26:09 -0500 Original-Received: from fmsmemgm.homelinux.net (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id x1RFQ4lp015228; Wed, 27 Feb 2019 10:26:04 -0500 Original-Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 4AB41AE0E9; Wed, 27 Feb 2019 10:26:04 -0500 (EST) In-Reply-To: <20190217141940.62v754v46qwfcs2i@Ergus> (Ergus's message of "Sun, 17 Feb 2019 15:19:40 +0100") X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 2 Rules triggered EDT_SA_DN_PASS=0, RV6492=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6492> : inlines <7024> : streams <1814261> : uri <2803127> 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: 209.51.188.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:155846 Archived-At: > 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