Skip to content

Commit

Permalink
edit: support bash-5.2 binding of "prior/next" to "history-search-{fo…
Browse files Browse the repository at this point in the history
…r,back}ward"
  • Loading branch information
akinomyoga committed Oct 4, 2021
1 parent e5b0c86 commit d26a6e1
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
5 changes: 3 additions & 2 deletions docs/ChangeLog.md
Expand Up @@ -27,7 +27,8 @@
- syntax: support tilde expansions in parameter expansions `#D1513` 0506df2
- decode: support `ble-bind -m KEYMAP --cursor DECSCUSR` (motivated by jmederosalvarado) `#D1514` `#D1515` `#D1516` 79d671d
- edit: support `nsearch` options (motivated by Alyetama, rashil2000, carv-silva) `#D1517` 9125795
- edit: support `nsearch` opts `empty=emulate-readline` (motivated by jainpratik163) `#D1661` 0000000
- edit: support `nsearch` opts `empty=emulate-readline` (motivated by jainpratik163) `#D1661` d68ba61
- edit: support bash-5.2 binding of `prior/next` to `history-search-{for,back}ward` `#D1661` 0000000
- syntax: support the deprecated redirection `>& file` `#D1539` b9b0de4
- complete: complete file descriptors and heredoc words after redirections `#D1539` b9b0de4
- main: support `blehook ATTACH DETACH`, `BLE_ONLOAD`, `BLE_ATTACHED` `#D1543` 750ca38
Expand Down Expand Up @@ -210,7 +211,7 @@
- cmap: add `st`-specific escape sequences for cursor keys `#D1633` acfb879
- cmap: distinguish <kbd>find</kbd>/<kbd>select</kbd> from <kbd>home</kbd>/<kbd>end</kbd> for openSUSE `inputrc.keys` (reported by cornfeedhobo) `#D1648` c4d28f4
- main: work around self-modifying `PROMPT_COMMAND` by `bash-preexec` (reported by cornfeedhobo) `#D1650` 39ebf53
- decode: work around openSUSE broken `/etc/inputrc` `#D1662` 0000000
- decode: work around openSUSE broken `/etc/inputrc` `#D1662` e5b0c86

## Internal changes and fixes

Expand Down
1 change: 1 addition & 0 deletions keymap/emacs.sh
Expand Up @@ -10,6 +10,7 @@ function ble-edit/bind/load-editing-mode:emacs { :; }
# 2020-04-29 force update (rename ble-decode/keymap/.register)
# 2021-01-25 force update (change mapping of C-w and M-w)
# 2021-04-26 force update (rename ble/decode/keymap#.register)
# 2021-09-23 force update (change to nsearch and bind-history)

# vi functions referenced from core-decode.emacs-rlfunc.txt
ble/util/autoload "$_ble_base/keymap/vi.sh" \
Expand Down
1 change: 1 addition & 0 deletions keymap/vi.sh
Expand Up @@ -8,6 +8,7 @@ function ble-edit/bind/load-editing-mode:vi { :; }
# 2020-04-29 force update (rename ble-decode/keymap/.register)
# 2021-01-25 force update (change mapping of C-w and M-w)
# 2021-04-26 force update (rename ble/decode/keymap#.register)
# 2021-09-23 force update (change to nsearch and bind-history)

source "$_ble_base/keymap/vi_digraph.sh"

Expand Down
20 changes: 19 additions & 1 deletion note.txt
Expand Up @@ -1604,6 +1604,8 @@ bash_tips

2021-09-22

* edit: 複数行モードの時は prior/next でページ移動?

* git clone 用の判定

$ grep -q '^github\.com' ~/.ssh/known_hosts
Expand Down Expand Up @@ -1658,7 +1660,7 @@ bash_tips
auto-complete を実行し、sabbrev が起こらなかった時には従来の auto-complete
と同様にカーソル位置を一つ進める事を試行する。

うーん。この問題は自動候補の戦闘文字が空白の時にのみ起こる。それ以外の時に
うーん。この問題は自動候補の先頭文字が空白の時にのみ起こる。それ以外の時に
は auto-complete を抜けて再度 SP が実行されるのでちゃんと sabbrev も呼び出
される。

Expand Down Expand Up @@ -5474,6 +5476,22 @@ bash_tips
searching with Up/Down." というのはこの振る舞いに関連しての事だったのではな
いかという気がする。まあ、今となっては考えても仕方のない事なのかもしれない。

[追加]

* 対応したと思ったら動かない。と思ったが、prior に history-search-backward
を束縛しても、nsearch keymap の中で prior が束縛されていないので、続けて
prior が押されると一旦 nsearch を抜けて改めて nsearch が開始される為に、
空文字列検索を続ける事ができないという状態になっていた。nsearch keymap に
も prior/next を束縛する事にした。

ところで、ble.sh は複数行編集に対応しているので、その意味での prior/next を
解釈する方が本当は理に適っているのでは? と思ったが、複数行編集している時に
はその複数行で履歴検索したいという事はないだろうし、代わりに現在カーソルが
ある行の文字列を履歴から検索するとしても、折角複数行のコマンドを編集してい
るのに別のコマンドに移動してしまう事になるので変な感じがする。という事を考
えれば、実は「複数行の時にはページ移動で、単一行の時は履歴検索」という
widget として実装すれば良い気がする。これはまた別項目として残す事にする。

2021-09-22

* README: roadmap [#D1660]
Expand Down
4 changes: 4 additions & 0 deletions src/edit.sh
Expand Up @@ -7573,6 +7573,8 @@ function ble-decode/keymap:nsearch/define {
ble-bind -f C-n nsearch/forward
ble-bind -f up nsearch/backward
ble-bind -f down nsearch/forward
ble-bind -f prior nsearch/backward
ble-bind -f next nsearch/forward
}

#
Expand Down Expand Up @@ -7711,6 +7713,8 @@ function ble-decode/keymap:safe/bind-history {
ble-decode/keymap:safe/.bind 'up' '@nomarked backward-line history'
ble-decode/keymap:safe/.bind 'C-n' '@nomarked forward-line history'
ble-decode/keymap:safe/.bind 'down' '@nomarked forward-line history'
ble-decode/keymap:safe/.bind 'prior' 'history-search-backward' # bash-5.2
ble-decode/keymap:safe/.bind 'next' 'history-search-forward' # bash-5.2
ble-decode/keymap:safe/.bind 'C-x C-p' 'history-search-backward'
ble-decode/keymap:safe/.bind 'C-x up' 'history-search-backward'
ble-decode/keymap:safe/.bind 'C-x C-n' 'history-search-forward'
Expand Down

0 comments on commit d26a6e1

Please sign in to comment.