Skip to content

Commit

Permalink
__load_completion: Load "xspec" completions dynamically too
Browse files Browse the repository at this point in the history
Allows overriding these completions by placing alternate ones to
separate completion files.

Closes #192
  • Loading branch information
scop committed Mar 13, 2018
1 parent 5e69954 commit e6781be
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 28 deletions.
4 changes: 3 additions & 1 deletion bash_completion
Original file line number Diff line number Diff line change
Expand Up @@ -1957,7 +1957,6 @@ _install_xspec()
for cmd in $@; do
_xspecs[$cmd]=$xspec
done
complete -F _filedir_xspec $@
}
# bzcmp, bzdiff, bz*grep, bzless, bzmore intentionally not here, see Debian: #455510
_install_xspec '!*.?(t)bz?(2)' bunzip2 bzcat pbunzip2 pbzcat lbunzip2 lbzcat
Expand Down Expand Up @@ -2055,6 +2054,9 @@ __load_completion()
done
done

# Look up simple "xspec" completions
[[ "${_xspecs[$cmd]}" ]] && complete -F _filedir_xspec "$cmd" && return 0

return 1
}

Expand Down
4 changes: 1 addition & 3 deletions test/completion/acroread.exp
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
assert_xspec_completion_installed acroread

source "$::srcdir/lib/completions/acroread.exp"
assert_source_completions acroread
4 changes: 1 addition & 3 deletions test/completion/kdvi.exp
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
assert_xspec_completion_installed kdvi

source "$::srcdir/lib/completions/kdvi.exp"
assert_source_completions kdvi
4 changes: 1 addition & 3 deletions test/completion/kpdf.exp
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
assert_xspec_completion_installed kpdf

source "$::srcdir/lib/completions/kpdf.exp"
assert_source_completions kpdf
4 changes: 1 addition & 3 deletions test/completion/vi.exp
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
assert_xspec_completion_installed vi

source "$::srcdir/lib/completions/vi.exp"
assert_source_completions vi
15 changes: 0 additions & 15 deletions test/lib/library.exp
Original file line number Diff line number Diff line change
Expand Up @@ -602,21 +602,6 @@ proc assert_source_completions {command {file ""}} {
}


# Assert that a _filedir_xspec completion is installed for specified command
# @param string $command Command to check completion installation for.
proc assert_xspec_completion_installed {command} {
set test "Completion via _filedir_xspec() should be installed"
set cmd "complete -p $command"
send "$cmd\r"

set expected "^$cmd\r\ncomplete -F _filedir_xspec $command\r\n/@$"
expect {
-re $expected { pass "$test" }
-re /@ { fail "$test at prompt" }
}
}


# Sort list.
# `exec sort' is used instead of `lsort' to achieve exactly the
# same sort order as in bash.
Expand Down

0 comments on commit e6781be

Please sign in to comment.