From: Hiroshi Nakamura Date: 2011-06-26T23:13:53+09:00 Subject: [ruby-dev:43948] [Ruby 1.9 - Bug #4546] ruby-indent-beg-re の値が壊れている Issue #4546 has been updated by Hiroshi Nakamura. Target version changed from 1.9.x to 1.9.3 ---------------------------------------- Bug #4546: ruby-indent-beg-re の値が壊れている http://redmine.ruby-lang.org/issues/4546 Author: Kenta Murata Status: Assigned Priority: Normal Assignee: Nobuyoshi Nakada Category: lib Target version: 1.9.3 ruby -v: trunk vim-ruby の indent/ruby.vim を修正しようと思い ruby-mode.el を読んでいたところ ruby-indent-beg-re の値が壊れているような気がしたので報告します。 r19205 で regexp-opt を使って正規表現を最適化するよう改善されていますが、 そのときに \\| が抜けてしまっています。 r19204 の 場合: "\\(\\s *\\(class\\|module\\|def\\)\\)\\|if\\|unless\\|case\\|while\\|until\\|for\\|begin" r19205 の場合: "\\(\\s *\\(class\\|def\\|module\\)\\)\\(?:begin\\|case\\|for\\|if\\|un\\(?:less\\|til\\)\\|while\\)" このように class, def, module を囲む括弧の直後にあった \\| が落ちています。 それでも、なぜか適切にインデントできていて不思議だったので少しだけ調査してみました。 r19205 以降では、ruby-beginning-of-indent が classif や defbegin のような不適切な語をインデントの開始として 判断してしまいますが、このような語が存在しない場合はバッファの先頭まで戻っていました。 ですから、以下のパッチを当ててこの間違いを修正すると、長いファイルのインデント計算が 若干高速化されるかもしれません。 diff --git a/misc/ruby-mode.el b/misc/ruby-mode.el index c799d8c..9023b77 100644 --- a/misc/ruby-mode.el +++ b/misc/ruby-mode.el @@ -72,7 +72,7 @@ "Regexp to match") (defconst ruby-indent-beg-re - (concat "\\(\\s *" (regexp-opt '("class" "module" "def") t) "\\)" + (concat "\\(\\s *" (regexp-opt '("class" "module" "def") t) "\\)\\|" (regexp-opt '("if" "unless" "case" "while" "until" "for" "begin"))) "Regexp to match where the indentation gets deeper.") -- http://redmine.ruby-lang.org