Another reason why I use Emacs as my primary editor

My editor of choice is Emacs. Like Perl, one of its strengths is its flexibility. (some would argue this a weakness. to each their own) Here's just one example I recently found... you can extend Emacs to change the cursor based on what mode you are in (normal, read-only, overwrite)


One thing I've been trying to figure out recently is how to extend Emacs's cperl-mode to highlight new 5.10 keywords, like `given`/`when`, `state`, and commonly imported functions that I use like `blessed`, `reftype` and `croak`.

Unfortunately, the last time I looked at cperl-mode.el I was confronted with a gigantic wall of parentheses and otherwise unintelligible Lisp. Since I don't know any Lisp I was at a complete loss to even know where to look for a list of keywords that are highlighted. :(

Oh well. One of these days I'll learn (some (wacky (lisp 'programming))) -- maybe when I finally get through the end of the Haskell book.

To just highlight them as keywords, you can add something like this to your .emacs:

(font-lock-add-keywords 'cperl-mode
'(("\\_<\\(given\\|when\\|state\\)\\_>" . font-lock-keyword-face)))

Adding them as syntax would be somewhat more involved, as cperl is some pretty hairy elisp.

You may want to check out jrockway's cperl-mode

Leave a comment

About silent11

user-pic Will Willis (silent11)