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

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

[nongnu] elpa/nix-mode aa1fa07344 342/500: Fix handling of keywords in i


From: ELPA Syncer
Subject: [nongnu] elpa/nix-mode aa1fa07344 342/500: Fix handling of keywords in identifiers
Date: Sat, 29 Jan 2022 08:27:19 -0500 (EST)

branch: elpa/nix-mode
commit aa1fa07344271b8bca1ec259d041d1a106329417
Author: Matthew Bauer <mjbauer95@gmail.com>
Commit: Matthew Bauer <mjbauer95@gmail.com>

    Fix handling of keywords in identifiers
    
    This case shouldn’t be highlighted. For instance:
    
      python-with-my-packages
    
    Need to look ahead and behind keywords to make sure they are not used
    in attribute names.
---
 nix-mode.el | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/nix-mode.el b/nix-mode.el
index 4fa219ce14..b1a263465a 100644
--- a/nix-mode.el
+++ b/nix-mode.el
@@ -128,10 +128,19 @@ very large Nix files (all-packages.nix)."
 
 (defconst nix-re-comments "#\\|/*\\|*/")
 
+(defun nix-re-keywords (keywords)
+  "Produce a regexp matching some keywords of Nix.
+KEYWORDS a list of strings to match as Nix keywords."
+  (concat
+   "\\(?:[[:space:]]\\|^\\)"
+   (regexp-opt keywords t)
+   "\\(?:[[:space:]]\\|$\\)"
+   ))
+
 (defconst nix-font-lock-keywords
-  `((,(regexp-opt nix-keywords 'symbols) 0 'nix-keyword-face)
-    (,(regexp-opt nix-warning-keywords 'symbols) 0 'nix-keyword-warning-face)
-    (,(regexp-opt nix-builtins 'symbols) 0 'nix-builtin-face)
+  `((,(nix-re-keywords nix-keywords) 1 'nix-keyword-face)
+    (,(nix-re-keywords nix-warning-keywords) 1 'nix-keyword-warning-face)
+    (,(nix-re-keywords nix-builtins) 1 'nix-builtin-face)
     (,nix-re-url 0 'nix-constant-face)
     (,nix-re-file-path 0 'nix-constant-face)
     (,nix-re-variable-assign 1 'nix-attribute-face)



reply via email to

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