split dual-roled function into two distinct ones

This commit is contained in:
Suraj N. Kurapati 2011-05-25 11:03:01 -07:00
parent 56d178984e
commit 9fd4576ae7

View file

@ -43,12 +43,8 @@ F_ordinary_highlight="bg=magenta,fg=white,bold"
F_out_of_matches_highlight="bg=red,fg=white,bold"
F_max_buffer_size=250000
history-substring-search-backward() {
emulate -L zsh
history-substring-search-begin() {
setopt extendedglob
zmodload -i zsh/parameter
F_zsh_highlighting_available=0
@ -81,8 +77,20 @@ history-substring-search-backward() {
# initial value of $F_match_number, which can initially only be decreased by
# ${WIDGET/forward/backward}
fi
}
history-substring-search-end() {
CURSOR=${#BUFFER}
#"zle .end-of-line" does not move CURSOR to the final end of line in multi-line buffers.
# for debugging purposes:
# zle -R "mn: "$F_match_number" m#: "${#F_matches}
# read -k -t 200 && zle -U $REPLY
}
history-substring-search-backward() {
history-substring-search-begin
if [[ $WIDGET = *backward* ]]; then # we have pressed arrow-up
if [[ ($F_match_number -ge 2 && $F_match_number -le $F_number_of_matches_plus_one) ]]; then
let "F_match_number = $F_match_number - 1"
F_command_to_be_retrieved=$history[$F_matches[$F_match_number]]
@ -130,7 +138,13 @@ history-substring-search-backward() {
fi
fi
fi
else # arrow-down
history-substring-search-end
}
history-substring-search-forward() {
history-substring-search-begin
if [[ ($F_match_number -eq $F_number_of_matches_plus_one ) ]]; then
let "F_match_number = $F_match_number"
F_old_buffer_forward=$BUFFER
@ -183,16 +197,12 @@ history-substring-search-backward() {
fi
fi
fi
fi
CURSOR=${#BUFFER}
#"zle .end-of-line" does not move CURSOR to the final end of line in multi-line buffers.
# for debugging purposes:
# zle -R "mn: "$F_match_number" m#: "${#F_matches}
# read -k -t 200 && zle -U $REPLY
history-substring-search-end
}
zle -N history-substring-search-forward history-substring-search-backward
zle -N history-substring-search-backward
zle -N history-substring-search-forward
bindkey '\e[A' history-substring-search-backward
bindkey '\e[B' history-substring-search-forward