* bug#66683: 30.0.50; xref-find-references returns duplicates
@ 2023-10-22 15:29 Petteri Hintsanen
2023-10-23 19:11 ` Dmitry Gutov
0 siblings, 1 reply; 4+ messages in thread
From: Petteri Hintsanen @ 2023-10-22 15:29 UTC (permalink / raw)
To: 66683
[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.
In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
2.24.33, cairo version 1.16.0) of 2023-10-22 built on romeo
Repository revision: ae337884107c4d5f66aaceef0e8b548565317412
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101007
System Description: Debian GNU/Linux 12 (bookworm)
Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON
LCMS2 LIBOTF LIBSELINUX LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG
SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP
X11 XDBE XIM XINPUT2 XPM GTK2 ZLIB
Important settings:
value of $LC_MESSAGES: en_US.UTF-8
value of $LANG: fi_FI.UTF-8
locale-coding-system: utf-8-unix
Major mode: Lisp Interaction
Minor modes in effect:
display-fill-column-indicator-mode: t
bug-reference-prog-mode: t
jinx-mode: t
winner-mode: t
savehist-mode: t
minibuffer-electric-default-mode: t
display-time-mode: t
emms-playing-time-display-mode: t
emms-playing-time-mode: t
desktop-save-mode: t
cwm-mode: t
windmove-mode: t
override-global-mode: t
tooltip-mode: t
global-eldoc-mode: t
eldoc-mode: t
show-paren-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
minibuffer-regexp-mode: t
column-number-mode: t
line-number-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
hs-minor-mode: t
Load-path shadows:
/home/phintsan/.emacs.d/elpa/transient-0.4.3/transient hides /home/phintsan/src/emacs/lisp/transient
Features:
(shadow mail-extr emacsbug message yank-media puny rfc822 mml mml-sec
epa derived epg rfc6068 epg-config gnus-util text-property-search
mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils
mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr
mail-utils hideshow display-fill-column-indicator bug-reference jinx
compat ph-simple-theme rx winner ring savehist minibuf-eldef time
emms-mpris pcase dbus emms-librefm-stream xml emms-librefm-scrobbler
emms-playlist-limit emms-i18n emms-history emms-score emms-stream-info
emms-metaplaylist-mode emms-bookmarks emms-cue emms-mode-line-icon
emms-browser sort emms-volume emms-volume-sndioctl emms-volume-mixerctl
emms-volume-pulse emms-volume-amixer emms-playlist-sort emms-last-played
emms-player-xine emms-player-mpd tq emms-lyrics emms-url time-date
emms-streams emms-show-all emms-tag-editor format-spec emms-tag-tracktag
emms-mark emms-mode-line emms-cache emms-info-native
emms-info-native-spc emms-info-native-mp3 emms-info-native-ogg
emms-info-native-opus emms-info-native-flac emms-info-native-vorbis
bindat emms-info-exiftool emms-info-tinytag emms-info-metaflac
emms-info-opusinfo emms-info-ogginfo emms-info-mp3info
emms-playlist-mode emms-player-vlc emms-player-mpv emms-playing-time
emms-info emms-later-do emms-player-mplayer emms-player-simple
emms-source-playlist emms-source-file thingatpt locate dired
dired-loaddefs emms-setup emms emms-compat desktop frameset cwm-mode
windmove edmacro kmacro cl-extra help-mode use-package-bind-key bind-key
easy-mmode finder-inf use-package-core cus-edit pp cus-load icons
wid-edit ack-autoloads jinx-autoloads perl-doc-autoloads
transient-autoloads with-editor-autoloads info compat-autoloads package
browse-url url url-proxy url-privacy url-expand url-methods url-history
url-cookie generate-lisp-file url-domsuf url-util mailcap url-handlers
url-parse auth-source cl-seq eieio eieio-core cl-macs password-cache
json subr-x map byte-opt gv bytecomp byte-compile url-vars cl-loaddefs
cl-lib rmc iso-transl tooltip cconv eldoc paren electric uniquify
ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win
term/common-win x-dnd touch-screen tool-bar dnd fontset image regexp-opt
fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode
register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer nadvice seq simple cl-generic indonesian philippine
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure
cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp
files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget keymap hashtable-print-readable backquote
threads dbusbind inotify lcms2 dynamic-setting system-font-setting
font-render-setting cairo gtk x-toolkit xinput2 x multi-tty move-toolbar
make-network-process emacs)
Memory information:
((conses 16 274554 22405) (symbols 48 13707 0) (strings 32 99822 3656)
(string-bytes 1 2414869) (vectors 16 29913)
(vector-slots 8 1123232 231495) (floats 8 86 55) (intervals 56 853 0)
(buffers 992 10))
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#66683: 30.0.50; xref-find-references returns duplicates
2023-10-22 15:29 bug#66683: 30.0.50; xref-find-references returns duplicates Petteri Hintsanen
@ 2023-10-23 19:11 ` Dmitry Gutov
2023-10-23 20:02 ` Petteri Hintsanen
0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Gutov @ 2023-10-23 19:11 UTC (permalink / raw)
To: Petteri Hintsanen, 66683
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.
^ permalink raw reply related [flat|nested] 4+ messages in thread
* bug#66683: 30.0.50; xref-find-references returns duplicates
2023-10-23 19:11 ` Dmitry Gutov
@ 2023-10-23 20:02 ` Petteri Hintsanen
2023-10-23 20:54 ` Dmitry Gutov
0 siblings, 1 reply; 4+ messages in thread
From: Petteri Hintsanen @ 2023-10-23 20:02 UTC (permalink / raw)
To: Dmitry Gutov; +Cc: 66683
Dmitry Gutov <dmitry@gutov.dev> writes:
> Could you try this little patch below?
Happy to report it fixes the issue: both the toy example in the recipe
and my original problem.
Thanks for your time,
Petteri
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#66683: 30.0.50; xref-find-references returns duplicates
2023-10-23 20:02 ` Petteri Hintsanen
@ 2023-10-23 20:54 ` Dmitry Gutov
0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Gutov @ 2023-10-23 20:54 UTC (permalink / raw)
To: Petteri Hintsanen; +Cc: 66683-done
Version: 30.1
On 23/10/2023 23:02, Petteri Hintsanen wrote:
> Dmitry Gutov<dmitry@gutov.dev> writes:
>
>> Could you try this little patch below?
> Happy to report it fixes the issue: both the toy example in the recipe
> and my original problem.
>
> Thanks for your time,
Thanks for checking!
Now pushed to master for the next Emacs release.
But the next version of Xref on GNU ELPA will also include it the fix
(will probably tag it in 1-2 weeks).
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-10-23 20:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-22 15:29 bug#66683: 30.0.50; xref-find-references returns duplicates Petteri Hintsanen
2023-10-23 19:11 ` Dmitry Gutov
2023-10-23 20:02 ` Petteri Hintsanen
2023-10-23 20:54 ` Dmitry Gutov
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).