Skip to content

Commit

Permalink
decode: check "bind -X" first to store the original bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Dec 19, 2019
1 parent 82a1e0b commit 4057ff0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
15 changes: 14 additions & 1 deletion memo.txt
Expand Up @@ -3265,9 +3265,22 @@ bash_tips
Done (実装ログ)
-------------------------------------------------------------------------------

2019-12-18

* bind -X の修正が入ったのでキーバインドの復元に bind -X を入れられる [#D1179]
またユーザ設定を起動時に読み取るというのもできるのではないか。

→確認したところ既に復元の時に bind -X を入れる様になっていた。
つまり bind -r した設定も一緒に復元されてしまう。
他の bind で上書きしたのが復元されてしまうのは困るので、
他の bind の復元の方を後に持ってくる様に変更する事にした。

ユーザ設定を起動時に読み取るのは面倒なので対応しなくて良い気がする。
そもそも bind -x に限らず現状の実装では設定を読み取る事は試みていない。

2019-12-16

* edit: 現状の実装では改行と同時に更に次の文字が来ている時 [#D1178]
* edit: 現状の実装では改行と同時に更に次の文字が来ている時 [#D1178]
その場でコマンドを実行せずに複数行編集に入るようになっている。
然し、ssh を使っている場合やそもそも使っている機械が遅い時、
簡単に複数行モードに突入してしまって使いづらい。
Expand Down
16 changes: 9 additions & 7 deletions src/decode.sh
Expand Up @@ -2450,11 +2450,12 @@ function ble/decode/attach/.generate-source-to-unbind-default {
# 1 ESC で始まる既存の binding を全て削除
# 2 bind を全て記録 at $$.bind.save
{
builtin bind -sp
if ((_ble_bash>=40300)); then
ble/bin/echo '__BINDX__'
builtin bind -X
fi
ble/bin/echo '__BINDP__'
builtin bind -sp
#%x
} | LC_ALL=C ble/decode/attach/.generate-source-to-unbind-default/.process

Expand All @@ -2466,7 +2467,7 @@ function ble/decode/attach/.generate-source-to-unbind-default/.process {
#%end.i
BEGIN {
APOS = apos "\\" apos apos;
mode = 0;
mode = 1;
}
function quote(text) {
Expand Down Expand Up @@ -2510,7 +2511,10 @@ function ble/decode/attach/.generate-source-to-unbind-default/.process {
}
}
mode == 0 && $0 ~ /^"/ {
/^__BINDP__$/ { mode = 1; next; }
/^__BINDX__$/ { mode = 2; next; }
mode == 1 && $0 ~ /^"/ {
# Workaround Bash-5.0 bug (cf #D1078)
sub(/^"\\C-\\\\\\"/, "\"\\C-\\\\\"");
sub(/^"\\C-\\"/, "\"\\C-\\\\\"");
Expand All @@ -2520,9 +2524,7 @@ function ble/decode/attach/.generate-source-to-unbind-default/.process {
print "builtin bind " quote($0) > "/dev/stderr";
}
/^__BINDX__$/ { mode = 1; }
mode == 1 && $0 ~ /^"/ {
mode == 2 && $0 ~ /^"/ {
output_bindr($0);
line = $0;
Expand All @@ -2540,7 +2542,7 @@ function ble/decode/attach/.generate-source-to-unbind-default/.process {
#% # escape には以下の種類がある: \C-a など \C-? \e \\ \"
#% # \n\r\f\t\v\b\a 等は使われない様だ。
#%if use_gawk
if (match(line, /^("([^"\\]|\\.)*":) "(([^"\\]|\\.)*)"/,captures) > 0) {
if (match(line, /^("([^"\\]|\\.)*":) "(([^"\\]|\\.)*)"/, captures) > 0) {
sequence = captures[1];
command = captures[3];
Expand Down

0 comments on commit 4057ff0

Please sign in to comment.