GNU bug report logs - #34513
display-line-numbers in term mode

Previous Next

Package: emacs;

Reported by: Ergus <spacibba <at> aol.com>

Date: Sun, 17 Feb 2019 14:21:02 UTC

Severity: normal

Tags: fixed

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 34513 in the body.
You can then email your comments to 34513 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#34513; Package emacs. (Sun, 17 Feb 2019 14:21:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ergus <spacibba <at> aol.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 17 Feb 2019 14:21:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ergus <spacibba <at> aol.com>
To: bug-gnu-emacs <at> gnu.org
Subject: display-line-numbers in term mode
Date: 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.

The problem is worst when trying to use for example mocp or similar
curses bases applications. Or in zsh that uses an alternative to
readline to select with tabs.

A workaround is be to disable the numbers in term-mode with a hook (this
hides the problem). But a proper fix (maybe) could be to inform properly the
number of columns to the terminal process.

To reproduce this issue just:
1) open emacs, 
2) enable display-line-numbers-mode
3) M-x term. 

Any curses based program there should expose the issue easily.

I tried with emacs 26.1 and the master branch too.

Regards




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34513; Package emacs. (Wed, 27 Feb 2019 15:27:02 GMT) Full text and rfc822 format available.

Message #8 received at 34513 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Ergus <spacibba <at> aol.com>
Cc: 34513 <at> debbugs.gnu.org
Subject: Re: bug#34513: display-line-numbers in term mode
Date: Wed, 27 Feb 2019 10:26:04 -0500
> 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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34513; Package emacs. (Wed, 27 Feb 2019 16:06:02 GMT) Full text and rfc822 format available.

Message #11 received at 34513 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: 34513 <at> debbugs.gnu.org, spacibba <at> aol.com
Subject: Re: bug#34513: display-line-numbers in term mode
Date: Wed, 27 Feb 2019 18:05:35 +0200
> From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
> Date: Wed, 27 Feb 2019 10:26:04 -0500
> Cc: 34513 <at> debbugs.gnu.org
> 
> PS: Why is the function called `line-number-display-width` when
> everything else seems to use the `display-line-number` prefix?  

Because display-line-numbers-line-number-display-width is a mouthful
that I couldn't live with, and also repeats 3 words twice each.

> -	   (ncols (/ window-width font-width)))
> +	   (ncols (- (/ window-width font-width) (line-number-display-width))))

