Anonymous committed 8d25059

Corrected a bug with templates that was 1) not setting the current package when reading or evaluating a template, and 2) use-package statements within a template were not evaluated until run-time--too late, since the reader has already placed unknown symbols into the current package (rather than being able to recognize them as imported symbols).

Comments (0)

Files changed (1)

   (if (listp expr)
       (cond ;; will likely need to add more cases over time
 	( (eql '+tag-library (car expr) ) (eval expr) t )
+	( (eql 'use-package (car expr) ) (eval expr) t )
 	)	   ; defaults to nil if no match, meaning no directive
 (defgeneric load-template (template-path &optional template-args template-keyword-args)
   (:method (template-path &optional (template-args nil) (template-keyword-args nil) )
     (let* (
-	  (*template* (make-instance 'template 
+	   (*template* (make-instance 'template 
 			       :path template-path
 			       :args template-args 
 			       :kwargs template-keyword-args
-			       ) 
+			       )
-	  (definition (eval `(lambda (,@template-args ,@(if template-keyword-args `(&key ,@template-keyword-args)) )
+	   (*package (template-package *template*))
+	   (definition (eval `(lambda (,@template-args ,@(if template-keyword-args `(&key ,@template-keyword-args)) )
 				,@(or (load-template-definition *template* template-path)
 					(error 'template-not-found-error :path ,template-path) 
 	    (when tmpl
-	      (funcall (definition-of tmpl) ,@template-arg-values ,@template-keyword-args)
+	      (let ((*template* tmpl)
+		    (*package* (template-package tmpl)))
+		(funcall (definition-of tmpl) ,@template-arg-values ,@template-keyword-args))