Emacs As A Lisp Machine

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 Entername-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 eval-last-sexp.

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.

This entry was posted in General and tagged . Bookmark the permalink.

7 Responses to Emacs As A Lisp Machine

  1. Aankhen says:

    For whatever reason, I find myself needing to do this pretty often, so I bound ucs-insert to H-\ in addition to C-x 8 RET, where H is my left Windows key rebound to Hyper. Took some getting used to, but it’s worked out well.

    • jcs jcs says:

      Right. When you do this you get a mini buffer dialog asking for the name or hex value. I meant to mention that if you regularly need to enter the values in decimal it would be easy to write a tiny bit of Emacs Lisp and bind it to a convenient key sequence. Here’s an example:

      (defun my-ucs-insert (arg)
      "Enter code point in decimal"
      (interactive "nCode Point: ")
      (ucs-insert arg))

  2. Xah Lee says:

    nice tip about 【Meta+:】 for eval-expression.

    for odd reasons that key doesn’t work for me (nor Esc :)… because the “;:” on Dvorak is qwerty’s zZ, and i have that position for undo and redo.

  3. Phil says:

    Regarding the title, I just encountered the following video (made by Kalman Reti), which I urge all Emacs users to watch if they wish to gain insight into what Lisp Machines were/are, and exactly why the comparison with Emacs is so apt:

    http://www.youtube.com/watch?v=o4-YnLpLgtk

    It’s “a rough introductory demo of the Symbolics Lisp Machine (in Brad Parker’s emulator)”, and Kalman says in the video that he intends to follow it up with others, although at present it’s the only one: http://www.youtube.com/user/lispwizard/videos (O note that the title of the video says January 2013, but Youtube says it was published in August, so I’m not certain how recent it actually is, or whether it and/or others are available elsewhere.)

    (re-posted due to captcha issues)

    • jcs jcs says:

      Yup. Don’t you love watching that software work? I wrote about a talk that Reti gave at MIT here: in that video he talks about the Lisp machines and their architecture and then gives a demo. The whole thing is over an hour but well worth your time.

      • Phil says:

        Ah, I have that blog entry in a browser tab in limbo somewhere! I didn’t have an hour to spend watching it at the time I read it, and then I completely forgot about it in the meantime. Thank you; I shall try to get to that in the very near future.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>