diff options
author | Dmitry Gutov <dmitry@gutov.dev> | 2023-12-09 19:04:55 +0200 |
---|---|---|
committer | Dmitry Gutov <dmitry@gutov.dev> | 2023-12-09 19:04:55 +0200 |
commit | 91f2ade57bb72e9bb4a44da44e5dc69adb3c7584 (patch) | |
tree | fed4bf06cedd388dc2df6de198b9f2018d9be5d6 /lisp/progmodes | |
parent | 0f361cc985d35202556233f04235df1c885f532e (diff) | |
download | emacs-91f2ade57bb72e9bb4a44da44e5dc69adb3c7584.tar.gz emacs-91f2ade57bb72e9bb4a44da44e5dc69adb3c7584.tar.bz2 emacs-91f2ade57bb72e9bb4a44da44e5dc69adb3c7584.zip |
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.
Diffstat (limited to 'lisp/progmodes')
-rw-r--r-- | lisp/progmodes/ruby-mode.el | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index b252826680c..0ecb3579278 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -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 |