Skip to content

Commit

Permalink
sabbrev: apply sabbrev to right-hand sides of variable assignments
Browse files Browse the repository at this point in the history
* complete (source:argument): fallback to rhs completion also for "name+=rhs"
* syntax: fix unrecognized variable assignment of the form "echo arr[i]+=rhs"
* global: normalize to "_a-zA-Z[0-9]" for bracket expressions
  • Loading branch information
akinomyoga committed Mar 9, 2023
1 parent f2aa32b commit 41faa49
Show file tree
Hide file tree
Showing 10 changed files with 155 additions and 64 deletions.
8 changes: 6 additions & 2 deletions docs/ChangeLog.md
Expand Up @@ -26,7 +26,7 @@
- prompt: support multiline `prompt_rps1` `#D1502` 4fa139a
- canvas: fix wrong coordinate calculation on linefolding (reported by telometto) `#D1602` 9badb5f
- prompt: fix coordinates after `prompt_rps1` `#D1972` e128801
- prompt: clear remaining SGR after `prompt_rps1` (reported by linwaytin) `#D2003` xxxxxxx
- prompt: clear remaining SGR after `prompt_rps1` (reported by linwaytin) `#D2003` ea99d944
- syntax: support tilde expansions in parameter expansions `#D1513` 0506df2
- decode: support `ble-bind -m KEYMAP --cursor DECSCUSR` (motivated by jmederosalvarado) `#D1514` `#D1515` `#D1516` 79d671d
- decode: reflect changes after `ble-bind --cursor` `#D1873` 39efcf9
Expand All @@ -50,7 +50,7 @@
- prompt (`contrib/prompt-git`): do not use `ble/util/idle` in Bash 3 `#D1606` 959cf27
- util (`bleopt`): add new option `-I` to reinitialize user settings on reload `#D1607` 959cf27
- vi (vi_cmap): fix wrong prompt calculations by the outdated initial values `#D1653` 2710b23
- vim-airline: measure separator widths and fix layout of status line `#D1999` 1ce0d1ad xxxxxxx
- vim-airline: measure separator widths and fix layout of status line `#D1999` 1ce0d1ad 478c9a10
- 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
Expand Down Expand Up @@ -241,6 +241,8 @@
- color: rearrange color table by `ble palette` (suggested by stackoverflow/caoanan) `#D1961` bb8541d
- util (`ble/util/idle`): process events before idle sleep `#D1980` 559d64b
- keymap/vi (`decompose-meta`): translate <kbd>S-a</kbd> to <kbd>A</kbd> `#D1988` 600e845
- sabbrev: apply sabbrev to right-hand sides of variable assignments `#D2006` xxxxxxxx
- complete (`source:argument`): fallback to rhs completion also for `name+=rhs` `#D2006` xxxxxxxx

## Fixes

Expand Down Expand Up @@ -370,6 +372,7 @@
- keymap/vi (`expand-range-for-linewise-operator`): fix the end point being not extended `#D1994` bce2033
- keymap/vi (`operator:filter`): do not append newline at the end of line `#D1994` bce2033
- highlight: fix shifted error marks after delayed `core-syntax` `#D2000` f4145f16
- syntax: fix unrecognized variable assignment of the form `echo arr[i]+=rhs` `#D2007` xxxxxxxx

## Documentation

Expand Down Expand Up @@ -565,6 +568,7 @@
- util: replace builtin `readonly` with a shell function (requested by mozirilla213) `#D1985` 8683c84 e4758db
- global: avoid directly using `/dev/tty` `#D1986` a835b83
- util: add `ble/util/message` `#D2001` 2a524f34
- global: normalize bracket expressions to `_a-zA-Z` / `_a-zA-Z0-9` `#D2006` xxxxxxxx

## Contrib

