Exemplo n.º 1
0
def pycomplete(s, imports=None):
    completions = get_all_completions(s, imports)
    dots = s.split(".")
    result = os.path.commonprefix([k[len(dots[-1]):] for k in completions])

    if result == "":
        if completions:
            width = lisp.window_width() - 2
            colum = width / 20
            white = "                    "

            msg = ""

            counter = 0
            for completion in completions:
                if completion.__len__() < 20:
                    msg += completion + white[completion.__len__():]
                    counter += 1
                else:
                    msg += completion + white[completion.__len__() - 20:]
                    counter += 2

                if counter >= colum:
                    counter = 0
                    msg += '\n'

        else:
            msg = "no completions!"
        lisp.message(msg)
    return result
Exemplo n.º 2
0
def pycomplete(s, imports=None):
    completions = get_all_completions(s, imports)
    dots = s.split(".")
    result = os.path.commonprefix([k[len(dots[-1]):] for k in completions])

    if result == "":
        if completions:
            width = lisp.window_width() - 2
            colum = width / 20
            white = "                    "

            msg = ""

            counter = 0
            for completion in completions :
                if completion.__len__() < 20 :
                    msg += completion + white[completion.__len__():]
                    counter += 1
                else :
                    msg += completion + white[completion.__len__() - 20:]
                    counter += 2

                if counter >= colum :
                    counter = 0
                    msg += '\n'

        else:
            msg = "no completions!"
        lisp.message(msg)
    return  result       
Exemplo n.º 3
0
def pycomplete(s, fname=None, imports=None, debug=False):
    '''Display completion in Emacs window'''

    if not s:
        return ''
    # changes to where the file is
    if fname:
        os.chdir(os.path.dirname(fname))

    completions = _get_all_completions(s, imports)
    completions.sort(key=lambda x: len(x), reverse=True)

    dots = s.split('.')
    result = os.path.commonprefix([k[len(dots[-1]):] for k in completions])

    if result == '' or result not in completions:
        if completions:
            if debug:
                width = 80
            else:
                width = lisp.window_width() - 2

            column = width / COLWIDTH
            white = ' ' * COLWIDTH
            msg = ''

            counter = 0
            for completion in completions:
                if len(completion) < COLWIDTH:
                    msg += completion + white[len(completion):]
                    counter += 1
                else:
                    msg += completion + white[len(completion) - COLWIDTH:]
                    counter += 2

                if counter >= column:
                    counter = 0
                    msg += '\n'
        else:
            msg = 'no completions!'
        if debug:
            return set(completions)
        else:
            lisp.message(msg)
    return result
Exemplo n.º 4
0
def pycomplete(s, fname=None, imports=None, debug=False):
    '''Display completion in Emacs window'''

    if not s:
        return ''
    # changes to where the file is
    if fname:
        os.chdir(os.path.dirname(fname))

    completions = _get_all_completions(s, imports)
    completions.sort(key=lambda x: len(x), reverse=True)

    dots = s.split('.')
    result = os.path.commonprefix([k[len(dots[-1]):] for k in completions])

    if result == '' or result not in completions:
        if completions:
            if debug:
                width = 80
            else:
                width = lisp.window_width() - 2

            column = width / COLWIDTH
            white = ' ' * COLWIDTH
            msg = ''

            counter = 0
            for completion in completions :
                if len(completion) < COLWIDTH:
                    msg += completion + white[len(completion):]
                    counter += 1
                else :
                    msg += completion + white[len(completion) - COLWIDTH:]
                    counter += 2

                if counter >= column:
                    counter = 0
                    msg += '\n'
        else:
            msg = 'no completions!'
        if debug:
            return set(completions)
        else:
            lisp.message(msg)
    return result       
Exemplo n.º 5
0
def pycomplete(s, fname=None, imports=None, debug=False):
    '''Display completion in Emacs window'''
    completions = _get_all_completions(s, fname, imports)
    if len(completions) == 0:
        return None
    dots = s.split('.')
    result = os.path.commonprefix([k[len(dots[-1]):] for k in completions])
    if result == '' or result not in completions:
        if completions:
            if debug:
                width = 80
            else:
                width = lisp.window_width() - 2

            column = width / COLWIDTH
            white = ' ' * COLWIDTH
            msg = ''

            counter = 0
            for completion in completions :
                if len(completion) < COLWIDTH:
                    msg += completion + white[len(completion):]
                    counter += 1
                else :
                    msg += completion + white[len(completion) - COLWIDTH:]
                    counter += 2

                if counter >= column:
                    counter = 0
                    msg += '\n'
        else:
            msg = 'no completions!'
        if debug:
            print msg
        else:
            return msg
 #           lisp.message(msg)
    return result       
Exemplo n.º 6
0
def pycomplete(s, imports=None, debug=False):
    """Display completion in Emacs window"""
    completions = _get_all_completions(s, imports)
    dots = s.split(".")
    result = os.path.commonprefix([k[len(dots[-1]):] for k in completions])

    if result == "":
        if completions:
            if debug:
                width = 80
            else:
                width = lisp.window_width() - 2

            column = width / 20
            white = " " * 20
            msg = ""

            counter = 0
            for completion in completions:
                if len(completion) < 20:
                    msg += completion + white[len(completion):]
                    counter += 1
                else:
                    msg += completion + white[len(completion) - 20:]
                    counter += 2

                if counter >= column:
                    counter = 0
                    msg += '\n'

        else:
            msg = "no completions!"
        if debug:
            print msg
        else:
            lisp.message(msg)
    return result
Exemplo n.º 7
0
def pycomplete(s, fname=None, imports=None, debug=False):
    '''Display completion in Emacs window'''
    completions = _get_all_completions(s, fname, imports)
    dots = s.split('.')
    result = os.path.commonprefix([k[len(dots[-1]):] for k in completions])

    if result == '' or result not in completions:
        if completions:
            if debug:
                width = 80
            else:
                width = lisp.window_width() - 2

            column = width / COLWIDTH
            white = ' ' * COLWIDTH
            msg = ''

            counter = 0
            for completion in completions :
                if len(completion) < COLWIDTH:
                    msg += completion + white[len(completion):]
                    counter += 1
                else :
                    msg += completion + white[len(completion) - COLWIDTH:]
                    counter += 2

                if counter >= column:
                    counter = 0
                    msg += '\n'
        else:
            msg = 'no completions!'
        if debug:
            print msg
        else:
            lisp.message(msg)
    return result