* Adding the original string from completion
@ 2003-12-05 11:36 Oliver Kiddle
2003-12-05 16:52 ` Bart Schaefer
0 siblings, 1 reply; 2+ messages in thread
From: Oliver Kiddle @ 2003-12-05 11:36 UTC (permalink / raw)
To: Zsh workers
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Adding the original string from completion
2003-12-05 11:36 Adding the original string from completion Oliver Kiddle
@ 2003-12-05 16:52 ` Bart Schaefer
0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2003-12-05 16:52 UTC (permalink / raw)
To: Zsh workers
On Dec 5, 12:36pm, Oliver Kiddle wrote:
}
} 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.
[...]
} 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?
How about this:
Have functions _prefix and _original cooperate with each other. Before
changing $ISUFFIX, _prefix stores the original value in a local, perhaps
$_orig_isuf or some such. Then _original uses ${_orig_isuf:-$ISUFFIX}
when constructing the compadd command.
} 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.
So then _original would work sort of like _all_matches ? That might be
a good way to go, but I'm not entirely certain.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-12-05 16:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-05 11:36 Adding the original string from completion Oliver Kiddle
2003-12-05 16:52 ` Bart Schaefer
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).