I think you want (line-number-display-width 'columns), since this
wants the canonical column units, right?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34513; Package emacs. (Wed, 27 Feb 2019 16:41:01 GMT) Full text and rfc822 format available.

Message #14 received at 34513 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 34513 <at> debbugs.gnu.org, spacibba <at> aol.com
Subject: Re: bug#34513: display-line-numbers in term mode
Date: Wed, 27 Feb 2019 11:40:04 -0500
>> PS: Why is the function called `line-number-display-width` when
>> everything else seems to use the `display-line-number` prefix?
> Because display-line-numbers-line-number-display-width is a mouthful
> that I couldn't live with, and also repeats 3 words twice each.

That would be awful, indeed.

How 'bout display-line-numbers-width or display-line-numbers-current-width?

>> -	   (ncols (/ window-width font-width)))
>> +	   (ncols (- (/ window-width font-width) (line-number-display-width))))
> I think you want (line-number-display-width 'columns), since this
> wants the canonical column units, right?

Could be, I don't know.  I don't know that all callers of
window-max-chars-per-line want that either.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34513; Package emacs. (Wed, 27 Feb 2019 17:07:01 GMT) Full text and rfc822 format available.

Message #17 received at 34513 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: 34513 <at> debbugs.gnu.org, spacibba <at> aol.com
Subject: Re: bug#34513: display-line-numbers in term mode
Date: Wed, 27 Feb 2019 19:06:02 +0200
> From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
> Cc: spacibba <at> aol.com, 34513 <at> debbugs.gnu.org
> Date: Wed, 27 Feb 2019 11:40:04 -0500
> 
> How 'bout display-line-numbers-width or display-line-numbers-current-width?

I think I considered those at the time, but found them not descriptive
enough.

And please remember that originally the code was entirely in C, so
there was no "package name" to use as prefix.  display-line-numbers.el
and display-line-numbers-mode were born much later.

> >> -	   (ncols (/ window-width font-width)))
> >> +	   (ncols (- (/ window-width font-width) (line-number-display-width))))
> > I think you want (line-number-display-width 'columns), since this
> > wants the canonical column units, right?
> 
> Could be, I don't know.  I don't know that all callers of
> window-max-chars-per-line want that either.

I hope someone does know.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34513; Package emacs. (Wed, 27 Feb 2019 17:22:02 GMT) Full text and rfc822 format available.

Message #20 received at 34513 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 34513 <at> debbugs.gnu.org, spacibba <at> aol.com
Subject: Re: bug#34513: display-line-numbers in term mode
Date: Wed, 27 Feb 2019 12:21:26 -0500
>> How 'bout display-line-numbers-width or display-line-numbers-current-width?
> I think I considered those at the time, but found them not descriptive
> enough.

And how 'bout now?

> And please remember that originally the code was entirely in C, so
> there was no "package name" to use as prefix.

Oh, of course.  But I think in the current context, it would be good to
bring that variable into the "display-line-numbers" prefix.

At first, TAB completion gave me the impression that there was simply no
way to know from Elisp the actual width, because the list of completions
seemed long enough to have the appearance of exhaustiveness.

>> >> -	   (ncols (/ window-width font-width)))
>> >> +	   (ncols (- (/ window-width font-width) (line-number-display-width))))
>> > I think you want (line-number-display-width 'columns), since this
>> > wants the canonical column units, right?
>> Could be, I don't know.  I don't know that all callers of
>> window-max-chars-per-line want that either.
> I hope someone does know.

So do I.  Martin maybe?


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34513; Package emacs. (Wed, 27 Feb 2019 17:34:02 GMT) Full text and rfc822 format available.

Message #23 received at 34513 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: 34513 <at> debbugs.gnu.org, spacibba <at> aol.com
Subject: Re: bug#34513: display-line-numbers in term mode
Date: Wed, 27 Feb 2019 19:33:36 +0200
> From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
> Cc: spacibba <at> aol.com, 34513 <at> debbugs.gnu.org
> Date: Wed, 27 Feb 2019 12:21:26 -0500
> 
> >> How 'bout display-line-numbers-width or display-line-numbers-current-width?
> > I think I considered those at the time, but found them not descriptive
> > enough.
> 
> And how 'bout now?

Same.

My problem was, and is, that the name should include "display-width",
since that's what the function provides.  And the problem, of course,
is that "display-line-numbers-" already includes "display" and
"line-number", so repeating any of that produces problematic names.

> At first, TAB completion gave me the impression that there was simply no
> way to know from Elisp the actual width, because the list of completions
> seemed long enough to have the appearance of exhaustiveness.

Maybe just mentioning the variable in the doc string of
display-line-numbers-mode would be "good enough".




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34513; Package emacs. (Wed, 27 Feb 2019 17:48:01 GMT) Full text and rfc822 format available.

Message #26 received at 34513 <at> debbugs.gnu.org (full text, mbox):

From: Ergus <spacibba <at> aol.com>
To: 34513 <at> debbugs.gnu.org
Subject: Fwd: Re: bug#34513: display-line-numbers in term mode
Date: Wed, 27 Feb 2019 18:46:56 +0100
Yes I see the limitations, specially when the
(line-number-display-width) changes due to user interaction. The problem
is that for a real fix maybe it needs a hook like
line-number-display-width-change (or equivalent) where to add actions, I
suppose there are potentially other modes with same issue. But I think
this is a bit overkill because it will require a redraw and the previous
lines will be modified.

The simplest to do (in my opinion) is to make the numbers not available
at all in term mode and avoid display-line-numbers to be enabled in term
mode. It will keep both the display-line-numbers and term.el
implementations simpler. If a user really needs the numbers in the
future then we can consider other solutions. But it makes not too much
sense actually to have the line numbers in term mode.

My report was because I faced the existent issue by default and it
required an action in my config to avoid exposing it, not because
I wanted the numbers.

But again, you have much much more experience on this and a better
opinion about what should be there or not.






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34513; Package emacs. (Wed, 27 Feb 2019 18:01:01 GMT) Full text and rfc822 format available.

Message #29 received at 34513 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Eli Zaretskii <eliz <at> gnu.org>, Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: 34513 <at> debbugs.gnu.org, spacibba <at> aol.com
Subject: RE: bug#34513: display-line-numbers in term mode
Date: Wed, 27 Feb 2019 10:00:25 -0800 (PST)
> My problem was, and is, that the name should include "display-width",
> since that's what the function provides.  And the problem, of course,
> is that "display-line-numbers-" already includes "display" and
> "line-number", so repeating any of that produces problematic names.

Not following this thread.  Feel free to ignore.

Why does the name need to include "display-width"?
What's unclear about, say, `line-number-width'?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34513; Package emacs. (Wed, 27 Feb 2019 18:16:02 GMT) Full text and rfc822 format available.

Message #32 received at 34513 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ergus <spacibba <at> aol.com>
Cc: 34513 <at> debbugs.gnu.org
Subject: Re: bug#34513: Fwd: Re: bug#34513: display-line-numbers in term mode
Date: Wed, 27 Feb 2019 20:15:13 +0200
> Date: Wed, 27 Feb 2019 18:46:56 +0100
> From: Ergus <spacibba <at> aol.com>
> 
> Yes I see the limitations, specially when the
> (line-number-display-width) changes due to user interaction. The problem
> is that for a real fix maybe it needs a hook like
> line-number-display-width-change (or equivalent) where to add actions, I
> suppose there are potentially other modes with same issue.

There's no such hook (and providing it would be very hard and largely
useless, as I explained in the past).  Modes which need such
adjustments can use window-scroll-functions and/or
pre-redisplay-functions.  You can see an example in tabulated-list.el.

