diff --git a/xonsh/completers/base.py b/xonsh/completers/base.py index abea5093e..991a4576d 100644 --- a/xonsh/completers/base.py +++ b/xonsh/completers/base.py @@ -6,6 +6,9 @@ from xonsh.completers.commands import complete_command def complete_base(prefix, line, start, end, ctx): + """If the line is empty, complete based on valid commands, python names, + and paths. If we are completing the first argument, complete based on + valid commands and python names.""" if line.strip() == '': out = (complete_python(prefix, line, start, end, ctx) | complete_command(prefix, line, start, end, ctx)) diff --git a/xonsh/completers/bash.py b/xonsh/completers/bash.py index b399f7bae..405a72d19 100644 --- a/xonsh/completers/bash.py +++ b/xonsh/completers/bash.py @@ -24,7 +24,7 @@ for ((i=0;i<${{#COMPREPLY[*]}};i++)) do echo ${{COMPREPLY[i]}}; done def complete_from_bash(prefix, line, begidx, endidx, ctx): - """Attempts BASH completion.""" + """Completes based on results from BASH completion.""" if not INITED: _load_bash_complete_funcs() _load_bash_complete_files() diff --git a/xonsh/completers/commands.py b/xonsh/completers/commands.py index 2500337ea..527075660 100644 --- a/xonsh/completers/commands.py +++ b/xonsh/completers/commands.py @@ -26,6 +26,10 @@ def complete_command(cmd, line, start, end, ctx): def complete_skipper(cmd, line, start, end, ctx): + """ + Skip over several tokens (e.g., sudo) and complete based on the rest of the + line. + """ res = line.split(' ', 1) if len(res) == 2: first, rest = res diff --git a/xonsh/completers/dirs.py b/xonsh/completers/dirs.py index 571076749..c0cdab6be 100644 --- a/xonsh/completers/dirs.py +++ b/xonsh/completers/dirs.py @@ -6,12 +6,18 @@ PREVENT_OTHERS = ['path'] def complete_cd(prefix, line, start, end, ctx): + """ + Completion for "cd", includes only valid directory names. + """ if start != 0 and line.split(' ')[0] == 'cd': return complete_dir(prefix, line, start, end, ctx, True) return set() def complete_rmdir(prefix, line, start, end, ctx): + """ + Completion for "rmdir", includes only valid directory names. + """ if start != 0 and line.split(' ')[0] == 'rmdir': return complete_dir(prefix, line, start, end, ctx, True) return set() diff --git a/xonsh/completers/man.py b/xonsh/completers/man.py index 3924e11bc..b10fe3154 100644 --- a/xonsh/completers/man.py +++ b/xonsh/completers/man.py @@ -22,7 +22,8 @@ INNER_OPTIONS_RE = re.compile(r'-\w|--[a-z0-9-]+') def complete_from_man(prefix, line, start, end, ctx): - """Completes an option name, basing on content of man page.""" + """Completes an option name, based on the contents of the associated man + page.""" global OPTIONS if not prefix.startswith('-'): return set() diff --git a/xonsh/completers/python.py b/xonsh/completers/python.py index f02054fd0..16f668ecc 100644 --- a/xonsh/completers/python.py +++ b/xonsh/completers/python.py @@ -17,11 +17,15 @@ XONSH_TOKENS = { '/', '//', '%', '**', '|', '&', '~', '^', '>>', '<<', '<', '<=', '>', '>=', '==', '!=', '->', '=', '+=', '-=', '*=', '/=', '%=', '**=', '>>=', '<<=', '&=', '^=', '|=', '//=', ',', ';', ':', '?', '??', '$(', '${', '$[', '..', - '...' + '...', '![', '!(', } def complete_python(prefix, line, start, end, ctx): + """ + Completes based on the contents of the current Python environment, + the Python built-ins, and xonsh operators. + """ filt = get_filter_function() rtn = {s for s in XONSH_TOKENS if filt(s, prefix)} if ctx is not None: @@ -33,6 +37,9 @@ def complete_python(prefix, line, start, end, ctx): def complete_python_mode(prefix, line, start, end, ctx): + """ + Python-mode completions for @( and ${ + """ if not (prefix.startswith('@(') or prefix.startswith('${')): return set() prefix_start = prefix[:2] @@ -88,6 +95,10 @@ def attr_complete(prefix, ctx, filter_func): def complete_import(prefix, line, start, end, ctx): + """ + Completes module names and contents for "import ..." and "from ... import + ..." + """ ltoks = line.split() if len(ltoks) == 2 and ltoks[0] == 'from': # completing module to import