From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.help Subject: Re: xref-find-references returns duplicates Date: Tue, 27 Dec 2022 03:09:47 +0200 Message-ID: <972ed3e4-6abf-d79f-f642-c340814d599c@yandex.ru> References: <7ac4ca06-cbbb-1c8d-0f59-2ccd5d3232f2@iki.fi> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40511"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 To: Petteri Hintsanen , help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 27 02:10:34 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p9yUE-000AQt-A5 for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 27 Dec 2022 02:10:34 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p9yTb-0007sZ-So; Mon, 26 Dec 2022 20:09:55 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p9yTa-0007s1-3P for help-gnu-emacs@gnu.org; Mon, 26 Dec 2022 20:09:54 -0500 Original-Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p9yTY-0001Z7-6c for help-gnu-emacs@gnu.org; Mon, 26 Dec 2022 20:09:53 -0500 Original-Received: by mail-wr1-x42c.google.com with SMTP id co23so11218539wrb.4 for ; Mon, 26 Dec 2022 17:09:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=xtbYf95c87dAKJApfzPPxyxYH7SZOv95kLAXHyfFuKw=; b=d0wrxaO8q6EUsLB2xofVaWC0Vi6QZ/a7gG2IICRt43OdcHC3nh9XZGGnu89T6RKH8V gShSUEvBO7GW6AQ9853a5SmzviDpToOLlVrJ9ZdOP6YI0H9+hJU0kiosI0+3fZSmNS6q jSdyL4g3qQZxgm9l90RZa562B3OLdJAoeRwvja9l/dduhsJsVLjhLJ87WhLp+BkMbwov zje4af4Xu+7t1ReO+18bR8XitGHpuCANBtKVjpvla0KLk6y15hSI7v15dD8J2uhn+C9I h4kCSEvuwTM8KNdQMKuPS93DahQRPs+rKe5UVq7X8bKOGqTSM9+TXDZiIY9b60tQNnlt FhyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=xtbYf95c87dAKJApfzPPxyxYH7SZOv95kLAXHyfFuKw=; b=x+nx3gzFmu8HBZqfxVjUcH6uNckuLtkodrUPbiL1rjL3au+azJ2DOX7Rc4tRgHQFy5 CdybnoUeqoJzR+p4b+ZPy7P0NHFSpaAMXm670v3XvhK4rsrAUHPw//MEKv3ViJObkZ5C YUMr2qqOkjGNMfgTWdYD5jOrlBR+DHCVI0jR/nTpejNDT0fBczED+JM/8LCSpuf7Myv4 q3czO9VQv0t/faVrhrYvfZo2eFFWT0h/7HEC6xJvSaHkTdJKFhdk8Ajw+vnbjzsEWrQs dcsWYz6c3jpu6dOxhUZFC+5C50REbrOkAX/2XFn1CLVwtjbN0JhlCKyL6C+2E7FMTDIu BgNw== X-Gm-Message-State: AFqh2kpGVLsFe43JJXc+bya1uATcn0BCByKDKpeudgmR/9RBvR4yriCc CMkweCMi5gPgXehiBFOcHqA= X-Google-Smtp-Source: AMrXdXvOWqp228W1MALBovM6Z8fNhimhhMuCX9iTgC+/lU/LqZL7QON6YcNFGehmaD+ajRZEh8Bmwg== X-Received: by 2002:adf:f54a:0:b0:242:2e1e:23a6 with SMTP id j10-20020adff54a000000b002422e1e23a6mr12996452wrp.22.1672103389223; Mon, 26 Dec 2022 17:09:49 -0800 (PST) Original-Received: from [192.168.0.2] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id x2-20020adfec02000000b0025e86026866sm13684718wrn.0.2022.12.26.17.09.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Dec 2022 17:09:48 -0800 (PST) Content-Language: en-US In-Reply-To: <7ac4ca06-cbbb-1c8d-0f59-2ccd5d3232f2@iki.fi> Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=raaahh@gmail.com; helo=mail-wr1-x42c.google.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, NICE_REPLY_A=-1.147, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:141947 Archived-At: 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.