Subject: bug#17744: 24.3.91; Cursor drawn at EOL while it's at BOL

From: Eli Zaretskii <[email-masked]>
Date: Tue, 10 Jun 2014 19:37:46 +0300

> From: Stefan <[email-masked]>
> Date: Tue, 10 Jun 2014 01:18:20 -0400
> 
> 
>    emacs -Q
> 
>    (progn (goto-char (point-min)) (forward-line 1)
>      (let ((ol (make-overlay (point) (point)))
>            (str "TOTO"))
>        (put-text-property 0 1 'cursor 1 str)
>        (overlay-put ol 'after-string str)))
> 
> Then do:
> 
>    M-<
>    C-n
> 
> Notice that the cursor is drawn at EOL whereas it should be drawn at BOL.

The patch below fixes this.  However, since this problem exists in
Emacs 24.3 as well, and so is not really a regression, I need your
permission to install on the release branch.

--- src/xdisp.c~0	2014-05-26 06:51:21 +0300
+++ src/xdisp.c	2014-06-10 18:37:35 +0300
@@ -14421,7 +14421,7 @@ set_cursor_from_row (struct window *w, s
 					      pos_after, 0);
 
 		if (prop_pos >= pos_before)
-		  bpos_max = prop_pos - 1;
+		  bpos_max = prop_pos;
 	      }
 	    if (INTEGERP (chprop))
 	      {
@@ -14495,7 +14495,7 @@ set_cursor_from_row (struct window *w, s
 					      pos_after, 0);
 
 		if (prop_pos >= pos_before)
-		  bpos_max = prop_pos - 1;
+		  bpos_max = prop_pos;
 	      }
 	    if (INTEGERP (chprop))
 	      {
@@ -14525,7 +14525,7 @@ set_cursor_from_row (struct window *w, s
      GLYPH_BEFORE and GLYPH_AFTER.  */
   if (!((row->reversed_p ? glyph > glyphs_end : glyph < glyphs_end)
 	&& BUFFERP (glyph->object) && glyph->charpos == pt_old)
-      && !(bpos_max < pt_old && pt_old <= bpos_covered))
+      && !(bpos_max <= pt_old && pt_old <= bpos_covered))
     {
       /* An empty line has a single glyph whose OBJECT is zero and
 	 whose CHARPOS is the position of a newline on that line.