Subject: bug#9415: 23.3.50; unerased cursor in a row that extends face to end of line

From: YAMAMOTO Mitsuharu <[email-masked]>
Date: Thu, 01 Sep 2011 09:29:53 +0900

Steps to reproduce:

  1. $ emacs -Q
  2. M-x font-lock-mode RET
  3. M-x blink-cursor-mode RET
  4. C-SPC C-p
  5. M-o o mode-line RET
  6. C-x 3
  7. C-x 1
  8. C-p

Result:

  The cursor at the beginning of the line whose face is mode-line is
  unerased.

The patch below seems to fix it, and the cause of the problem is
explained in the added comment.

=== modified file 'src/xdisp.c'
*** src/xdisp.c	2011-07-23 07:32:42 +0000
--- src/xdisp.c	2011-09-01 00:03:30 +0000
***************
*** 24278,24284 ****
      {
        int yb = window_text_bottom_y (w);
        struct glyph_row *row;
!       int cursor_cleared_p;
        struct glyph_row *first_overlapping_row, *last_overlapping_row;
  
        TRACE ((stderr, "expose_window (%d, %d, %d, %d)\n",
--- 24278,24284 ----
      {
        int yb = window_text_bottom_y (w);
        struct glyph_row *row;
!       int cursor_cleared_p, phys_cursor_on_p;
        struct glyph_row *first_overlapping_row, *last_overlapping_row;
  
        TRACE ((stderr, "expose_window (%d, %d, %d, %d)\n",
***************
*** 24298,24303 ****
--- 24298,24310 ----
        else
  	cursor_cleared_p = 0;
  
+       /* If the row containing the cursor extends face to end of line,
+ 	 then expose_area might overwrite the cursor outside the
+ 	 rectangle and thus notice_overwritten_cursor might clear
+ 	 w->phys_cursor_on_p.  We remember the original value and
+ 	 check later if it is changed.  */
+       phys_cursor_on_p = w->phys_cursor_on_p;
+ 
        /* Update lines intersecting rectangle R.  */
        first_overlapping_row = last_overlapping_row = NULL;
        for (row = w->current_matrix->rows;
***************
*** 24364,24370 ****
  	  x_draw_vertical_border (w);
  
  	  /* Turn the cursor on again.  */
! 	  if (cursor_cleared_p)
  	    update_window_cursor (w, 1);
  	}
      }
--- 24371,24378 ----
  	  x_draw_vertical_border (w);
  
  	  /* Turn the cursor on again.  */
! 	  if (cursor_cleared_p
! 	      || (phys_cursor_on_p && !w->phys_cursor_on_p))
  	    update_window_cursor (w, 1);
  	}
      }

				     YAMAMOTO Mitsuharu
				[email-masked]

If Emacs crashed, and you have the Emacs process in the gdb debugger,
please include the output from the following gdb commands:
    `bt full' and `xbacktrace'.
For information about debugging Emacs, please read the file
/Users/mituharu/src/bzr/emacs/emacs-23/etc/DEBUG.

In GNU Emacs 23.3.50.1 (x86_64-apple-darwin11.0.0, X toolkit)
 of 2011-08-31 on yamamoto-no-iMac.local
Windowing system distributor `The X.Org Foundation', version 11.0.11002000
configured using `configure  '--with-jpeg=no' '--with-gif=no' '--with-tiff=no''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: ja_JP.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
<help-echo> <help-echo> <help-echo> <help-echo> <help-echo> 
<help-echo> <help-echo> <help-echo> <help-echo> <help-echo> 
<help-echo> <help-echo> <help-echo> <help-echo> <help-echo> 
<help-echo> <menu-bar> <help-menu> <send-emacs-bug
-report>

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.

Load-path shadows:
None found.

Features:
(shadow sort mail-extr message ecomplete rfc822 mml easymenu mml-sec
password-cache mm-decode mm-bodies mm-encode mailcap mail-parse rfc2231
rfc2047 rfc2045 qp ietf-drums mailabbrev nnheader gnus-util netrc
time-date mm-util mail-prsvr gmm-utils wid-edit mailheader canlock sha1
hex-util hashcash mail-utils emacsbug japan-util tooltip ediff-hook
vc-hooks lisp-float-type mwheel x-win x-dnd font-setting tool-bar dnd
fontset image fringe lisp-mode register page menu-bar rfn-eshadow timer
select scroll-bar mldrag mouse jit-lock font-lock syntax facemenu
font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan
thai tai-viet lao korean japanese hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese case-table epa-hook
jka-cmpr-hook help simple abbrev loaddefs button minibuffer faces
cus-face files text-properties overlay md5 base64 format env code-pages
mule custom widget hashtable-print-readable backquote
make-network-process font-render-setting x-toolkit x multi-tty emacs)