From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17242 invoked by alias); 27 Mar 2012 13:59:32 -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: 16924 Received: (qmail 26158 invoked from network); 27 Mar 2012 13:59:30 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <120327065911.ZM6744@torch.brasslantern.com> Date: Tue, 27 Mar 2012 06:59:11 -0700 In-reply-to: Comments: In reply to Madsen Zhang "Re: are there some ways to get things like isearch-{start,end}-position?" (Mar 27, 2:58pm) References: <110924111752.ZM24907@torch.brasslantern.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: are there some ways to get things like isearch-{start,end}-position? MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Mar 27, 2:58pm, Madsen Zhang wrote: > > if the last isearch direction is available, the following script, based on > the one from Bart Schaefer, should work in both forward and backward > isearch: > > zle-isearch-exit() { > if [[ $ISEARCHDIR -eq 1 ]]; then > local match mbegin mend > setopt extendedglob > [[ -n $LASTSEARCH ]] || return 0 > : ${LBUFFER%(#b)(*)$LASTSEARCH} > CURSOR=$mend[1] > fi > > return 0 > } > zle -N zle-isearch-exit You can set ISEARCHDIR for yourself by putting a little wrapper function around history-incremental-search-*. hist-inc-search-save-direction() { if [[ $WIDGET = *-forward ]]; then typeset -g ISEARCHDIR=1 zle .history-incremental-search-forward "$@" else typeset -g ISEARCHDIR=-1 zle .history-incremental-search-backward "$@" fi } zle -N history-incremental-search-forward hist-inc-search-save-direction zle -N history-incremental-search-backward hist-inc-search-save-direction I'm not sure I got the semantics of ISEARCHDIR the way you wanted them, but you get the idea.