emacs/test/lisp/progmodes/cperl-mode-resources/sub-names.pl
Harald Jörg 3c44d7a1b7 cperl-mode.el: Subroutine names are fontified correctly in all places
Subroutine names are fontified as subroutine names even if the name is also
the name of a builtin (fixing an ancient unreported bug).  Subroutine name
are just comments in comment and pod (fixing a bug introduced recently)

* lisp/progmodes/cperl-mode.el (cperl-init-faces): Move
fontification of sub declarations before that of builtins.  Don't
override existing faces when fontifying subroutine declarations.
Don't fontify method calls even if the sub names match those of
builtins.

* test/lisp/progmodes/cperl-mode-tests.el (cperl-test-fontify-sub-names):
New tests with a subroutine name in several surroundings.

* test/lisp/progmodes/cperl-mode-resources/sub-names.pl: New resource
for the new test.
2023-08-02 23:59:42 +02:00

25 lines
616 B
Perl

use 5.038;
use feature 'class';
use warnings;
no warnings 'experimental';
class C {
# "method" is not yet understood by perl-mode, but it isn't
# relevant here: We can use "sub" because what matters is the
# name, which collides with a builtin.
sub m {
"m called"
}
}
say C->new->m;
# This comment has a method name in it, and we don't want "method"
# to be fontified as a keyword, nor "name" fontified as a name.
__END__
=head1 Test using the keywords POD
This piece of POD has a method name in it, and we don't want "method"
to be fontified as a keyword, nor "name" fontified as a name.