zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.dk
Subject: Re: zsh 4.x bug in completion?
Date: Tue, 10 Jul 2001 11:19:16 +0200 (MET DST)	[thread overview]
Message-ID: <200107100919.LAA16859@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: <1010710081054.ZM28108@candle.brasslantern.com>

Bart Schaefer wrote:

> I get very strange behavior from 4.0.2.
> 
> With
> 
> zstyle ':completion:*' completer _complete _prefix  
> 
> I get:
> 
> schaefer<503> <Ctrl-P>
> schaefer<503> echo foo<Ctrl-A>
> schaefer<503> sud<TAB>echo foo
> schaefer<503> sudoecho  foo
>                        ^
> 		       cursor here
> 
> That is, it inserts `sudo' with no trailing space, but then moves to
> the end of the word `echo' and adds a space *there*.  That is almost
> certainly wrong?
> 
> I get exactly the same thing from 4.1.0-dev-2.
> 
> If I then add
> 
> zstyle ':completion:*' add-space yes
> 
> I get `sudo echo  foo', that is, it has added a space both after `sudo'
> and after `echo'.

Hm, yes.  These were both caused by _prefix being actually a hack.  But
we can hack some more when there is a single match, to trick it into
leaving the cursor where it should be left.

And then we need that hunk in the C-code because if the user requests
that no list is shown, we should do that and not print the explanation
strings.

> And, by the way, with TAB bound to expand-or-complete-prefix, I can in
> fact reproduce the original complaint.  Auto-removing the space may make
> sense when completing in the middle of a file path, but it doesn't when
> completing in command position.

That's the hunk in zle_tricky.c.  It turns off the auto-suffix behaviour
if completion left us after a space, leaving the space if a non-space
character is typed next.  I hope this is the most sensible thing to do.


Should this and/or the _man thing go into the stable branch? (I.e., is
that to be updated until the next stable release?)


Bye
  Sven

Index: Completion/Base/Completer/_prefix
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Completer/_prefix,v
retrieving revision 1.1
diff -u -r1.1 _prefix
--- Completion/Base/Completer/_prefix	2001/04/02 11:08:54	1.1
+++ Completion/Base/Completer/_prefix	2001/07/10 09:16:04
@@ -4,7 +4,7 @@
 
 [[ _matcher_num -gt 1 || -z "$SUFFIX" ]] && return 1
 
-local comp curcontext="$curcontext" tmp \
+local comp curcontext="$curcontext" tmp suf="$SUFFIX" \
       _completer _completer_num \
       _matcher _c_matcher _matchers _matcher_num
 
@@ -44,7 +44,13 @@
       _matcher="$_c_matcher"
     fi
 
-    [[ "$tmp" != _prefix ]] && "$tmp" && return 0
+    if [[ "$tmp" != _prefix ]] && "$tmp"; then
+      [[ compstate[nmatches] -gt 1 ]] && return 0
+      compadd -U -i "$IPREFIX" -I "$ISUFFIX" - "${compstate[unambiguous]%$suf}x"
+      compstate[list]=
+      compstate[insert]=unambiguous
+      return 0
+    fi
     (( _matcher_num++ ))
   done
   (( _completer_num++ ))
Index: Src/Zle/compcore.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compcore.c,v
retrieving revision 1.45
diff -u -r1.45 compcore.c
--- Src/Zle/compcore.c	2001/02/28 09:12:57	1.45
+++ Src/Zle/compcore.c	2001/07/10 09:16:05
@@ -420,7 +420,7 @@
 	cs = origcs;
     }
     /* Print the explanation strings if needed. */
-    if (!showinglist && validlist && usemenu != 2 && 
+    if (!showinglist && validlist && usemenu != 2 && uselist &&
 	(nmatches != 1 || diffmatches) &&
 	useline >= 0 && useline != 2 && (!oldlist || !listshown)) {
 	onlyexpl = 3;
Index: Src/Zle/zle_tricky.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_tricky.c,v
retrieving revision 1.30
diff -u -r1.30 zle_tricky.c
--- Src/Zle/zle_tricky.c	2001/06/25 09:32:21	1.30
+++ Src/Zle/zle_tricky.c	2001/07/10 09:16:06
@@ -2363,6 +2363,8 @@
 
     comppref = 1;
     ret = expandorcomplete(args);
+    if (cs && line[cs - 1] == ' ')
+        makesuffixstr(NULL, "\\-", 0);
     comppref = 0;
     return ret;
 }

-- 
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


  reply	other threads:[~2001-07-10  9:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-09 18:33 Stefan `Sec` Zehl
2001-07-09 18:49 ` Andrej Borsenkow
2001-07-09 18:54 ` Peter Stephenson
2001-07-09 19:31   ` Oliver Kiddle
2001-07-10  5:24     ` Andrej Borsenkow
2001-07-10  8:10       ` Bart Schaefer
2001-07-10  9:19         ` Sven Wischnowsky [this message]
2001-07-10  9:32           ` Peter Stephenson
2001-07-10 16:33             ` Bart Schaefer
2001-07-11  8:20               ` Sven Wischnowsky
2001-07-10  5:54     ` Thomas Köhler

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=200107100919.LAA16859@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --cc=zsh-workers@sunsite.dk \
    /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).