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

From: Eli Zaretskii <[email-masked]>
Date: Sun, 20 Apr 2014 22:35:24 +0300

> Date: Sun, 20 Apr 2014 17:03:43 +0000
> From: Alan Mackenzie <[email-masked]>
> 
> 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?

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

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?

> 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?

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