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.

Full log


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)]

This bug report was last modified 4 years and 179 days ago.

Previous Next


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