aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2017-12-22 01:12:26 -0500
committerStefan Monnier2017-12-22 01:12:26 -0500
commitb003171d27dfa4f0a5e6f8d9eb632b1930748e95 (patch)
treece0a6f6e965d52d04a702c09851c9b91d7bf8650
parent1bcbcb7e486008d4fc449088e49da6c52ba88bee (diff)
downloademacs-b003171d27dfa4f0a5e6f8d9eb632b1930748e95.tar.gz
emacs-b003171d27dfa4f0a5e6f8d9eb632b1930748e95.zip
* lisp/progmodes/cperl-mode.el: Use lexical-binding
Drop some support code for Emacs-19. Remove unused args and vars. (cperl-mark-active): Remove, use region-active-p. (cperl-use-region-p): Remove, use use-region-p. (cperl-can-font-lock, cperl-enable-font-lock, cperl-emacs-can-parse): Remove, obsolete. (cperl-mode-map): Move initialization into declaration.
-rw-r--r--lisp/progmodes/cperl-mode.el847
1 files changed, 369 insertions, 478 deletions
diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el
index 5b161b621c4..64ee8c1b7e6 100644
--- a/lisp/progmodes/cperl-mode.el
+++ b/lisp/progmodes/cperl-mode.el
@@ -1,4 +1,4 @@
1;;; cperl-mode.el --- Perl code editing commands for Emacs 1;;; cperl-mode.el --- Perl code editing commands for Emacs -*- lexical-binding:t -*-
2 2
3;; Copyright (C) 1985-1987, 1991-2017 Free Software Foundation, Inc. 3;; Copyright (C) 1985-1987, 1991-2017 Free Software Foundation, Inc.
4 4
@@ -85,27 +85,19 @@
85 (condition-case nil 85 (condition-case nil
86 (require 'man) 86 (require 'man)
87 (error nil)) 87 (error nil))
88 (defvar cperl-can-font-lock
89 (or (featurep 'xemacs)
90 (and (boundp 'emacs-major-version)
91 (or window-system
92 (> emacs-major-version 20)))))
93 (if cperl-can-font-lock
94 (require 'font-lock))
95 (defvar msb-menu-cond) 88 (defvar msb-menu-cond)
96 (defvar gud-perldb-history) 89 (defvar gud-perldb-history)
97 (defvar font-lock-background-mode) ; not in Emacs 90 (defvar font-lock-background-mode) ; not in Emacs
98 (defvar font-lock-display-type) ; ditto 91 (defvar font-lock-display-type) ; ditto
99 (defvar paren-backwards-message) ; Not in newer XEmacs? 92 (defvar paren-backwards-message) ; Not in newer XEmacs?
100 (or (fboundp 'defgroup) 93 (or (fboundp 'defgroup)
101 (defmacro defgroup (name val doc &rest arr) 94 (defmacro defgroup (_name _val _doc &rest _)
102 nil)) 95 nil))
103 (or (fboundp 'custom-declare-variable) 96 (or (fboundp 'custom-declare-variable)
104 (defmacro defcustom (name val doc &rest arr) 97 (defmacro defcustom (name val doc &rest _)
105 `(defvar ,name ,val ,doc))) 98 `(defvar ,name ,val ,doc)))
106 (or (and (fboundp 'custom-declare-variable) 99 (or (fboundp 'custom-declare-variable)
107 (string< "19.31" emacs-version)) ; Checked with 19.30: defface does not work 100 (defmacro defface (&rest _)
108 (defmacro defface (&rest arr)
109 nil)) 101 nil))
110 ;; Avoid warning (tmp definitions) 102 ;; Avoid warning (tmp definitions)
111 (or (fboundp 'x-color-defined-p) 103 (or (fboundp 'x-color-defined-p)
@@ -142,7 +134,7 @@
142 `(progn 134 `(progn
143 (beginning-of-line 2) 135 (beginning-of-line 2)
144 (list ,file ,line))) 136 (list ,file ,line)))
145 (defmacro cperl-etags-snarf-tag (file line) 137 (defmacro cperl-etags-snarf-tag (_file _line)
146 `(etags-snarf-tag))) 138 `(etags-snarf-tag)))
147 (if (featurep 'xemacs) 139 (if (featurep 'xemacs)
148 (defmacro cperl-etags-goto-tag-location (elt) 140 (defmacro cperl-etags-goto-tag-location (elt)
@@ -157,12 +149,6 @@
157 (defmacro cperl-etags-goto-tag-location (elt) 149 (defmacro cperl-etags-goto-tag-location (elt)
158 `(etags-goto-tag-location ,elt)))) 150 `(etags-goto-tag-location ,elt))))
159 151
160(defvar cperl-can-font-lock
161 (or (featurep 'xemacs)
162 (and (boundp 'emacs-major-version)
163 (or window-system
164 (> emacs-major-version 20)))))
165
166(defun cperl-choose-color (&rest list) 152(defun cperl-choose-color (&rest list)
167 (let (answer) 153 (let (answer)
168 (while list 154 (while list
@@ -627,8 +613,7 @@ One should tune up `cperl-close-paren-offset' as well."
627 :group 'cperl-indentation-details) 613 :group 'cperl-indentation-details)
628 614
629(defcustom cperl-syntaxify-by-font-lock 615(defcustom cperl-syntaxify-by-font-lock
630 (and cperl-can-font-lock 616 (boundp 'parse-sexp-lookup-properties)
631 (boundp 'parse-sexp-lookup-properties))
632 "Non-nil means that CPerl uses the `font-lock' routines for syntaxification." 617 "Non-nil means that CPerl uses the `font-lock' routines for syntaxification."
633 :type '(choice (const message) boolean) 618 :type '(choice (const message) boolean)
634 :group 'cperl-speed) 619 :group 'cperl-speed)
@@ -1025,26 +1010,12 @@ In regular expressions (including character classes):
1025(and (vectorp cperl-del-back-ch) (= (length cperl-del-back-ch) 1) 1010(and (vectorp cperl-del-back-ch) (= (length cperl-del-back-ch) 1)
1026 (setq cperl-del-back-ch (aref cperl-del-back-ch 0))) 1011 (setq cperl-del-back-ch (aref cperl-del-back-ch 0)))
1027 1012
1028(defun cperl-mark-active () (mark)) ; Avoid undefined warning
1029(if (featurep 'xemacs)
1030 (progn
1031 ;; "Active regions" are on: use region only if active
1032 ;; "Active regions" are off: use region unconditionally
1033 (defun cperl-use-region-p ()
1034 (if zmacs-regions (mark) t)))
1035 (defun cperl-use-region-p ()
1036 (if transient-mark-mode mark-active t))
1037 (defun cperl-mark-active () mark-active))
1038
1039(defsubst cperl-enable-font-lock ()
1040 cperl-can-font-lock)
1041
1042(defun cperl-putback-char (c) ; Emacs 19 1013(defun cperl-putback-char (c) ; Emacs 19
1043 (push c unread-command-events)) ; Avoid undefined warning 1014 (push c unread-command-events)) ; Avoid undefined warning
1044 1015
1045(if (featurep 'xemacs) 1016(if (featurep 'xemacs)
1046 (defun cperl-putback-char (c) ; XEmacs >= 19.12 1017 (defun cperl-putback-char (c) ; XEmacs >= 19.12
1047 (push (eval '(character-to-event c)) unread-command-events))) 1018 (push (character-to-event c) unread-command-events)))
1048 1019
1049(or (fboundp 'uncomment-region) 1020(or (fboundp 'uncomment-region)
1050 (defun uncomment-region (beg end) 1021 (defun uncomment-region (beg end)
@@ -1052,6 +1023,7 @@ In regular expressions (including character classes):
1052 (comment-region beg end -1))) 1023 (comment-region beg end -1)))
1053 1024
1054(defvar cperl-do-not-fontify 1025(defvar cperl-do-not-fontify
1026 ;; FIXME: This is not doing what it claims!
1055 (if (string< emacs-version "19.30") 1027 (if (string< emacs-version "19.30")
1056 'fontified 1028 'fontified
1057 'lazy-lock) 1029 'lazy-lock)
@@ -1071,8 +1043,6 @@ In regular expressions (including character classes):
1071 1043
1072(defvar cperl-syntax-state nil) 1044(defvar cperl-syntax-state nil)
1073(defvar cperl-syntax-done-to nil) 1045(defvar cperl-syntax-done-to nil)
1074(defvar cperl-emacs-can-parse (> (length (save-excursion
1075 (parse-partial-sexp (point) (point)))) 9))
1076 1046
1077;; Make customization possible "in reverse" 1047;; Make customization possible "in reverse"
1078(defsubst cperl-val (symbol &optional default hairy) 1048(defsubst cperl-val (symbol &optional default hairy)
@@ -1100,14 +1070,14 @@ versions of Emacs."
1100 (put-text-property (point) (match-end 0) 1070 (put-text-property (point) (match-end 0)
1101 'syntax-type prop))))))) 1071 'syntax-type prop)))))))
1102 1072
1103;;; Probably it is too late to set these guys already, but it can help later: 1073;; Probably it is too late to set these guys already, but it can help later:
1104 1074
1105;;;(and cperl-clobber-mode-lists 1075;;(and cperl-clobber-mode-lists
1106;;;(setq auto-mode-alist 1076;;(setq auto-mode-alist
1107;;; (append '(("\\.\\([pP][Llm]\\|al\\)$" . perl-mode)) auto-mode-alist )) 1077;; (append '(("\\.\\([pP][Llm]\\|al\\)$" . perl-mode)) auto-mode-alist ))
1108;;;(and (boundp 'interpreter-mode-alist) 1078;;(and (boundp 'interpreter-mode-alist)
1109;;; (setq interpreter-mode-alist (append interpreter-mode-alist 1079;; (setq interpreter-mode-alist (append interpreter-mode-alist
1110;;; '(("miniperl" . perl-mode)))))) 1080;; '(("miniperl" . perl-mode))))))
1111(eval-when-compile 1081(eval-when-compile
1112 (mapc (lambda (p) 1082 (mapc (lambda (p)
1113 (condition-case nil 1083 (condition-case nil
@@ -1117,7 +1087,7 @@ versions of Emacs."
1117 (if (fboundp 'ps-extend-face-list) 1087 (if (fboundp 'ps-extend-face-list)
1118 (defmacro cperl-ps-extend-face-list (arg) 1088 (defmacro cperl-ps-extend-face-list (arg)
1119 `(ps-extend-face-list ,arg)) 1089 `(ps-extend-face-list ,arg))
1120 (defmacro cperl-ps-extend-face-list (arg) 1090 (defmacro cperl-ps-extend-face-list (_)
1121 `(error "This version of Emacs has no `ps-extend-face-list'"))) 1091 `(error "This version of Emacs has no `ps-extend-face-list'")))
1122 ;; Calling `cperl-enable-font-lock' below doesn't compile on XEmacs, 1092 ;; Calling `cperl-enable-font-lock' below doesn't compile on XEmacs,
1123 ;; macros instead of defsubsts don't work on Emacs, so we do the 1093 ;; macros instead of defsubsts don't work on Emacs, so we do the
@@ -1152,93 +1122,80 @@ versions of Emacs."
1152 ("head2" "head2" cperl-electric-pod :system t))) 1122 ("head2" "head2" cperl-electric-pod :system t)))
1153 "Abbrev table in use in CPerl mode buffers.") 1123 "Abbrev table in use in CPerl mode buffers.")
1154 1124
1155(add-hook 'edit-var-mode-alist '(perl-mode (regexp . "^cperl-"))) 1125(when (boundp 'edit-var-mode-alist)
1156 1126 (add-to-list 'edit-var-mode-alist '(perl-mode (regexp . "^cperl-"))))
1157(defvar cperl-mode-map () "Keymap used in CPerl mode.") 1127
1158 1128(defvar cperl-mode-map
1159(if cperl-mode-map nil 1129 (let ((map (make-sparse-keymap)))
1160 (setq cperl-mode-map (make-sparse-keymap)) 1130 (define-key map "{" 'cperl-electric-lbrace)
1161 (cperl-define-key "{" 'cperl-electric-lbrace) 1131 (define-key map "[" 'cperl-electric-paren)
1162 (cperl-define-key "[" 'cperl-electric-paren) 1132 (define-key map "(" 'cperl-electric-paren)
1163 (cperl-define-key "(" 'cperl-electric-paren) 1133 (define-key map "<" 'cperl-electric-paren)
1164 (cperl-define-key "<" 'cperl-electric-paren) 1134 (define-key map "}" 'cperl-electric-brace)
1165 (cperl-define-key "}" 'cperl-electric-brace) 1135 (define-key map "]" 'cperl-electric-rparen)
1166 (cperl-define-key "]" 'cperl-electric-rparen) 1136 (define-key map ")" 'cperl-electric-rparen)
1167 (cperl-define-key ")" 'cperl-electric-rparen) 1137 (define-key map ";" 'cperl-electric-semi)
1168 (cperl-define-key ";" 'cperl-electric-semi) 1138 (define-key map ":" 'cperl-electric-terminator)
1169 (cperl-define-key ":" 'cperl-electric-terminator) 1139 (define-key map "\C-j" 'newline-and-indent)
1170 (cperl-define-key "\C-j" 'newline-and-indent) 1140 (define-key map "\C-c\C-j" 'cperl-linefeed)
1171 (cperl-define-key "\C-c\C-j" 'cperl-linefeed) 1141 (define-key map "\C-c\C-t" 'cperl-invert-if-unless)
1172 (cperl-define-key "\C-c\C-t" 'cperl-invert-if-unless) 1142 (define-key map "\C-c\C-a" 'cperl-toggle-auto-newline)
1173 (cperl-define-key "\C-c\C-a" 'cperl-toggle-auto-newline) 1143 (define-key map "\C-c\C-k" 'cperl-toggle-abbrev)
1174 (cperl-define-key "\C-c\C-k" 'cperl-toggle-abbrev) 1144 (define-key map "\C-c\C-w" 'cperl-toggle-construct-fix)
1175 (cperl-define-key "\C-c\C-w" 'cperl-toggle-construct-fix) 1145 (define-key map "\C-c\C-f" 'auto-fill-mode)
1176 (cperl-define-key "\C-c\C-f" 'auto-fill-mode) 1146 (define-key map "\C-c\C-e" 'cperl-toggle-electric)
1177 (cperl-define-key "\C-c\C-e" 'cperl-toggle-electric) 1147 (define-key map "\C-c\C-b" 'cperl-find-bad-style)
1178 (cperl-define-key "\C-c\C-b" 'cperl-find-bad-style) 1148 (define-key map "\C-c\C-p" 'cperl-pod-spell)
1179 (cperl-define-key "\C-c\C-p" 'cperl-pod-spell) 1149 (define-key map "\C-c\C-d" 'cperl-here-doc-spell)
1180 (cperl-define-key "\C-c\C-d" 'cperl-here-doc-spell) 1150 (define-key map "\C-c\C-n" 'cperl-narrow-to-here-doc)
1181 (cperl-define-key "\C-c\C-n" 'cperl-narrow-to-here-doc) 1151 (define-key map "\C-c\C-v" 'cperl-next-interpolated-REx)
1182 (cperl-define-key "\C-c\C-v" 'cperl-next-interpolated-REx) 1152 (define-key map "\C-c\C-x" 'cperl-next-interpolated-REx-0)
1183 (cperl-define-key "\C-c\C-x" 'cperl-next-interpolated-REx-0) 1153 (define-key map "\C-c\C-y" 'cperl-next-interpolated-REx-1)
1184 (cperl-define-key "\C-c\C-y" 'cperl-next-interpolated-REx-1) 1154 (define-key map "\C-c\C-ha" 'cperl-toggle-autohelp)
1185 (cperl-define-key "\C-c\C-ha" 'cperl-toggle-autohelp) 1155 (define-key map "\C-c\C-hp" 'cperl-perldoc)
1186 (cperl-define-key "\C-c\C-hp" 'cperl-perldoc) 1156 (define-key map "\C-c\C-hP" 'cperl-perldoc-at-point)
1187 (cperl-define-key "\C-c\C-hP" 'cperl-perldoc-at-point) 1157 (define-key map "\e\C-q" 'cperl-indent-exp) ; Usually not bound
1188 (cperl-define-key "\e\C-q" 'cperl-indent-exp) ; Usually not bound 1158 (define-key map [(control meta ?|)] 'cperl-lineup)
1189 (cperl-define-key [?\C-\M-\|] 'cperl-lineup 1159 ;;(define-key map "\M-q" 'cperl-fill-paragraph)
1190 [(control meta |)]) 1160 ;;(define-key map "\e;" 'cperl-indent-for-comment)
1191 ;;(cperl-define-key "\M-q" 'cperl-fill-paragraph) 1161 (define-key map "\177" 'cperl-electric-backspace)
1192 ;;(cperl-define-key "\e;" 'cperl-indent-for-comment) 1162 (define-key map "\t" 'cperl-indent-command)
1193 (cperl-define-key "\177" 'cperl-electric-backspace) 1163 ;; don't clobber the backspace binding:
1194 (cperl-define-key "\t" 'cperl-indent-command) 1164 (define-key map [(control ?c) (control ?h) ?F] 'cperl-info-on-command)
1195 ;; don't clobber the backspace binding: 1165 (if (cperl-val 'cperl-clobber-lisp-bindings)
1196 (cperl-define-key "\C-c\C-hF" 'cperl-info-on-command 1166 (progn
1197 [(control c) (control h) F]) 1167 (define-key map [(control ?h) ?f]
1198 (if (cperl-val 'cperl-clobber-lisp-bindings) 1168 ;;(concat (char-to-string help-char) "f") ; does not work
1199 (progn 1169 'cperl-info-on-command)
1200 (cperl-define-key "\C-hf" 1170 (define-key map [(control ?h) ?v]
1201 ;;(concat (char-to-string help-char) "f") ; does not work 1171 ;;(concat (char-to-string help-char) "v") ; does not work
1202 'cperl-info-on-command 1172 'cperl-get-help)
1203 [(control h) f]) 1173 (define-key map [(control ?c) (control ?h) ?f]
1204 (cperl-define-key "\C-hv" 1174 ;;(concat (char-to-string help-char) "f") ; does not work
1205 ;;(concat (char-to-string help-char) "v") ; does not work 1175 (key-binding "\C-hf"))
1206 'cperl-get-help 1176 (define-key map [(control ?c) (control ?h) ?v]
1207 [(control h) v]) 1177 ;;(concat (char-to-string help-char) "v") ; does not work
1208 (cperl-define-key "\C-c\C-hf" 1178 (key-binding "\C-hv")))
1209 ;;(concat (char-to-string help-char) "f") ; does not work 1179 (define-key map [(control ?c) (control ?h) ?f]
1210 (key-binding "\C-hf") 1180 'cperl-info-on-current-command)
1211 [(control c) (control h) f]) 1181 (define-key map [(control ?c) (control ?h) ?v]
1212 (cperl-define-key "\C-c\C-hv" 1182 ;;(concat (char-to-string help-char) "v") ; does not work
1213 ;;(concat (char-to-string help-char) "v") ; does not work 1183 'cperl-get-help))
1214 (key-binding "\C-hv")
1215 [(control c) (control h) v]))
1216 (cperl-define-key "\C-c\C-hf" 'cperl-info-on-current-command
1217 [(control c) (control h) f])
1218 (cperl-define-key "\C-c\C-hv"
1219 ;;(concat (char-to-string help-char) "v") ; does not work
1220 'cperl-get-help
1221 [(control c) (control h) v]))
1222 (if (and (featurep 'xemacs)
1223 (<= emacs-minor-version 11) (<= emacs-major-version 19))
1224 (progn
1225 ;; substitute-key-definition is usefulness-deenhanced...
1226 ;;;;;(cperl-define-key "\M-q" 'cperl-fill-paragraph)
1227 (cperl-define-key "\e;" 'cperl-indent-for-comment)
1228 (cperl-define-key "\e\C-\\" 'cperl-indent-region))
1229 (or (boundp 'fill-paragraph-function) 1184 (or (boundp 'fill-paragraph-function)
1230 (substitute-key-definition 1185 (substitute-key-definition
1231 'fill-paragraph 'cperl-fill-paragraph 1186 'fill-paragraph 'cperl-fill-paragraph
1232 cperl-mode-map global-map)) 1187 map global-map))
1233 (substitute-key-definition 1188 (substitute-key-definition
1234 'indent-sexp 'cperl-indent-exp 1189 'indent-sexp 'cperl-indent-exp
1235 cperl-mode-map global-map) 1190 map global-map)
1236 (substitute-key-definition 1191 (substitute-key-definition
1237 'indent-region 'cperl-indent-region 1192 'indent-region 'cperl-indent-region
1238 cperl-mode-map global-map) 1193 map global-map)
1239 (substitute-key-definition 1194 (substitute-key-definition
1240 'indent-for-comment 'cperl-indent-for-comment 1195 'indent-for-comment 'cperl-indent-for-comment
1241 cperl-mode-map global-map))) 1196 map global-map)
1197 map)
1198 "Keymap used in CPerl mode.")
1242 1199
1243(defvar cperl-menu) 1200(defvar cperl-menu)
1244(defvar cperl-lazy-installed) 1201(defvar cperl-lazy-installed)
@@ -1255,7 +1212,7 @@ versions of Emacs."
1255 ["Indent expression" cperl-indent-exp t] 1212 ["Indent expression" cperl-indent-exp t]
1256 ["Fill paragraph/comment" fill-paragraph t] 1213 ["Fill paragraph/comment" fill-paragraph t]
1257 "----" 1214 "----"
1258 ["Line up a construction" cperl-lineup (cperl-use-region-p)] 1215 ["Line up a construction" cperl-lineup (use-region-p)]
1259 ["Invert if/unless/while etc" cperl-invert-if-unless t] 1216 ["Invert if/unless/while etc" cperl-invert-if-unless t]
1260 ("Regexp" 1217 ("Regexp"
1261 ["Beautify" cperl-beautify-regexp 1218 ["Beautify" cperl-beautify-regexp
@@ -1283,9 +1240,9 @@ versions of Emacs."
1283 ["Insert spaces if needed to fix style" cperl-find-bad-style t] 1240 ["Insert spaces if needed to fix style" cperl-find-bad-style t]
1284 ["Refresh \"hard\" constructions" cperl-find-pods-heres t] 1241 ["Refresh \"hard\" constructions" cperl-find-pods-heres t]
1285 "----" 1242 "----"
1286 ["Indent region" cperl-indent-region (cperl-use-region-p)] 1243 ["Indent region" cperl-indent-region (use-region-p)]
1287 ["Comment region" cperl-comment-region (cperl-use-region-p)] 1244 ["Comment region" cperl-comment-region (use-region-p)]
1288 ["Uncomment region" cperl-uncomment-region (cperl-use-region-p)] 1245 ["Uncomment region" cperl-uncomment-region (use-region-p)]
1289 "----" 1246 "----"
1290 ["Run" mode-compile (fboundp 'mode-compile)] 1247 ["Run" mode-compile (fboundp 'mode-compile)]
1291 ["Kill" mode-compile-kill (and (fboundp 'mode-compile-kill) 1248 ["Kill" mode-compile-kill (and (fboundp 'mode-compile-kill)
@@ -1332,7 +1289,7 @@ versions of Emacs."
1332 (fboundp 'ps-extend-face-list)] 1289 (fboundp 'ps-extend-face-list)]
1333 "----" 1290 "----"
1334 ["Syntaxify region" cperl-find-pods-heres-region 1291 ["Syntaxify region" cperl-find-pods-heres-region
1335 (cperl-use-region-p)] 1292 (use-region-p)]
1336 ["Profile syntaxification" cperl-time-fontification t] 1293 ["Profile syntaxification" cperl-time-fontification t]
1337 ["Debug errors in delayed fontification" cperl-emulate-lazy-lock t] 1294 ["Debug errors in delayed fontification" cperl-emulate-lazy-lock t]
1338 ["Debug unwind for syntactic scan" cperl-toggle-set-debug-unwind t] 1295 ["Debug unwind for syntactic scan" cperl-toggle-set-debug-unwind t]
@@ -1371,11 +1328,9 @@ versions of Emacs."
1371 ["Perldoc on word at point" cperl-perldoc-at-point t] 1328 ["Perldoc on word at point" cperl-perldoc-at-point t]
1372 ["View manpage of POD in this file" cperl-build-manpage t] 1329 ["View manpage of POD in this file" cperl-build-manpage t]
1373 ["Auto-help on" cperl-lazy-install 1330 ["Auto-help on" cperl-lazy-install
1374 (and (fboundp 'run-with-idle-timer) 1331 (not cperl-lazy-installed)]
1375 (not cperl-lazy-installed))]
1376 ["Auto-help off" cperl-lazy-unstall 1332 ["Auto-help off" cperl-lazy-unstall
1377 (and (fboundp 'run-with-idle-timer) 1333 cperl-lazy-installed])
1378 cperl-lazy-installed)])
1379 ("Toggle..." 1334 ("Toggle..."
1380 ["Auto newline" cperl-toggle-auto-newline t] 1335 ["Auto newline" cperl-toggle-auto-newline t]
1381 ["Electric parens" cperl-toggle-electric t] 1336 ["Electric parens" cperl-toggle-electric t]
@@ -1402,7 +1357,8 @@ versions of Emacs."
1402 ["CPerl mode" (describe-function 'cperl-mode) t] 1357 ["CPerl mode" (describe-function 'cperl-mode) t]
1403 ["CPerl version" 1358 ["CPerl version"
1404 (message "The version of master-file for this CPerl is %s-Emacs" 1359 (message "The version of master-file for this CPerl is %s-Emacs"
1405 cperl-version) t])))) 1360 cperl-version)
1361 t]))))
1406 (error nil)) 1362 (error nil))
1407 1363
1408(autoload 'c-macro-expand "cmacexp" 1364(autoload 'c-macro-expand "cmacexp"
@@ -1421,11 +1377,11 @@ Should contain exactly one group.")
1421Should contain exactly one group.") 1377Should contain exactly one group.")
1422 1378
1423 1379
1424;;; Is incorporated in `cperl-imenu--function-name-regexp-perl' 1380;; Is incorporated in `cperl-imenu--function-name-regexp-perl'
1425;;; `cperl-outline-regexp', `defun-prompt-regexp'. 1381;; `cperl-outline-regexp', `defun-prompt-regexp'.
1426;;; Details of groups in this may be used in several functions; see comments 1382;; Details of groups in this may be used in several functions; see comments
1427;;; near mentioned above variable(s)... 1383;; near mentioned above variable(s)...
1428;;; sub($$):lvalue{} sub:lvalue{} Both allowed... 1384;; sub($$):lvalue{} sub:lvalue{} Both allowed...
1429(defsubst cperl-after-sub-regexp (named attr) ; 9 groups without attr... 1385(defsubst cperl-after-sub-regexp (named attr) ; 9 groups without attr...
1430 "Match the text after `sub' in a subroutine declaration. 1386 "Match the text after `sub' in a subroutine declaration.
1431If NAMED is nil, allows anonymous subroutines. Matches up to the first \":\" 1387If NAMED is nil, allows anonymous subroutines. Matches up to the first \":\"
@@ -1460,8 +1416,8 @@ the last)."
1460 "\\)?" ; END n+6=proto-group 1416 "\\)?" ; END n+6=proto-group
1461 )) 1417 ))
1462 1418
1463;;; Tired of editing this in 8 places every time I remember that there 1419;; Tired of editing this in 8 places every time I remember that there
1464;;; is another method-defining keyword 1420;; is another method-defining keyword
1465(defvar cperl-sub-keywords 1421(defvar cperl-sub-keywords
1466 '("sub")) 1422 '("sub"))
1467 1423
@@ -1657,7 +1613,7 @@ It is possible to show this help automatically after some idle time.
1657This is regulated by variable `cperl-lazy-help-time'. Default with 1613This is regulated by variable `cperl-lazy-help-time'. Default with
1658`cperl-hairy' (if the value of `cperl-lazy-help-time' is nil) is 5 1614`cperl-hairy' (if the value of `cperl-lazy-help-time' is nil) is 5
1659secs idle time . It is also possible to switch this on/off from the 1615secs idle time . It is also possible to switch this on/off from the
1660menu, or via \\[cperl-toggle-autohelp]. Requires `run-with-idle-timer'. 1616menu, or via \\[cperl-toggle-autohelp].
1661 1617
1662Use \\[cperl-lineup] to vertically lineup some construction - put the 1618Use \\[cperl-lineup] to vertically lineup some construction - put the
1663beginning of the region at the start of construction, and make region 1619beginning of the region at the start of construction, and make region
@@ -1752,108 +1708,74 @@ or as help on variables `cperl-tips', `cperl-problems',
1752 ;; Until Emacs is multi-threaded, we do not actually need it local: 1708 ;; Until Emacs is multi-threaded, we do not actually need it local:
1753 (make-local-variable 'cperl-font-lock-multiline-start) 1709 (make-local-variable 'cperl-font-lock-multiline-start)
1754 (make-local-variable 'cperl-font-locking) 1710 (make-local-variable 'cperl-font-locking)
1755 (make-local-variable 'outline-regexp) 1711 (set (make-local-variable 'outline-regexp) cperl-outline-regexp)
1756 ;; (setq outline-regexp imenu-example--function-name-regexp-perl) 1712 (set (make-local-variable 'outline-level) 'cperl-outline-level)
1757 (setq outline-regexp cperl-outline-regexp) 1713 (set (make-local-variable 'add-log-current-defun-function)
1758 (make-local-variable 'outline-level)
1759 (setq outline-level 'cperl-outline-level)
1760 (make-local-variable 'add-log-current-defun-function)
1761 (setq add-log-current-defun-function
1762 (lambda () 1714 (lambda ()
1763 (save-excursion 1715 (save-excursion
1764 (if (re-search-backward "^sub[ \t]+\\([^({ \t\n]+\\)" nil t) 1716 (if (re-search-backward "^sub[ \t]+\\([^({ \t\n]+\\)" nil t)
1765 (match-string-no-properties 1))))) 1717 (match-string-no-properties 1)))))
1766 1718
1767 (make-local-variable 'paragraph-start) 1719 (set (make-local-variable 'paragraph-start) (concat "^$\\|" page-delimiter))
1768 (setq paragraph-start (concat "^$\\|" page-delimiter)) 1720 (set (make-local-variable 'paragraph-separate) paragraph-start)
1769 (make-local-variable 'paragraph-separate) 1721 (set (make-local-variable 'paragraph-ignore-fill-prefix) t)
1770 (setq paragraph-separate paragraph-start)
1771 (make-local-variable 'paragraph-ignore-fill-prefix)
1772 (setq paragraph-ignore-fill-prefix t)
1773 (if (featurep 'xemacs) 1722 (if (featurep 'xemacs)
1774 (progn 1723 (set (make-local-variable 'paren-backwards-message) t))
1775 (make-local-variable 'paren-backwards-message) 1724 (set (make-local-variable 'indent-line-function) #'cperl-indent-line)
1776 (set 'paren-backwards-message t))) 1725 (set (make-local-variable 'require-final-newline) mode-require-final-newline)
1777 (make-local-variable 'indent-line-function) 1726 (set (make-local-variable 'comment-start) "# ")
1778 (setq indent-line-function 'cperl-indent-line) 1727 (set (make-local-variable 'comment-end) "")
1779 (make-local-variable 'require-final-newline) 1728 (set (make-local-variable 'comment-column) cperl-comment-column)
1780 (setq require-final-newline mode-require-final-newline) 1729 (set (make-local-variable 'comment-start-skip) "#+ *")
1781 (make-local-variable 'comment-start) 1730
1782 (setq comment-start "# ") 1731;; "[ \t]*sub"
1783 (make-local-variable 'comment-end) 1732;; (cperl-after-sub-regexp 'named nil) ; 8=name 11=proto 14=attr-start
1784 (setq comment-end "") 1733;; cperl-maybe-white-and-comment-rex ; 15=pre-block
1785 (make-local-variable 'comment-column) 1734 (set (make-local-variable 'defun-prompt-regexp)
1786 (setq comment-column cperl-comment-column) 1735 (concat "^[ \t]*\\("
1787 (make-local-variable 'comment-start-skip) 1736 cperl-sub-regexp
1788 (setq comment-start-skip "#+ *") 1737 (cperl-after-sub-regexp 'named 'attr-groups)
1789 (make-local-variable 'defun-prompt-regexp) 1738 "\\|" ; per toke.c
1790;;; "[ \t]*sub" 1739 "\\(BEGIN\\|UNITCHECK\\|CHECK\\|INIT\\|END\\|AUTOLOAD\\|DESTROY\\)"
1791;;; (cperl-after-sub-regexp 'named nil) ; 8=name 11=proto 14=attr-start 1740 "\\)"
1792;;; cperl-maybe-white-and-comment-rex ; 15=pre-block 1741 cperl-maybe-white-and-comment-rex))
1793 (setq defun-prompt-regexp 1742 (set (make-local-variable 'comment-indent-function) #'cperl-comment-indent)
1794 (concat "^[ \t]*\\("
1795 cperl-sub-regexp
1796 (cperl-after-sub-regexp 'named 'attr-groups)
1797 "\\|" ; per toke.c
1798 "\\(BEGIN\\|UNITCHECK\\|CHECK\\|INIT\\|END\\|AUTOLOAD\\|DESTROY\\)"
1799 "\\)"
1800 cperl-maybe-white-and-comment-rex))
1801 (make-local-variable 'comment-indent-function)
1802 (setq comment-indent-function 'cperl-comment-indent)
1803 (and (boundp 'fill-paragraph-function) 1743 (and (boundp 'fill-paragraph-function)
1804 (progn 1744 (set (make-local-variable 'fill-paragraph-function)
1805 (make-local-variable 'fill-paragraph-function) 1745 #'cperl-fill-paragraph))
1806 (set 'fill-paragraph-function 'cperl-fill-paragraph))) 1746 (set (make-local-variable 'parse-sexp-ignore-comments) t)
1807 (make-local-variable 'parse-sexp-ignore-comments) 1747 (set (make-local-variable 'indent-region-function) #'cperl-indent-region)
1808 (setq parse-sexp-ignore-comments t) 1748 ;;(setq auto-fill-function #'cperl-do-auto-fill) ; Need to switch on and off!
1809 (make-local-variable 'indent-region-function) 1749 (set (make-local-variable 'imenu-create-index-function)
1810 (setq indent-region-function 'cperl-indent-region) 1750 #'cperl-imenu--create-perl-index)
1811 ;;(setq auto-fill-function 'cperl-do-auto-fill) ; Need to switch on and off! 1751 (set (make-local-variable 'imenu-sort-function) nil)
1812 (make-local-variable 'imenu-create-index-function) 1752 (set (make-local-variable 'vc-rcs-header) cperl-vc-rcs-header)
1813 (setq imenu-create-index-function 1753 (set (make-local-variable 'vc-sccs-header) cperl-vc-sccs-header)
1814 (function cperl-imenu--create-perl-index))
1815 (make-local-variable 'imenu-sort-function)
1816 (setq imenu-sort-function nil)
1817 (make-local-variable 'vc-rcs-header)
1818 (set 'vc-rcs-header cperl-vc-rcs-header)
1819 (make-local-variable 'vc-sccs-header)
1820 (set 'vc-sccs-header cperl-vc-sccs-header)
1821 (when (featurep 'xemacs) 1754 (when (featurep 'xemacs)
1822 ;; This one is obsolete... 1755 ;; This one is obsolete...
1823 (make-local-variable 'vc-header-alist) 1756 (set (make-local-variable 'vc-header-alist)
1824 (set 'vc-header-alist (or cperl-vc-header-alist ; Avoid warning 1757 (or cperl-vc-header-alist ; Avoid warning
1825 `((SCCS ,(car cperl-vc-sccs-header)) 1758 `((SCCS ,(car cperl-vc-sccs-header))
1826 (RCS ,(car cperl-vc-rcs-header)))))) 1759 (RCS ,(car cperl-vc-rcs-header))))))
1827 (cond ((boundp 'compilation-error-regexp-alist-alist);; xemacs 20.x 1760 (cond ((boundp 'compilation-error-regexp-alist-alist);; xemacs 20.x
1828 (make-local-variable 'compilation-error-regexp-alist-alist) 1761 (set (make-local-variable 'compilation-error-regexp-alist-alist)
1829 (set 'compilation-error-regexp-alist-alist
1830 (cons (cons 'cperl (car cperl-compilation-error-regexp-alist)) 1762 (cons (cons 'cperl (car cperl-compilation-error-regexp-alist))
1831 (symbol-value 'compilation-error-regexp-alist-alist))) 1763 compilation-error-regexp-alist-alist))
1832 (if (fboundp 'compilation-build-compilation-error-regexp-alist) 1764 (if (fboundp 'compilation-build-compilation-error-regexp-alist)
1833 (let ((f 'compilation-build-compilation-error-regexp-alist)) 1765 (let ((f 'compilation-build-compilation-error-regexp-alist))
1834 (funcall f)) 1766 (funcall f))
1835 (make-local-variable 'compilation-error-regexp-alist) 1767 (make-local-variable 'compilation-error-regexp-alist)
1836 (push 'cperl compilation-error-regexp-alist))) 1768 (push 'cperl compilation-error-regexp-alist)))
1837 ((boundp 'compilation-error-regexp-alist);; xemacs 19.x 1769 ((boundp 'compilation-error-regexp-alist);; xemacs 19.x
1838 (make-local-variable 'compilation-error-regexp-alist) 1770 (set (make-local-variable 'compilation-error-regexp-alist)
1839 (set 'compilation-error-regexp-alist
1840 (append cperl-compilation-error-regexp-alist 1771 (append cperl-compilation-error-regexp-alist
1841 (symbol-value 'compilation-error-regexp-alist))))) 1772 compilation-error-regexp-alist))))
1842 (make-local-variable 'font-lock-defaults) 1773 (set (make-local-variable 'font-lock-defaults)
1843 (setq font-lock-defaults 1774 '((cperl-load-font-lock-keywords
1844 (cond 1775 cperl-load-font-lock-keywords-1
1845 ((string< emacs-version "19.30") 1776 cperl-load-font-lock-keywords-2) nil nil ((?_ . "w"))))
1846 '(cperl-font-lock-keywords-2 nil nil ((?_ . "w")))) 1777 ;; Reset syntaxification cache.
1847 ((string< emacs-version "19.33") ; Which one to use? 1778 (set (make-local-variable 'cperl-syntax-state) nil)
1848 '((cperl-font-lock-keywords
1849 cperl-font-lock-keywords-1
1850 cperl-font-lock-keywords-2) nil nil ((?_ . "w"))))
1851 (t
1852 '((cperl-load-font-lock-keywords
1853 cperl-load-font-lock-keywords-1
1854 cperl-load-font-lock-keywords-2) nil nil ((?_ . "w"))))))
1855 (make-local-variable 'cperl-syntax-state)
1856 (setq cperl-syntax-state nil) ; reset syntaxification cache
1857 (if cperl-use-syntax-table-text-property 1779 (if cperl-use-syntax-table-text-property
1858 (if (eval-when-compile (fboundp 'syntax-propertize-rules)) 1780 (if (eval-when-compile (fboundp 'syntax-propertize-rules))
1859 (progn 1781 (progn
@@ -1868,21 +1790,19 @@ or as help on variables `cperl-tips', `cperl-problems',
1868 ;; to re-apply them. 1790 ;; to re-apply them.
1869 (setq cperl-syntax-done-to start) 1791 (setq cperl-syntax-done-to start)
1870 (cperl-fontify-syntaxically end)))) 1792 (cperl-fontify-syntaxically end))))
1871 (make-local-variable 'parse-sexp-lookup-properties)
1872 ;; Do not introduce variable if not needed, we check it! 1793 ;; Do not introduce variable if not needed, we check it!
1873 (set 'parse-sexp-lookup-properties t) 1794 (set (make-local-variable 'parse-sexp-lookup-properties) t)
1874 ;; Fix broken font-lock: 1795 ;; Fix broken font-lock:
1875 (or (boundp 'font-lock-unfontify-region-function) 1796 (or (boundp 'font-lock-unfontify-region-function)
1876 (set 'font-lock-unfontify-region-function 1797 (setq font-lock-unfontify-region-function
1877 'font-lock-default-unfontify-region)) 1798 #'font-lock-default-unfontify-region))
1878 (unless (featurep 'xemacs) ; Our: just a plug for wrong font-lock 1799 (unless (featurep 'xemacs) ; Our: just a plug for wrong font-lock
1879 (make-local-variable 'font-lock-unfontify-region-function) 1800 (set (make-local-variable 'font-lock-unfontify-region-function)
1880 (set 'font-lock-unfontify-region-function ; not present with old Emacs 1801 ;; not present with old Emacs
1881 'cperl-font-lock-unfontify-region-function)) 1802 #'cperl-font-lock-unfontify-region-function))
1882 (make-local-variable 'cperl-syntax-done-to) 1803 ;; Reset syntaxification cache.
1883 (setq cperl-syntax-done-to nil) ; reset syntaxification cache 1804 (set (make-local-variable 'cperl-syntax-done-to) nil)
1884 (make-local-variable 'font-lock-syntactic-keywords) 1805 (set (make-local-variable 'font-lock-syntactic-keywords)
1885 (setq font-lock-syntactic-keywords
1886 (if cperl-syntaxify-by-font-lock 1806 (if cperl-syntaxify-by-font-lock
1887 '((cperl-fontify-syntaxically)) 1807 '((cperl-fontify-syntaxically))
1888 ;; unless font-lock-syntactic-keywords, font-lock (pre-22.1) 1808 ;; unless font-lock-syntactic-keywords, font-lock (pre-22.1)
@@ -1894,45 +1814,33 @@ or as help on variables `cperl-tips', `cperl-problems',
1894 (progn 1814 (progn
1895 (setq cperl-font-lock-multiline t) ; Not localized... 1815 (setq cperl-font-lock-multiline t) ; Not localized...
1896 (set (make-local-variable 'font-lock-multiline) t)) 1816 (set (make-local-variable 'font-lock-multiline) t))
1897 (make-local-variable 'font-lock-fontify-region-function) 1817 (set (make-local-variable 'font-lock-fontify-region-function)
1898 (set 'font-lock-fontify-region-function ; not present with old Emacs 1818 ;; not present with old Emacs
1899 'cperl-font-lock-fontify-region-function)) 1819 #'cperl-font-lock-fontify-region-function))
1900 (make-local-variable 'font-lock-fontify-region-function) 1820 (set (make-local-variable 'font-lock-fontify-region-function)
1901 (set 'font-lock-fontify-region-function ; not present with old Emacs 1821 #'cperl-font-lock-fontify-region-function)
1902 'cperl-font-lock-fontify-region-function)
1903 (make-local-variable 'cperl-old-style) 1822 (make-local-variable 'cperl-old-style)
1904 (if (boundp 'normal-auto-fill-function) ; 19.33 and later 1823 (set (make-local-variable 'normal-auto-fill-function)
1905 (set (make-local-variable 'normal-auto-fill-function) 1824 #'cperl-do-auto-fill)
1906 'cperl-do-auto-fill) 1825 (if (cperl-val 'cperl-font-lock)
1907 (or (fboundp 'cperl-old-auto-fill-mode) 1826 (progn (or cperl-faces-init (cperl-init-faces))
1908 (progn 1827 (font-lock-mode 1)))
1909 (fset 'cperl-old-auto-fill-mode (symbol-function 'auto-fill-mode))
1910 (defun auto-fill-mode (&optional arg)
1911 (interactive "P")
1912 (eval '(cperl-old-auto-fill-mode arg)) ; Avoid a warning
1913 (and auto-fill-function (memq major-mode '(perl-mode cperl-mode))
1914 (setq auto-fill-function 'cperl-do-auto-fill))))))
1915 (if (cperl-enable-font-lock)
1916 (if (cperl-val 'cperl-font-lock)
1917 (progn (or cperl-faces-init (cperl-init-faces))
1918 (font-lock-mode 1))))
1919 (set (make-local-variable 'facemenu-add-face-function) 1828 (set (make-local-variable 'facemenu-add-face-function)
1920 'cperl-facemenu-add-face-function) ; XXXX What this guy is for??? 1829 #'cperl-facemenu-add-face-function) ; XXXX What this guy is for???
1921 (and (boundp 'msb-menu-cond) 1830 (and (boundp 'msb-menu-cond)
1922 (not cperl-msb-fixed) 1831 (not cperl-msb-fixed)
1923 (cperl-msb-fix)) 1832 (cperl-msb-fix))
1924 (if (fboundp 'easy-menu-add) 1833 (if (fboundp 'easy-menu-add)
1925 (easy-menu-add cperl-menu)) ; A NOP in Emacs. 1834 (easy-menu-add cperl-menu)) ; A NOP in Emacs.
1926 (run-mode-hooks 'cperl-mode-hook)
1927 (if cperl-hook-after-change 1835 (if cperl-hook-after-change
1928 (add-hook 'after-change-functions 'cperl-after-change-function nil t)) 1836 (add-hook 'after-change-functions #'cperl-after-change-function nil t))
1929 ;; After hooks since fontification will break this 1837 ;; After hooks since fontification will break this
1930 (if cperl-pod-here-scan 1838 (if cperl-pod-here-scan
1931 (or cperl-syntaxify-by-font-lock 1839 (or cperl-syntaxify-by-font-lock
1932 (progn (or cperl-faces-init (cperl-init-faces-weak)) 1840 (progn (or cperl-faces-init (cperl-init-faces-weak))
1933 (cperl-find-pods-heres)))) 1841 (cperl-find-pods-heres))))
1934 ;; Setup Flymake 1842 ;; Setup Flymake
1935 (add-hook 'flymake-diagnostic-functions 'perl-flymake nil t)) 1843 (add-hook 'flymake-diagnostic-functions #'perl-flymake nil t))
1936 1844
1937;; Fix for perldb - make default reasonable 1845;; Fix for perldb - make default reasonable
1938(defun cperl-db () 1846(defun cperl-db ()
@@ -2059,7 +1967,7 @@ char is \"{\", insert extra newline before only if
2059 (interactive "P") 1967 (interactive "P")
2060 (let (insertpos 1968 (let (insertpos
2061 (other-end (if (and cperl-electric-parens-mark 1969 (other-end (if (and cperl-electric-parens-mark
2062 (cperl-mark-active) 1970 (region-active-p)
2063 (< (mark) (point))) 1971 (< (mark) (point)))
2064 (mark) 1972 (mark)
2065 nil))) 1973 nil)))
@@ -2131,13 +2039,13 @@ char is \"{\", insert extra newline before only if
2131 (cperl-auto-newline cperl-auto-newline) 2039 (cperl-auto-newline cperl-auto-newline)
2132 (other-end (or end 2040 (other-end (or end
2133 (if (and cperl-electric-parens-mark 2041 (if (and cperl-electric-parens-mark
2134 (cperl-mark-active) 2042 (region-active-p)
2135 (> (mark) (point))) 2043 (> (mark) (point)))
2136 (save-excursion 2044 (save-excursion
2137 (goto-char (mark)) 2045 (goto-char (mark))
2138 (point-marker)) 2046 (point-marker))
2139 nil))) 2047 nil)))
2140 pos after) 2048 pos)
2141 (and (cperl-val 'cperl-electric-lbrace-space) 2049 (and (cperl-val 'cperl-electric-lbrace-space)
2142 (eq (preceding-char) ?$) 2050 (eq (preceding-char) ?$)
2143 (save-excursion 2051 (save-excursion
@@ -2167,9 +2075,8 @@ char is \"{\", insert extra newline before only if
2167 "Insert an opening parenthesis or a matching pair of parentheses. 2075 "Insert an opening parenthesis or a matching pair of parentheses.
2168See `cperl-electric-parens'." 2076See `cperl-electric-parens'."
2169 (interactive "P") 2077 (interactive "P")
2170 (let ((beg (point-at-bol)) 2078 (let ((other-end (if (and cperl-electric-parens-mark
2171 (other-end (if (and cperl-electric-parens-mark 2079 (region-active-p)
2172 (cperl-mark-active)
2173 (> (mark) (point))) 2080 (> (mark) (point)))
2174 (save-excursion 2081 (save-excursion
2175 (goto-char (mark)) 2082 (goto-char (mark))
@@ -2179,7 +2086,6 @@ See `cperl-electric-parens'."
2179 (memq last-command-event 2086 (memq last-command-event
2180 (append cperl-electric-parens-string nil)) 2087 (append cperl-electric-parens-string nil))
2181 (>= (save-excursion (cperl-to-comment-or-eol) (point)) (point)) 2088 (>= (save-excursion (cperl-to-comment-or-eol) (point)) (point))
2182 ;;(not (save-excursion (search-backward "#" beg t)))
2183 (if (eq last-command-event ?<) 2089 (if (eq last-command-event ?<)
2184 (progn 2090 (progn
2185 ;; This code is too electric, see Bug#3943. 2091 ;; This code is too electric, see Bug#3943.
@@ -2204,12 +2110,11 @@ See `cperl-electric-parens'."
2204If not, or if we are not at the end of marking range, would self-insert. 2110If not, or if we are not at the end of marking range, would self-insert.
2205Affected by `cperl-electric-parens'." 2111Affected by `cperl-electric-parens'."
2206 (interactive "P") 2112 (interactive "P")
2207 (let ((beg (point-at-bol)) 2113 (let ((other-end (if (and cperl-electric-parens-mark
2208 (other-end (if (and cperl-electric-parens-mark
2209 (cperl-val 'cperl-electric-parens) 2114 (cperl-val 'cperl-electric-parens)
2210 (memq last-command-event 2115 (memq last-command-event
2211 (append cperl-electric-parens-string nil)) 2116 (append cperl-electric-parens-string nil))
2212 (cperl-mark-active) 2117 (region-active-p)
2213 (< (mark) (point))) 2118 (< (mark) (point)))
2214 (mark) 2119 (mark)
2215 nil)) 2120 nil))
@@ -2218,7 +2123,6 @@ Affected by `cperl-electric-parens'."
2218 (cperl-val 'cperl-electric-parens) 2123 (cperl-val 'cperl-electric-parens)
2219 (memq last-command-event '( ?\) ?\] ?\} ?\> )) 2124 (memq last-command-event '( ?\) ?\] ?\} ?\> ))
2220 (>= (save-excursion (cperl-to-comment-or-eol) (point)) (point)) 2125 (>= (save-excursion (cperl-to-comment-or-eol) (point)) (point))
2221 ;;(not (save-excursion (search-backward "#" beg t)))
2222 ) 2126 )
2223 (progn 2127 (progn
2224 (self-insert-command (prefix-numeric-value arg)) 2128 (self-insert-command (prefix-numeric-value arg))
@@ -2659,11 +2563,10 @@ The relative indentation among the lines of the expression are preserved."
2659Return the amount the indentation changed by." 2563Return the amount the indentation changed by."
2660 (let ((case-fold-search nil) 2564 (let ((case-fold-search nil)
2661 (pos (- (point-max) (point))) 2565 (pos (- (point-max) (point)))
2662 indent i beg shift-amt) 2566 indent i shift-amt)
2663 (setq indent (cperl-calculate-indent parse-data) 2567 (setq indent (cperl-calculate-indent parse-data)
2664 i indent) 2568 i indent)
2665 (beginning-of-line) 2569 (beginning-of-line)
2666 (setq beg (point))
2667 (cond ((or (eq indent nil) (eq indent t)) 2570 (cond ((or (eq indent nil) (eq indent t))
2668 (setq indent (current-indentation) i nil)) 2571 (setq indent (current-indentation) i nil))
2669 ;;((eq indent t) ; Never? 2572 ;;((eq indent t) ; Never?
@@ -2690,8 +2593,8 @@ Return the amount the indentation changed by."
2690 (zerop shift-amt)) 2593 (zerop shift-amt))
2691 (if (> (- (point-max) pos) (point)) 2594 (if (> (- (point-max) pos) (point))
2692 (goto-char (- (point-max) pos))) 2595 (goto-char (- (point-max) pos)))
2693 ;;;(delete-region beg (point)) 2596 ;;(delete-region beg (point))
2694 ;;;(indent-to indent) 2597 ;;(indent-to indent)
2695 (cperl-make-indent indent) 2598 (cperl-make-indent indent)
2696 ;; If initial point was within line's indentation, 2599 ;; If initial point was within line's indentation,
2697 ;; position after the indentation. Else stay at same point in text. 2600 ;; position after the indentation. Else stay at same point in text.
@@ -2709,13 +2612,13 @@ Return the amount the indentation changed by."
2709 (looking-at "[a-zA-Z_][a-zA-Z0-9_]*:[^:]")))) 2612 (looking-at "[a-zA-Z_][a-zA-Z0-9_]*:[^:]"))))
2710 2613
2711(defun cperl-get-state (&optional parse-start start-state) 2614(defun cperl-get-state (&optional parse-start start-state)
2712 ;; returns list (START STATE DEPTH PRESTART), 2615 "Return list (START STATE DEPTH PRESTART),
2713 ;; START is a good place to start parsing, or equal to 2616START is a good place to start parsing, or equal to
2714 ;; PARSE-START if preset, 2617PARSE-START if preset,
2715 ;; STATE is what is returned by `parse-partial-sexp'. 2618STATE is what is returned by `parse-partial-sexp'.
2716 ;; DEPTH is true is we are immediately after end of block 2619DEPTH is true is we are immediately after end of block
2717 ;; which contains START. 2620which contains START.
2718 ;; PRESTART is the position basing on which START was found. 2621PRESTART is the position basing on which START was found."
2719 (save-excursion 2622 (save-excursion
2720 (let ((start-point (point)) depth state start prestart) 2623 (let ((start-point (point)) depth state start prestart)
2721 (if (and parse-start 2624 (if (and parse-start
@@ -3231,7 +3134,7 @@ and closing parentheses and brackets."
3231(defun cperl-calculate-indent-within-comment () 3134(defun cperl-calculate-indent-within-comment ()
3232 "Return the indentation amount for line, assuming that 3135 "Return the indentation amount for line, assuming that
3233the current line is to be regarded as part of a block comment." 3136the current line is to be regarded as part of a block comment."
3234 (let (end star-start) 3137 (let (end)
3235 (save-excursion 3138 (save-excursion
3236 (beginning-of-line) 3139 (beginning-of-line)
3237 (skip-chars-forward " \t") 3140 (skip-chars-forward " \t")
@@ -3515,12 +3418,11 @@ Works before syntax recognition is done."
3515 3418
3516(defun cperl-unwind-to-safe (before &optional end) 3419(defun cperl-unwind-to-safe (before &optional end)
3517 ;; if BEFORE, go to the previous start-of-line on each step of unwinding 3420 ;; if BEFORE, go to the previous start-of-line on each step of unwinding
3518 (let ((pos (point)) opos) 3421 (let ((pos (point)))
3519 (while (and pos (progn 3422 (while (and pos (progn
3520 (beginning-of-line) 3423 (beginning-of-line)
3521 (get-text-property (setq pos (point)) 'syntax-type))) 3424 (get-text-property (setq pos (point)) 'syntax-type)))
3522 (setq opos pos 3425 (setq pos (cperl-beginning-of-property pos 'syntax-type))
3523 pos (cperl-beginning-of-property pos 'syntax-type))
3524 (if (eq pos (point-min)) 3426 (if (eq pos (point-min))
3525 (setq pos nil)) 3427 (setq pos nil))
3526 (if pos 3428 (if pos
@@ -3564,7 +3466,7 @@ Works before syntax recognition is done."
3564Should be called with the point before leading colon of an attribute." 3466Should be called with the point before leading colon of an attribute."
3565 ;; Works *before* syntax recognition is done 3467 ;; Works *before* syntax recognition is done
3566 (or st-l (setq st-l (list nil))) ; Avoid overwriting '() 3468 (or st-l (setq st-l (list nil))) ; Avoid overwriting '()
3567 (let (st b p reset-st after-first (start (point)) start1 end1) 3469 (let (st p reset-st after-first (start (point)) start1 end1)
3568 (condition-case b 3470 (condition-case b
3569 (while (looking-at 3471 (while (looking-at
3570 (concat 3472 (concat
@@ -3665,7 +3567,8 @@ Should be called with the point before leading colon of an attribute."
3665 'face dashface)) 3567 'face dashface))
3666 ;; save match data (for looking-at) 3568 ;; save match data (for looking-at)
3667 (setq lll (mapcar (function (lambda (elt) (cons (match-beginning elt) 3569 (setq lll (mapcar (function (lambda (elt) (cons (match-beginning elt)
3668 (match-end elt)))) l)) 3570 (match-end elt))))
3571 l))
3669 (while lll 3572 (while lll
3670 (setq ll (car lll)) 3573 (setq ll (car lll))
3671 (setq lle (cdr ll) 3574 (setq lle (cdr ll)
@@ -4913,7 +4816,7 @@ TEST is the expression to evaluate at the found position. If absent,
4913CHARS is a string that contains good characters to have before us (however, 4816CHARS is a string that contains good characters to have before us (however,
4914`}' is treated \"smartly\" if it is not in the list)." 4817`}' is treated \"smartly\" if it is not in the list)."
4915 (let ((lim (or lim (point-min))) 4818 (let ((lim (or lim (point-min)))
4916 stop p pr) 4819 stop p)
4917 (cperl-update-syntaxification (point) (point)) 4820 (cperl-update-syntaxification (point) (point))
4918 (save-excursion 4821 (save-excursion
4919 (while (and (not stop) (> (point) lim)) 4822 (while (and (not stop) (> (point) lim))
@@ -4988,7 +4891,6 @@ CHARS is a string that contains good characters to have before us (however,
4988 (error t)))) 4891 (error t))))
4989 4892
4990(defun cperl-forward-to-end-of-expr (&optional lim) 4893(defun cperl-forward-to-end-of-expr (&optional lim)
4991 (let ((p (point))))
4992 (condition-case nil 4894 (condition-case nil
4993 (progn 4895 (progn
4994 (while (and (< (point) (or lim (point-max))) 4896 (while (and (< (point) (or lim (point-max)))
@@ -5285,7 +5187,7 @@ Returns some position at the last line."
5285 5187
5286(defvar cperl-update-start) ; Do not need to make them local 5188(defvar cperl-update-start) ; Do not need to make them local
5287(defvar cperl-update-end) 5189(defvar cperl-update-end)
5288(defun cperl-delay-update-hook (beg end old-len) 5190(defun cperl-delay-update-hook (beg end _old-len)
5289 (setq cperl-update-start (min beg (or cperl-update-start (point-max)))) 5191 (setq cperl-update-start (min beg (or cperl-update-start (point-max))))
5290 (setq cperl-update-end (max end (or cperl-update-end (point-min))))) 5192 (setq cperl-update-end (max end (or cperl-update-end (point-min)))))
5291 5193
@@ -5302,13 +5204,11 @@ conditional/loop constructs."
5302 (cperl-update-syntaxification end end) 5204 (cperl-update-syntaxification end end)
5303 (save-excursion 5205 (save-excursion
5304 (let (cperl-update-start cperl-update-end (h-a-c after-change-functions)) 5206 (let (cperl-update-start cperl-update-end (h-a-c after-change-functions))
5305 (let ((indent-info (if cperl-emacs-can-parse 5207 (let ((indent-info (list nil nil nil) ; Cannot use '(), since will modify
5306 (list nil nil nil) ; Cannot use '(), since will modify 5208 )
5307 nil))
5308 (pm 0)
5309 after-change-functions ; Speed it up! 5209 after-change-functions ; Speed it up!
5310 st comm old-comm-indent new-comm-indent p pp i empty) 5210 comm old-comm-indent new-comm-indent i empty)
5311 (if h-a-c (add-hook 'after-change-functions 'cperl-delay-update-hook)) 5211 (if h-a-c (add-hook 'after-change-functions #'cperl-delay-update-hook))
5312 (goto-char start) 5212 (goto-char start)
5313 (setq old-comm-indent (and (cperl-to-comment-or-eol) 5213 (setq old-comm-indent (and (cperl-to-comment-or-eol)
5314 (current-column)) 5214 (current-column))
@@ -5317,7 +5217,6 @@ conditional/loop constructs."
5317 (setq end (set-marker (make-marker) end)) ; indentation changes pos 5217 (setq end (set-marker (make-marker) end)) ; indentation changes pos
5318 (or (bolp) (beginning-of-line 2)) 5218 (or (bolp) (beginning-of-line 2))
5319 (while (and (<= (point) end) (not (eobp))) ; bol to check start 5219 (while (and (<= (point) end) (not (eobp))) ; bol to check start
5320 (setq st (point))
5321 (if (or 5220 (if (or
5322 (setq empty (looking-at "[ \t]*\n")) 5221 (setq empty (looking-at "[ \t]*\n"))
5323 (and (setq comm (looking-at "[ \t]*#")) 5222 (and (setq comm (looking-at "[ \t]*#"))
@@ -5503,10 +5402,10 @@ indentation and initial hashes. Behaves usually outside of comment."
5503(defun cperl-imenu--create-perl-index (&optional regexp) 5402(defun cperl-imenu--create-perl-index (&optional regexp)
5504 (require 'imenu) ; May be called from TAGS creator 5403 (require 'imenu) ; May be called from TAGS creator
5505 (let ((index-alist '()) (index-pack-alist '()) (index-pod-alist '()) 5404 (let ((index-alist '()) (index-pack-alist '()) (index-pod-alist '())
5506 (index-unsorted-alist '()) (i-s-f (default-value 'imenu-sort-function)) 5405 (index-unsorted-alist '())
5507 (index-meth-alist '()) meth 5406 (index-meth-alist '()) meth
5508 packages ends-ranges p marker is-proto 5407 packages ends-ranges p marker is-proto
5509 (prev-pos 0) is-pack index index1 name (end-range 0) package) 5408 is-pack index index1 name (end-range 0) package)
5510 (goto-char (point-min)) 5409 (goto-char (point-min))
5511 (cperl-update-syntaxification (point-max) (point-max)) 5410 (cperl-update-syntaxification (point-max) (point-max))
5512 ;; Search for the function 5411 ;; Search for the function
@@ -5728,7 +5627,7 @@ indentation and initial hashes. Behaves usually outside of comment."
5728 (concat 5627 (concat
5729 "\\(^\\|[^$@%&\\]\\)\\<\\(" 5628 "\\(^\\|[^$@%&\\]\\)\\<\\("
5730 (mapconcat 5629 (mapconcat
5731 'identity 5630 #'identity
5732 (append 5631 (append
5733 cperl-sub-keywords 5632 cperl-sub-keywords
5734 '("if" "until" "while" "elsif" "else" 5633 '("if" "until" "while" "elsif" "else"
@@ -5838,8 +5737,9 @@ indentation and initial hashes. Behaves usually outside of comment."
5838 "u\\(se\\|n\\(shift\\|ti\\(l\\|e\\)\\|def\\|less\\)\\)\\|" 5737 "u\\(se\\|n\\(shift\\|ti\\(l\\|e\\)\\|def\\|less\\)\\)\\|"
5839 "wh\\(en\\|ile\\)\\|y\\|__\\(END\\|DATA\\)__" ;__DATA__ added manually 5738 "wh\\(en\\|ile\\)\\|y\\|__\\(END\\|DATA\\)__" ;__DATA__ added manually
5840 "\\|[sm]" ; Added manually 5739 "\\|[sm]" ; Added manually
5841 "\\)\\>") 2 'cperl-nonoverridable-face) 5740 "\\)\\>")
5842 ;; (mapconcat 'identity 5741 2 'cperl-nonoverridable-face)
5742 ;; (mapconcat #'identity
5843 ;; '("#endif" "#else" "#ifdef" "#ifndef" "#if" 5743 ;; '("#endif" "#else" "#ifdef" "#ifndef" "#if"
5844 ;; "#include" "#define" "#undef") 5744 ;; "#include" "#define" "#undef")
5845 ;; "\\|") 5745 ;; "\\|")
@@ -6165,14 +6065,15 @@ indentation and initial hashes. Behaves usually outside of comment."
6165 (if (boundp 'font-lock-background-mode) 6065 (if (boundp 'font-lock-background-mode)
6166 font-lock-background-mode 6066 font-lock-background-mode
6167 'light)) 6067 'light))
6168 (face-list (and (fboundp 'face-list) (face-list)))) 6068 ;; (face-list (and (fboundp 'face-list) (face-list)))
6169;;;; (fset 'cperl-is-face 6069 )
6170;;;; (cond ((fboundp 'find-face) 6070 ;; (fset 'cperl-is-face
6171;;;; (symbol-function 'find-face)) 6071 ;; (cond ((fboundp 'find-face)
6172;;;; (face-list 6072 ;; (symbol-function 'find-face))
6173;;;; (function (lambda (face) (member face face-list)))) 6073 ;; (face-list
6174;;;; (t 6074 ;; (function (lambda (face) (member face face-list))))
6175;;;; (function (lambda (face) (boundp face)))))) 6075 ;; (t
6076 ;; (function (lambda (face) (boundp face))))))
6176 (defvar cperl-guessed-background 6077 (defvar cperl-guessed-background
6177 (if (and (boundp 'font-lock-display-type) 6078 (if (and (boundp 'font-lock-display-type)
6178 (eq font-lock-display-type 'grayscale)) 6079 (eq font-lock-display-type 'grayscale))
@@ -6296,40 +6197,40 @@ Style of printout regulated by the variable `cperl-ps-print-face-properties'."
6296 (cperl-ps-extend-face-list cperl-ps-print-face-properties) 6197 (cperl-ps-extend-face-list cperl-ps-print-face-properties)
6297 (ps-print-buffer-with-faces file))) 6198 (ps-print-buffer-with-faces file)))
6298 6199
6299;;; (defun cperl-ps-print-init () 6200;; (defun cperl-ps-print-init ()
6300;;; "Initialization of `ps-print' components for faces used in CPerl." 6201;; "Initialization of `ps-print' components for faces used in CPerl."
6301;;; ;; Guard against old versions 6202;; ;; Guard against old versions
6302;;; (defvar ps-underlined-faces nil) 6203;; (defvar ps-underlined-faces nil)
6303;;; (defvar ps-bold-faces nil) 6204;; (defvar ps-bold-faces nil)
6304;;; (defvar ps-italic-faces nil) 6205;; (defvar ps-italic-faces nil)
6305;;; (setq ps-bold-faces 6206;; (setq ps-bold-faces
6306;;; (append '(font-lock-emphasized-face 6207;; (append '(font-lock-emphasized-face
6307;;; cperl-array-face 6208;; cperl-array-face
6308;;; font-lock-keyword-face 6209;; font-lock-keyword-face
6309;;; font-lock-variable-name-face 6210;; font-lock-variable-name-face
6310;;; font-lock-constant-face 6211;; font-lock-constant-face
6311;;; font-lock-reference-face 6212;; font-lock-reference-face
6312;;; font-lock-other-emphasized-face 6213;; font-lock-other-emphasized-face
6313;;; cperl-hash-face) 6214;; cperl-hash-face)
6314;;; ps-bold-faces)) 6215;; ps-bold-faces))
6315;;; (setq ps-italic-faces 6216;; (setq ps-italic-faces
6316;;; (append '(cperl-nonoverridable-face 6217;; (append '(cperl-nonoverridable-face
6317;;; font-lock-constant-face 6218;; font-lock-constant-face
6318;;; font-lock-reference-face 6219;; font-lock-reference-face
6319;;; font-lock-other-emphasized-face 6220;; font-lock-other-emphasized-face
6320;;; cperl-hash-face) 6221;; cperl-hash-face)
6321;;; ps-italic-faces)) 6222;; ps-italic-faces))
6322;;; (setq ps-underlined-faces 6223;; (setq ps-underlined-faces
6323;;; (append '(font-lock-emphasized-face 6224;; (append '(font-lock-emphasized-face
6324;;; cperl-array-face 6225;; cperl-array-face
6325;;; font-lock-other-emphasized-face 6226;; font-lock-other-emphasized-face
6326;;; cperl-hash-face 6227;; cperl-hash-face
6327;;; cperl-nonoverridable-face font-lock-type-face) 6228;; cperl-nonoverridable-face font-lock-type-face)
6328;;; ps-underlined-faces)) 6229;; ps-underlined-faces))
6329;;; (cons 'font-lock-type-face ps-underlined-faces)) 6230;; (cons 'font-lock-type-face ps-underlined-faces))
6330 6231
6331 6232
6332(if (cperl-enable-font-lock) (cperl-windowed-init)) 6233(cperl-windowed-init)
6333 6234
6334(defconst cperl-styles-entries 6235(defconst cperl-styles-entries
6335 '(cperl-indent-level cperl-brace-offset cperl-continued-brace-offset 6236 '(cperl-indent-level cperl-brace-offset cperl-continued-brace-offset
@@ -6540,16 +6441,14 @@ data already), may be restored by `cperl-set-style-back'.
6540Choosing \"Current\" style will not change style, so this may be used for 6441Choosing \"Current\" style will not change style, so this may be used for
6541side-effect of memorizing only. Examples in `cperl-style-examples'." 6442side-effect of memorizing only. Examples in `cperl-style-examples'."
6542 (interactive 6443 (interactive
6543 (let ((list (mapcar (function (lambda (elt) (list (car elt)))) 6444 (list (completing-read "Enter style: " cperl-style-alist nil 'insist)))
6544 cperl-style-alist)))
6545 (list (completing-read "Enter style: " list nil 'insist))))
6546 (or cperl-old-style 6445 (or cperl-old-style
6547 (setq cperl-old-style 6446 (setq cperl-old-style
6548 (mapcar (function 6447 (mapcar (function
6549 (lambda (name) 6448 (lambda (name)
6550 (cons name (eval name)))) 6449 (cons name (eval name))))
6551 cperl-styles-entries))) 6450 cperl-styles-entries)))
6552 (let ((style (cdr (assoc style cperl-style-alist))) setting str sym) 6451 (let ((style (cdr (assoc style cperl-style-alist))) setting)
6553 (while style 6452 (while style
6554 (setq setting (car style) style (cdr style)) 6453 (setq setting (car style) style (cdr style))
6555 (set (car setting) (cdr setting))))) 6454 (set (car setting) (cdr setting)))))
@@ -6564,6 +6463,7 @@ side-effect of memorizing only. Examples in `cperl-style-examples'."
6564 cperl-old-style (cdr cperl-old-style)) 6463 cperl-old-style (cdr cperl-old-style))
6565 (set (car setting) (cdr setting))))) 6464 (set (car setting) (cdr setting)))))
6566 6465
6466(defvar perl-dbg-flags)
6567(defun cperl-check-syntax () 6467(defun cperl-check-syntax ()
6568 (interactive) 6468 (interactive)
6569 (require 'mode-compile) 6469 (require 'mode-compile)
@@ -6596,8 +6496,7 @@ side-effect of memorizing only. Examples in `cperl-style-examples'."
6596 (set-buffer "*info-perl-tmp*") 6496 (set-buffer "*info-perl-tmp*")
6597 (rename-buffer "*info*") 6497 (rename-buffer "*info*")
6598 (set-buffer bname))) 6498 (set-buffer bname)))
6599 (make-local-variable 'window-min-height) 6499 (set (make-local-variable 'window-min-height) 2)
6600 (setq window-min-height 2)
6601 (current-buffer))))) 6500 (current-buffer)))))
6602 6501
6603(defun cperl-word-at-point (&optional p) 6502(defun cperl-word-at-point (&optional p)
@@ -6628,8 +6527,7 @@ Customized by setting variables `cperl-shrink-wrap-info-frame',
6628 default 6527 default
6629 read)))) 6528 read))))
6630 6529
6631 (let ((buffer (current-buffer)) 6530 (let ((cmd-desc (concat "^" (regexp-quote command) "[^a-zA-Z_0-9]")) ; "tr///"
6632 (cmd-desc (concat "^" (regexp-quote command) "[^a-zA-Z_0-9]")) ; "tr///"
6633 pos isvar height iniheight frheight buf win fr1 fr2 iniwin not-loner 6531 pos isvar height iniheight frheight buf win fr1 fr2 iniwin not-loner
6634 max-height char-height buf-list) 6532 max-height char-height buf-list)
6635 (if (string-match "^-[a-zA-Z]$" command) 6533 (if (string-match "^-[a-zA-Z]$" command)
@@ -6727,9 +6625,9 @@ Opens Perl Info buffer if needed."
6727 (setq imenu-create-index-function 6625 (setq imenu-create-index-function
6728 'imenu-default-create-index-function 6626 'imenu-default-create-index-function
6729 imenu-prev-index-position-function 6627 imenu-prev-index-position-function
6730 'cperl-imenu-info-imenu-search 6628 #'cperl-imenu-info-imenu-search
6731 imenu-extract-index-name-function 6629 imenu-extract-index-name-function
6732 'cperl-imenu-info-imenu-name) 6630 #'cperl-imenu-info-imenu-name)
6733 (imenu-choose-buffer-index))))) 6631 (imenu-choose-buffer-index)))))
6734 (and index-item 6632 (and index-item
6735 (progn 6633 (progn
@@ -6755,7 +6653,7 @@ If STEP is nil, `cperl-lineup-step' will be used
6755\(or `cperl-indent-level', if `cperl-lineup-step' is nil). 6653\(or `cperl-indent-level', if `cperl-lineup-step' is nil).
6756Will not move the position at the start to the left." 6654Will not move the position at the start to the left."
6757 (interactive "r") 6655 (interactive "r")
6758 (let (search col tcol seen b) 6656 (let (search col tcol seen)
6759 (save-excursion 6657 (save-excursion
6760 (goto-char end) 6658 (goto-char end)
6761 (end-of-line) 6659 (end-of-line)
@@ -6861,17 +6759,16 @@ in subdirectories too."
6861 (if (cperl-val 'cperl-electric-parens) "" "not "))) 6759 (if (cperl-val 'cperl-electric-parens) "" "not ")))
6862 6760
6863(defun cperl-toggle-autohelp () 6761(defun cperl-toggle-autohelp ()
6762 ;; FIXME: Turn me into a minor mode. Fix menu entries for "Auto-help on" as
6763 ;; well.
6864 "Toggle the state of Auto-Help on Perl constructs (put in the message area). 6764 "Toggle the state of Auto-Help on Perl constructs (put in the message area).
6865Delay of auto-help controlled by `cperl-lazy-help-time'." 6765Delay of auto-help controlled by `cperl-lazy-help-time'."
6866 (interactive) 6766 (interactive)
6867 (if (fboundp 'run-with-idle-timer) 6767 (if cperl-lazy-installed
6868 (progn 6768 (cperl-lazy-unstall)
6869 (if cperl-lazy-installed 6769 (cperl-lazy-install))
6870 (cperl-lazy-unstall) 6770 (message "Perl help messages will %sbe automatically shown now."
6871 (cperl-lazy-install)) 6771 (if cperl-lazy-installed "" "not ")))
6872 (message "Perl help messages will %sbe automatically shown now."
6873 (if cperl-lazy-installed "" "not ")))
6874 (message "Cannot automatically show Perl help messages - run-with-idle-timer missing.")))
6875 6772
6876(defun cperl-toggle-construct-fix () 6773(defun cperl-toggle-construct-fix ()
6877 "Toggle whether `indent-region'/`indent-sexp' fix whitespace too." 6774 "Toggle whether `indent-region'/`indent-sexp' fix whitespace too."
@@ -6900,7 +6797,8 @@ by CPerl."
6900 (interactive "P") 6797 (interactive "P")
6901 (or arg 6798 (or arg
6902 (setq arg (if (eq cperl-syntaxify-by-font-lock 6799 (setq arg (if (eq cperl-syntaxify-by-font-lock
6903 (if backtrace 'backtrace 'message)) 0 1))) 6800 (if backtrace 'backtrace 'message))
6801 0 1)))
6904 (setq arg (if (> arg 0) (if backtrace 'backtrace 'message) t)) 6802 (setq arg (if (> arg 0) (if backtrace 'backtrace 'message) t))
6905 (setq cperl-syntaxify-by-font-lock arg) 6803 (setq cperl-syntaxify-by-font-lock arg)
6906 (message "Debugging messages of syntax unwind %sabled." 6804 (message "Debugging messages of syntax unwind %sabled."
@@ -6917,9 +6815,8 @@ by CPerl."
6917 (auto-fill-mode 0) 6815 (auto-fill-mode 0)
6918 (if cperl-use-syntax-table-text-property-for-tags 6816 (if cperl-use-syntax-table-text-property-for-tags
6919 (progn 6817 (progn
6920 (make-local-variable 'parse-sexp-lookup-properties)
6921 ;; Do not introduce variable if not needed, we check it! 6818 ;; Do not introduce variable if not needed, we check it!
6922 (set 'parse-sexp-lookup-properties t)))) 6819 (set (make-local-variable 'parse-sexp-lookup-properties) t))))
6923 6820
6924;; Copied from imenu-example--name-and-position. 6821;; Copied from imenu-example--name-and-position.
6925(defvar imenu-use-markers) 6822(defvar imenu-use-markers)
@@ -6937,7 +6834,7 @@ Does not move point."
6937(defun cperl-xsub-scan () 6834(defun cperl-xsub-scan ()
6938 (require 'imenu) 6835 (require 'imenu)
6939 (let ((index-alist '()) 6836 (let ((index-alist '())
6940 (prev-pos 0) index index1 name package prefix) 6837 index index1 name package prefix)
6941 (goto-char (point-min)) 6838 (goto-char (point-min))
6942 ;; Search for the function 6839 ;; Search for the function
6943 (progn ;;save-match-data 6840 (progn ;;save-match-data
@@ -6977,12 +6874,12 @@ Does not move point."
6977 6874
6978(defun cperl-find-tags (ifile xs topdir) 6875(defun cperl-find-tags (ifile xs topdir)
6979 (let ((b (get-buffer cperl-tmp-buffer)) ind lst elt pos ret rel 6876 (let ((b (get-buffer cperl-tmp-buffer)) ind lst elt pos ret rel
6980 (cperl-pod-here-fontify nil) f file) 6877 (cperl-pod-here-fontify nil) file)
6981 (save-excursion 6878 (save-excursion
6982 (if b (set-buffer b) 6879 (if b (set-buffer b)
6983 (cperl-setup-tmp-buf)) 6880 (cperl-setup-tmp-buf))
6984 (erase-buffer) 6881 (erase-buffer)
6985 (condition-case err 6882 (condition-case nil
6986 (setq file (car (insert-file-contents ifile))) 6883 (setq file (car (insert-file-contents ifile)))
6987 (error (if cperl-unreadable-ok nil 6884 (error (if cperl-unreadable-ok nil
6988 (if (y-or-n-p 6885 (if (y-or-n-p
@@ -6996,7 +6893,7 @@ Does not move point."
6996 (not xs)) 6893 (not xs))
6997 (condition-case err ; after __END__ may have garbage 6894 (condition-case err ; after __END__ may have garbage
6998 (cperl-find-pods-heres nil nil noninteractive) 6895 (cperl-find-pods-heres nil nil noninteractive)
6999 (error (message "While scanning for syntax: %s" err)))) 6896 (error (message "While scanning for syntax: %S" err))))
7000 (if xs 6897 (if xs
7001 (setq lst (cperl-xsub-scan)) 6898 (setq lst (cperl-xsub-scan))
7002 (setq ind (cperl-imenu--create-perl-index)) 6899 (setq ind (cperl-imenu--create-perl-index))
@@ -7094,7 +6991,7 @@ Use as
7094 (setq topdir default-directory)) 6991 (setq topdir default-directory))
7095 (let ((tags-file-name "TAGS") 6992 (let ((tags-file-name "TAGS")
7096 (case-fold-search (and (featurep 'xemacs) (eq system-type 'emx))) 6993 (case-fold-search (and (featurep 'xemacs) (eq system-type 'emx)))
7097 xs rel tm) 6994 xs rel)
7098 (save-excursion 6995 (save-excursion
7099 (cond (inbuffer nil) ; Already there 6996 (cond (inbuffer nil) ; Already there
7100 ((file-exists-p tags-file-name) 6997 ((file-exists-p tags-file-name)
@@ -7109,7 +7006,7 @@ Use as
7109 (erase-buffer) 7006 (erase-buffer)
7110 (setq erase 'ignore))) 7007 (setq erase 'ignore)))
7111 (let ((files 7008 (let ((files
7112 (condition-case err 7009 (condition-case nil
7113 (directory-files file t 7010 (directory-files file t
7114 (if recurse nil cperl-scan-files-regexp) 7011 (if recurse nil cperl-scan-files-regexp)
7115 t) 7012 t)
@@ -7117,8 +7014,9 @@ Use as
7117 (if cperl-unreadable-ok nil 7014 (if cperl-unreadable-ok nil
7118 (if (y-or-n-p 7015 (if (y-or-n-p
7119 (format "Directory %s unreadable. Continue? " file)) 7016 (format "Directory %s unreadable. Continue? " file))
7120 (setq cperl-unreadable-ok t 7017 (progn
7121 tm nil) ; Return empty list 7018 (setq cperl-unreadable-ok t)
7019 nil) ; Return empty list
7122 (error "Aborting: unreadable directory %s" file))))))) 7020 (error "Aborting: unreadable directory %s" file)))))))
7123 (mapc (function 7021 (mapc (function
7124 (lambda (file) 7022 (lambda (file)
@@ -7183,10 +7081,9 @@ Use as
7183(defun cperl-tags-hier-fill () 7081(defun cperl-tags-hier-fill ()
7184 ;; Suppose we are in a tag table cooked by cperl. 7082 ;; Suppose we are in a tag table cooked by cperl.
7185 (goto-char 1) 7083 (goto-char 1)
7186 (let (type pack name pos line chunk ord cons1 file str info fileind) 7084 (let (pack name line ord cons1 file info fileind)
7187 (while (re-search-forward cperl-tags-hier-regexp-list nil t) 7085 (while (re-search-forward cperl-tags-hier-regexp-list nil t)
7188 (setq pos (match-beginning 0) 7086 (setq pack (match-beginning 2))
7189 pack (match-beginning 2))
7190 (beginning-of-line) 7087 (beginning-of-line)
7191 (if (looking-at (concat 7088 (if (looking-at (concat
7192 "\\([^\n]+\\)" 7089 "\\([^\n]+\\)"
@@ -7238,7 +7135,7 @@ One may build such TAGS files from CPerl mode menu."
7238 (or (nthcdr 2 elt) 7135 (or (nthcdr 2 elt)
7239 ;; Only in one file 7136 ;; Only in one file
7240 (setcdr elt (cdr (nth 1 elt))))))) 7137 (setcdr elt (cdr (nth 1 elt)))))))
7241 pack name cons1 to l1 l2 l3 l4 b) 7138 to l1 l2 l3)
7242 ;; (setq cperl-hierarchy '(() () ())) ; Would write into '() later! 7139 ;; (setq cperl-hierarchy '(() () ())) ; Would write into '() later!
7243 (setq cperl-hierarchy (list l1 l2 l3)) 7140 (setq cperl-hierarchy (list l1 l2 l3))
7244 (if (featurep 'xemacs) ; Not checked 7141 (if (featurep 'xemacs) ; Not checked
@@ -7272,7 +7169,7 @@ One may build such TAGS files from CPerl mode menu."
7272 (or (nth 2 cperl-hierarchy) 7169 (or (nth 2 cperl-hierarchy)
7273 (error "No items found")) 7170 (error "No items found"))
7274 (setq update 7171 (setq update
7275;;; (imenu-choose-buffer-index "Packages: " (nth 2 cperl-hierarchy)) 7172 ;; (imenu-choose-buffer-index "Packages: " (nth 2 cperl-hierarchy))
7276 (if (if (fboundp 'display-popup-menus-p) 7173 (if (if (fboundp 'display-popup-menus-p)
7277 (let ((f 'display-popup-menus-p)) 7174 (let ((f 'display-popup-menus-p))
7278 (funcall f)) 7175 (funcall f))
@@ -7292,22 +7189,20 @@ One may build such TAGS files from CPerl mode menu."
7292(defun cperl-tags-treeify (to level) 7189(defun cperl-tags-treeify (to level)
7293 ;; cadr of `to' is read-write. On start it is a cons 7190 ;; cadr of `to' is read-write. On start it is a cons
7294 (let* ((regexp (concat "^\\(" (mapconcat 7191 (let* ((regexp (concat "^\\(" (mapconcat
7295 'identity 7192 #'identity
7296 (make-list level "[_a-zA-Z0-9]+") 7193 (make-list level "[_a-zA-Z0-9]+")
7297 "::") 7194 "::")
7298 "\\)\\(::\\)?")) 7195 "\\)\\(::\\)?"))
7299 (packages (cdr (nth 1 to))) 7196 (packages (cdr (nth 1 to)))
7300 (methods (cdr (nth 2 to))) 7197 (methods (cdr (nth 2 to)))
7301 l1 head tail cons1 cons2 ord writeto packs recurse 7198 l1 head cons1 cons2 ord writeto recurse
7302 root-packages root-functions ms many_ms same_name ps 7199 root-packages root-functions
7303 (move-deeper 7200 (move-deeper
7304 (function 7201 (function
7305 (lambda (elt) 7202 (lambda (elt)
7306 (cond ((and (string-match regexp (car elt)) 7203 (cond ((and (string-match regexp (car elt))
7307 (or (eq ord 1) (match-end 2))) 7204 (or (eq ord 1) (match-end 2)))
7308 (setq head (substring (car elt) 0 (match-end 1)) 7205 (setq head (substring (car elt) 0 (match-end 1))
7309 tail (if (match-end 2) (substring (car elt)
7310 (match-end 2)))
7311 recurse t) 7206 recurse t)
7312 (if (setq cons1 (assoc head writeto)) nil 7207 (if (setq cons1 (assoc head writeto)) nil
7313 ;; Need to init new head 7208 ;; Need to init new head
@@ -7334,7 +7229,8 @@ One may build such TAGS files from CPerl mode menu."
7334 ;;Now clean up leaders with one child only 7229 ;;Now clean up leaders with one child only
7335 (mapc (function (lambda (elt) 7230 (mapc (function (lambda (elt)
7336 (if (not (and (listp (cdr elt)) 7231 (if (not (and (listp (cdr elt))
7337 (eq (length elt) 2))) nil 7232 (eq (length elt) 2)))
7233 nil
7338 (setcar elt (car (nth 1 elt))) 7234 (setcar elt (car (nth 1 elt)))
7339 (setcdr elt (cdr (nth 1 elt)))))) 7235 (setcdr elt (cdr (nth 1 elt))))))
7340 (cdr to)) 7236 (cdr to))
@@ -7359,12 +7255,12 @@ One may build such TAGS files from CPerl mode menu."
7359 (sort root-packages (default-value 'imenu-sort-function))) 7255 (sort root-packages (default-value 'imenu-sort-function)))
7360 root-packages)))) 7256 root-packages))))
7361 7257
7362;;;(x-popup-menu t 7258;;(x-popup-menu t
7363;;; '(keymap "Name1" 7259;; '(keymap "Name1"
7364;;; ("Ret1" "aa") 7260;; ("Ret1" "aa")
7365;;; ("Head1" "ab" 7261;; ("Head1" "ab"
7366;;; keymap "Name2" 7262;; keymap "Name2"
7367;;; ("Tail1" "x") ("Tail2" "y")))) 7263;; ("Tail1" "x") ("Tail2" "y"))))
7368 7264
7369(defun cperl-list-fold (list name limit) 7265(defun cperl-list-fold (list name limit)
7370 (let (list1 list2 elt1 (num 0)) 7266 (let (list1 list2 elt1 (num 0))
@@ -7385,7 +7281,7 @@ One may build such TAGS files from CPerl mode menu."
7385 (nreverse list2)) 7281 (nreverse list2))
7386 list1))))) 7282 list1)))))
7387 7283
7388(defun cperl-menu-to-keymap (menu &optional name) 7284(defun cperl-menu-to-keymap (menu)
7389 (let (list) 7285 (let (list)
7390 (cons 'keymap 7286 (cons 'keymap
7391 (mapcar 7287 (mapcar
@@ -7403,7 +7299,7 @@ One may build such TAGS files from CPerl mode menu."
7403 7299
7404 7300
7405(defvar cperl-bad-style-regexp 7301(defvar cperl-bad-style-regexp
7406 (mapconcat 'identity 7302 (mapconcat #'identity
7407 '("[^-\n\t <>=+!.&|(*/'`\"#^][-=+<>!|&^]" ; char sign 7303 '("[^-\n\t <>=+!.&|(*/'`\"#^][-=+<>!|&^]" ; char sign
7408 "[-<>=+^&|]+[^- \t\n=+<>~]") ; sign+ char 7304 "[-<>=+^&|]+[^- \t\n=+<>~]") ; sign+ char
7409 "\\|") 7305 "\\|")
@@ -7411,7 +7307,7 @@ One may build such TAGS files from CPerl mode menu."
7411 7307
7412(defvar cperl-not-bad-style-regexp 7308(defvar cperl-not-bad-style-regexp
7413 (mapconcat 7309 (mapconcat
7414 'identity 7310 #'identity
7415 '("[^-\t <>=+]\\(--\\|\\+\\+\\)" ; var-- var++ 7311 '("[^-\t <>=+]\\(--\\|\\+\\+\\)" ; var-- var++
7416 "[a-zA-Z0-9_][|&][a-zA-Z0-9_$]" ; abc|def abc&def are often used. 7312 "[a-zA-Z0-9_][|&][a-zA-Z0-9_$]" ; abc|def abc&def are often used.
7417 "&[(a-zA-Z0-9_$]" ; &subroutine &(var->field) 7313 "&[(a-zA-Z0-9_$]" ; &subroutine &(var->field)
@@ -7450,22 +7346,22 @@ Currently it is tuned to C and Perl syntax."
7450 (setq last-nonmenu-event 13) ; To disable popup 7346 (setq last-nonmenu-event 13) ; To disable popup
7451 (goto-char (point-min)) 7347 (goto-char (point-min))
7452 (map-y-or-n-p "Insert space here? " 7348 (map-y-or-n-p "Insert space here? "
7453 (lambda (arg) (insert " ")) 7349 (lambda (_) (insert " "))
7454 'cperl-next-bad-style 7350 'cperl-next-bad-style
7455 '("location" "locations" "insert a space into") 7351 '("location" "locations" "insert a space into")
7456 '((?\C-r (lambda (arg) 7352 `((?\C-r ,(lambda (_)
7457 (let ((buffer-quit-function 7353 (let ((buffer-quit-function
7458 'exit-recursive-edit)) 7354 #'exit-recursive-edit))
7459 (message "Exit with Esc Esc") 7355 (message "Exit with Esc Esc")
7460 (recursive-edit) 7356 (recursive-edit)
7461 t)) ; Consider acted upon 7357 t)) ; Consider acted upon
7462 "edit, exit with Esc Esc") 7358 "edit, exit with Esc Esc")
7463 (?e (lambda (arg) 7359 (?e ,(lambda (_)
7464 (let ((buffer-quit-function 7360 (let ((buffer-quit-function
7465 'exit-recursive-edit)) 7361 #'exit-recursive-edit))
7466 (message "Exit with Esc Esc") 7362 (message "Exit with Esc Esc")
7467 (recursive-edit) 7363 (recursive-edit)
7468 t)) ; Consider acted upon 7364 t)) ; Consider acted upon
7469 "edit, exit with Esc Esc")) 7365 "edit, exit with Esc Esc"))
7470 t) 7366 t)
7471 (if found-bad (goto-char found-bad) 7367 (if found-bad (goto-char found-bad)
@@ -7473,7 +7369,7 @@ Currently it is tuned to C and Perl syntax."
7473 (message "No appropriate place found")))) 7369 (message "No appropriate place found"))))
7474 7370
7475(defun cperl-next-bad-style () 7371(defun cperl-next-bad-style ()
7476 (let (p (not-found t) (point (point)) found) 7372 (let (p (not-found t) found)
7477 (while (and not-found 7373 (while (and not-found
7478 (re-search-forward cperl-bad-style-regexp nil 'to-end)) 7374 (re-search-forward cperl-bad-style-regexp nil 'to-end))
7479 (setq p (point)) 7375 (setq p (point))
@@ -7502,7 +7398,7 @@ Currently it is tuned to C and Perl syntax."
7502(defvar cperl-have-help-regexp 7398(defvar cperl-have-help-regexp
7503 ;;(concat "\\(" 7399 ;;(concat "\\("
7504 (mapconcat 7400 (mapconcat
7505 'identity 7401 #'identity
7506 '("[$@%*&][0-9a-zA-Z_:]+\\([ \t]*[[{]\\)?" ; Usual variable 7402 '("[$@%*&][0-9a-zA-Z_:]+\\([ \t]*[[{]\\)?" ; Usual variable
7507 "[$@]\\^[a-zA-Z]" ; Special variable 7403 "[$@]\\^[a-zA-Z]" ; Special variable
7508 "[$@][^ \n\t]" ; Special variable 7404 "[$@][^ \n\t]" ; Special variable
@@ -7602,7 +7498,7 @@ than a line. Your contribution to update/shorten it is appreciated."
7602(defun cperl-describe-perl-symbol (val) 7498(defun cperl-describe-perl-symbol (val)
7603 "Display the documentation of symbol at point, a Perl operator." 7499 "Display the documentation of symbol at point, a Perl operator."
7604 (let ((enable-recursive-minibuffers t) 7500 (let ((enable-recursive-minibuffers t)
7605 args-file regexp) 7501 regexp)
7606 (cond 7502 (cond
7607 ((string-match "^[&*][a-zA-Z_]" val) 7503 ((string-match "^[&*][a-zA-Z_]" val)
7608 (setq val (concat (substring val 0 1) "NAME"))) 7504 (setq val (concat (substring val 0 1) "NAME")))
@@ -8097,7 +7993,7 @@ prototype \\&SUB Returns prototype of the function given a reference.
8097 ;; The REx is guaranteed to have //x 7993 ;; The REx is guaranteed to have //x
8098 ;; LEVEL shows how many levels deep to go 7994 ;; LEVEL shows how many levels deep to go
8099 ;; position at enter and at leave is not defined 7995 ;; position at enter and at leave is not defined
8100 (let (s c tmp (m (make-marker)) (m1 (make-marker)) c1 spaces inline code pos) 7996 (let (s c tmp (m (make-marker)) (m1 (make-marker)) c1 spaces inline pos)
8101 (if embed 7997 (if embed
8102 (progn 7998 (progn
8103 (goto-char b) 7999 (goto-char b)
@@ -8293,8 +8189,8 @@ prototype \\&SUB Returns prototype of the function given a reference.
8293 (goto-char (match-end 1)) 8189 (goto-char (match-end 1))
8294 (re-search-backward "\\s|"))) ; Assume it is scanned already. 8190 (re-search-backward "\\s|"))) ; Assume it is scanned already.
8295 ;;(forward-char 1) 8191 ;;(forward-char 1)
8296 (let ((b (point)) (e (make-marker)) have-x delim (c (current-column)) 8192 (let ((b (point)) (e (make-marker)) have-x delim
8297 (sub-p (eq (preceding-char) ?s)) s) 8193 (sub-p (eq (preceding-char) ?s)))
8298 (forward-sexp 1) 8194 (forward-sexp 1)
8299 (set-marker e (1- (point))) 8195 (set-marker e (1- (point)))
8300 (setq delim (preceding-char)) 8196 (setq delim (preceding-char))
@@ -8371,7 +8267,7 @@ We suppose that the regexp is scanned already."
8371 (cperl-regext-to-level-start) 8267 (cperl-regext-to-level-start)
8372 (error ; We are outside outermost group 8268 (error ; We are outside outermost group
8373 (goto-char (cperl-make-regexp-x)))) 8269 (goto-char (cperl-make-regexp-x))))
8374 (let ((b (point)) (e (make-marker)) s c) 8270 (let ((b (point)) (e (make-marker)))
8375 (forward-sexp 1) 8271 (forward-sexp 1)
8376 (set-marker e (1- (point))) 8272 (set-marker e (1- (point)))
8377 (goto-char (1+ b)) 8273 (goto-char (1+ b))
@@ -8583,10 +8479,10 @@ the appropriate statement modifier."
8583 8479
8584(declare-function Man-getpage-in-background "man" (topic)) 8480(declare-function Man-getpage-in-background "man" (topic))
8585 8481
8586;;; By Anthony Foiani <afoiani@uswest.com> 8482;; By Anthony Foiani <afoiani@uswest.com>
8587;;; Getting help on modules in C-h f ? 8483;; Getting help on modules in C-h f ?
8588;;; This is a modified version of `man'. 8484;; This is a modified version of `man'.
8589;;; Need to teach it how to lookup functions 8485;; Need to teach it how to lookup functions
8590;;;###autoload 8486;;;###autoload
8591(defun cperl-perldoc (word) 8487(defun cperl-perldoc (word)
8592 "Run `perldoc' on WORD." 8488 "Run `perldoc' on WORD."
@@ -8614,6 +8510,8 @@ the appropriate statement modifier."
8614 (manual-program (if is-func "perldoc -f" "perldoc"))) 8510 (manual-program (if is-func "perldoc -f" "perldoc")))
8615 (cond 8511 (cond
8616 ((featurep 'xemacs) 8512 ((featurep 'xemacs)
8513 (defvar Manual-program)
8514 (defvar Manual-switches)
8617 (let ((Manual-program "perldoc") 8515 (let ((Manual-program "perldoc")
8618 (Manual-switches (if is-func (list "-f")))) 8516 (Manual-switches (if is-func (list "-f"))))
8619 (manual-entry word))) 8517 (manual-entry word)))
@@ -8655,6 +8553,7 @@ the appropriate statement modifier."
8655 (require 'man) 8553 (require 'man)
8656 (cond 8554 (cond
8657 ((featurep 'xemacs) 8555 ((featurep 'xemacs)
8556 (defvar Manual-program)
8658 (let ((Manual-program "perldoc")) 8557 (let ((Manual-program "perldoc"))
8659 (manual-entry buffer-file-name))) 8558 (manual-entry buffer-file-name)))
8660 (t 8559 (t
@@ -8711,7 +8610,7 @@ a result of qr//, this is not a performance hit), t for the rest."
8711 (and (eq (get-text-property beg 'syntax-type) 'string) 8610 (and (eq (get-text-property beg 'syntax-type) 'string)
8712 (setq beg (next-single-property-change beg 'syntax-type nil limit))) 8611 (setq beg (next-single-property-change beg 'syntax-type nil limit)))
8713 (cperl-map-pods-heres 8612 (cperl-map-pods-heres
8714 (function (lambda (s e p) 8613 (function (lambda (s _e _p)
8715 (if (memq (get-text-property s 'REx-interpolated) skip) 8614 (if (memq (get-text-property s 'REx-interpolated) skip)
8716 t 8615 t
8717 (setq pp s) 8616 (setq pp s)
@@ -8721,26 +8620,26 @@ a result of qr//, this is not a performance hit), t for the rest."
8721 (message "No more interpolated REx")))) 8620 (message "No more interpolated REx"))))
8722 8621
8723;;; Initial version contributed by Trey Belew 8622;;; Initial version contributed by Trey Belew
8724(defun cperl-here-doc-spell (&optional beg end) 8623(defun cperl-here-doc-spell ()
8725 "Spell-check HERE-documents in the Perl buffer. 8624 "Spell-check HERE-documents in the Perl buffer.
8726If a region is highlighted, restricts to the region." 8625If a region is highlighted, restricts to the region."
8727 (interactive "") 8626 (interactive)
8728 (cperl-pod-spell t beg end)) 8627 (cperl-pod-spell t))
8729 8628
8730(defun cperl-pod-spell (&optional do-heres beg end) 8629(defun cperl-pod-spell (&optional do-heres)
8731 "Spell-check POD documentation. 8630 "Spell-check POD documentation.
8732If invoked with prefix argument, will do HERE-DOCs instead. 8631If invoked with prefix argument, will do HERE-DOCs instead.
8733If a region is highlighted, restricts to the region." 8632If a region is highlighted, restricts to the region."
8734 (interactive "P") 8633 (interactive "P")
8735 (save-excursion 8634 (save-excursion
8736 (let (beg end) 8635 (let (beg end)
8737 (if (cperl-mark-active) 8636 (if (region-active-p)
8738 (setq beg (min (mark) (point)) 8637 (setq beg (min (mark) (point))
8739 end (max (mark) (point))) 8638 end (max (mark) (point)))
8740 (setq beg (point-min) 8639 (setq beg (point-min)
8741 end (point-max))) 8640 end (point-max)))
8742 (cperl-map-pods-heres (function 8641 (cperl-map-pods-heres (function
8743 (lambda (s e p) 8642 (lambda (s e _p)
8744 (if do-heres 8643 (if do-heres
8745 (setq e (save-excursion 8644 (setq e (save-excursion
8746 (goto-char e) 8645 (goto-char e)
@@ -8805,7 +8704,7 @@ POS defaults to the point."
8805 (push-mark (cdr p) nil t)) ; Message, activate in transient-mode 8704 (push-mark (cdr p) nil t)) ; Message, activate in transient-mode
8806 (message "I do not think POS is in POD or a HERE-doc...")))) 8705 (message "I do not think POS is in POD or a HERE-doc..."))))
8807 8706
8808(defun cperl-facemenu-add-face-function (face end) 8707(defun cperl-facemenu-add-face-function (face _end)
8809 "A callback to process user-initiated font-change requests. 8708 "A callback to process user-initiated font-change requests.
8810Translates `bold', `italic', and `bold-italic' requests to insertion of 8709Translates `bold', `italic', and `bold-italic' requests to insertion of
8811corresponding POD directives, and `underline' to C<> POD directive. 8710corresponding POD directives, and `underline' to C<> POD directive.
@@ -8818,7 +8717,7 @@ Such requests are usually bound to M-o LETTER."
8818 (italic . "I<") 8717 (italic . "I<")
8819 (bold-italic . "B<I<") 8718 (bold-italic . "B<I<")
8820 (underline . "C<"))) 8719 (underline . "C<")))
8821 (error "Face %s not configured for cperl-mode" 8720 (error "Face %S not configured for cperl-mode"
8822 face)))) 8721 face))))
8823 8722
8824(defun cperl-time-fontification (&optional l step lim) 8723(defun cperl-time-fontification (&optional l step lim)
@@ -8881,61 +8780,52 @@ may be used to debug problems with delayed incremental fontification."
8881 (setq pos p)))) 8780 (setq pos p))))
8882 8781
8883 8782
8884(defun cperl-lazy-install ()) ; Avoid a warning 8783(defvar cperl-help-shown nil
8885(defun cperl-lazy-unstall ()) ; Avoid a warning 8784 "Non-nil means that the help was already shown now.")
8886
8887(if (fboundp 'run-with-idle-timer)
8888 (progn
8889 (defvar cperl-help-shown nil
8890 "Non-nil means that the help was already shown now.")
8891 8785
8892 (defvar cperl-lazy-installed nil 8786(defvar cperl-lazy-installed nil
8893 "Non-nil means that the lazy-help handlers are installed now.") 8787 "Non-nil means that the lazy-help handlers are installed now.")
8894 8788
8895 (defun cperl-lazy-install () 8789;; FIXME: Use eldoc?
8896 "Switches on Auto-Help on Perl constructs (put in the message area). 8790(defun cperl-lazy-install ()
8791 "Switch on Auto-Help on Perl constructs (put in the message area).
8897Delay of auto-help controlled by `cperl-lazy-help-time'." 8792Delay of auto-help controlled by `cperl-lazy-help-time'."
8898 (interactive) 8793 (interactive)
8899 (make-local-variable 'cperl-help-shown) 8794 (make-local-variable 'cperl-help-shown)
8900 (if (and (cperl-val 'cperl-lazy-help-time) 8795 (if (and (cperl-val 'cperl-lazy-help-time)
8901 (not cperl-lazy-installed)) 8796 (not cperl-lazy-installed))
8902 (progn 8797 (progn
8903 (add-hook 'post-command-hook 'cperl-lazy-hook) 8798 (add-hook 'post-command-hook #'cperl-lazy-hook)
8904 (run-with-idle-timer 8799 (run-with-idle-timer
8905 (cperl-val 'cperl-lazy-help-time 1000000 5) 8800 (cperl-val 'cperl-lazy-help-time 1000000 5)
8906 t 8801 t
8907 'cperl-get-help-defer) 8802 #'cperl-get-help-defer)
8908 (setq cperl-lazy-installed t)))) 8803 (setq cperl-lazy-installed t))))
8909 8804
8910 (defun cperl-lazy-unstall () 8805(defun cperl-lazy-unstall ()
8911 "Switches off Auto-Help on Perl constructs (put in the message area). 8806 "Switch off Auto-Help on Perl constructs (put in the message area).
8912Delay of auto-help controlled by `cperl-lazy-help-time'." 8807Delay of auto-help controlled by `cperl-lazy-help-time'."
8913 (interactive) 8808 (interactive)
8914 (remove-hook 'post-command-hook 'cperl-lazy-hook) 8809 (remove-hook 'post-command-hook #'cperl-lazy-hook)
8915 (cancel-function-timers 'cperl-get-help-defer) 8810 (cancel-function-timers #'cperl-get-help-defer)
8916 (setq cperl-lazy-installed nil)) 8811 (setq cperl-lazy-installed nil))
8917 8812
8918 (defun cperl-lazy-hook () 8813(defun cperl-lazy-hook ()
8919 (setq cperl-help-shown nil)) 8814 (setq cperl-help-shown nil))
8920 8815
8921 (defun cperl-get-help-defer () 8816(defun cperl-get-help-defer ()
8922 (if (not (memq major-mode '(perl-mode cperl-mode))) nil 8817 (if (not (memq major-mode '(perl-mode cperl-mode))) nil
8923 (let ((cperl-message-on-help-error nil) (cperl-help-from-timer t)) 8818 (let ((cperl-message-on-help-error nil) (cperl-help-from-timer t))
8924 (cperl-get-help) 8819 (cperl-get-help)
8925 (setq cperl-help-shown t)))) 8820 (setq cperl-help-shown t))))
8926 (cperl-lazy-install))) 8821(cperl-lazy-install)
8927 8822
8928 8823
8929;;; Plug for wrong font-lock: 8824;;; Plug for wrong font-lock:
8930 8825
8931(defun cperl-font-lock-unfontify-region-function (beg end) 8826(defun cperl-font-lock-unfontify-region-function (beg end)
8932 (let* ((modified (buffer-modified-p)) (buffer-undo-list t) 8827 (with-silent-modifications
8933 (inhibit-read-only t) (inhibit-point-motion-hooks t) 8828 (remove-text-properties beg end '(face nil))))
8934 (inhibit-modification-hooks t)
8935 deactivate-mark buffer-file-name buffer-file-truename)
8936 (remove-text-properties beg end '(face nil))
8937 (if (and (not modified) (buffer-modified-p))
8938 (set-buffer-modified-p nil))))
8939 8829
8940(defun cperl-font-lock-fontify-region-function (beg end loudly) 8830(defun cperl-font-lock-fontify-region-function (beg end loudly)
8941 "Extends the region to safe positions, then calls the default function. 8831 "Extends the region to safe positions, then calls the default function.
@@ -8967,6 +8857,7 @@ do extra unwind via `cperl-unwind-to-safe'."
8967 (font-lock-default-fontify-region beg end loudly)) 8857 (font-lock-default-fontify-region beg end loudly))
8968 8858
8969(defvar cperl-d-l nil) 8859(defvar cperl-d-l nil)
8860(defvar edebug-backtrace-buffer)
8970(defun cperl-fontify-syntaxically (end) 8861(defun cperl-fontify-syntaxically (end)
8971 ;; Some vars for debugging only 8862 ;; Some vars for debugging only
8972 ;; (message "Syntaxifying...") 8863 ;; (message "Syntaxifying...")
@@ -9027,7 +8918,7 @@ do extra unwind via `cperl-unwind-to-safe'."
9027 nil) ; Do not iterate 8918 nil) ; Do not iterate
9028 8919
9029;; Called when any modification is made to buffer text. 8920;; Called when any modification is made to buffer text.
9030(defun cperl-after-change-function (beg end old-len) 8921(defun cperl-after-change-function (beg _end _old-len)
9031 ;; We should have been informed about changes by `font-lock'. Since it 8922 ;; We should have been informed about changes by `font-lock'. Since it
9032 ;; does not inform as which calls are deferred, do it ourselves 8923 ;; does not inform as which calls are deferred, do it ourselves
9033 (if cperl-syntax-done-to 8924 (if cperl-syntax-done-to