noverlays = overlays_at (pos, 0, &overlay_vec, &len, NULL, NULL);
}
+ /* Sort overlays into increasing priority order. */
noverlays = sort_overlays (overlay_vec, noverlays, w);
/* Check mouse-face highlighting. */
/* Find highest priority overlay that has a mouse-face prop. */
overlay = Qnil;
- for (i = 0; i < noverlays; i++)
+ for (i = noverlays - 1; i >= 0; --i)
{
mouse_face = Foverlay_get (overlay_vec[i], Qmouse_face);
if (!NILP (mouse_face))
/* Check overlays first. */
help = Qnil;
- for (i = 0; i < noverlays && NILP (help); ++i)
- help = Foverlay_get (overlay_vec[i], Qhelp_echo);
+ for (i = noverlays - 1; i >= 0 && NILP (help); --i)
+ {
+ overlay = overlay_vec[i];
+ help = Foverlay_get (overlay, Qhelp_echo);
+ }
if (!NILP (help))
{
help_echo = help;
help_echo_window = window;
- help_echo_object = w->buffer;
+ help_echo_object = overlay;
help_echo_pos = pos;
}
/* Try text properties. */