GNU bug report logs -
#66683
30.0.50; xref-find-references returns duplicates
Previous Next
Reported by: Petteri Hintsanen <petterih <at> iki.fi>
Date: Sun, 22 Oct 2023 15:31:01 UTC
Severity: normal
Found in version 30.0.50
Fixed in version 30.1
Done: Dmitry Gutov <dmitry <at> gutov.dev>
Bug is archived. No further changes may be made.
Full log
Message #8 received at 66683 <at> debbugs.gnu.org (full text, mbox):
On 22/10/2023 18:29, Petteri Hintsanen wrote:
> [This is a bug report from an old issue discussed in
> help-gnu-emacs <at> gnu.org (dated 19 Dec 2022, Message-ID
> <7ac4ca06-cbbb-1c8d-0f59-2ccd5d3232f2 <at> iki.fi>). Dmitry Gutov asked me
> to file a bug, which I unfortunately forgot to do that time. Hence
> filing now.]
>
> I discovered a somewhat peculiar case where xref-find-references returns
> duplicate references for elisp symbols.
>
> Recipe:
>
> 1. Create a file ~/foo/bar/bar.el with contents:
>
> (defun bar-f ())
>
> (defun bar-g ()
> (bar-f))
>
> (provide 'bar)
>
> 2. Create a git repo in ~/foo/bar and commit bar.el. This is just to
> set up a project that Emacs can recognize.
>
> 3. Start emacs -Q and eval
>
> (add-to-list 'load-path "~/foo")
> (add-to-list 'load-path "~/foo/bar")
> (require 'bar)
>
> 4. C-x C-f ~/foo/bar/bar.el
>
> 5. M-x xref-find-references RET bar-f RET
>
> On my machine I get
>
> bar.el
> 1: (defun bar-f ())
> 4: (bar-f))
> 1: (defun bar-f ())
> 4: (bar-f))
>
> i.e. references are duplicated. The issue seems to be in load-path: if
> I remove (add-to-list 'load-path "~/foo") from step (3) above, then I
> don't see any duplicates.
Hi! Thanks for the report and the reminder.
Could you try this little patch below?
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index fd788ec8f32..81618428bf3 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -281,9 +281,10 @@ xref-backend-references
(xref-references-in-directory identifier dir)
(message "Searching %s... done" dir)))
(let ((pr (project-current t)))
- (cons
- (xref--project-root pr)
- (project-external-roots pr)))))
+ (project-combine-directories
+ (cons
+ (xref--project-root pr)
+ (project-external-roots pr))))))
(cl-defgeneric xref-backend-apropos (backend pattern)
"Find all symbols that match PATTERN string.
This bug report was last modified 1 year and 262 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.