From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8481 invoked from network); 28 Feb 2002 08:29:36 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 28 Feb 2002 08:29:36 -0000 Received: (qmail 2967 invoked by alias); 28 Feb 2002 08:29:22 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 4713 Received: (qmail 2956 invoked from network); 28 Feb 2002 08:29:22 -0000 X-Authentication-Warning: erdbeere.lifebits.local: luthien set sender to d.vogt@lifebits.de using -f Date: Thu, 28 Feb 2002 08:52:21 +0100 From: Dominik Vogt To: zsh-users@sunsite.auc.dk Subject: Re: up-line-or-search question Message-ID: <20020228085221.A11888@lifebits.de> Reply-To: d.vogt@lifebits.de Mail-Followup-To: zsh-users@sunsite.auc.dk References: <20020227143627.F5514@lifebits.de> <20020227160806.77968.qmail@web9304.mail.yahoo.com> <20020228074136.C993@lifebits.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="FL5UXtIhxfXey3p5" Content-Disposition: inline User-Agent: Mutt/1.3.12i In-Reply-To: <20020228074136.C993@lifebits.de>; from dominik.vogt@gmx.de on Thu, Feb 28, 2002 at 07:41:36AM +0100 X-Virus-Scanned: by AMaViS perl-11 X-Sender: 520008918237-0001@t-dialin.net --FL5UXtIhxfXey3p5 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Feb 28, 2002 at 07:41:36AM +0100, Dominik Vogt wrote: > On Wed, Feb 27, 2002 at 04:08:06PM +0000, Oliver Kiddle wrote: > > --- Dominik Vogt wrote: > > > > > > Actually, that does not do what I want. I'd need > > > > > > up-line-or-history-beginning-search-backward > > > up-line-or-history-beginning-search-forward > > > > > > Since I still want to be able to navigate through the lines in the > > > ZLE. > > > > Is this closer to what you want: > > > > up-line-or-beginning-search-backward() { > > if [[ $LBUFFER == *$'\n'* ]]; then > > zle up-line-or-history > > else > > zle history-beginning-search-backward > > fi > > } > > > > zle -N up-line-or-beginning-search-backward > > > > If it is, this was discussed some time around about last November. A > > few variations on the idea were posted including a similar function for > > forward. > > It's close, but not exactly what I need. For reference, I have > attached my final solution including documentation. Since it > contains tabs, don't simply copy-and-paste it. I've tinkered a bit mor with it and used the function Bart posted as the base and came up with a new version that works a tad more like up-line-or-search. The history-beginning-search-... functions are only used when one actually typed more than the first word, i.e. $ cd /f uses history-beginning-search-backward and $ cd uses up-line-or-search Bye Dominik ^_^ ^_^ -- Dominik Vogt, email: d.vogt@lifebits.de LifeBits Aktiengesellschaft, Albrechtstr. 9, D-72072 Tuebingen fon: ++49 (0) 7071/7965-0, fax: ++49 (0) 7071/7965-20 --FL5UXtIhxfXey3p5 Content-Type: application/x-sh Content-Disposition: attachment; filename="zle_updown_funcs.sh" function __up_or_down_line_or_beginning_search { if [[ $LASTWIDGET != down-line-or-beginning-search && $LASTWIDGET != up-line-or-beginning-search ]]; then local LBUFFER_STRIPPED="${LBUFFER/#[ ]#/}" if [[ $RBUFFER == *$'\n'* || ${LBUFFER_STRIPPED} == "" ]]; then __last_up_line=up-line-or-history __last_down_line=down-line-or-history else LBUFFER_STRIPPED="${LBUFFER_STRIPPED/#[^ ]#[ ]#/}" if [[ "$LBUFFER_STRIPPED" == "" ]]; then __last_up_line=up-line-or-search __last_down_line=down-line-or-search else __last_up_line=history-beginning-search-backward __last_down_line=history-beginning-search-forward fi fi fi } zle -N __up_or_down_line_or_beginning_search function up-line-or-beginning-search { __up_or_down_line_or_beginning_search zle .${__last_up_line:-beep} } function down-line-or-beginning-search { __up_or_down_line_or_beginning_search zle .${__last_down_line:-beep} } zle -N up-line-or-beginning-search zle -N down-line-or-beginning-search --FL5UXtIhxfXey3p5--