zsh-workers
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: Oliver Kiddle <okiddle@yahoo.co.uk>
Cc: zsh workers <zsh-workers@zsh.org>
Subject: Re: PATCH: Fix "35531: fallback on file completion"
Date: Sat, 19 Mar 2016 02:13:02 +0100	[thread overview]
Message-ID: <CAHYJk3RQMAqs89BvX19FW3PxR=ddbERYy=NG+AgGBn0dXK2=fA@mail.gmail.com> (raw)
In-Reply-To: <31107.1458343247@thecus.kiddle.eu>

On Sat, Mar 19, 2016 at 12:20 AM, Oliver Kiddle <okiddle@yahoo.co.uk> wrote:
> 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?

Every completion after "adb anything <tab>" only completed files.

> 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 () {
>
>> -  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.
>
> Are you sure you want to back that out?

No, I removed those hunks from the commit before pushing, included in
the sent diff by mistake.

> 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.
>
> 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.

Yeah, there's some really questionable code in there, and lots of
superfluous double quotes that end up in displayed descriptions. (like
for i in $(ls -d /*)). Someone just complained earlier that the
completer broke, and since reverting this commit fixed it, I spent
some time to get file completion after unhandled subcommands and
working completion after handled subcommands. I didn't really spend
any time looking into why the changed code didn't work, sorry. If you
have any theories about it, I'd be happy to try them out though.

-- 
Mikael Magnusson


  reply	other threads:[~2016-03-19  1:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-18 16:08 Mikael Magnusson
2016-03-18 16:11 ` Mikael Magnusson
2016-03-18 23:20 ` Oliver Kiddle
2016-03-19  1:13   ` Mikael Magnusson [this message]
2016-03-19  5:56     ` Oliver Kiddle
2016-03-19 12:36       ` PATCH: _adb: fix remote file completion + various fixes 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='CAHYJk3RQMAqs89BvX19FW3PxR=ddbERYy=NG+AgGBn0dXK2=fA@mail.gmail.com' \
    --to=mikachu@gmail.com \
    --cc=okiddle@yahoo.co.uk \
    --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).