lisp

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") =>
   #P"/home/xach/.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")
(tilde:install-tilde-expander)

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.

Tags:

Comments

Re: clbuild

(Anonymous)

Re: clbuild

Great, thanks. clbuild users can now run:

$ clbuild update tilde
$ clbuild dumpcore tilde

and then test it with:

$ clbuild preloaded

Slime users wouldn't run preloaded, but can enable START_SLIME_USING_CORE in clbuild.conf for the same effect.


David

September 2014

S M T W T F S
 123456
78910111213
14151617181920
21222324252627
282930    
Powered by LiveJournal.com