Index: macros.py
===================================================================
--- macros.py	(revision 10019)
+++ macros.py	(working copy)
@@ -19,6 +19,7 @@
 import os
 import re
 from StringIO import StringIO
+import fnmatch
 
 from genshi.builder import Element, tag
 from genshi.core import Markup
@@ -76,6 +77,7 @@
     parameter is omitted, all pages are listed.
     If the prefix is specified, a second argument of value 'hideprefix'
     can be given as well, in order to remove that prefix from the output.
+    Any includes provided are processed before excludes.
 
     Alternate `format` and `depth` named parameters can be specified:
      - `format=compact`: The pages are displayed as comma-separated links.
@@ -89,6 +91,10 @@
        only toplevel pages will be shown, if set to 1, only immediate
        children pages will be shown, etc. If not set, or set to -1,
        all pages in the hierarchy will be shown.
+     - `exclude=page1:page*2`: exclude pages which match any item in the colon
+        separated list of pages.
+     - `include=page1:page*2`: include pages wihch match any item in the colon
+        separated list of pages
     """
 
     SPLIT_RE = re.compile(r"([/ 0-9.]+)")
@@ -102,6 +108,13 @@
         start = prefix and prefix.count('/') or 0
         format = kw.get('format', '')
 
+        def parse_include_exclude(in_or_exclude):
+            return [inc.strip()
+                    for inc in in_or_exclude.split(':')
+                    if inc.strip()]
+        includes = parse_include_exclude(kw.get('include', ''))
+        excludes = parse_include_exclude(kw.get('exclude', ''))
+
         if hideprefix:
             omitprefix = lambda page: page[len(prefix):]
         else:
@@ -109,10 +122,24 @@
 
         wiki = formatter.wiki
 
-        pages = sorted(page for page in wiki.get_pages(prefix) \
-                       if (depth < 0 or depth >= page.count('/') - start)
-                       and 'WIKI_VIEW' in formatter.perm('wiki', page))
+        pages = [page for page in wiki.get_pages(prefix)
+                 if (depth < 0 or depth >= page.count('/') - start)
+                 and 'WIKI_VIEW' in formatter.perm('wiki', page)]
 
+        filtered_pages = set()
+
+        if includes:
+            for include in includes:
+                filtered_pages.update(fnmatch.filter(pages, include))
+        else:
+            filtered_pages = set(pages)
+
+        for exclude in excludes:
+            filtered_pages.difference_update(
+                fnmatch.filter(filtered_pages, exclude))
+
+        pages = sorted(filtered_pages)
+
         if format == 'compact':
             return tag(
                 separated((tag.a(wiki.format_page_name(omitprefix(p)),
Index: tests/macros.py
===================================================================
--- tests/macros.py	(revision 10019)
+++ tests/macros.py	(working copy)
@@ -213,6 +213,27 @@
 </p><div class="titleindex"><ul><li><strong>0.11</strong><ul><li><strong>Group</strong><ul><li><a href="/wiki/0.11/GroupOne">0.11/GroupOne</a></li><li><a href="/wiki/0.11/GroupTwo">0.11/GroupTwo</a></li></ul></li><li><a href="/wiki/0.11/Test">0.11/Test</a></li></ul></li><li><strong>Test</strong><ul><li><strong>0.11Abc</strong><ul><li><a href="/wiki/Test0.11/Abc">Test0.11/Abc</a></li><li><a href="/wiki/Test0.11Abc">Test0.11Abc</a></li></ul></li><li><strong>0.12</strong><ul><li><a href="/wiki/Test0.12Def">Test0.12Def</a></li><li><a href="/wiki/Test0.12Ijk">Test0.12Ijk</a></li></ul></li><li><strong>0.13</strong><ul><li><a href="/wiki/Test0.13alpha">Test0.13alpha</a></li><li><a href="/wiki/Test0.13beta">Test0.13beta</a></li></ul></li><li><a href="/wiki/Test0.131">Test0.131</a></li><li><a href="/wiki/Test2">Test2</a></li><li><a href="/wiki/TestTest">TestTest</a></li><li><a href="/wiki/TestThing">TestThing</a></li></ul></li><li><a href="/wiki/WikiStart">WikiStart</a></li></ul></div><p>
 </p>
 ------------------------------
+============================== TitleIndex, compact format with prefix hidden, including Test0.13*
+[[TitleIndex(Test,format=compact,include=*0.13*)]]
+------------------------------
+<p>
+<a href="/wiki/Test0.131">Test0.131</a>, <a href="/wiki/Test0.13alpha">Test0.13alpha</a>, <a href="/wiki/Test0.13beta">Test0.13beta</a>
+</p>
+------------------------------
+============================== TitleIndex, compact format, excluding various topics
+[[TitleIndex(Test,format=compact,exclude=Test0.13*:*0.11*:Test2:Test*i*)]]
+------------------------------
+<p>
+<a href="/wiki/Test0.12Def">Test0.12Def</a>, <a href="/wiki/TestTest">TestTest</a>
+</p>
+------------------------------
+============================== TitleIndex, compact format, including and excluding various topics
+[[TitleIndex(format=compact,include=*Group*:test2,exclude=*one)]]
+------------------------------
+<p>
+<a href="/wiki/0.11/GroupTwo">0.11/GroupTwo</a>, <a href="/wiki/Test2">Test2</a>
+</p>
+------------------------------
 """
 
 def titleindex4_setup(tc):

