Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: completion for compilers (cc, gcc...) and -o
Vincent Lefevre wrote on Thu, 30 Apr 2020 22:54 +0200:
> Now I'm wondering whether there is a way to automatically apply
> the zstyle to the _gcc command list (I also sometimes use clang
> and so on).
This? —
zstyle -e ":completion::complete:*:option-o-1:" file-patterns '(( ${+funcstack[_gcc]} )) && reply=( … )'
---
More generally, I think it might be nice if the code evaluated by
«zstyle -e» could be told what context it's being looked up under.
Something like this:
% zstyle -e '*' foo 'echo $CONTEXT > /dev/tty'
% zstyle -s bar foo REPLY
bar
%
(though the name $CONTEXT is already taken)
> I was also wondering whether there is a way to get the extension
> list automatically from the one in _gcc (assuming that it could
> evolve[*]).
>
I don't know how likely it is to evolve, but I suppose we could drop
the list of extensions in a variable, «cc_extensions=( c h cc C cxx cpp
hpp )», then you'll be able to use «zstyle -e» to build on top of it?
> [*] On this subject, I'm quite sure I've already used the .cpp
> extension. I do not program in C++, but sometimes have to do
> some tests of small examples... I think that it should be added
> to the standard list, but C++ programmers may tell you more.
Sure. This? —
diff --git a/Completion/Unix/Command/_gcc b/Completion/Unix/Command/_gcc
index 9ec09200e..20b3abe59 100644
--- a/Completion/Unix/Command/_gcc
+++ b/Completion/Unix/Command/_gcc
@@ -390,7 +390,7 @@ languages=(
# generic options (from --help)
args+=(
'-###[print commands to run this compilation]'
- '-o:output file:_files -g "^*.(c|h|cc|C|cxx)(-.)"'
+ '-o:output file:_files -g "^*.(c|h|cc|C|cxx|cpp|hpp)(-.)"'
'-x[Specify the language of the following input files]:input file language:('"$languages"')'
'+e-:virtual function definitions in classes:((0\:only\ interface 1\:generate\ code))'
'-d-:dump:->dump'
@@ -1004,7 +1004,7 @@ args+=(
'--help[Display this information]'
'--no-warnings[Same as -w]'
'--optimize[Same as -O]'
- '--output[Same as -o]'
+ '--output:output file:_files -g "^*.(c|h|cc|C|cxx|cpp|hpp)(-.)"'
'--param[Set parameter <param> to value. See manpage for a complete list of parameters]:name=value'
'--verbose[Same as -v]'
'--version[Display version information]'
Cheers,
Messages sorted by:
Reverse Date,
Date,
Thread,
Author