From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2087 invoked by alias); 12 Jan 2016 13:10:13 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 37586 Received: (qmail 23894 invoked from network); 12 Jan 2016 13:10:11 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID,WEIRD_QUOTING autolearn=ham autolearn_force=no version=3.4.0 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== X-Received: by 10.25.41.193 with SMTP id p184mr32651038lfp.150.1452604207333; Tue, 12 Jan 2016 05:10:07 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <160111161501.ZM5305@torch.brasslantern.com> References: <160111161501.ZM5305@torch.brasslantern.com> From: Sebastian Gniazdowski Date: Tue, 12 Jan 2016 14:09:47 +0100 Message-ID: Subject: Re: _history-complete-older problems with $( To: Bart Schaefer Cc: Zsh hackers list Content-Type: text/plain; charset=UTF-8 On 12 January 2016 at 01:15, Bart Schaefer 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 CURRENT: 1, NEWCUR: 1, CURSR: 2, lft: |ls|, rght: |ls|, words: >ls< # ls CURRENT: 1, NEWCUR: 1, CURSR: 3, lft: |ls|, rght: |ls|, words: >ls< # $( 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 $( (btw., not after $(), the completer behaves weird. For "ls " 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 $() 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