zsh-workers
 help / color / mirror / code / Atom feed
* incorrect setopt completion
@ 2015-08-15  0:05 Vincent Lefevre
  2015-08-15  1:02 ` Mikael Magnusson
  2015-08-15  2:09 ` Bart Schaefer
  0 siblings, 2 replies; 6+ messages in thread
From: Vincent Lefevre @ 2015-08-15  0:05 UTC (permalink / raw)
  To: zsh-workers

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!

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: incorrect setopt completion
  2015-08-15  0:05 incorrect setopt completion Vincent Lefevre
@ 2015-08-15  1:02 ` Mikael Magnusson
  2015-08-17 22:02   ` Daniel Shahaf
  2015-08-15  2:09 ` Bart Schaefer
  1 sibling, 1 reply; 6+ messages in thread
From: Mikael Magnusson @ 2015-08-15  1:02 UTC (permalink / raw)
  To: zsh workers

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: incorrect setopt completion
  2015-08-15  0:05 incorrect setopt completion Vincent Lefevre
  2015-08-15  1:02 ` Mikael Magnusson
@ 2015-08-15  2:09 ` Bart Schaefer
  2015-08-15  2:14   ` Mikael Magnusson
  1 sibling, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 2015-08-15  2:09 UTC (permalink / raw)
  To: zsh-workers

On Aug 15,  2:05am, Vincent Lefevre wrote:
}
} 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!

Hm.

_main_complete is saving the state of the options as early as it can,
but XTRACE, PRINTEXITVALUE, LOCALOPTIONS, and LOCALLOOPS are all subject
to being saved/restored during the execution of shell functions, which
of course means the entirety of compsys.

There's no way to fix this from shell script code.  The state of the
options will have to be stashed somewhere at the C code level before
completion functions are entered, if we want this to work.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: incorrect setopt completion
  2015-08-15  2:09 ` Bart Schaefer
@ 2015-08-15  2:14   ` Mikael Magnusson
  2015-08-16 22:55     ` Mikael Magnusson
  0 siblings, 1 reply; 6+ messages in thread
From: Mikael Magnusson @ 2015-08-15  2:14 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh workers

On Sat, Aug 15, 2015 at 4:09 AM, Bart Schaefer
<schaefer@brasslantern.com> wrote:
> On Aug 15,  2:05am, Vincent Lefevre wrote:
> }
> } 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!
>
> Hm.
>
> _main_complete is saving the state of the options as early as it can,
> but XTRACE, PRINTEXITVALUE, LOCALOPTIONS, and LOCALLOOPS are all subject
> to being saved/restored during the execution of shell functions, which
> of course means the entirety of compsys.
>
> There's no way to fix this from shell script code.  The state of the
> options will have to be stashed somewhere at the C code level before
> completion functions are entered, if we want this to work.

I guess I should amend my patch to include all four of these.

-- 
Mikael Magnusson


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: incorrect setopt completion
  2015-08-15  2:14   ` Mikael Magnusson
@ 2015-08-16 22:55     ` Mikael Magnusson
  0 siblings, 0 replies; 6+ messages in thread
From: Mikael Magnusson @ 2015-08-16 22:55 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh workers

On Sat, Aug 15, 2015 at 4:14 AM, Mikael Magnusson <mikachu@gmail.com> wrote:
> On Sat, Aug 15, 2015 at 4:09 AM, Bart Schaefer
> <schaefer@brasslantern.com> wrote:
>> On Aug 15,  2:05am, Vincent Lefevre wrote:
>> }
>> } 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!
>>
>> Hm.
>>
>> _main_complete is saving the state of the options as early as it can,
>> but XTRACE, PRINTEXITVALUE, LOCALOPTIONS, and LOCALLOOPS are all subject
>> to being saved/restored during the execution of shell functions, which
>> of course means the entirety of compsys.
>>
>> There's no way to fix this from shell script code.  The state of the
>> options will have to be stashed somewhere at the C code level before
>> completion functions are entered, if we want this to work.
>
> I guess I should amend my patch to include all four of these.

Actually I just tried this, and all of the other three complete
correctly in an interactive shell for me, so I'll leave it as just
printexitvalue.

-- 
Mikael Magnusson


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: incorrect setopt completion
  2015-08-15  1:02 ` Mikael Magnusson
@ 2015-08-17 22:02   ` Daniel Shahaf
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Shahaf @ 2015-08-17 22:02 UTC (permalink / raw)
  To: zsh-workers

Mikael Magnusson wrote on Sat, Aug 15, 2015 at 03:02:45 +0200:
> 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.

I think my PRINT_EXIT_VALUE branch (discussed in another thread) does
this:

https://github.com/danielshahaf/zsh/commit/ba8c0a1afd5c000cbb86aa988e85bd8ba7cf99ff

> -onopts=( ${(k)_comp_caller_options[(R)on]} )
> +onopts=( ${(k)_comp_caller_options[(R)on]} printexitvalue )

I suggest a comment explaining why printexitvalue is special-cased.  (So
people don't have to run 'git blame' and then search the list archives.)


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-08-17 22:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-15  0:05 incorrect setopt completion Vincent Lefevre
2015-08-15  1:02 ` Mikael Magnusson
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

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).