zsh-users
 help / color / mirror / code / Atom feed
From: Madsen Zhang <md11235@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: zsh-users@zsh.org
Subject: Re: are there some ways to get things like isearch-{start,end}-position?
Date: Thu, 29 Mar 2012 14:33:43 +0800	[thread overview]
Message-ID: <CACLLAdmro6Jx_8iy9KYFNTDnkafpVqseVRQcewQM4jK9PeyLqw@mail.gmail.com> (raw)
In-Reply-To: <120327065911.ZM6744@torch.brasslantern.com>

[-- Attachment #1: Type: text/plain, Size: 1384 bytes --]

Good, it works gracefully. your definition of ISEARCHDIR is the same with
what I desired.

Bart, thank you very much :)!

On Tue, Mar 27, 2012 at 9:59 PM, Bart Schaefer <schaefer@brasslantern.com>wrote:

> 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.
>

      reply	other threads:[~2012-03-29  6:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-24  6:26 md 1983
2011-09-24 18:17 ` Bart Schaefer
2011-09-25  4:06   ` Madsen Zhang
2012-03-27  6:58     ` Madsen Zhang
2012-03-27 13:59       ` Bart Schaefer
2012-03-29  6:33         ` Madsen Zhang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACLLAdmro6Jx_8iy9KYFNTDnkafpVqseVRQcewQM4jK9PeyLqw@mail.gmail.com \
    --to=md11235@gmail.com \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).