[Top][All Lists]

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

bug#17303: On tty or -nw, (window-body-width) is one column too big.

From: Alan Mackenzie
Subject: bug#17303: On tty or -nw, (window-body-width) is one column too big.
Date: Sun, 20 Apr 2014 20:39:04 +0000
User-agent: Mutt/1.5.21 (2010-09-15)

Hi, Eli.

On Sun, Apr 20, 2014 at 10:35:24PM +0300, Eli Zaretskii wrote:
> > Date: Sun, 20 Apr 2014 17:03:43 +0000
> > From: Alan Mackenzie <address@hidden>

> > I'm doing something at the moment involving scrolling of windows, and I
> > need to know at what "visual" column point is in.  So, naturally, I do

> >     (% (current-column) (window-body-width))

> > .  At the start of the first continuation line, this formula (correctly)
> > returns 0 on a GUI, but (e.g.) 79 on a tty or in emacs -nw.

> You mean, it says 80 in a GUI session, not 0, right?

Er, no.  It says 0 in a GUI session.  In the GUI, (window-body-width) is
the number of characters which fit on the line.  In a tty,
(window-body-width) is ONE MORE than that number.

> > This is caused by emacs counting the "\" character in the right margin as
> > part of the body-width.

> No, it's because the last character in the continued like is in column
> 78 on a TTY, but in column 79 in a GUI session.  Emacs counts columns
> in continuation lines starting from the last column in the previous
> line, as you'd expect.  IOW, the continued line is treated as one long
> line, and all its columns counted contiguously.

Yes, this is true, but it's (window-body-width) which is inconsistent
between GUI and tty.

> It is true that the "\" character on a TTY takes up one column, and
> thus leaves only 79 columns for text, but what else can Emacs do?

Tell me that (window-body-width) is 79, not 80.

> > This seems like a bad idea.  I think it's also a bug.

> What would you like Emacs to do instead, given what I just explained?

See above.

> > So, is there a better method of determining the "visual" column point is
> > in?

> current-column is it.  Please tell why it doesn't fit your needs.

current-column provides the "logical" column (e.g. 79).  I need the
"visual" column (e.g. 0).

I'm working on getting follow-mode's scrolling working properly.  I have
a situation where:
o - point is at Col 79, this being at the start of a continuation line.
o - this position is one line below the bottom of the window
o - (but hasn't been redisplayed yet).
o - set-window-start has NOT been called with a nil NOFORCE parameter.

If I were to allow the redisplay without further action, redisplay would
scroll the window back upwards to ensure point is displayed.  This would
negate the purpose of the scrolling.  I want to move point back into the
window before the redisplay.  So I attempt the following:
o - (setq dest-col (Determine-the-visual-column-point-is-in))
o - (vertical-motion -1)
o - (move-to-column dest-col)

However this last action becomes, on a tty, (move-to-column 79) putting
point back where it started.  :-(

It is (Determine-the-visual-column-..) which gives me trouble.  On a GUI,
I can use

    (% (current-column) (window-body-width))

, but this fails on a tty, as noted above.

Alan Mackenzie (Nuremberg, Germany).

reply via email to

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