Subject: bug#4911: mouse-face property should merge face attributes, not replace

From: Clément Pit-Claudel <[email-masked]>
Date: Fri, 10 Apr 2020 12:26:12 -0400

Lars Ingebrigtsen <larsi <at> gnus.org> writes:
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
>> I see no reason to change that now.  The use case described in the bug
>> report could be handled by using some non-color attribute for the
>> mouse-face, for example.
> 
> Seems like everybody agrees, so I'm closing this bug report.

I'd like to disagree :) This is a problem I've run into in various packages and as a user, and the workaround doesn't work when there are multiple different faces applied to the text of a link.

As a concrete example, consider compilation-mode, which uses different colors for the file name, the line number, the column number, and the error message.  Currently, when hovering over a compilation-mode line highlights it, but also causes it to lose all of its other highlighting.

Setting different mouse-face properties to match the different faces would cause the mouse-face highlighting to be only applied to part of the line.

Of course, one way to go is to handle mouse-in and mouse-out events in Lisp, creating and removing overlays as needed.  But that's explicitly recommended against in the ELisp manual, and it's a lot of work for not much gain.

It would be great to have an option for this; maybe as an extra text property, like 'mouse-face-merge?  Or maybe as a user option?
Of course, if the default changed to merging, recovering the current behavior would be easy even without an extra property (it would just be a matter of making the mouse-face inherit from 'default), I think.  But even without changing the default it would be nice to introduce a way to achieve that behavior.

Clément.