emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/swift-mode 84059659de 2/2: Fix highlighting identifier con


From: ELPA Syncer
Subject: [nongnu] elpa/swift-mode 84059659de 2/2: Fix highlighting identifier containing underscores and keywords
Date: Thu, 4 Jan 2024 07:01:19 -0500 (EST)

branch: elpa/swift-mode
commit 84059659de4da89d3d2902611cebed6d0423bf06
Author: taku0 <mxxouy6x3m_github@tatapa.org>
Commit: taku0 <mxxouy6x3m_github@tatapa.org>

    Fix highlighting identifier containing underscores and keywords
    
    Fixes https://github.com/swift-emacs/swift-mode/issues/190
---
 swift-mode-font-lock.el                    | 18 ++++++++----------
 test/swift-files/font-lock/font-lock.swift |  2 +-
 2 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/swift-mode-font-lock.el b/swift-mode-font-lock.el
index 9092327ca4..998c57f410 100644
--- a/swift-mode-font-lock.el
+++ b/swift-mode-font-lock.el
@@ -196,11 +196,11 @@ This function does not search beyond LIMIT."
    (< (point) limit)
    (looking-at
     (concat
-     "\\<\\("
+     "\\_<\\("
      (string-join
       '("func" "enum" "struct" "class" "protocol" "extension" "actor" "macro")
       "\\|")
-     "\\)\\>"))))
+     "\\)\\_>"))))
 
 (defun swift-mode:property-access-pos-p (pos limit)
   "Return t if POS is just before the property name of a member expression.
@@ -350,7 +350,7 @@ The predicate MATCH-P is called with two arguments:
     (while (and
             (< (point) limit)
             (not result)
-            (re-search-forward "\\<\\(\\sw\\|\\s_\\)+\\>" limit t))
+            (re-search-forward "\\_<\\(\\sw\\|\\s_\\)+\\_>" limit t))
       (when (save-excursion
               (save-match-data
                 (funcall match-p (match-beginning 0) limit)))
@@ -585,7 +585,7 @@ Excludes true, false, and keywords begin with a number 
sign.")
     ;; Attributes
     "@\\(\\sw\\|\\s_\\)*"
 
-    (,(regexp-opt swift-mode:constant-keywords 'words)
+    (,(regexp-opt swift-mode:constant-keywords 'symbols)
      .
      'swift-mode:constant-keyword-face)
 
@@ -598,7 +598,7 @@ Excludes true, false, and keywords begin with a number 
sign.")
                           swift-mode:statement-keywords
                           swift-mode:expression-keywords
                           swift-mode:context-keywords)
-                  'words)
+                  'symbols)
      .
      'swift-mode:keyword-face)
 
@@ -634,13 +634,11 @@ Excludes true, false, and keywords begin with a number 
sign.")
      .
      'swift-mode:builtin-constant-face)
 
-    (,(regexp-opt swift-mode:build-config-keywords 'words)
+    (,(regexp-opt swift-mode:build-config-keywords 'symbols)
      .
      'swift-mode:build-config-keyword-face)
 
-    (,(concat "\\<"
-              (regexp-opt swift-mode:standard-precedence-groups 'non-nil)
-              "\\>")
+    (,(regexp-opt swift-mode:standard-precedence-groups 'symbols)
      .
      'swift-mode:builtin-precedence-group-face)
 
@@ -650,7 +648,7 @@ Excludes true, false, and keywords begin with a number 
sign.")
      'swift-mode:function-name-face)
 
     ;; Method/function calls
-    ("\\<\\(\\(\\sw\\|\\s_\\)+\\)\\>\\??\\s-*("
+    ("\\_<\\(\\(\\sw\\|\\s_\\)+\\)\\_>\\??\\s-*("
      1
      'swift-mode:function-call-face)
 
diff --git a/test/swift-files/font-lock/font-lock.swift 
b/test/swift-files/font-lock/font-lock.swift
index 5ba4c3e665..3fe12e3a96 100644
--- a/test/swift-files/font-lock/font-lock.swift
+++ b/test/swift-files/font-lock/font-lock.swift
@@ -32,7 +32,7 @@ foo !== bar // "foo !== bar"
 
 a.b.c! // #("a.b.c!" 2 3 (face swift-mode:property-access-face) 4 5 (face 
swift-mode:property-access-face))
 
-a.b.c_! // #("a.b.c_!" 2 3 (face swift-mode:property-access-face) 4 5 (face 
swift-mode:property-access-face))
+a.b.c_! // #("a.b.c_!" 2 3 (face swift-mode:property-access-face) 4 6 (face 
swift-mode:property-access-face))
 
 a.b.aあ! // #("a.b.a\343\201\202!" 2 3 (face swift-mode:property-access-face) 4 
8 (face swift-mode:property-access-face))
 



reply via email to

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