From 67e62d6490f854d1cde2adddc4a7daf1ab10637b Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Thu, 10 Dec 2020 17:16:10 +0800 Subject: [PATCH] syntax: exclude "\ + LF" at the word beginning from words --- .github/ISSUE_TEMPLATE/00_T1-bug_report.md | 14 ++++-- lib/core-syntax.sh | 13 +++-- memo/ChangeLog.md | 2 + note.txt | 55 ++++++++++++++++++++++ 4 files changed, 76 insertions(+), 8 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/00_T1-bug_report.md b/.github/ISSUE_TEMPLATE/00_T1-bug_report.md index e789a83f..c9ae75be 100644 --- a/.github/ISSUE_TEMPLATE/00_T1-bug_report.md +++ b/.github/ISSUE_TEMPLATE/00_T1-bug_report.md @@ -4,7 +4,15 @@ about: Create a report to fix problems --- -**ble version**: -**Bash version**: +**ble version**: +**Bash version**: - + diff --git a/lib/core-syntax.sh b/lib/core-syntax.sh index 1a512d3c..e2e6ec65 100644 --- a/lib/core-syntax.sh +++ b/lib/core-syntax.sh @@ -3052,7 +3052,7 @@ _BLE_SYNTAX_FEND[CTX_COARGI]=ble/syntax:bash/ctx-coproc/check-word-end function ble/syntax:bash/starts-with-delimiter-or-redirect { local delimiters=$_ble_syntax_bash_RexDelimiter local redirect=$_ble_syntax_bash_RexRedirect - [[ ( $tail =~ ^$delimiters || $wbegin -lt 0 && $tail =~ ^$redirect ) && $tail != ['<>']'('* ]] + [[ ( $tail =~ ^$delimiters || $wbegin -lt 0 && $tail =~ ^$redirect || $wbegin -lt 0 && $tail == $'\\\n'* ) && $tail != ['<>']'('* ]] } function ble/syntax:bash/starts-with-delimiter { [[ $tail == ["$_ble_syntax_bash_IFS;|&<>()"]* && $tail != ['<>']'('* ]] @@ -3425,12 +3425,15 @@ _ble_syntax_bash_command_Opt[CTX_CMDXD0]=1 _ble_syntax_bash_is_command_form_for= function ble/syntax:bash/ctx-command/.check-delimiter-or-redirect { - if [[ $tail =~ ^$_ble_syntax_bash_RexIFSs ]]; then - # 空白 + if [[ $tail =~ ^$_ble_syntax_bash_RexIFSs || $wbegin -lt 0 && $tail == $'\\\n'* ]]; then + # 空白 or \ + 改行 - # 改行がある場合: ヒアドキュメントの確認 / 改行による文脈更新 local spaces=$BASH_REMATCH - if [[ $spaces == *$'\n'* ]]; then + if [[ $tail == $'\\\n'* ]]; then + # \ + 改行は単純に無視 + spaces=$'\\\n' + elif [[ $spaces == *$'\n'* ]]; then + # 改行がある場合: ヒアドキュメントの確認 / 改行による文脈更新 ble/syntax:bash/check-here-document-from "$spaces" && return 0 if ((ctx==CTX_ARGX||ctx==CTX_ARGX0||ctx==CTX_ARGVX||ctx==CTX_ARGEX||ctx==CTX_CMDXV||ctx==CTX_CMDXT||ctx==CTX_CMDXE)); then ((ctx=CTX_CMDX)) diff --git a/memo/ChangeLog.md b/memo/ChangeLog.md index d106a05d..90e8944c 100644 --- a/memo/ChangeLog.md +++ b/memo/ChangeLog.md @@ -7,6 +7,8 @@ ## Changes +- syntax: exclude \\ + LF at the word beginning from words (motivated by cmplstofB) `#D1431` 0000000 + ## Fixes - term: fix a bug that VTE based terminals are not recognized `#D1427` 7e16d9d diff --git a/note.txt b/note.txt index 58ea1064..6c747ce6 100644 --- a/note.txt +++ b/note.txt @@ -1197,6 +1197,15 @@ bash_tips ToDo ------------------------------------------------------------------------------- +2020-12-10 + + * complete/mandb: FreeBSD でも動かす + + freebsd には roff, nroff, troff 等が存在していない。 + それでも man が動作している事を考えると、 + 何らかの方法で man pages を変換しているという事の筈。 + それについて調べて対応する。 + 2020-12-09 * READLINE_MARK, etc. の値が残ってしまっている。 @@ -3693,6 +3702,50 @@ bash_tips 2020-12-10 + * highlight: command \^J-a とした時に -a がコマンドとして着色されない (reported by cmplstofB) [#D1431] + https://github.com/akinomyoga/ble.sh/issues/76 + + 現在の着色では \-a や ''-a 等の様に quote がある場合には、 + 意図的にオプションとしての着色を避けている。 + そういう意味に於いて \^J-a もやはりオプションの前に quote が + ある物として取り扱ってオプションとしての着色が無効になっている。 + + a 然し意味的に考えるとやはり \^J は単語の一部に含まれない様にするのが自然に + も思われる。 + + ? その様に構文解析を変更する事は恐らく簡単だろうが、単語の一部として解析 + しない部分文字列がコマンドラインに含まれる事による副作用などはあるだろ + うか。思うにリダイレクションなども単語の一部として登録していないので、 + 特にこの事で問題が発生する事はない気がする。 + + また sabbrev の単語判定でもやはり語頭の \^J は含まれない様にしたい。 + + 語頭の \^J は skip する事にする。これはどの様に実装すれば良いか? + ^J や空白を処理している箇所で一緒に処理すれば良いだろうか。 + + 取り敢えず構文解析は修正した。多分大丈夫。副作用が起こるかもしれないが、 + それは実際に何かが起こってから見るという事で良いだろう。 + うーん。問題が起こるとすれば二次的に起こる問題ではなくて、 + 構文解析自体が変になる可能性が高い気がするが多分大丈夫。 + + * color: italic が描画できていないという (by rlanore) [#D1430] + https://github.com/akinomyoga/ble.sh/issues/73 + + 試してみると手許では動いている。対応していない端末で使おうとしているのではないか。 + この Issue には返信がないがもう一つの新しい Issue に対して Terminal 情報を載せている。 + Terminator 1.92 を使っている様である。 + + Cygwin 付属の Terminator 0.98 は italic に対応していない。 + Cygwin 附属の GNOME terminal は対応している。 + vte のソースコードを見ると 2012 には italic 関連のコードが存在している様だ。 + 2014 にまた別のフォント初期化コードが追加されている。然し一方で pango も呼び出している。 + これが実際に X11 環境で使われるのかどうかはよく分からない。 + + →これは結局向こうの tmux の設定が問題であった。手許で試して見たところに依 + るとどうも tmux は default-terminal の値に応じて自身の振る舞いも変更する様 + である。これについて wiki の manual にも書いておく必要があるのではないか。 + →wiki に説明を追加した。 + * complete/mandb: ^H が大量に挿入される (reported by rlanore) [#D1429] https://github.com/akinomyoga/ble.sh/issues/75 @@ -3700,6 +3753,8 @@ bash_tips なので、単に .\b を削除すれば良い。 取り敢えず修正してみたが本当に動くか微妙。複数の OS で試す必要があるのではないか。 + freebsd で試して見たところ、troff がないので動いていない。 + これについては後で対応する事にする。 2020-12-09