From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21807 invoked by alias); 14 Sep 2016 02:59:12 -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: 21900 Received: (qmail 2016 invoked from network); 14 Sep 2016 02:59:12 -0000 X-Qmail-Scanner-Diagnostics: from mail-pa0-f46.google.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(209.85.220.46):SA:0(0.0/5.0):. Processed in 0.569189 secs); 14 Sep 2016 02:59:12 -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=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at brasslantern.com does not designate permitted sender hosts) 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; bh=mZPuBXk8EdEh0lsZhY9YO8Zbok7+TvpQ454cD/IyPcA=; b=RHnGOvF2i9gpjVI/qhfbCE0FihlgbzXJZ9RWgNOzggiLalyGRMJ/4PkNKTsqMlIU2K Cts73hA2MCmiKixuBFqXYekccI0hdNQccZ5zuEazuwZ51r5DAF3IzroJPDvKERxpFCFh 05CM/5rayMGOBBYT0CoJwzOqAgL/9YYQND1GuqAOt0TRM7xLynOfnzslYwKXsxQzWWB0 /T40tarcuB0PBKwVCdNknkGya4uBWpki9fjVWUOK9Ngbg8lzW2DzrvpR+N3aFjMILqCx G9ebSG5JDxUviWAD4FjXVhsYZbT6zz5n4dGa5gbnVJ0Z1CP36C3gwCTaMEU4uBbBWsdU tdzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version; bh=mZPuBXk8EdEh0lsZhY9YO8Zbok7+TvpQ454cD/IyPcA=; b=Luray6fLiOAqfShSUV1RJ73RVWpn95zaIrvK6U4GOAm7NxI+oRbpLyK3V/YjDOFKc0 n7WL+vvQBxEsGW+eHek/wwqQGqlWOD4csKx1uVr6IlB5d6SvVxj4wHJwrtqVhP4I3Wk/ YuPx77/WDDIzTXofNhn1LZfKufX2hnLdw265O2NIySoTQwIxGNhKO+8l+aoRg0H3RXzs bTWCFQXAS5edrl7Fbxae5iy459NovtOtUyYncHunyuofknkhbnHpddak4RmUrbkY/Tj6 mw35V/emTneQ/98vPJapFYdClbs5x3BhKexDL82gzhovZROcSlo2OJip4MX+uiln6OU5 v+pw== X-Gm-Message-State: AE9vXwOT830cx9E7l6PaSNoHMvqdhtfaIqDHvQbRJM6icg8hOYlKr8lkBjfFX4U37tY0gA== X-Received: by 10.66.146.201 with SMTP id te9mr434911pab.104.1473821945508; Tue, 13 Sep 2016 19:59:05 -0700 (PDT) From: Bart Schaefer Message-Id: <160913195916.ZM30431@torch.brasslantern.com> Date: Tue, 13 Sep 2016 19:59:16 -0700 In-Reply-To: Comments: In reply to Jesper Nygards "Re: Three questions about a completer" (Sep 13, 9:18pm) References: <75335.1473713583@hydra.kiddle.eu> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Zsh Users Subject: Re: Three questions about a completer MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Sep 13, 9:18pm, Jesper Nygards wrote: } } So now, at least, I get the completion to trigger. However, I still have } the same problem: hitting alt-e for menu-complete works, and hitting alt-E } for reverse-menu-complete works as well, but switching direction doesn't: The doc for the _menu completer that Oliver mentioned, states: Note that this is independent of the setting of the MENU_COMPLETE option and does not work with the other menu completion widgets such as reverse-menu-complete, or accept-and-menu-complete. So that suggestion is out. >> 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 >> alternatives. You should not have to do this yourself; this is what the completion internals are made to do. You need to caculate ALL the possible files that fit the rest of your criteria, and "compadd" will take care of filtering that set down to the ones that match what's on the line. If you don't want to match by simple prefix then you do have to tell compadd how to filter. You do this with the matching control format that Oliver outlined. To stop the listing, and only menu through the matches, you assign empty string to compstate[list]. Finally you need Oliver's wrapper technique to interpret NUMERIC. The nice thing about menu-complete / reverse-menu-complete is that if a menu is already in progress, it won't re-invoke the completer, so if you start from the wrapper widget in the forward direction, you can reverse without having to use the wrapper again. So the whole thing looks something like: zle -C list-comp menu-complete _generic zle -C reve-list-comp reverse-menu-complete _generic n-list-comp() { local -a dirs=( $HOME /etc /bin ) local __lsdir=${dirs[${NUMERIC:-1}] zle list-comp -w -n 1 } zle -N n-list-comp # Similarly for n-rev-list-comp to start in reverse with NUMERIC bindkey '\ee' n-list-comp bindkey '\eE' rev-list-comp # or n-rev-list-comp if defined _list-result() { compadd -M 'l:|=* m:{[:lower:]}={[:upper:]}' -f ${__lsdir:-HOME}/* compstate[list]='' } zstyle ':completion:*list-comp::::' completer _list-result Strictly speaking you don't even need rev-list-comp, you could just invoke reverse-menu-complete provided that you always first enter the menu in the forward direction.