Skip to content

Commit

Permalink
edit: preserve the state of "READLINE_{LINE,POINT,MARK}"
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Dec 26, 2020
1 parent bc4735e commit 8379d4a
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 37 deletions.
20 changes: 18 additions & 2 deletions make_command.sh
Expand Up @@ -319,8 +319,24 @@ function sub:scan {
sub:scan/memo-numbering
}

function sub:show-contrib-in-changelog {
sed -n 's/.*([^()]* by \([^()]*\)).*/\1/p' ChangeLog.md | sort | uniq -c | sort -rn
function sub:show-contrib {
local cache_contrib_github=out/contrib-github.txt
if [[ ! ( $cache_contrib_github -nt .git/refs/remotes/origin/master ) ]]; then
{
wget 'https://api.github.com/repos/akinomyoga/ble.sh/issues?state=all&per_page=100&pulls=true' -O -
wget 'https://api.github.com/repos/akinomyoga/blesh-contrib/issues?state=all&per_page=100&pulls=true' -O -
} |
sed -n 's/^[[:space:]]*"login": "\(.*\)",$/\1/p' |
sort | uniq -c | sort -rn > "$cache_contrib_github"
fi

echo "Contributions (from ChangeLog.md)"
sed -n 's/.*([^()]* by \([^()]*\)).*/\1/p' memo/ChangeLog.md |
sort | uniq -c | sort -rn
echo

echo "Contributions (from GitHub Issues/PRs)"
cat "$cache_contrib_github"
}

#------------------------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion memo/ChangeLog.md
Expand Up @@ -11,13 +11,15 @@

- syntax: exclude <code>\\ + LF</code> at the word beginning from words (motivated by cmplstofB) `#D1431` 67e62d6
- complete: do not quote `:` and `=` in non-filename completions generated by progcomp (reported by 3ximus) `#D1434` d82535e
- edit: preserve the state of `READLINE_{LINE,POINT,MARK}` `#D1437` 0000000

## Fixes

- term: fix a bug that VTE based terminals are not recognized `#D1427` 7e16d9d
- complete: fix a problem that candidates are not updated after menu-filter (reported by 3ximus) `#D1428` 98fbc1c
- complete/mandb: fix BS contamination used by nroff to represent bold (reported by rlnore) `#D1429` b5c875a
- edit: work around the wrong job information of Bash in trap handlers (reported by 3ximus) `#D1435` 0000000
- edit: work around the wrong job information of Bash in trap handlers (reported by 3ximus) `#D1435` `#D1436` bc4735e
- edit (command-help): work around the Bash bug that tempenv vanishes with `builtin eval` `#D1438` 0000000

## Internal changes and fixes

Expand Down
81 changes: 54 additions & 27 deletions note.txt
Expand Up @@ -1199,6 +1199,22 @@ bash_tips

2020-12-19

* bug-bash: jobs in trap handlers

以下を実行して端末を resize すると (true) の偽ジョブ情報が出力される

trap '(true); jobs' WINCH

SIGWINCH に限らない。以下を実行して C-c を押しても同様の問題が発生する。

trap '(true); jobs' INT

実は直後の bind -x の中で jobs を実行しても同様。
一度でもユーザーコマンドを実行すれば偽情報は消える。

trap '(true)' INT
bind -x '"\C-t": jobs'

* Note (#D1435): blehook WINCH を処理している最中に終了したユーザのジョブがあ
るとその通知が画面に表示されない可能性がある。これは実際に起こりうるのかど
うか確認していない。
Expand All @@ -1221,17 +1237,6 @@ bash_tips

或いは simple-word element を一つずつ抽出して処理すれば良いのかもしれない。

2020-12-09

* READLINE_MARK, etc. の値が残ってしまっている。

これは ble/textarea#adjust-for-bash-bind によって設定されている値である。
コマンドを実行する時に復元・保存する様にするのが良いのではないだろうか。

* 何故か READLINE_LINE, READLINE_POINT が export されている。
と思ったが、これは ble.sh を bind -x の内部で動かしているからであった。
READLINE_LINE 及び READLINE_POINT が

2020-11-30

* color: face editor の TUI の様な物を作っても良いのかもしれない。
Expand Down Expand Up @@ -1400,22 +1405,6 @@ bash_tips
ちゃんと source:* や candidates/generate などのコメントに使う変数を記述して、
それから auto-complete の中で candidates/generate を呼び出す前に local で宣言する。

2020-09-27

* SIGWINCH で job メッセージが出る

SIGWINCH に対して次の様な job メッセージが表示される様になっている。
[1] 終了 [[ -n $_dotfiles_blesh_manual_attach ]] | [[ -n $_dotfiles_blesh_manual_attach ]]
これは .bashrc で設定されている関数の一部である。何故?

調べてみるとそもそも関数ですらなくて、
これは ble-attach を呼び出す条件の中に含まれているコマンドだと分かった。
つまり SIGWINCH に際して ble-attach 関連の何かが呼び出されて、
そして最後に呼び出された ble-attach の呼び出し時のコマンド文字列が何処かに保持されている?
もしくは再び .bashrc が source されている可能性もあるがやはりそれは変だ。

2020-10-10 今試してみると再現しない。

2020-09-07

* complete: メニュー絞り込みが働いている状態で単一確定ができない場合がある
Expand Down Expand Up @@ -3715,8 +3704,46 @@ bash_tips
Done (実装ログ)
-------------------------------------------------------------------------------

2020-12-25

* edit: f1 で関数定義を表示する時に LESS=-r が効いていない [#D1438]
これは bash のバグの様である。バグ報告は bug-report でする事にして、
ここでは簡単に修正してしまう。

* edit: 2020-12-09 READLINE_MARK, etc. の値が残ってしまっている [#D1437]

これは ble/textarea#adjust-for-bash-bind によって設定されている値である。
コマンドを実行する時に復元・保存する様にするのが良いのではないだろうか。

* 何故か READLINE_LINE, READLINE_POINT が export されている。
と思ったが、これは ble.sh を bind -x の内部で動かしているからであった。
READLINE_LINE 及び READLINE_POINT が

* 普通の bash で実行するとどうなるのかと思ったが、どうやら自分で設定した
READLINE_LINE 及び READILNE_POINT があっても bind -x の実行と共に削除され
てしまう様である。

取り敢えず adjust/restore する様にした。コマンドの実行の間で値が保存される
様にした。bind -x が実行されても値がクリアされる事はない。

2020-12-20

* [解消] 2020-09-27 SIGWINCH で job メッセージが出る [#D1436]
2020-12-20 これは #D1435 と同一の問題であろう。直ったと見て良い。

SIGWINCH に対して次の様な job メッセージが表示される様になっている。
[1] 終了 [[ -n $_dotfiles_blesh_manual_attach ]] | [[ -n $_dotfiles_blesh_manual_attach ]]
これは .bashrc で設定されている関数の一部である。何故?

調べてみるとそもそも関数ですらなくて、
これは ble-attach を呼び出す条件の中に含まれているコマンドだと分かった。
つまり SIGWINCH に際して ble-attach 関連の何かが呼び出されて、
そして最後に呼び出された ble-attach の呼び出し時のコマンド文字列が何処かに保持されている?
もしくは再び .bashrc が source されている可能性もあるがやはりそれは変だ。

2020-10-10 今試してみると再現しない。


* edit: WINCH 後に偽のジョブ情報が表示される (reported by 3ximus) [#D1435]
https://github.com/akinomyoga/ble.sh/issues/78

Expand Down
37 changes: 30 additions & 7 deletions src/edit.sh
Expand Up @@ -1466,12 +1466,13 @@ function ble-edit/content/push-kill-ring {
# **** saved variables such as (PS1/LINENO) **** @edit.ps1
#
# 内部使用変数
## 変数 _ble_edit_LINENO
## 変数 _ble_edit_CMD
## 変数 _ble_edit_PS1
## 変数 _ble_edit_IFS
## 変数 _ble_edit_IGNOREEOF_adjusted
## 変数 _ble_edit_IGNOREEOF
## @var _ble_edit_LINENO
## @var _ble_edit_CMD
## @var _ble_edit_PS1
## @var _ble_edit_IFS
## @var _ble_edit_IGNOREEOF_adjusted
## @var _ble_edit_IGNOREEOF
## @arr _ble_edit_READLINE

_ble_edit_PS1_adjusted=
_ble_edit_PS1='\s-\v\$ '
Expand Down Expand Up @@ -1514,6 +1515,23 @@ function ble-edit/restore-IGNOREEOF {
builtin unset -v IGNOREEOF
fi
}

_ble_edit_READLINE=()
function ble-edit/adjust-READLINE {
[[ $_ble_edit_READLINE ]] && return 0
_ble_edit_READLINE=1
ble/variable#copy-state READLINE_LINE '_ble_edit_READLINE[1]'
ble/variable#copy-state READLINE_POINT '_ble_edit_READLINE[2]'
ble/variable#copy-state READLINE_MARK '_ble_edit_READLINE[3]'
}
function ble-edit/restore-READLINE {
[[ $_ble_edit_READLINE ]] || return 0
_ble_edit_READLINE=
ble/variable#copy-state '_ble_edit_READLINE[1]' READLINE_LINE
ble/variable#copy-state '_ble_edit_READLINE[2]' READLINE_POINT
ble/variable#copy-state '_ble_edit_READLINE[3]' READLINE_MARK
}

## 関数 ble-edit/eval-IGNOREEOF
## @var[out] ret
function ble-edit/eval-IGNOREEOF {
Expand Down Expand Up @@ -1566,13 +1584,15 @@ function ble-edit/attach/.attach {
blehook WINCH-+=ble-edit/attach/TRAPWINCH

ble-edit/adjust-PS1
ble-edit/adjust-READLINE
ble-edit/adjust-IGNOREEOF
[[ $bleopt_internal_exec_type == exec ]] && _ble_edit_IFS=$IFS
}

function ble-edit/attach/.detach {
((!_ble_edit_attached)) && return 0
ble-edit/restore-PS1
ble-edit/restore-READLINE
ble-edit/restore-IGNOREEOF
[[ $bleopt_internal_exec_type == exec ]] && IFS=$_ble_edit_IFS
_ble_edit_attached=0
Expand Down Expand Up @@ -4607,6 +4627,7 @@ function ble-edit/exec:gexec/.prologue {
BASH_COMMAND=$1
_ble_edit_exec_BASH_COMMAND=$1
ble-edit/restore-PS1
ble-edit/restore-READLINE
ble-edit/restore-IGNOREEOF
builtin unset -v HISTCMD; ble/history/get-count -v HISTCMD
_ble_edit_exec_INT=0
Expand Down Expand Up @@ -4646,6 +4667,7 @@ function ble-edit/exec:gexec/.epilogue {
ble/base/adjust-POSIXLY_CORRECT
ble-edit/exec/.reset-builtins-2
ble-edit/adjust-IGNOREEOF
ble-edit/adjust-READLINE
ble-edit/adjust-PS1
ble-edit/exec/save-BASH_REMATCH
ble/util/reset-keymap-of-editing-mode
Expand Down Expand Up @@ -7363,7 +7385,8 @@ function ble/widget/command-help.core {
type -t source-highlight &>/dev/null &&
pager='source-highlight -s sh -f esc | '$pager
local def; ble/function#getdef "$command"
LESS="$LESS -r" builtin eval -- "$pager" <<< "$def" && return 0
local -x LESS="$LESS -r" # Note: Bash のバグで tempenv builtin eval は消滅するので #D1438
builtin eval -- "$pager" <<< "$def" && return 0
fi

if ble/is-function ble/bin/man; then
Expand Down
8 changes: 8 additions & 0 deletions src/util.sh
Expand Up @@ -363,6 +363,14 @@ function ble/variable#is-global/.test { ! local "$1" 2>/dev/null; }
function ble/variable#is-global {
(readonly "$1"; ble/variable#is-global/.test "$1")
}
function ble/variable#copy-state {
local src=$1 dst=$2
if [[ ${!src+set} ]]; then
eval "$dst=\${$src}"
else
unset "$dst"
fi
}

_ble_array_prototype=()
function ble/array#reserve-prototype {
Expand Down

0 comments on commit 8379d4a

Please sign in to comment.