More irritant-reduction
« previous entry | next entry »
Sep. 29th, 2008 | 12:05 pm
In SBCL, ASDF hooks into
the REQUIRE mechanism so
you can type (require 'mysystem). On other systems you
can also figure out a way to hook REQUIRE, so you can avoid
typing (asdf:oos 'asdf:load-op 'mysystem).
I got tired of trying to figure out how to do this in different
ways on different Lisp systems, so below is a file I've been loading from
my init files to get consistent, concise ASDF loading across
implementations. It also adds a crude registry maintenance system
and a way to reload a system without using :FORCE.
:FORCE has the downside of recompiling and reloading
all other dependencies, which is never what I want.
It's a work in progress, but so far I've been pretty happy
using (asdf:load* 'mysystem) and (asdf:reload
'mysystem). YMMV.
(require 'asdf)
(in-package #:asdf)
(export '(load* reload register register-permanently))
(defvar *registry-file*
(merge-pathnames (make-pathname :directory '(:relative "asdf")
:name "registry"
:type "sexp")
(user-homedir-pathname)))
(eval-when (:compile-toplevel :load-toplevel :execute)
(let ((registry (probe-file *registry-file*)))
(when registry
(with-open-file (stream registry)
(loop for form = (read stream nil)
while form do (push form *central-registry*))
(setf *central-registry*
(remove-duplicates *central-registry* :test #'equalp))))))
(defun load* (system &key verbose)
(oos 'load-op system :verbose verbose)
t)
(defun reload (system)
(let ((name (coerce-name system)))
(remhash name *defined-systems*)
(load* name)))
(defun register (form)
(pushnew form *central-registry* :test #'equalp))
(defun register-permanently (form)
(register form)
(ensure-directories-exist *registry-file*)
(with-open-file (stream *registry-file*
:direction :output
:if-exists :append
:if-does-not-exist :create)
(prin1 form stream)
(terpri stream)))
;;; Automatically recompile stale FASLs
(handler-bind ((style-warning #'muffle-warning))
(defmethod perform :around ((o load-op) (c cl-source-file))
(handler-case (call-next-method o c)
(#+sbcl sb-ext:invalid-fasl
#-sbcl error ()
(perform (make-instance 'compile-op) c)
(call-next-method)))))
Do you have any ugly local hacks that you think aren't polished enough to share, but that make your life much easier? Share them anyway, and let's clean them up and use them and improve life everywhere.
(no subject)
from: anonymous
date: Sep. 29th, 2008 08:26 pm (UTC)
Link
-Tim Jasko
Reply | Thread
(no subject)
from:
xach
date: Sep. 30th, 2008 08:50 pm (UTC)
Link
Why not do it in a lisp init file, though?
Reply | Parent | Thread
(no subject)
from: anonymous
date: Oct. 1st, 2008 04:30 am (UTC)
Link
In the end, I think it boiled down to the fact that I already knew all the Java functions for dealing with the file system. It wasn't a terribly interesting bit of code, but at least it didn't take long to write.
-Tim Jasko
Reply | Parent | Thread
ASDF
from: anonymous
date: Sep. 29th, 2008 11:19 pm (UTC)
Link
Also, "(asdf:load* 'mysystem)" is great. I'm sure we've all done that independently by now, which kind of makes the "ASDF is designed to be an extensible system" answer in their FAQ look like a complete non sequitur. :-)
Reply | Thread
Re: ASDF
from:
xach
date: Oct. 1st, 2008 01:53 pm (UTC)
Link
Reply | Parent | Thread
REPL commands for ASDF
from: anonymous
date: Oct. 27th, 2008 07:01 pm (UTC)
Link
Reply | Thread
Re: REPL commands for ASDF
from:
xach
date: Oct. 27th, 2008 07:24 pm (UTC)
Link
Reply | Parent | Thread
quickie for asdf :force issue
from: anonymous
date: Jan. 3rd, 2009 04:31 pm (UTC)
Link
Reply | Thread