I would like to add custom tooltips to emacs. More specifically, whenever I hover on a symbol (function/variable) name with my mouse of I would like to see a tooltip with the symbol’s definition. I know that I can find this kind of info with a tool like cscope but I have no idea how to attach the output of cscope to a tooltip. does anyone have a partial (how to link a callback to a tooltip in emacs in general) or a full (how do I actually link the output of cscope to a tooltip) solution to this?
Thanks, Nir
Your Emacs installation should include the Elisp reference manual (if not, download it now – you’re going to need it when developing your mode). To access it, go to Info (C-h i) and look for a node labeled ‘Elisp’, sometimes in a separate ‘Emacs’ menu. Type
ifor index andtooltipto look for information on tooltips. You should find node 32.19.4 Properties with Special Meanings, which tells you that the content of thehelp-echoproperty is a string that is the tooltip content, or a function that can construct the tooltip dynamically. Explore the manual around that node to find out more about text properties and how to set them.Here’s a simple example:
Type this into your
*scratch*buffer and pressC-jto run the code. Then point your mouse at the word ‘foo’ and you should see the tooltip.