zsh-users
 help / color / mirror / code / Atom feed
* Aaaaargggghhh... :)
@ 2005-04-28 18:35 Meino Christian Cramer
  2005-04-29  3:27 ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Meino Christian Cramer @ 2005-04-28 18:35 UTC (permalink / raw)
  To: zsh-users


Hi,

 am I totally .... ?

 There is a neat keeper function described here:
 
   http://www.unixreview.com/documents/s=9513/ur0501a/ur0501a.htm

 But it seems, that I am not able to get the desribed script working
 for me.

 I always tell me:

   No such widget `_expand-kept-result'

 or 

   No such widget `_expand-kept-result

 I tried to remove/add underscores but it does not help either.

 What is the bug in my implementation of that keeper funtionality?

 Here is my script:

# ======================================================================
# keep
# ----------------------------------------------------------------------
function keep {
    setopt localoptions nomarkdirs nonomatch nocshnullglob nullglob
    kept=()         # Erase old value in case of error on next line
    kept=($~*)
    if [[ ! -t 0 ]]; then
        local line
        while read line; do
            kept+=( $line )   # += is a zsh 4.2+ feature
        done
    fi
    print -Rc - ${^kept%/}(T)
}
# ......................................................................
alias keep='noglob keep'
#......................................................................
function keep {
    setopt localoptions nomarkdirs nonomatch nocshnullglob nullglob
    kept=()         # Erase old value in case of error on next line
    kept=($~*)
    if [[ ! -t 0 ]]; then
        local line
        while read line; do
            kept+=( $line )   # += is a zsh 4.2+ feature
        done
    fi
    print -Rc - ${^kept%/}(T)
}
# !

_insert_kept() {
    (( $#kept )) || return 1
    local action
    zstyle -s :completion:$curcontext insert-kept action
    if [[ -n $action ]]
    then compstate[insert]=$action
    elif [[ $WIDGET = *expand* ]]
    then compstate[insert]=all
    fi
    if [[ $WIDGET = *expand* ]]
    then compadd -U ${(M)kept:#${~words[CURRENT]}}
    else compadd -a kept
    fi
}      

 _expand_word_and_keep() {
     function compadd() {
         local -A args
         zparseopts -E -A args J:
         if [[ $args[-J] == all-expansions ]]
         then
             builtin compadd -A kept "$@"
             kept=( ${(Q)${(z)kept}} )
         fi
         builtin compadd "$@"
     }
     local result
     _main_complete _expand
     result=$?
     unfunction compadd
     return result
 }

zle -C _expand_word complete-word _expand_word_and_keep
zstyle ':completion:expand-kept-result:*' completer _insert_kept      
bindkey '^XK' expand-kept-result
bindkey '^Xk' insert-kept-result 




Thank you very much for any help in advance!
Happy zshing!
Meino







 # ======================================================================


     


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-04-29  3:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-28 18:35 Aaaaargggghhh... :) Meino Christian Cramer
2005-04-29  3:27 ` Bart Schaefer
2005-04-29  3:36   ` Meino Christian Cramer
2005-04-29  3:37   ` Meino Christian Cramer

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).