Clarify keywords in loop macro

This commit is contained in:
paku 2024-02-20 11:09:38 +09:00
parent 7d24252899
commit 7d94d02f42
2 changed files with 11 additions and 11 deletions

View file

@ -136,13 +136,13 @@
(values (make-attrs :alist (asu:hash-alist (first attrs-and-children)))
(flatten (rest attrs-and-children))))
((keywordp (first attrs-and-children)) ;inline-plist
(loop for thing on attrs-and-children by #'cddr
for (k v) = thing
when (and (keywordp k) v)
collect (cons k v) into attrs
when (not (keywordp k))
return (values (make-attrs :alist attrs) (flatten thing))
finally (return (values (make-attrs :alist attrs) nil))))
(loop :for thing :on attrs-and-children :by #'cddr
:for (k v) := thing
:when (and (keywordp k) v)
:collect (cons k v) :into attrs
:when (not (keywordp k))
:return (values (make-attrs :alist attrs) (flatten thing))
:finally (return (values (make-attrs :alist attrs) nil))))
(t
(values (make-attrs :alist nil) (flatten attrs-and-children)))))

View file

@ -25,15 +25,15 @@
(defun escape-char (char escape-map)
(or (cdr (assoc char escape-map))
char))
char))
(defun escape-string (string escape-map)
(if (stringp string)
(with-output-to-string (s)
(loop
for c across string
do (write (escape-char c escape-map)
:stream s :escape nil)))
:for c :across string
:do (write (escape-char c escape-map)
:stream s :escape nil)))
string))
(defun escape-attrs-alist (alist)