def is_magic(token, token_start, buf):
    """
    Detect if the passed token corresponds to a magic command: starts
    with a percent, and it's at the beginning of the buffer
    """
    return token[0] == '%' and token_start == 0
