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

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

[nongnu] elpa/nix-mode 87ba3a26c1 05/14: Fix $$ in string literals


From: ELPA Syncer
Subject: [nongnu] elpa/nix-mode 87ba3a26c1 05/14: Fix $$ in string literals
Date: Tue, 19 Jul 2022 01:58:49 -0400 (EDT)

branch: elpa/nix-mode
commit 87ba3a26c15e105d98845d29cab7900791cb5d45
Author: Nicholas Coltharp <coltharp@pdx.edu>
Commit: Nicholas Coltharp <coltharp@pdx.edu>

    Fix $$ in string literals
    
    - Inside a string literal, one "$" always removes any special meaning
    from any following "$"; i.e., the string "$${x}" has no antiquote.  Add
    a rule that ignores $$.
    - This breaks an edge case: in a double-quoted string, the character
    sequence "\$${" should be treated as a literal "$" followed by an
    antiquote open.  Add a special rule for this case.
---
 nix-mode.el | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/nix-mode.el b/nix-mode.el
index 8d00fa2f99..9c8cb46842 100644
--- a/nix-mode.el
+++ b/nix-mode.el
@@ -252,6 +252,14 @@ STRING-TYPE type of string based off of Emacs syntax table 
types"
            (t
             (nix--mark-string (1- end) ?\'))))))))
 
+(defun nix--antiquote-sq-style ()
+  "Hande Nix antiquote sq style."
+  (let* ((start (match-beginning 0))
+         (ps (nix--get-parse-state start))
+        (string-type (nix--get-string-type ps)))
+    (when (equal string-type ?\")
+      (nix--antiquote-open-at (+ start 2) ?\"))))
+
 (defun nix--escaped-antiquote-dq-style ()
   "Handle Nix escaped antiquote dq style."
   (let* ((start (match-beginning 0))
@@ -348,6 +356,10 @@ STRING-TYPE type of string based off of Emacs syntax table 
types"
      (0 nil))
     ("\\\\\""
      (0 nil))
+    ("\\$\\$"
+     (0 nil))
+    ("\\\\\\$\\${"
+     (0 (ignore (nix--\$${))))
     ("\\\\\\${"
      (0 (ignore (nix--escaped-antiquote-dq-style))))
     ("'\\{2,\\}"



reply via email to

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