[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/nix-mode c577957d66 347/500: Merge pull request #85 from N
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/nix-mode c577957d66 347/500: Merge pull request #85 from NixOS/fix-84 |
Date: |
Sat, 29 Jan 2022 08:27:19 -0500 (EST) |
branch: elpa/nix-mode
commit c577957d668ea9513cc1cafc911ef6789d9fcb14
Merge: bf027132d0 8118a807a7
Author: Matthew Bauer <mjbauer95@gmail.com>
Commit: GitHub <noreply@github.com>
Merge pull request #85 from NixOS/fix-84
Fix handling of keywords in identifiers
---
.gitignore | 4 +++-
Makefile | 7 ++++---
nix-mode.el | 15 ++++++++++++---
tests/nix-font-lock-tests.el | 10 ++++++++--
4 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/.gitignore b/.gitignore
index bfc379fa2f..04e5e875c1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,4 +13,6 @@ result
*.info
*.tex
*.pdf
-auto/
\ No newline at end of file
+auto/
+
+AUTHORS.md
diff --git a/Makefile b/Makefile
index c111c1f3ce..3f3b0c24f1 100644
--- a/Makefile
+++ b/Makefile
@@ -6,15 +6,16 @@ ELS = nix.el nix-company.el nix-drv-mode.el nix-format.el \
nix-shell.el nix-store.el
ELCS = $(ELS:.el=.elc)
+TESTS = tests/nix-mode-tests.el tests/nix-font-lock-tests.el
+
DESTDIR =
PREFIX = /usr
all: $(ELCS) nix-mode.info nix-mode.html AUTHORS.md
-check:
+check: $(TESTS) $(ELCS)
emacs -batch -L . \
- -l tests/nix-mode-tests.el \
- -l tests/nix-font-lock-tests.el \
+ $(foreach test,$(TESTS),-l $(test)) \
-f ert-run-tests-batch-and-exit
install: $(ELCS) nix-mode.info nix-mode.html AUTHORS.md
diff --git a/nix-mode.el b/nix-mode.el
index 6e354cc19e..e1dba6c1c9 100644
--- a/nix-mode.el
+++ b/nix-mode.el
@@ -128,10 +128,19 @@ very large Nix files (all-packages.nix)."
(defconst nix-re-comments "#\\|/*\\|*/")
+(defun nix-re-keywords (keywords)
+ "Produce a regexp matching some keywords of Nix.
+KEYWORDS a list of strings to match as Nix keywords."
+ (concat
+ "\\(?:[[:space:];:{}()]\\|^\\)"
+ (regexp-opt keywords t)
+ "\\(?:[[:space:];:{}()]\\|$\\)"
+ ))
+
(defconst nix-font-lock-keywords
- `((,(regexp-opt nix-keywords 'symbols) 0 'nix-keyword-face)
- (,(regexp-opt nix-warning-keywords 'symbols) 0 'nix-keyword-warning-face)
- (,(regexp-opt nix-builtins 'symbols) 0 'nix-builtin-face)
+ `((,(nix-re-keywords nix-keywords) 1 'nix-keyword-face)
+ (,(nix-re-keywords nix-warning-keywords) 1 'nix-keyword-warning-face)
+ (,(nix-re-keywords nix-builtins) 1 'nix-builtin-face)
(,nix-re-url 0 'nix-constant-face)
(,nix-re-file-path 0 'nix-constant-face)
(,nix-re-variable-assign 1 'nix-attribute-face)
diff --git a/tests/nix-font-lock-tests.el b/tests/nix-font-lock-tests.el
index 1ec0008b6a..5abdb5744f 100644
--- a/tests/nix-font-lock-tests.el
+++ b/tests/nix-font-lock-tests.el
@@ -40,7 +40,7 @@ after a test as this aids interactive debugging."
(defun check-properties (lines-or-contents props &optional mode)
"Check if syntax properties and font-lock properties as set properly.
LINES is a list of strings that will be inserted to a new
-buffer. Then PROPS is a list of tripples of (string syntax
+buffer. Then PROPS is a list of triples of (string syntax
face). String is searched for in the buffer and then is checked
if all of its characters have syntax and face. See
`check-syntax-and-face-match-range`."
@@ -64,7 +64,6 @@ if all of its characters have syntax and face. See
(search-forward string))
(check-syntax-and-face-match-range
(match-beginning 0) (match-end 0) syntax face)))))
-
(ert-deftest nix-equals-1 ()
(check-properties
'("pattern = 3")
@@ -75,6 +74,13 @@ if all of its characters have syntax and face. See
'("pattern == 3")
'(("pattern" t nil))))
+(ert-deftest nix-issue-84 ()
+ (check-properties
+ '("{ with-a ? {let-in=1; } , ... }:with with-a; { foo = \"bar\"; }")
+ '(("let-in" t nix-attribute-face)
+ ("with" t nix-keyword-face)
+ ("foo" t nix-attribute-face))))
+
;; Local Variables:
;; flycheck-disabled-checkers: (emacs-lisp-checkdoc)
;; End:
- [nongnu] elpa/nix-mode abf54fb448 354/500: Emacs 25 is now the minimum version required, (continued)
- [nongnu] elpa/nix-mode abf54fb448 354/500: Emacs 25 is now the minimum version required, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode de6ef0d0c7 355/500: Give "-" the "symbol" character class, since it is a legal symbol constituent, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 28e83dd56b 360/500: Don’t overwrite smie-indent-exps & smie-indent-close, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 9f24153d67 367/500: Remove redundant case in tokenizer., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode b4518ae3ee 374/500: fixed a typo, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode d13d70b37d 377/500: Merge pull request #102 from yilinwei/master, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode a00b3f776d 384/500: Merge pull request #103 from yilinwei/patch-1, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode bb0b49e3ac 408/500: Merge pull request #112 from leungbk/makefile-load-path, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 7d09073976 424/500: Merge pull request #121 from znewman01/fixbuild, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 4941961c75 059/500: Get rid of extra hanging indent matches., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode c577957d66 347/500: Merge pull request #85 from NixOS/fix-84,
ELPA Syncer <=
- [nongnu] elpa/nix-mode cccd68768b 319/500: Install info page to the right location, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode e820157994 338/500: Merge pull request #82 from jabranham/comp-warns, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 7556c032dc 421/500: Use the located nixfmt binary for formatting., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode df4ba688a7 435/500: Merge branch 'nix-search-updates', ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 4528033194 018/500: Add "nix-mode-reload" function., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode f3b4215166 004/500: Update metadata, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 69c7c87caa 017/500: Sert comment-multi-line., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 83229f0d4c 041/500: Fix flycheck errors., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 76ad5882f0 046/500: format, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 3ef4647aa2 052/500: Fixup lets/ins counting., ELPA Syncer, 2022/01/29