emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/nix-mode f938aeaeb6 324/500: Fix buggy implementation of n


From: ELPA Syncer
Subject: [nongnu] elpa/nix-mode f938aeaeb6 324/500: Fix buggy implementation of nix-smie--anchor.
Date: Sat, 29 Jan 2022 08:27:17 -0500 (EST)

branch: elpa/nix-mode
commit f938aeaeb64a5421b1c08ebc877a64d899c5d291
Author: Jakub Piecuch <j.piecuch96@gmail.com>
Commit: Jakub Piecuch <j.piecuch96@gmail.com>

    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."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]