Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Aaaaargggghhh... :)
- X-seq: zsh-users 8767
- From: Meino Christian Cramer <Meino.Cramer@xxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Aaaaargggghhh... :)
- Date: Thu, 28 Apr 2005 20:35:57 +0200 (CEST)
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
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
# ======================================================================
Messages sorted by:
Reverse Date,
Date,
Thread,
Author