From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23345 invoked by alias); 31 Aug 2015 10:17:25 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 36346 Received: (qmail 16818 invoked from network); 31 Aug 2015 10:17:23 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.0 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== MIME-Version: 1.0 X-Received: by 10.141.28.2 with SMTP id f2mr37634264qhe.17.1441016241730; Mon, 31 Aug 2015 03:17:21 -0700 (PDT) In-Reply-To: <1441014958-27075-1-git-send-email-mikachu@gmail.com> References: <1441007642-12365-1-git-send-email-mikachu@gmail.com> <1441014958-27075-1-git-send-email-mikachu@gmail.com> Date: Mon, 31 Aug 2015 12:17:21 +0200 Message-ID: Subject: Re: PATCH: Set completion function flags correctly for zle -P From: Mikael Magnusson To: zsh workers Content-Type: text/plain; charset=UTF-8 On Mon, Aug 31, 2015 at 11:55 AM, Mikael Magnusson 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