rename _search* variables to be self-documenting
This commit is contained in:
parent
9cb4212c40
commit
1e02a2118e
1 changed files with 12 additions and 12 deletions
|
|
@ -55,16 +55,16 @@ history-substring-search-begin() {
|
||||||
# $BUFFER contains the text that is in the command-line currently.
|
# $BUFFER contains the text that is in the command-line currently.
|
||||||
# we put an extra "\\" before meta characters such as "\(" and "\)",
|
# we put an extra "\\" before meta characters such as "\(" and "\)",
|
||||||
# so that they become "\\\|" and "\\\("
|
# so that they become "\\\|" and "\\\("
|
||||||
history_substring_search_search=${BUFFER//(#m)[\][()\\*?#<>~^]/\\$MATCH}
|
history_substring_search_query_escaped=${BUFFER//(#m)[\][()\\*?#<>~^]/\\$MATCH}
|
||||||
|
|
||||||
# for the purpose of highlighting we will also keep a version without
|
# for the purpose of highlighting we will also keep a version without
|
||||||
# doubly-escaped meta characters
|
# doubly-escaped meta characters
|
||||||
history_substring_search_search4later=${BUFFER}
|
history_substring_search_query=${BUFFER}
|
||||||
|
|
||||||
# find all occurrences of the pattern *${seach}* within the history file
|
# find all occurrences of the pattern *${seach}* within the history file
|
||||||
# (k) turns it an array of line numbers. (on) seems to remove duplicates.
|
# (k) turns it an array of line numbers. (on) seems to remove duplicates.
|
||||||
# (on) are default options. they can be turned off by (ON).
|
# (on) are default options. they can be turned off by (ON).
|
||||||
history_substring_search_matches=(${(kon)history[(R)*${history_substring_search_search}*]})
|
history_substring_search_matches=(${(kon)history[(R)*${history_substring_search_query_escaped}*]})
|
||||||
|
|
||||||
# define the range of value that $history_substring_search_match_number
|
# define the range of value that $history_substring_search_match_number
|
||||||
# can take: [0, $history_substring_search_number_of_matches_plus_one]
|
# can take: [0, $history_substring_search_number_of_matches_plus_one]
|
||||||
|
|
@ -85,15 +85,15 @@ history-substring-search-highlight() {
|
||||||
_zsh_highlight-zle-buffer
|
_zsh_highlight-zle-buffer
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $history_substring_search_search4later != "" ]]; then
|
if [[ $history_substring_search_query != "" ]]; then
|
||||||
# history_substring_search_search string was not empty: highlight it
|
# history_substring_search_query_escaped string was not empty: highlight it
|
||||||
# among other things, the following expression yields a variable $MEND,
|
# among other things, the following expression yields a variable $MEND,
|
||||||
# which indicates the end position of the first occurrence of
|
# which indicates the end position of the first occurrence of
|
||||||
# $history_substring_search_search in $BUFFER
|
# $history_substring_search_query_escaped in $BUFFER
|
||||||
: ${(S)BUFFER##(#m)($history_substring_search_search4later##)}
|
: ${(S)BUFFER##(#m)($history_substring_search_query##)}
|
||||||
let "history_substring_search_my_mbegin = $MEND - $#history_substring_search_search4later"
|
let "history_substring_search_query_mbegin = $MEND - $#history_substring_search_query"
|
||||||
# this is slightly more informative than highlighting that fish performs
|
# this is slightly more informative than highlighting that fish performs
|
||||||
region_highlight=("$history_substring_search_my_mbegin $MEND $1")
|
region_highlight=("$history_substring_search_query_mbegin $MEND $1")
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -120,7 +120,7 @@ history-substring-search-backward() {
|
||||||
# we will move out of the history_substring_search_matches
|
# we will move out of the history_substring_search_matches
|
||||||
let "history_substring_search_match_number = $history_substring_search_match_number - 1"
|
let "history_substring_search_match_number = $history_substring_search_match_number - 1"
|
||||||
history_substring_search_old_buffer_backward=$BUFFER
|
history_substring_search_old_buffer_backward=$BUFFER
|
||||||
BUFFER=$history_substring_search_search4later
|
BUFFER=$history_substring_search_query
|
||||||
history-substring-search-highlight $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND
|
history-substring-search-highlight $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND
|
||||||
else
|
else
|
||||||
if [[ $history_substring_search_match_number -eq $history_substring_search_number_of_matches_plus_one ]]; then
|
if [[ $history_substring_search_match_number -eq $history_substring_search_number_of_matches_plus_one ]]; then
|
||||||
|
|
@ -141,7 +141,7 @@ history-substring-search-forward() {
|
||||||
if [[ $history_substring_search_match_number -eq $history_substring_search_number_of_matches_plus_one ]]; then
|
if [[ $history_substring_search_match_number -eq $history_substring_search_number_of_matches_plus_one ]]; then
|
||||||
let "history_substring_search_match_number = $history_substring_search_match_number"
|
let "history_substring_search_match_number = $history_substring_search_match_number"
|
||||||
history_substring_search_old_buffer_forward=$BUFFER
|
history_substring_search_old_buffer_forward=$BUFFER
|
||||||
BUFFER=$history_substring_search_search4later
|
BUFFER=$history_substring_search_query
|
||||||
history-substring-search-highlight $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND
|
history-substring-search-highlight $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND
|
||||||
elif [[ $history_substring_search_match_number -ge 0 && $history_substring_search_match_number -le $history_substring_search_number_of_matches_minus_one ]]; then
|
elif [[ $history_substring_search_match_number -ge 0 && $history_substring_search_match_number -le $history_substring_search_number_of_matches_minus_one ]]; then
|
||||||
let "history_substring_search_match_number = $history_substring_search_match_number + 1"
|
let "history_substring_search_match_number = $history_substring_search_match_number + 1"
|
||||||
|
|
@ -152,7 +152,7 @@ history-substring-search-forward() {
|
||||||
if [[ $history_substring_search_match_number -eq $history_substring_search_number_of_matches ]]; then
|
if [[ $history_substring_search_match_number -eq $history_substring_search_number_of_matches ]]; then
|
||||||
let "history_substring_search_match_number = $history_substring_search_match_number + 1"
|
let "history_substring_search_match_number = $history_substring_search_match_number + 1"
|
||||||
history_substring_search_old_buffer_forward=$BUFFER
|
history_substring_search_old_buffer_forward=$BUFFER
|
||||||
BUFFER=$history_substring_search_search4later
|
BUFFER=$history_substring_search_query
|
||||||
history-substring-search-highlight $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND
|
history-substring-search-highlight $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND
|
||||||
else
|
else
|
||||||
if [[ $history_substring_search_match_number -eq 0 ]]; then
|
if [[ $history_substring_search_match_number -eq 0 ]]; then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue