Fix missing `without-special-symbol-access' in `funcall-with-attribute-context'
[clinton/lisp-on-lines.git] / src / standard-descriptions / t.lisp
CommitLineData
4358148e 1(in-package :lisp-on-lines)
2
e7444a93 3(defmethod described-object ((attribute standard-attribute))
4 (described-object (attribute-description attribute)))
5
4358148e 6(define-description T ()
bd9c9c31 7 ((label :label nil
8 :function (lambda (object)
9 (format nil "~@(~A~)"
10 (substitute #\Space #\-
11 (symbol-name
12 (class-name (class-of
13 object)))))))
14 (identity :label nil :function #'identity)
b1c8f43b 15 (type :label "Type" :function #'type-of)
6de8d300 16 (class :label "Class" :function #'class-of)
17 (active-attributes :label "Attributes"
18 :value nil
19 :activep nil
b7657b86 20 :keyword :attributes)
21 (attribute-delimiter :label "Attribute Delimiter"
22 :value "~%"
23 :activep nil
24 :keyword :delimter)
25 (active-descriptions :label "Active Descriptions"
26 :value nil
27 :activep nil
28 :keyword :activate)
29 (inactive-descriptions :label "Inactive Descriptions"
bd9c9c31 30 :value nil
31 :activep nil
32 :keyword :deactivate)
f4efa7ff 33 (label-formatter :value (lambda (label)
b1c8f43b 34 (generic-format *display* "~A:" label))
f4efa7ff 35 :activep nil)
36 (value-formatter :value (curry #'format nil "~A")
37 :activep nil)))
4358148e 38
39(define-layered-method description-of (any-lisp-object)
40 (find-description 't))
41
b7657b86 42(define-layered-function display-attribute (attribute)
43 (:method (attribute)
44 (display-using-description attribute *display* (attribute-object attribute))))
e8d4fa45 45
2548f054 46
b7657b86 47(define-layered-function display-attribute-label (attribute)
48 (:method (attribute)
f4efa7ff 49 (funcall (attribute-label-formatter attribute) (attribute-label attribute))))
50
b7657b86 51(define-layered-function display-attribute-value (attribute)
f56d6e7e 52 (:method-combination arnesi:wrapping-standard)
b7657b86 53 (:method (attribute)
54 (flet ((disp (val &rest args)
55 (apply #'display *display* val
56 :activate (attribute-active-descriptions attribute)
57 :deactivate (attribute-inactive-descriptions attribute)
58 args)))
46440824 59
60
e8d4fa45 61 (let ((val (attribute-value attribute)))
46440824 62#+nil (break "display Attribute value: ~A with object ~A ~% Description ~A att-d ~A ~% VALUE ~A display on ~A"
63 attribute
64 (attribute-object attribute)
65 *description*
66 (attribute-description attribute)
67 val
68 *display*
69 )
2548f054 70 (if (and (not (slot-boundp attribute 'active-attributes))
46440824 71 (equal val (attribute-object attribute)))
72 (progn (generic-format *display* "~A"(funcall (attribute-value-formatter attribute) val))
73 #+nil(break "using generic format because val is object and there is no active attributes."))
74
e8d4fa45 75 (with-active-descriptions (inline)
2548f054 76 (cond ((slot-value attribute 'value-formatter)
46440824 77 (generic-format *display* "~A"(funcall (attribute-value-formatter attribute) val)))
2548f054 78 ((slot-boundp attribute 'active-attributes)
79 (disp val :attributes (slot-value attribute 'active-attributes)))
80 (t
81 (disp val)))))))))
e8d4fa45 82
83(define-layered-method display-using-description
84 ((attribute standard-attribute) display object &rest args)
85 (declare (ignore args))
86 (when (attribute-label attribute)
b7657b86 87 (display-attribute-label attribute))
88 (display-attribute-value attribute))
e8d4fa45 89
3a420e7d
CE
90(define-layered-method display-attribute :around ((attribute standard-attribute))
91 (with-attribute-context (attribute)
92 (call-next-method))
93 #+nil(funcall-with-layer-context
2548f054 94 (modify-layer-context (current-layer-context)
95 :activate (attribute-active-descriptions attribute)
96 :deactivate (attribute-inactive-descriptions attribute))
97 (lambda ()
98 (call-next-method))))
99
100(define-layered-method display-attribute :before
101 ((attribute standard-attribute))
46440824 102#+nil (break "Attribute : ~A with object ~A ~% Description ~A att-d ~A"
103 attribute
104 (attribute-object attribute)
105 *description*
106 (attribute-description attribute)
107))
2548f054 108
4358148e 109(define-display ((description t))
b7657b86 110 (let ((attributes (attributes description)))
f56d6e7e 111 (when (first attributes)(display-attribute (first attributes)))
f4efa7ff 112 (dolist (attribute (rest attributes) (values))
b7657b86 113 (generic-format *display*
114 (attribute-value
115 (find-attribute description 'attribute-delimiter)))
116 (display-attribute attribute))))
117
118
f4efa7ff 119(define-display :around ((description t) (display null) object)
120 (with-output-to-string (*standard-output*)
7aeb0a90
CE
121 (apply #'call-next-layered-method description t object args)))
122
b7657b86 123
4358148e 124
6de8d300 125
126