Have you ever used emacs buttons? If you’ve used
M-x grep then you have used similar functionality. When you click on one of the links it opens the file and goes to the appropriate line. If your mouse is hovering over the link then it highlights it.
How can you make your own button? First of all, you make a function that is called when you click the button.
(defun myfun (button) (message (format "Button [%s]" (button-label button))))
Then you make a button template. Buttons are actually made with an overlay that overrides the current keymap. By default, buttons run their action on button 2. I prefer left click so I set follow-link to true. You can make a hierarchy of button types using
(define-button-type 'my-button 'action 'myfun 'follow-link t 'help-echo "Click button")
Then insert the button using your template. These automatically highlight when your mouse is hovering over it.
(insert-text-button "xyz" :type 'my-button)