From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21653 invoked by alias); 31 Aug 2014 02:58:59 -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: 33078 Received: (qmail 10279 invoked from network); 31 Aug 2014 02:58:46 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=Ltrz7LLun1UkGLXjxgbXy+8vkYltuE3BZsXwtxWGsX4=; b=S8U7q+dIWkO3wZZG5F3kSNDvLh5E145kIbVZm5oXTSBkedB7/N237YqCmB0REJ2DHQ 5rKaQdFMAxwXEN523TeHhL57ZhKOI6yKtO3hQs4rFApzr78WfWshpfUATzSrztNVRjZT c71OS2b67OCVcqr0mkqRdLBFll2xbdVupthVTgMAlpVQfOEW2RmOeEZzpURfnvceoPM6 Ju6YjDNLQrt/+8nDOLr/coc5qKE1K4SLNB4dy3v943cGX21+XHZSmfdlDckErl3NDxLi 6oeggyeMXgsW+gifmw23qaNZYUVs3EhT4mT2dgewCzNocQ6g/yBCEqf6Nv1p+NIoaVvk bHtQ== X-Received: by 10.152.42.231 with SMTP id r7mr1060194lal.23.1409453921307; Sat, 30 Aug 2014 19:58:41 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <140830133206.ZM13172@torch.brasslantern.com> References: <140830133206.ZM13172@torch.brasslantern.com> From: Jonathan H Date: Sat, 30 Aug 2014 19:58:11 -0700 Message-ID: Subject: Re: _expand_alias does not expand aliases that contain an "!" To: Bart Schaefer Cc: zsh-workers@zsh.org Content-Type: text/plain; charset=UTF-8 Thank you! Oddly enough, for me _expand_alias works for all characters in [*#?@:+-^%$.,]. the only character that didn't work and wasn't already meaningful to the shell was the exclamation point. I'm on Zsh 5.02, Ubuntu 14.04 x64 and Fedora Rawhide x64. One possible solution on my end is to define the aliases like this: Heptagon% alias 'gc!'="git commit --amend" Heptagon% alias 'gc\!'="git commit --amend" One for expansion, and one for the shell internally. I'm not sure how this works on the insides, but it does. Is this unexpected or, worse, incorrect? Thanks, PythonNut On Sat, Aug 30, 2014 at 1:32 PM, Bart Schaefer wrote: > On Aug 26, 9:50am, Jonathan H wrote: > } > } Aliases that contain an exclamation point are not correctly expanded > } by _expand_alias. > > You've encountered a fairly generic problem with the completion system, > to wit, special characters like '!' must be quoted in some contexts, > but must not be in other contexts. You'd find the same issue with an > alias containing an asterisk, question mark, etc. > > The following makes this work more of the time in the specific case of > alias expansion, but introduces what might be described as the inverse > problem. That is, after the patch below, > > % gc\! > > will expand with _expand_alias, because the backslash is incorrectly > removed prior to looking up the alias. There's no compstate value or > the like to indicate that the original string on the line contained a > backslash that shouldn't be removed. (Examining $words[CURRENT] may > be a way around this, I haven't worked that out.) > > Incidentally: Running "compinit" binds ^Xa to _expand_alias for you. > > > diff --git a/Completion/Base/Completer/_expand_alias b/Completion/Base/Completer/_expand_alias > index 8240e41..9064ce8 100644 > --- a/Completion/Base/Completer/_expand_alias > +++ b/Completion/Base/Completer/_expand_alias > @@ -25,6 +25,8 @@ else > pre=(_main_complete - aliases) > fi > > +[[ "$compstate[quoting]" = (single|double) ]] || word="${(Q)word}" > + > zstyle -s ":completion:${curcontext}:" regular tmp || tmp=yes > case $tmp in > always) sel=r;;