Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,
	T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1458343249; bh=sbAMryICqSxqFqFuYyyRSQtzqkvQm2JDD5Kgy9SM1Zw=; h=In-reply-to:From:References:To:Subject:Date:From:Subject; b=fstVLJMJlmfUT6C/lLHBHzz1op95jPQSsF39cs6VLdno9v8Y8w2WnBADO+U4+jhfnijnBbt3ngxEnTwzM8PuFtZQUFEuYf4L4eZmeYxRjikFAEWsTs3AQeQLlwpqhRcWS65tWTGOTFnT4hNzdtreUv5QYRAhKiDrfW26sxF09C9uXyijSIS2sHHsKg8GNS+pehSIDy41VQX9Kg3r6MsDVQQlc2bWIvIxvRtXGMU4qk8bCf/cNaU0BBhnQn1ztDk+Qf8FHzbeTf0eFkmv1R5+la7n0NnrLSbNYxO/y//jdw04KTYgzZdfGbf4OjbwVseNPLW94yObuyUxLkNjxx1xvQ==
X-Yahoo-Newman-Id: 162474.23881.bm@smtp129.mail.ir2.yahoo.com
X-Yahoo-Newman-Property: ymail-3
X-YMail-OSG: KUWNqMUVM1n_.UNyvkMA2Wkq4meD.doVqD38YisxUBUj5dm
 pf3YQD3_q3KH5LWExDGRey1MhPMTLhYeEAU5c4aDj.u0bD6Wo9US90aiu7cU
 SRqSMNTKi8eJLjr8.BsGs3Q9dPtP0AG9fsTC9I98WYdMKrbi3wLOb_MjBKhZ
 snK92KNRqkx8ykpiJotYcromwuWsgrhy5QT2zjo4Te8SrR8UZPXi651CdWkd
 kHY6FgSteSG5KRay0tsfYjlhPYi86RCZmXHR3zKcEJJNGuPzX5vDGda1J7kz
 bZXEpf4CCQnWyYbKOf9dcy2WQClK2oYsGKBqUDSkyQW.wu__vJtMqVQ.gmsK
 qCm94jv5mn2tvJx5IsPjGe747pmUvOts5HsBZJxkkQz5UMWJyN8F6jIzFsIF
 2RuezYTF4laEs_LAbgNzgVXWU7G2MWBdYJx.HIVjNaHlTtZqIrifOOXTFoaB
 .Wms_CzwzXeDYX8gL6jbJImtiPCK.bvuqqwBK332ECgPzwB4lQJF2p02VSlq
 HzvFAsMcCqxSxJA7.Y_eFv41nBmt1HA--
X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI-
In-reply-to: <1458317336-27434-1-git-send-email-mikachu@gmail.com>
From: Oliver Kiddle <okiddle@yahoo.co.uk>
References: <1458317336-27434-1-git-send-email-mikachu@gmail.com>
To: zsh-workers@zsh.org
Subject: Re: PATCH: Fix "35531: fallback on file completion"
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <31051.1458343015.1@thecus.kiddle.eu>
Date: Sat, 19 Mar 2016 00:20:47 +0100
Message-ID: <31107.1458343247@thecus.kiddle.eu>
X-Seq: zsh-workers 38183

Mikael Magnusson wrote:
> The above commit just changed a bunch of stuff without testing, the
> result was that the completer didn't work. It now works, to an extent.

Specifically, in what way didn't it work?

Testing will have been limited because I don't have any device adb could
connect to (still using an ancient Nokia) and I don't typically use or
install it. There's a different adb command on Solaris which is perhaps
why I was annoyed at it not falling back to default file completion.

> The one remaining caveat is that if you enter a subcommand the completer
> doesn't recognize, it will go on to offer subcommands instead of falling
> back to _default. I'm not sure what it's trying to do with the
> "sanitize context" stuff, or "shift words" etc which just makes the rest
> of the code not know where it is, but I don't care enough to rewrite it.

The "sanitize context" stuff was because it was putting the sub-command
into the wrong component of $curcontext. Completion contexts are
supposed to be:
  :completion:<function>:<completer>:<command>:<arg>:<tag>

We typically put subcommands into <command> by changing it to
<command>-<subcommand>. If you use a colon instead of a dash, the
subcommand will be in <arg> and thereafter, everything gets messed up.

> -(( $+functions[_adb_check_log_redirect] )) ||
> +(( $+functions[adb_check_log_redirect] )) ||
>  _adb_check_log_redirect () {

Are you sure you want to back that out?
I'm not actually fond of these guards on function definitions myself
because they prevent the function from being reloaded when the
underlying file in $fpath is modified and reloaded. I only use them in
cases where it seems likely that someone would want to override the
function.

> -  LOG_REDIRECT=${$(adb ${=ADB_DEVICE_SPECIFICATION} shell getprop log.redirect-stdio 2>/dev/null)//
> +  LOG_REDIRECT=${$(adb ${=ADB_DEVICE_SPECIFICATION} shell getprop log.redirect-stdio)//
>  /}

This should really be using _call_program but I'm sure I redirected
stderr for a reason. It was probably spewing out errors to the terminal
because it couldn't find an attached device.

I also don't really like _adb being chatty with lots of _message -r
calls. I tend to prefer completion functions to just do the best they
can of generating matches and otherwise keep quiet.

Oliver

