Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: One small step towards making ~[foo]<tab> work
- X-seq: zsh-workers 35515
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: PATCH: One small step towards making ~[foo]<tab> work
- Date: Thu, 18 Jun 2015 13:28:16 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=xdn4YbVp9soOHtKDnS5l4y8dsAf4IzOUSmkmmmvzrtU=; b=oYoMqq7ijhHIRvZXvb5c+iXwfMP/KqeZ6//4mGmxHz5NPaPvimRbYJbbMl0kBtVJH1 6uUpO86bkK+Y0i2qbydq/U5Dy80QeVyrMPk2OIzu7T0lWB6H+XMVtVupFRHUAJzmoJFZ 3/Qn4ofVr+7xAL8hQhsPaByhabMCmeZ9/nRLqE8YPEfPRTDio8yfeICOWpaG/Kr1nOKB 1EXBNbQdHnqLq+v/JAX9A34hNoZYVXasM+8hG3cSd9LgnAA6vA4s9y73nJTGGJRPowqN o4fHpr9iQfh5A1mX6FAgjw2n1iQEW6x6Qd2knn1y0Z6s3JTuPQjl4tAkCGyAqZRQh5nd CvQA==
- In-reply-to: <CAHYJk3S86hsRBcLAbGdKbQtUjCw+GyHHUG+cPFoj-11sr5DNLg@mail.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: <CAHYJk3S86hsRBcLAbGdKbQtUjCw+GyHHUG+cPFoj-11sr5DNLg@mail.gmail.com>
I'm not sure if the first hunk does anything useful, because I'm unable
to make much else after that work yet. The second hunk at least makes it
so ~[foo/]/ tries ~[foo/] as the prefix instead of ~[foo. This results
in ~[m48/]<tab> completing to files inside the directory I want but,
it lists it as "corrections (errors: 1)". Doing ~[m48/]/<tab> produces a
"no match" error.
~[m48]<tab> still produces nonsense results like ~man ~messagebus etc,
I guess it thinks [m48] is a character class. I don't know where to hook
into that properly to redirect it to _path_files(?).
(The %%]*] is not strictly correct, zsh currently accepts
~[foo]blabla/hello as an expansion to bazblabla/hello if ~[foo] expands
to baz, which is possibly not something we should allow. It feels weird
anyway).
---
Completion/Base/Completer/_expand | 1 +
Completion/Unix/Type/_path_files | 7 ++++++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/Completion/Base/Completer/_expand b/Completion/Base/Completer/_expand
index 3c76e13..1c25238 100644
--- a/Completion/Base/Completer/_expand
+++ b/Completion/Base/Completer/_expand
@@ -45,6 +45,7 @@ if [[ "$tmp" != (yes|true|on|1) ]]; then
{ [[ "$word" = \~(|[-+]) ||
( "$word" = \~[-+][1-9]## && $word[3,-1] -le $#dirstack ) ]] && return 1 }
{ [[ ( "$word" = \~* && ${#userdirs[(I)${word[2,-1]}*]}+${#nameddirs[(I)${word[2,-1]}*]} -gt 1 ) ||
+ ( "$word" = \~\[* ) ||
( "$word" = *\$[a-zA-Z0-9_]## &&
${#parameters[(I)${word##*\$}*]} -ne 1 ) ]] && continue=1 }
[[ continue -eq 1 && "$tmp" != continue ]] && return 1
diff --git a/Completion/Unix/Type/_path_files b/Completion/Unix/Type/_path_files
index fc5bdac..f51db4a 100644
--- a/Completion/Unix/Type/_path_files
+++ b/Completion/Unix/Type/_path_files
@@ -283,7 +283,12 @@ elif [[ "$pre[1]" = \~ && -z "$compstate[quote]" ]]; then
# paths and make sure that the loop below is run only once with an empty
# prefix path by setting `prepaths'.
- linepath="${pre[2,-1]%%/*}"
+ linepath="${pre[2,-1]}"
+ if [[ "$linepath" = \[* ]]; then
+ linepath="${linepath%%]*}]"
+ else
+ linepath="${linepath%%/*}"
+ fi
if [[ -z "$linepath" ]]; then
realpath="${HOME%/}/"
elif [[ "$linepath" = ([-+]|)[0-9]## ]]; then
--
2.4.0
Messages sorted by:
Reverse Date,
Date,
Thread,
Author