> The simplest to do (in my opinion) is to make the numbers not available
> at all in term mode and avoid display-line-numbers to be enabled in term
> mode.

Based on prior experience, I very much doubt that this solution will
be accepted by the community.  It's better to allow turning on line
numbers in this mode as well.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34513; Package emacs. (Wed, 27 Feb 2019 18:21:01 GMT) Full text and rfc822 format available.

Message #35 received at 34513 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: 34513 <at> debbugs.gnu.org, spacibba <at> aol.com, monnier <at> IRO.UMontreal.CA
Subject: Re: bug#34513: display-line-numbers in term mode
Date: Wed, 27 Feb 2019 20:20:13 +0200
> Date: Wed, 27 Feb 2019 10:00:25 -0800 (PST)
> From: Drew Adams <drew.adams <at> oracle.com>
> Cc: 34513 <at> debbugs.gnu.org, spacibba <at> aol.com
> 
> What's unclear about, say, `line-number-width'?

It's not unclear, it's wrong.

And even if we disregard the fact that it's wrong, it still includes
"line-number", which is why "display-line-numbers-number-width" gives
me nausea.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34513; Package emacs. (Wed, 27 Feb 2019 19:05:02 GMT) Full text and rfc822 format available.

Message #38 received at 34513 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Eli Zaretskii <eliz <at> gnu.org>, Drew Adams <drew.adams <at> oracle.com>
Cc: 34513 <at> debbugs.gnu.org, spacibba <at> aol.com, monnier <at> IRO.UMontreal.CA
Subject: RE: bug#34513: display-line-numbers in term mode
Date: Wed, 27 Feb 2019 11:04:01 -0800 (PST)
> > What's unclear about, say, `line-number-width'?
> 
> It's not unclear, it's wrong.

I didn't realize that this is a minor-mode global
function.

Emacs convention says that the names of global
symbols (such as this) should start with either
the mode name OR an abbreviation.

The mode name `display-line-numbers' (mode) is
long enough to deserve an abbreviation for use
as prefix.  Please consider coming up with one.

Maybe something like `linenum-' or `line-number-'.

