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

Re: incorrect setopt completion



On Sat, Aug 15, 2015 at 2:05 AM, Vincent Lefevre <vincent@xxxxxxxxxx> wrote:
> With zsh 5.0.8, I have:
>
> zira:~> setopt | grep print
> printexitvalue
>
> "setopt nopri[TAB]" and "unsetopt pri[TAB]" don't give any completion.
> However "setopt pri[TAB]" has printexitvalue among its completions.
> This should be the opposite!

The completion system takes care to store a backup of $options before
setting $_comp_options, however, the C code does this when calling any
sh function:

    opts[PRINTEXITVALUE] = 0;

So, I guess _setopt will just have to always complete printexitvalues
both ways around.

% setopt | grep 'combiningchars\|printexitvalue'
combiningchars
printexitvalue

% source =(echo 'setopt | grep ''combiningchars\|printexitvalue''')
combiningchars
printexitvalue

% () setopt | grep 'combiningchars\|printexitvalue'
combiningchars

If anyone is very bored, they could make a separate variable that gets
checked instead of / in addition to isset(PRINTEXITVALUE) in relevant
places, and leave the value of the option alone, but for now I'll just
do this.

diff --git i/Completion/Zsh/Command/_setopt w/Completion/Zsh/Command/_setopt
index fb38d1d..86c0965 100644
--- i/Completion/Zsh/Command/_setopt
+++ w/Completion/Zsh/Command/_setopt
@@ -2,8 +2,9 @@

 local expl ret=1
 local -a onopts offopts
-onopts=( ${(k)_comp_caller_options[(R)on]} )
-offopts=( ${(k)_comp_caller_options[(R)off]} )
+onopts=( ${(k)_comp_caller_options[(R)on]} printexitvalue )
+offopts=( ${(k)_comp_caller_options[(R)off]} printexitvalue )
+typeset -U onopts offopts
 case $service in
   setopt) onopts=(no$onopts) ;;
   unsetopt) offopts=(no$offopts) ;;


-- 
Mikael Magnusson



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