Own JS/CSS options

Sunday, March 18, 2012

typo.el 1.0 released: An Emacs library for typographical editing

typo.el provides two modes. typo-global-mode provides a prefix map for a number of useful Unicode glyphs, while typo-mode changes the behavior of a number of keys in the current buffer.

The changed keys will try to smartly guess which Unicode glyph you wanted to enter from context. Most of them let you easily cycle through a selection in case the first one was not what you wanted.

Quotation Marks

“He said, ‘leave me alone,’ and closed the door.”

All quotation marks in this sentence were added by hitting the " key exactly once each. typo.el guessed the correct glyphs to use from context. If it gets it wrong, you can just repeat hitting the " key until you get the quotation mark you wanted.

M-x typo-change-language lets you change which quotation marks to use. This is also configurable, in case you want to add your own.

Dashes and Dots

The hyphen key will insert a default hyphen-minus glyph. On repeated use, though, it will cycle through the en-dash, em-dash, and a number of other dash-like glyphs available in Unicode. This means that typing two dashes inserts an en-dash and typing three dashes inserts an em-dash, as would be expected. The name of the currently inserted dash is shown in the minibuffer.

The full stop key will self-insert as usual. When three dots are inserted in a row, though, they are replaced by a horizontal ellipsis glyph.

Other Keys

Tick and backtick keys insert the appropriate quotation mark as well. The less-than and greater-than signs cycle insert the default glyphs on first use, but cycle through double and single guillemets on repeated use.

Prefix Map

In addition to the above, typo-global-mode also provides a globally-accessible key map under the C-c 8 prefix (akin to Emacs’ default C-x 8 prefix map) to insert various Unicode characters.

In particular, C-c 8 SPC will insert a no-break space. Continued use of SPC after this will cycle through half a dozen different space types available in Unicode.

Check the mode’s documentation for more details.

Download and Installation

Download typo.el and put it somewhere in your load-path.

Add the following to your .emacs:

(typo-global-mode 1)
(add-hook 'text-mode-hook 'typo-mode)