branch: elpa/nix-mode
commit 0f94476b7e845eb4dd6e51d87fbfb9846eb990ac
Author: Leon Isenberg <[email protected]>
Commit: Leon Isenberg <[email protected]>
nix-syntax-match-antiquote: Handle case where point has the property
---
nix-mode.el | 36 ++++++++++++++++++++----------------
1 file changed, 20 insertions(+), 16 deletions(-)
diff --git a/nix-mode.el b/nix-mode.el
index 2d01b9e0c6..a0542586ef 100644
--- a/nix-mode.el
+++ b/nix-mode.el
@@ -28,22 +28,26 @@
(defun nix-syntax-match-antiquote (limit)
"Find antiquote within a Nix expression up to LIMIT."
- (let ((pos (next-single-char-property-change (point) 'nix-syntax-antiquote
- nil limit)))
- (when (and pos (> pos (point)) (< pos (point-max)))
- (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))
- )
- )))
+ (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"