Ignore:
Timestamp:
10/16/09 14:59:20 (3 years ago)
Author:
james
Message:

support multiple filters per abstract

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/modules/abstract.tcl

    r1032 r1041  
    136136  global bMotionModules bMotion_testing bMotion_loading 
    137137  global bMotionInfo bMotion_abstract_languages bMotion_abstract_dir 
    138         global bMotion_abstract_last_get 
     138        global bMotion_abstract_last_get bMotion_abstract_filters 
    139139 
    140140  #set timestamp to now 
     
    142142  set lang $bMotionInfo(language) 
    143143        set bMotion_abstract_last_get($abstract) "" 
     144        set bMotion_abstract_filters($abstract) "" 
    144145 
    145146  #load any existing abstracts 
     
    508509proc bMotion_abstract_revive_language { } { 
    509510  global bMotionSettings bMotionInfo bMotionModules 
    510   global bMotion_abstract_contents bMotionLocal 
    511  
    512   set lang $bMotionInfo(language) 
     511  global bMotion_abstract_contents bMotionLocal bMotion_abstract_filters 
     512 
     513  set lang $bMotionInfo(language) 
     514 
    513515 
    514516  bMotion_putloglev 2 * "bMotion: reviving language ($lang) abstracts" 
     
    582584 
    583585# filter out stuff from an abstract 
    584 proc bMotion_abstract_filter { abstract filter_text } { 
     586proc bMotion_abstract_filter { abstract filter } { 
    585587        global bMotion_abstract_contents bMotion_abstract_ondisk 
    586588 
     
    596598 
    597599        if {[llength $contents] == 0} { 
    598                 bMotion_putloglev d * "can't get contents for $abstract" 
     600                if {$abstract != "_all"} { 
     601                        bMotion_putloglev d * "can't get contents for $abstract" 
     602                } 
    599603                return 
    600604        } 
     
    605609        foreach element $contents { 
    606610                bMotion_putloglev 2 * "considering $element for filtering" 
    607                 if [regexp $filter_text $element] { 
    608                         bMotion_putloglev 1 * "abstract $abstract element $element matches filter, dropping" 
    609                         continue 
    610                 } 
    611                 lappend new_contents $element 
     611                set do_filter 0 
     612                foreach filter_text $filter { 
     613                        if {(!$do_filter) && [regexp $filter_text $element]} { 
     614                                bMotion_putloglev 1 * "abstract $abstract element $element matches filter $filter_text, dropping" 
     615                                set do_filter 1 
     616                        } 
     617                } 
     618                if {!$do_filter} { 
     619                        lappend new_contents $element 
     620                } 
    612621        } 
    613622 
    614623        set new_size [llength $new_contents] 
    615624  set diff [expr $initial_size - $new_size] 
    616         bMotion_putloglev d * "abstract $abstract reduced by $diff items with filter $filter_text" 
     625        bMotion_putloglev d * "abstract $abstract reduced by $diff items with filter $filter" 
    617626 
    618627        if {$diff > 0} { 
     
    635644 
    636645        bMotion_abstract_filter $abstract $filter 
     646        catch { 
     647                set filter $bMotion_abstract_filter(_all) 
     648                bMotion_abstract_filter $abstract $filter 
     649        } 
    637650} 
    638651 
     
    641654        global bMotion_abstract_filters 
    642655 
    643         set bMotion_abstract_filters($abstract) $filter_text 
     656        lappend bMotion_abstract_filters($abstract) $filter_text 
     657 
    644658        bMotion_putloglev d * "registered filter /$filter_text/ for abstract $abstract" 
    645659 
Note: See TracChangeset for help on using the changeset viewer.