zsh-users
 help / color / mirror / code / Atom feed
* How to get all tagets for rake completion?
@ 2020-12-15 12:57 Jörg Sommer
  2020-12-15 17:12 ` Peter Stephenson
  0 siblings, 1 reply; 13+ messages in thread
From: Jörg Sommer @ 2020-12-15 12:57 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 511 bytes --]

Hi,

I would like to get all targets for the completion of rake arguments. How
can I inject an argument to the targets query call or how to replace it? I
have to pass `-A` to *rake* to get the arguments for the completion.

This doesn't work:

```
zstyle ':completion::complete:rake:*:targets' command 'rake -sTA'
```

Regards Jörg

-- 
The social dynamics of the net are a direct consequence of the fact
that nobody has yet developed a Remote Strangulation Protocol.
            (Larry Wall)

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 269 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How to get all tagets for rake completion?
  2020-12-15 12:57 How to get all tagets for rake completion? Jörg Sommer
@ 2020-12-15 17:12 ` Peter Stephenson
  2020-12-15 21:40   ` Jörg Sommer
  0 siblings, 1 reply; 13+ messages in thread
From: Peter Stephenson @ 2020-12-15 17:12 UTC (permalink / raw)
  To: zsh-users

> On 15 December 2020 at 12:57 Jörg Sommer <joerg@jo-so.de> wrote:
> I would like to get all targets for the completion of rake arguments. How
> can I inject an argument to the targets query call or how to replace it? I
> have to pass `-A` to *rake* to get the arguments for the completion.

Frankly, your best bet is probably just to copy the distributed _rake
function and adapt it, copying it to somewhere early in your $fpath.
You'll see towards the end an extremely complicated line with "-sT" in
the middle --- just change that to "-sTA".

I have a feeling it might be possible to set a style so that the
_call_program helper does something different for you, but I'm not
sure there's any benefit in being too clever here.  The _rake completer
doesn't change very often, I don't think.

(This could be made a style for the _rake completer easily enough,
in fact.)

pws


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How to get all tagets for rake completion?
  2020-12-15 17:12 ` Peter Stephenson
@ 2020-12-15 21:40   ` Jörg Sommer
  2021-03-31  0:10     ` Oliver Kiddle
  0 siblings, 1 reply; 13+ messages in thread
From: Jörg Sommer @ 2020-12-15 21:40 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-users


