Tuesday, June 12

Lisp Array Setter Syntax

Not the most inituituve in the world

(defmethod (setf setter-name) (value (self class-type) x y z)
(setf (row-major-aref (array-of self) (* x ... blah... ))))

(setf (setter-name self) x-index y-index z-index value)

The thing to remember is that the value always comes first.

Saturday, June 9

wxWidgets Documentation in Devhelp format

This post is what it says on the tin. I converted the wxWidgets help from htb to devhelp using this handy help converter. Here is the result. It needs to live somewhere where devhelp can find it: usually /usr/share/devhelp/books or ~/.devhelp/books, although the latter did not work for me

Why did I want devhelp and not HTB. Partly because devhelp integrates much more nicely with Gnome, but also because it made it trivial to get context - sensitive help out of Emacs with this little gem:

(defun devhelp-word-at-point ()
"runs devhelp"
(setq w (current-word))
(start-process-shell-command "devhelp" nil "devhelp" "-s" w))

Monday, June 4

Save Slime And Die

The best way to work with a Lisp is to leave it running all the time and hack on it bit by bit, building up your program bit by bit, doing mini-tests and off-the-cuff code as you go along and shaping it..

Except if you are like me, you might be working on a laptop with a limited battery life and have a strict time limit to your lisp hacking. It's bothered me that when working with SLIME the only way to save a core was to start a lisp in a terminal, load up your systems and your files, then dump and use that with C-u M-x slime, which lets you enter a command line to start your lisp.

It annoys me because if you are like me, your code doesn't necessarily capture the actual state of your core: it also contains half a dozen test variables and functions that you entered in the repl and are useful to have hang around. So I tried to find a way to dump and restore core from within slime. I came up with the following function

(defun save-slime-and-die (core-file-name)
;; close all
(mapcar #'(lambda (x) (swank::close-connection x)) swank::*connections*)
(dolist (thread (remove (swank::current-thread) (swank::all-threads)))
(swank::kill-thread thread))
(sleep 1)
(save-lisp-and-die core-file-name))

It's obviously for sbcl, and the gotcha is that it has to be executed in the *inferior-lisp* buffer, but it works..C-u M-x sbcl --core test.core brings back core dumped with (save-slime-and-die #P"test.core")