In that case, this function could be called just
`linenum-width' or `linenum-number-width'.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34513; Package emacs. (Sun, 20 Oct 2019 22:56:02 GMT) Full text and rfc822 format available.

Message #41 received at 34513 <at> debbugs.gnu.org (full text, mbox):

From: Ergus <spacibba <at> aol.com>
To: 34513 <at> debbugs.gnu.org
Cc: Eli Zaretskii <eliz <at> gnu.org>, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#34513: display-line-numbers in term mode
Date: Mon, 21 Oct 2019 00:54:46 +0200
Hi:

I have tried the quick solution Stefan proposed to this but there are
still limitations when the number column width change and some
others when resizing the window. Does anyone has a way to improve
this?

I think that this must be simple enough to fix quickly in order to not
pass this to emacs 27.

On the other hand I wanted to ask if new changes like dfci must be
disabled in term-mode by default or we let that configuration to the
user?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34513; Package emacs. (Mon, 21 Oct 2019 06:53:01 GMT) Full text and rfc822 format available.

Message #44 received at 34513 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ergus <spacibba <at> aol.com>
Cc: 34513 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca
Subject: Re: bug#34513: display-line-numbers in term mode
Date: Mon, 21 Oct 2019 09:51:47 +0300
> Date: Mon, 21 Oct 2019 00:54:46 +0200
> From: Ergus <spacibba <at> aol.com>
> Cc: Eli Zaretskii <eliz <at> gnu.org>, Stefan Monnier <monnier <at> iro.umontreal.ca>
> 
> I have tried the quick solution Stefan proposed to this but there are
> still limitations when the number column width change and some
> others when resizing the window. Does anyone has a way to improve
> this?

You can see the various solutions in tabulated-list.el.  I wrote them
because features like package.el need to react to the changing width
of the line numbers.

In addition to the change in the line numbers display width due to
scrolling, there are changes due to resizing the default font.

> On the other hand I wanted to ask if new changes like dfci must be
> disabled in term-mode by default or we let that configuration to the
> user?

This is a different issue, unrelated to this bug report.  Let's
discuss it separately, probably on emacs-devel.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34513; Package emacs. (Mon, 21 Oct 2019 21:45:01 GMT) Full text and rfc822 format available.

Message #47 received at 34513 <at> debbugs.gnu.org (full text, mbox):

From: Ergus <spacibba <at> aol.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 34513 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca
Subject: Re: bug#34513: display-line-numbers in term mode
Date: Mon, 21 Oct 2019 23:44:11 +0200
On Mon, Oct 21, 2019 at 09:51:47AM +0300, Eli Zaretskii wrote:
>> Date: Mon, 21 Oct 2019 00:54:46 +0200
>> From: Ergus <spacibba <at> aol.com>
>> Cc: Eli Zaretskii <eliz <at> gnu.org>, Stefan Monnier <monnier <at> iro.umontreal.ca>
>>
>> I have tried the quick solution Stefan proposed to this but there are
>> still limitations when the number column width change and some
>> others when resizing the window. Does anyone has a way to improve
>> this?
>
>You can see the various solutions in tabulated-list.el.  I wrote them
>because features like package.el need to react to the changing width
>of the line numbers.
>
>In addition to the change in the line numbers display width due to
>scrolling, there are changes due to resizing the default font.
>
Hi Eli:

I see that, but what about when the window width changes? Are there any
hook we ca use?

>> On the other hand I wanted to ask if new changes like dfci must be
>> disabled in term-mode by default or we let that configuration to the
>> user?
>
>This is a different issue, unrelated to this bug report.  Let's
>discuss it separately, probably on emacs-devel.
>
>Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34513; Package emacs. (Tue, 22 Oct 2019 15:12:02 GMT) Full text and rfc822 format available.

