diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index 5c34ddc562b..b2d833fa2b0 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -2125,7 +2125,7 @@ ruby-find-library-file "or" "not" "&&" "||")) ;; Method name from the list. "\\|\\_<" - (regexp-opt ruby-syntax-methods-before-regexp) + (regexp-opt ruby-syntax-methods-before-regexp t) "\\)\\s *") "Regexp to match text that can be followed by a regular expression.")) @@ -2183,14 +2183,18 @@ ruby-syntax-propertize (when (save-excursion (forward-char -1) (cl-evenp (skip-chars-backward "\\\\"))) - (let ((state (save-excursion (syntax-ppss (match-beginning 1))))) + (let ((state (save-excursion (syntax-ppss (match-beginning 1)))) + space-after-slash) (when (or ;; Beginning of a regexp. (and (null (nth 8 state)) (save-excursion + (setq space-after-slash (eql (char-after) ?\s)) (forward-char -1) (looking-back ruby-syntax-before-regexp-re - (line-beginning-position)))) + (line-beginning-position))) + (or (not space-after-slash) + (not (match-beginning 2)))) ;; End of regexp. We don't match the whole ;; regexp at once because it can have ;; string interpolation inside, or span