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?

  • 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 7 '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 7 '16 at 21:50
  • Right, sorry. It was a result of a sloppy edit. – Dmitry Jun 7 '16 at 22:39
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.

  • I'm not sure I understand why distinguishing between a method on a string and a variable name is ambiguous. Wouldn't any variable name that also happens to be a method on a literal be problematic, in that case? – harumph Jun 7 '16 at 23:00
  • Also, I am going to submit a bug report. – harumph Jun 7 '16 at 23:01
  • The ambiguity I'm referring to here is between regexp delimiters and division. – Dmitry Jun 7 '16 at 23:05
  • Upvotes are nice and all, but would somebody file the bug? – Dmitry Jun 15 '16 at 12:20
  • Filed the bug with M-x report-emacs-bug last week, right after creating this post. – harumph Jun 15 '16 at 18:05
0

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.