From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29004 invoked by alias); 12 Sep 2016 21:00:08 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 21881 Received: (qmail 24241 invoked from network); 12 Sep 2016 21:00:08 -0000 X-Qmail-Scanner-Diagnostics: from nm35-vm3.bullet.mail.ir2.yahoo.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(212.82.97.126):SA:0(0.0/5.0):. Processed in 0.420044 secs); 12 Sep 2016 21:00:08 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM,SPF_PASS, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: okiddle@yahoo.co.uk X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.mail.yahoo.com designates 212.82.97.126 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1473713584; bh=FvR8QRXcA0sNSVrrdZz12Emsq+t6oFHWriyjSD+TYwA=; h=cc:In-reply-to:From:References:To:Subject:Date:From:Subject; b=HaUqzHTgbPDg9YG/nUCGkWuGEo8kOLMwb1H4d/fmKIX8oSBvPV5hoqRyCfFzofqExoI7fO9my2dqv4kLFl3jzeXGVnOJUzhz1d84Ywf5AKnG5BmBoyGnRY5JILRTRnd0ChAt6QnUpLpgv2AYwAVS7CmGx43qkUv7wYt2bs6EmqQPEnhqdUFQDAhfvMu2Z4vB04gytacz4wYrRL2PkaMHSd/4v2RBysJNsim2+IHsrEutMwehTh0t3MOHghzEkda+2jFCr44JfoYoUHo3eFIEAotasy1MwVlRpTXjOB2IYl5u30C72fTjG/TDDiD0E0Ic0cDnPp4Q40iAiA4aiTis7g== X-Yahoo-Newman-Id: 474592.72396.bm@smtp110.mail.ir2.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: NxM2szYVM1n9ggF3v.ek.3qyJ3Kjf96K7Pc5fyLfml7HjDp _TTBdbwS3VIzVXUtiBG_iCnFex8OWL08lSFYBKlhRf3Xtkf0MEs.AGGN.9Sj pLbdpaijL.RIZl3IWsRummP42pVrx5iO7OJuNZcIMeHTVinzhkwygJl.f2FX 01y8R8f1U0WVJaCMELwUjNgDDbm9eBPm5AM8oeQWEhkwt.zXmmi6c2ikg9Kq laYHfLDcdcsiRn9O8Nq1oa0ng5eeshBbryNJAdNsWFLB5AdXzmoJfX7EcJ8N cmE052Q_TYdXnIw5CTcDgb4Wj4kviVJFrJ.aP8qfpGxXCo_85SBO2dm7ZhLx scoHOBbAMWbpDZw1sMGqBOQnVBMGWRexvPIqIU1lc4ywJtB6VZTTRbrAjXoe kGjO6dHHj_UGqYXGjksuQHriQEYV1Xj84kMHOA9iDB_w1x8RUbtK4cHQvvcM RaXdsB7fRMgOY_57UOuI6c7HyzIRO2DdhkrUplZ_ejyaglL1GN.36ca9b959 Zhv15TdBSRjyUcp_vDL8.EgqiLCqfvYVwdAR_DW27G.M- X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI- cc: Zsh Users In-reply-to: From: Oliver Kiddle References: To: =?UTF-8?Q?Jesper_Nyg=C3=A5rds?= Subject: Re: Three questions about a completer MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <75334.1473713583.1@hydra.kiddle.eu> Content-Transfer-Encoding: 8bit Date: Mon, 12 Sep 2016 22:53:03 +0200 Message-ID: <75335.1473713583@hydra.kiddle.eu> Jesper Nygårds wrote: > I have a completer function that I have bound with menu-complete to alt-e > 1) I want to have the alternatives offered by consecutive presses of alt-e, > and I don't want the alternatives to be listed below the command line. To The hidden style should suppress listing the matches: zstyle ':completion:*list-comp:*' hidden all But hidden is looked up from _description which you don't call. You could add _wanted around the compadd but all the hidden style actually does is cause the -n option to be passed to compadd which you could do directly. > 2) The line starting with "[[ -n $words[CURRENT] ]] ..." is meant to make > sure that only files that match whats given on the command line (case > insensitively and anywhere within the file name) is offered as I would try using the completion matching control: compadd -n -p /etc/ -M 'l:|=* m:{[:lower:]}={[:upper:]}' /etc/*(:t) > alternatives. I does work, but it also means that reversing the order - > either by starting with alt-e and then hitting alt-E, or the opposite - > does not work. I assume that when I reverse the order, the widget is called > again, and since there is already a file on the command line (from pressing > alt-e once), there is only one file matching. Is there a better way to get > this behaviour? Again, I want to put a string on the command line, hit > alt-e, and only those files having a part matching what i wrote should be > offered. If I then reverse the order, I want the same list, i.e. those > files matching what I originally wrote. Using _menu generally does what I think you're describing. To use that, you may want to use _generic instead of _list-result directly. I'd recommend using _generic regardless of whether you want _menu, actually. Other completers such as _match could also be useful. zle -C list-comp menu-complete _generic zstyle ':completion:*list-comp::::' completer _menu _list-result The same thing can probably be done directly: _menu is not long but I wonder whether it is right with the reverse widget. > 3) I like the idea of using $NUMERIC to trigger alternative behaviour, in > this example getting the file names from another directory. That means I The menu completion widgets interpret the numeric argument. You can always use a wrapper zle widget: zle-list-comp() { local dir (( NUMERIC == 1 )) && dir=/etc || dir=~ zle list-comp -n 1 } zle -N zle-list-comp The -n 1 there passes 1 as the numeric argument on to list-comp. Needing two widgets is a big ugly but I don't know of any alternative. Oliver