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

Re: _arguments: normal arg spec with empty action



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