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

PATCH: ignore-line (was: Re: PATCH: Re: expansion)



I wrote:

> ...
> 
> I want to integrate it with (the already existing) ignore-line style,
> three choices there: ignore all words from the line, ignore only the
> current word, ignore all words except the current one.

Here is the patchlet for that. You can now set ignore-line to `true'
(`yes',...), `current' (to ignore only the current word) and `other'
(to ignore all words except the current one).

For example, if you set it to `current' and you have the directories
foo and foobar and do `cd f<TAB>' you get `cd foo' and if you now hit
TAB again, this will complete to foobar.

Hm, this maybe we should allow `current listed' or some such to mean
`ignore the current word if the list of matches is shown'.

Bye
 Sven

Index: Completion/Core/_description
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_description,v
retrieving revision 1.6
diff -u -r1.6 _description
--- Completion/Core/_description	2000/05/23 08:54:30	1.6
+++ Completion/Core/_description	2000/06/16 07:31:39
@@ -30,15 +30,19 @@
 [[ -n "$_matcher" ]] && opts=($opts -M "$_matcher")
 
 if [[ -z "$_comp_no_ignore" ]]; then
-  if zstyle -a ":completion:${curcontext}:$1" ignored-patterns _comp_ignore; then
-    opts=( $opts -F _comp_ignore )
-    zstyle -t ":completion:${curcontext}:$1" ignore-line &&
-        _comp_ignore=( "$_comp_ignore[@]" "$words[@]" )
-  elif zstyle -t ":completion:${curcontext}:$1" ignore-line; then
-    _comp_ignore=( "$words[@]" )
-  else
+  zstyle -a ":completion:${curcontext}:$1" ignored-patterns _comp_ignore ||
     _comp_ignore=()
-  fi
+
+  zstyle -s ":completion:${curcontext}:$1" ignore-line hidden &&
+    case "$hidden" in
+    true|yes|on|1) _comp_ignore=( "$_comp_ignore[@]" "$words[@]" );;
+    current)       _comp_ignore=( "$_comp_ignore[@]" "$words[CURRENT]" );;
+    other)         _comp_ignore=( "$_comp_ignore[@]"
+                                  "${(@)words[1,CURRENT-1]}"
+				  "${(@)words[CURRENT+1,-1]}" );;
+    esac
+
+  (( $#_comp_ignore )) && opts=( $opts -F _comp_ignore )
 else
   _comp_ignore=()
 fi
Index: Doc/Zsh/compsys.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v
retrieving revision 1.66
diff -u -r1.66 compsys.yo
--- Doc/Zsh/compsys.yo	2000/06/16 07:31:09	1.66
+++ Doc/Zsh/compsys.yo	2000/06/16 07:31:44
@@ -1187,9 +1187,17 @@
 item(tt(ignore-line))(
 This style is tested for the tags used when generating matches.  If it
 is set to `true', then none of the words that are already on the line
-will be considered possible completions.
+will be considered possible completions.  If it is set to
+`tt(current)', the word the cursor is on will not be considered a
+possible completion and if it is set to `tt(other)' all words except
+the current one will not be considered to be a possible completion.
 
-Note that you almost certainly don't want to set this for a general
+The value `tt(current)' is a bit like the opposite of the
+tt(accept-exact). It means that only strings with missing characters
+will be completed.
+
+Note that you almost certainly don't want to set this to `true' or
+`tt(other)' for a general
 context such as `tt(:completion:*)'.  This is because it would disallow
 completion of, for example, options multiple times even if the command
 in question accepts the option more than once.

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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