]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/cperl-mode.el
(cperl-mode): Don't precompile the font-lock-fontify-syntactic-keywords.
[gnu-emacs] / lisp / progmodes / cperl-mode.el
index c6721524a51eb25ca4bf35b18af75bb0fb015846..4a701edcca2e615933195c58f954bfc2f58693e1 100644 (file)
@@ -1,6 +1,6 @@
 ;;; cperl-mode.el --- Perl code editing commands for Emacs
 
-;; Copyright (C) 1985, 86, 87, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2003
+;; Copyright (C) 1985,86,87,91,92,93,94,95,96,97,98,99,2000,03,2004,2005
 ;;     Free Software Foundation, Inc.
 
 ;; Author: Ilya Zakharevich and Bob Olson
@@ -38,7 +38,7 @@
 
 ;; DO NOT FORGET to read micro-docs (available from `Perl' menu)   <<<<<<
 ;; or as help on variables `cperl-tips', `cperl-problems',         <<<<<<
-;; `cperl-praise', `cperl-speed'.                                  <<<<<<
+;; `cperl-praise', `cperl-speed'.                                 <<<<<<
 
 ;; The mode information (on C-h m) provides some customization help.
 ;; If you use font-lock feature of this mode, it is advisable to use
@@ -584,7 +584,7 @@ when syntaxifying a chunk of buffer."
     (((class color) (background dark))
      (:foreground ,cperl-dark-foreground))
     (t (:weight bold :underline t)))
