diff --git a/ble.pp b/ble.pp index 4570a81d..78527ef8 100644 --- a/ble.pp +++ b/ble.pp @@ -1184,7 +1184,7 @@ function ble-update { #%x inc.r|@|lib/core-syntax-def| #%x inc.r|@|lib/core-complete-def| -bleopt/check-all +bleopt -I #------------------------------------------------------------------------------ #%if measure_load_time time { diff --git a/contrib b/contrib index 6ed10862..5fdb7149 160000 --- a/contrib +++ b/contrib @@ -1 +1 @@ -Subproject commit 6ed108629e4aa3ad4998923ae3bcc74473475ae1 +Subproject commit 5fdb714999bf360e0970a4913c4be0a3131bcf90 diff --git a/lib/core-syntax.sh b/lib/core-syntax.sh index 3f04f38c..0b77ce91 100644 --- a/lib/core-syntax.sh +++ b/lib/core-syntax.sh @@ -6420,7 +6420,7 @@ function ble/syntax/highlight/getg-from-filename { function bleopt/check:filename_ls_colors { ble/syntax/highlight/ls_colors/.parse "$value" } -value=$bleopt_filename_ls_colors bleopt/check:filename_ls_colors +bleopt -I filename_ls_colors #------------------------------------------------------------------------------ # ble/syntax/progcolor diff --git a/lib/vim-airline.sh b/lib/vim-airline.sh index 29dccd2f..1345f49c 100644 --- a/lib/vim-airline.sh +++ b/lib/vim-airline.sh @@ -356,6 +356,7 @@ function ble/prompt/backslash:lib/vim-airline { done } +bleopt -I vim_airline_@ bleopt keymap_vi_mode_show= bleopt prompt_status_line='\q{lib/vim-airline}' bleopt prompt_status_align=$'justify=\r' diff --git a/memo/ChangeLog.md b/memo/ChangeLog.md index acb345c9..ddcf1e76 100644 --- a/memo/ChangeLog.md +++ b/memo/ChangeLog.md @@ -46,7 +46,9 @@ - prompt: track dependencies and detect changes `#D1590` `#D1591` cf8d949 - prompt: preserve `LINES` and `COLUMNS` for custom sequences `#D1592` 040016d - color: fix the face initialiation order for uses in prompts (motivated by jmederosalvarado) `#D1593` 321371f - - prompt: support `contrib/prompt-git` dirty checking `#D1601` b2713d9 + - prompt (`contrib/prompt-git`): support dirty checking `#D1601` b2713d9 + - prompt (`contrib/prompt-git`): do not use `ble/util/idle` in Bash 3 `#D1606` 0000000 + - util (`bleopt`): add new option `-I` to reinitialize user settings on reload `#D1607` 0000000 - util, color: refactor configuration interfaces (`bleopt`, `blehook`, `ble-face`) `#D1568` c94d292 - color: support new face setting function `ble-face` - util (`bleopt`): support option `-r` and `-u` and wildcards in option names diff --git a/note.txt b/note.txt index 88cae45f..e62410f8 100644 --- a/note.txt +++ b/note.txt @@ -4683,6 +4683,53 @@ bash_tips 2021-06-12 + * reject: idle: 時々自動的に表示更新をかけるべきではないか [#D1608] + + 裏で処理が走っている間に状態が変化してそれを表示に反映させたい時にはどうす + るのか。現在の実装だとその様な仕組みにはなっていない筈。例えば + textarea#invalidate を実行した時にその場で反映されるだろうか。 + + 処理が一巡したら、もしくはn巡したら更新するのも良い気がする。否、時間を決め + て置いてある程度時間が経ったら更新するというのでも良い。しかしそれならば、 + 普通の task として n 秒置きに更新をかけるというので良い気がする。その様にし + ておけば idle の他の処理が終わった後でも更新を確認し続ける様になるし自然な + 実装であるように思われる。 + + それとは別に idle 内部の動作によって表示を更新する必要があるのであれば、そ + の動作を起こした側でその場で更新をかけるか或いは新しく task を投入するかす + るべきなのである。 + + * util (bleopt): 遅延定義された設定項目の check [#D1607] + + airline: ble-reload する時に状態が書き換わってしまっているのに bleopt + vim_airline_theme=light の儘なので初期化が正しく為されない。うーん。既定値 + から再設定される筈なのだがそれも正しく処理されていない? と思ったがそれは + ble.sh のロード時に処理される事なので遅延ロードされるモジュールの設定には当 + て嵌まらないという事。遅延ロードされる時にはその場で "設定" を再現する必要 + があるのではないか? 然し、そうすると関連する関数が既に定義済みでないと正し + く動作しない事になる。或いは bleopt -I vim_airline_@ 的な関数を最後に呼び出 + して最初期化を強制するという可能性もある。 + + 現在遅延定義される設定項目は恐らく vim_airline 及び vim_surround に限られる。 + complete, syntax は ble.sh に設定項目を定義しているので問題にならない。 + + * done: vim-airline で bleopt -I vim_airline_@ を実行する + + * done: 他にも影響のある場所がないか確認する。特に bleopt/check: + を定義しているオプションで、ble.pp の "bleopt -I" よりも後に実行 + される可能性のある物が対象である。 + + 確認した所 core-syntax.sh で定義されている check:filename_ls_colors が怪 + しい。と思って実際に確認してみた所ちゃんと対策は為されていた。今回のこの + 対策を bleopt -I を使う物に置き換える事にする。 + + * ok: update wiki と思ったが、元々 bleopt はそんなに詳しく説明していなかっ + た。bleopt -u も bleopt -r も wiki には説明が書かれていないので、bleopt + -I について今すぐに追加しなければならないという事はない気がする。一方で、 + bleopt のもっと詳しい説明についてはいつか書かなければならない。 + + * prompt-git: bash 3 では async にできない→修正した [#D1606] + * history: cygwin に於いて arg_offset を処理していない気がするが大丈夫なのか [#D1605] ble/builtin/history/.load-recent-entries から append:count=$delta という形 diff --git a/src/util.sh b/src/util.sh index 5903df8c..28ff5931 100644 --- a/src/util.sh +++ b/src/util.sh @@ -20,6 +20,7 @@ function bleopt/.read-arguments/process-option { flags=E$flags ;; (reset) flags=r$flags ;; (changed) flags=u$flags ;; + (initialize) flags=I$flags ;; (*) ble/util/print "bleopt: unrecognized long option '--$name'." >&2 flags=E$flags ;; @@ -47,6 +48,7 @@ function bleopt/expand-variable-pattern { ## n --color=never ## r --reset ## u --changed +## I --initialize ## @var[out] pvars ## @var[out] specs function bleopt/.read-arguments { @@ -69,6 +71,7 @@ function bleopt/.read-arguments { case $c in (r) bleopt/.read-arguments/process-option reset ;; (u) bleopt/.read-arguments/process-option changed ;; + (I) bleopt/.read-arguments/process-option initialize ;; (*) ble/util/print "bleopt: unrecognized option '-c'." >&2 flags=E$flags ;; @@ -152,11 +155,12 @@ function bleopt { ' Set ble.sh options. Without arguments, this prints all the settings.' \ '' \ ' Options' \ - ' --help Print this help.' \ - ' -r, --reset Reset options to the default values' \ - ' -u, --changed Only select changed options' \ + ' --help Print this help.' \ + ' -r, --reset Reset options to the default values' \ + ' -I, --initialize Re-initialize settings' \ + ' -u, --changed Only select changed options' \ ' --color[=always|never|auto]' \ - ' Change color settings.' \ + ' Change color settings.' \ '' \ ' Arguments' \ ' NAME Print the value of the option.' \ @@ -183,11 +187,19 @@ function bleopt { if [[ $flags == *r* ]]; then local var for var in "${pvars[@]}"; do - local def=_ble_opt_def_${var#bleopt_} + local name=${var#bleopt_} + ble/is-function bleopt/obsolete:"$name" && continue + local def=_ble_opt_def_$name [[ ${!def+set} && ${!var-} != "${!def}" ]] && ble/array#push specs "$var=${!def}" done pvars=() + elif [[ $flags == *I* ]]; then + local var + for var in "${pvars[@]}"; do + bleopt/reinitialize "${var#bleopt_}" + done + pvars=() fi if ((${#specs[@]})); then @@ -256,21 +268,20 @@ function bleopt/declare { esac return 0 } -function bleopt/check-all { - local name defname varname - for defname in "${!_ble_opt_def_@}"; do - name=${defname#_ble_opt_def_} - varname=bleopt_$name - [[ ${!varname} == "${!defname}" ]] && continue - ble/is-function bleopt/obsolete:"$name" && continue - ble/is-function bleopt/check:"$name" || continue - - # 一旦値を既定値に戻して改めてチェックを行う。 - local value=${!varname} - builtin eval -- "$varname=\$$defname" - bleopt/check:"$name" && - builtin eval "$varname=\$value" - done +function bleopt/reinitialize { + local name=$1 + local defname=_ble_opt_def_$name + local varname=bleopt_$name + [[ ${!defname+set} ]] || return 1 + [[ ${!varname} == "${!defname}" ]] && return 0 + ble/is-function bleopt/obsolete:"$name" && return 0 + ble/is-function bleopt/check:"$name" || return 0 + + # 一旦値を既定値に戻して改めてチェックを行う。 + local value=${!varname} + builtin eval -- "$varname=\$$defname" + bleopt/check:"$name" && + builtin eval "$varname=\$value" } ## @bleopt input_encoding