From 9763da46c81b921cd82c3d145c1777ca5320050e Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Thu, 21 Mar 2002 23:03:09 +0000 Subject: 16879: Functions/Zle/up-line-or-beginning-search, Functions/Zle/down-line-or-beginning-search, Doc/Zsh/contrib.yo: originally by Bart --- widgets which combine up-line-or-search and history-beginning-search-backward behaviour. --- ChangeLog | 8 ++++++++ Doc/Zsh/contrib.yo | 11 +++++++++++ Functions/Zle/down-line-or-beginning-search | 13 +++++++++++++ Functions/Zle/up-line-or-beginning-search | 13 +++++++++++++ 4 files changed, 45 insertions(+) create mode 100644 Functions/Zle/down-line-or-beginning-search create mode 100644 Functions/Zle/up-line-or-beginning-search diff --git a/ChangeLog b/ChangeLog index defbbaeaa..e1616fbbe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2002-03-21 Peter Stephenson + + * 16879: Functions/Zle/up-line-or-beginning-search, + Functions/Zle/down-line-or-beginning-search, + Doc/Zsh/contrib.yo: originally by Bart --- widgets which + combine up-line-or-search and history-beginning-search-backward + behaviour. + 2002-03-19 Oliver Kiddle * 16864: Completion/Unix/Command/ssh: fix remote file completion diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index 21997b7d8..f21a31284 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -430,6 +430,17 @@ zle -N history-beginning-search-forward-end \ bindkey '\e^P' history-beginning-search-backward-end bindkey '\e^N' history-beginning-search-forward-end) ) +tindex(up-line-or-beginning-search) +tindex(down-line-or-beginning-search) +item(tt(up-line-or-beginning-search), tt(down-line-or-beginning-search))( +These widgets are similar to the builtin functions tt(up-line-or-search) +and tt(down-line-or-search): if in a multiline buffer they move up or +down within the buffer, otherwise they search for a history line matching +the start of the current line. In this case, however, they search for +a line which matches the current line up to the current cursor position, in +the manner of tt(history-begining-search-backward) and tt(-forward), rather +than the first word on the line. +) tindex(incarg) vindex(incarg, use of) item(tt(incarg))( diff --git a/Functions/Zle/down-line-or-beginning-search b/Functions/Zle/down-line-or-beginning-search new file mode 100644 index 000000000..881150171 --- /dev/null +++ b/Functions/Zle/down-line-or-beginning-search @@ -0,0 +1,13 @@ +# Like down-line-or-search, but uses the whole line prefix up to the +# cursor position for searching forwards. + +if [[ $LASTWIDGET != $WIDGET ]] +then + if [[ $LBUFFER == *$'\n'* ]] + then + __last_down_line=down-line-or-history + else + __last_down_line=history-beginning-search-forward + fi +fi +zle .${__last_down_line:-beep} diff --git a/Functions/Zle/up-line-or-beginning-search b/Functions/Zle/up-line-or-beginning-search new file mode 100644 index 000000000..12f2edaae --- /dev/null +++ b/Functions/Zle/up-line-or-beginning-search @@ -0,0 +1,13 @@ +# Like up-line-or-search, but uses the whole line prefix up to the +# cursor position for searching backwards. + +if [[ $LASTWIDGET != $WIDGET ]] +then + if [[ $LBUFFER == *$'\n'* ]] + then + __last_up_line=up-line-or-history + else + __last_up_line=history-beginning-search-backward + fi +fi +zle .${__last_up_line:-beep} -- cgit 1.4.1