Skip to content

Commit

Permalink
syntax: exclude "\ + LF" at the word beginning from words
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Dec 10, 2020
1 parent b5c875a commit 67e62d6
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 8 deletions.
14 changes: 11 additions & 3 deletions .github/ISSUE_TEMPLATE/00_T1-bug_report.md
Expand Up @@ -4,7 +4,15 @@ about: Create a report to fix problems

---

**ble version**: <!-- version/commit-id available with `echo $BLE_VERSION` -->
**Bash version**: <!-- Bash version available with `echo $BASH_VERSION, $MACHTYPE` -->
**ble version**: <!-- The result of `echo $BLE_VERSION` (version, commit-hash) -->
**Bash version**: <!-- The result of `echo $BASH_VERSION, $MACHTYPE` -->

<!-- Describe the problem here. If example terminal contents are available, you may paste them here. -->
<!-- Describe the problem here. If example terminal contents (in either the
text form or an image) are available, you may paste/insert them to explain
the situation more clearly.
Note: In most cases, in reply, we will ask further questions to investigate
the problem in detail. Please don't hesitate to RESPOND TO THE QUESTIONS, or
otherwise we need to just close the issue soon.
-->
13 changes: 8 additions & 5 deletions lib/core-syntax.sh
Expand Up @@ -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 != ['<>']'('* ]]
Expand Down Expand Up @@ -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))
Expand Down
2 changes: 2 additions & 0 deletions memo/ChangeLog.md
Expand Up @@ -7,6 +7,8 @@

## Changes

- syntax: exclude <code>\\ + LF</code> 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
Expand Down
55 changes: 55 additions & 0 deletions note.txt
Expand Up @@ -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. の値が残ってしまっている。
Expand Down Expand Up @@ -3693,13 +3702,59 @@ bash_tips

2020-12-10

* highlight: command \^J-a とした時に -a がコマンドとして着色されない (reported by cmplstofB) [#D1431]

This comment has been minimized.

Copy link
@cmplstofB

cmplstofB Dec 10, 2020

Contributor

コマンド→オプション?

This comment has been minimized.

Copy link
@akinomyoga

akinomyoga Dec 10, 2020

Author Owner

あ、その通りです!

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

これは nroff で太字を表現するのに <CHAR>^H<CHAR> を出力する物がある為。
なので、単に .\b を削除すれば良い。

取り敢えず修正してみたが本当に動くか微妙。複数の OS で試す必要があるのではないか。
freebsd で試して見たところ、troff がないので動いていない。
これについては後で対応する事にする。

2020-12-09

Expand Down

0 comments on commit 67e62d6

Please sign in to comment.