Message #50 received at 34513 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ergus <spacibba <at> aol.com>
Cc: 34513 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca
Subject: Re: bug#34513: display-line-numbers in term mode
Date: Tue, 22 Oct 2019 18:11:34 +0300
> Date: Mon, 21 Oct 2019 23:44:11 +0200
> From: Ergus <spacibba <at> aol.com>
> Cc: 34513 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca
> 
> >You can see the various solutions in tabulated-list.el.  I wrote them
> >because features like package.el need to react to the changing width
> >of the line numbers.
> >
> >In addition to the change in the line numbers display width due to
> >scrolling, there are changes due to resizing the default font.
> >
> Hi Eli:
> 
> I see that, but what about when the window width changes? Are there any
> hook we ca use?

Window width changes are unrelated to line numbers, right?

Is window-size-change-functions what you want?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34513; Package emacs. (Tue, 22 Oct 2019 16:54:01 GMT) Full text and rfc822 format available.

Message #53 received at 34513 <at> debbugs.gnu.org (full text, mbox):

From: Ergus <spacibba <at> aol.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 34513 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca
Subject: Re: bug#34513: display-line-numbers in term mode
Date: Thu 01 Jan 1970 01:00:00 AM CET
--text follows this line--: --text follows this line--
Hi Eli: 
MIME-Version: 1.0
Content-Type: text/plain

Eli Zaretskii <eliz <at> gnu.org> writes:

>> Date: Mon, 21 Oct 2019 23:44:11 +0200
>> From: Ergus <spacibba <at> aol.com>
>> Cc: 34513 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca
>>
>> >You can see the various solutions in tabulated-list.el.  I wrote them
>> >because features like package.el need to react to the changing width
>> >of the line numbers.
>> >
>> >In addition to the change in the line numbers display width due to
>> >scrolling, there are changes due to resizing the default font.
>> >
>> Hi Eli:
>>
>> I see that, but what about when the window width changes? Are there any
>> hook we ca use?
>
> Window width changes are unrelated to line numbers, right?
>
> Is window-size-change-functions what you want?

Yes they are unrelated, but the issue is the same... when and how to
trigger a line-width update/recalculation.

Actually on a windows resize the term-line width is not updated
either. So the new outputs after that assume the same window width. The
line-number-width is just another side of the same problem where the
line-width is not recalculated..

On window increase size the issue is not so annoying (it is not right,
but it works) but on window decrease size (or line-number-width
increase) it is worth because the lines adds a \ and break.

So a right fix maybe should recalculate the line-width more dynamically
(for example when inserting RET in term mode)

Does it makes sense?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34513; Package emacs. (Tue, 22 Oct 2019 17:34:01 GMT) Full text and rfc822 format available.

Message #56 received at 34513 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ergus <spacibba <at> aol.com>
Cc: 34513 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca
Subject: Re: bug#34513: display-line-numbers in term mode
Date: Tue, 22 Oct 2019 20:33:27 +0300
> From: Ergus <spacibba <at> aol.com>
> Cc: 34513 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca
> Date: Thu 01 Jan 1970 01:00:00 AM CET
> > Window width changes are unrelated to line numbers, right?
> >
> > Is window-size-change-functions what you want?
> 
> Yes they are unrelated, but the issue is the same...

No, the issue is not the same.  When a window is resized, it is
completely redrawn, and as part of that the line numbers are
recalculated and redisplayed.  That's because line-number display is
an inherent part of redisplay.

> Actually on a windows resize the term-line width is not updated
> either. So the new outputs after that assume the same window width. The
> line-number-width is just another side of the same problem where the
> line-width is not recalculated..
> 
> On window increase size the issue is not so annoying (it is not right,
> but it works) but on window decrease size (or line-number-width
> increase) it is worth because the lines adds a \ and break.
> 
> So a right fix maybe should recalculate the line-width more dynamically
> (for example when inserting RET in term mode)

So is window-size-change-functions what you need to use to hook into
the size changes?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34513; Package emacs. (Tue, 22 Oct 2019 23:07:01 GMT) Full text and rfc822 format available.

Message #59 received at 34513 <at> debbugs.gnu.org (full text, mbox):

