Subject: Re: bug#78218: 30.1; mouse-highlight variable does not work on macOS

From: Eli Zaretskii <[email-masked]>
Date: Sat, 03 May 2025 14:10:48 +0300

> From: Gerd Möllmann <[email-masked]>
> Cc: Robert Morelli <[email-masked]>,  Alan Third <[email-masked]>,
>   [email-masked]
> Date: Sat, 03 May 2025 10:29:16 +0200
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> >> auth-sender: [email-masked]
> >> Date: Fri, 2 May 2025 12:19:34 -0600
> >> From: Robert Morelli <[email-masked]>
> >> 
> >> According to the documentation for mouse-highlight, "If the value is an
> >> integer, highlighting is shown only after moving the mouse, while
> >> keyboard input turns off the highlight even when the mouse is over the
> >> clickable text." This is not working, even if Emacs is started with
> >> the --no-init option. I've checked with several independent builds on
> >> macOS, versions 29 up to 30.1. I'm running macOS Sequoia 15.3.2.
> >> 
> >> Note that the problem is especially distracting in situations where a
> >> "vertical list" is invoked by a keyboard action but the mouse cursor 
> >> happens to be over an item of the list, in which case that item is
> >> 
> >> highlighted, but with no functional significance.
> >> 
> >> The specific context where this became problematic for me, is using 
> >> Vertico, and other similar packages, but the problem manifests in plain 
> >> Emacs with no third party packages installed.
> >> 
> >> It took me some time to recognize where the highlighting was coming
> >> from, even though I'm an experienced Emacs user, because I normally use
> >> "mouse avoidance" features of Emacs, so generally don't expect the
> >> mouse, which I'm not often using, to affect how I interact with Emacs.
> >> Me belief is that this issue would create even more confusion for a new
> >> Emacs user.
> >
> > This seems to be macOS specific (works for me on MS-Windows, and I see
> > code for supporting this in xterm.c and pgtkterm.c).  I've added to
> > this conversation people who might be able to debug and fix this.
> >
> > Btw, do you see this in a GUI session or in a -nw session (or in
> > both)?
> 
> This makes no sense to me:
> 
> nsterm.m:
>  6978   if (hlinfo->mouse_face_hidden && FIXNUMP (Vmouse_highlight))
>  6979     {
>  6980       clear_mouse_face (hlinfo);
>  6981       hlinfo->mouse_face_hidden = 1;
>  6982     }
> 
> Why set hidden to true when it is already? There is probably a '!'
> missing. Maybe someone with a GUI Emacs can check if that works.

That was also my impression.

> Not sure if this was ever implemented for ttys. I can't find it.

AFAICT, it wasn't implemented (except for MS-DOS).  I've now fixed
that for the MS-Windows console.  I don't have access to a Unix
terminal with a mouse, so I cannot work on fixing this, but AFAIU the
fix should be in handle_one_term_event.