Habibullah’s posterous

« Back to blog
October 15, 2008

Refer to CL documentation from within Emacs

While programming in Common Lisp I feel the need to refer to the documentation time and again. As I'm very lazy (a positive trait mind you), I don't want to browse to /usr/local/acl81/doc, wait for Firefox to load, then click on the index, then search for the symbol you want and click on it.

Okay, it's not such a long procedure but it is a distraction nonetheless. And why can't this procedure be somewhat shorter?

Turns out I'm just following the path of other lazy programmers.

Slime and acldoc can help us here.

If you are programming in ANSI Common Lisp then you can't go wrong with the LispWorks Common Lisp HyperSpec.

If you are programming with Allegro Common Lisp and utilize their extensions to CL, you will need to refer to the Allegro documentation. Heck, you can refer to both if you so desire.

The CL documentation isn't going to change rapidly. So it makes sense to cache the documentation onto your local hard disk instead of referring to the web-site for every request. Where I stay this has an added benefit of not getting frustrated with the pathetic load times.

Here's how you go about accessing the HyperSpec from within Emacs:

1) Download the HyperSpec from here, and extract it to your favourite location.

2) Open your .emacs file and type in:
(setq common-lisp-hyperspec-root "path/to/HyperSpec/")
(setq common-lisp-hyperspec-symbol-table (concat common-lisp-hyperspec-root "Data/Map_Sym.txt"))
where "/path/to/HyperSpec/" is where you have extracted it.

3) After you've started Slime, put the point on the symbol you want and press C-c C-d h to pop-up the documentation in a new browser window.

Here's how you go about accessing the ACL docs from within Emacs. It's a little more involved, but the results are beautiful!

1) The Free Express edition doesn't come with documentation. You can download it from here.

2) If you are using the Professional edition, then the documentation is stored in a sub-folder called doc where ACL is installed. Put this in your .emacs file:
;;The location of ACL docs
(setq acldoc-local-root "/usr/local/acl81/")
(setq acldoc-use-local t)

3) Then you need to get url.el and it's dependants. If you are using Emacs 22 or above, then you already have it. Say hurray and skip to step 5.

4) Download the tar.gz from the bottom of this post and untar it to your favourite location. Then add to your .emacs file:
(add-to-list 'load-path "/path/to/url/")
You know what to do with "/path/to/url/".

5) Type in your .emacs file:
(require 'url)

6) Now you need acldoc. Get it from here, and copy the contents to a file called acldoc.el. Put in your .emacs file:
(add-to-list 'load-path "/path/to/acldoc/")
(require 'acldoc)

7) Congrats! Now you can refer to the ACL docs by typing:
M-x acldoc
and then the name of the symbol. If you are still lazy then add the following shortcut to your .emacs file:
;;Press C-F1 with the cursor on a symbol and then press Enter to get the ACL docs for the given symbol.
(global-set-key [(control f1)] 'acldoc)

Okay, things aren't quite as hunky-dory as they might seem. Some html files are displayed in the Emacs buffers. I tried to figure out the why behind the extra files, but I was feeling rather dense today. So I cheated. Since I have ample RAM and processing power, I don't care if a few extra buffers get opened up. So I put them out of sight using Tabbar. Take a look at the Tabbar section of my .emacs file to see what I did.

Hint: It's something to do with the major mode.

Enjoy!

Click here to download:
url.tar.gz (71 KB)



Comments (0)
Leave a comment...
 
To leave a comment on this posterous, please login.
Click here to login or sign up