zsh-users
 help / color / mirror / code / Atom feed
* completion functions not loaded
@ 2023-02-11 21:18 Pier Paolo Grassi
  2023-02-11 21:27 ` Bart Schaefer
  0 siblings, 1 reply; 16+ messages in thread
From: Pier Paolo Grassi @ 2023-02-11 21:18 UTC (permalink / raw)
  To: Zsh-Users List

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

Hello, there are some completion functions that aren't loaded, it appears.

> functions _systemctl
_systemctl () {
        # undefined
        builtin autoload -XUz
}

systemctl<tab>
the output is from _files

systemctl<ctrl-h>
tags in context :completion::complete:SYSTEMD_PAGER=::
    argument-rest  (_arguments _gnu_generic)
tags in context :completion::complete:SYSTEMD_PAGER=:argument-rest:
    use-compctl    (_default _arguments _gnu_generic)
    globbed-files  (_files _default _arguments _gnu_generic)
tags in context :completion::complete:sudo::
    argument-rest  (_arguments _sudo)

it's not even listed. The completion function is defined in
/usr/share/zsh/vendor-completions

the dir is present in $fpath and other completion function from the same
directory are working correctly.

What can I do to debug the issue?

thanks

Pier Paolo Grassi

[-- Attachment #2: Type: text/html, Size: 1378 bytes --]

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

* Re: completion functions not loaded
  2023-02-11 21:18 completion functions not loaded Pier Paolo Grassi
@ 2023-02-11 21:27 ` Bart Schaefer
  2023-02-11 21:30   ` Pier Paolo Grassi
  2023-02-11 21:31   ` Bart Schaefer
  0 siblings, 2 replies; 16+ messages in thread
From: Bart Schaefer @ 2023-02-11 21:27 UTC (permalink / raw)
  To: Pier Paolo Grassi; +Cc: Zsh-Users List

On Sat, Feb 11, 2023 at 1:19 PM Pier Paolo Grassi <pierpaolog@gmail.com> wrote:
>
> Hello, there are some completion functions that aren't loaded, it appears.
>
> it's not even listed. The completion function is defined in
> /usr/share/zsh/vendor-completions

That means it's provided by the OS zsh package, it's not present in
the zsh source tree.

> What can I do to debug the issue?

Check that the file starts with either

#compdef ...

or

#autoload


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

* Re: completion functions not loaded
  2023-02-11 21:27 ` Bart Schaefer
@ 2023-02-11 21:30   ` Pier Paolo Grassi
  2023-02-11 21:31   ` Bart Schaefer
  1 sibling, 0 replies; 16+ messages in thread
From: Pier Paolo Grassi @ 2023-02-11 21:30 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh-Users List

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

: head /usr/share/zsh/vendor-completions/_systemctl
#compdef systemctl

(( $+functions[_systemctl_command] )) || _systemctl_command()
{
  local -a _systemctl_cmds
  _systemctl_cmds=(
    "list-sockets:List sockets"
    "list-timers:List timers"
    "list-units:List units"
    "start:Start (activate) one or more units"

Pier Paolo Grassi


Il giorno sab 11 feb 2023 alle ore 22:27 Bart Schaefer <
schaefer@brasslantern.com> ha scritto:

> On Sat, Feb 11, 2023 at 1:19 PM Pier Paolo Grassi <pierpaolog@gmail.com>
> wrote:
> >
> > Hello, there are some completion functions that aren't loaded, it
> appears.
> >
> > it's not even listed. The completion function is defined in
> > /usr/share/zsh/vendor-completions
>
> That means it's provided by the OS zsh package, it's not present in
> the zsh source tree.
>
> > What can I do to debug the issue?
>
> Check that the file starts with either
>
> #compdef ...
>
> or
>
> #autoload
>

[-- Attachment #2: Type: text/html, Size: 1657 bytes --]

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

* Re: completion functions not loaded
  2023-02-11 21:27 ` Bart Schaefer
  2023-02-11 21:30   ` Pier Paolo Grassi
@ 2023-02-11 21:31   ` Bart Schaefer
  2023-02-12 17:22     ` Pier Paolo Grassi
  1 sibling, 1 reply; 16+ messages in thread
From: Bart Schaefer @ 2023-02-11 21:31 UTC (permalink / raw)
  To: Pier Paolo Grassi; +Cc: Zsh-Users List

On Sat, Feb 11, 2023 at 1:27 PM Bart Schaefer <schaefer@brasslantern.com> wrote:
>
> > What can I do to debug the issue?
>
> Check that the file starts with either
>
> #compdef ...
>
> or
>
> #autoload

Sorry, accidentally sent too soon.

And that the #compdef line mentions the "systemctl" command.  You can
also check $_comps[systemctl], it's possible that something else
loaded later is replacing it.


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

* Re: completion functions not loaded
  2023-02-11 21:31   ` Bart Schaefer
