bug-gnu-emacs
[Top][All Lists]
Advanced

[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: Mon, 21 Apr 2014 15:43:35 +0000
User-agent: Mutt/1.5.21 (2010-09-15)

Hi, Eli.

On Mon, Apr 21, 2014 at 09:56:01AM +0300, Eli Zaretskii wrote:
> > Date: Sun, 20 Apr 2014 20:39:04 +0000
> > Cc: 17303@debbugs.gnu.org
> > From: Alan Mackenzie <acm@muc.de>

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

> It can't.  It's not designed for what you need.  You should use
> different APIs for what you want; see below.

OK.

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

> Then what you want is '(car (posn-col-row (posn-at-point)))'.  But see
> below.

posn-at-point only works when point is inside a window.  What I ended up
using is

    (- (current-column)
       (progn (vertical-motion 0) (current-column)))

(with a save-excursion at a strategic surrounding point).

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

> I think you just need to use pos-visible-in-window-p instead of all
> that complexity: if that function returns an indication that point is
> not visible, move it back until it is.

pos-visible-in-window-p unfortunately doesn't reveal whether pos is above
or below the window, it just returns nil.

> There's also the new pre-redisplay-function hook that you might find
> useful.

OK, I'll look at this sometime.

> Don't try to outsmart redisplay; instead, ask redisplay to tell you
> what it already knows.  The functions I mentioned are interfaces
> exposed by redisplay for this very purpose.

follow-mode is about nothing else but outsmarting redisplay.  ;-)  As its
original author recently discussed with you, it would be nice if there
were more support for it inside redisplay, but that means Somebody (tm)
stepping up to the plate and implementing it.

> So can we close this bug report?

I've just closed it.

Thanks for all the help!

-- 
Alan Mackenzie (Nuremberg, Germany).





reply via email to

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