Thoughts on Perl and Emacs, technology and writing

Emacs Buttons

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.

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 :supertype.