all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dmitry@gutov.dev>
To: Petteri Hintsanen <petterih@iki.fi>, 66683@debbugs.gnu.org
Subject: bug#66683: 30.0.50; xref-find-references returns duplicates
Date: Mon, 23 Oct 2023 22:11:51 +0300	[thread overview]
Message-ID: <f399cb9d-575c-f08c-d368-c69c2478d600@gutov.dev> (raw)
In-Reply-To: <87h6mioetl.fsf@iki.fi>

On 22/10/2023 18:29, Petteri Hintsanen wrote:
> [This is a bug report from an old issue discussed in
> help-gnu-emacs@gnu.org  (dated 19 Dec 2022, Message-ID
> <7ac4ca06-cbbb-1c8d-0f59-2ccd5d3232f2@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.






  reply	other threads:[~2023-10-23 19:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-22 15:29 bug#66683: 30.0.50; xref-find-references returns duplicates Petteri Hintsanen
2023-10-23 19:11 ` Dmitry Gutov [this message]
2023-10-23 20:02   ` Petteri Hintsanen
2023-10-23 20:54     ` Dmitry Gutov

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f399cb9d-575c-f08c-d368-c69c2478d600@gutov.dev \
    --to=dmitry@gutov.dev \
    --cc=66683@debbugs.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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.