Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] add and use _comp_original_options



I noticed while looking at my sketchy parameter flags patch that the
"Look for glob qualifiers" below the first hunk in _path_files had [[
-o extendedglob ]] in it to only complete globflags then, but completion
code always has extendedglob set. I came up with this to work around it,
I think I caught all the places where an option overriden in _comp_options
is checked for, ie I grepped for '-o [a-z]'. Is it safe to use $options,
or do I have to check if the parameters module is available?

---
 Completion/Base/Completer/_expand    |    2 +-
 Completion/Unix/Type/_have_glob_qual |    4 ++--
 Completion/Unix/Type/_path_files     |    2 +-
 Completion/compinit                  |    4 +++-
 4 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/Completion/Base/Completer/_expand b/Completion/Base/Completer/_expand
index 89cc969..7f56cbc 100644
--- a/Completion/Base/Completer/_expand
+++ b/Completion/Base/Completer/_expand
@@ -70,7 +70,7 @@ if [[ "$force" = *s* ]] ||
 ###  parameter expressions such as ${foo} be expanded like brace
 ###  expansions, too (and with braceccl set...).
 
-   if [[ ! -o ignorebraces && "${#${exp}//[^\{]}" = "${#${exp}//[^\}]}" ]]; then
+   if [[ ! $_comp_original_options[ignorebraces] == on && "${#${exp}//[^\{]}" = "${#${exp}//[^\}]}" ]]; then
      local otmp
 
      tmp=${(q)word}
diff --git a/Completion/Unix/Type/_have_glob_qual b/Completion/Unix/Type/_have_glob_qual
index d174406..851b1fb 100644
--- a/Completion/Unix/Type/_have_glob_qual
+++ b/Completion/Unix/Type/_have_glob_qual
@@ -16,9 +16,9 @@ local complete
 [[ $2 = complete ]] && complete=")"
 
 [[ -z $compstate[quote] &&
-  ( -o bareglobqual &&
+  ( $_comp_original_options[bareglobqual] == on &&
        $1 = (#b)(((*[^\\\$]|)(\\\\)#)\()([^\)\|\~]#)$complete &&
        ${#match[1]} -gt 1 ||
-     -o extendedglob &&
+     $_comp_original_options[extendedglob] == on &&
        $1 = (#b)(((*[^\\\$]|)(\\\\)#)"(#q")([^\)]#)$complete
     ) ]]
diff --git a/Completion/Unix/Type/_path_files b/Completion/Unix/Type/_path_files
index 34d5e8d..dc80b46 100644
--- a/Completion/Unix/Type/_path_files
+++ b/Completion/Unix/Type/_path_files
@@ -21,7 +21,7 @@ fi
 # The later test looks for an outstanding quote.
 if _have_glob_qual $PREFIX; then
    compset -p ${#match[1]}
-   if [[ -o extendedglob ]] && compset -P '\#'; then
+   if [[ $_comp_original_options[extendedglob] == on ]] && compset -P '\#'; then
      _globflags
    else
      _globquals
diff --git a/Completion/compinit b/Completion/compinit
index d3c5e28..6d3d127 100644
--- a/Completion/compinit
+++ b/Completion/compinit
@@ -160,7 +160,9 @@ _comp_options=(
 # have a valid stdin descriptor (zle closes it before calling widgets)
 # and don't get confused by user's ZERR trap handlers.
 
-typeset -g _comp_setup='setopt localoptions localtraps ${_comp_options[@]};
+typeset -g _comp_setup='local -A _comp_original_options;
+             _comp_original_options=(${(kv)options});
+             setopt localoptions localtraps ${_comp_options[@]};
              local IFS=$'\'\ \\t\\r\\n\\0\''
              exec </dev/null;
              trap - ZERR
-- 
1.7.4-rc1



Messages sorted by: Reverse Date, Date, Thread, Author