[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/nix-mode 9043a8d687 369/500: Merge pull request #98 from j
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/nix-mode 9043a8d687 369/500: Merge pull request #98 from j-piecuch/94-fix |
Date: |
Sat, 29 Jan 2022 08:27:22 -0500 (EST) |
branch: elpa/nix-mode
commit 9043a8d6870367294bc37beb18debe438bfbc1d5
Merge: 32b013cd62 1ebfda9810
Author: Matthew Bauer <mjbauer95@gmail.com>
Commit: GitHub <noreply@github.com>
Merge pull request #98 from j-piecuch/94-fix
Improve symbol tokenization.
---
nix-mode.el | 29 ++++++++++++++++++++++-------
tests/nix-mode-tests.el | 2 +-
2 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/nix-mode.el b/nix-mode.el
index 31c8efa1b1..887424c085 100644
--- a/nix-mode.el
+++ b/nix-mode.el
@@ -418,11 +418,12 @@ STRING-TYPE type of string based off of Emacs syntax
table types"
(right " -bseqskip- ")
(left " -fseqskip- "))))))
-(defconst nix-smie--symbol-chars "[:->|&=!</-+*?,;!]")
+(defconst nix-smie--2char-symbols
+ '("->" "||" "&&" "==" "!=" "<=" ">=" "++" "//"))
(defconst nix-smie--infix-symbols-re
- (regexp-opt '(":" "->" "||" "&&" "==" "!=" "<" "<=" ">" ">="
- "//" "-" "+" "*" "/" "++" "?")))
+ (regexp-opt (append '(":" "<" ">" "-" "+" "*" "/" "?")
+ nix-smie--2char-symbols)))
(defconst nix-smie-indent-tokens-re
(regexp-opt '("{" "(" "[" "=" "let" "if" "then" "else")))
@@ -564,6 +565,22 @@ STRING-TYPE type of string based off of Emacs syntax table
types"
sub
(ignore (goto-char start))))))
+;; Returns non-nil if it successfully skipped a symbol.
+(defun nix-smie--skip-symbol (how)
+ (let* ((start (point))
+ (nskip (pcase-exhaustive how
+ ('backward (skip-syntax-backward "._"))
+ ('forward (skip-syntax-forward "._"))))
+ (abs-skip (abs nskip)))
+ (or (= 1 abs-skip)
+ (and (= 2 abs-skip)
+ (member (buffer-substring-no-properties (point) start)
+ nix-smie--2char-symbols))
+ (if (< 0 abs-skip)
+ (goto-char (+ start (if (< 0 nskip) 1 -1)))
+ (goto-char start)
+ nil))))
+
(defun nix-smie--forward-token-1 ()
"Move forward one token."
(forward-comment (point-max))
@@ -573,8 +590,7 @@ STRING-TYPE type of string based off of Emacs syntax table
types"
(point)
(progn
(or (/= 0 (skip-syntax-forward "'w_"))
- (when (looking-at nix-smie--symbol-chars) (forward-char) t)
- (skip-syntax-forward "'"))
+ (nix-smie--skip-symbol 'forward))
(point)))))
(defun nix-smie--forward-token ()
@@ -595,8 +611,7 @@ STRING-TYPE type of string based off of Emacs syntax table
types"
(point)
(progn
(or (/= 0 (skip-syntax-backward "'w_"))
- (when (looking-back nix-smie--symbol-chars) (backward-char) t)
- (skip-syntax-backward "'"))
+ (nix-smie--skip-symbol 'backward))
(point)))))
(defun nix-smie--backward-token ()
diff --git a/tests/nix-mode-tests.el b/tests/nix-mode-tests.el
index 6f41199a27..106ad3ba13 100644
--- a/tests/nix-mode-tests.el
+++ b/tests/nix-mode-tests.el
@@ -231,7 +231,7 @@ Related issue: https://github.com/NixOS/nix-mode/issues/72"
"Proper indentation of attrsets inside of lists inside of attrsets.
Related issue: https://github.com/NixOS/nix-mode/issues/94"
- (with-nix-mode-test ("issue-60.1.nix" :indent 'smie-indent-line)))
+ (with-nix-mode-test ("issue-94.nix" :indent 'smie-indent-line)))
(ert-deftest nix-mode-test-indent-lambdas-smie ()
"Proper indentation of function bodies."
- [nongnu] elpa/nix-mode 2bb0a0c1f4 340/500: Improve indentation of let expressions., (continued)
- [nongnu] elpa/nix-mode 2bb0a0c1f4 340/500: Improve indentation of let expressions., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 1b2f22f235 343/500: Add issue 84 test, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode aaef8580c5 351/500: Merge pull request #86 from j-piecuch/smie-tweaks, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 4ffab960ef 345/500: Add AUTHORS.md to gitignore, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode ecf005009e 361/500: Remove org-man.el from .texi makefile rule, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 32b013cd62 363/500: Merge pull request #97 from NixOS/fix-94, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 2c19243e2a 364/500: Revert fix for #94, but leave the test., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 55985b326b 366/500: Be smarter about tokenizing symbols., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode a54fc29289 372/500: Always “decompose” in nix-prettify-mode, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode c34990e956 371/500: Remove references to /gnu in nix-prettify-mode, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 9043a8d687 369/500: Merge pull request #98 from j-piecuch/94-fix,
ELPA Syncer <=
- [nongnu] elpa/nix-mode dc298e77b6 375/500: Merge pull request #101 from jgarte/patch-1, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode a3610b521f 385/500: Use NIX_GET_COMPLETIONS for Nix 3.0, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 1dcbf13a1d 402/500: Merge pull request #111 from leungbk/make-run, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode c52795de7d 392/500: Add completion-at-point to nix-repl-mode-map, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 75f383899a 395/500: Fixed styles., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 0023fc5b10 428/500: Merge pull request #127 from leungbk/nix-drv-regexp, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode bdd3c8a1e5 412/500: Exclude braces from ffap pattern, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode d1ee0e1741 416/500: Use javascript-mode for nix-drv-mode, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 0cf1ea1e0e 390/500: Don’t pare nix completions, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 25cd13349f 445/500: Linkify `nix-mode.org` in Readme, ELPA Syncer, 2022/01/29