Expand Down
38 changes: 29 additions & 9 deletions lib/core-complete.sh
Expand Up @@ -3799,7 +3799,7 @@ function ble/complete/progcomp/.split-alias-words {
done

# skip assignments/redirections
local i=0 rex_assign='^[a-zA-Z_0-9]+(\['$_ble_syntax_bash_simple_rex_element'*\])?\+?='
local i=0 rex_assign='^[_a-zA-Z0-9]+(\['$_ble_syntax_bash_simple_rex_element'*\])?\+?='
while ((i<${#words[@]})); do
if [[ ${words[i]} =~ $rex_assign ]]; then
((i++))
Expand Down Expand Up @@ -4759,7 +4759,7 @@ function ble/complete/mandb:help/generate-cache {
}
cfg_usage {
if (NR <= 20 && (g_usage_start || $0 ~ /^[a-zA-Z_0-9]|^[^-[:space:]][^[:space:]]*(: |:)/) ) {
if (NR <= 20 && (g_usage_start || $0 ~ /^[_a-zA-Z0-9]|^[^-[:space:]][^[:space:]]*(: |:)/) ) {
g_usage_start = 1;
usage_parse($0);
} else if (/^[[:space:]]*$/)
Expand Down Expand Up @@ -5260,7 +5260,7 @@ function ble/complete/source:argument {
#----------------------------------------------------------------------------
# 3. Attempt rhs completion

if local rex='^/?[-_a-zA-Z0-9.]+[:=]|^-[^-/=:]'; [[ $COMPV =~ $rex ]]; then
if local rex='^/?[-_a-zA-Z0-9.]+\+?[:=]|^-[^-/=:]'; [[ $COMPV =~ $rex ]]; then
# var=filename --option=filename /I:filename など。
local prefix=$BASH_REMATCH value=${COMPV:${#BASH_REMATCH}}
local COMP_PREFIX=$prefix
Expand Down Expand Up @@ -5688,7 +5688,7 @@ function ble/complete/candidates/.filter-word-by-prefix {
function ble/complete/candidates/.initialize-rex_raw_paramx {
local element=$_ble_syntax_bash_simple_rex_element
local open_dquot=$_ble_syntax_bash_simple_rex_open_dquot
rex_raw_paramx='^('$element'*('$open_dquot')?)\$[a-zA-Z_][a-zA-Z_0-9]*$'
rex_raw_paramx='^('$element'*('$open_dquot')?)\$[_a-zA-Z][_a-zA-Z0-9]*$'
}

## 候補フィルタ (candidate filters) は以下の関数を通して実装される。
Expand Down Expand Up @@ -8369,16 +8369,36 @@ function ble/complete/sabbrev/locate-key {
ble/complete/context:syntax/generate-sources
for src in "${sources[@]}"; do
ble/string#split-words asrc "$src"
[[ ${asrc[0]} =~ $rex_source_type ]] &&
((asrc[1]<pos)) &&
pos=${asrc[1]}
[[ ${asrc[0]} =~ $rex_source_type ]] || continue

if [[ ${asrc[0]} == argument ]]; then
# source:argument かつ変数代入形式の時は右辺を sabbrev の対象とする。
# wtype を (恰も declare の引数の様に) ATTR_VAR にして find-rhs を呼び出
# す。
local wtype=$_ble_attr_VAR wbeg=${asrc[1]} wlen=$((comp_index-asrc[1])) ret
ble/syntax:bash/find-rhs "$wtype" "$wbeg" "$wlen" long-option &&
asrc[0]=rhs asrc[1]=$ret
fi

if [[ ${asrc[0]} == rhs ]]; then
# 変数代入形式の右辺では : で区切った最後のフィールドを対象とする。最後の
# unquoted colon まで読み飛ばす。[Note: 文法情報の参照をすればより厳密に
# 決定できるかもしれないが今は実装しない]
local rex_element
ble/syntax:bash/simple-word/get-rex_element :
local rex='^:*('$rex_element':+)'
[[ ${_ble_edit_str:asrc[1]:comp_index-asrc[1]} =~ $rex ]] &&
((asrc[1]+=${#BASH_REMATCH}))
fi

((asrc[1]<pos)) && pos=${asrc[1]}
done
((pos<comp_index))
}

function ble/complete/sabbrev/expand {
local pos comp_index=$_ble_edit_ind comp_text=$_ble_edit_str
ble/complete/sabbrev/locate-key 'file|command|argument|variable:w|wordlist:.*|sabbrev'
((pos<comp_index)) || return 1
ble/complete/sabbrev/locate-key 'file|command|argument|variable:w|wordlist:.*|sabbrev|rhs' || return 1

local key=${_ble_edit_str:pos:comp_index-pos}
local ret; ble/complete/sabbrev/get "$key" || return 1
Expand Down
33 changes: 17 additions & 16 deletions lib/core-syntax-def.sh
Expand Up @@ -60,22 +60,23 @@ function ble/syntax:bash/is-complete { true; }

# 以下の関数に関しては遅延せずにその場で lib/core-syntax.sh をロードする
ble/util/autoload "$_ble_base/lib/core-syntax.sh" \
ble/syntax/parse \
ble/syntax/highlight \
ble/syntax/tree-enumerate \
ble/syntax/tree-enumerate-children \
ble/syntax/completion-context/generate \
ble/syntax/highlight/cmdtype \
ble/syntax/highlight/cmdtype1 \
ble/syntax/highlight/filetype \
ble/syntax/highlight/getg-from-filename \
ble/syntax:bash/extract-command \
ble/syntax:bash/simple-word/eval \
ble/syntax:bash/simple-word/evaluate-path-spec \
ble/syntax:bash/simple-word/is-never-word \
ble/syntax:bash/simple-word/is-simple \
ble/syntax:bash/simple-word/is-simple-or-open-simple \
ble/syntax:bash/simple-word/reconstruct-incomplete-word
ble/syntax/parse \
ble/syntax/highlight \
ble/syntax/tree-enumerate \
ble/syntax/tree-enumerate-children \
ble/syntax/completion-context/generate \
ble/syntax/highlight/cmdtype \
ble/syntax/highlight/cmdtype1 \
ble/syntax/highlight/filetype \
ble/syntax/highlight/getg-from-filename \
ble/syntax:bash/extract-command \
ble/syntax:bash/simple-word/eval \
ble/syntax:bash/simple-word/evaluate-path-spec \
ble/syntax:bash/simple-word/is-never-word \
ble/syntax:bash/simple-word/is-simple \
ble/syntax:bash/simple-word/is-simple-or-open-simple \
ble/syntax:bash/simple-word/reconstruct-incomplete-word \
ble/syntax:bash/simple-word/get-rex_element

#------------------------------------------------------------------------------
# グローバル変数の定義 (関数内からではできないのでここで先に定義)
Expand Down
55 changes: 30 additions & 25 deletions lib/core-syntax.sh
Expand Up @@ -933,7 +933,7 @@ function ble/syntax:text/initialize-vars { :; }
_ble_syntax_bash_RexSpaces=$'[ \t]+'
_ble_syntax_bash_RexIFSs="[$_ble_term_IFS]+"
_ble_syntax_bash_RexDelimiter="[$_ble_term_IFS;|&<>()]"
_ble_syntax_bash_RexRedirect='((\{[a-zA-Z_][a-zA-Z_0-9]*\}|[0-9]+)?(&?>>?|>[|&]|<[>&]?|<<[-<]?))[ ]*'
_ble_syntax_bash_RexRedirect='((\{[_a-zA-Z][_a-zA-Z0-9]*\}|[0-9]+)?(&?>>?|>[|&]|<[>&]?|<<[-<]?))[ ]*'

## @var _ble_syntax_bash_chars[]
## 特定の役割を持つ文字の集合。Bracket expression [~] に入れて使う為の物。
Expand Down Expand Up @@ -1088,8 +1088,8 @@ function ble/syntax:bash/simple-word/update {
local q="'"

local letter='\[[!^]|[^'${_ble_syntax_bashc_simple}']'
local param1='\$([-*@#?$!0_]|[1-9][0-9]*|[a-zA-Z_][a-zA-Z_0-9]*)'
local param2='\$\{(#?[-*@#?$!0]|[#!]?([1-9][0-9]*|[a-zA-Z_][a-zA-Z_0-9]*))\}' # ${!!} ${!$} はエラーになる。履歴展開の所為?
local param1='\$([-*@#?$!0_]|[1-9][0-9]*|[_a-zA-Z][_a-zA-Z0-9]*)'
local param2='\$\{(#?[-*@#?$!0]|[#!]?([1-9][0-9]*|[_a-zA-Z][_a-zA-Z0-9]*))\}' # ${!!} ${!$} はエラーになる。履歴展開の所為?
local param=$param1'|'$param2
local bquot='\\.'
local squot=$q'[^'$q']*'$q'|\$'$q'([^'$q'\]|\\.)*'$q
Expand Down Expand Up @@ -1552,10 +1552,10 @@ function ble/syntax:bash/simple-word/eval {
return "$ext"
}

## @fn ble/syntax:bash/simple-word/.get-rex_element sep
## @fn ble/syntax:bash/simple-word/get-rex_element sep
## 指定した分割文字 (sep) で区切られた単純単語片に一致する正規表現を構築します。
## @var[out] rex_element
function ble/syntax:bash/simple-word/.get-rex_element {
function ble/syntax:bash/simple-word/get-rex_element {
local sep=$1
local param=$_ble_syntax_bash_simple_rex_param
local bquot=$_ble_syntax_bash_simple_rex_bquot
Expand Down Expand Up @@ -1608,7 +1608,7 @@ function ble/syntax:bash/simple-word/evaluate-path-spec {
ble/opts#extract-last-optarg "$opts" fixlen 0

# compose regular expressions
local rex_element; ble/syntax:bash/simple-word/.get-rex_element "$sep"
local rex_element; ble/syntax:bash/simple-word/get-rex_element "$sep"
local rex='^['$sep']?'$rex_element'|^['$sep']'
[[ :$opts: == *:after-sep:* ]] &&
local rex='^'$rex_element'['$sep']?|^['$sep']'
Expand Down Expand Up @@ -1656,7 +1656,7 @@ function ble/syntax:bash/simple-word/detect-separated-path {

# compose regular expressions
local rex_element
ble/syntax:bash/simple-word/.get-rex_element /
ble/syntax:bash/simple-word/get-rex_element /
local rex='^'$rex_element'/?|^/'

local tail=$word head=
Expand All @@ -1673,7 +1673,7 @@ function ble/syntax:bash/simple-word/detect-separated-path {
local i
for ((i=0;i<${#sep};i++)); do
local sep1=${sep:i:1}
ble/syntax:bash/simple-word/.get-rex_element "$sep1"
ble/syntax:bash/simple-word/get-rex_element "$sep1"
local rex_nocolon='^('$rex_element')?$'
local rex_hascolon='^('$rex_element')?['$sep1']'
[[ $head =~ $rex_nocolon && $tail =~ $rex_hascolon ]] && ret=$ret$sep1
Expand Down Expand Up @@ -1729,7 +1729,7 @@ function ble/syntax:bash/simple-word/locate-filename {
local eval_opts=$opts

# compose regular expressions
local rex_element; ble/syntax:bash/simple-word/.get-rex_element "$sep"
local rex_element; ble/syntax:bash/simple-word/get-rex_element "$sep"
local rex='^'$rex_element'['$sep']|^['$sep']'
local rex_url='^[a-z]+://'

Expand Down Expand Up @@ -1797,7 +1797,7 @@ function ble/syntax:bash/simple-word#break-word {
sep=${sep//[\"\'\$\`]}

# compose regular expressions
local rex_element; ble/syntax:bash/simple-word/.get-rex_element "$sep"
local rex_element; ble/syntax:bash/simple-word/get-rex_element "$sep"
local rex='^('$rex_element')?['$sep']+'

local -a out=()
Expand Down Expand Up @@ -1984,8 +1984,8 @@ function ble/syntax:bash/check-dollar {
# Note: 初めに文字数 ${#param} の形式を試す (失敗するとしても lookahead は設定する)。
# その次に ${param...} 及び ${!param...} の形式を試す。
# これにより ${#...} の # が文字数か或いは $# か判定する。
local rex1='^(\$\{#)([-*@#?$!0]\}?|[1-9][0-9]*\}?|[a-zA-Z_][a-zA-Z_0-9]*[[}]?)'
local rex2='^(\$\{!?)([-*@#?$!0]|[1-9][0-9]*|[a-zA-Z_][a-zA-Z_0-9]*\[?)'
local rex1='^(\$\{#)([-*@#?$!0]\}?|[1-9][0-9]*\}?|[_a-zA-Z][_a-zA-Z0-9]*[[}]?)'
local rex2='^(\$\{!?)([-*@#?$!0]|[1-9][0-9]*|[_a-zA-Z][_a-zA-Z0-9]*\[?)'
if
[[ $tail =~ $rex1 ]] && {
[[ ${BASH_REMATCH[2]} == *['[}'] || $BASH_REMATCH == "$tail" ]] ||
Expand Down Expand Up @@ -2023,7 +2023,7 @@ function ble/syntax:bash/check-dollar {
i+=${#varname}))
[[ $lookahead ]] && ble/syntax/parse/set-lookahead "$lookahead"

if rex='^\$\{![a-zA-Z_][a-zA-Z_0-9]*[*@]\}?'; [[ $tail =~ $rex ]]; then
if rex='^\$\{![_a-zA-Z][_a-zA-Z0-9]*[*@]\}?'; [[ $tail =~ $rex ]]; then
ble/syntax/parse/set-lookahead 2
if [[ $BASH_REMATCH == *'}' ]]; then
# ${!head<@>} の時は末尾の @* を個別に読み取る。
Expand Down Expand Up @@ -2053,7 +2053,7 @@ function ble/syntax:bash/check-dollar {
ble/syntax/parse/nest-push "$CTX_CMDX" '$('
((i+=2))
return 0
elif rex='^\$([-*@#?$!0_]|[1-9]|[a-zA-Z_][a-zA-Z_0-9]*)' && [[ $tail =~ $rex ]]; then
elif rex='^\$([-*@#?$!0_]|[1-9]|[_a-zA-Z][_a-zA-Z0-9]*)' && [[ $tail =~ $rex ]]; then
local rematch=$BASH_REMATCH rematch1=${BASH_REMATCH[1]}
((_ble_syntax_attr[i++]=CTX_PARAM))

Expand Down Expand Up @@ -2578,7 +2578,7 @@ function ble/syntax:bash/ctx-bracket-expression {
((_ble_syntax_attr[i++]=ctx,is_assign=1))
elif [[ $tail == ']+'* ]]; then
ble/syntax/parse/set-lookahead 2
[[ $tail == ']+=' ]] && ((_ble_syntax_attr[i]=ctx,i+=2,is_assign=1))
[[ $tail == ']+='* ]] && ((_ble_syntax_attr[i]=ctx,i+=2,is_assign=1))
fi

if [[ $is_assign ]]; then
Expand Down Expand Up @@ -2884,15 +2884,15 @@ function ble/syntax:bash/ctx-expr/.count-brace {
function ble/syntax:bash/ctx-expr {
# 式の中身
local rex
if rex='^[a-zA-Z_][a-zA-Z_0-9]*'; [[ $tail =~ $rex ]]; then
if rex='^[_a-zA-Z][_a-zA-Z0-9]*'; [[ $tail =~ $rex ]]; then
local rematch=$BASH_REMATCH
local ret; ble/syntax/highlight/vartype "$BASH_REMATCH" readvar:expr:global
((_ble_syntax_attr[i]=ret,i+=${#rematch}))
return 0
elif rex='^0[xX][0-9a-fA-F]*|^[0-9]+(#[0-9a-zA-Z@_]*)?'; [[ $tail =~ $rex ]]; then
((_ble_syntax_attr[i]=ATTR_VAR_NUMBER,i+=${#BASH_REMATCH}))
return 0
elif ble/syntax:bash/check-plain-with-escape "[^${_ble_syntax_bash_chars[ctx]}a-zA-Z_0-9]+" 1; then
elif ble/syntax:bash/check-plain-with-escape "[^${_ble_syntax_bash_chars[ctx]}_a-zA-Z0-9]+" 1; then
return 0
elif [[ $tail == ['][()}']* ]]; then
local char=${tail::1} ntype
Expand Down Expand Up @@ -3225,7 +3225,7 @@ function ble/syntax:bash/check-variable-assignment {
# パターン一致 (var= var+= arr[ のどれか)
local suffix='[=[]'
((_ble_bash>=30100)) && suffix=$suffix'|\+=?'
local rex_assign="^([a-zA-Z_][a-zA-Z_0-9]*)($suffix)"
local rex_assign="^([_a-zA-Z][_a-zA-Z0-9]*)($suffix)"
[[ $tail =~ $rex_assign ]] || return 1
local rematch=$BASH_REMATCH
local rematch1=${BASH_REMATCH[1]} # for bash-3.1 ${#arr[n]} bug
Expand Down Expand Up @@ -4056,7 +4056,7 @@ function ble/syntax:bash/ctx-command {

if ((ctx==CTX_FARGI1)); then
# for var in ... の var の部分は変数名をチェックして着色
local rex='^[a-zA-Z_][a-zA-Z_0-9]*$' attr=$ATTR_ERR
local rex='^[_a-zA-Z][_a-zA-Z0-9]*$' attr=$ATTR_ERR
if ((i0==wbegin)) && [[ ${text:i0:i-i0} =~ $rex ]]; then
local ret; ble/syntax/highlight/vartype "$BASH_REMATCH" global; attr=$ret
fi
Expand Down Expand Up @@ -4769,6 +4769,8 @@ function ble/syntax:bash/find-end-of-array-index {
## @param[in] opts
## element-assignment
## 配列要素の場合にも変数代入の形式を許します。
## long-option
## --long-option= の形式にも強制的に対応します。
## @var[out] ret
## 右辺の開始位置を返します。
## 変数代入の形式でない時には単語の開始位置を返します。
Expand All @@ -4783,15 +4785,18 @@ function ble/syntax:bash/find-rhs {

local rex=
if ((wtype==ATTR_VAR)); then
rex='^[a-zA-Z0-9_]+(\+?=|\[)'
rex='^[_a-zA-Z0-9]+(\+?=|\[)'
elif ((wtype==CTX_VALI)); then
if [[ :$opts: == *:element-assignment:* ]]; then
# 配列要素に対しても変数代入の形式を許す
rex='^[a-zA-Z0-9_]+(\+?=|\[)|^(\[)'
rex='^[_a-zA-Z0-9]+(\+?=|\[)|^(\[)'
else
rex='^(\[)'
fi
fi
if [[ :$opts: == *:long-option:* ]]; then
rex=${rex:+$rex'|'}'^--[-_a-zA-Z0-9]+='
fi

if [[ $rex && $word =~ $rex ]]; then
local last_char=${BASH_REMATCH:${#BASH_REMATCH}-1}
Expand Down Expand Up @@ -5329,7 +5334,7 @@ function ble/syntax/completion-context/.add {
## @fn ble/syntax/completion-context/.check/parameter-expansion
## @var[in] text istat index ctx
function ble/syntax/completion-context/.check/parameter-expansion {
local rex_paramx='^(\$(\{[!#]?)?)([a-zA-Z_][a-zA-Z_0-9]*)?$'
local rex_paramx='^(\$(\{[!#]?)?)([_a-zA-Z][_a-zA-Z0-9]*)?$'
if [[ ${text:istat:index-istat} =~ $rex_paramx ]]; then
local rematch1=${BASH_REMATCH[1]}
local source=variable
Expand Down Expand Up @@ -5444,7 +5449,7 @@ function ble/syntax/completion-context/.check-prefix/ctx:next-command {
ble/syntax/completion-context/.add command "$istat"

# 変数・代入のチェック
if local rex='^[a-zA-Z_][a-zA-Z_0-9]*(\+?=)?$' && [[ $word =~ $rex ]]; then
if local rex='^[_a-zA-Z][_a-zA-Z0-9]*(\+?=)?$' && [[ $word =~ $rex ]]; then
if [[ $word == *= ]]; then
if ((_ble_bash>=30100)) || [[ $word != *+= ]]; then
# VAR=<argument>: 現在位置から argument 候補を生成する
Expand Down Expand Up @@ -5710,7 +5715,7 @@ function ble/syntax/completion-context/.check-prefix/ctx:param {
## 数式中の変数名を補完する文脈
_ble_syntax_bash_complete_check_prefix[CTX_EXPR]=expr
function ble/syntax/completion-context/.check-prefix/ctx:expr {
local tail=${text:istat:index-istat} rex='[a-zA-Z_]+$'
local tail=${text:istat:index-istat} rex='[_a-zA-Z]+$'
if [[ $tail =~ $rex ]]; then
local p=$((index-${#BASH_REMATCH}))
ble/syntax/completion-context/.add variable:a "$p"
Expand Down Expand Up @@ -5791,7 +5796,7 @@ function ble/syntax/completion-context/.search-last-istat {
## @var[in] index
## @var[out] sources
function ble/syntax/completion-context/.check-prefix {
local rex_param='^[a-zA-Z_][a-zA-Z_0-9]*$'
local rex_param='^[_a-zA-Z][_a-zA-Z0-9]*$'
local from=${1:-$((index-1))}

local ret
Expand Down
2 changes: 1 addition & 1 deletion lib/init-term.sh
Expand Up @@ -66,7 +66,7 @@ function ble/init:term/define-sgr-param {
builtin eval "$name="
fi

if [[ $name =~ ^[a-zA-Z_][a-zA-Z_0-9]*$ ]]; then
if [[ $name =~ ^[_a-zA-Z][_a-zA-Z0-9]*$ ]]; then
ble/init:term/register-varname "$name"
fi
}
Expand Down
2 changes: 1 addition & 1 deletion lib/vim-airline.sh
Expand Up @@ -132,7 +132,7 @@ function ble/lib/vim-airline/convert-theme/.setface {
}
function ble/lib/vim-airline/convert-theme {
local file=$1
sed -n 's/let s:airline_\([a-zA-Z_0-9]\{1,\}\)[^[:alnum:]]\{1,\}\(\#[0-9a-fA-F]\{6\}\)[^[:alnum:]]\{1,\}\(\#[0-9a-fA-F]\{6\}\).*/\1 \2 \3/p' "$file" |
sed -n 's/let s:airline_\([_a-zA-Z0-9]\{1,\}\)[^[:alnum:]]\{1,\}\(\#[0-9a-fA-F]\{6\}\)[^[:alnum:]]\{1,\}\(\#[0-9a-fA-F]\{6\}\).*/\1 \2 \3/p' "$file" |
while ble/bash/read face fg bg; do
ble/lib/vim-airline/convert-theme/.setface "$face" "$fg" "$bg"
done
Expand Down

0 comments on commit 41faa49

Please sign in to comment.