From: Ergus <spacibba <at> aol.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 34513 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca
Subject: Re: bug#34513: display-line-numbers in term mode
Date: Wed, 23 Oct 2019 01:06:05 +0200
On Tue, Oct 22, 2019 at 08:33:27PM +0300, Eli Zaretskii wrote:
>> From: Ergus <spacibba <at> aol.com>
>> Cc: 34513 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca
>> Date: Thu 01 Jan 1970 01:00:00 AM CET
>> > Window width changes are unrelated to line numbers, right?
>> >
>> > Is window-size-change-functions what you want?
>>
>> Yes they are unrelated, but the issue is the same...
>
>No, the issue is not the same.  When a window is resized, it is
>completely redrawn, and as part of that the line numbers are
>recalculated and redisplayed.  That's because line-number display is
>an inherent part of redisplay.
>
Hi:

I don't have too much time to be looking into this. But actually one of
the issues I had with the Stefan's solution is that sometimes I get:

Error adjusting window size: (wrong-type-argument wholenump 78.0)

Actually very often.

On the other hand, I am not sure that the fix will be needed in
lisp/window.el as it may affect many other things around.

Maybe we need the change in term.el itself as it seems to be the only
one with the issue. Otherwise the fix you made for tabulated-list.el
will be needed as a function in some other place we can access from
term-mode.

Could you please give a look into it?


>> Actually on a windows resize the term-line width is not updated
>> either. So the new outputs after that assume the same window width. The
>> line-number-width is just another side of the same problem where the
>> line-width is not recalculated..
>>
>> On window increase size the issue is not so annoying (it is not right,
>> but it works) but on window decrease size (or line-number-width
>> increase) it is worth because the lines adds a \ and break.
>>
>> So a right fix maybe should recalculate the line-width more dynamically
>> (for example when inserting RET in term mode)
>
>So is window-size-change-functions what you need to use to hook into
>the size changes?

Yes I suppose it is. But I have not clear how to use it :(.

Again,
Could you please give a look into it?
Please.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34513; Package emacs. (Wed, 23 Oct 2019 16:23:02 GMT) Full text and rfc822 format available.

Message #62 received at 34513 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ergus <spacibba <at> aol.com>
Cc: 34513 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca
Subject: Re: bug#34513: display-line-numbers in term mode
Date: Wed, 23 Oct 2019 19:21:36 +0300
> Date: Wed, 23 Oct 2019 01:06:05 +0200
> From: Ergus <spacibba <at> aol.com>
> Cc: 34513 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca
> 
> Again,
> Could you please give a look into it?

Look at what? at fixing term.el myself in this case?  Or something
else?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34513; Package emacs. (Wed, 23 Oct 2019 16:51:01 GMT) Full text and rfc822 format available.

Message #65 received at 34513 <at> debbugs.gnu.org (full text, mbox):

From: Ergus <spacibba <at> aol.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 34513 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca
Subject: Re: bug#34513: display-line-numbers in term mode
Date: Wed, 23 Oct 2019 18:50:05 +0200
On Wed, Oct 23, 2019 at 07:21:36PM +0300, Eli Zaretskii wrote:
>> Date: Wed, 23 Oct 2019 01:06:05 +0200
>> From: Ergus <spacibba <at> aol.com>
>> Cc: 34513 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca
>>
>> Again,
>> Could you please give a look into it?
>
>Look at what? at fixing term.el myself in this case?  Or something
>else?

At least if the fix should be in term.el or in window.el like the one
proposed by Stefan.

The lisp side is too high level, and I don't want to waste time
reinventing the wheel.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34513; Package emacs. (Sun, 20 Sep 2020 18:31:01 GMT) Full text and rfc822 format available.

Message #68 received at 34513 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: 34513 <at> debbugs.gnu.org, Ergus <spacibba <at> aol.com>
Subject: Re: bug#34513: display-line-numbers in term mode
Date: Sun, 20 Sep 2020 20:30:33 +0200
[Message part 1 (text/plain, inline)]
Stefan Monnier <monnier <at> IRO.UMontreal.CA> writes:

> 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).

[...]

