zsh-users
 help / color / mirror / 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; 3+ 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] 3+ 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; 3+ 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] 3+ 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
  0 siblings, 0 replies; 3+ 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] 3+ messages in thread

end of thread, other threads:[~2020-12-15 21:41 UTC | newest]

Thread overview: 3+ 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

zsh-users

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/zsh-users

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 zsh-users zsh-users/ http://inbox.vuxu.org/zsh-users \
		zsh-users@zsh.org
	public-inbox-index zsh-users

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.users


code repositories for the project(s) associated with this inbox:

	https://git.vuxu.org/mirror/zsh/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git