mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
ruby-mode: Better detect regexp vs division (bug#67569)
* lisp/progmodes/ruby-mode.el (ruby-syntax-before-regexp-re): Add grouping around methods from the whitelist. (ruby-syntax-propertize): Also look for spaces around the slash.
This commit is contained in:
parent
0f361cc985
commit
91f2ade57b
2 changed files with 21 additions and 3 deletions
|
|
@ -2124,7 +2124,7 @@ It will be properly highlighted even when the call omits parens.")
|
|||
"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."))
|
||||
|
||||
|
|
@ -2182,14 +2182,20 @@ It will be properly highlighted even when the call omits parens.")
|
|||
(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))))
|
||||
division-like)
|
||||
(when (or
|
||||
;; Beginning of a regexp.
|
||||
(and (null (nth 8 state))
|
||||
(save-excursion
|
||||
(setq division-like
|
||||
(or (eql (char-after) ?\s)
|
||||
(not (eql (char-before (1- (point))) ?\s))))
|
||||
(forward-char -1)
|
||||
(looking-back ruby-syntax-before-regexp-re
|
||||
(line-beginning-position))))
|
||||
(line-beginning-position)))
|
||||
(not (and division-like
|
||||
(match-beginning 2))))
|
||||
;; End of regexp. We don't match the whole
|
||||
;; regexp at once because it can have
|
||||
;; string interpolation inside, or span
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue