]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/xmode/utilities/utilities.factor
xmode: update for recent jEdit mode changes
[factor.git] / basis / xmode / utilities / utilities.factor
index b5a2f6eb98eeacc068575c6b44ef4a31c1d0131a..2d5e3c7f4041f632231082cd8765fe6ac1d7a2b4 100644 (file)
@@ -1,16 +1,9 @@
-USING: accessors sequences assocs kernel quotations namespaces
-xml.data xml.utilities combinators macros parser lexer words fry ;
+USING: combinators kernel namespaces quotations regexp sequences
+splitting xml.data xml.traversal ;
 IN: xmode.utilities
 
 : implies ( x y -- z ) [ not ] dip or ; inline
 
-: child-tags ( tag -- seq ) children>> [ tag? ] filter ;
-
-: map-find ( seq quot -- result elt )
-    f -rot
-    '[ nip @ dup ] find
-    [ [ drop f ] unless ] dip ; inline
-
 : tag-init-form ( spec -- quot )
     {
         { [ dup quotation? ] [ [ object get tag get ] prepose ] }
@@ -22,7 +15,7 @@ IN: xmode.utilities
         ] }
         { [ dup length 3 = ] [
             first3 '[
-                _ tag get at
+                tag get _ attr
                 _ [ execute ] when* object get _ execute
             ]
         ] }
@@ -31,27 +24,14 @@ IN: xmode.utilities
 : with-tag-initializer ( tag obj quot -- )
     [ object set tag set ] prepose with-scope ; inline
 
-MACRO: (init-from-tag) ( specs -- )
+MACRO: (init-from-tag) ( specs -- quot )
     [ tag-init-form ] map concat [ ] like
     [ with-tag-initializer ] curry ;
 
 : init-from-tag ( tag tuple specs -- tuple )
     over [ (init-from-tag) ] dip ; inline
 
-SYMBOL: tag-handlers
-SYMBOL: tag-handler-word
-
-: <TAGS:
-    CREATE tag-handler-word set
-    H{ } clone tag-handlers set ; parsing
-
-: (TAG:) ( name quot -- ) swap tag-handlers get set-at ;
-
-: TAG:
-    scan parse-definition
-    (TAG:) ; parsing
-
-: TAGS>
-    tag-handler-word get
-    tag-handlers get >alist [ [ dup main>> ] dip case ] curry
-    define ; parsing
+: <?insensitive-regexp> ( string ? -- regexp )
+    ! handle Java style case-insensitive flags
+    "(?i)" pick subseq-start [ drop "(?i)" "" replace t ] when
+    "i" "" ? <optioned-regexp> ;