(in-package :lisp-on-lines)
-(defvar *object*)
+(defvar *description*)
(defvar *display*)
+(defvar *object* nil)
+
+
+(deflayer display-layer)
(define-layered-function display-using-description (description display object &rest args)
(:documentation
"Displays OBJECT via description using/in/with/on display"))
-(defun display (display object &rest args)
- (display-using-description (description-of object) display object args))
+(defun display (display object &rest args &key attributes )
+ (let ((*display-attributes* attributes))
+ (apply #'display-using-description (description-of object) display object args)))
(define-layered-method display-using-description
:around (description display object &rest args)
- (let ((*display* display)
+ (declare (ignorable args))
+ (let ((*description* description)
+ (*display* display)
(*object* object))
- (call-next-method)))
+ (dletf (((described-object description) object))
+ (contextl::funcall-with-special-initargs
+ (loop
+ :for (key val) :on args :by #'cddr
+ :collect (list (find key (description-attributes description)
+ :key #'attribute-keyword)
+ :value val))
+ (lambda ()
+ (contextl::funcall-with-special-initargs
+ (let ((attribute (find-attribute description 'active-attributes)))
+ (when attribute
+ (loop for spec in (attribute-value attribute)
+ if (listp spec)
+ collect (cons (or
+ (find-attribute description (car spec))
+ (error "No attribute matching ~A" (car spec)))
+ (cdr spec)))))
+ (lambda ()
+ (call-next-method))))))))
+
+
+
+(defun display/d (&rest args)
+ (apply #'display-using-description args))
(define-layered-method display-using-description (description display object &rest args)
(error "No DISPLAY-USING-DESCRIPTION methods are specified for: ~% DESCRIPTION: ~A ~% DISPLAY: ~A ~% OBJECT: ~A ~% ARGS: ~S
OMGWTF! If you didn't do this, it's a bug!" description display object args))
-(defun display-attribute (attribute)
- (display-using-description attribute *display* *object*))
-
(defmacro define-display (&body body)
- (loop with in-layerp = (eq (car body) :in-layer)
- with layer = (if in-layerp (cadr body) 't)
- for tail on (if in-layerp (cddr body) body)
+ (loop with in-descriptionp = (eq (car body) :in-description)
+ with description = (if in-descriptionp (cadr body) 't)
+ for tail on (if in-descriptionp (cddr body) body)
until (listp (car tail))
collect (car tail) into qualifiers
finally
- (when (member :in-layer qualifiers)
- (error "Incorrect occurrence of :in-layer in defdisplay. Must occur before qualifiers."))
+ (when (member :in-description qualifiers)
+ (error "Incorrect occurrence of :in-description in defdisplay. Must occur before qualifiers."))
(return
(destructuring-bind (description-spec &optional (display-spec (gensym)) (object-spec (gensym)))
(car tail)
`(define-layered-method
display-using-description
- :in-layer ,layer
+ :in-layer ,(if (eq t description)
+ t
+ (defining-description description))
,@qualifiers
(,(if (listp description-spec)
(list (first description-spec)