Not many days ago I asked a few Emacs developers on #emacs how I might easily type characters from the General Punctuation Unicode block within console Emacs. To my surprise, the best answers I received were to copy-and-paste from a GTK application, or insert the characters by ISO 14755/UCS hex code entry.
Fortunately, xmlunicode provides a variety of Unicode entry methods that do not require numeric memorizations. With some quick coding, I bound the interactive input methods to familiar key strokes—similar to those used by Unibyte Editing. A minor mode is used to toggle automatic “word processing”-style punctuation, including smart quotes, ellipses, and em/en dashes.
My binding code in all of its simplicity:
(autoload 'unicode-character-insert "xmlunicode" "" t)
(autoload 'unicode-character-shortcut-insert "xmlunicode" "" t)
(autoload 'iso8879-character-insert "xmlunicode" "" t)
(global-set-key (kbd "C-x 9") 'unicode-character-shortcut-insert)
(global-set-key (kbd "C-x 7") 'iso8879-character-insert)
(global-set-key (kbd "C-c 9") 'unicode-character-insert)
(global-set-key (kbd "C-c 7") 'smart-chars-mode)
(define-minor-mode smart-chars-mode
"Toggle SmartChars unicode punctuation mode." nil " SmartChars"
'(("\'" . unicode-smart-single-quote)
("\"" . unicode-smart-double-quote)
("\;" . unicode-smart-semicolon)
("\-" . unicode-smart-hyphen)
("\." . unicode-smart-period))
(if (not (commandp 'unicode-smart-period)) (load "xmlunicode")))
The source also available at: smartchars.el.
Other elisp code snippets available at: …/elisp-snippets/.
| © Copyright Timothy Stotts 2002, 2007. All rights reserved. | ^ top of page |