Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Magic-Backspace
- X-seq: zsh-users 17267
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Pascal Wittmann <PascalWittmann@xxxxxxx>
- Subject: Re: Magic-Backspace
- Date: Sat, 15 Sep 2012 20:57:09 +0200
- Cc: zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s1024; t=1347735430; bh=o21FmJcq6WDuIFeZ5Llv5Uin8gDE0qIR7LSSieG/CYY=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:Received:cc:In-reply-to:From:References:To:Subject:Date:Message-ID; b=JAbGTKt5IhDd5iSGNhqW6NuelMoCiHHhByN/uQAs6rNg309L+4j30Y4En2C6L9AJ6dn5ESVykmV8Vtur4ycJaHXW3ENOQj39dRab1fVfT4pxU7m3NIw4YQngwmqhmINY0pZ06HZ9IGctF3EpuTFXEfwcTXFOnkH8CzAmXi7Lz7U=
- In-reply-to: <504EED6B.7030403@gmx.net>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <504EED6B.7030403@gmx.net>
On 11 Sep, Pascal Wittmann wrote:
>
> I thought of implementing some magic-backspace that removes characters
> until the 'current' completion is ambiguous (i.e. some extended version
> of undo).
I've got a function which does roughly this. It has a number of issues
and, as I wrote it over eight years ago, I can't remember what those
issues are. I've attached it below. It works by removing characters
from the PREFIX and trying completion. It is intended to be used as a
completion widget via _generic:
zle -C retract complete-word _generic
zstyle ':completion:retract::::' completer _retract
bindkey '^[[24~' retract # F12
I'm not sure what the commented out line was for.
Oliver
#autoload
local _comp_backup=1 bumax=30
if (( ! $+functions[compadd] )); then
compadd() {
local save oldp="$PREFIX"
SUFFIX=
# removing the -O option is a nasty way to make this work from _multi_parts
zparseopts -D -E O:=save
local i
for ((i=_comp_backup;i>0;i--)); do
PREFIX="${PREFIX%?}"
done
builtin compadd -S '' -F "( $oldp* )" "$@"
}
trap 'unfunction compadd' EXIT INT
fi
while [[ _comp_backup -le bumax ]]; do
_complete && return
(( _comp_backup++ ))
done
#builtin compadd - ''
return 1
Messages sorted by:
Reverse Date,
Date,
Thread,
Author