]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/cperl-mode.el
(cperl-compilation-error-regexp-alist): Remove duplicate defvar
[gnu-emacs] / lisp / progmodes / cperl-mode.el
index 26bbb8f3fafe88fe1200578a56b2e62694db6d9c..3badfed5d4f0d9cd1bd5a6edc518402a505e33c2 100644 (file)
@@ -1,7 +1,7 @@
 ;;; cperl-mode.el --- Perl code editing commands for Emacs
 
 ;; Copyright (C) 1985, 1986, 1987, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
-;; 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+;; 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
 ;;     Free Software Foundation, Inc.
 
 ;; Author: Ilya Zakharevich and Bob Olson
@@ -12,7 +12,7 @@
 
 ;; 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 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
@@ -233,6 +233,7 @@ for constructs with multiline if/unless/while/until/for/foreach condition."
   "*Indentation of CPerl statements with respect to containing block."
   :type 'integer
   :group 'cperl-indentation-details)
+(put 'cperl-indent-level 'safe-local-variable 'integerp)
 
 (defcustom cperl-lineup-step nil
   "*`cperl-lineup' will always lineup at multiple of this number.
@@ -352,7 +353,15 @@ Can be overwritten by `cperl-hairy' if nil."
 
 (defcustom cperl-electric-keywords nil
   "*Not-nil (and non-null) means keywords are electric in CPerl.
-Can be overwritten by `cperl-hairy' if nil."
+Can be overwritten by `cperl-hairy' if nil.
+
+Uses `abbrev-mode' to do the expansion.  If you want to use your
+own abbrevs in cperl-mode, but do not want keywords to be
+electric, you must redefine `cperl-mode-abbrev-table': do
+\\[edit-abbrevs], search for `cperl-mode-abbrev-table', and, in
+that paragraph, delete the words that appear at the ends of lines and
+that begin with \"cperl-electric\".
+"
   :type '(choice (const null) boolean)
   :group 'cperl-affected-by-hairy)
 
@@ -1488,9 +1497,16 @@ the last)."
 (defvar cperl-use-major-mode 'cperl-mode)
 (defvar cperl-font-lock-multiline-start nil)
 (defvar cperl-font-lock-multiline nil)
-(defvar cperl-compilation-error-regexp-alist nil)
 (defvar cperl-font-locking nil)
 
+;; NB as it stands the code in cperl-mode assumes this only has one
+;; element. If Xemacs 19 support were dropped, this could all be simplified.
+(defvar cperl-compilation-error-regexp-alist
+  ;; This look like a paranoiac regexp: could anybody find a better one? (which WORKS).
+  '(("^[^\n]* \\(file\\|at\\) \\([^ \t\n]+\\) [^\n]*line \\([0-9]+\\)[\\., \n]"
+     2 3))
+  "Alist that specifies how to match errors in perl output.")
+
 ;;;###autoload
 (defun cperl-mode ()
   "Major mode for editing Perl code.
@@ -1681,9 +1697,8 @@ or as help on variables `cperl-tips', `cperl-problems',
                          [(control c) (control h) f])))
   (setq major-mode cperl-use-major-mode)
   (setq mode-name "CPerl")
-  (if (not cperl-mode-abbrev-table)
-      (let ((prev-a-c abbrevs-changed))
-       (define-abbrev-table 'cperl-mode-abbrev-table '(
+  (let ((prev-a-c abbrevs-changed))
+    (define-abbrev-table 'cperl-mode-abbrev-table '(
                ("if" "if" cperl-electric-keyword 0)
                ("elsif" "elsif" cperl-electric-keyword 0)
                ("while" "while" cperl-electric-keyword 0)
@@ -1704,7 +1719,7 @@ or as help on variables `cperl-tips', `cperl-problems',
                ("over" "over" cperl-electric-pod 0)
                ("head1" "head1" cperl-electric-pod 0)
                ("head2" "head2" cperl-electric-pod 0)))
-       (setq abbrevs-changed prev-a-c)))
+       (setq abbrevs-changed prev-a-c))
   (setq local-abbrev-table cperl-mode-abbrev-table)
   (if (cperl-val 'cperl-electric-keywords)
       (abbrev-mode 1))
@@ -1778,17 +1793,18 @@ or as help on variables `cperl-tips', `cperl-problems',
   (cond ((boundp 'compilation-error-regexp-alist-alist);; xemacs 20.x
         (make-local-variable 'compilation-error-regexp-alist-alist)
         (set 'compilation-error-regexp-alist-alist
-             (cons (cons 'cperl cperl-compilation-error-regexp-alist)
+             (cons (cons 'cperl (car cperl-compilation-error-regexp-alist))
                    (symbol-value 'compilation-error-regexp-alist-alist)))
          (if (fboundp 'compilation-build-compilation-error-regexp-alist)
              (let ((f 'compilation-build-compilation-error-regexp-alist))
                (funcall f))
+           (make-local-variable 'compilation-error-regexp-alist)
            (push 'cperl compilation-error-regexp-alist)))
        ((boundp 'compilation-error-regexp-alist);; xmeacs 19.x
         (make-local-variable 'compilation-error-regexp-alist)
         (set 'compilation-error-regexp-alist
-              (cons cperl-compilation-error-regexp-alist
-                    (symbol-value 'compilation-error-regexp-alist)))))
+              (append cperl-compilation-error-regexp-alist
+                      (symbol-value 'compilation-error-regexp-alist)))))
   (make-local-variable 'font-lock-defaults)
   (setq        font-lock-defaults
        (cond
@@ -1863,9 +1879,7 @@ or as help on variables `cperl-tips', `cperl-problems',
       (easy-menu-add cperl-menu))      ; A NOP in Emacs.
   (run-mode-hooks 'cperl-mode-hook)
   (if cperl-hook-after-change
-      (progn
-       (make-local-hook 'after-change-functions)
-       (add-hook 'after-change-functions 'cperl-after-change-function nil t)))
+      (add-hook 'after-change-functions 'cperl-after-change-function nil t))
   ;; After hooks since fontification will break this
   (if cperl-pod-here-scan
       (or cperl-syntaxify-by-font-lock
@@ -5695,13 +5709,6 @@ indentation and initial hashes.  Behaves usually outside of comment."
        (t 5)))                         ; should not happen
 
 \f
-(defvar cperl-compilation-error-regexp-alist
-  ;; This look like a paranoiac regexp: could anybody find a better one? (which WORKS).
-  '(("^[^\n]* \\(file\\|at\\) \\([^ \t\n]+\\) [^\n]*line \\([0-9]+\\)[\\., \n]"
-     2 3))
-  "Alist that specifies how to match errors in perl output.")
-
-
 (defun cperl-windowed-init ()
   "Initialization under windowed version."
   (cond ((featurep 'ps-print)