From a295e82c1e3c6d10cd873d0fcd31ed45d77e4ca3 Mon Sep 17 00:00:00 2001 From: Sven Wischnowsky Date: Mon, 19 Jun 2000 09:55:31 +0000 Subject: allow _expand to expand braces; better detection of braces to complete in C (11973) --- ChangeLog | 7 +++++++ Completion/Builtins/_zstyle | 43 +++++++++++++++++++++++++++++++++++-------- Completion/Core/_description | 2 ++ Completion/Core/_expand | 8 +++++--- Doc/Zsh/compsys.yo | 15 +++++++++------ Src/Zle/zle_tricky.c | 26 +++++++++++++++++++++++++- 6 files changed, 83 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 18c8fe9c2..16ae04e78 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2000-06-19 Sven Wischnowsky + + * 11973: Completion/Builtins/_zstyle, Completion/Core/_description, + Completion/Core/_expand, Doc/Zsh/compsys.yo, Src/Zle/zle_tricky.c: + allow _expand to expand braces; better detection of braces to + complete inC + 2000-06-19 Peter Stephenson * unpost: additions to Completion/Commands/.distfiles and diff --git a/Completion/Builtins/_zstyle b/Completion/Builtins/_zstyle index db86829ec..764afb5a1 100644 --- a/Completion/Builtins/_zstyle +++ b/Completion/Builtins/_zstyle @@ -17,31 +17,32 @@ styles=( break-keys c: command c:command completer c:completer - completions c: - condition c: + completions c:bool + condition c:bool cursor c:cursor disable-stat c:bool domains c: expand c: + fake c:fake file-patterns c:filepat file-sort c:fsort - force-list c + force-list c: format c: - glob c: + glob c:bool group-name c: group-order c:tag groups c:_groups - guarded-completer c:completer hidden c:bool hosts c:_hosts hosts-ports c:host-port users-hosts-ports c:user-host-port - ignore-line c:bool + ignore-line c:ignline ignore-parents c:ignorepar ignored-patterns c: insert-ids c:insert-ids insert-tab c:bool insert-unambiguous c:bool + keep-prefix c:keep-prefix last-prompt c:bool list c:listwhen list-colors c: @@ -49,6 +50,8 @@ styles=( list-prompt c: list-rows-first c:bool local c: + match-original c:match-orig + matcher c: matcher-list c: max-errors c: menu c:boolauto @@ -62,6 +65,7 @@ styles=( prefix-hidden c:bool prefix-needed c:bool prompt c: + remote-access c:bool remove-all-dups c:bool select-prompt c: select-scroll c: @@ -71,9 +75,12 @@ styles=( squeeze-slashes c:bool stop c:stop stop-keys c: - subst-globs-only c: - substitute c: + subst-globs-only c:bool + substitute c:bool + suffix c:bool tag-order c:tag + try-to-use-pminst c:bool + use-compctl c:urgh users c:_users users-hosts c:user-host verbose c:bool @@ -256,6 +263,26 @@ while [[ -n $state ]]; do compadd - menu single longer ;; + fake) + _message 'prefix and names' + ;; + + ignline) + _wanted values expl boolean compadd true false current current-shown other + ;; + + keep-prefix) + _wanted values expl boolean compadd true false changed + ;; + + match-orig) + _wanted values expl boolean compadd only both + ;; + + urgh) + _wanted values expl no compadd no false off 0 + ;; + _*) ${=ostate} ;; diff --git a/Completion/Core/_description b/Completion/Core/_description index b1b98741c..2c4232ade 100644 --- a/Completion/Core/_description +++ b/Completion/Core/_description @@ -38,6 +38,8 @@ if [[ -z "$_comp_no_ignore" ]]; then case "$hidden" in true|yes|on|1) _comp_ignore=( "$_comp_ignore[@]" "$words[@]" );; current) _comp_ignore=( "$_comp_ignore[@]" "$words[CURRENT]" );; + current-shown) [[ "$compstate[old_list]" = *shown* ]] && + _comp_ignore=( "$_comp_ignore[@]" "$words[CURRENT]" );; other) _comp_ignore=( "$_comp_ignore[@]" "${(@)words[1,CURRENT-1]}" "${(@)words[CURRENT+1,-1]}" );; diff --git a/Completion/Core/_expand b/Completion/Core/_expand index 88a2fb97d..8b0bae95f 100644 --- a/Completion/Core/_expand +++ b/Completion/Core/_expand @@ -55,10 +55,12 @@ exp=("$word") if [[ "$force" = *s* ]] || zstyle -T ":completion:${curcontext}:" substitute; then - exp=( "${(e)exp//\\[ -]/ }" ) + [[ ! -o ignorebraces && "${#${exp}//[^\{]}" = "${#${exp}//[^\}]}" ]] && + eval exp\=\( ${${(q)exp}:gs/\\{/\{/:gs/\\}/\}/} \) + exp=( ${(e)exp//\\[ +]/ } ) else - exp=( "${exp:s/\\\$/\$}" ) + exp=( ${exp:s/\\\$/\$} ) fi # If the array is empty, store the original string again. diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo index 2afd505fc..71ceb9ab0 100644 --- a/Doc/Zsh/compsys.yo +++ b/Doc/Zsh/compsys.yo @@ -1207,12 +1207,15 @@ 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. 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. - -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. +possible completion. The same happens if the value is +`tt(current-shown)', but only if the list of completions is currently +shown on the screen. Finally, if it is set to `tt(other)' all words +except the current one will not be considered to be a possible +completion. + +The values `tt(current)' and `tt(current-shown)' are 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 diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c index af0c43f57..bc76ad4cd 100644 --- a/Src/Zle/zle_tricky.c +++ b/Src/Zle/zle_tricky.c @@ -1434,7 +1434,19 @@ get_comp_string(void) } } } else if (p < curs) { + if (*p == Outbrace) { + cant = 1; + break; + } if (*p == Inbrace) { + char *tp = p; + + if (!skipparens(Inbrace, Outbrace, &tp)) { + i += tp - p - 1; + dp += tp - p - 1; + p = tp - 1; + continue; + } if (bbeg) { Brinfo new; int len = bend - bbeg; @@ -1470,6 +1482,18 @@ get_comp_string(void) hascom = 1; } } else { + if (*p == Inbrace) { + char *tp = p; + + if (!skipparens(Inbrace, Outbrace, &tp)) { + i += tp - p - 1; + dp += tp - p - 1; + p = tp - 1; + continue; + } + cant = 1; + break; + } if (p == curs) { if (bbeg) { Brinfo new; @@ -1501,7 +1525,7 @@ get_comp_string(void) if (*p == Comma) { if (!bbeg) bbeg = p; - hascom = 1; + hascom = 2; } else if (*p == Outbrace) { Brinfo new; int len; -- cgit 1.4.1