How to display a tooltip when the cursor enters an overlay in emacs?

I am writing a secondary mode that does not allow writing tips. I use overlays to highlight errors. When the dot enters the overlay, I want to display more detailed information (now message , but maybe in a separate buffer.)

help-echo is almost what I want, but I use Gnu Emacs in the terminal, and help-echo for the mouse pointer, not the point.

point-entered also almost what I want, but point-entered has no effect on overlays, just text properties.

The overlays looked attractive because they are easy to erase when I rewrite the buffer (I conclude that the re-builder here). Should I continue to use overlays, but use point-moving hooks to find overlays, extract tooltips, and display them? Should I use text properties instead of overlays?

+6
emacs elisp
source share
3 answers

For some ideas, check out Autocomplete .

A menu appears in which people can scroll. It may not be exactly what you want - it looks like you don't want a menu, but looking at the code can be interesting.

enter image description here

Also see the tooltip-show method, part of tooltip.el.

 tooltip-show is a compiled Lisp function in `tooltip.el'. (tooltip-show TEXT &optional USE-ECHO-AREA) Show a tooltip window displaying TEXT. Text larger than `x-max-tooltip-size' is clipped. If the alist in `tooltip-frame-parameters' includes `left' and `top' parameters, they determine the x and y position where the tooltip is displayed. Otherwise, the tooltip pops at offsets specified by `tooltip-x-offset' and `tooltip-y-offset' from the current mouse position. Optional second arg USE-ECHO-AREA non-nil means to show tooltip in echo area. 
0
source share

In general, this is not a good design to respond to mouse movements, since the mouse is likely to go through your areas for many reasons.

I would advise you to implement this, for example, in the right menu button.

When it comes to overlaying against text properties, the one difference is that the text properties are saved when doing a buffer-substring , which is probably not what you want. Another is that text properties are shared between legacy buffers (although this is rarely used).

0
source share

You might like to try cursor-sensor-mode (which is new in Emacs-25), which allows you to place actions in the text properties of cursor-sensor-functions (including through overlays).

It is supposed to replace the point-entered property and respond to cursor movements, not point movements (the two are closely related, but different: this command can move the point many times internally, but the cursor will only be moved once, at the end, when the display is updated )

0
source share