From: Grant Taylor <gtaylor@tnetconsulting.net>
To: zsh-users@zsh.org
Subject: Re: Conditionally complete on space.
Date: Fri, 18 Aug 2017 11:13:34 -0600 [thread overview]
Message-ID: <b906d7a1-0a80-9c24-e00f-ded6b54e63b4@tnetconsulting.net> (raw)
In-Reply-To: <1503032825.3842363.1077203224.3C85AD9F@webmail.messagingengine.com>
[-- Attachment #1: Type: text/plain, Size: 1579 bytes --]
On 08/17/2017 11:07 PM, Daniel Shahaf wrote:
> That doesn't seem to have anything to do with the widget:
>
> $ zsh -f
> % autoload compinit
> % compinit
> % sipcalc(){}
> % sipc<TAB><space>
>
> results in BUFFER="sipcalc " with just one space.
Well I'll be....
I never noticed it before, but it sure is there. - I guess that means
that I won't mind it henceforth either. :-)
> You can always <Ctrl+V><Space> to enter a literal space.
Ya, I was doing that during my diagnostics.
My goal is to overload space so that I don't need to hit special keys. ;-)
> The REC_EXACT option works if you change expand-or-complete
> to complete-word. (In this case you may want to add _expand
> to your 'completer' zstyle.)
You've gotten me a LOT closer. And some brute force hacking (less than
gracefully) got me to what I think I want.
maybe-expand-or-complete() {
if [[ $LBUFFER[-1] != ' ' && -z "$JUSTCOMPLETED" ]]; then
zle expand-or-complete
if [[ $LBUFFER[-1] != ' ' ]]; then
JUSTCOMPLETED=true
fi
else
unset JUSTCOMPLETED
zle self-insert
fi
}
zle -N maybe-expand-or-complete
bindkey ' ' maybe-expand-or-complete
setopt recexact
The key was to retain state between maybe-expand-or-complete()
executions via JUSTCOMPLETED so as to not call expand-or-complete
successively when there were multiple matches.
Thanks to your help Daniel, I believe I have something that I can start
using and deal with any annoyances as they come up. :-)
--
Grant. . . .
unix || die
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 3717 bytes --]
next prev parent reply other threads:[~2017-08-18 17:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-17 22:34 Grant Taylor
2017-08-18 1:07 ` Daniel Shahaf
2017-08-18 4:32 ` Grant Taylor
2017-08-18 5:07 ` Daniel Shahaf
2017-08-18 17:13 ` Grant Taylor [this message]
2017-08-18 17:19 ` Grant Taylor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b906d7a1-0a80-9c24-e00f-ded6b54e63b4@tnetconsulting.net \
--to=gtaylor@tnetconsulting.net \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).