GNU bug report logs - #77421
[PATCH] [etags] Fix module definition with ::

Previous Next

Package: emacs;

Reported by: Laurent Stacul <laurent.stacul <at> gmail.com>

Date: Tue, 1 Apr 2025 00:15:01 UTC

Severity: normal

Tags: patch

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Laurent Stacul <laurent.stacul <at> gmail.com>
Subject: bug#77421: closed (Re: bug#77421: [PATCH] [etags] Fix module
 definition with ::)
Date: Thu, 03 Apr 2025 06:14:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#77421: [PATCH] [etags] Fix module definition with ::

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 77421 <at> debbugs.gnu.org.

-- 
77421: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=77421
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Eli Zaretskii <eliz <at> gnu.org>
To: Dmitry Gutov <dmitry <at> gutov.dev>
Cc: 77421-done <at> debbugs.gnu.org, laurent.stacul <at> gmail.com
Subject: Re: bug#77421: [PATCH] [etags] Fix module definition with ::
Date: Thu, 03 Apr 2025 09:13:25 +0300
> Date: Wed, 2 Apr 2025 00:52:18 +0300
> Cc: 77421 <at> debbugs.gnu.org
> From: Dmitry Gutov <dmitry <at> gutov.dev>
> 
> Hi!
> 
> On 01/04/2025 14:53, Eli Zaretskii wrote:
> >> Or, if M already exists, we can also write:
> >>
> >>    module M::N; end
> >>
> >> With the later notation, the tag generated by etags will be M::N. When
> >> browsing the code, using xref-find-definitions when the point is on N,
> >> will not be able to find the definition of N because the implicit tag
> >> name is M::N.
> >>
> >> This is the same problem with nested classes or even some rare
> >> allowed definitions like explicitely defining a module/class from the
> >> global namespace:
> >>
> >>    class ::A; end
> >>
> >> Solution: We need to give an explicit tag name. To achieve this, on
> >> module/class definition we truncate the name to the last found column.
> > Thanks.
> > 
> > Dmitry, any comments?
> 
> Yes, this all seems right.
> 
> This might have not come up before because this convention is relatively 
> less popular, but the proposed change should be an improvement.

Thanks, now installed on master, and closing the bug.

[Message part 3 (message/rfc822, inline)]
From: Laurent Stacul <laurent.stacul <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] [etags] Fix module definition with ::
Date: Mon, 31 Mar 2025 20:45:12 +0200
[Message part 4 (text/plain, inline)]
Tags: patch

Tags: patch

Hello dear Emacs maintainers,

I have a patch I would like to submit. I tried to follow all the docs
but if I did something wrong, don't hesitate to tell me.

Problem: In ruby we can define a nested module/class the safe way (in
the sense, if the parent module does not exist, it will define it):

  module M
    module N
    end
  end

Or, if M already exists, we can also write:

  module M::N; end

With the later notation, the tag generated by etags will be M::N. When
browsing the code, using xref-find-definitions when the point is on N,
will not be able to find the definition of N because the implicit tag
name is M::N.

This is the same problem with nested classes or even some rare
allowed definitions like explicitely defining a module/class from the
global namespace:

  class ::A; end

Solution: We need to give an explicit tag name. To achieve this, on
module/class definition we truncate the name to the last found column.

Best Regards,
Laurent

In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.43, cairo version 1.18.2) of 2025-03-29 built on Host-002
Repository revision: 04bd6497300789cd90b365299885517d92292648
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101016
System Description: Fedora Linux 41 (Workstation Edition)

Configured using:
 'configure --prefix=/home/stac/.local --disable-gc-mark-trace
 --with-cairo --with-dbus --with-gif --with-gpm=no --with-gnutls
 --with-harfbuzz --with-imagemagick --with-jpeg --with-mailutils
 --with-modules --with-native-compilation=aot --with-png --with-rsvg
 --with-sqlite3 --with-tiff --with-tree-sitter --with-webp
 --with-wide-int --with-x-toolkit=gtk3 --with-xinput2 --with-xpm
 --without-pop 'CFLAGS=-O2 -pipe -mtune=native -march=native
 -fomit-frame-pointer''

[0001-etags-Fix-module-definition-with.patch (text/patch, attachment)]

This bug report was last modified 46 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.