redguardtoo/evil-matchit

Ruby matches without spaces fail

kriansa opened this issue · 6 comments

In ruby, you can write the following code:

if(my_condition == true)
  do_this
else
  do_that
end

However, if I try to match the if, it won't find a pair. If I remove the space between the condition and the statement, it works:

if (my_condition == true)
# ...

I think this is not common, but it's valid syntax.

(off) I would love to write a fix for that, but I just started out using emacs and learning Elisp.

30e6b2f support more ruby syntax (Chen Bin)

The rules for ruby are written in regular expression. So it's not 100% compatible with all possible ruby syntax. One advantage of evil-matchit is it's configurable. So you can change any rules in your setup.

@redguardtoo Thanks for the quick response.

The commit 1027459 doesn't seem to actually fix this issue. I've managed to fix the regexp so it can now detect the ( as valid syntax.

    (setq evilmi-ruby-extract-keyword-howtos
      '(("^[ \t]*[^ \t=]+[ \t]*=[ \t]*\\([a-z]+\\)\\( .*\\|(.*\\| *\\)$" 1) ;; I've changed this one
         ("^[ \t]*\\([a-z]+\\)\\( .*\\|(.*\\| *\\)$" 1)                     ;; And this one too
         ("^.* \\(do\\) |[a-z0-9A-Z_, *]+| *$" 1)
         ("^.* \\(do\\) *$" 1)
         ("^.* \\(begin\\) *$" 1)
         ("^.* \\(end\\)\\..*$" 1)))

OK. I will use your regex.

Awesome. Thank you for such a prompt response. Let me know if you would like me to open a PR instead. 😄

ea1e867 support more ruby syntax, thanks to @kriansa (Chen Bin)

Thank you!