Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: _history-complete-older problems with $(
- X-seq: zsh-workers 37565
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: _history-complete-older problems with $(
- Date: Mon, 11 Jan 2016 16:15:01 -0800
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version:content-type; bh=KNSmWQ3iRFA3PDgeIlVxwRmq1UGWlQLP+EbxGvvxQZk=; b=ErRSKH5NW6CS4NYRCb8lcwSvUxETvRzQiWv6ncKLP2JZNMX8zrMVvgvwnGsRYsfLXY HmHlepKALi1/czFY3Oud8iEcxmZ29XKigDLxZShi7W6UmDP4hEPJNTP3a3M91Pfcnxhf d7t0HXweQlUmeqA/rZ2KNcqleFkWfDHlD+R8aBwbmU0C1rWAq8SvKXQas4K5zbN0EHKj M/ZsHiwDzpxroMsvpG4GnZGLxMLiV0DjnqnzPU++Xrzx4AFrRYHMHAEyC29YXWWcfpXC 9ePIddisHNpKR9EIy98zneQ0pe6aXeCTCdNqTeKu8ios66YZWTrZ5fTApy3E6hiq+lWP SlLw==
- In-reply-to: <CAKc7PVDVR=B8SWX+gSiNvtODWZ-25LtDz7jXVDH8BtrcxMnjXQ@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVCnEX1rEhNqhtx7spyUVKCWukz4Tzkqr27-OV9+4hVciQ@mail.gmail.com> <CAKc7PVDVR=B8SWX+gSiNvtODWZ-25LtDz7jXVDH8BtrcxMnjXQ@mail.gmail.com>
On Jan 11, 5:21pm, Sebastian Gniazdowski wrote:
} Subject: Re: _history-complete-older problems with $(
}
} on IRC it came up that $( is a start of a subshell and that it makes
} completion start over at this place. Seems that $(( works in the same
} way. Is there any possibility to change that? Even at level of C code?
The following produces the correct set of completion matches (pardon the
unimaginative name) but is a bit of a hack (it breaks _complete_debug
and _complete_help):
_widen_for_history () {
local -a left=( "${(z)LBUFFER}" )
local right="${words[CURRENT]#${left[-1]}}"
words=( "${(z)BUFFER}" )
CURRENT=${#left}
PREFIX="${left[-1]}"
IPREFIX=''
SUFFIX="${right}"
ISUFFIX=''
{
compadd () {
local -a found
builtin compadd -O found "$@"
builtin compadd -Q -U "${(@)${(@)found#$PREFIX}%$SUFFIX}"
}
_history
} always {
unfunction compadd
}
}
zstyle ':completion:*' completer _widen_for_history _complete
This needs some work around the issue of empty words, i.e., when
completing in empty parens such as $(<TAB>) then $words[CURRENT] is
empty and the trailing paren must be copied from $RBUFFER to SUFFIX.
I haven't dived into that detail.
It could be further refined (with a lot of work) to widen only to the
next "outward" command, e.g., in
foo $(bar $(<TAB>
to extend back only as far as "bar" rather than to "foo", which might
turn out to be important for some multi-line buffers, I'm not sure.
Another approach would be to create a custom key binding for a widget
which
- inserts an open quote before the current word
- invokes completion with completer style set to _history
- removes quoting again
but that has its own complications if the word on the line is already
quoted, etc.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author