Word Finder

So far, Crossword mode isn't much more than very fancy graph paper. Apart from keeping track of what letters you want to put where, it offers little help to the aspiring crossword puzzle creator. The really hard part of designing a crossword puzzle isn't keeping track of what belongs in each grid square; it's trying to find words that will fit with other words you've already chosen, such as when you need a five-letter word whose last three letters have to be "fas".

It's possible to use standard UNIX utilities to find suitable words. The UNIX program grep, given a suitable regular expression, can find matching words from a word file. Most UNIXes have a word file in /usr/dict/words or /usr/lib/dict/words or, on modern GNU systems, /usr/local/share/dict/words.

If the word file contains one word per line, it is possible to find a five-letter word ending in "fas" with this UNIX command:

grep -i '^..fas$'  word-file

(The -i tells grep to match case-insensitively.) Running this command gives us the answer, "sofas".

Wouldn't it be nice if we could just hit a key and have Emacs construct the correct regular expression and run grep for us?

Here's how it would work. With the cursor on a grid cell, you press C-c h to find a word that fits horizontally through the current cell, C-c v to find a word that fits vertically. In each case, the function searches left and right, or up and down, for the nearest enclosing blocks. The intervening cells are used to construct a regular expression. Empty ...

Get Writing GNU Emacs Extensions now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.