Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: expansion of custom abbreviations in configure (autoconf) completion
"Daniel Shahaf" wrote:
> I have a local command that lets me do
> .
> ,build zsh [BUILD_PROFILE] [SRCDIR]
I quite like the flexibility that comes from not using a wrapper, but
can see that may be a convenient approach.
> Yet another approach would be to use global aliases, for instance,
> .
> alias -g ,,asan='CFLAGS="-fsanitize=address -fno-omit-frame-pointer" LDFLAGS="-fsanitize=address"'
In this particular case, I find the full expansion useful because I
sometimes want to make further edits. Global aliases fit different use
cases where you'd want history to contain unexpanded values. In the
past, I had some normal aliases for this (including the ./configure) but
would nearly always invoke a zle widget to expand the alias.
> P.S. Speaking of global aliases, why doesn't «alias -g bar=42» followed
> by «foo ba<TAB>» offer «bar»?
Probably because that would be really annoying. You'd complete them
everywhere. A completer that does little more than compadd -k galiases
would be enough to implement that if you want it. Taking it to extremes,
we could complete all redirection operators anywhere they can be applied
(which is nearly everywhere). With the recent _phony addition, I
pondered whether the `-` for standard input/output should be completed
for commands like cat and tar and concluded that that would be more
annoying than useful.
I attach a patch consisting just of the handling for variables after
configure without any of the snippet stuff.
Thanks
Oliver
diff --git a/_configure b/_configure
index 3b22b53db..460144ac3 100644
--- a/_configure
+++ b/_configure
@@ -1,6 +1,11 @@
#compdef configure config.status
-_arguments -- -i '(--(disable|enable)-FEATURE* --(with|without)-PACKAGE*)' \
+local ret=1
+local -a expl suf
+
+[[ -prefix - ]] ||
+ ! zstyle -T ":completion:${curcontext}:options" prefix-needed &&
+ _arguments -- -i '(--(disable|enable)-FEATURE* --(with|without)-PACKAGE*)' \
-s '((#s)--disable- --enable-
(#s)--enable- --disable-
(#s)--with- --without-
@@ -8,4 +13,19 @@ _arguments -- -i '(--(disable|enable)-FEATURE* --(with|without)-PACKAGE*)' \
'*=(E|)PREFIX*:prefix directory:_files -/' \
'*=PROGRAM*:program:_command_names -e' \
'*=NAME*executable*:program:_command_names -e' \
- '*=NAME*:file:_files'
+ '*=NAME*:file:_files' && ret=0
+
+if [[ ! -prefix - ]]; then
+ if [[ "$PREFIX" = *\=* ]]; then
+ compstate[parameter]="${PREFIX%%\=*}"
+ compset -P 1 '*='
+ _value && ret=0
+ else
+ compset -S '=*' || suf=( -S = )
+ _wanted -x variables expl variable compadd $suf \
+ CC CFLAGS CPP CPPFLAGS CXX CXXFLAGS DEFS ERLCFLAGS FCFLAGS \
+ FFLAGS GOFLAGS LDFLAGS LIBS OBJCFLAGS OBJCXXFLAGS && ret=0
+ fi
+fi
+
+return ret
diff --git a/_gcc b/_gcc
index 1f05edb73..3c7db6beb 100644
--- a/_gcc
+++ b/_gcc
@@ -1,10 +1,18 @@
-#compdef gcc g++ cc c++ llvm-gcc llvm-g++ clang clang++ -value-,LDFLAGS,-default- -value-,CFLAGS,-default- -value-,CXXFLAGS,-default- -value-,CPPFLAGS,-default- -P gcc-* -P g++-* -P c++-*
+#compdef gcc g++ cc c++ llvm-gcc llvm-g++ clang clang++ -value-,LDFLAGS,-default- -value-,CFLAGS,-default- -value-,CXXFLAGS,-default- -value-,CPPFLAGS,-default- -value-,CC,-default- -value-,CXX,-default- -P gcc-* -P g++-* -P c++-*
local curcontext="$curcontext" state line ret=1 expl i
local -a args args2 warnings arch
typeset -A opt_args
-if [[ "$service" = -value-* ]]; then
+if [[ "$service" = -value-,CC,* ]]; then
+ _description compilers expl compiler
+ compadd "$expl[@]" -M 'r:|-=* r:|=*' -k 'commands[(I)(clang|([ig]|sun|open)cc(|<->|-devel)|icx)]'
+ return
+elif [[ "$service" = -value-,CXX,* ]]; then
+ _description compilers expl compiler
+ compadd "$expl[@]" -M 'r:|-=* r:|=*' -k 'commands[(I)((clang|g)++(|<->|-devel)|(sun|open|)CC|icpx)]'
+ return
+elif [[ "$service" = -value-* ]]; then
compset -q
words=( fake "$words[@]" )
(( CURRENT++ ))
Messages sorted by:
Reverse Date,
Date,
Thread,
Author