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: Eli Zaretskii
Subject: bug#17303: On tty or -nw, (window-body-width) is one column too big.
Date: Mon, 21 Apr 2014 19:07:39 +0300

> Date: Mon, 21 Apr 2014 15:43:35 +0000
> Cc: address@hidden
> From: Alan Mackenzie <address@hidden>
> 
> > 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.

Which it sometimes is.  I was drawing your attention to some APIs that
you should know about if you want to mess with redisplay.

> What I ended up using is
> 
>     (- (current-column)
>        (progn (vertical-motion 0) (current-column)))
> 
> (with a save-excursion at a strategic surrounding point).

That should do, but beware of display properties on that line.

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

Your description above indicated that you already know where you are.
If you don't, compare with what window-start returns.

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

You can't.

> > So can we close this bug report?
> 
> I've just closed it.

Thanks.





reply via email to

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