Skip to content

Commit

Permalink
mandb: insert a comma in brace expansions instead of a space
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Dec 22, 2021
1 parent 8d37048 commit 0ac7f03
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 16 deletions.
2 changes: 1 addition & 1 deletion contrib
Submodule contrib updated 2 files
+138 −0 prompt-defer.bash
+33 −73 prompt-git.bash
17 changes: 9 additions & 8 deletions docs/ChangeLog.md
Expand Up @@ -85,7 +85,7 @@
- complete: improve support for `declare` and `[[ ... ]]` `#D1701` da38404
- syntax: fix completion and highlighting of `declare` with assignment arguments `#D1704` `#D1705` e12bae4
- cmdspec: refactor `{mandb => cmdspec}_opts` `#D1706` `#D1707` 0786e92
- complete (menu-style:align): refactor `complete_menu_align => menu_align_{min,max}` (motivated by banoris) `#D1717` 0000000
- complete (menu-style:align): refactor `complete_menu_align => menu_align_{min,max}` (motivated by banoris) `#D1717` 22a2449

## Changes

Expand Down Expand Up @@ -129,9 +129,9 @@
- syntax: revert 371a5a4 and generate empty completion source on syntax error `#D1609` e09fcab
- syntax: strictly check variable names of `for`-statements `#D1692` d056547
- widget `self-insert`: untranslate control chars and insert the last character `#D1696` 5ff3021
- complete (`source:command`): exclude inactive aliases `#D1715` 0000000
- complete (`source:command`): not quote aliases and keywords `#D1715` 0000000
- highlight (`wtype=CTX_CMDI`): check alias names before shell expansions `#D1715` 0000000
- complete (`source:command`): exclude inactive aliases `#D1715` d6242a7
- complete (`source:command`): not quote aliases and keywords `#D1715` d6242a7
- highlight (`wtype=CTX_CMDI`): check alias names before shell expansions `#D1715` d6242a7

## Fixes

Expand All @@ -151,6 +151,7 @@
- mandb: carry optarg for e.g. `-a, --accept=LIST` `#D1687` 23d5657
- mandb: parse `--help` for specified commands `#D1693` e1ad2f1
- mandb: fix small issues of man-page analysis `#D1708` caa77bc
- mandb: insert a comma in brace expansions instead of a space `#D1719` 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` 8379d4a
- global: suppress missing locale errors (reported by 3ximus) `#D1440` 4d3c595
Expand Down Expand Up @@ -209,8 +210,8 @@
- menu (menu-style:align): fix the failure of delaying `ble/canvas/trace` on items (motivated by banoris) `#D1710` acc9661
- complete: fix empty completions with `FIGNORE` (reported by seanfarley) `#D1711` 144ea5d
- main: fix the message of owner errors of cache directories (reported by zim0369) `#D1712` b547a41
- util (`ble/string#escape-for-bash-specialchars`): fix escaping of TAB `#D1713` 0000000
- complete: fix failglob messages while progcomp for commands containing globchars `#D1716` 0000000
- util (`ble/string#escape-for-bash-specialchars`): fix escaping of TAB `#D1713` 7db3d2b
- complete: fix failglob messages while progcomp for commands containing globchars `#D1716` e26a3a8

## Documentation

Expand All @@ -237,7 +238,7 @@
- prompt: use `${PS1@P}` when the prompt contains only safe prompt sequences `#D1617` 8b5da08
- prompt: fix not properly set `$?` in `${PS1@P}` evaluation (reported by nihilismus) `#D1644` 521aff9
- decode: cache `inputrc` translations `#D1652` 994e2a5
- complete: use `awk` for batch `quote-insert` (motivated by banoris) `#D1714` 0000000
- complete: use `awk` for batch `quote-insert` (motivated by banoris) `#D1714` a0b2ad2

## Compatibility

