zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: "Jun T." <takimoto-j@kba.biglobe.ne.jp>, zsh-workers@zsh.org
Subject: Completion after assignment as command (Re: 5.0.9 eventually...?)
Date: Sun, 9 Aug 2015 17:15:34 +0100	[thread overview]
Message-ID: <20150809171534.5bbe4f10@ntlworld.com> (raw)
In-Reply-To: <F4297B2B-399C-457F-9B24-471D9A3B965A@kba.biglobe.ne.jp>

On Sun, 9 Aug 2015 23:45:00 +0900
"Jun T." <takimoto-j@kba.biglobe.ne.jp> wrote:
> 35852 ? Do you mean this?
> 
> Subject: Completion bug after assignment,unset
> >    zsh -f
> >    autoload compinit && compinit
> >    RPS2=$PS2; unset PS2 ; setopt <TAB>
> > 
> > completes files rather than options.
> 
> In my case it completes commands (not files), while
> % a=b; setopt <TAB>
> completes files.
>...
> I can't understand how get_comp_string() works, of course...

No one does, which is why it was changed in the slightly fudged way it
was to minimise the overall effect instead of to fix the probalem
outright.

The following improves things without any obvious side effect, maybe ---
I only just noticed the !incond thing at the last minute, which would
otherwise have screwed up completion in conditions which might have
taken a while to notice.  Note I've remvoed some unnecessary parentheses
just as a very small concession to clartiy.

I don't understand the SEPER / ins handling except to the limited extent
I've noted in previous tortuous and frustrated comments.  Any problems
with this?  Anyone any idea how to add a test for it?

pws

diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c
index 3bf8d45..b87b99b 100644
--- a/Src/Zle/zle_tricky.c
+++ b/Src/Zle/zle_tricky.c
@@ -1175,9 +1175,19 @@ get_comp_string(void)
     do {
         qsub = noword = 0;
 
-	lincmd = ((incmdpos && !ins && !incond) ||
-		  (oins == 2 && wordpos == 2) ||
-		  (ins == 3 && wordpos == 1));
+	/*
+	 * pws: added cmdtok == NULLTOK test as fallback for detecting
+	 * we haven't had a command yet.  This is a cop out: it's needed
+	 * after SEPER because of bizarre and incomprehensible dance
+	 * that we otherwise do involving the "ins" flag when you might
+	 * have thought we'd just reset everything because we're now
+	 * considering a new command.  Consequently, although this looks
+	 * relatively harmless by itself, it's probably incomplete.
+	 */
+	lincmd = (incmdpos && !ins && !incond) ||
+	    (oins == 2 && wordpos == 2) ||
+	    (ins == 3 && wordpos == 1) ||
+	    (cmdtok == NULLTOK && !incond);
 	linredir = (inredir && !ins);
 	oins = ins;
 	/* Get the next token. */


  reply	other threads:[~2015-08-09 16:15 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-08 19:05 5.0.9 eventually...? Peter Stephenson
2015-08-08 20:40 ` Bart Schaefer
2015-08-08 20:50   ` Mikael Magnusson
2015-08-09  0:20     ` Bart Schaefer
2015-08-08 21:22 ` Oliver Kiddle
2015-08-09  0:23   ` Bart Schaefer
2015-08-09  0:24     ` Bart Schaefer
2015-08-09 14:45       ` Jun T.
2015-08-09 16:15         ` Peter Stephenson [this message]
2015-08-10  7:12 ` Ismail Donmez
2015-08-10  9:59   ` Ismail Donmez
2015-08-10 12:50   ` Wait test failure Peter Stephenson
2015-08-10 15:18     ` Peter Stephenson
2015-08-10 15:48       ` Peter Stephenson
2015-08-10 17:44         ` Bart Schaefer
2015-08-10 19:11           ` Peter Stephenson
2015-08-10 17:24   ` A05 test failure (was Re: 5.0.9 eventually...?) Bart Schaefer
2015-08-11  8:20     ` Ismail Donmez
2015-08-17 19:54 ` 5.0.9 eventually...? Peter Stephenson
2015-08-17 20:08   ` Bart Schaefer
2015-08-17 21:17   ` Mikael Magnusson

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=20150809171534.5bbe4f10@ntlworld.com \
    --to=p.w.stephenson@ntlworld.com \
    --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).