Xah Lee has an update to his Emacs and Unicode Tips page that I’ve written about before on my old blog. This is a great reference that tells you how to deal with Unicode and UTF-8 in Emacs. One of the new parts that I really like is how to enter a Unicode character by its decimal number. I like this not because I want to do it—I’m perfectly happy using the 【Ctrl+x 8 Enter】
name-or-hex-number method—but because of the way it works and what it tells us about Emacs.
Lee tells us that to input a λ character by its decimal number, 955, you type
(ucs-insert 955) into the text and then evaluate it by typing 【Ctrl+x Ctrl+e】 to insert the lambda character. Of course, now you have to delete the
(ucs-insert 955) so the method isn’t really that practical.
What I like about it is what it tell us about Emacs. It’s easy, and nominally correct, to think of Emacs as an editor that has elisp as an extension language but Emacs is really more. It’s more accurate to think of it as a lisp machine that’s specialized for editing functions. With that view, you’re always typing into a REPL of sorts where each “normal” character that you type runs the command
self-insert-command. You can run other commands by using various control sequences or other special keys. Lee’s method shows both these functions. First you type in the string
(ucs-insert 955) and then you use 【Ctrl+x Ctrl+e】 to run
With this view, elisp isn’t an extension language but an instance of a running Lisp interpreter that knows a lot of commands useful for editing and whose REPL (or more accurately reader) behaves a little differently than other Lisps. The point is that it expands your view of what Emacs is and allows you to imagine new and non-intuitive ways of doing things.
By the way, if you must enter a Unicode character by its decimal number, an easier, but similar, way is to type 【Meta+:】
(ucs-insert 955) or whatever number you need.