From: Bart Schaefer <schaefer@brasslantern.com>
To: Jonathan H <pythonnut@gmail.com>, zsh-workers@zsh.org
Subject: Re: _expand_alias does not expand aliases that contain an "!"
Date: Sat, 30 Aug 2014 13:32:06 -0700 [thread overview]
Message-ID: <140830133206.ZM13172@torch.brasslantern.com> (raw)
In-Reply-To: <CAAW2-Zd65X5_aF0DR0EzX_E26Ji9GAqMV6V4ge4PopMrypJEWw@mail.gmail.com>
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;;
next prev parent reply other threads:[~2014-08-30 20:31 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-26 16:50 Jonathan H
2014-08-30 20:32 ` Bart Schaefer [this message]
2014-08-31 2:58 ` Jonathan H
2014-08-31 20:50 ` Bart Schaefer
2014-09-14 18:30 ` Bart Schaefer
2014-09-14 20:55 ` Bart Schaefer
2014-10-01 14:03 ` Peter Stephenson
2014-10-01 14:06 ` Peter Stephenson
2014-10-01 14:15 ` Peter Stephenson
2014-10-01 16:29 ` Bart Schaefer
2014-10-01 16:39 ` Peter Stephenson
2014-10-02 1:11 ` Bart Schaefer
2014-10-02 5:20 ` Bart Schaefer
2014-09-23 5:59 ` Jonathan H
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=140830133206.ZM13172@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=pythonnut@gmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).