Expand Down Expand Up @@ -268,7 +269,7 @@
- builtin: print usages of emulated builtins on option errors `#D1694` 6f74021
- decode (`ble/builtin/bind`): improve compatibility of the deprecated form `bind key:rlfunc` (motivated by cmplstofB) `#D1698` b6fc4f0
- complete: work around a false warning messages of gawk-4.0.2 `#D1709` 9771693
- main: work around `XDG_RUNTIME_DIR` of a different user by `su` (reported by zim0369) `#D1712` 0000000
- main: work around `XDG_RUNTIME_DIR` of a different user by `su` (reported by zim0369) `#D1712` 8d37048

## Internal changes and fixes

Expand Down
4 changes: 3 additions & 1 deletion lib/core-complete.sh
Expand Up @@ -3603,7 +3603,9 @@ function ble/complete/action:mandb/complete {
ble/complete/action/complete.close-quotation
local fields
ble/string#split fields "$_ble_term_FS" "$DATA"
ble/complete/action/complete.addtail "${fields[2]}"
local tail=${fields[2]}
[[ $tail == ' ' && $comps_flags == *x* ]] && tail=','
ble/complete/action/complete.addtail "$tail"
}
function ble/complete/action:mandb/init-menu-item {
local ret; ble/color/face2g argument_option; g=$ret
Expand Down
83 changes: 80 additions & 3 deletions note.txt
Expand Up @@ -1633,13 +1633,20 @@ bash_tips
ToDo
-------------------------------------------------------------------------------

2021-12-20

* README: oh-my-bash は流石に削除するべきだろう。

* git-prompt, git-status 等の機能の模倣?

2021-12-18

* contrib/git: dirty で rps1 が更新された瞬間にカーソル位置がずれた。これは後
で調べる必要がある。

* ble/util/import でファイル名に関数名として許されない文字が入っていた時の対
策が必要では。

* complete (action:mandb): brace の後は space ではなくて , にするべき。

* deprecated functions の枠組みを整える。

散発的に deprecate して行くと毎回設定を変更しなければならず面倒なので、
Expand Down Expand Up @@ -1762,7 +1769,29 @@ bash_tips
$ dnf -C repoquery --installed --whatprovides /usr/bin/\* --nvr
$ LANG=C dnf -C provides -q /usr/bin/\*

というか man -s 1:5:... -f command... を呼び出せばよいらしい。
* man -f ...

というか man -s 1:6:8 -f command... を呼び出せばよいらしい。

* linux では man -s 1:6:8 -f command 等として結果を得られる。whatis -s
1:6:8 command としても同じ出力結果である。というか whatis 自体が man に
よって実装されている疑惑 (-s オプションなどがあるので)。

* cygwin で実行したら駄目だった。whatis sed awk とした時と全く同じ出力結
果になったので、whatis を使っているのだろう。

* solaris では man -f sed は表示されるが、man -f sed awk や man -f sed -f
awk 等の様にして複数の結果を取得しようとすると何も表示されなくなる。1行
目は空行で、2行目に man ファイルの情報があって、3行目にようやく説明が表
示される。

* minix では man -f sed で whatis を間接的に呼び出そうとしている。そして
whatis はデータベースがない等の文句を言って動かない。

* freebsd でも whatis を呼び出している様だ。警告が出ているが、複数指定し
たら複数の説明をちゃんと出力してくれる。, 区切りで一行に複数の名称を出
す事もある。例えば man -f awk とすると "awk, nawk (1) - <説明>" という
具合の行を出力する。

* complete: 文字列引数の中にファイル名を含めたい事もあるのでは。つまり "add
a.sh" の様な。特に complete -m '...' の編集で欲しくなる。
Expand Down Expand Up @@ -5697,6 +5726,54 @@ bash_tips
Done (実装ログ)
-------------------------------------------------------------------------------

2021-12-21

* complete (action:mandb): brace の後は space ではなくて , にするべき [#D1719]

ブレース展開の中にいるかどうかは simple_ibrace に非自明な物が設定されている
かどうかで判定できる様に見える。然しこの simple_ibrace は公開されている変数
ではないし途中で書き換わっているかもしれない。それよりは comps_flags 等に情
報が反映されていないか確認する必要がある。実装を見ると x を comps_flags に
追加している様に見えるが、この x はどういう意味だろうか。brace 展開以外の場
合にも追加される可能性があるのだろうか。

comps_flags の説明には含まれていない→と思ったらちゃんと含まれていた。

既存の addtail の実装を見ると brace の中にいるかどうかは comps_flags x で判
定している。なのでそれをそのまま真似すれば良いだろう。

* contrib/git: index に全て登録しただけで非 dirty という事になっているがそれは変だ [#D1718]

? もっと詳細な情報を取得する為のコマンドは何か。

? プロンプトの更新を遅延させる一般の枠組みがあると良い気がする。ble.sh 本体
がどんどん肥大化するのは良くないのでprompt-defer.bash 的なファイルに新し
く定義するのが良い。単に現在の git の呼び出しの部分を差し替える事ができる
様にしたら良い気がする。

一つのプロンプト要素の中に複数の更新項目が含まれる場合にはどうするのか。
依存を複数登録するのか、或いは、まとめて更新する事にするのか。

うーん。現在の待ちはどの様に行われているのか確認する→idle経由で状態を更
新している。 ble/prompt/unit/add-hash '$_ble_contrib_prompt_git_dirty' を
通して変更を検出して更新をかけている。

情報を格納する変数も指定するべきなのだろうという気がする。或いは version
変数を作ってそれを参照させるか。或いは id か何かを指定させるというのでも
良い。うーん。何が良いか。

- より詳細な情報を得る為には git status --porcelain を読み出して使うのが良
い。然し、それで本当に足りるのかどうかも分からない。実際にどういった情報
を人々が求めているのかに依存する様な気がする。自分の為という意味であれば、
取り敢えずは index に変更があるかどうかが分かれば良い。

遅延に関係するコードを prompt-defer に分離した。意外とすっきりとできた。

取り敢えずは staged な変更がある場合に色を変えて表示する事にした。実はもっ
と詳しく表示する事を考えても良いが面倒なのでそのままにする。将来的には
git-status だとか git-prompt のエミュレーションを作っても良いのではないかと
いう気がするが、別に自分が使う訳でもないので今は実装しない事にする。

2021-12-19

* menu (align): bleopt menu_align_{min,max} (motivated by banoris) [#D1717]
Expand Down
8 changes: 5 additions & 3 deletions src/util.sh
Expand Up @@ -1410,7 +1410,7 @@ function ble/opts#has {

## @fn ble/opts#extract-first-optarg opts key [default_value]
function ble/opts#extract-first-optarg {
ret=()
ret=
local rex=':'$2'(=[^:]*)?:'
[[ :$1: =~ $rex ]] || return 1
if [[ ${BASH_REMATCH[1]} ]]; then
Expand All @@ -1422,7 +1422,7 @@ function ble/opts#extract-first-optarg {
}
## @fn ble/opts#extract-last-optarg opts key [default_value]
function ble/opts#extract-last-optarg {
ret=()
ret=
local rex='.*:'$2'(=[^:]*)?:'
[[ :$1: =~ $rex ]] || return 1
if [[ ${BASH_REMATCH[1]} ]]; then
Expand Down Expand Up @@ -2889,13 +2889,15 @@ function ble/function#suppress-stderr {
# miscallaneous utils
#

# Note: "printf -v" for an array element is only allowed in bash-4.1
# or later.
if ((_ble_bash>=40100)); then
function ble/util/set {
builtin printf -v "$1" %s "$2"
}
else
function ble/util/set {
builtin eval "$1=\"\$2\""
builtin eval -- "$1=\"\$2\""
}
fi

Expand Down

0 comments on commit 0ac7f03

Please sign in to comment.