-(defmacro defdisplay (&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)
- 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."))
- (return
- (destructuring-bind (description &optional object component) (car tail)
- (with-unique-names (d c)
- (let (standard-description-p)
- `(define-layered-method
- display-using-description
- :in-layer ,layer
- ,@qualifiers
-
- ,@(unless object
- (setf object description)
- (setf description d)
- nil)
- (,(cond
- ((listp description)
- (setf d (car description))
- description)
- (t
- (setf d description)
- (setf standard-description-p t)
- `(,d description)))
- ,object
- ,(cond
- ((null component)
- `(,c component))
- ((listp component)
- (setf c (car component))
- component)
- (t
- (setf c component)
- `(,c t))))
- (with-component (,c)
- ,@(cdr tail)))))))))