From 3a420e7db4db666d59ae107bc689a359c3bdf07a Mon Sep 17 00:00:00 2001 From: Clinton Ebadi Date: Tue, 17 May 2011 19:48:26 -0400 Subject: [PATCH] Support `:activate ((DESC . SPECIAL-INITARGS))' in attributes * Remove duplicate code in `display-attribute' too --- src/display.lisp | 21 +++++++++++++++++---- src/standard-descriptions/t.lisp | 7 ++++--- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/display.lisp b/src/display.lisp index d04a131..e502b85 100644 --- a/src/display.lisp +++ b/src/display.lisp @@ -15,22 +15,35 @@ (setf context (remove-layer (find-description d) context))) (dolist (d activate context) - (setf context (adjoin-layer (find-description d) + (setf context (adjoin-layer (find-description (if (consp d) (car d) d)) context)))) (defun funcall-with-attribute-context (attribute thunk) (funcall-with-layer-context - (modify-layer-context (current-layer-context) + (modify-layer-context (current-layer-context) :activate (attribute-active-descriptions attribute) :deactivate (attribute-inactive-descriptions attribute)) - thunk)) + (lambda () + (with-special-symbol-access + (contextl::funcall-with-special-initargs + (mappend (lambda (desc) + (when (consp desc) + (let ((description (find-description (car desc)))) + (loop + :for (key val) :on (cdr desc) :by #'cddr + :collect (list (find key (description-attributes description) + :key #'attribute-keyword) + :value val))))) + (attribute-active-descriptions attribute)) + (lambda () + (without-special-symbol-access + (funcall thunk)))))))) (defmacro with-attribute-context ((attribute) &body body) `(funcall-with-attribute-context ,attribute (lambda () ,@body))) (defun display (display object &rest args &key deactivate activate &allow-other-keys) - (funcall-with-layer-context (modify-layer-context (current-layer-context) :activate activate diff --git a/src/standard-descriptions/t.lisp b/src/standard-descriptions/t.lisp index 3256903..bc2c367 100644 --- a/src/standard-descriptions/t.lisp +++ b/src/standard-descriptions/t.lisp @@ -87,9 +87,10 @@ (display-attribute-label attribute)) (display-attribute-value attribute)) -(define-layered-method display-attribute :around - ((attribute standard-attribute)) - (funcall-with-layer-context +(define-layered-method display-attribute :around ((attribute standard-attribute)) + (with-attribute-context (attribute) + (call-next-method)) + #+nil(funcall-with-layer-context (modify-layer-context (current-layer-context) :activate (attribute-active-descriptions attribute) :deactivate (attribute-inactive-descriptions attribute)) -- 2.20.1