Emacs: Using a Unix Filter

2013-04-30*
emacs

In Vim, you can easily call an external text utility on a region of text, then replace that selected region with the output of the text utility. This is very useful for doing bulk transformations quickly.

I coded up a very stupid commenting program called nox that comments/uncomments text. Here is how you’d use it straight from the terminal:

$ echo "hi" | nox -l c
//hi

By default nox comments text, and the -l c option sets it to C-styled comments, //.

Emacs

I use evil-mode with Emacs. Here is my relevant .emacs to set up nox correctly:

This is certainly not the most beautiful code, but it works.

References