Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: are there some ways to get things like isearch-{start,end}-position?
- X-seq: zsh-users 16923
- From: Madsen Zhang <md11235@xxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: are there some ways to get things like isearch-{start,end}-position?
- Date: Tue, 27 Mar 2012 14:58:41 +0800
- 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==
- In-reply-to: <CACLLAdmCsNhRteYOzmX5CT1KckvLFZnT5-cdaVQOjJYUC45Hqw@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CACLLAdkRdQ1YFDyqsyLfkFw-irqRyQuQOkJsTEPwueW7qmN0gQ@mail.gmail.com> <110924111752.ZM24907@torch.brasslantern.com> <CACLLAdmCsNhRteYOzmX5CT1KckvLFZnT5-cdaVQOjJYUC45Hqw@mail.gmail.com>
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 <md11235@xxxxxxxxx> wrote:
> Fantastic solution:).
>
> Bart, thank you very much!!
>
>
>
> On Sun, Sep 25, 2011 at 2:17 AM, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>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.
>>
>
>
Messages sorted by:
Reverse Date,
Date,
Thread,
Author