Created
March 6, 2012 19:19
-
-
Save kingcons/1988394 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(in-package :quickproject) | |
(defvar *after-make-project-hooks* nil | |
"A list of functions to call after MAKE-PROJECT is finished making a | |
project. It is called with the same arguments passed to | |
MAKE-PROJECT, except that NAME is canonicalized if necessary.") | |
;; TODO: Instead of &key docs do (when (stringp docs) ...)? | |
(defmacro defhook (name (&key docs) &body body) | |
"Define a function with the given NAME and an appropriate lambda list, | |
pushing it onto *after-make-project-hooks* after definition. BODY will be | |
executed inside a LABELS providing RELATIVE and NAMETYPE functions as in | |
WRITE-PROJECT-FILES." | |
`(progn | |
(defun ,name (pathname &key depends-on name) | |
,@(when docs (list docs)) | |
(labels ((relative (file &optional (path pathname)) | |
(merge-pathnames file path)) | |
(nametype (type) | |
(relative (make-pathname :name name :type type)))) | |
,@body)) | |
(pushnew ',name *after-make-project-hooks*))) | |
(defun toggle-hook (hook) | |
"Add or remove HOOK from *AFTER-MAKE-PROJECT-HOOKS*." | |
(if (member hook *after-make-project-hooks*) | |
(delete hook *after-make-project-hooks*) | |
(push hook *after-make-project-hooks*))) | |
;;;; allowing a ~/bin/quickproject like... | |
;; #!/bin/sh | |
;; sbcl --eval \"(ql:quickload 'quickproject)\" \ | |
;; --eval \"(load "/home/redline/.quickprojectrc")\" \ | |
;; --eval \"(quickproject:make-project $1)\" \ | |
;; --eval \"(progn (terpri) (sb-ext:quit))\" | |
;;;; where .quickprojectrc is just: | |
;; (in-project :quickproject) | |
;; defhook a, defhook b, etc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment