

"Run ` describe-function/variable ' on the command." "Move point to the end of the next expression matching ` this-syntax ', and put a tooltip on the match that shows the key sequence.

( defun match-next-emacs-command ( &optional limit) This one seems simple enough we just write a regexp for it. Let's go ahead and make syntax for `some-command' too. "%s\n\nClick for documentation.\ns-mouse-1 to find function." this is what gets run when you click on it. "Run ` describe-function ' on the command." "Move point to the end of the next expression matching ` elisp-symbol-keybinding-re ', and put properties on the match that shows the key sequence. ( defun match-next-keybinding ( &optional limit)

\\ Regexp group 1 matches ` some-command '.") "Regexp for an elisp command keybinding syntax. The tooltip will show the key-binding to run the command. We will go ahead and make the text clickable so we can access documentation and code easily. We define a function that will move the point to the end of the next match, and put properties on the match. All we need is to integrate this into font-lock. Since we are matching \ in the pattern, there are some obligatory escaping \ characters in there too. It is a bit easier to document than a raw regexp. Here we use the `rx' library to build up a regular expression for this. I made a video ( ) showing what this post is all about. Basically, we need a regular expression to match the syntax, and a function to find the next instance, and put some properties on the matched text. Font lock is the tool we will use for this. We are going to explore a way to recognize the syntax shown above, change its appearance to alert us that we are looking at an emacs command, add a tooltip, and make it clickable to open the documentation, and s (super) clickable to find the function code.
