on the loading of preference files
Gary King <[email protected]>
| Newsgroups | gmane.lisp.cclan.general |
|---|---|
| Message-ID | <[email protected]> |
The code below adds the loading of preference files to ASDF. There are two new (exported) generic functions: load-preferences <system> preference-file-for-system <system> The first is called in an :after method of perform for all systems. It wraps *package* and loads the file returned by preference-file-for- system if it exists. The default preference file is named <system>.lisp and is located in a subdirectory named ".asdf" of (user- homedir-pathname). I think that this is a useful addition to generic asdf. If others tend to agree, I'll write some tests, make sure they pass and check in the changes. This (along with some export statements in the defpackage) is the new code. I'd show a diff but one of sourceforge or myself is having conniptions. > (defgeneric load-preferences (system) > (:documentation "Called to load system preferences after <perform > load-op system>. Typical uses are to set parameters that don't > exist until after the system has been loaded.")) > > (defgeneric preference-file-for-system (system) > (:documentation "Returns the pathname of the preference file for > this system. Called by 'load-preferences to determine what file to > load.")) > > (defmethod load-preferences ((s system)) > (let* ((*package* (find-package :common-lisp)) > (file (probe-file (preference-file-for-system s)))) > (when file (load file)))) > > (defmethod preference-file-for-system ((system t)) > ;; cope with anything other than systems > (preference-file-for-system (find-system system t))) > > (defmethod preference-file-for-system ((s system)) > (merge-pathnames > (make-pathname :name (component-name s) > :type "lisp" > :directory '(:relative ".asdf")) > (truename (user-homedir-pathname)))) > > (defmethod perform :after ((operation load-op) (c system)) > (load-preferences c)) thanks, -- Gary Warren King metabang.com http://www.metabang.com/ (413) 210 7511 gwking on #lisp (occasionally)