GNU bug report logs - #46574
cperl-mode: Improve detection of entries for imenu [PATCH]

Previous Next

Package: emacs;

Reported by: haj <at> posteo.de (Harald Jörg)

Date: Tue, 16 Feb 2021 22:55:02 UTC

Severity: normal

Tags: fixed, patch

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 46574 in the body.
You can then email your comments to 46574 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#46574; Package emacs. (Tue, 16 Feb 2021 22:55:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to haj <at> posteo.de (Harald Jörg):
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 16 Feb 2021 22:55:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: haj <at> posteo.de (Harald Jörg)
To: bug-gnu-emacs <at> gnu.org
Subject: cperl-mode: Improve detection of entries for imenu [PATCH]
Date: Tue, 16 Feb 2021 23:54:08 +0100
[Message part 1 (text/plain, inline)]
This patch helps CPerl mode to detect various declarations which should
go into the imenu index but were missed, and also prevents some false
positives from being included.  Undetected package declarations also led
to wrong namespace attributions for subroutines declared within those
packages.

This comes with a new approach to handle Perl syntax: CPerl mode suffers
from a lot of very complex ad-hoc regular expressions, not always
consistent with each other, and very difficult to maintain.  Instead, I
have created some regular expressions for basic syntactic building
blocks which I hope to use in upcoming refactorings to fix some
inaccuracies, and in particular to add support for "modern" or even
upcoming Perl syntax.

The regular expressions are built with rx syntax, but with the
restricted set of rx features which is available in Emacs 26.1 (as
eventually this should be the minimum version for an ELPA release).

These are the constructs which are now correctly processed:

  # really, really weird namespaces
  package ::; # yes, that's perfectly valid!

  # package with a version (since Perl 5.14)
  package Foo::Bar 1.23;

  # package with a block (since Perl 5.14)
  package Foo::Bar {
      ...;
  }

  # subroutines with my, state, our (since Perl 5.18)
  my sub lexical_sub { ...; }
  state sub also_lexical { ...; }
  our sub shared_in_scope { ...; }

  # subroutines in a "foreign" namespace (since "forever")
  sub Elsewhere::routine { ...; }

  # subroutines without space before the attribute (since "forever")
  sub attr:lvalue { ...; } # this is sub attr with attribute :lvalue

-- 
Cheers,
haj
[0001-cperl-mode-Improve-detection-of-index-entries-for-im.patch (text/x-diff, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46574; Package emacs. (Tue, 16 Feb 2021 23:04:01 GMT) Full text and rfc822 format available.

Message #8 received at 46574 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: haj <at> posteo.de (Harald Jörg)
Cc: 46574 <at> debbugs.gnu.org
Subject: Re: bug#46574: cperl-mode: Improve detection of entries for imenu
 [PATCH]
Date: Wed, 17 Feb 2021 00:03:12 +0100
haj <at> posteo.de (Harald Jörg) writes:

> This patch helps CPerl mode to detect various declarations which should
> go into the imenu index but were missed, and also prevents some false
> positives from being included.  Undetected package declarations also led
> to wrong namespace attributions for subroutines declared within those
> packages.

I've only skimmed the patch, but it makes sense to me.  When applying
it, though, patch said:

patching file lisp/progmodes/cperl-mode.el
Hunk #2 succeeded at 1210 (offset -41 lines).
Hunk #3 succeeded at 1367 (offset -41 lines).
Hunk #4 succeeded at 5286 (offset -41 lines).
Hunk #5 succeeded at 5368 (offset -41 lines).
Hunk #6 succeeded at 5403 (offset -41 lines).
Hunk #7 succeeded at 6734 (offset -41 lines).

Which is odd.  Could you check whether the patch is against the current
Emacs trunk?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46574; Package emacs. (Tue, 16 Feb 2021 23:49:01 GMT) Full text and rfc822 format available.

Message #11 received at 46574 <at> debbugs.gnu.org (full text, mbox):

From: haj <at> posteo.de (Harald Jörg)
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 46574 <at> debbugs.gnu.org
Subject: Re: bug#46574: cperl-mode: Improve detection of entries for imenu
 [PATCH]
Date: Wed, 17 Feb 2021 00:48:08 +0100
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> haj <at> posteo.de (Harald Jörg) writes:
>
>> This patch helps CPerl mode to detect various declarations which should
>> go into the imenu index but were missed, and also prevents some false
>> positives from being included.  Undetected package declarations also led
>> to wrong namespace attributions for subroutines declared within those
>> packages.
>
> I've only skimmed the patch, but it makes sense to me.  When applying
> it, though, patch said:
>
> patching file lisp/progmodes/cperl-mode.el
> Hunk #2 succeeded at 1210 (offset -41 lines).
> Hunk #3 succeeded at 1367 (offset -41 lines).
> Hunk #4 succeeded at 5286 (offset -41 lines).
> Hunk #5 succeeded at 5368 (offset -41 lines).
> Hunk #6 succeeded at 5403 (offset -41 lines).
> Hunk #7 succeeded at 6734 (offset -41 lines).
>
> Which is odd.  Could you check whether the patch is against the current
> Emacs trunk?

Ouch.  I thought that my branch was up to date, but apparently Stefan
Kangas has been active with CPerl mode while I was testing.

I've reviewed Stefan's changes now.  There is definitely no conflict and
the patch can be applied regardless of the offset.  The offset mainly
came with 24a98755 (Feb 13), where Stefan eliminated a length of
obsolete documentation.

BTW: Stefan's cleanup work is great here.  I've always wanted to start
working on this but I am not confident enough.  I don't know enough
about the histories of (X)Emacs and CPerl-mode.

-- 
Thanks for checking,
haj




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46574; Package emacs. (Tue, 16 Feb 2021 23:58:02 GMT) Full text and rfc822 format available.

Message #14 received at 46574 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: haj <at> posteo.de (Harald Jörg)
Cc: 46574 <at> debbugs.gnu.org
Subject: Re: bug#46574: cperl-mode: Improve detection of entries for imenu
 [PATCH]
Date: Wed, 17 Feb 2021 00:56:56 +0100
haj <at> posteo.de (Harald Jörg) writes:

> I've reviewed Stefan's changes now.  There is definitely no conflict and
> the patch can be applied regardless of the offset.  The offset mainly
> came with 24a98755 (Feb 13), where Stefan eliminated a length of
> obsolete documentation.

Thanks for checking; I've now applied your patch to Emacs 28.

> BTW: Stefan's cleanup work is great here.

Yup.

> I've always wanted to start working on this but I am not confident
> enough.  I don't know enough about the histories of (X)Emacs and
> CPerl-mode.

I'm a bit vague about the history of the mode, too, but it's OK to rip
out all XEmacs compat code (and compat code with Emacs < 26.1, I think).

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 16 Feb 2021 23:58:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 46574 <at> debbugs.gnu.org and haj <at> posteo.de (Harald Jörg) Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 16 Feb 2021 23:58:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 17 Mar 2021 11:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 34 days ago.

Previous Next


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