From 9e81bf6a8fa8262566a33797aa9dfd51f40e80dc Mon Sep 17 00:00:00 2001 From: colin Date: Sun, 24 Nov 2024 09:28:14 -0800 Subject: Alter ATTRIBS debug printing; add more attribs updaters --- src/hypnotisml.lisp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/hypnotisml.lisp') 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) -- cgit v1.2.3