-  "Font Lock mode face used to highlight array names."
+  "Font Lock mode face used non-overridable keywords and modifiers of regexps."
   :group 'cperl-faces)
 
 (defface cperl-array-face
@@ -713,7 +713,7 @@ should work if the balance of delimiters is not broken by POD).
 
 The main trick (to make $ a \"backslash\") makes constructions like
 ${aaa} look like unbalanced braces.  The only trick I can think of is
-to insert it as $ {aaa} (legal in perl5, not in perl4).
+to insert it as $ {aaa} (valid in perl5, not in perl4).
 
 Similar problems arise in regexps, when /(\\s|$)/ should be rewritten
 as /($|\\s)/.  Note that such a transposition is not always possible.
@@ -926,12 +926,9 @@ the faces: please specify bold, italic, underline, shadow and box.)
 (defun cperl-putback-char (c)          ; Emacs 19
   (set 'unread-command-events (list c))) ; Avoid undefined warning
 
-(if (boundp 'unread-command-events)
-    (if cperl-xemacs-p
-       (defun cperl-putback-char (c)   ; XEmacs >= 19.12
-         (setq unread-command-events (list (eval '(character-to-event c))))))
-  (defun cperl-putback-char (c)                ; XEmacs <= 19.11
-    (set 'unread-command-event (eval '(character-to-event c))))) ; Avoid warnings
+(if cperl-xemacs-p
+    (defun cperl-putback-char (c)      ; XEmacs >= 19.12
+      (setq unread-command-events (list (eval '(character-to-event c))))))
 
 (or (fboundp 'uncomment-region)
     (defun uncomment-region (beg end)
@@ -1063,9 +1060,6 @@ the faces: please specify bold, italic, underline, shadow and box.)
     (substitute-key-definition
      'indent-sexp 'cperl-indent-exp
      cperl-mode-map global-map)
-    (substitute-key-definition
-     'fill-paragraph 'cperl-fill-paragraph
-     cperl-mode-map global-map)
     (substitute-key-definition
      'indent-region 'cperl-indent-region
      cperl-mode-map global-map)
@@ -1086,7 +1080,7 @@ the faces: please specify bold, italic, underline, shadow and box.)
          ["End of function" end-of-defun t]
          ["Mark function" mark-defun t]
          ["Indent expression" cperl-indent-exp t]
-         ["Fill paragraph/comment" cperl-fill-paragraph t]
+         ["Fill paragraph/comment" fill-paragraph t]
          "----"
          ["Line up a construction" cperl-lineup (cperl-use-region-p)]
          ["Invert if/unless/while etc" cperl-invert-if-unless t]
@@ -1146,7 +1140,7 @@ the faces: please specify bold, italic, underline, shadow and box.)
           ["Add tags for Perl files in (sub)directories"
            (cperl-write-tags nil nil t t) t]))
         ("Perl docs"
-         ["Define word at point" imenu-go-find-at-position 
+         ["Define word at point" imenu-go-find-at-position
           (fboundp 'imenu-go-find-at-position)]
          ["Help on function" cperl-info-on-command t]
          ["Help on function at point" cperl-info-on-current-command t]
@@ -1154,7 +1148,7 @@ the faces: please specify bold, italic, underline, shadow and box.)
          ["Perldoc" cperl-perldoc t]
          ["Perldoc on word at point" cperl-perldoc-at-point t]
          ["View manpage of POD in this file" cperl-build-manpage t]
-         ["Auto-help on" cperl-lazy-install 
+         ["Auto-help on" cperl-lazy-install
           (and (fboundp 'run-with-idle-timer)
                (not cperl-lazy-installed))]
          ["Auto-help off" cperl-lazy-unstall
@@ -1166,7 +1160,7 @@ the faces: please specify bold, italic, underline, shadow and box.)
          ["Electric keywords" cperl-toggle-abbrev t]
          ["Fix whitespace on indent" cperl-toggle-construct-fix t]
          ["Auto-help on Perl constructs" cperl-toggle-autohelp t]
-         ["Auto fill" auto-fill-mode t]) 
+         ["Auto fill" auto-fill-mode t])
         ("Indent styles..."
          ["CPerl" (cperl-set-style "CPerl") t]
          ["PerlStyle" (cperl-set-style "PerlStyle") t]
@@ -1464,10 +1458,11 @@ or as help on variables `cperl-tips', `cperl-problems',
   (setq paragraph-separate paragraph-start)
   (make-local-variable 'paragraph-ignore-fill-prefix)
   (setq paragraph-ignore-fill-prefix t)
+  (set (make-local-variable 'fill-paragraph-function) 'cperl-fill-paragraph)
   (make-local-variable 'indent-line-function)
   (setq indent-line-function 'cperl-indent-line)
   (make-local-variable 'require-final-newline)
-  (setq require-final-newline t)
+  (setq require-final-newline mode-require-final-newline)
   (make-local-variable 'comment-start)
   (setq comment-start "# ")
   (make-local-variable 'comment-end)
@@ -1477,7 +1472,7 @@ or as help on variables `cperl-tips', `cperl-problems',
   (make-local-variable 'comment-start-skip)
   (setq comment-start-skip "#+ *")
   (make-local-variable 'defun-prompt-regexp)
-  (setq defun-prompt-regexp "^[ \t]*sub[ \t]+\\([^ \t\n{(;]+\\)\\([ \t]*([^()]*)[ \t]*\\)?[ \t]*")
+  (setq defun-prompt-regexp "^[ \t]*sub[ \t\n]+\\([^ \t\n{(;]+\\)\\([ \t\n]*([^()]*)[ \t\n]*\\)?[ \t\n]*)")
   (make-local-variable 'comment-indent-function)
   (setq comment-indent-function 'cperl-comment-indent)
   (make-local-variable 'parse-sexp-ignore-comments)
@@ -1519,14 +1514,14 @@ or as help on variables `cperl-tips', `cperl-problems',
        (set 'font-lock-unfontify-region-function ; not present with old Emacs
              'cperl-font-lock-unfontify-region-function)
        (make-local-variable 'cperl-syntax-done-to)
-       ;; Another bug: unless font-lock-syntactic-keywords, font-lock
-       ;;  ignores syntax-table text-property.  (t) is a hack
-       ;;  to make font-lock think that font-lock-syntactic-keywords
-       ;;  are defined
        (make-local-variable 'font-lock-syntactic-keywords)
        (setq font-lock-syntactic-keywords
              (if cperl-syntaxify-by-font-lock
-                 '(t (cperl-fontify-syntaxically))
+                 '((cperl-fontify-syntaxically))
+                ;; unless font-lock-syntactic-keywords, font-lock (pre-22.1)
+                ;;  used to ignore syntax-table text-properties.  (t) is a hack
+                ;;  to make font-lock think that font-lock-syntactic-keywords
+                ;;  are defined.
                '(t)))))
   (make-local-variable 'cperl-old-style)
   (if (boundp 'normal-auto-fill-function) ; 19.33 and later
@@ -1549,7 +1544,7 @@ or as help on variables `cperl-tips', `cperl-problems',
        (cperl-msb-fix))
   (if (featurep 'easymenu)
       (easy-menu-add cperl-menu))      ; A NOP in Emacs.
-  (run-hooks 'cperl-mode-hook)
+  (run-mode-hooks 'cperl-mode-hook)
   ;; After hooks since fontification will break this
   (if cperl-pod-here-scan
       (or cperl-syntaxify-by-font-lock
@@ -2695,168 +2690,168 @@ and closing parentheses and brackets."
                                 (cperl-calculate-indent))
                             (current-indentation))))))))))))))
 
-(defvar cperl-indent-alist
-  '((string nil)
-    (comment nil)
-    (toplevel 0)
-    (toplevel-after-parenth 2)
-    (toplevel-continued 2)
-    (expression 1))
-  "Alist of indentation rules for CPerl mode.
-The values mean:
-  nil: do not indent;
-  number: add this amount of indentation.
-
-Not finished, not used.")
-
-(defun cperl-where-am-i (&optional parse-start start-state)
-  ;; Unfinished
-  "Return a list of lists ((TYPE POS)...) of good points before the point.
-POS may be nil if it is hard to find, say, when TYPE is `string' or `comment'.
-
-Not finished, not used."
-  (save-excursion
-    (let* ((start-point (point))
-          (s-s (cperl-get-state))
-          (start (nth 0 s-s))
-          (state (nth 1 s-s))
-          (prestart (nth 3 s-s))
-          (containing-sexp (car (cdr state)))
-          (case-fold-search nil)
-          (res (list (list 'parse-start start) (list 'parse-prestart prestart))))
-      (cond ((nth 3 state)             ; In string
-            (setq res (cons (list 'string nil (nth 3 state)) res))) ; What started string
-           ((nth 4 state)              ; In comment
-            (setq res (cons '(comment) res)))
-           ((null containing-sexp)
-            ;; Line is at top level.
-            ;; Indent like the previous top level line
-            ;; unless that ends in a closeparen without semicolon,
-            ;; in which case this line is the first argument decl.
-            (cperl-backward-to-noncomment (or parse-start (point-min)))
-            ;;(skip-chars-backward " \t\f\n")
-            (cond
-             ((or (bobp)
-                  (memq (preceding-char) (append ";}" nil)))
-              (setq res (cons (list 'toplevel start) res)))
-             ((eq (preceding-char) ?\) )
-              (setq res (cons (list 'toplevel-after-parenth start) res)))
-             (t
-              (setq res (cons (list 'toplevel-continued start) res)))))
-           ((/= (char-after containing-sexp) ?{)
-            ;; line is expression, not statement:
-            ;; indent to just after the surrounding open.
-            ;; skip blanks if we do not close the expression.
-            (setq res (cons (list 'expression-blanks
-                                  (progn
-                                    (goto-char (1+ containing-sexp))
-                                    (or (looking-at "[ \t]*\\(#\\|$\\)")
-                                        (skip-chars-forward " \t"))
-                                    (point)))
-                            (cons (list 'expression containing-sexp) res))))
-           ((progn
-              ;; Containing-expr starts with \{.  Check whether it is a hash.
-              (goto-char containing-sexp)
-              (not (cperl-block-p)))
-            (setq res (cons (list 'expression-blanks
-                                  (progn
-                                    (goto-char (1+ containing-sexp))
-                                    (or (looking-at "[ \t]*\\(#\\|$\\)")
-                                        (skip-chars-forward " \t"))
-                                    (point)))
-                            (cons (list 'expression containing-sexp) res))))
-           (t
-            ;; Statement level.
-            (setq res (cons (list 'in-block containing-sexp) res))
-            ;; Is it a continuation or a new statement?
-            ;; Find previous non-comment character.
-            (cperl-backward-to-noncomment containing-sexp)
-            ;; Back up over label lines, since they don't
-            ;; affect whether our line is a continuation.
-            ;; Back up comma-delimited lines too ?????
-            (while (or (eq (preceding-char) ?\,)
-                       (save-excursion (cperl-after-label)))
-              (if (eq (preceding-char) ?\,)
-                  ;; Will go to beginning of line, essentially
-                  ;; Will ignore embedded sexpr XXXX.
-                  (cperl-backward-to-start-of-continued-exp containing-sexp))
-              (beginning-of-line)
-              (cperl-backward-to-noncomment containing-sexp))
-            ;; Now we get the answer.
-            (if (not (memq (preceding-char) (append ";}{" '(nil)))) ; Was ?\,
-                ;; This line is continuation of preceding line's statement.
-                (list (list 'statement-continued containing-sexp))
-              ;; This line starts a new statement.
-              ;; Position following last unclosed open.
-              (goto-char containing-sexp)
-              ;; Is line first statement after an open-brace?
-              (or
-               ;; If no, find that first statement and indent like
-               ;; it.  If the first statement begins with label, do
-               ;; not believe when the indentation of the label is too
-               ;; small.
-               (save-excursion
-                 (forward-char 1)
-                 (let ((colon-line-end 0))
-                   (while (progn (skip-chars-forward " \t\n" start-point)
-                                 (and (< (point) start-point)
-                                      (looking-at
-                                       "#\\|[a-zA-Z_][a-zA-Z0-9_]*:[^:]")))
-                     ;; Skip over comments and labels following openbrace.
-                     (cond ((= (following-char) ?\#)
-                            ;;(forward-line 1)
-                            (end-of-line))
-                           ;; label:
-                           (t
-                            (save-excursion (end-of-line)
-                                            (setq colon-line-end (point)))
-                            (search-forward ":"))))
-                   ;; Now at the point, after label, or at start
-                   ;; of first statement in the block.
-                   (and (< (point) start-point)
-                        (if (> colon-line-end (point))
-                            ;; Before statement after label
-                            (if (> (current-indentation)
-                                   cperl-min-label-indent)
-                                (list (list 'label-in-block (point)))
-                              ;; Do not believe: `max' is involved
-                              (list
-                               (list 'label-in-block-min-indent (point))))
-                          ;; Before statement
-                          (list 'statement-in-block (point))))))
-               ;; If no previous statement,
-               ;; indent it relative to line brace is on.
-               ;; For open brace in column zero, don't let statement
-               ;; start there too.  If cperl-indent-level is zero,
-               ;; use cperl-brace-offset + cperl-continued-statement-offset instead.
-               ;; For open-braces not the first thing in a line,
-               ;; add in cperl-brace-imaginary-offset.
-
-               ;; If first thing on a line:  ?????
-               (+ (if (and (bolp) (zerop cperl-indent-level))
-                      (+ cperl-brace-offset cperl-continued-statement-offset)
-                    cperl-indent-level)
-                  ;; Move back over whitespace before the openbrace.
-                  ;; If openbrace is not first nonwhite thing on the line,
-                  ;; add the cperl-brace-imaginary-offset.
-                  (progn (skip-chars-backward " \t")
-                         (if (bolp) 0 cperl-brace-imaginary-offset))
-                  ;; If the openbrace is preceded by a parenthesized exp,
-                  ;; move to the beginning of that;
-                  ;; possibly a different line
-                  (progn
-                    (if (eq (preceding-char) ?\))
-                        (forward-sexp -1))
-                    ;; Get initial indentation of the line we are on.
-                    ;; If line starts with label, calculate label indentation
-                    (if (save-excursion
-                          (beginning-of-line)
-                          (looking-at "[ \t]*[a-zA-Z_][a-zA-Z_0-9]*:[^:]"))
-                        (if (> (current-indentation) cperl-min-label-indent)
-                            (- (current-indentation) cperl-label-offset)
-                          (cperl-calculate-indent))
-                      (current-indentation))))))))
-      res)))
+;; (defvar cperl-indent-alist
+;;   '((string nil)
+;;     (comment nil)
+;;     (toplevel 0)
+;;     (toplevel-after-parenth 2)
+;;     (toplevel-continued 2)
+;;     (expression 1))
+;;   "Alist of indentation rules for CPerl mode.
+;; The values mean:
+;;   nil: do not indent;
+;;   number: add this amount of indentation.
+
+;; Not finished, not used.")
+
+;; (defun cperl-where-am-i (&optional parse-start start-state)
+;;   ;; Unfinished
+;;   "Return a list of lists ((TYPE POS)...) of good points before the point.
+;; ;; POS may be nil if it is hard to find, say, when TYPE is `string' or `comment'.
+
+;; ;; Not finished, not used."
+;;   (save-excursion
+;;     (let* ((start-point (point))
+;;        (s-s (cperl-get-state))
+;;        (start (nth 0 s-s))
+;;        (state (nth 1 s-s))
+;;        (prestart (nth 3 s-s))
+;;        (containing-sexp (car (cdr state)))
+;;        (case-fold-search nil)
+;;        (res (list (list 'parse-start start) (list 'parse-prestart prestart))))
+;;       (cond ((nth 3 state)          ; In string
+;;          (setq res (cons (list 'string nil (nth 3 state)) res))) ; What started string
+;;         ((nth 4 state)              ; In comment
+;;          (setq res (cons '(comment) res)))
+;;         ((null containing-sexp)
+;;          ;; Line is at top level.
+;;          ;; Indent like the previous top level line
+;;          ;; unless that ends in a closeparen without semicolon,
+;;          ;; in which case this line is the first argument decl.
+;;          (cperl-backward-to-noncomment (or parse-start (point-min)))
+;;          ;;(skip-chars-backward " \t\f\n")
+;;          (cond
+;;           ((or (bobp)
+;;                (memq (preceding-char) (append ";}" nil)))
+;;            (setq res (cons (list 'toplevel start) res)))
+;;           ((eq (preceding-char) ?\) )
+;;            (setq res (cons (list 'toplevel-after-parenth start) res)))
+;;           (t
+;;            (setq res (cons (list 'toplevel-continued start) res)))))
+;;         ((/= (char-after containing-sexp) ?{)
+;;          ;; line is expression, not statement:
+;;          ;; indent to just after the surrounding open.
+;;          ;; skip blanks if we do not close the expression.
+;;          (setq res (cons (list 'expression-blanks
+;;                                (progn
+;;                                  (goto-char (1+ containing-sexp))
+;;                                  (or (looking-at "[ \t]*\\(#\\|$\\)")
+;;                                      (skip-chars-forward " \t"))
+;;                                  (point)))
+;;                          (cons (list 'expression containing-sexp) res))))
+;;         ((progn
+;;            ;; Containing-expr starts with \{.  Check whether it is a hash.
+;;            (goto-char containing-sexp)
+;;            (not (cperl-block-p)))
+;;          (setq res (cons (list 'expression-blanks
+;;                                (progn
+;;                                  (goto-char (1+ containing-sexp))
+;;                                  (or (looking-at "[ \t]*\\(#\\|$\\)")
+;;                                      (skip-chars-forward " \t"))
+;;                                  (point)))
+;;                          (cons (list 'expression containing-sexp) res))))
+;;         (t
+;;          ;; Statement level.
+;;          (setq res (cons (list 'in-block containing-sexp) res))
+;;          ;; Is it a continuation or a new statement?
+;;          ;; Find previous non-comment character.
+;;          (cperl-backward-to-noncomment containing-sexp)
+;;          ;; Back up over label lines, since they don't
+;;          ;; affect whether our line is a continuation.
+;;          ;; Back up comma-delimited lines too ?????
+;;          (while (or (eq (preceding-char) ?\,)
+;;                     (save-excursion (cperl-after-label)))
+;;            (if (eq (preceding-char) ?\,)
+;;                ;; Will go to beginning of line, essentially
+;;                ;; Will ignore embedded sexpr XXXX.
+;;                (cperl-backward-to-start-of-continued-exp containing-sexp))
+;;            (beginning-of-line)
+;;            (cperl-backward-to-noncomment containing-sexp))
+;;          ;; Now we get the answer.
+;;          (if (not (memq (preceding-char) (append ";}{" '(nil)))) ; Was ?\,
+;;              ;; This line is continuation of preceding line's statement.
+;;              (list (list 'statement-continued containing-sexp))
+;;            ;; This line starts a new statement.
+;;            ;; Position following last unclosed open.
+;;            (goto-char containing-sexp)
+;;            ;; Is line first statement after an open-brace?
+;;            (or
+;;             ;; If no, find that first statement and indent like
+;;             ;; it.  If the first statement begins with label, do
+;;             ;; not believe when the indentation of the label is too
+;;             ;; small.
+;;             (save-excursion
+;;               (forward-char 1)
+;;               (let ((colon-line-end 0))
+;;                 (while (progn (skip-chars-forward " \t\n" start-point)
+;;                               (and (< (point) start-point)
+;;                                    (looking-at
+;;                                     "#\\|[a-zA-Z_][a-zA-Z0-9_]*:[^:]")))
+;;                   ;; Skip over comments and labels following openbrace.
+;;                   (cond ((= (following-char) ?\#)
+;;                          ;;(forward-line 1)
+;;                          (end-of-line))
+;;                         ;; label:
+;;                         (t
+;;                          (save-excursion (end-of-line)
+;;                                          (setq colon-line-end (point)))
+;;                          (search-forward ":"))))
+;;                 ;; Now at the point, after label, or at start
+;;                 ;; of first statement in the block.
+;;                 (and (< (point) start-point)
+;;                      (if (> colon-line-end (point))
+;;                          ;; Before statement after label
+;;                          (if (> (current-indentation)
+;;                                 cperl-min-label-indent)
+;;                              (list (list 'label-in-block (point)))
+;;                            ;; Do not believe: `max' is involved
+;;                            (list
+;;                             (list 'label-in-block-min-indent (point))))
+;;                        ;; Before statement
+;;                        (list 'statement-in-block (point))))))
+;;             ;; If no previous statement,
+;;             ;; indent it relative to line brace is on.
+;;             ;; For open brace in column zero, don't let statement
+;;             ;; start there too.  If cperl-indent-level is zero,
+;;             ;; use cperl-brace-offset + cperl-continued-statement-offset instead.
+;;             ;; For open-braces not the first thing in a line,
+;;             ;; add in cperl-brace-imaginary-offset.
+
+;;             ;; If first thing on a line:  ?????
+;;             (+ (if (and (bolp) (zerop cperl-indent-level))
+;;                    (+ cperl-brace-offset cperl-continued-statement-offset)
+;;                  cperl-indent-level)
+;;                ;; Move back over whitespace before the openbrace.
+;;                ;; If openbrace is not first nonwhite thing on the line,
+;;                ;; add the cperl-brace-imaginary-offset.
+;;                (progn (skip-chars-backward " \t")
+;;                       (if (bolp) 0 cperl-brace-imaginary-offset))
+;;                ;; If the openbrace is preceded by a parenthesized exp,
+;;                ;; move to the beginning of that;
+;;                ;; possibly a different line
+;;                (progn
+;;                  (if (eq (preceding-char) ?\))
+;;                      (forward-sexp -1))
+;;                  ;; Get initial indentation of the line we are on.
+;;                  ;; If line starts with label, calculate label indentation
+;;                  (if (save-excursion
+;;                        (beginning-of-line)
+;;                        (looking-at "[ \t]*[a-zA-Z_][a-zA-Z_0-9]*:[^:]"))
+;;                      (if (> (current-indentation) cperl-min-label-indent)
+;;                          (- (current-indentation) cperl-label-offset)
+;;                        (cperl-calculate-indent))
+;;                    (current-indentation))))))))
+;;       res)))
 
 (defun cperl-calculate-indent-within-comment ()
   "Return the indentation amount for line, assuming that
@@ -2912,7 +2907,7 @@ Returns true if comment is found."
                    (goto-char (1- cpoint)))))
              (setq stop-in t)          ; Finish
              (forward-char -1))
-         (setq stop-in t)))            ; Finish 
+         (setq stop-in t)))            ; Finish
       (nth 4 state))))
 
 (defsubst cperl-1- (p)
@@ -3570,7 +3565,7 @@ the sections using `cperl-pod-head-face', `cperl-pod-face',
                            ((and (eq (following-char) ?:)
                                  (eq b1 ?\{) ; Check for $ { s::bar }
                                  (looking-at "::[a-zA-Z0-9_:]*[ \t\n\f]*}")
-                                 (progn 
+                                 (progn
                                    (goto-char (1- go))
                                    (skip-chars-backward " \t\n\f")
                                    (memq (preceding-char)
@@ -4185,7 +4180,7 @@ conditional/loop constructs."
       (let ((indent-info (if cperl-emacs-can-parse
                             (list nil nil nil) ; Cannot use '(), since will modify
                           nil))
-           (pm 0) (imenu-scanning-message "Indenting... (%3d%%)")
+           (pm 0)
            after-change-functions      ; Speed it up!
            st comm old-comm-indent new-comm-indent p pp i empty)
        (if h-a-c (add-hook 'after-change-functions 'cperl-delay-update-hook))
@@ -4196,12 +4191,7 @@ conditional/loop constructs."
        (goto-char start)
        (setq end (set-marker (make-marker) end)) ; indentation changes pos
        (or (bolp) (beginning-of-line 2))
-       (or (fboundp 'imenu-progress-message)
-           (message "Indenting... For feedback load `imenu'..."))
        (while (and (<= (point) end) (not (eobp))) ; bol to check start
-         (and (fboundp 'imenu-progress-message)
-              (imenu-progress-message
-               pm (/ (* 100 (- (point) start)) (- end start -1))))
          (setq st (point))
          (if (or
               (setq empty (looking-at "[ \t]*\n"))
@@ -4237,10 +4227,7 @@ conditional/loop constructs."
                             (skip-chars-backward " \t")
                             (skip-chars-backward "#")
                             (setq new-comm-indent (current-column))))))))
-       (beginning-of-line 2))
-       (if (fboundp 'imenu-progress-message)
-            (imenu-progress-message pm 100)
-         (message nil)))
+       (beginning-of-line 2)))
       ;; Now run the update hooks
       (and after-change-functions
           cperl-update-end
@@ -4255,11 +4242,11 @@ conditional/loop constructs."
 ;; Stolen from lisp-mode with a lot of improvements
 
 (defun cperl-fill-paragraph (&optional justify iteration)
-  "Like \\[fill-paragraph], but handle CPerl comments.
+  "Like `fill-paragraph', but handle CPerl comments.
 If any of the current line is a comment, fill the comment or the
 block of it that point is in, preserving the comment's initial
 indentation and initial hashes.  Behaves usually outside of comment."
-  (interactive "P")
+  ;; (interactive "P") ; Only works when called from fill-paragraph.  -stef
   (let (;; Non-nil if the current line contains a comment.
        has-comment
 
@@ -4315,11 +4302,12 @@ indentation and initial hashes.  Behaves usually outside of comment."
                         (looking-at "^[ \t]*#+[ \t]*[^ \t\n#]")))
           (point)))
        ;; Remove existing hashes
-       (goto-char (point-min))
-       (while (progn (forward-line 1) (< (point) (point-max)))
-         (skip-chars-forward " \t")
-         (and (looking-at "#+")
-              (delete-char (- (match-end 0) (match-beginning 0)))))
+       (save-excursion
+         (goto-char (point-min))
+         (while (progn (forward-line 1) (< (point) (point-max)))
+           (skip-chars-forward " \t")
+           (and (looking-at "#+")
+                (delete-char (- (match-end 0) (match-beginning 0))))))
 
        ;; Lines with only hashes on them can be paragraph boundaries.
        (let ((paragraph-start (concat paragraph-start "\\|^[ \t#]*$"))
@@ -4346,9 +4334,11 @@ indentation and initial hashes.  Behaves usually outside of comment."
       (let ((c (save-excursion (beginning-of-line)
                               (cperl-to-comment-or-eol) (point)))
            (s (memq (following-char) '(?\ ?\t))) marker)
-       (if (>= c (point)) nil
+       (if (>= c (point))
+           ;; Don't break line inside code: only inside comment.
+           nil
          (setq marker (point-marker))
-         (cperl-fill-paragraph)
+         (fill-paragraph nil)
          (goto-char marker)
          ;; Is not enough, sometimes marker is a start of line
          (if (bolp) (progn (re-search-forward "#+[ \t]*")
@@ -4387,17 +4377,12 @@ indentation and initial hashes.  Behaves usually outside of comment."
        packages ends-ranges p marker
        (prev-pos 0) char fchar index index1 name (end-range 0) package)
     (goto-char (point-min))
-    (if noninteractive
-       (message "Scanning Perl for index")
-      (imenu-progress-message prev-pos 0))
     (cperl-update-syntaxification (point-max) (point-max))
     ;; Search for the function
     (progn ;;save-match-data
       (while (re-search-forward
              (or regexp cperl-imenu--function-name-regexp-perl)
              nil t)
-       (or noninteractive
-           (imenu-progress-message prev-pos))
        (cond
         ((and                          ; Skip some noise if building tags
           (match-beginning 2)          ; package or sub
@@ -4467,8 +4452,6 @@ indentation and initial hashes.  Behaves usually outside of comment."
          (setq index1 (cons (concat "=" name) (cdr index)))
          (push index index-pod-alist)
          (push index1 index-unsorted-alist)))))
-    (or noninteractive
-       (imenu-progress-message prev-pos 100))
     (setq index-alist
          (if (default-value 'imenu-sort-function)
              (sort index-alist (default-value 'imenu-sort-function))
@@ -4882,7 +4865,7 @@ indentation and initial hashes.  Behaves usually outside of comment."
          (defvar cperl-guessed-background nil
            "Display characteristics as guessed by cperl.")
          ;;      (or (fboundp 'x-color-defined-p)
-         ;;          (defalias 'x-color-defined-p 
+         ;;          (defalias 'x-color-defined-p
          ;;            (cond ((fboundp 'color-defined-p) 'color-defined-p)
          ;;                  ;; XEmacs >= 19.12
          ;;                  ((fboundp 'valid-color-name-p) 'valid-color-name-p)
@@ -5198,7 +5181,7 @@ data already), may be restored by `cperl-set-style-back'.
 Chosing \"Current\" style will not change style, so this may be used for
 side-effect of memorizing only."
   (interactive
-   (let ((list (mapcar (function (lambda (elt) (list (car elt)))) 
+   (let ((list (mapcar (function (lambda (elt) (list (car elt))))
                       cperl-style-alist)))
      (list (completing-read "Enter style: " list nil 'insist))))
   (or cperl-old-style
@@ -5294,7 +5277,7 @@ Customized by setting variables `cperl-shrink-wrap-info-frame',
          iniwin (selected-window)
          fr1 (window-frame iniwin))
     (set-buffer buf)
-    (beginning-of-buffer)
+    (goto-char (point-min))
     (or isvar
        (progn (re-search-forward "^-X[ \t\n]")
               (forward-line -1)))
@@ -5403,7 +5386,7 @@ partially contained in the region are lined up at the same column.
 MINSHIFT is the minimal amount of space to insert before the construction.
 STEP is the tabwidth to position constructions.
 If STEP is nil, `cperl-lineup-step' will be used
-\(or `cperl-indent-level', if `cperl-lineup-step' is `nil').
+\(or `cperl-indent-level', if `cperl-lineup-step' is nil).
 Will not move the position at the start to the left."
   (interactive "r")
   (let (search col tcol seen b e)
@@ -5551,16 +5534,11 @@ Delay of auto-help controlled by `cperl-lazy-help-time'."
   (let ((index-alist '())
        (prev-pos 0) index index1 name package prefix)
     (goto-char (point-min))
-    (if noninteractive
-       (message "Scanning XSUB for index")
-      (imenu-progress-message prev-pos 0))
     ;; Search for the function
     (progn ;;save-match-data
       (while (re-search-forward
              "^\\([ \t]*MODULE\\>[^\n]*\\<PACKAGE[ \t]*=[ \t]*\\([a-zA-Z_][a-zA-Z_0-9:]*\\)\\>\\|\\([a-zA-Z_][a-zA-Z_0-9]*\\)(\\|[ \t]*BOOT:\\)"
              nil t)
-       (or noninteractive
-           (imenu-progress-message prev-pos))
        (cond
         ((match-beginning 2)           ; SECTION
          (setq package (buffer-substring (match-beginning 2) (match-end 2)))
@@ -5588,8 +5566,6 @@ Delay of auto-help controlled by `cperl-lazy-help-time'."
          (setq index (imenu-example--name-and-position))
          (setcar index (concat package "::BOOT:"))
          (push index index-alist)))))
-    (or noninteractive
-       (imenu-progress-message prev-pos 100))
     index-alist))
 
 (defvar cperl-unreadable-ok nil)
@@ -5658,7 +5634,7 @@ Delay of auto-help controlled by `cperl-lazy-help-time'."
                         (string-match "^sub[ \t]+\\([_a-zA-Z]+\\)[^:_a-zA-Z]"
                                       (elt elt 3)))
                    ;; Need to insert the name without package as well
-                   (setq lst (cons (cons (substring (elt elt 3) 
+                   (setq lst (cons (cons (substring (elt elt 3)
                                                     (match-beginning 1)
                                                     (match-end 1))
                                          (cdr elt))
@@ -5730,7 +5706,7 @@ Use as
                        (setq cperl-unreadable-ok t
                              tm nil)   ; Return empty list
                      (error "Aborting: unreadable directory %s" file)))))))
-         (mapcar (function 
+         (mapcar (function
                   (lambda (file)
                     (cond
                      ((string-match cperl-noscan-files-regexp file)
@@ -6008,12 +5984,12 @@ One may build such TAGS files from CPerl mode menu."
 (defvar cperl-bad-style-regexp
   (mapconcat 'identity
             '("[^-\n\t <>=+!.&|(*/'`\"#^][-=+<>!|&^]" ; char sign
-              "[-<>=+^&|]+[^- \t\n=+<>~]") ; sign+ char 
+              "[-<>=+^&|]+[^- \t\n=+<>~]") ; sign+ char
             "\\|")
   "Finds places such that insertion of a whitespace may help a lot.")
 
 (defvar cperl-not-bad-style-regexp
-  (mapconcat 
+  (mapconcat
    'identity
    '("[^-\t <>=+]\\(--\\|\\+\\+\\)"    ; var-- var++
      "[a-zA-Z0-9_][|&][a-zA-Z0-9_$]"   ; abc|def abc&def are often used.
@@ -6050,7 +6026,8 @@ Currently it is tuned to C and Perl syntax."
   (interactive)
   (let (found-bad (p (point)))
     (setq last-nonmenu-event 13)       ; To disable popup
-    (beginning-of-buffer)
+    (with-no-warnings  ; It is useful to push the mark here.
+     (beginning-of-buffer))
     (map-y-or-n-p "Insert space here? "
                  (lambda (arg) (insert " "))
                  'cperl-next-bad-style
@@ -6666,11 +6643,11 @@ prototype \&SUB Returns prototype of the function given a reference.
 =pod           Switch from Perl to POD.
 ")
 
-(defun cperl-switch-to-doc-buffer ()
+(defun cperl-switch-to-doc-buffer (&optional interactive)
   "Go to the perl documentation buffer and insert the documentation."
-  (interactive)
+  (interactive "p")
   (let ((buf (get-buffer-create cperl-doc-buffer)))
-    (if (interactive-p)
+    (if interactive
        (switch-to-buffer-other-window buf)
       (set-buffer buf))
     (if (= (buffer-size) 0)
@@ -7207,13 +7184,9 @@ Delay of auto-help controlled by `cperl-lazy-help-time'."
 ;;; Plug for wrong font-lock:
 
 (defun cperl-font-lock-unfontify-region-function (beg end)
-  (let* ((modified (buffer-modified-p)) (buffer-undo-list t)
-        (inhibit-read-only t) (inhibit-point-motion-hooks t)
-        before-change-functions after-change-functions
-        deactivate-mark buffer-file-name buffer-file-truename)
-    (remove-text-properties beg end '(face nil))
-    (when (and (not modified) (buffer-modified-p))
-      (set-buffer-modified-p nil))))
+  ;; Simplified now that font-lock-unfontify-region uses save-buffer-state.
+  (let (before-change-functions after-change-functions)
+    (remove-text-properties beg end '(face nil))))
 
 (defvar cperl-d-l nil)
 (defun cperl-fontify-syntaxically (end)
@@ -7271,4 +7244,5 @@ Delay of auto-help controlled by `cperl-lazy-help-time'."
 
 (provide 'cperl-mode)
 
+;;; arch-tag: 42e5b19b-e187-4537-929f-1a7408980ce6
 ;;; cperl-mode.el ends here