[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/nix-mode 1a4c98fcf7 118/500: Cosmetics
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/nix-mode 1a4c98fcf7 118/500: Cosmetics |
Date: |
Sat, 29 Jan 2022 08:26:46 -0500 (EST) |
branch: elpa/nix-mode
commit 1a4c98fcf7f0835f7f1bd57f4e9e80d1244feb22
Author: Leon Isenberg <ljli@users.noreply.github.com>
Commit: Leon Isenberg <ljli@users.noreply.github.com>
Cosmetics
---
nix-mode.el | 68 ++++++++++++++++++++++++++++++-------------------------------
1 file changed, 34 insertions(+), 34 deletions(-)
diff --git a/nix-mode.el b/nix-mode.el
index a0542586ef..18a22d8267 100644
--- a/nix-mode.el
+++ b/nix-mode.el
@@ -26,36 +26,12 @@
;;; Syntax coloring
-(defun nix-syntax-match-antiquote (limit)
- "Find antiquote within a Nix expression up to LIMIT."
- (unless (> (point) limit)
- (if (get-text-property (point) 'nix-syntax-antiquote)
- (progn
- (set-match-data (list (point) (1+ (point))))
- (forward-char 1)
- t)
- (let ((pos (next-single-char-property-change (point)
'nix-syntax-antiquote
- nil limit)))
- (when (and pos (not (> pos limit)))
- (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"
"let" "in"
"rec" "inherit"
- "or"
- ))
+ "or"))
(defconst nix-builtins
'("builtins" "baseNameOf"
@@ -89,10 +65,12 @@
(,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-syntax-match-antiquote 0 font-lock-preprocessor-face t)
+ (nix--syntax-match-antiquote 0 font-lock-preprocessor-face t)
)
"Font lock keywords for nix.")
+(defconst nix--variable-char "[a-zA-Z0-9_'\-]")
+
(makunbound 'nix-mode-syntax-table)
(defvar nix-mode-syntax-table
@@ -108,14 +86,35 @@
table)
"Syntax table for Nix mode.")
+(defun nix--syntax-match-antiquote (limit)
+ "Find antiquote within a Nix expression up to LIMIT."
+ (unless (> (point) limit)
+ (if (get-text-property (point) 'nix-syntax-antiquote)
+ (progn
+ (set-match-data (list (point) (1+ (point))))
+ (forward-char 1)
+ t)
+ (let ((pos (next-single-char-property-change (point)
'nix-syntax-antiquote
+ nil limit)))
+ (when (and pos (not (> pos limit)))
+ (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))))))))
+
(defun nix--mark-string (pos string-type)
(put-text-property pos (1+ pos)
'syntax-table (string-to-syntax "|"))
(put-text-property pos (1+ pos)
'nix-string-type string-type))
-(defconst nix--variable-char "[a-zA-Z0-9_'\-]")
-
(defun nix--get-parse-state (pos)
(save-excursion (save-match-data (syntax-ppss pos))))
@@ -148,7 +147,7 @@
(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) ?\')))))))
+ (nix--mark-string (1- end) ?\')))))))
(defun nix--escaped-antiquote-dq-style ()
(let* ((start (match-beginning 0))
@@ -237,8 +236,10 @@
(0 nil))
("\\\\\""
(0 nil))
- ("\\\\\\${" (0 (ignore (nix--escaped-antiquote-dq-style))))
- ("'\\{2,\\}" (0 (ignore (nix--single-quotes))))
+ ("\\\\\\${"
+ (0 (ignore (nix--escaped-antiquote-dq-style))))
+ ("'\\{2,\\}"
+ (0 (ignore (nix--single-quotes))))
("}\\${"
(0 (ignore (nix--antiquote-close-open))))
("\\${"
@@ -246,8 +247,7 @@
("}"
(0 (ignore (nix--antiquote-close))))
("\""
- (0 (ignore (nix--double-quotes))))
- )
+ (0 (ignore (nix--double-quotes)))))
start end))
;;; Indentation
@@ -444,7 +444,7 @@ The hook `nix-mode-hook' is run when Nix mode is started.
(setq-local tab-width 2)
;; Font lock support.
- (setq-local font-lock-defaults '(nix-font-lock-keywords nil nil nil nil))
+ (setq-local font-lock-defaults '(nix-font-lock-keywords))
;; Special syntax properties for Nix
(setq-local syntax-propertize-function 'nix-syntax-propertize)
- [nongnu] elpa/nix-mode e4bc711d81 094/500: Add some more modes., (continued)
- [nongnu] elpa/nix-mode e4bc711d81 094/500: Add some more modes., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode e1f2e24cc4 104/500: Move separate modes into own files., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 56a87c8d81 087/500: Move nix-flycheck to separate file., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 199e20413e 102/500: Ignore comments for hanging let's., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode fcbaf3e054 106/500: Rename flycheck mode to "nix-flycheck"., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 542ae77358 110/500: buffer-substring can't bet <1., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 3e6fdd8311 112/500: Add back syntax coloring of antiquotes., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 66cc5478de 113/500: Merge branch 'master' into separate-files, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 0fd152e118 119/500: Merge pull request #22 from ljli/various, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 04a268a6fe 126/500: Remove "let" handling of indent., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 1a4c98fcf7 118/500: Cosmetics,
ELPA Syncer <=
- [nongnu] elpa/nix-mode 23bdbdf21f 124/500: Add custom mmm-mode, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode e413069e02 130/500: Fixup some corner cases in indentation, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 2def0ccd6a 191/500: Add autoload for company-nix command, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 895f9d14e5 193/500: Flatten "unless" form with no body, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 4a5b6d5d2c 177/500: Add travis and Makefile, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode af35742d55 198/500: Merge pull request #39 from purcell/master, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 1b3424ade0 190/500: Don't ignore errors when loading nix-format / nix-shebang, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 93a59d9acb 179/500: Use cl-lib instead of cl., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 7c732faf3a 183/500: Handle smartparens in nix-mode., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 7716e6d1e4 208/500: fix (cond) usage, ELPA Syncer, 2022/01/29