zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: RE: PATCH: cleanup in zle_tricky.c
Date: Tue, 23 Mar 1999 10:51:44 +0100 (MET)	[thread overview]
Message-ID: <199903230951.KAA18666@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: "Andrej Borsenkow"'s message of Mon, 22 Mar 1999 20:45:22 +0300


Andrej Borsenkow wrote:

> > Question to others: do you see the same behavior Andrej does? I.e. is
> > it me or is it the rest of the world who has run out of sync?
> >
> 
> I know now where the problem(s) were - I sent this to Sven as well.
> 
> Bsically, the completion does not work with ambiguous prefix. In my case I
> had /u1/informix* as well - that way _path_files took another branch.

Ah, I thought you had made sure that this didn't happen because we had
this discussion already -- and hence I didn't test for it (the real
problem was that without globcomplete there were no matches). At that
time I had asked if we wanted the path to expand as far as possible in
such cases.
Since you perceived this as a bug, the patch below makes the answer
`yes'.

> In case of `.../*.suffix', the `/.*' was replaced by `/.', that 'course
> could not match.

That was an attempt to make the normal non-globdots behavior simpler
for those who have a matcher making dots word-separators. Trying to do 
too much, one could say. The patch below removes this.

> In case of x*y, first the whole was quoted (that gives you `x\*y') then *
> was replaced by pattern, that should match anything except `/' - leaving
> backslash inside. again, that pattern could not match.

This, too, should be fixed by the patch below (an ugly oversight).


Ok, with the patch below and the ones from 5871, 5872, and 5875: does
everything work as you want (or expect ;-) it now? Including those
`test/{a1,b1,x1y}' problems you mentioned?

Bye
 Sven

diff -u oc/Core/_path_files Completion/Core/_path_files
--- oc/Core/_path_files	Mon Mar 22 14:54:41 1999
+++ Completion/Core/_path_files	Tue Mar 23 10:48:19 1999
@@ -23,13 +23,14 @@
 local nm str linepath realpath donepath patstr prepath testpath rest
 local tmp1 collect tmp2 suffixes i ignore matchflags opt group sopt pats gopt
 local addpfx addsfx expl orig ostr nm=$compstate[nmatches] menu remsfx patlast
-local origflags mflags
+local origflags mflags tmp3 tmp4 exppaths
 
 typeset -U prepaths
 
 setopt localoptions nullglob rcexpandparam extendedglob
 unsetopt markdirs globsubst shwordsplit nounset
 
+exppaths=()
 prepaths=('')
 ignore=()
 group=()
@@ -202,7 +203,7 @@
 # have special meaning for globbing, we remove them. But before that, we
 # add the pattern for matching any characters before a slash.
 
-patstr="$patstr:gs-/-*/-:gs/*.*./../:gs-/*.-/.-:gs/**/*/:gs-.*/-./-"
+patstr="$patstr:gs-/-*/-:gs/*.*./../:gs/**/*/:gs-.*/-./-"
 
 [[ "${compstate[pattern_match]-*}" != \** ]] && patstr="$patstr:gs/*//"
 
@@ -218,16 +219,16 @@
 
 if [[ "$patstr" = */* ]]; then
   if [[ -n "$_comp_correct" && "${#orig##*/}" -le _comp_correct ]]; then
-    patlast="*/${origflags}${${patstr##*/}//\*/[^/]#}"
+    patlast="*/${origflags}${${${patstr##*/}//\*/[^/]#}:gs.\[^/]#.\\\*.}"
   else
-    patlast="*/${matchflags}${${patstr##*/}//\*/[^/]#}"
+    patlast="*/${matchflags}${${${patstr##*/}//\*/[^/]#}:gs.\[^/]#.\\\*.}"
   fi
   patstr="${patstr%/*}/"
 else
   if [[ -n "$_comp_correct" && "$#orig" -le _comp_correct ]]; then
-    patlast="${origflags}${patstr//\*/[^/]#}"
+    patlast="${origflags}${${patstr//\*/[^/]#}:gs.\[^/]#.\\\*.}"
   else
-    patlast="${matchflags}${patstr//\*/[^/]#}"
+    patlast="${matchflags}${${patstr//\*/[^/]#}:gs.\[^/]#.\\\*.}"
   fi
   patstr=""
 fi
@@ -315,6 +316,24 @@
       # next `-W' path.
 
       if [[ $#collect -eq 0 ]]; then
+        # Before giving, we first try to get the longest expandable path-
+	# prefix, though. The result is stored in `exppaths'
+
+        tmp2=()
+	tmp3="$rest"
+	tmp4="${ostr##*/}"
+	ostr="${ostr%/*}"
+	while [[ "$tmp3" = */* ]]; do
+	  tmp2=( ${^tmp1}/${~mflags}${~tmp3} )
+	  if [[ $#tmp2 -eq 1 ]]; then
+	    exppaths=( "$exppaths[@]" "${tmp2[1]}${tmp4}" )
+	    exppaths=( "${(@)exppaths#${prepath}${realpath}}" )
+	    break;
+          fi
+	  tmp3="${tmp3%/*}"
+	  tmp4="${ostr##*/}/${tmp4}"
+	  ostr="${ostr%/*}"
+        done
         continue 2
       elif [[ $#collect -ne 1 ]]; then
         # If we have more than one possible match, this means that the
@@ -426,6 +445,16 @@
 	    -W "$prepath$realpath$testpath" - "${(@)${(@)tmp2#$tmp1}:q}"
   fi
 done
+
+# If no matches were found but we have expanded paths which are different
+# from the original string, use them.
+
+exppaths=( "${(@)exppaths:#$orig}" )
+
+if [[ nm -eq compstate[nmatches] && $#exppaths -ne 0 ]]; then
+  compadd -UQ -S '' "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" - \
+          "${linepath}${(@)^exppaths}"
+fi
 
 # This sets the return value to indicate that we added matches (or not).
 

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


             reply	other threads:[~1999-03-23  9:52 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-03-23  9:51 Sven Wischnowsky [this message]
1999-03-24 10:41 ` Andrej Borsenkow
  -- strict thread matches above, loose matches on Subject: below --
1999-03-24 12:29 Sven Wischnowsky
1999-03-22 15:43 Sven Wischnowsky
1999-03-22 17:45 ` Andrej Borsenkow
1999-03-22 15:29 Sven Wischnowsky
1999-03-22 14:28 Sven Wischnowsky
1999-03-22 15:32 ` Andrej Borsenkow
1999-03-22 13:55 Sven Wischnowsky
1999-03-22 14:09 ` Andrej Borsenkow
1999-03-22 14:17 ` Andrej Borsenkow
1999-03-22 10:56 Sven Wischnowsky
1999-03-22 13:02 ` Andrej Borsenkow

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=199903230951.KAA18666@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --cc=zsh-workers@sunsite.auc.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).