From: Dmitry Gutov <dgutov@yandex.ru>
To: Petteri Hintsanen <petterih@iki.fi>, help-gnu-emacs@gnu.org
Subject: Re: xref-find-references returns duplicates
Date: Tue, 27 Dec 2022 03:09:47 +0200 [thread overview]
Message-ID: <972ed3e4-6abf-d79f-f642-c340814d599c@yandex.ru> (raw)
In-Reply-To: <7ac4ca06-cbbb-1c8d-0f59-2ccd5d3232f2@iki.fi>
On 19/12/2022 02:25, Petteri Hintsanen wrote:
> Hello list,
>
> I discovered a somewhat peculiar case where xref-find-references returns
> duplicate references for elisp symbols.
>
> Here is a toy example:
>
> 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. Visit ~/foo/bar/bar.el and do xref-find-references for bar-f
>
> 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 ~/foo from step (3) above, then I don't see any duplicates.
>
> Am I abusing load-path somehow, or is this a bug, or something else?
I suppose it's a bug, or a limitation of the algorithm anyway.
The default "find references" implementation currently delegates to
xref-references-in-directory, which uses the semantic-symref-tool
facility to search for a simple notion of "references" inside a
directory tree. It doesn't have a mechanism to exclude certain
directories, such as the current project root (from being searched twice
over).
You can file a bug report with 'M-x report-emacs-bug', different ways to
solve this exist, more or less adequately.
next prev parent reply other threads:[~2022-12-27 1:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-19 0:25 xref-find-references returns duplicates Petteri Hintsanen
2022-12-27 1:09 ` Dmitry Gutov [this message]
2022-12-27 15:46 ` Petteri Hintsanen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=972ed3e4-6abf-d79f-f642-c340814d599c@yandex.ru \
--to=dgutov@yandex.ru \
--cc=help-gnu-emacs@gnu.org \
--cc=petterih@iki.fi \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).