From: Mikael Magnusson <mikachu@gmail.com>
To: zsh-workers@zsh.org
Subject: [PATCH] add and use _comp_original_options
Date: Fri, 27 May 2011 03:20:14 +0200 [thread overview]
Message-ID: <1306459214-17564-1-git-send-email-mikachu@gmail.com> (raw)
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
next reply other threads:[~2011-05-27 1:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-27 1:20 Mikael Magnusson [this message]
2011-05-27 4:27 ` Bart Schaefer
2011-05-27 14:37 ` Mikael Magnusson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1306459214-17564-1-git-send-email-mikachu@gmail.com \
--to=mikachu@gmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).