zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: dana <dana@dana.is>
Cc: Amyn Bennamane <amynbe@gmail.com>,
	"zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Re: Git-add completion should show full file paths
Date: Mon, 27 Apr 2020 21:35:28 -0700	[thread overview]
Message-ID: <CAH+w=7bJT2C6u+4q7Q_+eqyJTqFhEsNmzHHOt2BxzEAf6y+9=Q@mail.gmail.com> (raw)
In-Reply-To: <585FABCB-9B6A-47F8-886E-B24E359F8F51@dana.is>

On Mon, Apr 27, 2020 at 12:24 PM dana <dana@dana.is> wrote:
>
> I guess what Daniel is suggesting is basically an on/off switch for
> _multi_parts's intended function, and you can turn it off for git if you want.

That seems a bit off the mark to me?  Wouldn't the right approach here
be to call something OTHER THAN _multi_parts if you don't want the
strings treated as having multiple parts?

More specifically, _git_files already has the whole list in the $files
array, so instead of running
  _wanted $tag expl $description _multi_parts -f $compadd_opts - / files
it could instead just do
  _wanted $tag expl $description compadd -f $compadd_opts $files
(probably with some cleanup of subtleties I've ignored).

> I wonder if it could be more intelligent though — maybe this style could take
> an integer that acts as a threshold for whether it should work the normal way
> or the 'dumb' way? Like if there are more than x files with the same prefix or
> whatever. Not sure how you'd calculate it, but something like that.

That could be put into a wrapper function around the two possible
_wanted calls above, if it were desirable to have it somewhere other
than in _git_files.  Things do get a bit tricky if you're not passing
the -f option to compadd; you need something, other than the file
system, to which to compare the original strings.

> Also, whether it's like that or just a boolean, it seems like you'd also need
> to consider how recursive completion should work, or if it should, in the
> 'dumb' case. I think users are accustomed to being able to expand like
> f/b/b<TAB> -> foo/bar/baz with file paths

I think you'd just need to fall back on "_wanted _multi_parts" when
"_wanted compadd" didn't add anything.

  reply	other threads:[~2020-04-28  4:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-26 22:57 Amyn Bennamane
2020-04-27 19:25 ` dana
2020-04-28  4:35   ` Bart Schaefer [this message]
2020-04-28 18:01     ` Daniel Shahaf
2020-04-29  3:42       ` Bart Schaefer
2020-04-29  9:21         ` Daniel Shahaf

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='CAH+w=7bJT2C6u+4q7Q_+eqyJTqFhEsNmzHHOt2BxzEAf6y+9=Q@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=amynbe@gmail.com \
    --cc=dana@dana.is \
    --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).