branch: elpa/nix-mode
commit f938aeaeb64a5421b1c08ebc877a64d899c5d291
Author: Jakub Piecuch <[email protected]>
Commit: Jakub Piecuch <[email protected]>
Fix buggy implementation of nix-smie--anchor.
---
nix-mode.el | 32 +++++++++++++++++++-------------
1 file changed, 19 insertions(+), 13 deletions(-)
diff --git a/nix-mode.el b/nix-mode.el
index 2353695b91..ba858594a0 100644
--- a/nix-mode.el
+++ b/nix-mode.el
@@ -477,19 +477,25 @@ STRING-TYPE type of string based off of Emacs syntax
table types"
(defun nix-smie--anchor ()
"Return the anchor's offset from the beginning of the current line."
- (goto-char (+ (line-beginning-position) (current-indentation)))
- (let ((eol (line-end-position))
- (anchor (current-column))
- tok)
- (catch 'break
- (while (and (setq tok (car (smie-indent-forward-token)))
- (<= (point) eol))
- (when (equal "=" tok)
- (backward-char)
- (smie-backward-sexp " -bseqskip- ")
- (setq anchor (current-column))
- (throw 'break nil))))
- anchor))
+ (save-excursion
+ (beginning-of-line)
+ (let ((eol (line-end-position))
+ anchor
+ tok)
+ (forward-comment (point-max))
+ (unless (or (eobp) (< eol (point)))
+ (setq anchor (current-column))
+ (catch 'break
+ (while (and (not (eobp))
+ (progn
+ (setq tok (car (smie-indent-forward-token)))
+ (<= (point) eol)))
+ (when (equal "=" tok)
+ (backward-char)
+ (smie-backward-sexp " -bseqskip- ")
+ (setq anchor (current-column))
+ (throw 'break nil))))
+ anchor))))
(defun nix-smie--indent-anchor (&optional indent)
"Intended for use only in the rules function."