* 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
* Re: Aaaaargggghhh... :)
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
0 siblings, 2 replies; 4+ messages in thread
From: Bart Schaefer @ 2005-04-29 3:27 UTC (permalink / raw)
To: Meino Christian Cramer, zsh-users
On Apr 28, 8:35pm, Meino Christian Cramer wrote:
>
> am I totally .... ?
The whole keeper function suite is in the development version of zsh,
available from CVS on sourceforge: Functions/Zle/keeper
You need at least zsh-4.2.2 to run that edition of the suite, as it
has been updated to use the "always" syntax.
> No such widget `_expand-kept-result'
> or
> No such widget `_expand-kept-result
(I presume one of those is supposed to mention "insert".)
> What is the bug in my implementation of that keeper funtionality?
You're missing a couple of "zle -C" commands; go back and look at the
article again. There should be a total of three "zle -C" commands in
the final script, but you've only included one of them.
Also ...
> Here is my script:
>
> function keep {
[...]
> }
> # ......................................................................
> alias keep='noglob keep'
> #......................................................................
> function keep {
[...]
> }
You don't need to define the "keep" function twice.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Aaaaargggghhh... :)
2005-04-29 3:27 ` Bart Schaefer
@ 2005-04-29 3:36 ` Meino Christian Cramer
2005-04-29 3:37 ` Meino Christian Cramer
1 sibling, 0 replies; 4+ messages in thread
From: Meino Christian Cramer @ 2005-04-29 3:36 UTC (permalink / raw)
To: schaefer; +Cc: zsh-users
From: Bart Schaefer <schaefer@brasslantern.com>
Subject: Re: Aaaaargggghhh... :)
Date: Fri, 29 Apr 2005 03:27:26 +0000
Hi Bart,
thank you very much for your helpful mail !
I will re-read the article ... for me it was not always clear whether
a new line of script code would replace a previous one or would be
added (English isn't my mother's tongue...)
Or I will do "reengineering my English": I will download the cvs
version of the keeper-function and with that knowledge I will reread
the article :)
Have a nice weekend!
Meino
> On Apr 28, 8:35pm, Meino Christian Cramer wrote:
> >
> > am I totally .... ?
>
> The whole keeper function suite is in the development version of zsh,
> available from CVS on sourceforge: Functions/Zle/keeper
>
> You need at least zsh-4.2.2 to run that edition of the suite, as it
> has been updated to use the "always" syntax.
>
> > No such widget `_expand-kept-result'
> > or
> > No such widget `_expand-kept-result
>
> (I presume one of those is supposed to mention "insert".)
>
> > What is the bug in my implementation of that keeper funtionality?
>
> You're missing a couple of "zle -C" commands; go back and look at the
> article again. There should be a total of three "zle -C" commands in
> the final script, but you've only included one of them.
>
> Also ...
>
> > Here is my script:
> >
> > function keep {
> [...]
> > }
> > # ......................................................................
> > alias keep='noglob keep'
> > #......................................................................
> > function keep {
> [...]
> > }
>
> You don't need to define the "keep" function twice.
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Aaaaargggghhh... :)
2005-04-29 3:27 ` Bart Schaefer
2005-04-29 3:36 ` Meino Christian Cramer
@ 2005-04-29 3:37 ` Meino Christian Cramer
1 sibling, 0 replies; 4+ messages in thread
From: Meino Christian Cramer @ 2005-04-29 3:37 UTC (permalink / raw)
To: schaefer; +Cc: zsh-users
Ah.... by the way: My zsh is of version 4.2.5....
:)
keep 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).