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))) (values (make-attrs :alist (asu:hash-alist (first attrs-and-children)))
(flatten (rest attrs-and-children)))) (flatten (rest attrs-and-children))))
((keywordp (first attrs-and-children)) ;inline-plist ((keywordp (first attrs-and-children)) ;inline-plist
(loop for thing on attrs-and-children by #'cddr (loop :for thing :on attrs-and-children :by #'cddr
for (k v) = thing :for (k v) := thing
when (and (keywordp k) v) :when (and (keywordp k) v)
collect (cons k v) into attrs :collect (cons k v) :into attrs
when (not (keywordp k)) :when (not (keywordp k))
return (values (make-attrs :alist attrs) (flatten thing)) :return (values (make-attrs :alist attrs) (flatten thing))
finally (return (values (make-attrs :alist attrs) nil)))) :finally (return (values (make-attrs :alist attrs) nil))))
(t (t
(values (make-attrs :alist nil) (flatten attrs-and-children))))) (values (make-attrs :alist nil) (flatten attrs-and-children)))))

View file

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