summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lisp/progmodes/xref.el8
-rw-r--r--test/lisp/progmodes/xref-tests.el6
2 files changed, 9 insertions, 5 deletions
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index f33dfb4f5de..181f94b0bc6 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -97,6 +97,10 @@ This is typically the filename.")
"Return the line number corresponding to the location."
nil)
+(cl-defgeneric xref-location-column (_location)
+ "Return the exact column corresponding to the location."
+ nil)
+
(cl-defgeneric xref-match-length (_item)
"Return the length of the match."
nil)
@@ -118,7 +122,7 @@ part of the file name."
(defclass xref-file-location (xref-location)
((file :type string :initarg :file)
(line :type fixnum :initarg :line :reader xref-location-line)
- (column :type fixnum :initarg :column :reader xref-file-location-column))
+ (column :type fixnum :initarg :column :reader xref-location-column))
:documentation "A file location is a file/line/column triple.
Line numbers start from 1 and columns from 0.")
@@ -869,7 +873,7 @@ GROUP is a string for decoration purposes and XREF is an
" ")))
;; Render multiple matches on the same line, together.
(when (and line (equal prev-line-key line-key))
- (let ((column (xref-file-location-column location)))
+ (when-let ((column (xref-location-column location)))
(delete-region
(save-excursion
(forward-line -1)
diff --git a/test/lisp/progmodes/xref-tests.el b/test/lisp/progmodes/xref-tests.el
index 038f9d0e304..e220d09dada 100644
--- a/test/lisp/progmodes/xref-tests.el
+++ b/test/lisp/progmodes/xref-tests.el
@@ -52,8 +52,8 @@
(should (string-match-p "file1\\.txt\\'" (xref-location-group (nth 1 locs))))
(should (equal 1 (xref-location-line (nth 0 locs))))
(should (equal 1 (xref-location-line (nth 1 locs))))
- (should (equal 0 (xref-file-location-column (nth 0 locs))))
- (should (equal 4 (xref-file-location-column (nth 1 locs))))))
+ (should (equal 0 (xref-location-column (nth 0 locs))))
+ (should (equal 4 (xref-location-column (nth 1 locs))))))
(ert-deftest xref-matches-in-directory-finds-an-empty-line-regexp-match ()
(let* ((matches (xref-matches-in-directory "^$" "*" xref-tests-data-dir nil))
@@ -61,7 +61,7 @@
(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))))))
+ (should (equal 0 (xref-location-column (nth 0 locs))))))
(ert-deftest xref--buf-pairs-iterator-groups-markers-by-buffers-1 ()
(let* ((xrefs (xref-matches-in-directory "foo" "*" xref-tests-data-dir nil))