emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: perl-mode confused whith split(/,/,$var);


From: Stefan Monnier
Subject: Re: perl-mode confused whith split(/,/,$var);
Date: Wed, 16 Nov 2005 22:20:41 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

> This code below confuses perl-mode. The comma in split /,/, ...  causes
> everything after it to be indented and hi-lighted wrong.

The best I could come up with so far is the patch below.  Please try it.
It's a real pain in the rear to have to do so much effort just for this one
special case.

But it's really non trivial since I have to be able to tell the difference
between

        $tmp = split / $foo /
and
        $tmp = $ split / $foo /
or
        $tmp = $# split /$ foo /


-- Stefan


Index: perl-mode.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/perl-mode.el,v
retrieving revision 1.62
diff -u -u -b -r1.62 perl-mode.el
--- perl-mode.el        2 Nov 2005 17:33:28 -0000       1.62
+++ perl-mode.el        17 Nov 2005 03:17:48 -0000
@@ -267,7 +267,12 @@
     ;; Funny things in sub arg specifications like `sub myfunc ($$)'
     ("\\<sub\\s-+\\S-+\\s-*(\\([^)]+\\))" 1 '(1))
     ;; regexp and funny quotes
-    ("[?:.,;=!~({[][ \t\n]*\\(/\\)" (1 '(7)))
+    ("\\(?:[?:.,;=!~({[]\\|\\<split\\)[ \t\n]*\\(/\\)"
+     (1 (if (or (not (eq (char-after (match-beginning 0)) ?s))
+                (save-excursion (goto-char (match-beginning 0))
+                                (skip-chars-backward " \t")
+                                (not (memq (char-before) '(?$ ?# ?% ?@)))))
+            '(7))))
     ("\\(^\\|[?:.,;=!~({[ \t]\\)\\([msy]\\|q[qxrw]?\\|tr\\)\\>\\s-*\\([^])}> 
\n\t]\\)"
      ;; Nasty cases:
      ;; /foo/m  $a->m  $#m $m @m %m




reply via email to

[Prev in Thread] Current Thread [Next in Thread]