Log in

No account? Create an account

Tilde for SBCL convenience

Every now and then I want to use leading tildes in SBCL pathnames. That is, something like this:

(probe-file "~/.emacs") =>
OR #P"/Users/xach/.emacs"
OR #P"/usr/u/xach/.emacs"

I know about user-homedir-pathname, but it's not quite convenient for interactive REPL use.

So I put together a short file that patches SBCL internals slightly so leading tildes in pathnames go through the POSIX getpw interface to look up home directories. It's not something I'll ever use in source files, but it's pretty convenient interactively.

To use it yourself, just download tilde.lisp and add this to your ~/.sbclrc:

(load "/path/to/tilde.lisp")

After that, you can use "~/foo" and "~bob/foo" in SBCL pathnames.

update Here's a git repo for tilde.lisp, with an ASDF system file too.



Ah, right... I suppose it's the reader's job to intern symbols even if the form isn't going to get evaluated....

I do have it in separate forms, but I've stumbled before trying to get similar things to work and was afraid that calling load from somewhere other than the top-level meant that all the stuff it created got thrown out when load returned. But, I would guess that instead it's the same sort of thing with the reader trying to intern symbols even though they might not get evaluated.

And, yep... the "read-from-string" offends my sensibility, too. :). I'll just assume the load's going to succeed.