Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: Set completion function flags correctly for zle -P
- X-seq: zsh-workers 36346
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh workers <zsh-workers@xxxxxxx>
- Subject: Re: PATCH: Set completion function flags correctly for zle -P
- Date: Mon, 31 Aug 2015 12:17:21 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=0+9YjgZvwPOi8pyg1IZK6tvJT9t1hgXrA1c9j4FDWO0=; b=GBxgMPHmIVSHV4ckMBhjg2CUf4ubsBcVyk0cIlVpyJMLMWwxwuUrvaOssmQn7f/ya5 jK51fDJdFV9efnoUINP06idow4bFabM5UVorK2uJURtQibV5CiKLPam+uW/0wW9bvSoS /qemb1yVNQRJf2nqM1J8P//Ilvo/zpIOuIltM/Zf6yK48Ds5avtHMs1X7tdpOvkXThmf mig7GBKJohObElFYvHNMbhX6suqoavba+0bbsYLscy9+GXF6zLeaRsOSt9QrfiRAmnj/ ap72UdjTvoo3/RGyWkQpGKdRw5jRs5fVhoqGXl9R1qP8e9AosyFkt9rWf3C6ZykB9M3z dGxw==
- In-reply-to: <1441014958-27075-1-git-send-email-mikachu@gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <1441007642-12365-1-git-send-email-mikachu@gmail.com> <1441014958-27075-1-git-send-email-mikachu@gmail.com>
On Mon, Aug 31, 2015 at 11:55 AM, Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> ---
>
> This appears to work better.
>
> Src/Zle/zle_thingy.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/Src/Zle/zle_thingy.c b/Src/Zle/zle_thingy.c
> index e648838..0401099 100644
> --- a/Src/Zle/zle_thingy.c
> +++ b/Src/Zle/zle_thingy.c
> @@ -606,9 +606,10 @@ bin_zle_prototype(char *name, char **args, UNUSED(Options ops), UNUSED(char func
> return 1;
> }
> w = zalloc(sizeof(*w));
> - w->flags = pw->flags & ~WIDGET_INT;
> + w->flags = pw->flags & ~(WIDGET_INT|ZLE_ISCOMP);
> w->first = NULL;
> - if (w->flags & WIDGET_NCOMP) {
> + if (pw->flags & ZLE_ISCOMP) {
> + w->flags |= WIDGET_NCOMP;
> w->u.comp.fn = pw->u.fn;
> w->u.comp.wid = ztrdup(args[1]);
> w->u.comp.func = ztrdup(args[2]);
Here's the final(?) touchup, not counting documentation. It makes the
last argument optional. Maybe it would be better to make the middle
argument optional? Not sure. (This one will be whitespace damaged.)
I can now do this (which is why I originally found this old thread, if
anyone was curious):
function _start_paste() {
local content
local a b
local oldcutbuf="$CUTBUFFER"
# I haven't quite decided how I want to control quoting yet.
[[ $_SPACE_AFTER_PASTE_QUOTE = 1 ]]; a=$?
(( $+NUMERIC )) || [[ $KEYS = $'\e\e'* ]]; b=$?
zle .$WIDGET -N content
if [[ $a -ne $b ]]; then
CUTBUFFER=${(q-)content}' '
else
CUTBUFFER=$content
fi
zle .yank
CUTBUFFER="$oldcutbuf"
}
zle -P bracketed-paste bracketed-paste _start_paste
And my pastes are appropriately highlit. (Wouldn't it really be more
useful to have the middle argument optional? I see how it might be
confusing if you're used to the zle -N behavior though.)
diff --git i/Src/Zle/zle_thingy.c w/Src/Zle/zle_thingy.c
index 8c66761..20a1de9 100644
--- i/Src/Zle/zle_thingy.c
+++ w/Src/Zle/zle_thingy.c
@@ -347,7 +347,7 @@ bin_zle(char *name, char **args, Options ops,
UNUSED(int func))
{ 'A', bin_zle_link, 2, 2 },
{ 'N', bin_zle_new, 1, 2 },
{ 'C', bin_zle_complete, 3, 3 },
- { 'P', bin_zle_prototype, 3, 3},
+ { 'P', bin_zle_prototype, 2, 3},
{ 'R', bin_zle_refresh, 0, -1 },
{ 'M', bin_zle_mesg, 1, 1 },
{ 'U', bin_zle_unget, 1, 1 },
@@ -596,6 +596,7 @@ bin_zle_prototype(char *name, char **args,
UNUSED(Options ops), UNUSED(char func
{
Thingy t;
Widget w, pw;
+ char *funcname = args[2] ? args[2] : args[0];
t = rthingy((args[1][0] == '.') ? args[1] : dyncat(".", args[1]));
pw = t->widget;
@@ -618,9 +619,9 @@ bin_zle_prototype(char *name, char **args,
UNUSED(Options ops), UNUSED(char func
w->flags |= WIDGET_NCOMP;
w->u.comp.fn = pw->u.fn;
w->u.comp.wid = ztrdup(args[1]);
- w->u.comp.func = ztrdup(args[2]);
+ w->u.comp.func = ztrdup(funcname);
} else {
- w->u.fnnam = ztrdup(args[2]);
+ w->u.fnnam = ztrdup(funcname);
}
if (bindwidget(w, rthingy(args[0]))) {
freewidget(w);
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author