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

PATCH: Re: prefix-needed style in _popd



Oliver Kiddle wrote:

> --- Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx> wrote: > 
> > Bleah... I never liked that prefix-needed business.
> 
> I just never liked prefix-needed false behaviour. Maybe only because I
> was used to always requiring a prefix going back to all my old tcsh
> completions. One character prefixes are not a lot to type and it is
> nice to cut down the number of matches.

Err... I meant that I prefer this, too, and don't like all the
problems handling prefix-needed==false has caused.

> ...
> 
> > Removing the prefix-needed handling is of course the easiest thing
> > (and give the behaviour I almost certainly would want and expect,
> > too).  For that completeness thing we would have to add every entry
> > with `+' and `-'.
> 
> Personally, I think completeness purely for its own sake is pointless
> unless you enjoy implementing it. Can I suggest then that if anyone
> feels that completeness here is important or that there is some other
> behaviour they want (such as choosing + or -) that they say. Otherwise
> we should just remove prefix-needed from _popd so that what is
> effectively a bug is gone. 

And I didn't mean to say that I was planning to implement adding all
directories with both prefixes.  The patch below just comments out
using the prefix-needed style in _popd.

> If anyone does make any significant changes to _popd, can I suggest
> that they consider looking at _tilde which could and possibly should
> call _popd (especially if _popd is renamed _directory_stack). Currently
> it repeats much of _popd.

Ah, right, thanks for the reminder.


Bye
 Sven

Index: Completion/Base/_tilde
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/_tilde,v
retrieving revision 1.5
diff -u -r1.5 _tilde
--- Completion/Base/_tilde	2000/05/31 09:38:26	1.5
+++ Completion/Base/_tilde	2001/03/27 12:16:55
@@ -24,33 +24,7 @@
   _requested named-directories expl 'named directory' \
       compadd "$suf[@]" "$@" -k nameddirs
 
-  if _requested directory-stack &&
-     { ! zstyle -T ":completion:${curcontext}:directory-stack" prefix-needed ||
-       [[ "$PREFIX" = [-+]* || nm -eq compstate[nmatches] ]] }; then
-    if zstyle -T ":completion:${curcontext}:directory-stack" verbose; then
-      integer i
+  _requested directory-stack && _popd "$suf[@]" && ret=0
 
-      lines=("${PWD}" "${dirstack[@]}")
-
-      if [[ ( -prefix - && ! -o pushdminus ) ||
-	    ( -prefix + && -o pushdminus ) ]]; then
-        revlines=( $lines )
-        for (( i = 1; i <= $#lines; i++ )); do
-          lines[$i]="$((i-1)) -- ${revlines[-$i]}"
-        done
-      else
-        for (( i = 1; i <= $#lines; i++ )); do
-          lines[$i]="$((i-1)) -- ${lines[$i]}"
-        done
-      fi
-      list=( ${PREFIX[1]}${^lines%% *} )
-      disp=( -ld lines )
-    else
-      list=( ${PREFIX[1]}{0..${#dirstack}} )
-      disp=()
-    fi
-    _all_labels -V directory-stack expl 'directory stack' \
-        compadd "$suf[@]" "$disp[@]" -Q -a list && ret=0
-  fi
   (( ret )) || return 0
 done
Index: Completion/Builtins/_popd
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Builtins/_popd,v
retrieving revision 1.5
diff -u -r1.5 _popd
--- Completion/Builtins/_popd	2000/10/06 13:01:53	1.5
+++ Completion/Builtins/_popd	2001/03/27 12:16:55
@@ -7,10 +7,20 @@
 
 setopt localoptions nonomatch
 
-local expl list lines revlines disp
+local expl list lines revlines disp suf
 
-! zstyle -T ":completion:${curcontext}:directory-stack" prefix-needed ||
-    [[ $PREFIX = [-+]* ]] || return 1
+if [[ "$SUFFIX" = */* ]]; then
+  ISUFFIX="/${SUFFIX#*/}$ISUFFIX"
+  SUFFIX="${SUFFIX%%/*}"
+  suf=(-S '')
+else
+  suf=(-qS/)
+fi
+
+### we decided against this, for now...
+#! zstyle -T ":completion:${curcontext}:directory-stack" prefix-needed ||
+
+[[ $PREFIX = [-+]* ]] || return 1
 
 if zstyle -T ":completion:${curcontext}:directory-stack" verbose; then
   # get the list of directories with their canonical number
@@ -38,4 +48,4 @@
 fi
 
 _wanted -V directory-stack expl 'directory stack' \
-    compadd "$@" "$disp[@]" -Q -a list
+    compadd "$@" "$suf[@]" "$disp[@]" -Q -a list

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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