X-Git-Url: https://git.hcoop.net/clinton/lisp-on-lines.git/blobdiff_plain/b1c8f43be32503f3911e60696dba8c9194f28ca5..2548f0540da69973512f1827b2bfd2360470bb27:/src/description.lisp diff --git a/src/description.lisp b/src/description.lisp index b64f611..d373ace 100644 --- a/src/description.lisp +++ b/src/description.lisp @@ -28,9 +28,10 @@ #'attribute-active-p (description-attributes description))) -(defun find-attribute (description attribute-name) - (find attribute-name (description-attributes description) - :key #'attribute-name)) +(defun find-attribute (description attribute-name &optional (errorp t)) + (or (find attribute-name (description-attributes description) + :key #'attribute-name) + (when errorp (error "No attribute named ~A found in ~A" attribute-name description)))) (define-layered-function description-active-descriptions (description) (:method ((description standard-description-object)) @@ -50,21 +51,22 @@ (find-attribute description 'active-attributes)) (attributes (when active-attributes (ignore-errors (attribute-value active-attributes))))) - (if attributes - (mapcar (lambda (spec) - (find-attribute - description - (if (listp spec) - (car spec) - spec))) - attributes) - (remove-if-not - (lambda (attribute) - (and (attribute-active-p attribute) - (some #'layer-active-p - (mapcar #'find-layer - (slot-definition-layers - (attribute-effective-attribute-definition attribute)))))) + (remove-if-not + (lambda (attribute) + (and attribute + (attribute-active-p attribute) + (some #'layer-active-p + (mapcar #'find-layer + (slot-definition-layers + (attribute-effective-attribute-definition attribute)))))) + (if attributes + (mapcar (lambda (spec) + (find-attribute + description + (if (listp spec) + (car spec) + spec))) + attributes) (description-attributes description))))))