[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs-25 4d8fd9c 4/4: Handle "empty line" regexp in xref s
From: |
Dmitry Gutov |
Subject: |
[Emacs-diffs] emacs-25 4d8fd9c 4/4: Handle "empty line" regexp in xref searches |
Date: |
Tue, 03 May 2016 23:02:08 +0000 |
branch: emacs-25
commit 4d8fd9cf338cf9b5dfc613657adfeabff2d9c14e
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>
Handle "empty line" regexp in xref searches
* lisp/progmodes/xref.el (xref--collect-matches-1): Stop after one
match if re-search-forward doesn't move point (bug#23426).
* test/automated/xref-tests.el
(xref-collect-matches-finds-an-empty-line-regexp-match):
Uncomment test.
---
lisp/progmodes/xref.el | 6 +++++-
test/automated/xref-tests.el | 14 +++++++-------
2 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 540c7b0..62cef23 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -1016,7 +1016,11 @@ directory, used as the root of the ignore globs."
(syntax-propertize line-end)
;; FIXME: This results in several lines with the same
;; summary. Solve with composite pattern?
- (while (re-search-forward regexp line-end t)
+ (while (and
+ ;; REGEXP might match an empty string. Or line.
+ (or (null matches)
+ (> (point) line-beg))
+ (re-search-forward regexp line-end t))
(let* ((beg-column (- (match-beginning 0) line-beg))
(end-column (- (match-end 0) line-beg))
(loc (xref-make-file-location file line beg-column))
diff --git a/test/automated/xref-tests.el b/test/automated/xref-tests.el
index 1b500c3..28ca351 100644
--- a/test/automated/xref-tests.el
+++ b/test/automated/xref-tests.el
@@ -28,10 +28,10 @@
(should (equal 0 (xref-file-location-column (nth 0 locs))))
(should (equal 4 (xref-file-location-column (nth 1 locs))))))
-;; (ert-deftest xref-collect-matches-finds-an-empty-line-regexp-match ()
-;; (let* ((matches (xref-collect-matches "^$" "*" xref-tests-data-dir nil))
-;; (locs (mapcar #'xref-item-location matches)))
-;; (should (= 1 (length matches)))
-;; (should (string-match-p "file2\\.txt\\'" (xref-location-group (nth 0
locs))))
-;; (should (equal 1 (xref-location-line (nth 0 locs))))
-;; (should (equal 0 (xref-file-location-column (nth 0 locs))))))
+(ert-deftest xref-collect-matches-finds-an-empty-line-regexp-match ()
+ (let* ((matches (xref-collect-matches "^$" "*" xref-tests-data-dir nil))
+ (locs (mapcar #'xref-item-location matches)))
+ (should (= 1 (length matches)))
+ (should (string-match-p "file2\\.txt\\'" (xref-location-group (nth 0
locs))))
+ (should (equal 1 (xref-location-line (nth 0 locs))))
+ (should (equal 0 (xref-file-location-column (nth 0 locs))))))