I learned something new from Magnar Sveen’s excellent Emacs Rocks! episode on Paredit: the paredit-convolute-sexp
command (bound to【Meta+?】). It’s hard to describe exactly what it does so check out the video to see it in action. The thing is, I didn’t even know that command existed; it wasn’t on my Paredit Reference Card. I noticed some of the other commands were missing too so I decided to find out exactly what commands were available and make a list of them.
I brought up the paredit.el
file and started looking around and noticed there’s an odd list of commands complete with examples built right into the code. Here’s the first few entries:
(progn (setq paredit-commands `( "Basic Insertion Commands" ("(" paredit-open-round ("(a b |c d)" "(a b (|) c d)") ("(foo \"bar |baz\" quux)" "(foo \"bar (|baz\" quux)")) (")" paredit-close-round ("(a b |c )" "(a b c)|") ("; Hello,| world!" "; Hello,)| world!")) ("M-)" paredit-close-round-and-newline ("(defun f (x| ))" "(defun f (x)\n |)") ("; (Foo.|" "; (Foo.)|")) ...)))
I thought, “This is perfect. I can use this list to programmatically build a reference card and it will always be up to date.” So I started mapping out the Lisp code in my head but then I remembered this is Emacs so I thought I better check the code to make sure it wasn’t already doing something like that. Sure enough, there’s a function called paredit-insert-html-examples
that will format a nice HTML reference card for you. What I did was open an empty file called paredit.html
and then call paredit-insert-html-examples
. Next I saved the file and then opened it with my browser and set a bookmark to it in my Docs section. Now I have a nicely formatted reference card complete with examples and I know it’s correct because it’s generated from the actual code in the package.
You may have seen a version of this reference card on the Internet. It’s not this one, which is nicer looking but not complete. Here’s a older version of what gets generated. If you’re new to paredit
or the type of person who doesn’t remember key sequences unless you use them all the time, this may be just what you need and it’s easy to generate when new versions of paredit
come around.