[-- Attachment #1.1: Type: text/plain, Size: 1188 bytes --]

Peter Stephenson schrieb am Di 15. Dez, 17:12 (+0000):
> > On 15 December 2020 at 12:57 Jörg Sommer <joerg@jo-so.de> wrote:
> > I would like to get all targets for the completion of rake arguments. How
> > can I inject an argument to the targets query call or how to replace it? I
> > have to pass `-A` to *rake* to get the arguments for the completion.
> 
> Frankly, your best bet is probably just to copy the distributed _rake
> function and adapt it, copying it to somewhere early in your $fpath.
> You'll see towards the end an extremely complicated line with "-sT" in
> the middle --- just change that to "-sTA".
> 
> I have a feeling it might be possible to set a style so that the
> _call_program helper does something different for you, but I'm not
> sure there's any benefit in being too clever here.  The _rake completer
> doesn't change very often, I don't think.
> 
> (This could be made a style for the _rake completer easily enough,
> in fact.)

What do you think about the attached commit? Is it fine or should I change
anything?


Jörg

-- 
Was ist das bloß für eine Welt, in der es mehr Mut braucht ehrlich zu
weinen als Stärke vorzutäuschen?

[-- Attachment #1.2: 0001-Completion-_rake-add-zsytle-for-targets-without-desc.patch --]
[-- Type: text/x-diff, Size: 1533 bytes --]

From 640e40dc81833624281f5c146b514417f251b4c3 Mon Sep 17 00:00:00 2001
Message-Id: <640e40dc81833624281f5c146b514417f251b4c3.1608068274.git.joerg@jo-so.de>
From: =?UTF-8?q?J=C3=B6rg=20Sommer?= <joerg@jo-so.de>
Date: Tue, 15 Dec 2020 22:32:46 +0100
Subject: [PATCH] Completion/_rake: add zsytle for targets without description

`rake -T` shows only these targets having a description. But it might be
useful to see all. Allow this with the zsytle setting:

zstyle :completion::complete:rake:argument-rest all-targets true
---
 Completion/Unix/Command/_rake | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Completion/Unix/Command/_rake b/Completion/Unix/Command/_rake
index 8814edaa5..88c25d7cf 100644
--- a/Completion/Unix/Command/_rake
+++ b/Completion/Unix/Command/_rake
@@ -37,7 +37,9 @@ case "$state" in
   ;;
   target)
     local -a targets
-    targets=( ${${(f)"$(_call_program targets $words[1] -sT $opt_args[(I)(-N|--nosearch)] ${(kv)opt_args[(I)(-f|--rakefile)]} 2>/dev/null)"}/(#b)rake ([^ ]##) ##\# (*)/${${match[1]}//:/\\:}:${match[2]:l}} )
+    local all
+    zstyle -t ":completion:${curcontext}" all-targets && all=-A
+    targets=( ${${(f)"$(_call_program targets $words[1] $all -sT $opt_args[(I)(-N|--nosearch)] ${(kv)opt_args[(I)(-f|--rakefile)]} 2>/dev/null)"}/(#b)rake ([^ ]##) ##\# (*)/${${match[1]}//:/\\:}:${match[2]:l}} )
     if (( ! ${targets[(I)rake aborted!]} )) then
       _describe -t targets 'rake target' targets && ret=0
     else
-- 
2.29.2


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 269 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How to get all tagets for rake completion?
  2020-12-15 21:40   ` Jörg Sommer
@ 2021-03-31  0:10     ` Oliver Kiddle
  2021-03-31  7:45       ` Jörg Sommer
  0 siblings, 1 reply; 13+ messages in thread
From: Oliver Kiddle @ 2021-03-31  0:10 UTC (permalink / raw)
  To: Jörg Sommer; +Cc: zsh-users

On 15 Dec, Jörg Sommer wrote:
> > > I would like to get all targets for the completion of rake arguments. How
> > > can I inject an argument to the targets query call or how to replace it? I
> > > have to pass `-A` to *rake* to get the arguments for the completion.

Sorry that this patch didn't receive any attention earlier.

To try to understand this, what is the disadvantage of calling rake with
-A? Does that make it much slower or is it that most users wouldn't want
"uncommented" targets? If they're fully applicable, it may be better to
add the -A without a style. It looks like the descriptions are included
in the rake output so you could separate them out and add matches with
both the commented-targets and uncommented-targets tags.

Incidentally, _rake doesn't seem to complete the -A option so that must
be newish.

> What do you think about the attached commit? Is it fine or should I change
> anything?

When looking up the style, you should include the tag in the context
when one is applicable, so ":completion:${curcontext}:targets" in this
case.

As a general principle, it is better to use a style name that has a
generic meaning. I can't find any existing style along the lines of an
extra-matches, more-matches, allow-slow-generation etc so unless I've
missed one you'd need to invent a suitable one. "all-targets" is too
specific to targets.

Oliver


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How to get all tagets for rake completion?
  2021-03-31  0:10     ` Oliver Kiddle
@ 2021-03-31  7:45       ` Jörg Sommer
  2021-03-31  9:50         ` Oliver Kiddle
  0 siblings, 1 reply; 13+ messages in thread
From: Jörg Sommer @ 2021-03-31  7:45 UTC (permalink / raw)
  To: Oliver Kiddle; +Cc: zsh-users

[-- Attachment #1: Type: text/plain, Size: 2055 bytes --]

Oliver Kiddle schrieb am Mi 31. Mär, 02:10 (+0200):
> On 15 Dec, Jörg Sommer wrote:
> > > > I would like to get all targets for the completion of rake arguments. How
> > > > can I inject an argument to the targets query call or how to replace it? I
> > > > have to pass `-A` to *rake* to get the arguments for the completion.
> 
> Sorry that this patch didn't receive any attention earlier.

No problem. Don't worry.

> To try to understand this, what is the disadvantage of calling rake with
> -A? Does that make it much slower or is it that most users wouldn't want
> "uncommented" targets?

It gives a much huger list and might contain many entries someone will never
use. But I don't know what's common. From my point of view I prefer more
than less.

> Incidentally, _rake doesn't seem to complete the -A option so that must
> be newish.

I found this commit:
https://github.com/ruby/rake/commit/72ac1327d82d85daed68220700ea6873d5b76fe6
from Oct 16, 2012 included in tag rake-0.9.3. I think it's old enough the be
seen as commonly available.

> > What do you think about the attached commit? Is it fine or should I change
> > anything?
> 
> When looking up the style, you should include the tag in the context
> when one is applicable, so ":completion:${curcontext}:targets" in this
> case.

Ah, okay. I must admit, I've never used zsytle queries before. I would make
this change, right?

-    zstyle -t ":completion:${curcontext}" all-targets && all=-A
+    zstyle -t ":completion:${curcontext}:targets" all-targets && all=-A

> As a general principle, it is better to use a style name that has a
> generic meaning. I can't find any existing style along the lines of an
> extra-matches, more-matches, allow-slow-generation etc so unless I've
> missed one you'd need to invent a suitable one. "all-targets" is too
> specific to targets.

How about ‘verbose’?

-- 
Wer geliebt, kann nicht vergessen,
Wer vergisst, hat nie geliebt,
Wer geliebt und doch vergessen,
Hat vergessen, wie man liebt!

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 269 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How to get all tagets for rake completion?
  2021-03-31  7:45       ` Jörg Sommer
@ 2021-03-31  9:50         ` Oliver Kiddle
  2021-04-04  8:28           ` Jörg Sommer
  0 siblings, 1 reply; 13+ messages in thread
From: Oliver Kiddle @ 2021-03-31  9:50 UTC (permalink / raw)
  To: Jörg Sommer; +Cc: zsh-users

Jörg Sommer wrote:
> It gives a much huger list and might contain many entries someone will never
> use. But I don't know what's common. From my point of view I prefer more
> than less.

It's certainly arguable that completion matches should be comprehensive.
But having fewer can be more useful. Perhaps consider including them by
default and having a style to filter them.

> Ah, okay. I must admit, I've never used zsytle queries before. I would make
> this change, right?
>
> -    zstyle -t ":completion:${curcontext}" all-targets && all=-A
> +    zstyle -t ":completion:${curcontext}:targets" all-targets && all=-A

Exactly.

> > As a general principle, it is better to use a style name that has a
> > generic meaning. I can't find any existing style along the lines of an
> > extra-matches, more-matches, allow-slow-generation etc so unless I've
> > missed one you'd need to invent a suitable one. "all-targets" is too
> > specific to targets.
>
> How about ‘verbose’?

The existing `verbose` style is usually used to conditionally add
descriptions to matches, especially where generating those descriptions
is slow or where they're of questionable value.

One existing style that adds additional matches is `use-ip` to add
IP addresses with hostnames. I don't really like "use" here but
`use-uncommented` would fit with that.

There are a few that do the converse – disable matches. `ignore-line`,
`ignore-parents`, `ignore-patterns`. An `ignore-uncommented` or
`ignore-undescribed` would fit in with those. But the sense is the
converse which may need different lookup code and perhaps implies the
opposite default. That could even be implemented from _describe itself.
Is rake -A giving you a fallback, e.g. "unknown" description for the
extra targets or does the description remain blank?

Oliver


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How to get all tagets for rake completion?
  2021-03-31  9:50         ` Oliver Kiddle
@ 2021-04-04  8:28           ` Jörg Sommer
  2021-04-08 21:51             ` Oliver Kiddle
  0 siblings, 1 reply; 13+ messages in thread
From: Jörg Sommer @ 2021-04-04  8:28 UTC (permalink / raw)
  To: Oliver Kiddle; +Cc: zsh-users

[-- Attachment #1: Type: text/plain, Size: 1267 bytes --]

Oliver Kiddle schrieb am Mi 31. Mär, 11:50 (+0200):
> Jörg Sommer wrote:
> > > As a general principle, it is better to use a style name that has a
> > > generic meaning. I can't find any existing style along the lines of an
> > > extra-matches, more-matches, allow-slow-generation etc so unless I've
> > > missed one you'd need to invent a suitable one. "all-targets" is too
> > > specific to targets.
> >
> > How about ‘verbose’?
> 
> The existing `verbose` style is usually used to conditionally add
> descriptions to matches, especially where generating those descriptions
> is slow or where they're of questionable value.

And how about ‘expanded’ or ‘extended’?

> Is rake -A giving you a fallback, e.g. "unknown" description for the
> extra targets or does the description remain blank?

The description remains blank. It looks like this:

```
rake www/dev/files/main.min.css  # min.css files depend on there js file
rake www/dev/files/main.min.js   # The .js file depends on the sources from .js.map / The .min.js fil...
rake www/dev/files/rss           # Build main rss file
rake www/dev/files/sync.html     # 
rake www/dev/nginx.cfg           # 
```

Regards Jörg

-- 
Du hast keine Chance – also nutze sie.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 269 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How to get all tagets for rake completion?
  2021-04-04  8:28           ` Jörg Sommer
@ 2021-04-08 21:51             ` Oliver Kiddle
  2021-04-12  8:07               ` Jörg Sommer
  0 siblings, 1 reply; 13+ messages in thread
From: Oliver Kiddle @ 2021-04-08 21:51 UTC (permalink / raw)
  To: Jörg Sommer; +Cc: zsh-users

On 4 Apr, Jörg Sommer wrote:
> > The existing `verbose` style is usually used to conditionally add
> > descriptions to matches, especially where generating those descriptions
> > is slow or where they're of questionable value.
>
> And how about ‘expanded’ or ‘extended’?

Either of those are fine. Though you've not commented on the approach of
inverting the sense of the style and using ignore-<something> which I
think I prefer but I don't know rake so well.

Just pick whatever you think is best and update the patch with that and
it should then be good to commit.

> > Is rake -A giving you a fallback, e.g. "unknown" description for the
> > extra targets or does the description remain blank?
>
> The description remains blank. It looks like this:

> rake www/dev/files/rss           # Build main rss file
> rake www/dev/files/sync.html     # 

Checking the targets=( ... ) assignment and _describe with that appears
to work fine without any further adjustment.

Oliver


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How to get all tagets for rake completion?
  2021-04-08 21:51             ` Oliver Kiddle
@ 2021-04-12  8:07               ` Jörg Sommer
  2021-04-25 16:34                 ` Lawrence Velázquez
  0 siblings, 1 reply; 13+ messages in thread
From: Jörg Sommer @ 2021-04-12  8:07 UTC (permalink / raw)
  To: Oliver Kiddle; +Cc: zsh-users


[-- Attachment #1.1: Type: text/plain, Size: 1140 bytes --]

Oliver Kiddle schrieb am Do 08. Apr, 23:51 (+0200):
> On 4 Apr, Jörg Sommer wrote:
> > > The existing `verbose` style is usually used to conditionally add
> > > descriptions to matches, especially where generating those descriptions
> > > is slow or where they're of questionable value.
> >
> > And how about ‘expanded’ or ‘extended’?
> 
> Either of those are fine. Though you've not commented on the approach of
> inverting the sense of the style and using ignore-<something> which I
> think I prefer but I don't know rake so well.

I think rake is like make and I guess they show the uncommended tasks only
with `-A` for the same reason as make can have many internal targets they
aren't of any external use. I would choose the approach of enabling the
additional output which matches the behaviour of rake.

> Just pick whatever you think is best and update the patch with that and
> it should then be good to commit.

So here it is.

Regards Jörg

-- 
„Gesundheit ist dasjenige Maß an Krankheit, das es mir noch erlaubt,
meinen wesentlichen Beschäftigungen nachzugehen.“ (Friedrich Nietzsche)

[-- Attachment #1.2: 0001-Completion-_rake-add-zsytle-for-targets-without-desc.patch --]
[-- Type: text/x-diff, Size: 1543 bytes --]

From 6ba3068957f3ba555f6290f31abd07ada36cd237 Mon Sep 17 00:00:00 2001
Message-Id: <6ba3068957f3ba555f6290f31abd07ada36cd237.1618214528.git.joerg@jo-so.de>
From: =?UTF-8?q?J=C3=B6rg=20Sommer?= <joerg@jo-so.de>
Date: Tue, 15 Dec 2020 22:32:46 +0100
Subject: [PATCH] Completion/_rake: add zsytle for targets without description

`rake -T` shows only these targets having a description. But it might be
useful to see all. Allow this with the zsytle setting:

zstyle :completion::complete:rake:argument-rest:targets extended true
---
 Completion/Unix/Command/_rake | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Completion/Unix/Command/_rake b/Completion/Unix/Command/_rake
index 8814edaa5..10d621991 100644
--- a/Completion/Unix/Command/_rake
+++ b/Completion/Unix/Command/_rake
@@ -37,7 +37,9 @@ case "$state" in
   ;;
   target)
     local -a targets
-    targets=( ${${(f)"$(_call_program targets $words[1] -sT $opt_args[(I)(-N|--nosearch)] ${(kv)opt_args[(I)(-f|--rakefile)]} 2>/dev/null)"}/(#b)rake ([^ ]##) ##\# (*)/${${match[1]}//:/\\:}:${match[2]:l}} )
+    local all
+    zstyle -t ":completion:${curcontext}:targets" extended && all=-A
+    targets=( ${${(f)"$(_call_program targets $words[1] $all -sT $opt_args[(I)(-N|--nosearch)] ${(kv)opt_args[(I)(-f|--rakefile)]} 2>/dev/null)"}/(#b)rake ([^ ]##) ##\# (*)/${${match[1]}//:/\\:}:${match[2]:l}} )
     if (( ! ${targets[(I)rake aborted!]} )) then
       _describe -t targets 'rake target' targets && ret=0
     else
-- 
2.31.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 269 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How to get all tagets for rake completion?
  2021-04-12  8:07               ` Jörg Sommer
@ 2021-04-25 16:34                 ` Lawrence Velázquez
  2021-05-02 16:52                   ` Lawrence Velázquez
  0 siblings, 1 reply; 13+ messages in thread
From: Lawrence Velázquez @ 2021-04-25 16:34 UTC (permalink / raw)
  To: zsh-users; +Cc: Jörg Sommer

On Mon, Apr 12, 2021, at 4:07 AM, Jörg Sommer wrote:
> Oliver Kiddle schrieb am Do 08. Apr, 23:51 (+0200):
> > Just pick whatever you think is best and update the patch with that and
> > it should then be good to commit.
> 
> So here it is.

ping for review/commit

vq


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How to get all tagets for rake completion?
  2021-04-25 16:34                 ` Lawrence Velázquez
@ 2021-05-02 16:52                   ` Lawrence Velázquez
  2021-05-09 17:32                     ` Lawrence Velázquez
  0 siblings, 1 reply; 13+ messages in thread
From: Lawrence Velázquez @ 2021-05-02 16:52 UTC (permalink / raw)
  To: zsh-users; +Cc: Jörg Sommer

On Sun, Apr 25, 2021, at 12:34 PM, Lawrence Velázquez wrote:
> On Mon, Apr 12, 2021, at 4:07 AM, Jörg Sommer wrote:
> > Oliver Kiddle schrieb am Do 08. Apr, 23:51 (+0200):
> > > Just pick whatever you think is best and update the patch with that and
> > > it should then be good to commit.
> > 
> > So here it is.
> 
> ping for review/commit

reping

vq


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How to get all tagets for rake completion?
  2021-05-02 16:52                   ` Lawrence Velázquez
@ 2021-05-09 17:32                     ` Lawrence Velázquez
  2021-05-10 12:14                       ` Daniel Shahaf
  0 siblings, 1 reply; 13+ messages in thread
From: Lawrence Velázquez @ 2021-05-09 17:32 UTC (permalink / raw)
  To: zsh-users; +Cc: Jörg Sommer

On Sun, May 2, 2021, at 12:52 PM, Lawrence Velázquez wrote:
> On Sun, Apr 25, 2021, at 12:34 PM, Lawrence Velázquez wrote:
> > On Mon, Apr 12, 2021, at 4:07 AM, Jörg Sommer wrote:
> > > Oliver Kiddle schrieb am Do 08. Apr, 23:51 (+0200):
> > > > Just pick whatever you think is best and update the patch with that and
> > > > it should then be good to commit.
> > > 
> > > So here it is.
> > 
> > ping for review/commit
> 
> reping

ping the third

-- 
vq


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How to get all tagets for rake completion?
  2021-05-09 17:32                     ` Lawrence Velázquez
@ 2021-05-10 12:14                       ` Daniel Shahaf
  0 siblings, 0 replies; 13+ messages in thread
From: Daniel Shahaf @ 2021-05-10 12:14 UTC (permalink / raw)
  To: Lawrence Velázquez, Oliver Kiddle; +Cc: zsh-users, Jörg Sommer

Lawrence Velázquez wrote on Sun, May 09, 2021 at 13:32:29 -0400:
> On Sun, May 2, 2021, at 12:52 PM, Lawrence Velázquez wrote:
> > On Sun, Apr 25, 2021, at 12:34 PM, Lawrence Velázquez wrote:
> > > On Mon, Apr 12, 2021, at 4:07 AM, Jörg Sommer wrote:
> > > > Oliver Kiddle schrieb am Do 08. Apr, 23:51 (+0200):
> > > > > Just pick whatever you think is best and update the patch with that and
> > > > > it should then be good to commit.
> > > > 
> > > > So here it is.
> > > 
> > > ping for review/commit
> > 
> > reping
> 
> ping the third

Thanks for the pings, Lawrence, and for the patience, Jörg.  I think
Oliver's plate has been full with exim and rspamd work behind the
scenes.  Oliver, should someone else take over reviewing here?  Sounds
like you've already done 99% of the review work and it'd be easier for
you to finish it, if you have time of course.

Cheers,

Daniel


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-05-10 12:15 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-15 12:57 How to get all tagets for rake completion? Jörg Sommer
2020-12-15 17:12 ` Peter Stephenson
2020-12-15 21:40   ` Jörg Sommer
2021-03-31  0:10     ` Oliver Kiddle
2021-03-31  7:45       ` Jörg Sommer
2021-03-31  9:50         ` Oliver Kiddle
2021-04-04  8:28           ` Jörg Sommer
2021-04-08 21:51             ` Oliver Kiddle
2021-04-12  8:07               ` Jörg Sommer
2021-04-25 16:34                 ` Lawrence Velázquez
2021-05-02 16:52                   ` Lawrence Velázquez
2021-05-09 17:32                     ` Lawrence Velázquez
2021-05-10 12:14                       ` Daniel Shahaf

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