zsh-users
 help / color / mirror / code / Atom feed
* Autocomplet with compdef _precommand
@ 2016-08-30  7:35 Michel
  2016-08-30 17:56 ` Bart Schaefer
       [not found] ` <160830105636.ZM25657__30145.0480045334$1472579856$gmane$org@torch.brasslantern.com>
  0 siblings, 2 replies; 5+ messages in thread
From: Michel @ 2016-08-30  7:35 UTC (permalink / raw)
  To: zsh-users

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

Hello,

I use zsh (5.0.7) with the autocd option. I create a function start() that
will run another command :

function start (){
    "$@" &> /dev/null &
}

And I add this line to have autocomplet :

compdef _precommand start

But when I run, for example "start ssh example.com" zsh want replace "ssh"
by ".ssh/" (if I am in $HOME). I think that is because autocd change the
behaviour of _precommand.

How can I use a autocomplet like p_precommand but without the autocd
behavur ?

Thanks for your help!

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

* Re: Autocomplet with compdef _precommand
  2016-08-30  7:35 Autocomplet with compdef _precommand Michel
@ 2016-08-30 17:56 ` Bart Schaefer
  2016-08-31  8:24   ` Michel
       [not found] ` <160830105636.ZM25657__30145.0480045334$1472579856$gmane$org@torch.brasslantern.com>
  1 sibling, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2016-08-30 17:56 UTC (permalink / raw)
  To: zsh-users, zsh-users

On Aug 30,  7:35am, Michel wrote:
}
} How can I use a autocomplet like _precommand but without the autocd
} behaviour?

Unfortunately this is a little tricky.

The easiest thing might be this:

    _start () {
	setopt localoptions noautocd
	_precommand "$@"
    }
    compdef _start start

More generically, the only zstyle that modifies autocd behavior is for
the "-command-" special context, so you have to use "zstyle -e" with
an evaluated test that determines whether "start" was the precommand
word AND whether the tags are being looked up for "cd":

    zstyle -e :completion::complete:-command-:: tag-order \
      '(( $precommands[(I)start] && $funcstack[(I)_cd] )) && reply=(-)'

Question for zsh-workers:  Is it worth adding a style to _precommand
to selectively turn off autocd?  If so, what should it be called?


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

* Re: Autocomplet with compdef _precommand
       [not found] ` <160830105636.ZM25657__30145.0480045334$1472579856$gmane$org@torch.brasslantern.com>
@ 2016-08-31  2:35   ` Daniel Shahaf
  2016-08-31  3:45     ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Shahaf @ 2016-08-31  2:35 UTC (permalink / raw)
  To: zsh-users

Bart Schaefer wrote on Tue, Aug 30, 2016 at 10:56:36 -0700:
> More generically, the only zstyle that modifies autocd behavior is for
> the "-command-" special context, so you have to use "zstyle -e" with
> an evaluated test that determines whether "start" was the precommand
> word AND whether the tags are being looked up for "cd":
> 
>     zstyle -e :completion::complete:-command-:: tag-order \
>       '(( $precommands[(I)start] && $funcstack[(I)_cd] )) && reply=(-)'
> 
> Question for zsh-workers:  Is it worth adding a style to _precommand
> to selectively turn off autocd?  If so, what should it be called?

Isn't that already possible? —

    zstyle -e :completion::complete:-command-:: tag-order \
      '(( $precommands[(I)start] )) && reply=("!local-directories" -)'


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

* Re: Autocomplet with compdef _precommand
  2016-08-31  2:35   ` Daniel Shahaf
@ 2016-08-31  3:45     ` Bart Schaefer
  0 siblings, 0 replies; 5+ messages in thread
From: Bart Schaefer @ 2016-08-31  3:45 UTC (permalink / raw)
  To: zsh-users

On Aug 31,  2:35am, Daniel Shahaf wrote:
} Subject: Re: Autocomplet with compdef _precommand
}
} Bart Schaefer wrote on Tue, Aug 30, 2016 at 10:56:36 -0700:
} > Question for zsh-workers:  Is it worth adding a style to _precommand
} > to selectively turn off autocd?  If so, what should it be called?
} 
} Isn't that already possible? -
} 
}     zstyle -e :completion::complete:-command-:: tag-order \
}       '(( $precommands[(I)start] )) && reply=("!local-directories" -)'

It would be nice not to need to use -e and to know about $precommands.
E.g. I was asking about something like

    zstyle :completion::complete:precommand-start:: autocd off

Or perhaps

    zstyle :completion::complete:precommand-start:: localoptions noautocd

which would be a more generic style name that other cases might use. But
what to make the context is also a problem.


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

* Re: Autocomplet with compdef _precommand
  2016-08-30 17:56 ` Bart Schaefer
@ 2016-08-31  8:24   ` Michel
  0 siblings, 0 replies; 5+ messages in thread
From: Michel @ 2016-08-31  8:24 UTC (permalink / raw)
  To: Bart Schaefer, zsh-users

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

Thank you for your help.

Have a nide day :)

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

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

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-30  7:35 Autocomplet with compdef _precommand Michel
2016-08-30 17:56 ` Bart Schaefer
2016-08-31  8:24   ` Michel
     [not found] ` <160830105636.ZM25657__30145.0480045334$1472579856$gmane$org@torch.brasslantern.com>
2016-08-31  2:35   ` Daniel Shahaf
2016-08-31  3:45     ` Bart Schaefer

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