Subject: bug#88 closed by Stefan Monnier <[email-masked]> (Re: perl-mode - fix syntax of anonymous sub prototypes)

From: [email-masked] (Emacs bug Tracking System)

This is an automatic notification regarding your bug report
which was filed against the emacs package:

#88: perl-mode - fix syntax of anonymous sub prototypes

It has been closed by Stefan Monnier <[email-masked]>.

Their explanation is attached below along with your original report.
If this explanation is unsatisfactory and you have not received a
better one in a separate message then please contact Stefan Monnier <[email-masked]> by
replying to this email.

-- 
88: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=88
Emacs Bug Tracking System
Contact [email-masked] with problems
>From [email-masked] Fri Apr  4 03:36:32 2008
Resent-Message-ID: <[email-masked]>
Resent-To: [email-masked]
Resent-From: Stefan Monnier <[email-masked]>
Resent-Date: Thu, 03 Apr 2008 23:38:08 -0400
From: Stefan Monnier <[email-masked]>
To: "Giuliano Procida" <[email-masked]>
Cc: [email-masked]
Subject: Re: perl-mode - fix syntax of anonymous sub prototypes
Date: Thu, 03 Apr 2008 18:10:56 -0400

>     ;; Funny things in sub arg specifications like `sub myfunc ($$)'
>     ;; Be careful not to match "sub { (...) ... }".
>     ("\\<sub[[:space:]]+[^{}[:punct:][:space:]]+[[:space:]]*(\\([^)]+\\))"
> 1 '(1))

> It is still wrong for anonymous subs. Should be (untested):

> "\\<sub\\(?:[[:space:]]+[^{}[:punct:][:space:]]+\\)?[[:space:]]*(\\([^)]+\\))"

Thanks, installed,

        Stefan

>From [email-masked] Sat Mar 29 11:49:47 2008
Resent-Message-ID: <[email-masked]>
Resent-To: [email-masked]
Resent-From: Stefan Monnier <[email-masked]>
Resent-Date: Sat, 29 Mar 2008 14:49:38 -0400
Date: Fri, 28 Mar 2008 17:37:08 +0000
From: "Giuliano Procida" <[email-masked]>
To: [email-masked]
Subject: perl-mode - fix syntax of anonymous sub prototypes
Sender: bug-gnu-emacs-bounces+monnier=[email-masked]

Hi.

GNU Emacs 22.1.1 (i386-pc-solaris2.10, X toolkit) of 2008-02-11 on robot

Constructs like this:

    my $del = sub($) {
        my ($old) = @_;
        return if not active($old);
        &$delete_row($old->{$fde_id});
    };

upset later indentation as the $ in the sub($) has the default
backslash syntax class (instead of being treated specially as in
non-anonymous sub definitions) and then the "sub(" triggers the
hanging parens check.

The fix is to modify perl-font-lock-syntactic-keywords to have:

    ;; Funny things in sub arg specifications like `sub myfunc ($$)'
and `sub ($)'
    ("\\<sub\\(?:\\s-+\\S-+\\)?\\s-*(\\([^)]+\\))" 1 '(1))

instead of the existing regexp.

Here's a patch.

--- emacs/22.1/lisp/progmodes/perl-mode.el~   2008-03-28
17:19:19.267639000 +0000
+++ emacs/22.1/lisp/progmodes/perl-mode.el    2008-03-28
17:32:15.510903000 +0000
@@ -265,7 +265,7 @@
     ("\\$ ?{?^?[_a-zA-Z][_a-zA-Z0-9]*\\('\\)[_a-zA-Z]" (1 "_"))
     ;; format statements
     ("^[ \t]*format.*=[ \t]*\\(\n\\)" (1 '(7)))
-    ;; Funny things in sub arg specifications like `sub myfunc ($$)'
+    ;; Funny things in sub arg specifications like `sub myfunc ($$)'
and `sub ($)'
     ("\\<sub\\(?:\\s-+\\S-+\\)?\\s-*(\\([^)]+\\))" 1 '(1))
     ;; regexp and funny quotes
     ("[?:.,;=!~({[][ \t\n]*\\(/\\)" (1 '(7)))

This was really annoying me! If you need a proper test case Perl file,
I can cook one up.

Regards,
Giuliano Procida.