diff options
| author | Dmitry Gutov | 2020-12-31 19:50:48 +0200 |
|---|---|---|
| committer | Dmitry Gutov | 2020-12-31 19:50:48 +0200 |
| commit | 0e41e89d7e9787c5ca3446af01b3c3afa433bb9b (patch) | |
| tree | 19512fade1d8df13ccc39b35ed4b21b3f66df88d | |
| parent | b47b98bc4b2b6f901865b7530145766a0f8da142 (diff) | |
| download | emacs-0e41e89d7e9787c5ca3446af01b3c3afa433bb9b.tar.gz emacs-0e41e89d7e9787c5ca3446af01b3c3afa433bb9b.zip | |
ruby-syntax-propertize: Optimize two rules a little
* lisp/progmodes/ruby-mode.el (ruby-syntax-propertize):
Optimize two rules a little.
| -rw-r--r-- | lisp/progmodes/ruby-mode.el | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index 7d72a783033..9aebb29333b 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.") | |||
| 1864 | 'syntax-table (string-to-syntax "_")) | 1864 | 'syntax-table (string-to-syntax "_")) |
| 1865 | (string-to-syntax "'")))) | 1865 | (string-to-syntax "'")))) |
| 1866 | ;; Symbols with special characters. | 1866 | ;; Symbols with special characters. |
| 1867 | ("\\(^\\|[^:]\\)\\(:\\([-+~]@?\\|[/%&|^`]\\|\\*\\*?\\|<\\(<\\|=>?\\)?\\|>[>=]?\\|===?\\|=~\\|![~=]?\\|\\[\\]=?\\)\\)" | 1867 | (":\\([-+~]@?\\|[/%&|^`]\\|\\*\\*?\\|<\\(<\\|=>?\\)?\\|>[>=]?\\|===?\\|=~\\|![~=]?\\|\\[\\]=?\\)" |
| 1868 | (3 (unless (nth 8 (syntax-ppss (match-beginning 3))) | 1868 | (1 (unless (or |
| 1869 | (eq (char-before (match-beginning 0)) ?:) | ||
| 1870 | (nth 8 (syntax-ppss (match-beginning 1)))) | ||
| 1869 | (goto-char (match-end 0)) | 1871 | (goto-char (match-end 0)) |
| 1870 | (string-to-syntax "_")))) | 1872 | (string-to-syntax "_")))) |
| 1871 | ;; Symbols ending with '=' (bug#42846). | 1873 | ;; Symbols ending with '=' (bug#42846). |
| @@ -1888,9 +1890,14 @@ It will be properly highlighted even when the call omits parens.") | |||
| 1888 | ;; (semi-important for indentation). | 1890 | ;; (semi-important for indentation). |
| 1889 | ("\\(:\\)\\(?:[({]\\|\\[[^]]\\)" | 1891 | ("\\(:\\)\\(?:[({]\\|\\[[^]]\\)" |
| 1890 | (1 (string-to-syntax "."))) | 1892 | (1 (string-to-syntax "."))) |
| 1891 | ;; Regular expressions. Start with matching unescaped slash. | 1893 | ;; Regular expressions. |
| 1892 | ("\\(?:\\=\\|[^\\]\\)\\(?:\\\\\\\\\\)*\\(/\\)" | 1894 | ("\\(/\\)" |
| 1893 | (1 (let ((state (save-excursion (syntax-ppss (match-beginning 1))))) | 1895 | (1 |
| 1896 | ;; No unescaped slashes in front. | ||
| 1897 | (when (save-excursion | ||
| 1898 | (forward-char -1) | ||
| 1899 | (cl-evenp (skip-chars-backward "\\\\"))) | ||
| 1900 | (let ((state (save-excursion (syntax-ppss (match-beginning 1))))) | ||
| 1894 | (when (or | 1901 | (when (or |
| 1895 | ;; Beginning of a regexp. | 1902 | ;; Beginning of a regexp. |
| 1896 | (and (null (nth 8 state)) | 1903 | (and (null (nth 8 state)) |
| @@ -1903,7 +1910,7 @@ It will be properly highlighted even when the call omits parens.") | |||
| 1903 | ;; string interpolation inside, or span | 1910 | ;; string interpolation inside, or span |
| 1904 | ;; several lines. | 1911 | ;; several lines. |
| 1905 | (eq ?/ (nth 3 state))) | 1912 | (eq ?/ (nth 3 state))) |
| 1906 | (string-to-syntax "\"/"))))) | 1913 | (string-to-syntax "\"/")))))) |
| 1907 | ;; Expression expansions in strings. We're handling them | 1914 | ;; Expression expansions in strings. We're handling them |
| 1908 | ;; here, so that the regexp rule never matches inside them. | 1915 | ;; here, so that the regexp rule never matches inside them. |
| 1909 | (ruby-expression-expansion-re | 1916 | (ruby-expression-expansion-re |