Fix h macro
This commit is contained in:
parent
2b3446dac6
commit
55735c71cc
2 changed files with 16 additions and 15 deletions
|
@ -194,7 +194,7 @@ When given :ASCII and :ATTR, it's possible to insert html text as a children, e.
|
||||||
|
|
||||||
(defmacro h (&body body)
|
(defmacro h (&body body)
|
||||||
`(progn
|
`(progn
|
||||||
,@(tree-leaves
|
,@(modify-first-leaves
|
||||||
body
|
body
|
||||||
(html-element-p x)
|
(html-element-p x)
|
||||||
(find-symbol (string-upcase x) :piccolo))))
|
(find-symbol (string-upcase x) :piccolo))))
|
||||||
|
|
|
@ -10,22 +10,23 @@
|
||||||
(cdr kv)))
|
(cdr kv)))
|
||||||
alist))
|
alist))
|
||||||
|
|
||||||
(defstruct !expanded list)
|
(defun %%modify-first-leaves (tree test result)
|
||||||
|
|
||||||
(defun tree-leaves%% (tree test result)
|
|
||||||
(if tree
|
(if tree
|
||||||
(if (listp tree)
|
(cons (let ((first-node (first tree)))
|
||||||
(let ((car-result (tree-leaves%% (car tree) test result))
|
(cond
|
||||||
(cdr-result (tree-leaves%% (cdr tree) test result)))
|
((listp first-node)
|
||||||
(if (!expanded-p car-result)
|
(%%modify-first-leaves first-node test result))
|
||||||
(append (!expanded-list car-result) cdr-result)
|
((funcall test first-node)
|
||||||
(cons car-result cdr-result)))
|
(funcall result first-node))
|
||||||
(if (funcall test tree)
|
(t first-node)))
|
||||||
(funcall result tree)
|
(mapcar (lambda (node)
|
||||||
tree))))
|
(if (listp node)
|
||||||
|
(%%modify-first-leaves node test result)
|
||||||
|
node))
|
||||||
|
(rest tree)))))
|
||||||
|
|
||||||
(defmacro tree-leaves (tree test result)
|
(defmacro modify-first-leaves (tree test result)
|
||||||
`(tree-leaves%%
|
`(%%modify-first-leaves
|
||||||
,tree
|
,tree
|
||||||
(lambda (x)
|
(lambda (x)
|
||||||
(declare (ignorable x))
|
(declare (ignorable x))
|
||||||
|
|
Loading…
Reference in a new issue