zsh-users
 help / color / mirror / code / Atom feed
* Complete with *part* not part*
@ 2016-02-12 11:48 Sebastian Gniazdowski
  2016-02-12 15:39 ` Mikael Magnusson
  0 siblings, 1 reply; 8+ messages in thread
From: Sebastian Gniazdowski @ 2016-02-12 11:48 UTC (permalink / raw)
  To: Zsh Users

Hello,
when completing, entering "l"<TAB> will complete say "ls", "lsof",
etc.. How to make "s"<TAB> complete ls, lsof, etc. ?

I'm completing long names – names of plugins:
            plugins=( "$ZPLG_PLUGINS_DIR"/*(N:t) )
            _wanted plugins expl "Plugins" \
                compadd "$@" -a - plugins && ret=0

want it be that "part" of plugin names will be completed not only as
part* but also as *part*.

Best regards,
Sebastian Gniazdowski


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

* Re: Complete with *part* not part*
  2016-02-12 11:48 Complete with *part* not part* Sebastian Gniazdowski
@ 2016-02-12 15:39 ` Mikael Magnusson
  2016-02-12 16:01   ` Bart Schaefer
  0 siblings, 1 reply; 8+ messages in thread
From: Mikael Magnusson @ 2016-02-12 15:39 UTC (permalink / raw)
  To: Sebastian Gniazdowski; +Cc: Zsh Users

On Fri, Feb 12, 2016 at 12:48 PM, Sebastian Gniazdowski
<sgniazdowski@gmail.com> wrote:
> Hello,
> when completing, entering "l"<TAB> will complete say "ls", "lsof",
> etc.. How to make "s"<TAB> complete ls, lsof, etc. ?
>
> I'm completing long names – names of plugins:
>             plugins=( "$ZPLG_PLUGINS_DIR"/*(N:t) )
>             _wanted plugins expl "Plugins" \
>                 compadd "$@" -a - plugins && ret=0
>
> want it be that "part" of plugin names will be completed not only as
> part* but also as *part*.

That's something the user configures, not something you put in the
completer. (Which they do with the matcher-list style).

-- 
Mikael Magnusson


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

* Re: Complete with *part* not part*
  2016-02-12 15:39 ` Mikael Magnusson
@ 2016-02-12 16:01   ` Bart Schaefer
  2016-02-12 16:11     ` Sebastian Gniazdowski
  0 siblings, 1 reply; 8+ messages in thread
From: Bart Schaefer @ 2016-02-12 16:01 UTC (permalink / raw)
  To: Zsh Users

On Feb 12,  4:39pm, Mikael Magnusson wrote:
} Subject: Re: Complete with *part* not part*
}
} On Fri, Feb 12, 2016 at 12:48 PM, Sebastian Gniazdowski
} <sgniazdowski@gmail.com> wrote:
} > want it be that "part" of plugin names will be completed not only as
} > part* but also as *part*.
} 
} That's something the user configures, not something you put in the
} completer. (Which they do with the matcher-list style).

Which you do like this:

    zstyle ':completion:*' matcher-list 'r:|=** l:|=*'


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

* Re: Complete with *part* not part*
  2016-02-12 16:01   ` Bart Schaefer
@ 2016-02-12 16:11     ` Sebastian Gniazdowski
  2016-02-12 17:16       ` Bart Schaefer
  2016-02-12 17:19       ` Sebastian Gniazdowski
  0 siblings, 2 replies; 8+ messages in thread
From: Sebastian Gniazdowski @ 2016-02-12 16:11 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh Users

On 12 February 2016 at 17:01, Bart Schaefer <schaefer@brasslantern.com> wrote:
> Which you do like this:
>
>     zstyle ':completion:*' matcher-list 'r:|=** l:|=*'
>

This works.

Want to have this only for "zplugin" and only for its sub-command.
Tried various combinations and none work. Already have working:

zstyle ':completion:*:zplugin:*:argument-rest' list-colors
'=(#b)(*)/(*)==1;35=1;33'

But doing the same or trying more "::" or ":*:" doesn't yield correct
behavior. Ctrl-x h is:

% zplugin load <^x h>
tags in context :completion::complete:zplugin::
    argument-rest  (_arguments _zplugin)

I'm using "_arguments" not "_arguments -C".

Anyway thanks, there for sure is some correct "::" ":*:" sequence for
this to work...

Best regards,
Sebastian Gniazdowski


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

