emacs/test/lisp/progmodes/cperl-mode-resources/cperl-indents.erts
Harald Jörg 766784f186 cperl-mode.el: Add support for new Perl syntax in Perl 5.36 and 5.38
Perl 5.38 was released on 2023-07-03.  This patch supports the new features
for 5.36 and 5.38 for font-lock, indentation, and imenu index creation.

* lisp/progmodes/cperl-mode.el (cperl-praise): Mention classes.
(defconst): Fix typo in docstring of cperl--single-attribute-rx.
Add "class" to cperl--package-rx, and adjust its docstring.
New rx sequence cperl--class-for-imenu-rx to capture classes,
use this in cperl--imenu-entries-rx.
Add "method" to cperl--sub-name-for-imenu-rx.
Add "class" to cperl--block-declaration-rx.
(cperl-sub-keywords): Add "method".
(cperl-mode): Add "ADJUST" to defun-prompt-regexp.
(cperl-after-block-p): Add new keywords for Perl 5.36 and 5.38.
(cperl-indent-exp): Add "field" to expression starters.
(cperl-imenu--create-perl-index): Rename variables refering to
"package", because they also contain classes.
(cperl-init-faces): Add new keywords for Perl 5.36 and 5.38.
(cperl-find-tags): Add support for "class".
(cperl-short-docs): Add new keywords for Perl 5.36 and 5.38.
(cperl-indent-exp): Add new keywords for Perl 5.36 and 5.38.

* test/lisp/progmodes/cperl-mode-tests.el
(cperl-test-fontify-class): New test for fontification of class
elements.
(cperl-test-imenu-index): Add tests for (nested) class
definitions.

* test/lisp/progmodes/cperl-mode-resources/cperl-indents.erts:
Add test cases for try/catch/finally, defer, class, method

* test/lisp/progmodes/cperl-mode-resources/perl-class.pl: New
resource for fontification tests of class elements.

* test/lisp/progmodes/cperl-mode-resources/grammar.pl: Add some
classes to the test resource.
2023-07-03 23:05:10 +02:00

81 lines
812 B
Text

Code:
(lambda ()
(cperl-mode)
(indent-region (point-min) (point-max)))
Name: cperl-indent1
=-=
{
print "",
"",
foo::bar(),
"";
}
=-=-=
Name: cperl-indents1
=-=
{
print "",
"",
foobar(),
"";
}
=-=-=
Name: cperl-try-catch-finally
=-=
{
try {
call_a_function();
}
catch ($e) {
warn "Unable to call; $e";
}
finally {
print "Finished\n";
}
}
=-=-=
Name: cperl-defer
=-=
use feature 'defer';
{
say "This happens first";
defer {
say "This happens last";
}
say "And this happens inbetween";
}
=-=-=
Name: cperl-feature-class
=-=
use 5.038;
use feature "class";
no warnings "experimental";
class A {
}
class C
: isa(A)
{
method with_sig_and_attr
: lvalue
($top,$down)
{
return $top-$down;
}
}
say "done!";
=-=-=