@ 2023-02-12 17:22     ` Pier Paolo Grassi
  2023-02-12 17:41       ` Bart Schaefer
  0 siblings, 1 reply; 16+ messages in thread
From: Pier Paolo Grassi @ 2023-02-12 17:22 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh-Users List

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

echo $_comps[systemctl]
_systemctl
I think that is the only definition of this function that I have

the strange thing is that it's not autoloaded even if it is scheduled to do
so
is it possibile that some error prevents it from loading?

Pier Paolo Grassi


Il giorno sab 11 feb 2023 alle ore 22:31 Bart Schaefer <
schaefer@brasslantern.com> ha scritto:

> On Sat, Feb 11, 2023 at 1:27 PM Bart Schaefer <schaefer@brasslantern.com>
> wrote:
> >
> > > What can I do to debug the issue?
> >
> > Check that the file starts with either
> >
> > #compdef ...
> >
> > or
> >
> > #autoload
>
> Sorry, accidentally sent too soon.
>
> And that the #compdef line mentions the "systemctl" command.  You can
> also check $_comps[systemctl], it's possible that something else
> loaded later is replacing it.
>
-- 
Pier Paolo Grassi

[-- Attachment #2: Type: text/html, Size: 1696 bytes --]

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

* Re: completion functions not loaded
  2023-02-12 17:22     ` Pier Paolo Grassi
@ 2023-02-12 17:41       ` Bart Schaefer
  2023-02-12 17:52         ` Pier Paolo Grassi
  0 siblings, 1 reply; 16+ messages in thread
From: Bart Schaefer @ 2023-02-12 17:41 UTC (permalink / raw)
  To: Pier Paolo Grassi; +Cc: Zsh-Users List

On Sun, Feb 12, 2023 at 9:23 AM Pier Paolo Grassi <pierpaolog@gmail.com> wrote:
>
> the strange thing is that it's not autoloaded even if it is scheduled to do so
> is it possibile that some error prevents it from loading?

Yes; try
  autoload +X _systemctl


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

* Re: completion functions not loaded
  2023-02-12 17:41       ` Bart Schaefer
@ 2023-02-12 17:52         ` Pier Paolo Grassi
  2023-02-12 18:13           ` Pier Paolo Grassi
  0 siblings, 1 reply; 16+ messages in thread
From: Pier Paolo Grassi @ 2023-02-12 17:52 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh-Users List

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

It doesn't seem to do anything. Even inserting
setopt xtrace

just after #compdef systemctl
in /usr/share/zsh/vendor-completions/_systemctl does not produce any output
when trying to complete the systemctl command after opening a new shell

Pier Paolo Grassi


Il giorno dom 12 feb 2023 alle ore 18:41 Bart Schaefer <
schaefer@brasslantern.com> ha scritto:

> On Sun, Feb 12, 2023 at 9:23 AM Pier Paolo Grassi <pierpaolog@gmail.com>
> wrote:
> >
> > the strange thing is that it's not autoloaded even if it is scheduled to
> do so
> > is it possibile that some error prevents it from loading?
>
> Yes; try
>   autoload +X _systemctl
>

[-- Attachment #2: Type: text/html, Size: 1258 bytes --]

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

* Re: completion functions not loaded
  2023-02-12 17:52         ` Pier Paolo Grassi
@ 2023-02-12 18:13           ` Pier Paolo Grassi
  2023-02-12 18:27             ` Pier Paolo Grassi
  0 siblings, 1 reply; 16+ messages in thread
From: Pier Paolo Grassi @ 2023-02-12 18:13 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh-Users List

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

autoload +X _systemctl

does not produce any output, but it does not gives an error though
but the completion context for systemctl does not change, _systemctl is not
present

Pier Paolo Grassi


Il giorno dom 12 feb 2023 alle ore 18:52 Pier Paolo Grassi <
pierpaolog@gmail.com> ha scritto:

> It doesn't seem to do anything. Even inserting
> setopt xtrace
>
> just after #compdef systemctl
> in /usr/share/zsh/vendor-completions/_systemctl does not produce any output
> when trying to complete the systemctl command after opening a new shell
>
> Pier Paolo Grassi
>
>
> Il giorno dom 12 feb 2023 alle ore 18:41 Bart Schaefer <
> schaefer@brasslantern.com> ha scritto:
>
>> On Sun, Feb 12, 2023 at 9:23 AM Pier Paolo Grassi <pierpaolog@gmail.com>
>> wrote:
>> >
>> > the strange thing is that it's not autoloaded even if it is scheduled
>> to do so
>> > is it possibile that some error prevents it from loading?
>>
>> Yes; try
>>   autoload +X _systemctl
>>
>

[-- Attachment #2: Type: text/html, Size: 2027 bytes --]

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

* Re: completion functions not loaded
  2023-02-12 18:13           ` Pier Paolo Grassi
@ 2023-02-12 18:27             ` Pier Paolo Grassi
  2023-02-12 18:36               ` Roman Perepelitsa
  0 siblings, 1 reply; 16+ messages in thread
From: Pier Paolo Grassi @ 2023-02-12 18:27 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh-Users List

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

sorry, too soon...

autoload +X _systemctl

does not produce any output, but it does not gives an error though
but the completion context for systemctl does not change, _systemctl is not
present,
even after a
compdef _systemctl systemctl

but functions _systemctl now returns the correctly loaded function body

Pier Paolo Grassi


Il giorno dom 12 feb 2023 alle ore 19:13 Pier Paolo Grassi <
pierpaolog@gmail.com> ha scritto:

> autoload +X _systemctl
>
> does not produce any output, but it does not gives an error though
> but the completion context for systemctl does not change, _systemctl is
> not present
>
> Pier Paolo Grassi
>
>
> Il giorno dom 12 feb 2023 alle ore 18:52 Pier Paolo Grassi <
> pierpaolog@gmail.com> ha scritto:
>
>> It doesn't seem to do anything. Even inserting
>> setopt xtrace
>>
>> just after #compdef systemctl
>> in /usr/share/zsh/vendor-completions/_systemctl does not produce any output
>> when trying to complete the systemctl command after opening a new shell
>>
>> Pier Paolo Grassi
>>
>>
>> Il giorno dom 12 feb 2023 alle ore 18:41 Bart Schaefer <
>> schaefer@brasslantern.com> ha scritto:
>>
>>> On Sun, Feb 12, 2023 at 9:23 AM Pier Paolo Grassi <pierpaolog@gmail.com>
>>> wrote:
>>> >
>>> > the strange thing is that it's not autoloaded even if it is scheduled
>>> to do so
>>> > is it possibile that some error prevents it from loading?
>>>
>>> Yes; try
>>>   autoload +X _systemctl
>>>
>>

[-- Attachment #2: Type: text/html, Size: 2995 bytes --]

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

* Re: completion functions not loaded
  2023-02-12 18:27             ` Pier Paolo Grassi
@ 2023-02-12 18:36               ` Roman Perepelitsa
  2023-02-12 20:58                 ` Pier Paolo Grassi
  0 siblings, 1 reply; 16+ messages in thread
From: Roman Perepelitsa @ 2023-02-12 18:36 UTC (permalink / raw)
  To: Pier Paolo Grassi; +Cc: Bart Schaefer, Zsh-Users List

On Sun, Feb 12, 2023 at 7:28 PM Pier Paolo Grassi <pierpaolog@gmail.com> wrote:
>
> sorry, too soon...
>
> autoload +X _systemctl
>
> does not produce any output, but it does not gives an error though
> but the completion context for systemctl does not change, _systemctl is not present,
> even after a
> compdef _systemctl systemctl

This works though, right?

    \systemctl <TAB>

(Note the backslash).

If the answer is yes (I assume it is), what's the output of `alias systemctl`?

Roman.


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

* Re: completion functions not loaded
  2023-02-12 18:36               ` Roman Perepelitsa
@ 2023-02-12 20:58                 ` Pier Paolo Grassi
  2023-02-12 21:08                   ` Roman Perepelitsa
  0 siblings, 1 reply; 16+ messages in thread
From: Pier Paolo Grassi @ 2023-02-12 20:58 UTC (permalink / raw)
  To: Roman Perepelitsa; +Cc: Bart Schaefer, Zsh-Users List

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

oh, yikes...
alias systemctl='sudo SYSTEMD_PAGER= systemctl'
sorry, totally forgotten about that

Pier Paolo Grassi


Il giorno dom 12 feb 2023 alle ore 19:36 Roman Perepelitsa <
roman.perepelitsa@gmail.com> ha scritto:

> On Sun, Feb 12, 2023 at 7:28 PM Pier Paolo Grassi <pierpaolog@gmail.com>
> wrote:
> >
> > sorry, too soon...
> >
> > autoload +X _systemctl
> >
> > does not produce any output, but it does not gives an error though
> > but the completion context for systemctl does not change, _systemctl is
> not present,
> > even after a
> > compdef _systemctl systemctl
>
> This works though, right?
>
>     \systemctl <TAB>
>
> (Note the backslash).
>
> If the answer is yes (I assume it is), what's the output of `alias
> systemctl`?
>
> Roman.
>

[-- Attachment #2: Type: text/html, Size: 1440 bytes --]

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

* Re: completion functions not loaded
  2023-02-12 20:58                 ` Pier Paolo Grassi
@ 2023-02-12 21:08                   ` Roman Perepelitsa
  2023-02-12 21:09                     ` Pier Paolo Grassi
  2023-02-12 21:53                     ` Bart Schaefer
  0 siblings, 2 replies; 16+ messages in thread
From: Roman Perepelitsa @ 2023-02-12 21:08 UTC (permalink / raw)
  To: Pier Paolo Grassi; +Cc: Bart Schaefer, Zsh-Users List

On Sun, Feb 12, 2023 at 9:58 PM Pier Paolo Grassi <pierpaolog@gmail.com> wrote:
>
> alias systemctl='sudo SYSTEMD_PAGER= systemctl'

If you replace the alias with a function, it'll complete nicely.

    systemctl() sudo SYSTEMD_PAGER= systemctl "$@"

Alternatively, you can `setopt complete_aliases` and then manually
`compdef` every alias. I'm not a fan of this approach but it's an
option.

Roman.


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

* Re: completion functions not loaded
  2023-02-12 21:08                   ` Roman Perepelitsa
@ 2023-02-12 21:09                     ` Pier Paolo Grassi
  2023-02-12 21:53                     ` Bart Schaefer
  1 sibling, 0 replies; 16+ messages in thread
From: Pier Paolo Grassi @ 2023-02-12 21:09 UTC (permalink / raw)
  To: Roman Perepelitsa; +Cc: Bart Schaefer, Zsh-Users List

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

yes i am now adapting these aliases to functions, thanks

Il giorno dom 12 feb 2023 alle 22:08 Roman Perepelitsa <
roman.perepelitsa@gmail.com> ha scritto:

> On Sun, Feb 12, 2023 at 9:58 PM Pier Paolo Grassi <pierpaolog@gmail.com>
> wrote:
> >
> > alias systemctl='sudo SYSTEMD_PAGER= systemctl'
>
> If you replace the alias with a function, it'll complete nicely.
>
>     systemctl() sudo SYSTEMD_PAGER= systemctl "$@"
>
> Alternatively, you can `setopt complete_aliases` and then manually
> `compdef` every alias. I'm not a fan of this approach but it's an
> option.
>
> Roman.
>
-- 
Pier Paolo Grassi

[-- Attachment #2: Type: text/html, Size: 1166 bytes --]

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

* Re: completion functions not loaded
  2023-02-12 21:08                   ` Roman Perepelitsa
  2023-02-12 21:09                     ` Pier Paolo Grassi
@ 2023-02-12 21:53                     ` Bart Schaefer
  2023-02-13  8:23                       ` Roman Perepelitsa
  1 sibling, 1 reply; 16+ messages in thread
From: Bart Schaefer @ 2023-02-12 21:53 UTC (permalink / raw)
  To: Roman Perepelitsa; +Cc: Pier Paolo Grassi, Zsh-Users List

On Sun, Feb 12, 2023 at 1:08 PM Roman Perepelitsa
<roman.perepelitsa@gmail.com> wrote:
>
> On Sun, Feb 12, 2023 at 9:58 PM Pier Paolo Grassi <pierpaolog@gmail.com> wrote:
> >
> > alias systemctl='sudo SYSTEMD_PAGER= systemctl'
>
> If you replace the alias with a function, it'll complete nicely.

sudo completion is supposed to know how to look ahead.  As written
above, the completion context is

tags in context :completion::complete:SYSTEMD_PAGER=::
    use-compctl    (_default)
    globbed-files  (_files _default)
tags in context :completion::complete:sudo::
    argument-rest  (_arguments _sudo)

The alias would work if it were instead

alias systemctl='SYSTEMD_PAGER= sudo systemctl'

Maybe this indicates need for a fix to _sudo


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

* Re: completion functions not loaded
  2023-02-12 21:53                     ` Bart Schaefer
@ 2023-02-13  8:23                       ` Roman Perepelitsa
  2023-02-13 10:01                         ` Pier Paolo Grassi
  0 siblings, 1 reply; 16+ messages in thread
From: Roman Perepelitsa @ 2023-02-13  8:23 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Pier Paolo Grassi, Zsh-Users List

On Sun, Feb 12, 2023 at 10:53 PM Bart Schaefer
<schaefer@brasslantern.com> wrote:
>
> The alias would work if it were instead
>
> alias systemctl='SYSTEMD_PAGER= sudo systemctl'

Keep in mind that on most systems with the default settings
SYSTEMD_PAGER won't be propagated through sudo.

> Maybe this indicates need for a fix to _sudo

Nod.

Roman.


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

* Re: completion functions not loaded
  2023-02-13  8:23                       ` Roman Perepelitsa
@ 2023-02-13 10:01                         ` Pier Paolo Grassi
  0 siblings, 0 replies; 16+ messages in thread
From: Pier Paolo Grassi @ 2023-02-13 10:01 UTC (permalink / raw)
  To: Roman Perepelitsa; +Cc: Bart Schaefer, Zsh-Users List

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

in my ubuntu the env var is not propagated if moved before sudo, the
function works correctly

Il giorno lun 13 feb 2023 alle 09:23 Roman Perepelitsa <
roman.perepelitsa@gmail.com> ha scritto:

> On Sun, Feb 12, 2023 at 10:53 PM Bart Schaefer
> <schaefer@brasslantern.com> wrote:
> >
> > The alias would work if it were instead
> >
> > alias systemctl='SYSTEMD_PAGER= sudo systemctl'
>
> Keep in mind that on most systems with the default settings
> SYSTEMD_PAGER won't be propagated through sudo.
>
> > Maybe this indicates need for a fix to _sudo
>
> Nod.
>
> Roman.
>
-- 
Pier Paolo Grassi

[-- Attachment #2: Type: text/html, Size: 1095 bytes --]

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

end of thread, other threads:[~2023-02-13 10:02 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-11 21:18 completion functions not loaded Pier Paolo Grassi
2023-02-11 21:27 ` Bart Schaefer
2023-02-11 21:30   ` Pier Paolo Grassi
2023-02-11 21:31   ` Bart Schaefer
2023-02-12 17:22     ` Pier Paolo Grassi
2023-02-12 17:41       ` Bart Schaefer
2023-02-12 17:52         ` Pier Paolo Grassi
2023-02-12 18:13           ` Pier Paolo Grassi
2023-02-12 18:27             ` Pier Paolo Grassi
2023-02-12 18:36               ` Roman Perepelitsa
2023-02-12 20:58                 ` Pier Paolo Grassi
2023-02-12 21:08                   ` Roman Perepelitsa
2023-02-12 21:09                     ` Pier Paolo Grassi
2023-02-12 21:53                     ` Bart Schaefer
2023-02-13  8:23                       ` Roman Perepelitsa
2023-02-13 10:01                         ` Pier Paolo Grassi

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