* Re: Complete with *part* not part*
  2016-02-12 16:11     ` Sebastian Gniazdowski
@ 2016-02-12 17:16       ` Bart Schaefer
  2016-02-12 17:29         ` Sebastian Gniazdowski
  2016-02-12 17:19       ` Sebastian Gniazdowski
  1 sibling, 1 reply; 8+ messages in thread
From: Bart Schaefer @ 2016-02-12 17:16 UTC (permalink / raw)
  To: Zsh Users

On Feb 12,  5:11pm, Sebastian Gniazdowski wrote:
} Subject: Re: Complete with *part* not part*
}
} On 12 February 2016 at 17:01, Bart Schaefer <schaefer@brasslantern.com> wrote:
} > Which you do like this:
} >
} >     zstyle ':completion:*' matcher-list 'r:|=** l:|=*'
} 
} This works.
} 
} Want to have this only for "zplugin" and only for its sub-command.

The name is "matcher" when it's a specific tag, "matcher-list" is for
the global setting.  So this should theoretically do it:

zstyle ':completion:*:zplugin:*:argument-rest' matcher 'r:|=** l:|=*'


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

* Re: Complete with *part* not part*
  2016-02-12 16:11     ` Sebastian Gniazdowski
  2016-02-12 17:16       ` Bart Schaefer
