Years ago, when Emacs was at 21.*, I had a function that displayed a tooltip when I hovered the mouse on certain words in the buffer. Now, in 26.3, I want to use that function again, but it does not work any more, apparently because Emacs is not passing mouse movement events to it.
Minimal example that worked fine in Emacs 21 but does nothing in Emacs 26:
(defun my-tooltip (event)
(interactive "e")
(tooltip-show "got mouse movement event")
t)
(progn
(tooltip-mode)
(set (make-local-variable 'track-mouse) t)
(setq tooltip-functions nil)
(add-hook 'tooltip-functions 'my-tooltip))
One more thing: when I did M-x describe-key
and moved the mouse, older Emacs versions used to tell me which command, if any, was bound to mouse-movement
. In the same situation, Emacs 26 does nothing — it obviously does not see that I am moving the mouse, even when I set track-mouse
to t
globally.
Running Emacs with -Q
does not change anything.
How should I catch mouse movement events in Emacs 26?
my-tooltip
. If you want tooltips for "certain words in the buffer" you need to set thehelp-echo
text property on those words.C-h i g (elisp)Special Properties
and(elisp)Tooltips