Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: _arguments: normal arg spec with empty action
- X-seq: zsh-workers 39945
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: "Jun T." <takimoto-j@xxxxxxxxxxxxxxxxx>, zsh-workers@xxxxxxx
- Subject: Re: _arguments: normal arg spec with empty action
- Date: Tue, 15 Nov 2016 01:31:39 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1479169900; bh=ogFoB8UtdSFhOdqVo8U6hKxlYmjC4Ns6SSBWFjb0xes=; h=In-reply-to:From:References:To:Subject:Date:From:Subject; b=FX/rSPcqifyEhjbtx+gtdZQ2THMsSHOdnT5wpphQEl+zKS6svFQ1MUIroab4iB8O8WKiFtzdEsAKXidvlahTdj+jGKbljVeq+3EETGAGFBcSlSLdj224nlKJJNnWXmGt1JV31zH7QUmjFvKzkV5cQIReS0AnyPvAFTR+xk3c/HZsdELSYzoXig0PQByTUDq/Xso4unbZ/kkuRIw3vfjF2BlqiSzkF4LmcOxVLGlGAMPDn85j4J9IqdKSS2edDBJALDnsHPh4xodh2ydd2cZL4pPqM3BJ/8PZO43oG+quJoAutromm1wgCmBnzfifb7Yz5JTaKZZYvVKX0sB+44IOxQ==
- In-reply-to: <19772.1478217190@hydra.kiddle.eu>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <81D02BE7-7F8E-4E46-B7A9-95A5C9D8DDF7@kba.biglobe.ne.jp> <19772.1478217190@hydra.kiddle.eu>
On 4 Nov, I wrote:
> This doesn't help if you don't use _oldlist because compstate[insert]
> gets cleared for every tab press. I also noticed when doing testing
> that with the BASH_AUTO_LIST option you never get anything useful
> at all for functions that clear compstate[insert]. I'm surprised we
> haven't had complaints about that:
This further patch covers these cases. There's many combinations of
options and zstyles that might affect this. So to test with your
configuration try repeated presses of <tab> for the following completion
definition:
compdef '_arguments --ab --ac :arg:' foo
The first case is handled by making _message only clear
compstate[insert] if the current value contains unambiguous. This makes
sense for _message -e style messages because all we want to do is
prevent the insertion of unambiguous characters (other characters may be
relevant to the group indicated by the message). menu completion
is not really a problem because it is inserting more characters than the
unambiguous ones by definition.
For BASH_AUTO_LIST, setting lastambig seems appropriate. It causes
subsequent invocations of completion to set bashautolist. So first tab
does nothing, second lists, third does menu completion if AUTO_MENU is
set.
Test cases have gone in Y03arguments because _arguments is the easiest
way to test this but it doesn't really have much to do with _arguments.
It's more about _message.
Oliver
diff --git a/Completion/Base/Core/_message b/Completion/Base/Core/_message
index 13c8398..4d5645e 100644
--- a/Completion/Base/Core/_message
+++ b/Completion/Base/Core/_message
@@ -18,7 +18,8 @@ if [[ "$1" = -e ]]; then
ret=0
done
- (( $compstate[nmatches] )) || compstate[insert]=
+ (( ! $compstate[nmatches] )) && [[ $compstate[insert] = *unambiguous* ]] &&
+ compstate[insert]=
return ret
fi
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index 536bca7..d1cf7a0 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -425,6 +425,7 @@ do_completion(UNUSED(Hookdef dummy), Compldat dat)
}
} else {
invalidatelist();
+ lastambig = isset(BASHAUTOLIST);
if (forcelist)
clearlist = 1;
zlemetacs = 0;
diff --git a/Test/Y03arguments.ztst b/Test/Y03arguments.ztst
index 3ada168..0763c41 100644
--- a/Test/Y03arguments.ztst
+++ b/Test/Y03arguments.ztst
@@ -243,6 +243,67 @@
>NO:{-a}
>NO:{-b}
+ tst_arguments --abc --aah :arg:
+ comptesteval 'setopt bashautolist automenu'
+ comptest $'tst --a\t\t\t'
+0:with message and bashautolist, a third tab will get menu completion
+>line: {tst --a}{}
+>line: {tst --a}{}
+>DESCRIPTION:{arg}
+>DESCRIPTION:{option}
+>NO:{--aah}
+>NO:{--abc}
+>line: {tst --aah}{}
+
+ tst_arguments --abc --aah :arg:
+ comptesteval 'setopt bashautolist noautomenu'
+ comptest $'tst --a\t\t\t'
+0:with message and bashautolist, a third tab is needed to display the list
+>line: {tst --a}{}
+>line: {tst --a}{}
+>DESCRIPTION:{arg}
+>DESCRIPTION:{option}
+>NO:{--aah}
+>NO:{--abc}
+>line: {tst --a}{}
+
+ tst_arguments --abc --aah :arg:
+ comptesteval 'setopt nobashautolist noautomenu'
+ comptest $'tst --\t\t'
+0:with message and noautomenu second tab redisplays the list
+>line: {tst --}{}
+>DESCRIPTION:{arg}
+>DESCRIPTION:{option}
+>NO:{--aah}
+>NO:{--abc}
+>line: {tst --}{}
+>DESCRIPTION:{arg}
+>DESCRIPTION:{option}
+>NO:{--aah}
+>NO:{--abc}
+
+ tst_arguments --abc --aah :arg:
+ comptesteval 'setopt nobashautolist automenu'
+ comptest $'tst --\t\t'
+0:with message two tabs will start menu completion
+>line: {tst --}{}
+>DESCRIPTION:{arg}
+>DESCRIPTION:{option}
+>NO:{--aah}
+>NO:{--abc}
+>line: {tst --aah}{}
+
+ tst_arguments --abc --aah :arg:
+ comptesteval 'zstyle ":completion:*::::" completer _oldlist _complete'
+ comptest $'tst --\t\t'
+0:with message and _oldlist, two tabs will start menu completion
+>line: {tst --}{}
+>DESCRIPTION:{arg}
+>DESCRIPTION:{option}
+>NO:{--aah}
+>NO:{--abc}
+>line: {tst --aah}{}
+
%clean
zmodload -ui zsh/zpty
Messages sorted by:
Reverse Date,
Date,
Thread,
Author