[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/nix-mode e22819a73b 12/14: Merge pull request #157 from no
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/nix-mode e22819a73b 12/14: Merge pull request #157 from nosewings/master |
Date: |
Tue, 19 Jul 2022 01:58:49 -0400 (EDT) |
branch: elpa/nix-mode
commit e22819a73bf4e2b71166992a0af2f555036cf634
Merge: 5d5704d846 7fbde25122
Author: Matthew Bauer <mjbauer95@gmail.com>
Commit: GitHub <noreply@github.com>
Merge pull request #157 from nosewings/master
Fix syntax highlighting for ''$ in indented strings
---
nix-mode.el | 22 +++++++++++++++++++---
tests/nix-font-lock-tests.el | 24 ++++++++++++++++++++++++
2 files changed, 43 insertions(+), 3 deletions(-)
diff --git a/nix-mode.el b/nix-mode.el
index 73bd4af794..59ca5a2101 100644
--- a/nix-mode.el
+++ b/nix-mode.el
@@ -244,9 +244,21 @@ STRING-TYPE type of string based off of Emacs syntax table
types"
(setq start (+ 2 start)))
(when (equal (mod (- end start) 3) 2)
(let ((str-peek (buffer-substring end (min (point-max) (+ 2 end)))))
- (if (member str-peek '("${" "\\n" "\\r" "\\t"))
- (goto-char (+ 2 end))
- (nix--mark-string (1- end) ?\')))))))
+ (cond
+ ((member str-peek '("${" "\\n" "\\r" "\\t"))
+ (goto-char (+ 2 end)))
+ ((string-prefix-p "$" str-peek)
+ (goto-char (1+ end)))
+ (t
+ (nix--mark-string (1- end) ?\'))))))))
+
+(defun nix--escaped-dollar-sign-antiquote-sq-style ()
+ "Hande Nix escaped dollar sign 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."
@@ -344,6 +356,10 @@ STRING-TYPE type of string based off of Emacs syntax table
types"
(0 nil))
("\\\\\""
(0 nil))
+ ("\\$\\$"
+ (0 nil))
+ ("\\\\\\$\\${"
+ (0 (ignore (nix--escaped-dollar-sign-antiquote-sq-style))))
("\\\\\\${"
(0 (ignore (nix--escaped-antiquote-dq-style))))
("'\\{2,\\}"
diff --git a/tests/nix-font-lock-tests.el b/tests/nix-font-lock-tests.el
index 5abdb5744f..619ee78f56 100644
--- a/tests/nix-font-lock-tests.el
+++ b/tests/nix-font-lock-tests.el
@@ -81,6 +81,30 @@ if all of its characters have syntax and face. See
("with" t nix-keyword-face)
("foo" t nix-attribute-face))))
+(ert-deftest nix-issue-157 ()
+ (check-properties
+ '("\"''$${x}")
+ '(("\"''$${x}" t font-lock-string-face)))
+ (check-properties
+ '("''''$${x}''")
+ '(("''''$" t font-lock-string-face)
+ ("${" t nix-antiquote-face)
+ ("}" t nix-antiquote-face)))
+ (check-properties
+ '("\"$${x}\"")
+ '(("\"$${x}\"" t font-lock-string-face)))
+ (check-properties
+ '("''$${x}''")
+ '(("''$${x}''" t font-lock-string-face)))
+ (check-properties
+ '("\"\\$${x}\"")
+ '(("\"\\$" t font-lock-string-face)
+ ("${" t nix-antiquote-face)
+ ("}" t nix-antiquote-face)))
+ (check-properties
+ '("''\\$${x}''")
+ '(("''\\$${x}''" t font-lock-string-face))))
+
;; Local Variables:
;; flycheck-disabled-checkers: (emacs-lisp-checkdoc)
;; End:
- [nongnu] elpa/nix-mode acf6f9d573 06/14: Code style: change (+ 1 ...) to (1+ ...), (continued)
- [nongnu] elpa/nix-mode acf6f9d573 06/14: Code style: change (+ 1 ...) to (1+ ...), ELPA Syncer, 2022/07/19
- [nongnu] elpa/nix-mode acf4d6fdce 07/14: Naming change, ELPA Syncer, 2022/07/19
- [nongnu] elpa/nix-mode 7fbde25122 09/14: Add tests for issue 157, ELPA Syncer, 2022/07/19
- [nongnu] elpa/nix-mode bac87932a8 02/14: chore(deps): bump cachix/install-nix-action from 16 to 17, ELPA Syncer, 2022/07/19
- [nongnu] elpa/nix-mode bca3d518e3 01/14: chore(deps): bump actions/checkout from 2 to 3, ELPA Syncer, 2022/07/19
- [nongnu] elpa/nix-mode 0950294c48 04/14: Fix out-of-bounds error, ELPA Syncer, 2022/07/19
- [nongnu] elpa/nix-mode 5669eff2ad 13/14: Merge pull request #151 from NixOS/dependabot/github_actions/actions/checkout-3, ELPA Syncer, 2022/07/19
- [nongnu] elpa/nix-mode 87ba3a26c1 05/14: Fix $$ in string literals, ELPA Syncer, 2022/07/19
- [nongnu] elpa/nix-mode 8bd12b16b8 10/14: fix wrong enum value in nix-has-flakes, ELPA Syncer, 2022/07/19
- [nongnu] elpa/nix-mode 5d5704d846 11/14: Merge pull request #159 from aameen-tulip/master, ELPA Syncer, 2022/07/19
- [nongnu] elpa/nix-mode e22819a73b 12/14: Merge pull request #157 from nosewings/master,
ELPA Syncer <=
- [nongnu] elpa/nix-mode b3f71c75f7 14/14: Merge pull request #153 from NixOS/dependabot/github_actions/cachix/install-nix-action-17, ELPA Syncer, 2022/07/19