Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Adding the original string from completion
- X-seq: zsh-workers 19278
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxxxxx>
- Subject: Adding the original string from completion
- Date: Fri, 05 Dec 2003 12:36:56 +0100
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
A good few completers can insert the original string as a match
allowing the user to easily get back to what they typed first.
Typically, this is done with a line looking like this:
compadd "$expl[@]" -U -Q - "$PREFIX$SUFFIX"
When called from _prefix, the result is that the suffix is lost.
The fix is to change the line to:
compadd "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" -U -Q - "$PREFIX$SUFFIX"
Only problem is if _prefix's add-space style is set. It sticks an
additional space at the beginning of ISUFFIX. That space is then
inserted after the cursor. That's still better than loosing the suffix
so I will do this change as a minimum. Adding $words[CURRENT], which is
unchanged, as the match looses the cursor position so that isn't much
help.
The hack round this is to use something like:
local isuf=${words[CURRENT][1+${#:-$QIPREFIX$IPREFIX$PREFIX$SUFFIX},-1]}
compadd "$expl[@]" -I "$isuf" -Q -U -S '' - "$IPREFIX$PREFIX$SUFFIX"
Though that needs a bit more tweaking to cope with all forms of
quoting.
This amounts to trusting $words[CURRENT] to be unchanged instead of
$ISUFFIX. If we do this, I'm inclined to factor it out into an new
_original function though. Anyone got any better ideas? Does that hack
seem reasonable?
_ignored is actually not using -Q or -U so it can end up quoting the
original string too. So that needs fixing.
There is also the option of only adding original strings at the end from
_main_complete. Given certain styles and whether menu completion if
enabled that is.
Oliver
Messages sorted by:
Reverse Date,
Date,
Thread,
Author