zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: "Jun T." <takimoto-j@kba.biglobe.ne.jp>, zsh-workers@zsh.org
Subject: Re: _arguments: normal arg spec with empty action
Date: Tue, 15 Nov 2016 01:31:39 +0100	[thread overview]
Message-ID: <60847.1479169899@hydra.kiddle.eu> (raw)
In-Reply-To: <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


      reply	other threads:[~2016-11-15  0:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-18 13:35 Jun T.
2016-10-21  6:31 ` Oliver Kiddle
2016-10-21 11:12   ` Jun T.
2016-11-03 23:53 ` Oliver Kiddle
2016-11-15  0:31   ` Oliver Kiddle [this message]

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=60847.1479169899@hydra.kiddle.eu \
    --to=okiddle@yahoo.co.uk \
    --cc=takimoto-j@kba.biglobe.ne.jp \
    --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).