Subject: bug#63271: 29.0.90; broken mouse-face

From: Stephen Berman <[email-masked]>
Date: Tue, 09 May 2023 12:07:25 +0200

On Tue, 09 May 2023 11:49:00 +0200 Stephen Berman <[email-masked]> wrote:

> On Tue, 09 May 2023 11:36:01 +0300 Eli Zaretskii <[email-masked]> wrote:
>
>>> From: Juri Linkov <[email-masked]>
>>> Cc: [email-masked],  [email-masked]
>>> Date: Tue, 09 May 2023 09:45:16 +0300
>>>
>>> > And what exactly is the manifestation of the problem in the image you
>>> > posted? that wide black part that hides the letters "ODO"? or
>>> > something else?
>>>
>>> The letters turn into black boxes while moving the cursor over them
>>> when the mouse pointer is over the text.
>>
>> Could you or Stephen please perform the following experiment, using
>> the latest emacs-29 branch, and report the results:
>>
>>   $ gdb ./emacs
>>   ...
>>   (gdb) break xdisp.c:33519
>>   (gdb) run -Q
>>
>> The breakpoint is here:
>>
>> 	  if (end_hpos > start_hpos)
>> 	    {
>> 	      draw_row_with_mouse_face (w, start_x, row,
>> 					start_hpos, end_hpos, draw);
>>
>> 	      row->mouse_face_p   <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>> 		= draw == DRAW_MOUSE_FACE || draw == DRAW_IMAGE_RAISED;
>> 	    }
>>
>> Once inside Emacs after "run -Q", first turn off blink-cursor-mode and
>> global-eldoc-mode, then evaluate the recipe:
>>
>>   M-: (insert " " (propertize "TODO" 'face '(:inherit variable-pitch) 'mouse-face 'highlight)) RET
>>
>> Then move the mouse pointer over the "TODO" text.  The breakpoint will
>> break, and GDB will kick in.  Then type:
>>
>>   (gdb) pgrow
>>   (gdb) continue
>>
>> The breakpoint will break again, and the display of Emacs you are
>> debugging will show the mouse highlight.  Then type again:
>>
>>   (gdb) pgrow
>>
>> And show everything that GDB displays as result of the two "pgrow"
>> commands.
>
> Here's what I get:
>
> Thread 1 "emacs" hit Breakpoint 3, show_mouse_face (
>     hlinfo=hlinfo@entry=0x555556145870, draw=draw@entry=DRAW_MOUSE_FACE)
>     at /home/steve/src/emacs/emacs-29/src/xdisp.c:33519
> 33519		      row->mouse_face_p
> (gdb) pgrow
> TEXT: 6 glyphs
>   0    0: CHAR[ ] pos=146 blev=0,btyp=L w=8 a+d=13+4 MB
>   1    8: CHAR[T] pos=147 blev=0,btyp=L w=8 a+d=13+4 MB
>   2   16: CHAR[O] pos=148 blev=0,btyp=L w=8 a+d=13+4 MB
>   3   24: CHAR[D] pos=149 blev=0,btyp=L w=8 a+d=13+4 MB
>   4   32: CHAR[O] pos=150 blev=0,btyp=L w=8 a+d=13+4 MB
>   5   40: CHAR[ ] pos=0 blev=0,btyp=B w=8 a+d=13+4 MB
> (gdb) continue
> Continuing.
>
> Thread 1 "emacs" hit Breakpoint 3, show_mouse_face (hlinfo=0x555556145870,
>     draw=draw@entry=DRAW_MOUSE_FACE)
>     at /home/steve/src/emacs/emacs-29/src/xdisp.c:33519
> 33519		      row->mouse_face_p
> (gdb) pgrow
> TEXT: 6 glyphs
>   0    0: CHAR[ ] pos=146 blev=0,btyp=L w=8 a+d=13+4 MB
>   1    8: CHAR[T] pos=147 blev=0,btyp=L w=8 a+d=13+4 MB
>   2   16: CHAR[O] pos=148 blev=0,btyp=L w=8 a+d=13+4 MB
>   3   24: CHAR[D] pos=149 blev=0,btyp=L w=8 a+d=13+4 MB
>   4   32: CHAR[O] pos=150 blev=0,btyp=L w=8 a+d=13+4 MB
>   5   40: CHAR[ ] pos=0 blev=0,btyp=B w=8 a+d=13+4 MB

When I carried out your instructions exactly, I was surprised to see
that "TODO" showed mouse-face highlighting after typing `continue'.
Then I ran my test outside of gdb and indeed, in *scratch* the
problematic characters do show mouse-face highlighting, i.e. in
lisp-interaction mode, but not in fundamental-mode.  Then I returned to
gdb and redid your instructions but switched to a buffer in
fundamental-mode before inserting the propertized string.  Here are the
results:

Thread 1 "emacs" hit Breakpoint 3, show_mouse_face (
    hlinfo=hlinfo@entry=0x555556145540, draw=draw@entry=DRAW_MOUSE_FACE)
    at /home/steve/src/emacs/emacs-29/src/xdisp.c:33519
33519		      row->mouse_face_p
(gdb) pgrow
TEXT: 6 glyphs
  0    0: CHAR[ ] pos=1 blev=0,btyp=L w=8 a+d=13+4 MB
  1    8: CHAR[T] pos=2 blev=0,btyp=L w=8 a+d=13+4 face=24 MB
  2   16: CHAR[O] pos=3 blev=0,btyp=L w=10 a+d=13+4 face=24 MB
  3   26: CHAR[D] pos=4 blev=0,btyp=L w=10 a+d=13+4 face=24 MB
  4   36: CHAR[O] pos=5 blev=0,btyp=L w=10 a+d=13+4 face=24 MB
  5   46: CHAR[ ] pos=0 blev=0,btyp=B w=8 a+d=13+4 MB
(gdb) continue
Continuing.

Thread 1 "emacs" hit Breakpoint 3, show_mouse_face (hlinfo=0x555556145540,
    draw=draw@entry=DRAW_MOUSE_FACE)
    at /home/steve/src/emacs/emacs-29/src/xdisp.c:33519
33519		      row->mouse_face_p
(gdb) pgrow
TEXT: 6 glyphs
  0    0: CHAR[ ] pos=1 blev=0,btyp=L w=8 a+d=13+4 MB
  1    8: CHAR[T] pos=2 blev=0,btyp=L w=8 a+d=13+4 face=24 MB
  2   16: CHAR[O] pos=3 blev=0,btyp=L w=10 a+d=13+4 face=24 MB
  3   26: CHAR[D] pos=4 blev=0,btyp=L w=10 a+d=13+4 face=24 MB
  4   36: CHAR[O] pos=5 blev=0,btyp=L w=10 a+d=13+4 face=24 MB
  5   46: CHAR[ ] pos=0 blev=0,btyp=B w=8 a+d=13+4 MB

Steve Berman