zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Guido van Steen <gvsteen@yahoo.com>, zsh-workers@zsh.org
Subject: Re: matlab-history-beginning-search-backward
Date: Sun, 13 Dec 2009 15:25:34 -0800	[thread overview]
Message-ID: <091213152534.ZM13525@torch.brasslantern.com> (raw)
In-Reply-To: <140222.25175.qm@web65614.mail.ac4.yahoo.com>

Nobody ever responded to this thread ...

On Sep 30,  9:52am, Guido van Steen wrote:
} Subject: matlab-history-beginning-search-backward
}
} I would prefer a similar [to history-beginning-search-backward]
} widget that searches for commands in the command history, in such a
} way that "LBUFFER" is a SUBSTRING of these commands. (This is the
} default history management in MATLAB and FISH.)
}
} I know there is the "history-incremental-search-backward" widget,
} which is bound to "^r" by default. This widget does more-or-less what
} I want. However, it shows two prompts, which I don't seem to like that
} much. Moreover, if requires the userto invoke it first and then start
} typing what he looks for.

Ignoring the issue of the extra prompt, what you want can be accomplished
like so:

matlab-history-beginning-search-backward() {
   local search="$LBUFFER"
   zle up-line-or-history
   zle end-of-line
   zle history-incremental-search-backward "$search"
}
zle -N matlab-history-beginning-search-backward
bindkey ^X^P matlab-history-beginning-search-backward
bindkey -M isearch ^X^P history-incremental-search-backward

The tricky bit there is that you use one keybinding to enter incremental
search mode, and then bind the same keys in the special isearch map to
repeat that search.  The other point to note is that you can start an
incremental search with an initial string by passing it as an argument.


      reply	other threads:[~2009-12-14  0:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-30 16:52 matlab-history-beginning-search-backward Guido van Steen
2009-12-13 23:25 ` Bart Schaefer [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=091213152534.ZM13525@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=gvsteen@yahoo.com \
    --cc=zsh-workers@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).