From f887a4b3f0f749d95f3a22a9beee1e0855865435 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Thu, 8 Sep 2022 16:50:33 +0300 Subject: [PATCH] ENHANCED: provide caller predicate in xref-find-references --- sweep.el | 7 ++++--- sweep.pl | 13 ++++++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/sweep.el b/sweep.el index f996831..932eec3 100644 --- a/sweep.el +++ b/sweep.el @@ -1201,9 +1201,10 @@ Interactively, a prefix arg means to prompt for BUFFER." (cl-defmethod xref-backend-references ((_backend (eql 'sweep)) mfn) (let ((refs (sweep-predicate-references mfn))) (seq-map (lambda (loc) - (let ((path (car loc)) - (line (or (cdr loc) 1))) - (xref-make (concat path ":" (number-to-string line)) (xref-make-file-location path line 0)))) + (let ((by (car loc)) + (path (cadr loc)) + (line (or (cddr loc) 1))) + (xref-make by (xref-make-file-location path line 0)))) refs))) (cl-defmethod xref-backend-apropos ((_backend (eql 'sweep)) pattern) diff --git a/sweep.pl b/sweep.pl index bdbebf9..1c90e85 100644 --- a/sweep.pl +++ b/sweep.pl @@ -139,7 +139,6 @@ sweep_identifier_at_point([Contents0, Path, Point], Identifier) :- :- dynamic sweep_current_identifier_at_point/1. - sweep_identifier_at_point_(Path0, Point, Contents, Identifier) :- atom_string(Path, Path0), ( xref_module(Path, M) @@ -360,13 +359,17 @@ sweep_module_description([M0|P], [M|[P]]) :- atom_string(M0, M). sweep_predicate_references(MFN, Refs) :- term_string(M:F/N, MFN), pi_head(F/N, H), - findall([Path|Line], - (xref_called(Path0, H, _, _, Line), + findall([B,Path|Line], + (xref_called(Path0, H, B0, _, Line), + pi_head(B1, B0), + term_string(B1, B), atom_string(Path0, Path)), Refs, Tail), - findall([Path|Line], - (xref_called(Path0, M:H, _, _, Line), + findall([B,Path|Line], + (xref_called(Path0, M:H, B0, _, Line), + pi_head(B1, B0), + term_string(B1, B), atom_string(Path0, Path)), Tail). -- 2.39.2