# This function takes an a list of patterns and a list and
# it searchs for a pattern that matches a member of the list

# patternListSearch pats list ?arg ... ?arg
#
# arg may be any of the lsearch options
# these options are used on each search (one search per pattern)
# 
# The return is either {} or a list of at least two entries.
# A return of {} indicates that none the patterns matches anything 
# in the list. The first entry is the index of the found pattern
# in list the second entry is the index of the pattern that matched
# if "-subindices" is code, the first entry will be as per lsearch
# if "-all" is coded, the return is a list of two element lists
# with one entry for each pattern that matched.
#
proc patternListSearch {pats list args} {
  set indx -1
  set ret {}
  foreach pattern $pats {
    incr indx
    if {[set re [lsearch {*}$args $list $pattern]] != -1} {
      lappend ret [list $re $indx]
      if { "-all" in $args} {continue}
      break
    }
  }
  return $ret
}