> -	   (ncols (/ window-width font-width)))
> +	   (ncols (- (/ window-width font-width) (line-number-display-width))))

I tried this patch in Emacs 28, and it didn't seem to help much.

To test

emacs -Q
M-x global-display-line-numbers-mode RET
M-x term RET RET
emacs -Q -nw

[Message part 2 (image/png, inline)]
[Message part 3 (text/plain, inline)]
Note wrapped mode line of the inner Emacs.

(This works fine if display-line-numbers-mode is not on.)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34513; Package emacs. (Sun, 20 Sep 2020 18:51:02 GMT) Full text and rfc822 format available.

Message #71 received at 34513 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 34513 <at> debbugs.gnu.org, spacibba <at> aol.com, monnier <at> IRO.UMontreal.CA
Subject: Re: bug#34513: display-line-numbers in term mode
Date: Sun, 20 Sep 2020 21:50:30 +0300
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Date: Sun, 20 Sep 2020 20:30:33 +0200
> Cc: 34513 <at> debbugs.gnu.org, Ergus <spacibba <at> aol.com>
> 
> > -	   (ncols (/ window-width font-width)))
> > +	   (ncols (- (/ window-width font-width) (line-number-display-width))))
> 
> I tried this patch in Emacs 28, and it didn't seem to help much.

Not even if you call line-number-display-width with arg of 'columns'?

Does it help to set COLUMNS in the environment to something like 76
before starting "M-x term"?  If it does, that would at least tell us
the columns are the cause of the problem.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34513; Package emacs. (Sun, 20 Sep 2020 19:58:01 GMT) Full text and rfc822 format available.

Message #74 received at 34513 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 34513 <at> debbugs.gnu.org, spacibba <at> aol.com, monnier <at> IRO.UMontreal.CA
Subject: Re: bug#34513: display-line-numbers in term mode
Date: Sun, 20 Sep 2020 21:56:54 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

> Not even if you call line-number-display-width with arg of 'columns'?

Yes, this works -- the Emacs-in-Emacs displays perfectly with this patch:

diff --git a/lisp/window.el b/lisp/window.el
index f1ee87aad2..72957d846a 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -2172,7 +2172,8 @@ 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 'columns))))
       (if (and (display-graphic-p)
 	       overflow-newline-into-fringe
                (not


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34513; Package emacs. (Mon, 21 Sep 2020 02:28:01 GMT) Full text and rfc822 format available.

Message #77 received at 34513 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 34513 <at> debbugs.gnu.org, spacibba <at> aol.com, monnier <at> IRO.UMontreal.CA
Subject: Re: bug#34513: display-line-numbers in term mode
Date: Mon, 21 Sep 2020 05:27:40 +0300
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Cc: monnier <at> IRO.UMontreal.CA,  34513 <at> debbugs.gnu.org,  spacibba <at> aol.com
> Date: Sun, 20 Sep 2020 21:56:54 +0200
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> > Not even if you call line-number-display-width with arg of 'columns'?
> 
> Yes, this works -- the Emacs-in-Emacs displays perfectly with this patch:
> 
> diff --git a/lisp/window.el b/lisp/window.el
> index f1ee87aad2..72957d846a 100644
> --- a/lisp/window.el
> +++ b/lisp/window.el
> @@ -2172,7 +2172,8 @@ 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 'columns))))
>        (if (and (display-graphic-p)
>  	       overflow-newline-into-fringe
>                 (not

Great, then please install, and thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34513; Package emacs. (Mon, 21 Sep 2020 14:11:01 GMT) Full text and rfc822 format available.

Message #80 received at 34513 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 34513 <at> debbugs.gnu.org, spacibba <at> aol.com, monnier <at> IRO.UMontreal.CA
Subject: Re: bug#34513: display-line-numbers in term mode
Date: Mon, 21 Sep 2020 16:10:29 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

> Great, then please install, and thanks.

OK; applied to Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 21 Sep 2020 14:11:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 34513 <at> debbugs.gnu.org and Ergus <spacibba <at> aol.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 21 Sep 2020 14:11:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 20 Oct 2020 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 189 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.