]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/perl-mode.el
(compilation-start): Resurrect the version for systems that don't support
[gnu-emacs] / lisp / progmodes / perl-mode.el
index ee14100f56d7f9e3de7622d3b9a0f676e6ac0dec..c92ac4252da0aeb30aad02b6b87010b06c2d0c15 100644 (file)
@@ -1,6 +1,6 @@
 ;;; perl-mode.el --- Perl code editing commands for GNU Emacs
 
-;; Copyright (C) 1990, 1994, 2001, 2002, 2003, 2004, 2005, 2006, 2007
+;; Copyright (C) 1990, 1994, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
 ;; Free Software Foundation, Inc.
 
 ;; Author: William F. Mann
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -24,9 +24,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
@@ -254,7 +252,7 @@ The expansion is entirely correct because it uses the C preprocessor."
 ;; <file*glob>
 (defvar perl-font-lock-syntactic-keywords
   ;; TODO: here-documents ("<<\\(\\sw\\|['\"]\\)")
-  '(;; Turn POD into b-style comments
+  `(;; Turn POD into b-style comments
     ("^\\(=\\)\\sw" (1 "< b"))
     ("^=cut[ \t]*\\(\n\\)" (1 "> b"))
     ;; Catch ${ so that ${var} doesn't screw up indentation.
@@ -265,16 +263,31 @@ The expansion is entirely correct because it uses the C preprocessor."
     ("\\$ ?{?^?[_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-specs like `sub myfun ($)' or `sub ($)'.
     ;; Be careful not to match "sub { (...) ... }".
-    ("\\<sub[[:space:]]+[^{}[:punct:][:space:]]+[[:space:]]*(\\([^)]+\\))"
+    ("\\<sub\\(?:[[:space:]]+[^{}[:punct:][:space:]]+\\)?[[:space:]]*(\\([^)]+\\))"
      1 '(1))
-    ;; Regexp and funny quotes.
-    ("\\(?:[?:.,;=!~({[]\\|\\(^\\)\\)[ \t\n]*\\(/\\)"
+    ;; Regexp and funny quotes.  Distinguishing a / that starts a regexp
+    ;; match from the division operator is ...interesting.
+    ;; Basically, / is a regexp match if it's preceded by an infix operator
+    ;; (or some similar separator), or by one of the special keywords
+    ;; corresponding to builtin functions that can take their first arg
+    ;; without parentheses.  Of course, that presume we're looking at the
+    ;; *opening* slash.  We can mis-match the closing ones, because they are
+    ;; treated separately later in
+    ;; perl-font-lock-special-syntactic-constructs.
+    (,(concat "\\(?:\\(?:\\(?:^\\|[^$@&%[:word:]]\\)"
+              (regexp-opt '("split" "if" "unless" "until" "while" "split"
+                            "grep" "map" "not" "or" "and"))
+              "\\)\\|[?:.,;=!~({[]\\|\\(^\\)\\)[ \t\n]*\\(/\\)")
      (2 (if (and (match-end 1)
                  (save-excursion
                    (goto-char (match-end 1))
-                   (skip-chars-backward " \t\n")
+                   ;; Not 100% correct since we haven't finished setting up
+                   ;; the syntax-table before point, but better than nothing.
+                   (forward-comment (- (point-max)))
+                   (put-text-property (point) (match-end 2)
+                                      'jit-lock-multiline t)
                    (not (memq (char-before)
                               '(?? ?: ?. ?, ?\; ?= ?! ?~ ?\( ?\[)))))
             nil ;; A division sign instead of a regexp-match.
@@ -322,7 +335,7 @@ The expansion is entirely correct because it uses the C preprocessor."
     (while (< (point) limit)
       (cond
        ((or (null (setq char (nth 3 state)))
-            (and (char-valid-p char) (eq (char-syntax (nth 3 state)) ?\")))
+            (and (characterp char) (eq (char-syntax (nth 3 state)) ?\")))
         ;; Normal text, or comment, or docstring, or normal string.
         nil)
        ((eq (nth 3 state) ?\n)
@@ -402,12 +415,17 @@ The expansion is entirely correct because it uses the C preprocessor."
   :type 'integer
   :group 'perl)
 
-;; Is is not unusual to put both perl-indent-level and
+;; Is is not unusual to put both things like perl-indent-level and
 ;; cperl-indent-level in the local variable section of a file. If only
 ;; one of perl-mode and cperl-mode is in use, a warning will be issued
-;; about the variable. Autoload this here, so that no warning is
+;; about the variable. Autoload these here, so that no warning is
 ;; issued when using either perl-mode or cperl-mode.
 ;;;###autoload(put 'perl-indent-level 'safe-local-variable 'integerp)
+;;;###autoload(put 'perl-continued-statement-offset 'safe-local-variable 'integerp)
+;;;###autoload(put 'perl-continued-brace-offset 'safe-local-variable 'integerp)
+;;;###autoload(put 'perl-brace-offset 'safe-local-variable 'integerp)
+;;;###autoload(put 'perl-brace-imaginary-offset 'safe-local-variable 'integerp)
+;;;###autoload(put 'perl-label-offset 'safe-local-variable 'integerp)
 
 (defcustom perl-continued-statement-offset 4
   "*Extra indent for lines not starting new statements."