def guessMode(text):
    """Tries to guess the type of the input text, using a quite fast heuristic.
    
    Returns one of the strings also present as key in the modes dictionary.
    
    """
    text = text.lstrip()
    if text.startswith(('%', '\\')):
        if '\\version' in text or '\\relative' in text or '\\score' in text:
            return 'lilypond'
        if '\\documentclass' in text or '\\begin{document}' in text:
            return 'latex'
        return 'lilypond'
    if text.startswith('<<'):
        return 'lilypond'
    if text.startswith('<'):
        if 'DOCTYPE book' in text or '<programlisting' in text:
            return 'docbook'
        else:
            return 'html'
    if text.startswith(('#!', ';', '(')):
        return 'scheme'
    if text.startswith('@'):
        return 'texinfo'
    if text.startswith('//'):
        return 'mup'
    s = text.split(None, 1)
    if s and s[0] in ('include', 'score', 'music'):
        return 'mup'
    return 'lilypond'
