Zamansky: Learning Elisp #7

Mike Zamansky has posted the seventh episode of his Learning Elisp video series. In the last set of videos, he showed how to code a Rot13 function in Elisp. This video begins a new project: automatically producing function header comments. The idea is to parse a defun declaration and produce a comment listing the function name, its return value, and its parameters. After its generation, the cursor is left in a position for the programmer to provide more commentary on the various objects.

This video is an introduction to the problem and the main mechanism used to parse the function definition: regular expressions. The subject of regular expression is already difficult enough for most implementations such as the quasi-standard Perl regular expressions or even the Unix egrep regular expressions but Emacs regular expressions seem especially difficult.

The hardest part of Emacs regular expressions is understanding when and what special characters need to be escaped and even how many escape characters are needed. The problem is exacerbated because the rules are different if Emacs thinks it’s reading a string or a regular expression. Everyone hates them but despite several suggestions to improve them, they remain the same.

Zamansky spends most of this video explaining elementary Emacs regular expressions and how they can be used to identify complex patterns of text and perhaps replace them with something else. One example he shows is how to change a date in the mm/dd/yy or mm/dd/yyyy format to the dd-mm-yy or dd-mm-yyyy format.

It’s a nice introduction and makes the whole subject seem a little less intimidating. The video is a bit long—for Zamansky videos—at 29 minutes, 11 seconds so you’ll need to schedule time but it’s worth a look especially if you’re new to regular expressions.

This entry was posted in General and tagged . Bookmark the permalink.