summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcolin <colin@cicadas.surf>2024-11-24 09:28:14 -0800
committercolin <colin@cicadas.surf>2024-11-24 09:28:14 -0800
commit9e81bf6a8fa8262566a33797aa9dfd51f40e80dc (patch)
treedb90bf6ad2128e48bdd292a0dbc0ee9c3cbfe0a6
parent8040abe92f2c8097aa40a609a6fac2ef5e22a2d3 (diff)
Alter ATTRIBS debug printing; add more attribs updaters
-rw-r--r--src/hypnotisml.lisp16
-rw-r--r--src/package.lisp2
2 files changed, 14 insertions, 4 deletions
diff --git a/src/hypnotisml.lisp b/src/hypnotisml.lisp
index 544f195..7a71fad 100644
--- a/src/hypnotisml.lisp
+++ b/src/hypnotisml.lisp
@@ -60,7 +60,7 @@
(list nil :type keyword-plist))
(defmethod print-object ((ob attribs) stream)
- (format stream "~{~a=~s~^ ~}" (attribs-list ob)))
+ (format stream "{~{~a=~s~^ ~}}" (attribs-list ob)))
(def:class node ()
(parent :type (or null elem))
@@ -227,15 +227,23 @@ Returns ELEM."
(make-attribs :list plist)))
elem)
+(defun @!= (elem attrs)
+ "Like @= but attrs is an ATTRIBS instance."
+ (apply #'@= elem (attribs-list attrs)))
+
+(defun @!~ (elem attrs)
+ "Like @~ but attrs is an ATTRIBS instance."
+ (apply #'@~ elem (attribs-list attrs)))
+
(defun @~ (elem &rest plist)
"Just like @= except an attribute WILL NOT be updated if it is
already present in the element."
(check-type plist keyword-plist)
(a:if-let (attribs (elem-attributes elem))
(loop
- :for (prop val) :on plist :by #'cddr
- :when (and val (not (getf (attribs-list attribs) prop)))
- :do (setf (getf (attribs-list attribs) prop) val))
+ :for (prop val) :on plist :by #'cddr
+ :when (and val (not (getf (attribs-list attribs) prop)))
+ :do (setf (getf (attribs-list attribs) prop) val))
(setf (elem-attributes elem)
(make-attribs :list plist)))
elem)
diff --git a/src/package.lisp b/src/package.lisp
index 5064b6c..64d3d87 100644
--- a/src/package.lisp
+++ b/src/package.lisp
@@ -156,6 +156,8 @@
#:@
#:@=
#:@~
+ #:@!=
+ #:@!~
#:@?
#:$
#:$=