From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14930 invoked by alias); 9 Mar 2016 22:45:04 -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: 38122 Received: (qmail 15682 invoked from network); 9 Mar 2016 22:45:01 -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=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 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=ZyDzT1UUqihm7/9HUwWHu24yIbfhlR+MMOY7lGWHUU0=; b=UjBL70JUvONyc930ggsZ15C2Ra5MatIXI0T7ONfXhentQPHYVMTaUxVuzDaua4JrO4 oK8ZdP6qs1Lis1KxOXmRPRHOmcIliCaKWWfAWHpbLUXCTmNJsyS9gJnUStYNaCUxABT2 6ky8nAaOo1gryRgL8X8L0orMiZygVP203lLCupUdPOSn+KQut6F+6JaiXLxK2eRGgO4P lhjOyMWcZQFJl/FvxOoqvRehJFhKVpj57RgRyGo2ugKUEsjFybtMdeD5GLeD+1BIDSE3 TNPZ9vt/QIX7Rt3bVmFQd8ebantMNTBTOoD54ERIpSHemNHLd23hAXa1XW7cr+tH19wN lowg== 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=ZyDzT1UUqihm7/9HUwWHu24yIbfhlR+MMOY7lGWHUU0=; b=TTUIDkUVUR0Yo34wmIFJ5oyEAR1Yk7scbfi/ywJnqQE3mIsnjumN1GNDRPjR6hGm0o gHrqwHrr2+eWWj4SpMpbw48x0j+J2HfJVlLjmixkJMNFLiHN/mS9VVeauQGLKMtd8Uuw RyME9x+gviGYAcdDKWNNIOX1dnJekYXl1EEkFFoL0D3jVMjWIaBF1wkOhBvJEL43xbqN apeUH6jm+utjr8LHUOlTJBkOUSmiGnNif1V4pdsq8bY4GC/tT4ZKsbbxJxIuKJPhUvCi luh0c38wGYUgiQPPn/MpJrjD5Or5cK34kDgRDOgSaVGeETwD96W2xPDDbVN/nuuCOjAv WUJA== X-Gm-Message-State: AD7BkJLAK5TrTIeUjkB/dJRkhnhX1lBHN8FYU41mojIwEHdjpSNWy+cNzt+U63oRTNYatQ== X-Received: by 10.98.76.194 with SMTP id e63mr278203pfj.89.1457563497503; Wed, 09 Mar 2016 14:44:57 -0800 (PST) From: Bart Schaefer Message-Id: <160309144505.ZM11492@torch.brasslantern.com> Date: Wed, 9 Mar 2016 14:45:05 -0800 In-Reply-To: Comments: In reply to Mikael Magnusson "Re: reverse-menu-complete re-starting completion on 5.2?" (Mar 9, 12:41pm) References: <20160226175937.GA22547@lorien.comfychair.org> <160226114511.ZM17604@torch.brasslantern.com> <8456.1456706752@thecus.kiddle.eu> <160306094154.ZM20831@torch.brasslantern.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Zsh workers Subject: Re: reverse-menu-complete re-starting completion on 5.2? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Mar 9, 12:41pm, Mikael Magnusson wrote: } Subject: Re: reverse-menu-complete re-starting completion on 5.2? } } On Wed, Mar 9, 2016 at 12:12 PM, Mikael Magnusson wrote: } > On Mon, Mar 7, 2016 at 3:05 AM, Mikael Magnusson wrote: } >> On Sun, Mar 6, 2016 at 6:41 PM, Bart Schaefer wrote: } >>> On Feb 29, 1:45am, Oliver Kiddle wrote: } >>> } } >>> } [...] I'm really not sure why we need to be so } >>> } strict about the completion widget matching the last completion widget. } >>> } >>> The only reason I can think of is in case menu completion is invoked from } >>> within a user-defined widget, or otherwise entered by a different widget } >>> } >>> Maybe we'd need another flag action for "zle -f" to continue/interrupt Turns out "zle auto-suffix-retain" already serves this purpose. This is tricky because widgets created with "zle -C" start directly in completion context, which means that "zle" generates an error; i.e., if we naively stick this into _generic: _generic:zle:1: widgets can only be called when ZLE is active (The error should probably be more specific, since a completion widget is merely the wrong *kind* of widget.) The solution is to make a normal widget for auto-suffix-retain, then invoke the completion widget with "zle the-widget -w". This seems a bit more work than should be necessary, but see example below. } >> I can tell you I quite often complete a directory name using normal } >> completion, and then press ctrl-n to complete files inside by latest } >> modification date. } } zstyle ':completion:most-recent-file:*' match-original both } zstyle ':completion:most-recent-file:*' file-sort modification } zstyle ':completion:most-recent-file:*' file-patterns '*:all\ files' } zstyle ':completion:most-recent-file:*' hidden all } zstyle ':completion:most-recent-file:*' completer _files } zle -C most-recent-file menu-complete _generic } } bindkey "^N" most-recent-file Just as-is, this works as you desire if the initial directory completion is not ambiguous, but cycles if there are multiple possible matches in the current menu. } I would like ^N after TAB to start completion over (even if this was } originally a ^N completion), but TAB after ^N to continue the same } completion. The following uses the normal-widget-calls-completion trick. There may be a better name for it. -- 8< -- # Replaces bindkey in the above, otherwise all the same complete-most-recent-file () { [[ $LASTWIDGET != $WIDGET ]] && zle auto-suffix-retain zle most-recent-file -w } zle -N complete-most-recent-file bindkey "^N" complete-most-recent-file -- 8< -- If we're OK with this, Oliver's patch can remain, but it's possible that there are other user-defined widgets that will start behaving unexpectedly.