Skip to content

Commit c0bf56c

Browse files
committed
fix(indent.el): Further improve indent-lint
1 parent dd0e5db commit c0bf56c

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

lisp/lint/indent.el

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,41 @@
2727
;;
2828
;;; Core
2929

30-
(defun eask--undo-lines (undo-list)
31-
"Return list of lines changed in UNDO-LIST."
32-
(let ((lines))
30+
(defun eask--undo-pos (entry)
31+
"Return the undo pos from ENTRY."
32+
(cl-typecase (car entry)
33+
(number (car entry))
34+
(string (abs (cdr entry)))))
35+
36+
(defun eask--undo-infos (undo-list)
37+
"Return list of infos in UNDO-LIST."
38+
(let ((infos))
3339
(dolist (elm undo-list)
34-
(when (and (consp elm) (numberp (cdr elm)))
35-
(push (line-number-at-pos (abs (cdr elm))) lines)))
36-
(reverse lines)))
40+
(when-let* ((pos (eask--undo-pos elm))
41+
(line (line-number-at-pos pos))
42+
(expected (progn (eask--goto-line line)
43+
(current-indentation))))
44+
(push (list line expected) infos)))
45+
infos))
3746

3847
(defun eask--indent-lint-file (file)
3948
"Lint indent for FILE."
4049
(eask-msg "")
4150
(eask-msg "`%s` with indent-lint" (ansi-green (eask-root-del file)))
4251
(find-file file)
43-
(let ((tick (buffer-modified-tick)))
52+
(let ((tick (buffer-modified-tick))
53+
(bs (buffer-string)))
54+
(eask-with-temp-buffer (insert bs))
4455
(eask--silent (indent-region (point-min) (point-max)))
4556
(if (/= tick (buffer-modified-tick))
4657
;; Indentation changed: warn for each line.
47-
(dolist (line (eask--undo-lines buffer-undo-list))
48-
(eask-report "%s:%s: mismatch indentation" (buffer-name) line))
58+
(dolist (info (eask--undo-infos buffer-undo-list))
59+
(let* ((line (nth 0 info))
60+
(column (nth 1 info))
61+
(current (eask-with-buffer
62+
(eask--goto-line line) (current-indentation))))
63+
(eask-report "%s:%s: Expected indentation is %s but found %s"
64+
(buffer-name) line column current)))
4965
(eask-log "No mismatch indentation found"))))
5066

5167
(eask-start

0 commit comments

Comments
 (0)