[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/nix-mode ea23a301d7 086/500: Fontification..
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/nix-mode ea23a301d7 086/500: Fontification.. |
Date: |
Sat, 29 Jan 2022 08:26:38 -0500 (EST) |
branch: elpa/nix-mode
commit ea23a301d743274a92bea3e81affc4616931a5c8
Author: Leon Isenberg <ljli@users.noreply.github.com>
Commit: Matthew Bauer <mjbauer95@gmail.com>
Fontification..
---
nix-mode.el | 88 ++++++++++++++++++++++++++-----------------------------------
1 file changed, 37 insertions(+), 51 deletions(-)
diff --git a/nix-mode.el b/nix-mode.el
index 41ebc54d4e..afc347114e 100644
--- a/nix-mode.el
+++ b/nix-mode.el
@@ -108,18 +108,16 @@
(string-type (nix--get-string-type context)))
(unless (or (equal string-type ?\")
(and (equal string-type nil)
- (save-match-data
- (string-match nix--variable-char
- (buffer-substring-no-properties (1-
start) start)))))
+ (string-match-p nix--variable-char
+ (buffer-substring (1- start) start))))
(when (equal string-type nil)
(nix--mark-string start ?\')
(setq start (+ 2 start)))
(when (equal (mod (- end start) 3) 2)
- (let ((str-peek (buffer-substring-no-properties end (+ 2 end))))
- (if (equal str-peek "${")
- (put-text-property end (+ 2 end) 'nix-escaped t)
- (unless (member str-peek '("\\n" "\\r" "\\t"))
- (nix--mark-string (1- end) ?\'))))))))
+ (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) ?\')))))))
(defun nix--escaped-antiquote-dq-style ()
(let* ((start (match-beginning 0))
@@ -136,14 +134,12 @@
(nix--mark-string pos ?\"))))
(defun nix--antiquote-open-at (pos string-type)
- (if (get-text-property pos 'nix-escaped)
- (remove-text-properties pos (+ 2 pos) '(nix-escaped nil))
(put-text-property pos (1+ pos)
'syntax-table (string-to-syntax "|"))
(put-text-property pos (+ 2 pos)
'nix-string-type string-type)
(put-text-property (1+ pos) (+ 2 pos)
- 'nix-syntax-antiquote t)))
+ 'nix-syntax-antiquote t))
(defun nix--antiquote-open ()
(let* ((start (match-beginning 0))
@@ -165,46 +161,40 @@
(put-text-property (+ 2 start) (+ 3 start)
'nix-syntax-antiquote t)))))
-(defun nix--antiquote-close-sq-end ()
- (let* ((start (match-beginning 0))
- (ps (nix--get-parse-state start)))
- (when (and (not (nix--get-string-type ps))
- (nix--open-brace-antiquote-p ps))
- (let ((string-type (nix--open-brace-string-type ps)))
- (pcase string-type
- (`?\'
- (put-text-property start (+ 3 start)
- 'nix-string-type string-type)
- (put-text-property start (1+ start)
- 'nix-syntax-antiquote t))
- (`?\" (nix--antiquote-close)))))))
-
-(defun nix--antiquote-close-dq-end ()
- (let* ((start (match-beginning 0))
- (ps (nix--get-parse-state start)))
- (when (and (not (nix--get-string-type ps))
- (nix--open-brace-antiquote-p ps))
- (let ((string-type (nix--open-brace-string-type ps)))
- (pcase string-type
- (`?\"
- (put-text-property start (+ 2 start)
- 'nix-string-type string-type)
- (put-text-property start (1+ start)
- 'nix-syntax-antiquote t))
- (`?\' (nix--antiquote-close)))))))
-
(defun nix--antiquote-close ()
(let* ((start (match-beginning 0))
(ps (nix--get-parse-state start)))
- (when (and (not (nix--get-string-type ps))
- (nix--open-brace-antiquote-p ps))
+ (unless (nix--get-string-type ps)
(let ((string-type (nix--open-brace-string-type ps)))
- (put-text-property start (+ 2 start)
- 'nix-string-type string-type)
- (put-text-property start (1+ start)
- 'nix-syntax-antiquote t)
- (put-text-property (1+ start) (+ 2 start)
- 'syntax-table (string-to-syntax "|"))))))
+ (when string-type
+ (put-text-property start (+ 2 start)
+ 'nix-string-type string-type)
+ (put-text-property start (1+ start)
+ 'nix-syntax-antiquote t)
+ (let ((ahead (buffer-substring (1+ start) (min (point-max) (+ 5
start)))))
+ (case string-type
+ (?\" (unless (string-match-p "^\"" ahead)
+ (put-text-property (1+ start) (+ 2 start)
+ 'syntax-table (string-to-syntax "|")))
+ (goto-char (+ 2 start)))
+ (?\' (cond
+ ((string-match-p "^'''" ahead)
+ (put-text-property (1+ start) (+ 2 start)
+ 'syntax-table (string-to-syntax "|"))
+ (goto-char (+ 4 start)))
+ ((string-match-p "^''\\${" ahead)
+ (put-text-property (1+ start) (+ 2 start)
+ 'syntax-table (string-to-syntax "|"))
+ (goto-char (+ 5 start)))
+ ((string-match-p "^''\\[nrt]" ahead)
+ (put-text-property (1+ start) (+ 2 start)
+ 'syntax-table (string-to-syntax "|"))
+ (goto-char (+ 5 start)))
+ ((string-match-p "^''" ahead)
+ (goto-char (+ 3 start)))
+ (t (put-text-property (1+ start) (+ 2 start)
+ 'syntax-table (string-to-syntax "|"))
+ (goto-char (+ 2 start))))))))))))
(defun nix-syntax-propertize (start end)
"Special syntax properties for Nix from START to END."
@@ -219,10 +209,6 @@
(0 nil))
("\\\\\\${" (0 (ignore (nix--escaped-antiquote-dq-style))))
("'\\{2,\\}" (0 (ignore (nix--single-quotes))))
- ("}''\\([^\\$'\\\\]\\|\\$[^{]\\|\\\\[^nrt]\\)"
- (0 (ignore (nix--antiquote-close-sq-end))))
- ("}\""
- (0 (ignore (nix--antiquote-close-dq-end))))
("}\\${"
(0 (ignore (nix--antiquote-close-open))))
("\\${"
- [nongnu] elpa/nix-mode 3338f5997e 056/500: Fix beginning of buffer issue, (continued)
- [nongnu] elpa/nix-mode 3338f5997e 056/500: Fix beginning of buffer issue, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 0f01eecdaa 050/500: Make sure everything starts at beginning of line., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 03f462ef34 062/500: Add "+" to hanging indent list., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode ad09b3be7f 066/500: Fix flycheck errors., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 6534f146eb 065/500: Formatting, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 5a29112764 073/500: Add function for escaped antiquote., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 460cc23161 075/500: Make " be treated as generic | syntax class., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode ff8409c617 079/500: Declare lexical-binding, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 6a9cb7e682 081/500: Add basic REPL via nix-repl, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 836e14fdd4 093/500: Merge pull request #12 from matthewbauer/case-sensitive-searching, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode ea23a301d7 086/500: Fontification..,
ELPA Syncer <=
- [nongnu] elpa/nix-mode f309e106ef 090/500: Revert "Make " be treated as generic | syntax class.", ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 64d615d628 096/500: Add nix-mode-mmm, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode f968cb98ef 097/500: Add nix-buffer., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode c0502994b5 100/500: Remove nix-mode-reload., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 956280c161 116/500: Refactor nix--antiquote-close, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode de02e17924 135/500: Fix fontification of "}${" in some contexts, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 0b19f975cd 143/500: Merge pull request #28 from pvmart/fix-nix-mmm, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 719482b701 148/500: Update customizations for Nix related modes., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode b3c6560f6d 166/500: Fix typo: rustfmt -> nixfmt, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 038dcf7b1b 147/500: Cleanup, ELPA Syncer, 2022/01/29