Calling External Programs

One of the rules specific to EmacsGolf, as opposed to VimGolf, is that you're allowed to call external programs to operate on a region of the buffer using something like 【Ctrl+u Meta+|】. You can do the same thing from an Elisp program, of course, and Xah Lee has a useful post showing how to call external programs.

This functionality is more flexible than many beginners realize. You can call shell scripts, a scripting language such as Perl or Python, or a compiled program such as sort—anything that reads from stdin and writes to stdout. There nothing hard about doing any of this, of course, but you do need to know the proper incantation. See Lee's post for the details. Also take a look at shell-command. It can be useful when you want to run an external program and optionally capture its output to a buffer—see this post for an example of its use.

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