From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8007 invoked from network); 28 Feb 2002 06:42:09 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 28 Feb 2002 06:42:09 -0000 Received: (qmail 12710 invoked by alias); 28 Feb 2002 06:41:53 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 4712 Received: (qmail 12698 invoked from network); 28 Feb 2002 06:41:52 -0000 X-Authentication-Warning: erdbeere.lifebits.local: luthien set sender to d.vogt@lifebits.de using -f Date: Thu, 28 Feb 2002 07:41:36 +0100 From: Dominik Vogt To: zsh-users@sunsite.auc.dk Subject: Re: up-line-or-search question Message-ID: <20020228074136.C993@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> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="pf9I7BMVVzbSWLtt" Content-Disposition: inline User-Agent: Mutt/1.3.12i In-Reply-To: <20020227160806.77968.qmail@web9304.mail.yahoo.com>; from okiddle@yahoo.co.uk on Wed, Feb 27, 2002 at 04:08:06PM +0000 X-Virus-Scanned: by AMaViS perl-11 X-Sender: 520008918237-0001@t-dialin.net --pf9I7BMVVzbSWLtt Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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. 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 --pf9I7BMVVzbSWLtt Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=zle_updown_funcs ################################################################### # ZLE functions: # up-line-or-beginning-search-backward # down-line-or-beginning-search-forward # # If these functions are invoked if the cursor is at the beginning # of the first line of the buffer (ignoring leading whitespace) or # in any line except the first, they work exactly like # up-line-or-history and down-line-or-history. However, the # cursor is moved to the beginning of the line afterwards. # If # invoked when the cursor is in the first line, but not at the # beginning of the line (leading whitespace are ignored), they # work like history-beginning-search-backward and # history-beginning-search-forward ################################################################### # needed later; why doesn't zle have beginning_of_buffer and # end-of-buffer functions? beginning-of-buffer() { while [[ ! $LBUFFER == "" ]]; do zle beginning-of-line done } zle -N beginning-of-buffer up-line-or-beginning-search-backward() { if [[ ${LBUFFER/#[ ]#/} == "" ]]; then zle up-history zle beginning-of-line elif [[ $LBUFFER == *$'\n'* ]]; then zle up-line-or-history else zle history-beginning-search-backward fi } down-line-or-beginning-search-forward() { if [[ ${LBUFFER/#[ ]#/} == "" || $LBUFFER == *$'\n'* ]]; then local DO_MOVE_TO_BOB="" if [[ ! $RBUFFER == *$'\n'* ]]; then DO_MOVE_TO_BOB=1 fi zle down-line-or-history if [[ $DO_MOVE_TO_BOB == 1 ]]; then zle beginning-of-buffer fi else zle history-beginning-search-forward fi } zle -N up-line-or-beginning-search-backward zle -N down-line-or-beginning-search-forward #bindkey "\e[A" up-line-or-beginning-search-backward #bindkey "\e[B" down-line-or-beginning-search-forward --pf9I7BMVVzbSWLtt--