main: Save user options in a single variable

This commit is contained in:
Matthew Martin 2017-11-24 10:05:13 -06:00
parent 749b30221d
commit 2a50614579

View File

@ -194,25 +194,8 @@ _zsh_highlight_main__stack_pop() {
# Main syntax highlighting function. # Main syntax highlighting function.
_zsh_highlight_highlighter_main_paint() _zsh_highlight_highlighter_main_paint()
{ {
## Before we even 'emulate -L', we must test a few options that would reset. # Before we even 'emulate -L', save the user's options
if [[ -o interactive_comments ]]; then local -A useroptions=("${(@kv)options}")
local interactive_comments= # set to empty
fi
if [[ -o ignore_braces ]] || eval '[[ -o ignore_close_braces ]] 2>/dev/null'; then
local right_brace_is_recognised_everywhere=false
else
local right_brace_is_recognised_everywhere=true
fi
if [[ -o path_dirs ]]; then
integer path_dirs_was_set=1
else
integer path_dirs_was_set=0
fi
if [[ -o multi_func_def ]]; then
integer multi_func_def=1
else
integer multi_func_def=0
fi
emulate -L zsh emulate -L zsh
setopt localoptions extendedglob bareglobqual setopt localoptions extendedglob bareglobqual
@ -245,10 +228,15 @@ _zsh_highlight_highlighter_main_paint()
# ":" for 'then' # ":" for 'then'
local braces_stack local braces_stack
if (( path_dirs_was_set )); then if [[ $useroptions[ignorebraces] == on || ${useroptions[ignoreclosebraces]:-off} == on ]]; then
local right_brace_is_recognised_everywhere=false
else
local right_brace_is_recognised_everywhere=true
fi
if [[ $useroptions[pathdirs] == on ]]; then
options_to_set+=( PATH_DIRS ) options_to_set+=( PATH_DIRS )
fi fi
unset path_dirs_was_set
ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR=( ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR=(
'|' '||' ';' '&' '&&' '|' '||' ';' '&' '&&'
@ -322,8 +310,13 @@ _zsh_highlight_highlighter_main_paint()
integer in_redirection integer in_redirection
# Processing buffer # Processing buffer
local proc_buf="$buf" local proc_buf="$buf"
for arg in ${interactive_comments-${(z)buf}} \ local -a args
${interactive_comments+${(zZ+c+)buf}}; do if [[ $useroptions[interactivecomments] == on ]]; then
args=(${(zZ+c+)buf})
else
args=(${(z)buf})
fi
for arg in $args; do
# Initialize $next_word. # Initialize $next_word.
if (( in_redirection )); then if (( in_redirection )); then
(( --in_redirection )) (( --in_redirection ))
@ -412,7 +405,7 @@ _zsh_highlight_highlighter_main_paint()
# Handle the INTERACTIVE_COMMENTS option. # Handle the INTERACTIVE_COMMENTS option.
# #
# We use the (Z+c+) flag so the entire comment is presented as one token in $arg. # We use the (Z+c+) flag so the entire comment is presented as one token in $arg.
if [[ -n ${interactive_comments+'set'} && $arg[1] == $histchars[3] ]]; then if [[ $useroptions[interactivecomments] == on && $arg[1] == $histchars[3] ]]; then
if [[ $this_word == *(':regular:'|':start:')* ]]; then if [[ $this_word == *(':regular:'|':start:')* ]]; then
style=comment style=comment
else else
@ -648,7 +641,7 @@ _zsh_highlight_highlighter_main_paint()
_zsh_highlight_main__stack_pop 'R' style=reserved-word _zsh_highlight_main__stack_pop 'R' style=reserved-word
fi;; fi;;
$'\x28\x29') # possibly a function definition $'\x28\x29') # possibly a function definition
if (( multi_func_def )) || false # TODO: or if the previous word was a command word if [[ $useroptions[multifuncdef] == on ]] || false # TODO: or if the previous word was a command word
then then
next_word+=':start:' next_word+=':start:'
fi fi