* [PATCH] add and use _comp_original_options
@ 2011-05-27 1:20 Mikael Magnusson
2011-05-27 4:27 ` Bart Schaefer
0 siblings, 1 reply; 3+ messages in thread
From: Mikael Magnusson @ 2011-05-27 1:20 UTC (permalink / raw)
To: zsh-workers
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] add and use _comp_original_options
2011-05-27 1:20 [PATCH] add and use _comp_original_options Mikael Magnusson
@ 2011-05-27 4:27 ` Bart Schaefer
2011-05-27 14:37 ` Mikael Magnusson
0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2011-05-27 4:27 UTC (permalink / raw)
To: zsh-workers
On May 27, 3:20am, Mikael Magnusson wrote:
}
} ... completion code always has extendedglob set. I came up with this
} to work around it,
This seems quite reasonable. Just for pedantry I think I'd have named
the variable "_comp_caller_options" but it hardly matters.
} Is it safe to use $options, or do I have to check if the parameters
} module is available?
If zsh/parameter is available, referencing $options will autoload it,
so it's safe in that sense, but if the module is not available there's
nothing to guarantee that it has a sensible value.
On the other hand several completions rely on $commands springing into
existence when referenced, or do "compadd -k builtins", so ...
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] add and use _comp_original_options
2011-05-27 4:27 ` Bart Schaefer
@ 2011-05-27 14:37 ` Mikael Magnusson
0 siblings, 0 replies; 3+ messages in thread
From: Mikael Magnusson @ 2011-05-27 14:37 UTC (permalink / raw)
To: Bart Schaefer; +Cc: zsh-workers
On 27 May 2011 06:27, Bart Schaefer <schaefer@brasslantern.com> wrote:
> On May 27, 3:20am, Mikael Magnusson wrote:
> }
> } ... completion code always has extendedglob set. I came up with this
> } to work around it,
>
> This seems quite reasonable. Just for pedantry I think I'd have named
> the variable "_comp_caller_options" but it hardly matters.
Well, it's shorter so I changed it.
--
Mikael Magnusson
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-05-27 14:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-27 1:20 [PATCH] add and use _comp_original_options Mikael Magnusson
2011-05-27 4:27 ` Bart Schaefer
2011-05-27 14:37 ` Mikael Magnusson
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).