示例#1
0
 def get_completions(self, info):
     txt = info["help_obj"]
     # from latex
     matches = latex_matches(txt)
     if matches:
         return matches
     matches = [word for word in self.env if word.startswith(txt)]
     for p in list(_hy_macros.values()) + [_compile_table]:
         p = filter(lambda x: isinstance(x, str), p.keys())
         p = [x.replace('_', '-') for x in p]
         matches.extend(
             [x for x in p if x.startswith(txt) and x not in matches])
     return matches
示例#2
0
    def complete(txt):
        try:
            from hy.compiler import _compile_table, load_stdlib
            load_stdlib()
        except:
            _compile_table = []

        matches = [word for word in env if word.startswith(txt)]
        for p in list(_hy_macros.values()) + _compile_table:
            p = filter(lambda x: isinstance(x, str), p.keys())
            p = [x.replace('_', '-') for x in p]
            matches.extend(
                [x for x in p if x.startswith(txt) and x not in matches])
        return matches
示例#3
0
    def do_complete(self, code, cursor_pos):
        # let IPython do the heavy lifting for variables, etc.
        txt, matches = self.shell.complete('', code, cursor_pos)

        # mangle underscores into dashes
        matches = [match.replace('_', '-') for match in matches]

        for p in list(_hy_macros.values()) + [_compile_table]:
            p = filter(lambda x: isinstance(x, str), p.keys())
            p = [x.replace('_', '-') for x in p]
            matches.extend(
                [x for x in p if x.startswith(txt) and x not in matches])

        return {
            'matches': matches,
            'cursor_end': cursor_pos,
            'cursor_start': cursor_pos - len(txt),
            'metadata': {},
            'status': 'ok'
        }
示例#4
0
    def do_complete(self, code, cursor_pos):
        # let IPython do the heavy lifting for variables, etc.
        txt, matches = self.shell.complete('', code, cursor_pos)

        # mangle underscores into dashes
        matches = [match.replace('_', '-') for match in matches]

        for p in list(_hy_macros.values()) + [_compile_table]:
            p = filter(lambda x: isinstance(x, str), p.keys())
            p = [x.replace('_', '-') for x in p]
            matches.extend([
                x for x in p
                if x.startswith(txt) and x not in matches
            ])

        return {
            'matches': matches,
            'cursor_end': cursor_pos,
            'cursor_start': cursor_pos - len(txt),
            'metadata': {},
            'status': 'ok'
        }
示例#5
0
    def _find_hy_completions(self, partial_name):
        from hy.macros import _hy_macros
        from hy.compiler import load_stdlib, _stdlib, _compile_table
        from itertools import chain
        from keyword import iskeyword

        # Without this, built in macros will not load until after
        # the first sexp is evalutaed
        load_stdlib()

        matches = []

        # Add macros
        for namespace in _hy_macros.values():
            for name in namespace.keys():
                if name.startswith(partial_name):
                    matches.append(name)

        # Add builtins
        for name in chain(_stdlib.keys(), _compile_table.keys()):
            if str(name).startswith(partial_name) and not iskeyword(str(name)):
                matches.append(name)
        return matches
示例#6
0
    def _find_hy_completions(self, partial_name):
        from hy.macros import _hy_macros
        from hy.compiler import load_stdlib, _stdlib, _compile_table
        from itertools import chain
        from keyword import iskeyword

        # Without this, built in macros will not load until after
        # the first sexp is evalutaed
        load_stdlib()

        matches = []

        # Add macros
        for namespace in _hy_macros.values():
            for name in namespace.keys():
                if name.startswith(partial_name):
                    matches.append(name)

        # Add builtins
        for name in chain(_stdlib.keys(), _compile_table.keys()):
            if str(name).startswith(partial_name) and not iskeyword(str(name)):
                matches.append(name)
        return matches