zsh-workers
 help / color / mirror / code / Atom feed
From: Frank Terbeck <ft@bewatermyfriend.org>
To: "Johan Sundström" <oyasumi@gmail.com>
Cc: zsh workers <zsh-workers@zsh.org>,  Nikolai Weibull <now@bitwi.se>
Subject: Re: PATCH: Fall back to file completion if nothing else works
Date: Tue, 28 Jun 2011 07:17:41 +0200	[thread overview]
Message-ID: <87d3hywn4a.fsf@ft.bewatermyfriend.org> (raw)
In-Reply-To: <BANLkTikpp01honaQfpX04OQF3znDaUg_6A@mail.gmail.com> ("Johan =?utf-8?Q?Sundstr=C3=B6m=22's?= message of "Mon, 27 Jun 2011 19:03:54 -0700")

Johan Sundström wrote:
> On Mon, Jun 27, 2011 at 14:55, Frank Terbeck <ft@bewatermyfriend.org> wrote:
>
>> Some people have for third party add-ons to git. `annex' is one such
>> add-on. Currently "git annex add <tab>" does nothing, because there is
>> no special subcommand handling function.
>>
>> _git should really fallback to file name completion in such cases. This
>> patch does exactly that.
>>
>
> -0. As I read this, you're proposing going from 0 (or close to it?) to an
> unbounded number of completion false positives.
>
> Before such a patch, you can be sure that git <anything> <tab> will complete
> something that is legal in this spot: a tag or branch name, for instance, a
> file which has not yet been added to the index, a flag for this command, et
> cetera.
>
> After it, one can never know whether zsh completed a filename because that
> particular filename was legal in this context, or just because it didn't
> know how to complete something in the given context – the completion could
> be super smart, but it wouldn't be possible to tell, since you can't know if
> a completion was legal without knowing git inside and out, or from running
> the command line.

What? Non sense.

I don't know how you understood the code, but

  zsh% git an-existing-known-subcommand <tab>

will *never* run into this fall back and complete file names, because
the subcommand completion function for `an-existing-known-subcommand'
will know what to do. The *only* thing this does is to fall back to file
name completion when _git doesn't know the subcommand in question.

Doing noting in that spot is entirely useless. And that's what's
happening with the current code.

Also, the old _git did fall back to file completion, too, after
zsh-workers-28411 <http://www.zsh.org/mla/workers/2010/msg00855.html>,
because offering file names when you don't know any better is vastly
more useful than just sitting on your hands doing nothing.

I'm pretty sure changing this behaviour was an unintended oversight when
Nikolai rewrote `_git'.


>> I'm wondering how we should handle third party add ons to commands. _git
>> used provide the `user-commands' style to do stuff like this:
>>
>>    % zstyle ':completion:*:*:git:*' user-commands foo:'description for foo'
>>
>> You could even define `_git-foo()' to have special handling.
>>
>
> I think that sounds like a better way to enable the behaviour you seek, for
> people that specifically want it.

No, it's not.  The behaviour I really want is for _git to accept real
completion add ons. The problem with the `user-commands' commands style
is, that add-ons can't really use it because they will never know which
style to add their description to.

You can already defined `_git-foo()' and it'll be picked up as a
sub-command completion. So the "git foo <tab>" situation would be
solvable. You'd have to manually load the _git-foo completion file
currently or put #autoload into it. I think _git should handle loading
of _git-* files itself so add-ons just had to drop their completion
somewhere into $fpath.

Then _git could register the command name, too and "git fo<tab>" would
suggest `foo' as well. That way we could also drop my "use `foo' from
git-foo binaries from $path" path.


As for `user-commands': It *was* in the old _git. And I know people who
use it. Throwing away existing functionality without good reason or
telling anybody is just bad behaviour.

Though, I am pretty sure this - again - was just an oversight when
Nikolai rewrote `_git', which was a quite the task on to pull off on his
own. Otherwise he would have removed the comment on top of _git, too.

Regards, Frank

-- 
In protocol design, perfection has been reached not when there is
nothing left to add, but when there is nothing left to take away.
                                                  -- RFC 1925


  reply	other threads:[~2011-06-28  5:28 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-27 21:55 Frank Terbeck
2011-06-28  2:03 ` Johan Sundström
2011-06-28  5:17   ` Frank Terbeck [this message]
2011-06-29 21:46     ` Johan Sundström
2011-06-29 22:33       ` Frank Terbeck
2011-06-29 20:37 ` PATCH: (0/3) _git fixes and enhancements Frank Terbeck
2011-06-29 20:37   ` PATCH: (1/3) _git: Fall back to file completion if nothing else works Frank Terbeck
2011-06-29 20:37   ` PATCH: (2/3) _git: Pick up addon completions from $fpath Frank Terbeck
2011-06-29 21:15     ` Frank Terbeck
2011-06-29 20:37   ` PATCH: (3/3) _git: re-add `user-commands' support again Frank Terbeck
2011-07-22 11:54     ` Nikolai Weibull
2011-07-22 11:55     ` Nikolai Weibull
2011-07-22 12:00       ` Frank Terbeck
2011-07-22 12:48         ` Nikolai Weibull
2011-07-22 12:49           ` Frank Terbeck
2011-07-22 13:05             ` Nikolai Weibull
2011-06-29 21:30   ` PATCH: (4/3) _git-buildpackage: use a #desc: line Frank Terbeck
2011-07-20 18:11     ` Nikolai Weibull
2011-07-20 18:22       ` Frank Terbeck
2011-07-22 11:58         ` Nikolai Weibull
2011-07-22 12:01           ` Frank Terbeck
2011-06-30  9:17   ` PATCH: (5/3) _git: Make file-completion fallback optional Frank Terbeck
2011-07-22  9:35     ` Nikolai Weibull
2011-10-27  8:00       ` Nikolai Weibull

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=87d3hywn4a.fsf@ft.bewatermyfriend.org \
    --to=ft@bewatermyfriend.org \
    --cc=now@bitwi.se \
    --cc=oyasumi@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).