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

Re: PATCH: Re: _match still does not work in _path_files



Bart Schaefer wrote:

> On Oct 18, 10:38am, Sven Wischnowsky wrote:
> } Subject: RE: PATCH: Re: _match still does not work in _path_files
> }
> } The patch below implements some kind of mixed-matching style. Even
> } with glob-complete behaviour it will try to match the prefix using the 
> } match specs currently in effect. This is as far as we can get. Is it
> } enough?
> 
> There's still one thing that bothers me; it's probably not related.  With
> the default compconfig:
> 
> zagzig% cd /u/l/s/z/f/
> 
> Fails to complete to /usr/local/share/zsh/functions/.  The problem is
> that _path_files wants there to be something after the final slash that
> is a fragment of a directory name.  I vaguely recall some discussion of
> a compconfig for something like this, but if there is one I can't find
> it -- and given that "cd" doesn't care if the trailing slash is there,
> shouldn't this work by default anyway?

This is one of the cases for `path_expand=prefix', but I agree that it
should be cleverer in doing the right thing automatically.

This makes `_path_files' automatically complete such a path even if
there are no files matching the pattern inside the last directory.
However, it keeps the behaviour of tking the trailing slash as a sign
that one wants to complete inside the directory. I.e. if there *are*
files matching in it, they are added as possible matches immediately.

Ok?

This also made me find some small bugs in the C-code. My last change
to the unambiguous-string insertion heuristic was a bit too eager to
avoid inserting a trailing part. If it was on the line, it should of
course be kept.

And then a rather weird one. Weird in the sense that I wonder why we
haven't noticed it yet. If you add a match as a filename and that's
the name of a directory, do_single() makes the test if it should
append a slash automatically. But if the name added already contains
that trailing slash, it still does the test -- leaving you with two
slashes at the end.

Bye
 Sven

diff -u -r oldsrc/Zle/zle_tricky.c Src/Zle/zle_tricky.c
--- oldsrc/Zle/zle_tricky.c	Mon Oct 18 11:54:06 1999
+++ Src/Zle/zle_tricky.c	Mon Oct 18 13:01:58 1999
@@ -7835,7 +7835,7 @@
 	    q = p;
     }
     if (!e && q && !q->orig && !q->olen && (q->flags & CLF_MISS) &&
-	(q->word ? q->wlen : q->llen) < 3) {
+	!(q->flags & CLF_MATCHED) && (q->word ? q->wlen : q->llen) < 3) {
 	q->word = q->line = NULL;
 	q->wlen = q->llen = 0;
     }
@@ -8452,7 +8452,8 @@
 	    if (m->flags & CMF_PARNEST)
 		havesuff = 1;
 	}
-	if ((m->flags & CMF_FILE) || (partest && isset(AUTOPARAMSLASH))) {
+	if (((m->flags & CMF_FILE) || (partest && isset(AUTOPARAMSLASH))) &&
+	    cs > 0 && line[cs - 1] != '/') {
 	    /* If we have a filename or we completed a parameter name      *
 	     * and AUTO_PARAM_SLASH is set, lets see if it is a directory. *
 	     * If it is, we append a slash.                                */
diff -u -r oldcompletion/Core/_path_files Completion/Core/_path_files
--- oldcompletion/Core/_path_files	Mon Oct 18 11:17:49 1999
+++ Completion/Core/_path_files	Mon Oct 18 13:10:14 1999
@@ -277,7 +277,12 @@
       # otherwise this would keep `_files' from completing all filenames
       # if none of the patterns match.
 
-      if [[ "$haspats" = no && -z "$tpre$tsuf" &&
+      if [[ -z "$tpre$tsuf" ]]; then
+        tmp1=( "$tmp2[@]" )
+	addsfx=(-S '')
+	remsfx=()
+	break;
+      elif [[ "$haspats" = no && -z "$tpre$tsuf" &&
 	"$pre" = */ && -z "$suf" ]]; then
 	PREFIX="${opre}${osuf}"
 	SUFFIX=""

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author