Skip to content

Commit

Permalink
syntax (layer:syntax/word): perform pathname expansions in background…
Browse files Browse the repository at this point in the history
… subshells
  • Loading branch information
akinomyoga committed Feb 20, 2021
1 parent 3cae6e4 commit 13e7bdd
Show file tree
Hide file tree
Showing 9 changed files with 633 additions and 106 deletions.
32 changes: 24 additions & 8 deletions blerc
Expand Up @@ -472,20 +472,36 @@
# bleopt filename_ls_colors="$LS_COLORS"


## The following settings controls enable or disable the syntax highlighting.
## When the setting "highlight_syntax" has a non-empty value, the syntax
## highlighting is enabled. When the setting "highlight_filename" has a
## non-empty value, the highlighting based on the filename and the command name
## is enabled during the process of the syntax highlighting. Similarly, when
## the setting "highlight_variable" has a non-empty value, the highlighting
## based on the variable type is enabled. All of these settings have non-empty
## values by default.
## The following settings enable or disable the syntax highlighting. When the
## setting "highlight_syntax" has a non-empty value, the syntax highlighting is
## enabled. When the setting "highlight_filename" has a non-empty value, the
## highlighting based on the filename and the command name is enabled during
## the process of the syntax highlighting. Similarly, when the setting
## "highlight_variable" has a non-empty value, the highlighting based on the
## variable type is enabled. All of these settings have non-empty values by
## default.

# bleopt highlight_syntax=
# bleopt highlight_filename=
# bleopt highlight_variable=


## The following settings control the timeout for the pathname expansions
## performed in the syntax highlighting. When the word contains a glob pattern
## that takes a long time to evaluate the pathname expansion, the syntax
## highlighting based on the filename is canceled based on the timeouts
## specified by these settings. "highlight_timeout_sync" /
## "highlight_timeout_async" specify the timeout durations in milliseconds to
## be used for the foreground / background syntax highlighting, respectively.
## When the timeout occurred in the foreground, the syntax highlighting will be
## deferred to the background syntax highlighting. When the timeout occurred
## in the background, the syntax highlighting for the filename is canceled.
## When the value is empty, the corresponding timeout is disabled.

# bleopt highlight_timeout_sync=500
# bleopt highlight_timeout_async=5000


## The following settings specify graphic styles of each faces.

# ble-color-setface region fg=white,bg=60
Expand Down
12 changes: 6 additions & 6 deletions lib/core-complete.sh
Expand Up @@ -1962,12 +1962,12 @@ function ble/complete/progcomp/.compvar-generate-subwords/impl1 {
point=0 words=()

# 単語毎に評価 (前半)
local evaluator=eval-noglob
((${#ret[@]}==1)) && evaluator=eval
local eval_opts=noglob
((${#ret[@]}==1)) && eval_opts=
ble/syntax:bash/simple-word#break-word "$left"
local subword
for subword in "${ret[@]}"; do
ble/syntax:bash/simple-word/"$evaluator" "$subword"
ble/syntax:bash/simple-word/eval "$subword" "$eval_opts"
ble/array#push words "$ret"
((point+=${#ret}))
done
Expand All @@ -1977,7 +1977,7 @@ function ble/complete/progcomp/.compvar-generate-subwords/impl1 {
ble/syntax:bash/simple-word#break-word "$right"
local subword isfirst=1
for subword in "${ret[@]}"; do
ble/syntax:bash/simple-word/eval-noglob "$subword"
ble/syntax:bash/simple-word/eval "$subword" noglob
if [[ $isfirst ]]; then
isfirst=
local iword=${#words[@]}; ((iword&&iword--))
Expand Down Expand Up @@ -3728,9 +3728,9 @@ function ble/complete/candidates/determine-common-prefix {
if [[ ! $is_processed ]] &&
local notilde=\'\' &&
ble/syntax:bash/simple-word/reconstruct-incomplete-word "$COMPS" &&
ble/syntax:bash/simple-word/eval-noglob "$notilde$ret" &&
ble/syntax:bash/simple-word/eval "$notilde$ret" noglob &&
local compv_notilde=$ret &&
ble/syntax:bash/simple-word/eval-noglob "$notilde$common_reconstructed" &&
ble/syntax:bash/simple-word/eval "$notilde$common_reconstructed" noglob &&
local commonv_notilde=$ret &&
COMPV=$compv_notilde ble/complete/candidates/filter:"$filter_type"/count-match-chars "$commonv_notilde"
then
Expand Down
3 changes: 2 additions & 1 deletion lib/core-syntax-def.sh
Expand Up @@ -71,7 +71,6 @@ ble/util/autoload "$_ble_base/lib/core-syntax.sh" \
ble/syntax/highlight/getg-from-filename \
ble/syntax:bash/extract-command \
ble/syntax:bash/simple-word/eval \
ble/syntax:bash/simple-word/eval-noglob \
ble/syntax:bash/simple-word/evaluate-path-spec \
ble/syntax:bash/simple-word/is-never-word \
ble/syntax:bash/simple-word/is-simple \
Expand All @@ -98,6 +97,8 @@ bleopt/declare -v filename_ls_colors ''
bleopt/declare -v highlight_syntax 1
bleopt/declare -v highlight_filename 1
bleopt/declare -v highlight_variable 1
bleopt/declare -v highlight_timeout_sync 50
bleopt/declare -v highlight_timeout_async 5000

if ((_ble_bash>=40300||_ble_bash>=40000&&!_ble_bash_loaded_in_function)); then
builtin unset -v _ble_syntax_highlight_filetype
Expand Down

0 comments on commit 13e7bdd

Please sign in to comment.