@ 2016-02-12 17:19       ` Sebastian Gniazdowski
  1 sibling, 0 replies; 8+ messages in thread
From: Sebastian Gniazdowski @ 2016-02-12 17:19 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh Users

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

I used zplugin/dtrace to catch all zstyle calls performed after
"zplugin load go<TAB>":

https://asciinema.org/a/birc08xq4qa2cbl9zcwvlxvho

I attach the dtrace report. Interesting, there is only:

Zstyle -a :completion::expand::: matcher-list _matchers
Zstyle -a :completion::complete::: matcher-list _matchers
Zstyle -s :completion::complete:zplugin:argument-rest:argument-rest
matcher match
Zstyle -s :completion::complete:zplugin::plugins matcher match
Zstyle -a :completion::ignored::: matcher-list _matchers

There isn't something analogous to list-colors zstyle:

Zstyle -a :completion::complete:zplugin:argument-rest:argument-rest
list-colors val

Will I be able to target the matcher-list zstyle at
":completion::complete:zplugin:argument-rest:" if there is no test for
this zstyle during operations triggered by <TAB>?

Best regards,
Sebastian Gniazdowski

[-- Attachment #2: report_less_R.txt --]
[-- Type: text/plain, Size: 5583 bytes --]

Plugin report for^[[00m ^[[01;35m_dtrace^[[00m/^[[01;33m_dtrace^[[00m
^[[01;35m---------------------------------^[[00m
^[[01;32mZstyle^[[00m -s :completion::::: insert-tab tmp
^[[01;32mZstyle^[[00m -a :completion:::::default list-colors val
^[[01;32mZstyle^[[00m -t :completion:::::default list-packed
^[[01;32mZstyle^[[00m -t :completion:::::default list-rows-first
^[[01;32mZstyle^[[00m -t :completion:::::default last-prompt
^[[01;32mZstyle^[[00m -t :completion:::::default accept-exact
^[[01;32mZstyle^[[00m -a :completion:::::default menu val
^[[01;32mZstyle^[[00m -s :completion:::::default force-list val
^[[01;32mZstyle^[[00m -s :completion:::::default list-prompt tmp
^[[01;32mZstyle^[[00m -s :completion:::::default select-prompt tmp
^[[01;32mZstyle^[[00m -s :completion:::::default select-scroll tmp
^[[01;32mZstyle^[[00m -a :completion::::: completer _completers
^[[01;32mZstyle^[[00m -t :completion::expand::: show-completer
^[[01;32mZstyle^[[00m -a :completion::expand::: matcher-list _matchers
^[[01;32mZstyle^[[00m -T :completion::expand::: suffix
^[[01;32mZstyle^[[00m -s :completion::expand::: accept-exact tmp
^[[01;32mZstyle^[[00m -T :completion::expand::: substitute
^[[01;32mZstyle^[[00m -T :completion::expand::: glob
^[[01;32mZstyle^[[00m -t :completion::complete::: show-completer
^[[01;32mZstyle^[[00m -a :completion::complete::: matcher-list _matchers
^[[01;32mZstyle^[[00m -s :completion::complete:zplugin::options auto-description autod
^[[01;32mZstyle^[[00m -a :completion::complete:zplugin:: group-order order
^[[01;32mZstyle^[[00m -a :completion::complete:zplugin:: tag-order order
^[[01;32mZstyle^[[00m -s :completion::complete:zplugin:argument-rest:argument-rest group-name gname
^[[01;32mZstyle^[[00m -a :completion::complete:zplugin:argument-rest:argument-rest list-colors val
^[[01;32mZstyle^[[00m -t :completion::complete:zplugin:argument-rest:argument-rest list-packed
^[[01;32mZstyle^[[00m -t :completion::complete:zplugin:argument-rest:argument-rest list-rows-first
^[[01;32mZstyle^[[00m -t :completion::complete:zplugin:argument-rest:argument-rest last-prompt
^[[01;32mZstyle^[[00m -t :completion::complete:zplugin:argument-rest:argument-rest accept-exact
^[[01;32mZstyle^[[00m -a :completion::complete:zplugin:argument-rest:argument-rest menu val
^[[01;32mZstyle^[[00m -s :completion::complete:zplugin:argument-rest:argument-rest force-list val
^[[01;32mZstyle^[[00m -s :completion::complete:zplugin:argument-rest:argument-rest format format
^[[01;32mZstyle^[[00m -s :completion::complete:zplugin:argument-rest:argument-rest hidden hidden
^[[01;32mZstyle^[[00m -s :completion::complete:zplugin:argument-rest:argument-rest matcher match
^[[01;32mZstyle^[[00m -s :completion::complete:zplugin:argument-rest:argument-rest sort sort
^[[01;32mZstyle^[[00m -s :completion::complete:zplugin:argument-rest: sort sort
^[[01;32mZstyle^[[00m -a :completion::complete:zplugin:argument-rest:argument-rest ignored-patterns _comp_ignore
^[[01;32mZstyle^[[00m -s :completion::complete:zplugin:argument-rest:argument-rest ignore-line hidden
^[[01;32mZstyle^[[00m -a :completion::complete:zplugin:argument-rest:argument-rest fake match
^[[01;32mZstyle^[[00m -a :completion::complete:zplugin:argument-rest:argument-rest fake-always match
^[[01;32mZstyle^[[00m -a :completion::complete:zplugin:: group-order order
^[[01;32mZstyle^[[00m -a :completion::complete:zplugin:: tag-order order
^[[01;32mZstyle^[[00m -s :completion::complete:zplugin::plugins group-name gname
^[[01;32mZstyle^[[00m -a :completion::complete:zplugin::plugins list-colors val
^[[01;32mZstyle^[[00m -t :completion::complete:zplugin::plugins list-packed
^[[01;32mZstyle^[[00m -t :completion::complete:zplugin::plugins list-rows-first
^[[01;32mZstyle^[[00m -t :completion::complete:zplugin::plugins last-prompt
^[[01;32mZstyle^[[00m -t :completion::complete:zplugin::plugins accept-exact
^[[01;32mZstyle^[[00m -a :completion::complete:zplugin::plugins menu val
^[[01;32mZstyle^[[00m -s :completion::complete:zplugin::plugins force-list val
^[[01;32mZstyle^[[00m -s :completion::complete:zplugin::plugins format format
^[[01;32mZstyle^[[00m -s :completion::complete:zplugin::plugins hidden hidden
^[[01;32mZstyle^[[00m -s :completion::complete:zplugin::plugins matcher match
^[[01;32mZstyle^[[00m -s :completion::complete:zplugin::plugins sort sort
^[[01;32mZstyle^[[00m -s :completion::complete:zplugin:: sort sort
^[[01;32mZstyle^[[00m -a :completion::complete:zplugin::plugins ignored-patterns _comp_ignore
^[[01;32mZstyle^[[00m -s :completion::complete:zplugin::plugins ignore-line hidden
^[[01;32mZstyle^[[00m -a :completion::complete:zplugin::plugins fake match
^[[01;32mZstyle^[[00m -a :completion::complete:zplugin::plugins fake-always match
^[[01;32mZstyle^[[00m -t :completion::ignored::: show-completer
^[[01;32mZstyle^[[00m -a :completion::ignored::: matcher-list _matchers
^[[01;32mZstyle^[[00m -s :completion:::::warnings format format
^[[01;32mZstyle^[[00m -a :completion:::::warnings list-colors val
^[[01;32mZstyle^[[00m -t :completion:::::warnings list-packed
^[[01;32mZstyle^[[00m -t :completion:::::warnings list-rows-first
^[[01;32mZstyle^[[00m -t :completion:::::warnings last-prompt
^[[01;32mZstyle^[[00m -t :completion:::::warnings accept-exact
^[[01;32mZstyle^[[00m -a :completion:::::warnings menu val
^[[01;32mZstyle^[[00m -s :completion:::::warnings force-list val
^[[01;32mZstyle^[[00m -s :completion::::: show-ambiguity tmp

^[[01;34mVariables added or redefined:^[[00m
MENUPROMPT        ^[[01;32m[ "" -> scalar ]^[[00m
ZLE_LINE_ABORTED  ^[[01;32m[ "" -> scalar ]^[[00m
ZLS_COLORS        ^[[01;32m[ "" -> scalar ]^[[00m
LISTPROMPT        ^[[01;32m[ "" -> scalar ]^[[00m
expl              ^[[01;32m[ "" -> array  ]^[[00m


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

* Re: Complete with *part* not part*
  2016-02-12 17:16       ` Bart Schaefer
