Subject: Re: bug#22873: Can we support multiple cursors?

From: Eli Zaretskii <[email-masked]>
Date: Mon, 14 Aug 2017 18:01:07 +0300

> Date:  Sun, 13 Aug 2017 20:20:10 -0700
> From:  Keith David Bershatsky <[email-masked]>
> Cc:  [email-masked],John Wiegley <[email-masked]>,Marcin Borkowski <[email-masked]>,Richard Stallman <[email-masked]>
> 
> I read through the comments in xdisp.c that immediately precede move_it_to and I also looked at all of it uses within xdisp.c, but I am still unclear how to limit move_it_to the it.last_visible_y.

Like this:

 move_it_to (&it, POS, -1, it.last_visible_y - 1, -1, MOVE_TO_POS | MOVE_TO_Y);

where POS is the buffer position.  You can find many examples of this
in xdisp.c.

> I got the impression that if I put it.last_visible_y as an argument of move_it_to, that `it` would move to that location instead of POS if POS cannot be found.

It stops when the first condition is satisfied.  If it reaches POS
before the window end, it stops there; otherwise it stops at the
window end.  It is then a simple matter of testing IT_CHARPOS(&it)
against POS to see which of these conditions caused it to stop.