zsh-workers
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: zsh workers <zsh-workers@zsh.org>
Subject: Re: incorrect setopt completion
Date: Sat, 15 Aug 2015 03:02:45 +0200	[thread overview]
Message-ID: <CAHYJk3RqWHvn3nBWmh16GvP0BNEDrekcpkcPTHtt0AHJMfN_iQ@mail.gmail.com> (raw)
In-Reply-To: <20150815000543.GA2043@zira.vinc17.org>

On Sat, Aug 15, 2015 at 2:05 AM, Vincent Lefevre <vincent@vinc17.net> 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


  reply	other threads:[~2015-08-15  1:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-15  0:05 Vincent Lefevre
2015-08-15  1:02 ` Mikael Magnusson [this message]
2015-08-17 22:02   ` Daniel Shahaf
2015-08-15  2:09 ` Bart Schaefer
2015-08-15  2:14   ` Mikael Magnusson
2015-08-16 22:55     ` 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=CAHYJk3RqWHvn3nBWmh16GvP0BNEDrekcpkcPTHtt0AHJMfN_iQ@mail.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).