From: Mikael Magnusson <mikachu@gmail.com>
To: zsh-workers@zsh.org
Subject: PATCH: One small step towards making ~[foo]<tab> work
Date: Thu, 18 Jun 2015 13:28:16 +0200 [thread overview]
Message-ID: <1434626896-18641-1-git-send-email-mikachu@gmail.com> (raw)
In-Reply-To: <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
next prev parent reply other threads:[~2015-06-18 11:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-07 10:32 _expand with dynamic named directories (and other issue) Mikael Magnusson
2015-06-18 11:28 ` Mikael Magnusson [this message]
2015-06-18 11:38 ` PATCH: One small step towards making ~[foo]<tab> work Mikael Magnusson
2015-06-20 2:48 ` PATCH: Step two seems to take us there Mikael Magnusson
2015-06-20 17:03 ` Peter Stephenson
2015-06-20 17:11 ` Mikael Magnusson
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=1434626896-18641-1-git-send-email-mikachu@gmail.com \
--to=mikachu@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).