Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Conditionally complete on space.
- X-seq: zsh-users 22837
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: Grant Taylor <gtaylor@xxxxxxxxxxxxxxxxxx>
- Subject: Re: Conditionally complete on space.
- Date: Fri, 18 Aug 2017 01:07:20 +0000
- Cc: Zsh Users List <zsh-users@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=8nKBIS yIC+bt8MTwrhp/wFhKBLOTaVDGo/V1uiJlVtQ=; b=EkAVPF6Z7R84pQP6OdWz7/ IOhJjIf/nxV7SkqsggINGU10QFx84clNH3p/3XaX1PWGfQoOyFUQu48/UOcKB7j8 rbZTQZ+rkv9XRgtdPk+uUJI6xy0pLxPeSpm/hUmJoBZnkadJS8VMB3CySDl2MciB /z2hbPNVqQiFtSQIR4hEezMyPwvj4S2Y7nIiuR0Zi8SVKW1KnWJea7O5b9uvxEVf eYjHUVrZ0idkKuGtPoIZeaIDOmpN9EaUve94EmlQmd1rYMQWfdRnaa1ZcM0QmuSS GtUGsadsPQy0CTHovPmVB/QbbjHeh9fFRM1fnhy9VX0Go3KWXgpd65I26n4tUbvg ==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=8nKBIS yIC+bt8MTwrhp/wFhKBLOTaVDGo/V1uiJlVtQ=; b=dTMOoKCDAKs6xUzp1ieUgo FmMWdo/IqlyZlQ4yI38ArZSpXuX4D5ngBdwAYNt3gjRZR65dC4HTxBJMK5hRjJg1 ldAjGUbO2ph00qH1Hvo/WQGkRsM2dh4yePtcpbG+bTRt/1X64Hzp5XiOHN6Mq5NF 9RMVSUVfHm3f4g6A3+bLoajp1jdX4LHPecap9zjZFQf/p93UluTkXhYl3lSfGKFK lof8Ikq7an/XE+SyAvTVEhFs4qkFYcY6G/tnhDdU119EYYCCuPiVqxsfDAuKrLyc s4ajqRSOL2z5JAJ8UiNFao26gSHySry+sxGymXUsXANP/ehW131Am6ZjZP2AGXYQ ==
- In-reply-to: <c4588344-b793-905c-61cc-ffdfbc623a97@tnetconsulting.net>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <c4588344-b793-905c-61cc-ffdfbc623a97@tnetconsulting.net>
Grant Taylor wrote on Thu, 17 Aug 2017 16:34 -0600:
> Thus I want to conditionally complete if there is not a space proceeding
> the cursor's current position. If there is a space proceeding the
> cursor, then put a space and not call expand-or-complete.
Define a custom widget:
maybe-complete-on-space() {
if [[ $LBUFFER[-1] == ' ' ]]; then
zle self-insert
else
zle expand-or-complete
fi
}
zle -N maybe-complete-on-space
and bind it:
bindkey ' ' maybe-complete-on-space
This implements the behaviour you specified, but I suspect you meant the
'if' and the 'else' behaviours to be the other way around.
> I am guessing that I will need to modify expand-or-complete's behavior
> via modifying _main_complete, or wrap _main_complete with something else
> to do the conditional logic and then call _main_complete, and update zle
> so that expand-or-complete calls the wrapper instead of _main_complete.
You aren't changing the behaviour of completion, you are just changing
the method of invoking it, so the solution was in zshzle(1)'s domain,
not in zshcompsys(1)'s.
Cheers,
Daniel
Messages sorted by:
Reverse Date,
Date,
Thread,
Author