Skip to content

Commit de3f6bc

Browse files
committed
Highlight xref matches in the target buffer more accurately
Use `xref-make-match` in Emacs 28; it takes a length argument.
1 parent 6d48d43 commit de3f6bc

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

emacs/merlin-xref.el

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,15 @@
1616
(cl-defmethod xref-backend-references ((_backend (eql merlin-xref)) symbol)
1717
(mapcar
1818
(lambda (loc)
19-
(let ((pt (merlin-make-point (alist-get 'start loc))))
20-
(xref-make (merlin-xref--line pt)
21-
(xref-make-buffer-location (current-buffer) pt))))
19+
(let* ((pt (merlin-make-point (alist-get 'start loc)))
20+
(summary (merlin-xref--line pt))
21+
(location (xref-make-buffer-location (current-buffer) pt)))
22+
(if (>= emacs-major-version 28)
23+
;; `xref-make-match' doesn't accept `xref-buffer-location'
24+
;; arguments until Emacs 28.
25+
(let ((length (- (merlin-make-point (alist-get 'end loc)) pt)))
26+
(xref-make-match summary location length))
27+
(xref-make summary location))))
2228
(save-excursion
2329
(let ((pt (get-text-property 0 'merlin-xref-point symbol)))
2430
(when pt

0 commit comments

Comments
 (0)