Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: history-incremental-search-backward with a twist



On Sep 29,  5:51pm, Hannu Koivisto wrote:
} Subject: Re: history-incremental-search-backward with a twist
}
} |     function beginning-incremental-search {
} | 	if [[ $LASTWIDGET == $WIDGET ]]
} | 	then zle .$WIDGET
} | 	else zle .$WIDGET $LBUFFER
} | 	fi
} |     }
} | 
} |     zle -N history-incremental-search-backward beginning-incremental-search
} |     zle -N history-incremental-search-forward beginning-incremental-search
} 
} This doesn't seem to do what I want.   [...]  That
} is, your change seems to insert to the bck-i-search: -prompt, as if
} I had written it, what I have on the command line at the moment I
} invoke the search.

Everything to the left of the cursor at the moment you invoke the search,
but otherwise yes.

} In order to do what I want, such insertion
} would work only if a) the search would be regexp search and b) it
} inserted "^<what I have on the command line>.*" instead of just
} "<what I have on the command line>".

Ah.  Well, zsh doesn't have re-search, though it does recognize "^" as
anchoring to beginning of line.  So you could change one line of the
above to

    else zle .$WIDGET "^$LBUFFER"

Beyond that, try looking at Functions/Zle/incremental-complete-word in the
distribution for ideas of how to implement something more like you want.
Or Functions/Zle/predict-on might be easier to modify -- you'd have to
replace `zle .history-beginning-search-backward' with your own search.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   



Messages sorted by: Reverse Date, Date, Thread, Author