[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/relint 77c3b87 04/10: Improved source traversal towards
From: |
Mattias Engdegård |
Subject: |
[elpa] externals/relint 77c3b87 04/10: Improved source traversal towards location |
Date: |
Sun, 4 Aug 2019 13:42:47 -0400 (EDT) |
branch: externals/relint
commit 77c3b8736978b3de825ea5ab27e7a7845e019955
Author: Mattias Engdegård <address@hidden>
Commit: Mattias Engdegård <address@hidden>
Improved source traversal towards location
Now dotted lists like (a b . (c d)) are handled better, including uses
of sugar like (a . 'b).
---
relint.el | 37 +++++++++++++++++++++++++++----------
1 file changed, 27 insertions(+), 10 deletions(-)
diff --git a/relint.el b/relint.el
index de2e594..93149c2 100644
--- a/relint.el
+++ b/relint.el
@@ -102,6 +102,11 @@
(let ((inhibit-read-only t))
(insert string))))
+(defun relint--skip-whitespace ()
+ (when (looking-at (rx (1+ (or blank "\n" "\f"
+ (seq ";" (0+ nonl))))))
+ (goto-char (match-end 0))))
+
(defun relint--line-col-from-pos-path (pos path)
"Compute (LINE . COLUMN) from POS (toplevel position)
and PATH (reversed list of list indices to follow to target)."
@@ -109,23 +114,35 @@ and PATH (reversed list of list indices to follow to
target)."
(goto-char pos)
(let ((p (reverse path)))
(while p
- (when (looking-at (rx (1+ (or blank "\n" "\f"
- (seq ";" (0+ nonl))))))
- (goto-char (match-end 0)))
+ (relint--skip-whitespace)
(let ((skip (car p)))
+ ;; Enter next sexp and skip past the `skip' first sexps inside.
(cond
((looking-at (rx (or "'" "#'" "`" "," ",@")))
(goto-char (match-end 0))
(setq skip (1- skip)))
((looking-at (rx "("))
(forward-char 1)))
- (forward-sexp skip)
- (setq p (cdr p))))
- (when (looking-at (rx (1+ (or blank "\n" "\f"
- (seq ";" (0+ nonl))))))
- (goto-char (match-end 0)))
- (cons (line-number-at-pos (point) t)
- (1+ (current-column))))))
+ (while (> skip 0)
+ (relint--skip-whitespace)
+ (if (looking-at (rx "."))
+ (progn
+ (goto-char (match-end 0))
+ (relint--skip-whitespace)
+ (cond
+ ((looking-at (rx (or "'" "#'" "`" "," ",@")))
+ ;; Sugar after dot represents one sexp.
+ (goto-char (match-end 0))
+ (setq skip (1- skip)))
+ ((looking-at (rx "("))
+ ;; `. (' represents zero sexps.
+ (goto-char (match-end 0)))))
+ (forward-sexp)
+ (setq skip (1- skip)))))
+ (setq p (cdr p))))
+ (relint--skip-whitespace)
+ (cons (line-number-at-pos (point) t)
+ (1+ (current-column)))))
(defun relint--output-error (string)
(if noninteractive
- [elpa] externals/relint updated (e049e93 -> bc001eb), Mattias Engdegård, 2019/08/04
- [elpa] externals/relint c5ac726 03/10: Handle rx `literal' and `regexp' forms correctly, Mattias Engdegård, 2019/08/04
- [elpa] externals/relint 77c3b87 04/10: Improved source traversal towards location,
Mattias Engdegård <=
- [elpa] externals/relint 1dc96b5 05/10: Make font-lock-keywords errors easier to find, Mattias Engdegård, 2019/08/04
- [elpa] externals/relint bc001eb 10/10: Increment version to 1.9, Mattias Engdegård, 2019/08/04
- [elpa] externals/relint 963e232 02/10: Check more defcustom strings, Mattias Engdegård, 2019/08/04
- [elpa] externals/relint c08baf2 06/10: Quote symbols with ' instead of ` in pcase, Mattias Engdegård, 2019/08/04
- [elpa] externals/relint 9238375 07/10: Detect more regexps in defcustom alists, Mattias Engdegård, 2019/08/04
- [elpa] externals/relint 943c728 08/10: Indentation fixes, Mattias Engdegård, 2019/08/04
- [elpa] externals/relint 298d407 01/10: Restructure `cond' expressions for better compilation, Mattias Engdegård, 2019/08/04
- [elpa] externals/relint 2e0bb22 09/10: Keep track of local variable bindings, Mattias Engdegård, 2019/08/04