From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12036 invoked from network); 8 Sep 1999 15:28:26 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 8 Sep 1999 15:28:25 -0000 Received: (qmail 2670 invoked by alias); 8 Sep 1999 15:28:00 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 2582 Received: (qmail 2662 invoked from network); 8 Sep 1999 15:27:59 -0000 Message-Id: <199909081527.RAA19661@paris.ifh.de> X-Authentication-Warning: paris.ifh.de: pws owned process doing -bs To: zsh-users@sunsite.auc.dk Subject: Re: is there a mix of history-search-backward and history-beginning-search-backward In-reply-to: "Andy Spiegl"'s message of "Wed, 08 Sep 1999 15:02:13 +0200." <19990908150213.D4878@br-online.de> Date: Wed, 08 Sep 1999 17:27:57 +0200 From: Peter Stephenson Andy Spiegl wrote: > A while ago I asked: > > > > I want to bind to ^P a widget that acts like > > history-beginning-search-backward, but always moves the cursor to the end > > of the line, like history-search-backward does. Or said the other way: > > I want history-search-backward to look at more than the first word. > > > > Do you know a way to get this behavior? > > Does noone have any idea about this? Sorry, I meant to try this and then got sidetracked into things like applying patches. I assume you're using zsh 3.1, in which case it's not so hard: probably you need 3.1.6 for the $LASTWIDGET test to work, which is crucial. I've called the functions history-beginning-search-{back,for}ward-end. If you shorten the names, you will need to change the pattern matched against $LASTWIDGET, because the functions need to know that one of the two was called last, and hence the position to compare up to is already set. (Wasted ten minutes wondering why an `if' with a missing `then' didn't work. I think we're too lenient with the syntax.) I might put these in the Functions/Zle directory (after Bart has found out whatever's wrong with them). # function history-beginning-search-forward-end { # history-beginning-search-forward, with cursor at end. integer ocursor=$CURSOR stat if [[ $LASTWIDGET = history-beginning-search-(back|for)ward-end ]]; then # Last widget called set $hbs_pos. CURSOR=$hbs_pos else hbs_pos=$CURSOR fi if zle history-beginning-search-forward; then # success, go to end of line zle end-of-line else # failure, restore position CURSOR=$ocursor return 1 fi # } # function history-beginning-search-backward-end { # history-beginning-search-backward, with cursor at end. integer ocursor=$CURSOR stat if [[ $LASTWIDGET = history-beginning-search-(back|for)ward-end ]]; then # Last widget called set $hbs_pos. CURSOR=$hbs_pos else hbs_pos=$CURSOR fi if zle history-beginning-search-backward; then # success, go to end of line zle end-of-line else # failure, restore position CURSOR=$ocursor return 1 fi # } -- Peter Stephenson Tel: +39 050 844536 WWW: http://www.ifh.de/~pws/ Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy