emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 0e41e89: ruby-syntax-propertize: Optimize two rules a little


From: Dmitry Gutov
Subject: master 0e41e89: ruby-syntax-propertize: Optimize two rules a little
Date: Thu, 31 Dec 2020 12:51:14 -0500 (EST)

branch: master
commit 0e41e89d7e9787c5ca3446af01b3c3afa433bb9b
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>

    ruby-syntax-propertize: Optimize two rules a little
    
    * lisp/progmodes/ruby-mode.el (ruby-syntax-propertize):
    Optimize two rules a little.
---
 lisp/progmodes/ruby-mode.el | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index 7d72a78..9aebb29 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -1864,8 +1864,10 @@ It will be properly highlighted even when the call omits 
parens.")
                                'syntax-table (string-to-syntax "_"))
             (string-to-syntax "'"))))
       ;; Symbols with special characters.
-      
("\\(^\\|[^:]\\)\\(:\\([-+~]@?\\|[/%&|^`]\\|\\*\\*?\\|<\\(<\\|=>?\\)?\\|>[>=]?\\|===?\\|=~\\|![~=]?\\|\\[\\]=?\\)\\)"
-       (3 (unless (nth 8 (syntax-ppss (match-beginning 3)))
+      
(":\\([-+~]@?\\|[/%&|^`]\\|\\*\\*?\\|<\\(<\\|=>?\\)?\\|>[>=]?\\|===?\\|=~\\|![~=]?\\|\\[\\]=?\\)"
+       (1 (unless (or
+                   (eq (char-before (match-beginning 0)) ?:)
+                   (nth 8 (syntax-ppss (match-beginning 1))))
             (goto-char (match-end 0))
             (string-to-syntax "_"))))
       ;; Symbols ending with '=' (bug#42846).
@@ -1888,9 +1890,14 @@ It will be properly highlighted even when the call omits 
parens.")
       ;; (semi-important for indentation).
       ("\\(:\\)\\(?:[({]\\|\\[[^]]\\)"
        (1 (string-to-syntax ".")))
-      ;; Regular expressions.  Start with matching unescaped slash.
-      ("\\(?:\\=\\|[^\\]\\)\\(?:\\\\\\\\\\)*\\(/\\)"
-       (1 (let ((state (save-excursion (syntax-ppss (match-beginning 1)))))
+      ;; Regular expressions.
+      ("\\(/\\)"
+       (1
+        ;; No unescaped slashes in front.
+        (when (save-excursion
+                (forward-char -1)
+                (cl-evenp (skip-chars-backward "\\\\")))
+          (let ((state (save-excursion (syntax-ppss (match-beginning 1)))))
             (when (or
                    ;; Beginning of a regexp.
                    (and (null (nth 8 state))
@@ -1903,7 +1910,7 @@ It will be properly highlighted even when the call omits 
parens.")
                    ;; string interpolation inside, or span
                    ;; several lines.
                    (eq ?/ (nth 3 state)))
-              (string-to-syntax "\"/")))))
+              (string-to-syntax "\"/"))))))
       ;; Expression expansions in strings.  We're handling them
       ;; here, so that the regexp rule never matches inside them.
       (ruby-expression-expansion-re



reply via email to

[Prev in Thread] Current Thread [Next in Thread]