Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: _history-complete-older problems with $(
- X-seq: zsh-workers 37586
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: _history-complete-older problems with $(
- Date: Tue, 12 Jan 2016 14:09:47 +0100
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=Mz1RkAI1kn1qWoYKlDB1WFT0ZB0KrvKQCJQilN7dHwQ=; b=GP4Mnv/aW+a6iJZq76i3tEYjLdpgp2tFSq205pfAGtdvFjFpPNEoyCihb/DvBUjUoG uZ7v1xm4v0wd6MXktjD0XONDiMQqXBKf13i64SDCJiUxBM9jP05zLn+0Ls2N+bAYIp+k ij65d6e0XN4cr9nwKO5L8jvyzoag5mnv5I/+v6vvpy/FsKKzjHf4mq8tAbOOYJG9pBTz d+io9x/aUxp43qStLcHDiDzby5RLOoF+tThjdkzTudgK1kTh1dho6l9ocYY8nK4WOpDk oRNisIDlNAT+VCWe1Or1VKT1SDAAgtG43oZVnjKC0iun1Y49ALfizUTNf6xdf4bnuL5h 7ySg==
- In-reply-to: <160111161501.ZM5305@torch.brasslantern.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> <160111161501.ZM5305@torch.brasslantern.com>
On 12 January 2016 at 01:15, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> 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):
I think the hacks are acceptable if the code will be used only by
Alt-/ (_history-complete-older). How to accomplish this, btw? Probably
the context should be changed:
> zstyle ':completion:*' completer _widen_for_history _complete
but I don't know how to do this exactly. Can you help?
> _widen_for_history () {
> local -a left=( "${(z)LBUFFER}" )
> local right="${words[CURRENT]#${left[-1]}}"
> words=( "${(z)BUFFER}" )
> CURRENT=${#left}
> *
> PREFIX="${left[-1]}"
I've added following line where * is:
echo -e "\nCURRENT: $CURRENT, NEWCUR: $CURRENT, CURSR: $CURSOR, lft:
|$left|, rght: |$left|, words: >""$words[@]""<"
Example outputs are:
# ls<TAB>
CURRENT: 1, NEWCUR: 1, CURSR: 2, lft: |ls|, rght: |ls|, words: >ls<
# ls <TAB>
CURRENT: 1, NEWCUR: 1, CURSR: 3, lft: |ls|, rght: |ls|, words: >ls<
# $(<TAB>
CURRENT: 1, NEWCUR: 1, CURSR: 2, lft: |$(|, rght: |$(|, words: >$(<
# $( TAB
CURRENT: 1, NEWCUR: 1, CURSR: 3, lft: |$( |, rght: |$( |, words: >$( <
Are this expected values? Because despite proposing $(( 0 + 1 ))
correctly after $(<TAB> (btw., not after $(<Alt-/>), the completer
behaves weird. For "ls <TAB>" it doesn't propose any files.
> 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.
I would gladly perform the work but the code is quite difficult. Could
you state in one sentence what it is doing? Variables $CURRENT, $word
aren't documented in zshzle.1. What does the {} always {} block of
code do? Next, I would guess that "builtin compadd -O found "$@""
performs one run of matching, is this correct? Why second comadd, and
what does "${(@)${(@)found#$PREFIX}%$SUFFIX}" do?
> 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.
Maybe I could get the complications resolved for Zew. The separate key
binding seems close to what I want for Alt-/
Best regards,
Sebastian Gniazdowski
Messages sorted by:
Reverse Date,
Date,
Thread,
Author