Subject: bug#11720: 24.1; outline-mode : cursor and point mismatch ?

From: Eli Zaretskii <[email-masked]>
Date: Sat, 16 Jun 2012 14:55:18 +0300

> Date: Fri, 15 Jun 2012 16:31:15 +0200
> From: Nicolas Richard <[email-masked]>
> 
> Say I have a buffer with the two lines:
> * A
> Some text
> 
> and I hit C-c C-d (hide-subtree) and M-<. Now I have:
> * A...
> ^
> where '...' indicates hidden text and '^' indicates the
> position of the cursor (on the title line).
> 
> Then hitting C-f a few times will advance the cursor successively :
> * A...
>   ^
> * A...
>    ^
> * A...
>       ^ <- I did not expect this.
> * A...
>        ^

Actually, the behavior in Emacs 24.1 is this:

* A...
  ^
* A...
      ^ <- I did not expect this.
* A...
       ^

> The behaviour that I expected was :
> * A...
>   ^
> * A...
>    ^
> * A...
>     ^   <- different
> * A...
>        ^

No, you expected this:

* A...
  ^
* A...
   ^   <- different
* A...
       ^

Anyway, I think I fixed this now, in revision 108626 on the trunk.  If
you can build your own Emacs, the patch is below; please try it and
tell if the problem is solved for you, or there are any leftovers.

Thanks.

--- src/xdisp.c	2012-06-16 10:18:21 +0000
+++ src/xdisp.c	2012-06-16 11:47:44 +0000
@@ -13937,16 +13937,13 @@ set_cursor_from_row (struct window *w, s
 		    break;
 		  }
 		/* See if we've found a better approximation to
-		   POS_BEFORE or to POS_AFTER.  Note that we want the
-		   first (leftmost) glyph of all those that are the
-		   closest from below, and the last (rightmost) of all
-		   those from above.  */
+		   POS_BEFORE or to POS_AFTER.  */
 		if (0 > dpos && dpos > pos_before - pt_old)
 		  {
 		    pos_before = glyph->charpos;
 		    glyph_before = glyph;
 		  }
-		else if (0 < dpos && dpos <= pos_after - pt_old)
+		else if (0 < dpos && dpos < pos_after - pt_old)
 		  {
 		    pos_after = glyph->charpos;
 		    glyph_after = glyph;
@@ -14030,7 +14027,7 @@ set_cursor_from_row (struct window *w, s
 		    pos_before = glyph->charpos;
 		    glyph_before = glyph;
 		  }
-		else if (0 < dpos && dpos <= pos_after - pt_old)
+		else if (0 < dpos && dpos < pos_after - pt_old)
 		  {
 		    pos_after = glyph->charpos;
 		    glyph_after = glyph;