Some people do their laundry in emacs, but I find typing ^C-^X-^W-q-L-TT to add the fabric softener to be a bit cumbersome.
Input methods like this greatly reduce the need for entity declarations, the last remaining holdouts from my life with DTDs. Who needs:
<!DOCTYPE article [ <!ENTITY euro "€"> ]>
And the corresponding “€”, if you can just stuff a “€” into your buffer!
I read Tim’s essay and decided that he was right about some things, like “smart quotes,” but he didn’t do it quite the way I would have. So I banged away for a bit and coded up XML Characters, my own solution.
XML Characters provides four functions:
This function, which I bind to
nxml-mode, inserts the appropriate double quote. Called after a space, newline, or >, it inserts a left double quote. Called after a double quote, it cycles through the three possible quote styles: left, straight, or right. Called anywhere else, it inserts a right double quote.
Inside a start tag, it always inserts just a vanilla ".
I bind this to
nxml-modeand it does just what you think it does.
This function inserts a named XML character. For example,
(insert-xml-char "sect")inserts a section mark (§). The set of names is maintained in a couple of associative lists, so you can easily tweak them. Called with no arguments, it pops up a menu, somewhat like Tim’s code.
I bind this to
C-t cbecause I have a pretty extensive Ctrl-T map that I’m used to using.
Where Tim seems content to have a selection of accented characters in a menu, I decided I wanted more complete and uniform access to all the ISO Latin 1 accented characters (plus a few other things; there’s another list, so you’re free to tweak).
For my function, I chose to read two more keystrokes and compose the approprate character that way. I bind this to
C-t eat the moment.
So, for example, I can type
C-t e e 'to insert “e acute”. Or
C-t e $ yto insert a yen symbol.
Thanks, Tim! I didn’t know how much I needed these functions before I wrote them. In the course of writing one essay, I’ve decided I wouldn’t want to live without them.