@ 2016-02-12 17:29         ` Sebastian Gniazdowski
  2016-02-12 19:14           ` Bart Schaefer
  0 siblings, 1 reply; 8+ messages in thread
From: Sebastian Gniazdowski @ 2016-02-12 17:29 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh Users

On 12 February 2016 at 18:16, Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Feb 12,  5:11pm, Sebastian Gniazdowski wrote:
> } Want to have this only for "zplugin" and only for its sub-command.
>
> The name is "matcher" when it's a specific tag, "matcher-list" is for
> the global setting.  So this should theoretically do it:
>
> zstyle ':completion:*:zplugin:*:argument-rest' matcher 'r:|=** l:|=*'

Looked at the dtrace output and found this to work:
zstyle ':completion::complete:zplugin::plugins' matcher 'r:|=** l:|=*'

Fine thing the dtrace, huh. I think it reveals some bugs in my
completion design. Should I be using -C for _arguments? Because there
are tests that look bad, double "argument-rest":

Zstyle -s :completion::complete:zplugin:argument-rest:argument-rest
matcher match

Best regards,
Sebastian Gniazdowski


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

* Re: Complete with *part* not part*
  2016-02-12 17:29         ` Sebastian Gniazdowski
@ 2016-02-12 19:14           ` Bart Schaefer
  0 siblings, 0 replies; 8+ messages in thread
From: Bart Schaefer @ 2016-02-12 19:14 UTC (permalink / raw)
  To: Zsh Users

On Feb 12,  6:29pm, Sebastian Gniazdowski wrote:
}
} Fine thing the dtrace, huh. I think it reveals some bugs in my
} completion design. Should I be using -C for _arguments? Because there
} are tests that look bad, double "argument-rest":
} 
} Zstyle -s :completion::complete:zplugin:argument-rest:argument-rest
} matcher match

No, nothing is wrong there.  Remember that the lookup context is of
the format

    :completion:FUNCTION:COMPLETER:COMMAND:ARGUMENT:TAG

So you have COMMAND=zplugin, ARGUMENT=argument-rest, TAG=argument-rest,
which is entirely normal:

   * The ARGUMENT; this indicates which command line or option argument
     we are completing.  For command arguments this generally takes the
     form argument-N, where N is the number of the argument, and for
     arguments to options the form option-OPT-N where N is the number
     of the argument to option OPT.  However, this is only the case if
     the command line is parsed with standard UNIX-style options and
     arguments, so many completions do not set this.

The doc omits the detail that N can be "rest" when all remaining argument
positions are treated the same.

   * The TAG.  As described previously, tags are used to discriminate
     between the types of matches a completion function can generate in
     a certain context.

So you only want -C if there are multiple tags in the argument-rest
context, *and* those tags are differentiated by using the ->state
form of _arguments specification.

The doc goes on:

 The context is gradually put together as the functions are executed,
 starting with the main entry point, which adds :completion: and the
 FUNCTION element if necessary.  The completer then adds the COMPLETER
 element.  The contextual completion adds the COMMAND and ARGUMENT
 options.  Finally, the TAG is added when the types of completion are
 known.

The tag name is actually generated by the "comparguments" builtin in this
case, which was intentionally left under-specified in the user-level doc,
but then developer-level doc for it was never written ...


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

end of thread, other threads:[~2016-02-12 19:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-12 11:48 Complete with *part* not part* Sebastian Gniazdowski
2016-02-12 15:39 ` Mikael Magnusson
2016-02-12 16:01   ` Bart Schaefer
2016-02-12 16:11     ` Sebastian Gniazdowski
2016-02-12 17:16       ` Bart Schaefer
2016-02-12 17:29         ` Sebastian Gniazdowski
2016-02-12 19:14           ` Bart Schaefer
2016-02-12 17:19       ` Sebastian Gniazdowski

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