Mercurial > urweb
annotate demo/treeFun.ur @ 2142:3288e3c9948b
Fix XML indentation in Emacs mode
The return value of MATCH-STRING is a string. At least on Emacs 25,
the comparisons between string and character with EQUAL could never
succeed, and so the cases for matching braces were never triggered.
GET-TEXT-PROPERTY may return a list rather than an atom (for example,
on long lines with whitespace-mode turned on), and this broke the
heuristic of looking for the tag face in previous text.
author | Julian Squires <julian@cipht.net> |
---|---|
date | Mon, 04 May 2015 14:35:07 -0400 |
parents | 311ca1ae715d |
children |
rev | line source |
---|---|
adamc@469 | 1 functor Make(M : sig |
adamc@469 | 2 type key |
adamc@469 | 3 con id :: Name |
adamc@469 | 4 con parent :: Name |
adamc@469 | 5 con cols :: {Type} |
adamc@469 | 6 constraint [id] ~ [parent] |
adamc@469 | 7 constraint [id, parent] ~ cols |
adamc@469 | 8 |
adamc@723 | 9 val key_inj : sql_injectable_prim key |
adamc@469 | 10 |
adamc@706 | 11 table tab : ([id = key, parent = option key] ++ cols) |
adamc@469 | 12 end) = struct |
adamc@469 | 13 |
adamc@469 | 14 open M |
adamc@469 | 15 |
adamc@469 | 16 fun tree (f : $([id = key, parent = option key] ++ cols) -> xbody) |
adamc@469 | 17 (root : option M.key) = |
adamc@469 | 18 let |
adamc@469 | 19 fun recurse (root : option key) = |
adamc@471 | 20 queryX' (SELECT * FROM tab WHERE {eqNullable' (SQL tab.{parent}) root}) |
adamc@469 | 21 (fn r => |
adamc@469 | 22 children <- recurse (Some r.Tab.id); |
adamc@469 | 23 return <xml> |
adamc@469 | 24 <li> {f r.Tab}</li> |
adamc@469 | 25 |
adamc@469 | 26 <ul> |
adamc@469 | 27 {children} |
adamc@469 | 28 </ul> |
adamc@469 | 29 </xml>) |
adamc@469 | 30 in |
adamc@469 | 31 recurse root |
adamc@469 | 32 end |
adamc@469 | 33 |
adamc@469 | 34 end |