# -*- coding: iso-8859-1 -*-
"""
    MoinMoin - FullSearchWithoutSelf Macro

    [[FullSearchWithoutSelf]]
        does the same as clicking on the page title, only that
        the result is embedded into the page and the page itself isn't listed.

"""

import re
from MoinMoin import config, wikiutil, search

Dependencies = ["pages"]

def execute(macro, needle):
    request = macro.request
    _ = request.getText

    needle = '"%s" -title:regex:"^%s$"' % (macro.formatter.page.page_name, macro.formatter.page.page_name)
    needle = needle.strip()

    # Search the pages and return the results
    query = search.QueryParser().parse_query(needle)
    results = search.searchPages(request, query)
    results.sortByPagename()

    return results.pageList(request, macro.formatter)


