Subject: bug#9246: Scrolling bug with word-wrap in emacs -nw

From: Eli Zaretskii <[email-masked]>
Date: Fri, 30 Dec 2011 20:13:56 +0200

> From: Antoine Levitt <[email-masked]>
> Cc: [email-masked],  [email-masked]
> Date: Fri, 30 Dec 2011 18:10:33 +0100
> 
> >> That works pretty well! (when hooked into post-command-hook) Except that
> >> sometimes posn-at-point is nil, presumably because redisplay hasn't
> >> taken place yet.
> >
> > If posn-at-point returns nil, it means point is outside of the
> > displayed portion, which in itself is something you may want to know,
> > I think.
> 
> In some cases, yes. In other cases, it's just that redisplay hasn't
> taken place yet (for instance, beginning-of-buffer, then end-of-buffer,
> posn-at-point returns nil on the post-command-hook of end-of-buffer)

posn-at-point does not depend on redisplay, it does its job regardless
of whether the display is up to date.  But if you moved point past the
window edge, and redisplay didn't yet happen, you will get nil because
point is not visible in the window.

> >> I couldn't find a post-redisplay-hook, which might be more
> >> appropriate. Is there one?
> >
> > There's redisplay-end-trigger-functions, but it's deprecated.  Stefan
> > expressed the desire to have a hook you want many times in the past,
> > but no one stepped forward to do the job yet.
> 
> Isn't it just a line at the end of the appropriate function?

I don't know, I didn't research the issue.  But I wouldn't be
surprised if it's not that simple.  Nothing is ever simple with Emacs
display engine.