3

Interesting bug in ruby-mode. When a variable called index is followed by a slash /, syntax highlighting breaks.

Here's a screenshot to show you what I mean:

fun syntax highlighting bug in ruby-mode

I'm not really sure how to file a ticket on the ruby-mode repo since I've never used SVN. Anyone know where to go from here?

harumph
  • 33
  • 2
  • 1
    To report a bug in ruby-mode, you should `M-x report-emacs-bug`. ruby-mode is distributed with Emacs. I can reproduce the problem, but the way to fix it is non-obvious, and it doesn't seem inappropriate to have that discussion in StackExchange. Thanks. – Dmitry Jun 07 '16 at 21:14
  • `it doesn't seem inappropriate to have that discussion in StackExchange`. Was that an intentional double-negative? Are you saying it *is* appropriate to have that discussion here? – harumph Jun 07 '16 at 21:50
  • Right, sorry. It was a result of a sloppy edit. – Dmitry Jun 07 '16 at 22:39
  • Interestingly it only happens with `index`, if you change the var's name is goes ok. – Henry Mazza Apr 09 '20 at 13:07

2 Answers2

3

In short, it is because Ruby's syntax is ambiguous, and because String#index accepts a regexp in its first argument.

There are different tradeoffs different editors take regarding regular expressions in Ruby. We can discuss improving Emacs's tradeoff in a bug report.

Dmitry
  • 3,508
  • 15
  • 20
0

FWIW, if you use enh-ruby-mode, that problem doesn't occur.

https://github.com/zenspider/enhanced-ruby-mode

Trevoke
  • 2,375
  • 21
  • 34