bug#81592: [PATCH] Implement `xref-location-line' for `xref-buffer-location'
Roi Martin <[email protected]>
| Newsgroups | gmane.emacs.bugs |
|---|---|
| Message-ID | <[email protected]> |
Tags: patch
This patch implements the `xref-location-line' method for the
`xref-buffer-location' struct. After this change, Xref buffers will
prefix Xref objects whose location is an `xref-buffer-location' with
their corresponding line number.
Xref-Edit mode depends on this prefix to work. So, this patch also
enables Xref-Edit mode for this type of reference.
Dmitry, I'm CCing you because, as far as I know, you are the main
xref.el contributor.
Thanks!
Roi
0001-Implement-xref-location-line-for-xref-buffer-locatio.patch
(text/x-patch, 1006 B)
From 0db46dc95c3362dddd573b37927bb397b5dc9e76 Mon Sep 17 00:00:00 2001 From: Roi Martin <[email protected]> Date: Mon, 10 Aug 2026 04:01:19 +0200 Subject: [PATCH] Implement `xref-location-line' for `xref-buffer-location' * lisp/progmodes/xref.el (xref-location-line): New method. --- lisp/progmodes/xref.el | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index 2c21d08d4488..f73ede69f17e 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -175,6 +175,11 @@ xref-location-marker (let ((m (make-marker))) (move-marker m position buffer)))) +(cl-defmethod xref-location-line ((l xref-buffer-location)) + (pcase-let (((cl-struct xref-buffer-location buffer position) l)) + (with-current-buffer buffer + (line-number-at-pos position)))) + (cl-defmethod xref-location-group ((l xref-buffer-location)) (pcase-let (((cl-struct xref-buffer-location buffer) l)) (or (buffer-file-name buffer) -- 2.55.0