Subject: bug#26037: 25.1; perl-mode add syntax support for subroutine signatures

From: Евгени Колев <[email-masked]>
Date: Sun, 26 Mar 2017 20:29:55 +0300

The regex is now updated to include all the chars $%&*;@[\]

I got the list of chars from here
http://perldoc.perl.org/perlsub.html#Prototypes

This is the diff, please let me if it can be improved:

diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el
index a516f07..43eb462 100644
--- a/lisp/progmodes/perl-mode.el
+++ b/lisp/progmodes/perl-mode.el
@@ -257,7 +257,7 @@
        (1 (prog1 "\"" (perl-syntax-propertize-special-constructs end))))
       ;; Funny things in `sub' arg-specs like `sub myfun ($)' or `sub ($)'.
       ;; Be careful not to match "sub { (...) ... }".
-      ("\\<sub\\(?:[\s\t\n]+\\(?:\\sw\\|\\s_\\)+\\)?[\s\t\n]*(\\([^)]+\\))"
+
 ("\\<sub\\(?:[\s\t\n]+\\(?:\\sw\\|\\s_\\)+\\)?[\s\t\n]*(\\([][$%&*;@\\]+\\))"
        (1 "."))
       ;; Turn __DATA__ trailer into a comment.
       ("^\\(_\\)_\\(?:DATA\\|END\\)__[
\t]*\\(?:\\(\n\\)#.-\\*-.*perl.*-\\*-\\|\n.*\\)"

On Sat, Mar 18, 2017 at 5:58 PM, <[email-masked]> wrote:

> Евгени Колев <[email-masked]> writes:
>
> >
> > After giving some thought to this, I think we can instead
> > make the regex more strict so that it matches only the
> > allowed characters in perl's prototypes. The allowed chars
> > are: $%&*;@[\]
> >
> > This is what I have in mind - diff is pasted below.
> > However, please note the change below doesn't handle
> > these 3 chars [ / ]  I'll add them if you think this is the correct
> > approach:
>
> Yeah, that looks right to me (although I don't know perl very well).
>