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

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

[nongnu] elpa/nix-mode 3e6fdd8311 112/500: Add back syntax coloring of a


From: ELPA Syncer
Subject: [nongnu] elpa/nix-mode 3e6fdd8311 112/500: Add back syntax coloring of antiquotes.
Date: Sat, 29 Jan 2022 08:26:42 -0500 (EST)

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

    Add back syntax coloring of antiquotes.
    
    Fixes issue #20.
---
 nix-mode.el | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/nix-mode.el b/nix-mode.el
index 2fa86c44b2..a9b8337297 100644
--- a/nix-mode.el
+++ b/nix-mode.el
@@ -26,6 +26,25 @@
 
 ;;; Syntax coloring
 
+(defun nix-syntax-match-antiquote (limit)
+  "Find antiquote within a Nix expression up to LIMIT."
+  (let ((pos (next-single-char-property-change (point) 'nix-syntax-antiquote
+                                               nil limit)))
+    (when (and pos (> pos (point)) (< pos (point-max)))
+      (goto-char pos)
+      (let ((char (char-after pos)))
+        (pcase char
+          (`?{
+           (forward-char 1)
+           (set-match-data (list (1- pos) (point)))
+           t)
+          (`?}
+           (forward-char 1)
+           (set-match-data (list pos (point)))
+           t))
+        )
+      )))
+
 (defconst nix-keywords
   '("if" "then"
     "else" "with"
@@ -65,7 +84,9 @@
     (,nix-re-url . font-lock-constant-face)
     (,nix-re-file-path . font-lock-constant-face)
     (,nix-re-variable-assign 1 font-lock-variable-name-face)
-    (,nix-re-bracket-path . font-lock-constant-face))
+    (,nix-re-bracket-path . font-lock-constant-face)
+    (nix-syntax-match-antiquote 0 font-lock-preprocessor-face t)
+    )
   "Font lock keywords for nix.")
 
 (makunbound 'nix-mode-syntax-table)



reply via email to

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