zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: "Jun T." <takimoto-j@kba.biglobe.ne.jp>
Cc: zsh-workers@zsh.org
Subject: Re: _arguments: normal arg spec with empty action
Date: Fri, 04 Nov 2016 00:53:10 +0100	[thread overview]
Message-ID: <19772.1478217190@hydra.kiddle.eu> (raw)
In-Reply-To: <81D02BE7-7F8E-4E46-B7A9-95A5C9D8DDF7@kba.biglobe.ne.jp>

On 18 Oct, "Jun T." wrote:
> If I type
>
> zsh% awk -<TAB>
>
> then it shows the list of options (-F -f -v), as expected.
> But if I hit <TAB> again, it does not cycle through the options.
>
> It seems this is caused by the empty action in the spec:
> 	'1:program text:'

I took a closer look at this. The reason I couldn't reproduce it
is that I use _oldlist in my list of completers. Still, I need a
third tab to get menu completion which didn't seem right. Normally,
a first tab will insert an unambiguous prefix, the second does the
list and the third goes to menu completion. An empty action spec
such as that above results in _message doing compstate[insert]=''.
This forces listing and ensures that nothing is inserted so that
the user can see that "program text" is a valid thing to insert at
this point. So the first tab does the listing, the second still
won't insert any unambiguous prefix but completion does record that
that stage is done so the third will start menu completion.

This patch adds some logic so that when compstate[insert] is found
to be empty, and AUTO_MENU is set, it knows that it can consider
the unambiguous insert bit done.

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:
  zsh -f
  autoload -U compinit; compinit
  setopt bash_auto_list
  grep -<tab><tab><tab><tab><tab>

Oliver

diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index 5443018..d7fbea5 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -835,6 +835,7 @@ callcompfunc(char *s, char *fn)
 	endparamscope();
 	lastcmd = 0;
 	incompfunc = icf;
+	startauto = 0;
 
 	if (!complist)
 	    uselist = 0;
@@ -882,8 +883,13 @@ callcompfunc(char *s, char *fn)
 		useline = 1, usemenu = 1;
 	    else if (strpfx("auto", compinsert))
 		useline = 1, usemenu = 2;
-	    else
+	    else {
 		useline = usemenu = 0;
+		/* if compstate[insert] was emptied, no unambiguous prefix
+		 * ever gets inserted so allow the next tab to already start
+		 * menu completion */
+		startauto = lastambig = isset(AUTOMENU);
+	    }
 
 	    if (useline && (p = strchr(compinsert, ':'))) {
 		insmnum = atoi(++p);
@@ -896,7 +902,7 @@ callcompfunc(char *s, char *fn)
 #endif
 	    }
 	}
-	startauto = ((compinsert &&
+	startauto = startauto || ((compinsert &&
 		      !strcmp(compinsert, "automenu-unambiguous")) ||
 		     (bashlistfirst && isset(AUTOMENU) &&
                       (!compinsert || !*compinsert)));


  parent reply	other threads:[~2016-11-03 23:59 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 [this message]
2016-11-15  0:31   ` Oliver Kiddle

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=19772.1478217190@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).