From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26831 invoked by alias); 18 Jun 2015 11:28:30 -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: 35515 Received: (qmail 28202 invoked from network); 18 Jun 2015 11:28:28 -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.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL 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=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== X-Received: by 10.194.121.163 with SMTP id ll3mr4222489wjb.142.1434626904151; Thu, 18 Jun 2015 04:28:24 -0700 (PDT) From: Mikael Magnusson To: zsh-workers@zsh.org Subject: PATCH: One small step towards making ~[foo] work Date: Thu, 18 Jun 2015 13:28:16 +0200 Message-Id: <1434626896-18641-1-git-send-email-mikachu@gmail.com> X-Mailer: git-send-email 2.4.0 In-Reply-To: References: 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/] completing to files inside the directory I want but, it lists it as "corrections (errors: 1)". Doing ~[m48/]/ produces a "no match" error. ~[m48] 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