Delay setting compopt -o filenames
...until just before query completion. It is not desired for commands and options completion and is better used selectively only when really needed.
This commit is contained in:
parent
34dbe3b3a8
commit
0f8c01f033
@ -15,13 +15,12 @@ _hledger_completion_function() {
|
|||||||
# Current treatment for special characters:
|
# Current treatment for special characters:
|
||||||
# - exclude colon (:) from COMP_WORDBREAKS
|
# - exclude colon (:) from COMP_WORDBREAKS
|
||||||
# - option processing assumes that `=` is in COMP_WORDBREAKS
|
# - option processing assumes that `=` is in COMP_WORDBREAKS
|
||||||
# - use compopt -o filenames to escape the rest
|
# - use compopt -o filenames selectively to escape the rest
|
||||||
COMP_WORDBREAKS=${COMP_WORDBREAKS//:}
|
COMP_WORDBREAKS=${COMP_WORDBREAKS//:}
|
||||||
case $COMP_WORDBREAKS in
|
case $COMP_WORDBREAKS in
|
||||||
*=*) : ;;
|
*=*) : ;;
|
||||||
*) COMP_WORDBREAKS=$COMP_WORDBREAKS= ;;
|
*) COMP_WORDBREAKS=$COMP_WORDBREAKS= ;;
|
||||||
esac
|
esac
|
||||||
compopt -o filenames
|
|
||||||
|
|
||||||
local subcommand
|
local subcommand
|
||||||
local i
|
local i
|
||||||
@ -36,7 +35,6 @@ _hledger_completion_function() {
|
|||||||
# $subcommand == bal --> balance, balancesheet, balancesheetequity, etc.
|
# $subcommand == bal --> balance, balancesheet, balancesheetequity, etc.
|
||||||
# Do not ignore them!
|
# Do not ignore them!
|
||||||
if ((i == cword)); then
|
if ((i == cword)); then
|
||||||
compopt +o filenames
|
|
||||||
_hledger_compreply "$(
|
_hledger_compreply "$(
|
||||||
_hledger_compgen "$_hledger_complist_commands"
|
_hledger_compgen "$_hledger_complist_commands"
|
||||||
)"
|
)"
|
||||||
@ -49,7 +47,6 @@ _hledger_completion_function() {
|
|||||||
_hledger_compreply_optarg && return
|
_hledger_compreply_optarg && return
|
||||||
|
|
||||||
if [[ -z $subcommand ]]; then
|
if [[ -z $subcommand ]]; then
|
||||||
compopt +o filenames
|
|
||||||
if [[ $cur == -* ]]; then
|
if [[ $cur == -* ]]; then
|
||||||
_hledger_compreply "$(
|
_hledger_compreply "$(
|
||||||
_hledger_compgen "$_hledger_complist_generic_options"
|
_hledger_compgen "$_hledger_complist_generic_options"
|
||||||
@ -73,11 +70,14 @@ _hledger_completion_function() {
|
|||||||
|
|
||||||
# Suspend space on completion of long options requiring an argument
|
# Suspend space on completion of long options requiring an argument
|
||||||
[[ ${COMPREPLY[0]} == --*= ]] && compopt -o nospace
|
[[ ${COMPREPLY[0]} == --*= ]] && compopt -o nospace
|
||||||
compopt +o filenames
|
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Set this from here on because queries tend to have lots of special chars
|
||||||
|
# TODO: better handling of special characters
|
||||||
|
compopt -o filenames
|
||||||
|
|
||||||
# Query completion
|
# Query completion
|
||||||
_hledger_compreply_query && return
|
_hledger_compreply_query && return
|
||||||
|
|
||||||
@ -224,12 +224,13 @@ _hledger_compreply_optarg() {
|
|||||||
|
|
||||||
case ${words[optionIndex]} in
|
case ${words[optionIndex]} in
|
||||||
--alias)
|
--alias)
|
||||||
compopt -o nospace
|
compopt -o nospace -o filenames
|
||||||
_hledger_compreply "$(
|
_hledger_compreply "$(
|
||||||
_hledger_compgen "$(_hledger accounts --flat)" "" "$match"
|
_hledger_compgen "$(_hledger accounts --flat)" "" "$match"
|
||||||
)"
|
)"
|
||||||
;;
|
;;
|
||||||
-f|--file|--rules-file|-o|--output-file)
|
-f|--file|--rules-file|-o|--output-file)
|
||||||
|
compopt -o filenames
|
||||||
_hledger_compreply "$(compgen -f -- "$match")"
|
_hledger_compreply "$(compgen -f -- "$match")"
|
||||||
;;
|
;;
|
||||||
--pivot)
|
--pivot)
|
||||||
@ -259,7 +260,7 @@ _hledger_compreply_optarg() {
|
|||||||
_hledger_compreply "$(compgen -W "$wordlist" -- "$match")"
|
_hledger_compreply "$(compgen -W "$wordlist" -- "$match")"
|
||||||
;;
|
;;
|
||||||
--close-acct|--open-acct)
|
--close-acct|--open-acct)
|
||||||
compopt -o nospace
|
compopt -o nospace -o filenames
|
||||||
_hledger_compreply "$(
|
_hledger_compreply "$(
|
||||||
_hledger_compgen "$(_hledger accounts --flat)" "" "$match"
|
_hledger_compgen "$(_hledger accounts --flat)" "" "$match"
|
||||||
)"
|
)"
|
||||||
|
|||||||
@ -15,13 +15,12 @@ _hledger_completion_function() {
|
|||||||
# Current treatment for special characters:
|
# Current treatment for special characters:
|
||||||
# - exclude colon (:) from COMP_WORDBREAKS
|
# - exclude colon (:) from COMP_WORDBREAKS
|
||||||
# - option processing assumes that `=` is in COMP_WORDBREAKS
|
# - option processing assumes that `=` is in COMP_WORDBREAKS
|
||||||
# - use compopt -o filenames to escape the rest
|
# - use compopt -o filenames selectively to escape the rest
|
||||||
COMP_WORDBREAKS=${COMP_WORDBREAKS//:}
|
COMP_WORDBREAKS=${COMP_WORDBREAKS//:}
|
||||||
case $COMP_WORDBREAKS in
|
case $COMP_WORDBREAKS in
|
||||||
*=*) : ;;
|
*=*) : ;;
|
||||||
*) COMP_WORDBREAKS=$COMP_WORDBREAKS= ;;
|
*) COMP_WORDBREAKS=$COMP_WORDBREAKS= ;;
|
||||||
esac
|
esac
|
||||||
compopt -o filenames
|
|
||||||
|
|
||||||
local subcommand
|
local subcommand
|
||||||
local i
|
local i
|
||||||
@ -36,7 +35,6 @@ _hledger_completion_function() {
|
|||||||
# $subcommand == bal --> balance, balancesheet, balancesheetequity, etc.
|
# $subcommand == bal --> balance, balancesheet, balancesheetequity, etc.
|
||||||
# Do not ignore them!
|
# Do not ignore them!
|
||||||
if ((i == cword)); then
|
if ((i == cword)); then
|
||||||
compopt +o filenames
|
|
||||||
_hledger_compreply "$(
|
_hledger_compreply "$(
|
||||||
_hledger_compgen "$_hledger_complist_commands"
|
_hledger_compgen "$_hledger_complist_commands"
|
||||||
)"
|
)"
|
||||||
@ -49,7 +47,6 @@ _hledger_completion_function() {
|
|||||||
_hledger_compreply_optarg && return
|
_hledger_compreply_optarg && return
|
||||||
|
|
||||||
if [[ -z $subcommand ]]; then
|
if [[ -z $subcommand ]]; then
|
||||||
compopt +o filenames
|
|
||||||
if [[ $cur == -* ]]; then
|
if [[ $cur == -* ]]; then
|
||||||
_hledger_compreply "$(
|
_hledger_compreply "$(
|
||||||
_hledger_compgen "$_hledger_complist_generic_options"
|
_hledger_compgen "$_hledger_complist_generic_options"
|
||||||
@ -73,11 +70,14 @@ _hledger_completion_function() {
|
|||||||
|
|
||||||
# Suspend space on completion of long options requiring an argument
|
# Suspend space on completion of long options requiring an argument
|
||||||
[[ ${COMPREPLY[0]} == --*= ]] && compopt -o nospace
|
[[ ${COMPREPLY[0]} == --*= ]] && compopt -o nospace
|
||||||
compopt +o filenames
|
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Set this from here on because queries tend to have lots of special chars
|
||||||
|
# TODO: better handling of special characters
|
||||||
|
compopt -o filenames
|
||||||
|
|
||||||
# Query completion
|
# Query completion
|
||||||
_hledger_compreply_query && return
|
_hledger_compreply_query && return
|
||||||
|
|
||||||
@ -224,12 +224,13 @@ _hledger_compreply_optarg() {
|
|||||||
|
|
||||||
case ${words[optionIndex]} in
|
case ${words[optionIndex]} in
|
||||||
--alias)
|
--alias)
|
||||||
compopt -o nospace
|
compopt -o nospace -o filenames
|
||||||
_hledger_compreply "$(
|
_hledger_compreply "$(
|
||||||
_hledger_compgen "$(_hledger accounts --flat)" "" "$match"
|
_hledger_compgen "$(_hledger accounts --flat)" "" "$match"
|
||||||
)"
|
)"
|
||||||
;;
|
;;
|
||||||
-f|--file|--rules-file|-o|--output-file)
|
-f|--file|--rules-file|-o|--output-file)
|
||||||
|
compopt -o filenames
|
||||||
_hledger_compreply "$(compgen -f -- "$match")"
|
_hledger_compreply "$(compgen -f -- "$match")"
|
||||||
;;
|
;;
|
||||||
--pivot)
|
--pivot)
|
||||||
@ -259,7 +260,7 @@ _hledger_compreply_optarg() {
|
|||||||
_hledger_compreply "$(compgen -W "$wordlist" -- "$match")"
|
_hledger_compreply "$(compgen -W "$wordlist" -- "$match")"
|
||||||
;;
|
;;
|
||||||
--close-acct|--open-acct)
|
--close-acct|--open-acct)
|
||||||
compopt -o nospace
|
compopt -o nospace -o filenames
|
||||||
_hledger_compreply "$(
|
_hledger_compreply "$(
|
||||||
_hledger_compgen "$(_hledger accounts --flat)" "" "$match"
|
_hledger_compgen "$(_hledger accounts --flat)" "" "$match"
|
||||||
)"
|
)"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user