about summary refs log tree commit diff
path: root/Completion/Core/_match
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-11-15 12:01:46 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-11-15 12:01:46 +0000
commit35b2633ad941966f5fca07b625a594a5b68c0fdb (patch)
treeb54740d014e594ba5d81931cdcdb3387bcf9dfca /Completion/Core/_match
parentbb98460a01ce1f6c1e71f7e401f782c81b71486b (diff)
downloadzsh-35b2633ad941966f5fca07b625a594a5b68c0fdb.tar.gz
zsh-35b2633ad941966f5fca07b625a594a5b68c0fdb.tar.xz
zsh-35b2633ad941966f5fca07b625a594a5b68c0fdb.zip
manual/8639
Diffstat (limited to 'Completion/Core/_match')
-rw-r--r--Completion/Core/_match20
1 files changed, 14 insertions, 6 deletions
diff --git a/Completion/Core/_match b/Completion/Core/_match
index f4e5fc0ee..35d7c2ecb 100644
--- a/Completion/Core/_match
+++ b/Completion/Core/_match
@@ -1,7 +1,7 @@
 #autoload
 
 # This is intended to be used as a completer function after the normal
-# completer as in: `compconf completer=_complete:_match'.
+# completer as in: `compstyle "*" completer _complete _match'.
 # It temporarily switches on pattern matching, allowing you to try 
 # completion on patterns without having to setopt glob_complete.
 #
@@ -9,7 +9,8 @@
 # expand-or-complete function because otherwise the pattern will
 # be expanded using globbing.
 
-local tmp opm="$compstate[pattern_match]" ret=0
+local tmp opm="$compstate[pattern_match]" ret=0 curcontext="$curcontext"
+local orig ins
 
 # Do nothing if we don't have a pattern or there are still global
 # match specifications to try.
@@ -18,9 +19,16 @@ tmp="${${:-$PREFIX$SUFFIX}#[~=]}"
 [[ "$tmp:q" = "$tmp" ||
    compstate[matcher] -ne compstate[total_matchers] ]] && return 1
 
+# Probably set initial context.
+
+[[ -z "$curcontext" ]] && curcontext=':match'
+
+_style -s '' original orig
+_style -s '' insert ins
+
 # Try completion without inserting a `*'?
 
-if [[ -n "$compconfig[match_original]" ]]; then
+if [[ -n "$orig" ]]; then
   compstate[matcher]=-1
   compstate[pattern_match]='-'
   _complete && ret=1
@@ -28,7 +36,7 @@ if [[ -n "$compconfig[match_original]" ]]; then
   compstate[matcher]="$compstate[total_matchers]"
 
   if (( ret )); then
-    [[ "$compconfig[match_insert]" = unambig* &&
+    [[ "$ins" = unambig* &&
        $#compstate[unambiguous] -ge ${#:-${PREFIX}${SUFFIX}} ]] && 
         compstate[pattern_insert]=unambiguous
     return 0
@@ -37,7 +45,7 @@ fi
 
 # No completion with inserting `*'?
 
-[[ "$compconfig[match_original]" = only ]] && return 1
+[[ "$orig" = only ]] && return 1
 
 compstate[matcher]=-1
 compstate[pattern_match]='*'
@@ -45,7 +53,7 @@ _complete && ret=1
 compstate[pattern_match]="$opm"
 compstate[matcher]="$compstate[total_matchers]"
 
-[[ ret -eq 1 && "$compconfig[match_insert]" = unambig* &&
+[[ ret -eq 1 && "$ins" = unambig* &&
    $#compstate[unambiguous] -ge ${#:-${PREFIX}${SUFFIX}} ]] && 
     compstate[pattern_insert]=unambiguous