From 1850913d96126ca52c8dc5beadc82b004477b0cf Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Sun, 2 Mar 2014 00:04:59 +0200 Subject: [PATCH] * lisp/progmodes/ruby-mode.el (ruby-font-lock-keywords): Highlight regexp options. Fixes: debbugs:16914 --- lisp/ChangeLog | 5 +++++ lisp/progmodes/ruby-mode.el | 10 ++++++++++ test/indent/ruby.rb | 4 ++++ 3 files changed, 19 insertions(+) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index d3419412ebe..d25f877a644 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2014-03-01 Dmitry Gutov + + * progmodes/ruby-mode.el (ruby-font-lock-keywords): Highlight + regexp options. (Bug#16914) + 2014-03-01 Martin Rudalics * window.el (window--max-delta-1): Round down when calculating diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index 5cd054a22a8..a5d8285c98e 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -2132,6 +2132,16 @@ See `font-lock-syntax-table'.") ;; Character literals. ;; FIXME: Support longer escape sequences. ("\\_<\\?\\\\?\\S " 0 font-lock-string-face) + ;; Regexp options. + ("\\(?:\\s|\\|/\\)\\([imxo]+\\)" + 1 (when (save-excursion + (let ((state (syntax-ppss (match-beginning 0)))) + (and (nth 3 state) + (or (eq (char-after) ?/) + (progn + (goto-char (nth 8 state)) + (looking-at "%r")))))) + font-lock-preprocessor-face)) ) "Additional expressions to highlight in Ruby mode.") diff --git a/test/indent/ruby.rb b/test/indent/ruby.rb index daec1c30c69..2ca0e482797 100644 --- a/test/indent/ruby.rb +++ b/test/indent/ruby.rb @@ -29,6 +29,10 @@ a = asub / aslb + bsub / bslb; # Highlight the regexp after "if". x = toto / foo if /do bar/ =~ "dobar" +# Regexp options are highlighted. + +/foo/xi != %r{bar}mo.tee + bar(class: XXX) do # ruby-indent-keyword-label foo end -- 2.39.2