Skip to content

Commit e1770b8

Browse files
committed
feat(explainer): add method to append string directly
1 parent 670ecf3 commit e1770b8

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

elsa-explainer.el

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ depth in case one explainer was appended to another.")
127127
(funcall (-flip #'string-join) "\n")
128128
(replace-regexp-in-string (concat "^" initial-prefix "\n") ""))))
129129

130-
(cl-defgeneric elsa--reset-depth ((this elsa-explainer))
130+
(cl-defmethod elsa--reset-depth ((this elsa-explainer))
131131
(let* ((messages (elsa-get-messages this))
132132
(min-depth-message (--min-by (> (oref it depth)
133133
(oref other depth))
@@ -139,8 +139,8 @@ depth in case one explainer was appended to another.")
139139
(setf (elsa-get-depth this) 0))
140140
this)
141141

142-
(cl-defgeneric elsa--append-explainer ((this elsa-explainer)
143-
(other elsa-explainer))
142+
(cl-defmethod elsa--append-explainer ((this elsa-explainer)
143+
(other elsa-explainer))
144144
"Append OTHER explainer to THIS on the same level."
145145
(let* ((this-messages (copy-sequence (elsa-get-messages this)))
146146
(other-messages (mapcar #'clone (elsa-get-messages other)))
@@ -152,8 +152,16 @@ depth in case one explainer was appended to another.")
152152
(append other-messages this-messages))
153153
this))
154154

155-
(cl-defgeneric elsa--attach-explainer ((this elsa-explainer)
156-
(other elsa-explainer))
155+
(cl-defmethod elsa--append-explainer ((this elsa-explainer)
156+
(other string))
157+
(elsa--append-explainer
158+
this
159+
(elsa-with-temp-explainer explainer
160+
(elsa-explain explainer other)
161+
explainer)))
162+
163+
(cl-defmethod elsa--attach-explainer ((this elsa-explainer)
164+
(other elsa-explainer))
157165
"Attach OTHER explainer to THIS indented by one extra level."
158166
(let* ((this-messages (copy-sequence (elsa-get-messages this)))
159167
(other-messages (mapcar #'clone (elsa-get-messages other)))

0 commit comments

Comments
 (0)