From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3656 invoked by alias); 27 Mar 2012 07:04:43 -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: 16923 Received: (qmail 12067 invoked from network); 27 Mar 2012 07:04:40 -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.6 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,HTML_MESSAGE,NML_ADSP_CUSTOM_MED,RCVD_IN_DNSWL_LOW, T_DKIM_INVALID,T_TO_NO_BRKTS_FREEMAIL autolearn=no version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.217.171 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=PKWsKrYxiQMjtpHJq7HL/ORZ+M03r5h139Jxeo5bChg=; b=0JoqDUj+LS4qGS9/yFbGjlHbLBkEUwyHe5t6BpH+NXzn+2/cY0zBqHufr7W0VB9pk4 H2tixC/9um4ztuJmvFsiZ2JaH5r96LvSWkU8IgB9eAB+YfZl4QmmL09FdvI56B4HfhcF bglkKajZ8xwDS1vKP/AN/HQaxRRnSS0k1lOURFmQTTc0pH+CusmACfHkf7YWw3dPc+U/ g4lQccCP+lGt+O2QtvU2rnnPjvhb/usf114y8NBACe+KgfY+HvmWiggaoaG59SfP4zQC MULXDPblyOj7LLQ1sCkhPqL8KaGmnOtbbi+LhnTbTmkrZnYQrtmkCu52Gj22izrWoFd7 v++w== MIME-Version: 1.0 In-Reply-To: References: <110924111752.ZM24907@torch.brasslantern.com> Date: Tue, 27 Mar 2012 14:58:41 +0800 Message-ID: Subject: Re: are there some ways to get things like isearch-{start,end}-position? From: Madsen Zhang To: zsh-users@zsh.org Content-Type: multipart/alternative; boundary=14dae9d717845c1a4504bc3405d1 --14dae9d717845c1a4504bc3405d1 Content-Type: text/plain; charset=ISO-8859-1 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 On Sun, Sep 25, 2011 at 12:06 PM, Madsen Zhang wrote: > Fantastic solution:). > > Bart, thank you very much!! > > > > On Sun, Sep 25, 2011 at 2:17 AM, Bart Schaefer wrote: > >> On Sep 24, 2:26pm, md 1983 wrote: >> } >> } I want to upon exiting isearch mode always place the cursor in ZLE at >> } the position as specified by the variable "isearch_start" in zsh's >> } source code, no matter it's a forward or backward search. >> >> You should be able to use the special zle-isearch-exit widget and the >> $LASTSEARCH variable to find the point in the buffer that was matched >> by the search. Here's a crude effort: >> >> zle-isearch-exit() { >> local match mbegin mend >> setopt extendedglob >> [[ -n $LASTSEARCH ]] || return 0 >> : ${BUFFER#(#b)(*)$LASTSEARCH} >> CURSOR=$mend[1] >> return 0 >> } >> zle -N zle-isearch-exit >> >> I agree that it would be nice to pass the search region at least to >> zle-isearch-exit and zle-isearch-update if not to make them generally >> available. >> > > --14dae9d717845c1a4504bc3405d1--