aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2017-12-22 10:06:49 -0500
committerStefan Monnier2017-12-22 10:06:49 -0500
commit168382db92d7ab9b8d7997b0bb91165b338e41e6 (patch)
treecb37cebca09265cf42cd5673b6e854d6e0b660bd
parentf6e6f5937356158287e1095a8e51422a5cbd2abc (diff)
downloademacs-168382db92d7ab9b8d7997b0bb91165b338e41e6.tar.gz
emacs-168382db92d7ab9b8d7997b0bb91165b338e41e6.zip
* lisp/progmodes/cperl-mode.el: Use cl-lib. Fix comment convention
(defgroup, defcustom, defface, x-color-defined-p, uncomment-region) (ps-extend-face-list, eval-after-load, turn-on-font-lock): Assume defined. (cperl-calculate-indent): Use 'functionp' to test if a value is a function.
-rw-r--r--lisp/progmodes/cperl-mode.el343
1 files changed, 143 insertions, 200 deletions
diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el
index 64ee8c1b7e6..c4f1ff2ec76 100644
--- a/lisp/progmodes/cperl-mode.el
+++ b/lisp/progmodes/cperl-mode.el
@@ -23,7 +23,7 @@
23;; You should have received a copy of the GNU General Public License 23;; You should have received a copy of the GNU General Public License
24;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. 24;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
25 25
26;;; Corrections made by Ilya Zakharevich ilyaz@cpan.org 26;; Corrections made by Ilya Zakharevich ilyaz@cpan.org
27 27
28;;; Commentary: 28;;; Commentary:
29 29
@@ -66,7 +66,7 @@
66 66
67;; (define-key global-map [M-S-down-mouse-3] 'imenu) 67;; (define-key global-map [M-S-down-mouse-3] 'imenu)
68 68
69;;; Font lock bugs as of v4.32: 69;;;; Font lock bugs as of v4.32:
70 70
71;; The following kinds of Perl code erroneously start strings: 71;; The following kinds of Perl code erroneously start strings:
72;; \$` \$' \$" 72;; \$` \$' \$"
@@ -75,6 +75,8 @@
75 75
76;;; Code: 76;;; Code:
77 77
78(eval-when-compile (require 'cl-lib))
79
78(defvar vc-rcs-header) 80(defvar vc-rcs-header)
79(defvar vc-sccs-header) 81(defvar vc-sccs-header)
80 82
@@ -90,24 +92,6 @@
90 (defvar font-lock-background-mode) ; not in Emacs 92 (defvar font-lock-background-mode) ; not in Emacs
91 (defvar font-lock-display-type) ; ditto 93 (defvar font-lock-display-type) ; ditto
92 (defvar paren-backwards-message) ; Not in newer XEmacs? 94 (defvar paren-backwards-message) ; Not in newer XEmacs?
93 (or (fboundp 'defgroup)
94 (defmacro defgroup (_name _val _doc &rest _)
95 nil))
96 (or (fboundp 'custom-declare-variable)
97 (defmacro defcustom (name val doc &rest _)
98 `(defvar ,name ,val ,doc)))
99 (or (fboundp 'custom-declare-variable)
100 (defmacro defface (&rest _)
101 nil))
102 ;; Avoid warning (tmp definitions)
103 (or (fboundp 'x-color-defined-p)
104 (defmacro x-color-defined-p (col)
105 (cond ((fboundp 'color-defined-p) `(color-defined-p ,col))
106 ;; XEmacs >= 19.12
107 ((fboundp 'valid-color-name-p) `(valid-color-name-p ,col))
108 ;; XEmacs 19.11
109 ((fboundp 'x-valid-color-name-p) `(x-valid-color-name-p ,col))
110 (t '(error "Cannot implement color-defined-p")))))
111 (defmacro cperl-is-face (arg) ; Takes quoted arg 95 (defmacro cperl-is-face (arg) ; Takes quoted arg
112 (cond ((fboundp 'find-face) 96 (cond ((fboundp 'find-face)
113 `(find-face ,arg)) 97 `(find-face ,arg))
@@ -224,10 +208,10 @@ for constructs with multiline if/unless/while/until/for/foreach condition."
224 :type 'integer 208 :type 'integer
225 :group 'cperl-indentation-details) 209 :group 'cperl-indentation-details)
226 210
227;; Is is not unusual to put both things like perl-indent-level and 211;; It is not unusual to put both things like perl-indent-level and
228;; cperl-indent-level in the local variable section of a file. If only 212;; cperl-indent-level in the local variable section of a file. If only
229;; one of perl-mode and cperl-mode is in use, a warning will be issued 213;; one of perl-mode and cperl-mode is in use, a warning will be issued
230;; about the variable. Autoload these here, so that no warning is 214;; about the variable. Autoload these here, so that no warning is
231;; issued when using either perl-mode or cperl-mode. 215;; issued when using either perl-mode or cperl-mode.
232;;;###autoload(put 'cperl-indent-level 'safe-local-variable 'integerp) 216;;;###autoload(put 'cperl-indent-level 'safe-local-variable 'integerp)
233;;;###autoload(put 'cperl-brace-offset 'safe-local-variable 'integerp) 217;;;###autoload(put 'cperl-brace-offset 'safe-local-variable 'integerp)
@@ -459,7 +443,7 @@ Font for POD headers."
459 :type 'face 443 :type 'face
460 :group 'cperl-faces) 444 :group 'cperl-faces)
461 445
462;;; Some double-evaluation happened with font-locks... Needed with 21.2... 446;; Some double-evaluation happened with font-locks... Needed with 21.2...
463(defvar cperl-singly-quote-face (featurep 'xemacs)) 447(defvar cperl-singly-quote-face (featurep 'xemacs))
464 448
465(defcustom cperl-invalid-face 'underline 449(defcustom cperl-invalid-face 'underline
@@ -1017,11 +1001,6 @@ In regular expressions (including character classes):
1017 (defun cperl-putback-char (c) ; XEmacs >= 19.12 1001 (defun cperl-putback-char (c) ; XEmacs >= 19.12
1018 (push (character-to-event c) unread-command-events))) 1002 (push (character-to-event c) unread-command-events)))
1019 1003
1020(or (fboundp 'uncomment-region)
1021 (defun uncomment-region (beg end)
1022 (interactive "r")
1023 (comment-region beg end -1)))
1024
1025(defvar cperl-do-not-fontify 1004(defvar cperl-do-not-fontify
1026 ;; FIXME: This is not doing what it claims! 1005 ;; FIXME: This is not doing what it claims!
1027 (if (string< emacs-version "19.30") 1006 (if (string< emacs-version "19.30")
@@ -1079,20 +1058,7 @@ versions of Emacs."
1079;; (setq interpreter-mode-alist (append interpreter-mode-alist 1058;; (setq interpreter-mode-alist (append interpreter-mode-alist
1080;; '(("miniperl" . perl-mode)))))) 1059;; '(("miniperl" . perl-mode))))))
1081(eval-when-compile 1060(eval-when-compile
1082 (mapc (lambda (p) 1061 (mapc #'require '(imenu easymenu etags timer man info)))
1083 (condition-case nil
1084 (require p)
1085 (error nil)))
1086 '(imenu easymenu etags timer man info))
1087 (if (fboundp 'ps-extend-face-list)
1088 (defmacro cperl-ps-extend-face-list (arg)
1089 `(ps-extend-face-list ,arg))
1090 (defmacro cperl-ps-extend-face-list (_)
1091 `(error "This version of Emacs has no `ps-extend-face-list'")))
1092 ;; Calling `cperl-enable-font-lock' below doesn't compile on XEmacs,
1093 ;; macros instead of defsubsts don't work on Emacs, so we do the
1094 ;; expansion manually. Any other suggestions?
1095 (require 'cl))
1096 1062
1097(define-abbrev-table 'cperl-mode-abbrev-table 1063(define-abbrev-table 'cperl-mode-abbrev-table
1098 ;; FIXME: Use a separate abbrev table for that, enabled conditionally, 1064 ;; FIXME: Use a separate abbrev table for that, enabled conditionally,
@@ -1299,15 +1265,15 @@ versions of Emacs."
1299 ["Class Hierarchy from TAGS" cperl-tags-hier-init t] 1265 ["Class Hierarchy from TAGS" cperl-tags-hier-init t]
1300 ;;["Update classes" (cperl-tags-hier-init t) tags-table-list] 1266 ;;["Update classes" (cperl-tags-hier-init t) tags-table-list]
1301 ("Tags" 1267 ("Tags"
1302;;; ["Create tags for current file" cperl-etags t] 1268 ;; ["Create tags for current file" cperl-etags t]
1303;;; ["Add tags for current file" (cperl-etags t) t] 1269 ;; ["Add tags for current file" (cperl-etags t) t]
1304;;; ["Create tags for Perl files in directory" (cperl-etags nil t) t] 1270 ;; ["Create tags for Perl files in directory" (cperl-etags nil t) t]
1305;;; ["Add tags for Perl files in directory" (cperl-etags t t) t] 1271 ;; ["Add tags for Perl files in directory" (cperl-etags t t) t]
1306;;; ["Create tags for Perl files in (sub)directories" 1272 ;; ["Create tags for Perl files in (sub)directories"
1307;;; (cperl-etags nil 'recursive) t] 1273 ;; (cperl-etags nil 'recursive) t]
1308;;; ["Add tags for Perl files in (sub)directories" 1274 ;; ["Add tags for Perl files in (sub)directories"
1309;;; (cperl-etags t 'recursive) t]) 1275 ;; (cperl-etags t 'recursive) t])
1310;;;; cperl-write-tags (&optional file erase recurse dir inbuffer) 1276 ;; ;;? cperl-write-tags (&optional file erase recurse dir inbuffer)
1311 ["Create tags for current file" (cperl-write-tags nil t) t] 1277 ["Create tags for current file" (cperl-write-tags nil t) t]
1312 ["Add tags for current file" (cperl-write-tags) t] 1278 ["Add tags for current file" (cperl-write-tags) t]
1313 ["Create tags for Perl files in directory" 1279 ["Create tags for Perl files in directory"
@@ -1366,12 +1332,12 @@ versions of Emacs."
1366The expansion is entirely correct because it uses the C preprocessor." 1332The expansion is entirely correct because it uses the C preprocessor."
1367 t) 1333 t)
1368 1334
1369;;; These two must be unwound, otherwise take exponential time 1335;; These two must be unwound, otherwise take exponential time
1370(defconst cperl-maybe-white-and-comment-rex "[ \t\n]*\\(#[^\n]*\n[ \t\n]*\\)*" 1336(defconst cperl-maybe-white-and-comment-rex "[ \t\n]*\\(#[^\n]*\n[ \t\n]*\\)*"
1371"Regular expression to match optional whitespace with interspersed comments. 1337"Regular expression to match optional whitespace with interspersed comments.
1372Should contain exactly one group.") 1338Should contain exactly one group.")
1373 1339
1374;;; This one is tricky to unwind; still very inefficient... 1340;; This one is tricky to unwind; still very inefficient...
1375(defconst cperl-white-and-comment-rex "\\([ \t\n]\\|#[^\n]*\n\\)+" 1341(defconst cperl-white-and-comment-rex "\\([ \t\n]\\|#[^\n]*\n\\)+"
1376"Regular expression to match whitespace with interspersed comments. 1342"Regular expression to match whitespace with interspersed comments.
1377Should contain exactly one group.") 1343Should contain exactly one group.")
@@ -1425,13 +1391,13 @@ the last)."
1425 1391
1426(defun cperl-char-ends-sub-keyword-p (char) 1392(defun cperl-char-ends-sub-keyword-p (char)
1427 "Return T if CHAR is the last character of a perl sub keyword." 1393 "Return T if CHAR is the last character of a perl sub keyword."
1428 (loop for keyword in cperl-sub-keywords 1394 (cl-loop for keyword in cperl-sub-keywords
1429 when (eq char (aref keyword (1- (length keyword)))) 1395 when (eq char (aref keyword (1- (length keyword))))
1430 return t)) 1396 return t))
1431 1397
1432;;; Details of groups in this are used in `cperl-imenu--create-perl-index' 1398;; Details of groups in this are used in `cperl-imenu--create-perl-index'
1433;;; and `cperl-outline-level'. 1399;; and `cperl-outline-level'.
1434;;;; Was: 2=sub|package; now 2=package-group, 5=package-name 8=sub-name (+3) 1400;; Was: 2=sub|package; now 2=package-group, 5=package-name 8=sub-name (+3)
1435(defvar cperl-imenu--function-name-regexp-perl 1401(defvar cperl-imenu--function-name-regexp-perl
1436 (concat 1402 (concat
1437 "^\\(" ; 1 = all 1403 "^\\(" ; 1 = all
@@ -1914,24 +1880,24 @@ or as help on variables `cperl-tips', `cperl-problems',
1914 (cperl-make-indent comment-column 1) ; Indent min 1 1880 (cperl-make-indent comment-column 1) ; Indent min 1
1915 c))))) 1881 c)))))
1916 1882
1917;;;(defun cperl-comment-indent-fallback () 1883;;(defun cperl-comment-indent-fallback ()
1918;;; "Is called if the standard comment-search procedure fails. 1884;; "Is called if the standard comment-search procedure fails.
1919;;;Point is at start of real comment." 1885;;Point is at start of real comment."
1920;;; (let ((c (current-column)) target cnt prevc) 1886;; (let ((c (current-column)) target cnt prevc)
1921;;; (if (= c comment-column) nil 1887;; (if (= c comment-column) nil
1922;;; (setq cnt (skip-chars-backward "[ \t]")) 1888;; (setq cnt (skip-chars-backward "[ \t]"))
1923;;; (setq target (max (1+ (setq prevc 1889;; (setq target (max (1+ (setq prevc
1924;;; (current-column))) ; Else indent at comment column 1890;; (current-column))) ; Else indent at comment column
1925;;; comment-column)) 1891;; comment-column))
1926;;; (if (= c comment-column) nil 1892;; (if (= c comment-column) nil
1927;;; (delete-backward-char cnt) 1893;; (delete-backward-char cnt)
1928;;; (while (< prevc target) 1894;; (while (< prevc target)
1929;;; (insert "\t") 1895;; (insert "\t")
1930;;; (setq prevc (current-column))) 1896;; (setq prevc (current-column)))
1931;;; (if (> prevc target) (progn (delete-char -1) (setq prevc (current-column)))) 1897;; (if (> prevc target) (progn (delete-char -1) (setq prevc (current-column))))
1932;;; (while (< prevc target) 1898;; (while (< prevc target)
1933;;; (insert " ") 1899;; (insert " ")
1934;;; (setq prevc (current-column))))))) 1900;; (setq prevc (current-column)))))))
1935 1901
1936(defun cperl-indent-for-comment () 1902(defun cperl-indent-for-comment ()
1937 "Substitute for `indent-for-comment' in CPerl." 1903 "Substitute for `indent-for-comment' in CPerl."
@@ -2647,17 +2613,17 @@ PRESTART is the position basing on which START was found."
2647(defun cperl-beginning-of-property (p prop &optional lim) 2613(defun cperl-beginning-of-property (p prop &optional lim)
2648 "Given that P has a property PROP, find where the property starts. 2614 "Given that P has a property PROP, find where the property starts.
2649Will not look before LIM." 2615Will not look before LIM."
2650 ;;; XXXX What to do at point-max??? 2616;;; XXXX What to do at point-max???
2651 (or (previous-single-property-change (cperl-1+ p) prop lim) 2617 (or (previous-single-property-change (cperl-1+ p) prop lim)
2652 (point-min)) 2618 (point-min))
2653;;; (cond ((eq p (point-min)) 2619 ;; (cond ((eq p (point-min))
2654;;; p) 2620 ;; p)
2655;;; ((and lim (<= p lim)) 2621 ;; ((and lim (<= p lim))
2656;;; p) 2622 ;; p)
2657;;; ((not (get-text-property (1- p) prop)) 2623 ;; ((not (get-text-property (1- p) prop))
2658;;; p) 2624 ;; p)
2659;;; (t (or (previous-single-property-change p look-prop lim) 2625 ;; (t (or (previous-single-property-change p look-prop lim)
2660;;; (point-min)))) 2626 ;; (point-min))))
2661 ) 2627 )
2662 2628
2663(defun cperl-sniff-for-indent (&optional parse-data) ; was parse-start 2629(defun cperl-sniff-for-indent (&optional parse-data) ; was parse-start
@@ -2968,7 +2934,7 @@ and closing parentheses and brackets."
2968 (cond 2934 (cond
2969 (what 2935 (what
2970 (let ((action (cadr what))) 2936 (let ((action (cadr what)))
2971 (cond ((fboundp action) (apply action (list i parse-data))) 2937 (cond ((functionp action) (apply action (list i parse-data)))
2972 ((numberp action) (+ action (current-indentation))) 2938 ((numberp action) (+ action (current-indentation)))
2973 (t action)))) 2939 (t action))))
2974 ;; 2940 ;;
@@ -3392,8 +3358,8 @@ Works before syntax recognition is done."
3392 (or now (put-text-property b e 'cperl-postpone (cons type val))) 3358 (or now (put-text-property b e 'cperl-postpone (cons type val)))
3393 (put-text-property b e type val))) 3359 (put-text-property b e type val)))
3394 3360
3395;;; Here is how the global structures (those which cannot be 3361;; Here is how the global structures (those which cannot be
3396;;; recognized locally) are marked: 3362;; recognized locally) are marked:
3397;; a) PODs: 3363;; a) PODs:
3398;; Start-to-end is marked `in-pod' ==> t 3364;; Start-to-end is marked `in-pod' ==> t
3399;; Each non-literal part is marked `syntax-type' ==> `pod' 3365;; Each non-literal part is marked `syntax-type' ==> `pod'
@@ -3413,8 +3379,8 @@ Works before syntax recognition is done."
3413;; (or 0 if declaration); up to `{' or ';': `syntax-type' => `sub-decl'. 3379;; (or 0 if declaration); up to `{' or ';': `syntax-type' => `sub-decl'.
3414;; f) Multiline my/our declaration lists etc: `syntax-type' => `multiline' 3380;; f) Multiline my/our declaration lists etc: `syntax-type' => `multiline'
3415 3381
3416;;; In addition, some parts of RExes may be marked as `REx-interpolated' 3382;; In addition, some parts of RExes may be marked as `REx-interpolated'
3417;;; (value: 0 in //o, 1 if "interpolated variable" is whole-REx, t otherwise). 3383;; (value: 0 in //o, 1 if "interpolated variable" is whole-REx, t otherwise).
3418 3384
3419(defun cperl-unwind-to-safe (before &optional end) 3385(defun cperl-unwind-to-safe (before &optional end)
3420 ;; if BEFORE, go to the previous start-of-line on each step of unwinding 3386 ;; if BEFORE, go to the previous start-of-line on each step of unwinding
@@ -3451,7 +3417,7 @@ Works before syntax recognition is done."
3451 (setq end (point))))) 3417 (setq end (point)))))
3452 (or end pos))))) 3418 (or end pos)))))
3453 3419
3454;;; These are needed for byte-compile (at least with v19) 3420;; These are needed for byte-compile (at least with v19)
3455(defvar cperl-nonoverridable-face) 3421(defvar cperl-nonoverridable-face)
3456(defvar font-lock-variable-name-face) 3422(defvar font-lock-variable-name-face)
3457(defvar font-lock-function-name-face) 3423(defvar font-lock-function-name-face)
@@ -3586,7 +3552,7 @@ Should be called with the point before leading colon of an attribute."
3586 (goto-char endbracket) ; just in case something misbehaves??? 3552 (goto-char endbracket) ; just in case something misbehaves???
3587 t)) 3553 t))
3588 3554
3589;;; Debugging this may require (setq max-specpdl-size 2000)... 3555;; Debugging this may require (setq max-specpdl-size 2000)...
3590(defun cperl-find-pods-heres (&optional min max non-inter end ignore-max end-of-here-doc) 3556(defun cperl-find-pods-heres (&optional min max non-inter end ignore-max end-of-here-doc)
3591 "Scans the buffer for hard-to-parse Perl constructions. 3557 "Scans the buffer for hard-to-parse Perl constructions.
3592If `cperl-pod-here-fontify' is not-nil after evaluation, will fontify 3558If `cperl-pod-here-fontify' is not-nil after evaluation, will fontify
@@ -4489,7 +4455,7 @@ the sections using `cperl-pod-head-face', `cperl-pod-face',
4489 (setq REx-subgr-end qtag) ;End smart-highlighted 4455 (setq REx-subgr-end qtag) ;End smart-highlighted
4490 ;; Apparently, I can't put \] into a charclass 4456 ;; Apparently, I can't put \] into a charclass
4491 ;; in m]]: m][\\\]\]] produces [\\]] 4457 ;; in m]]: m][\\\]\]] produces [\\]]
4492;;; POSIX? [:word:] [:^word:] only inside [] 4458;;; POSIX? [:word:] [:^word:] only inside []
4493;;; "\\=\\(\\\\.\\|[^][\\\\]\\|\\[:\\^?\sw+:]\\|\\[[^:]\\)*]") 4459;;; "\\=\\(\\\\.\\|[^][\\\\]\\|\\[:\\^?\sw+:]\\|\\[[^:]\\)*]")
4494 (while ; look for unescaped ] 4460 (while ; look for unescaped ]
4495 (and argument 4461 (and argument
@@ -4769,12 +4735,12 @@ the sections using `cperl-pod-head-face', `cperl-pod-face',
4769 (forward-sexp -1) 4735 (forward-sexp -1)
4770 (looking-at (concat cperl-sub-regexp "[ \t\n\f#]")))))))))) 4736 (looking-at (concat cperl-sub-regexp "[ \t\n\f#]"))))))))))
4771 4737
4772;;; What is the difference of (cperl-after-block-p lim t) and (cperl-block-p)? 4738;; What is the difference of (cperl-after-block-p lim t) and (cperl-block-p)?
4773;;; No save-excursion; condition-case ... In (cperl-block-p) the block 4739;; No save-excursion; condition-case ... In (cperl-block-p) the block
4774;;; may be a part of an in-statement construct, such as 4740;; may be a part of an in-statement construct, such as
4775;;; ${something()}, print {FH} $data. 4741;; ${something()}, print {FH} $data.
4776;;; Moreover, one takes positive approach (looks for else,grep etc) 4742;; Moreover, one takes positive approach (looks for else,grep etc)
4777;;; another negative (looks for bless,tr etc) 4743;; another negative (looks for bless,tr etc)
4778(defun cperl-after-block-p (lim &optional pre-block) 4744(defun cperl-after-block-p (lim &optional pre-block)
4779 "Return true if the preceding } (if PRE-BLOCK, following {) delimits a block. 4745 "Return true if the preceding } (if PRE-BLOCK, following {) delimits a block.
4780Would not look before LIM. Assumes that LIM is a good place to begin a 4746Would not look before LIM. Assumes that LIM is a good place to begin a
@@ -5551,7 +5517,7 @@ indentation and initial hashes. Behaves usually outside of comment."
5551(defun cperl-outline-level () 5517(defun cperl-outline-level ()
5552 (looking-at outline-regexp) 5518 (looking-at outline-regexp)
5553 (cond ((not (match-beginning 1)) 0) ; beginning-of-file 5519 (cond ((not (match-beginning 1)) 0) ; beginning-of-file
5554;;;; 2=package-group, 5=package-name 8=sub-name 16=head-level 5520 ;; 2=package-group, 5=package-name 8=sub-name 16=head-level
5555 ((match-beginning 2) 0) ; package 5521 ((match-beginning 2) 0) ; package
5556 ((match-beginning 8) 1) ; sub 5522 ((match-beginning 8) 1) ; sub
5557 ((match-beginning 16) 5523 ((match-beginning 16)
@@ -5574,10 +5540,9 @@ indentation and initial hashes. Behaves usually outside of comment."
5574 (if (memq major-mode '(perl-mode cperl-mode)) 5540 (if (memq major-mode '(perl-mode cperl-mode))
5575 (progn 5541 (progn
5576 (or cperl-faces-init (cperl-init-faces))))))) 5542 (or cperl-faces-init (cperl-init-faces)))))))
5577 (if (fboundp 'eval-after-load) 5543 (eval-after-load
5578 (eval-after-load 5544 "ps-print"
5579 "ps-print" 5545 '(or cperl-faces-init (cperl-init-faces))))))
5580 '(or cperl-faces-init (cperl-init-faces)))))))
5581 5546
5582(defvar cperl-font-lock-keywords-1 nil 5547(defvar cperl-font-lock-keywords-1 nil
5583 "Additional expressions to highlight in Perl mode. Minimal set.") 5548 "Additional expressions to highlight in Perl mode. Minimal set.")
@@ -5626,6 +5591,7 @@ indentation and initial hashes. Behaves usually outside of comment."
5626 (cons 5591 (cons
5627 (concat 5592 (concat
5628 "\\(^\\|[^$@%&\\]\\)\\<\\(" 5593 "\\(^\\|[^$@%&\\]\\)\\<\\("
5594 ;; FIXME: Use regexp-opt.
5629 (mapconcat 5595 (mapconcat
5630 #'identity 5596 #'identity
5631 (append 5597 (append
@@ -5647,6 +5613,7 @@ indentation and initial hashes. Behaves usually outside of comment."
5647 (list 5613 (list
5648 (concat 5614 (concat
5649 "\\(^\\|[^$@%&\\]\\)\\<\\(" 5615 "\\(^\\|[^$@%&\\]\\)\\<\\("
5616 ;; FIXME: Use regexp-opt.
5650 ;; "CORE" "__FILE__" "__LINE__" "__SUB__" "abs" "accept" "alarm" 5617 ;; "CORE" "__FILE__" "__LINE__" "__SUB__" "abs" "accept" "alarm"
5651 ;; "and" "atan2" "bind" "binmode" "bless" "caller" 5618 ;; "and" "atan2" "bind" "binmode" "bless" "caller"
5652 ;; "chdir" "chmod" "chown" "chr" "chroot" "close" 5619 ;; "chdir" "chmod" "chown" "chr" "chroot" "close"
@@ -5863,41 +5830,34 @@ indentation and initial hashes. Behaves usually outside of comment."
5863 '("\\[\\(\\^\\)" 1 font-lock-negation-char-face prepend))) 5830 '("\\[\\(\\^\\)" 1 font-lock-negation-char-face prepend)))
5864 (setq 5831 (setq
5865 t-font-lock-keywords-1 5832 t-font-lock-keywords-1
5866 (and (fboundp 'turn-on-font-lock) ; Check for newer font-lock 5833 '(
5867 ;; not yet as of XEmacs 19.12, works with 21.1.11 5834 ("\\(\\([@%]\\|\\$#\\)[a-zA-Z_:][a-zA-Z0-9_:]*\\)" 1
5868 (or 5835 (if (eq (char-after (match-beginning 2)) ?%)
5869 (not (featurep 'xemacs)) 5836 'cperl-hash-face
5870 (string< "21.1.9" emacs-version) 5837 'cperl-array-face)
5871 (and (string< "21.1.10" emacs-version) 5838 t) ; arrays and hashes
5872 (string< emacs-version "21.1.2"))) 5839 ("\\(\\([$@]+\\)[a-zA-Z_:][a-zA-Z0-9_:]*\\)[ \t]*\\([[{]\\)"
5873 '( 5840 1
5874 ("\\(\\([@%]\\|\\$#\\)[a-zA-Z_:][a-zA-Z0-9_:]*\\)" 1 5841 (if (= (- (match-end 2) (match-beginning 2)) 1)
5875 (if (eq (char-after (match-beginning 2)) ?%) 5842 (if (eq (char-after (match-beginning 3)) ?{)
5876 'cperl-hash-face 5843 'cperl-hash-face
5877 'cperl-array-face) 5844 'cperl-array-face) ; arrays and hashes
5878 t) ; arrays and hashes 5845 font-lock-variable-name-face) ; Just to put something
5879 ("\\(\\([$@]+\\)[a-zA-Z_:][a-zA-Z0-9_:]*\\)[ \t]*\\([[{]\\)" 5846 t)
5880 1 5847 ("\\(@\\|\\$#\\)\\(\\$+\\([a-zA-Z_:][a-zA-Z0-9_:]*\\|[^ \t\n]\\)\\)"
5881 (if (= (- (match-end 2) (match-beginning 2)) 1) 5848 (1 cperl-array-face)
5882 (if (eq (char-after (match-beginning 3)) ?{) 5849 (2 font-lock-variable-name-face))
5883 'cperl-hash-face 5850 ("\\(%\\)\\(\\$+\\([a-zA-Z_:][a-zA-Z0-9_:]*\\|[^ \t\n]\\)\\)"
5884 'cperl-array-face) ; arrays and hashes 5851 (1 cperl-hash-face)
5885 font-lock-variable-name-face) ; Just to put something 5852 (2 font-lock-variable-name-face))
5886 t) 5853;;("\\([smy]\\|tr\\)\\([^a-z_A-Z0-9]\\)\\(\\([^\n\\]*||\\)\\)\\2")
5887 ("\\(@\\|\\$#\\)\\(\\$+\\([a-zA-Z_:][a-zA-Z0-9_:]*\\|[^ \t\n]\\)\\)" 5854;;; Too much noise from \s* @s[ and friends
5888 (1 cperl-array-face) 5855 ;;("\\(\\<\\([msy]\\|tr\\)[ \t]*\\([^ \t\na-zA-Z0-9_]\\)\\|\\(/\\)\\)"
5889 (2 font-lock-variable-name-face)) 5856 ;;(3 font-lock-function-name-face t t)
5890 ("\\(%\\)\\(\\$+\\([a-zA-Z_:][a-zA-Z0-9_:]*\\|[^ \t\n]\\)\\)" 5857 ;;(4
5891 (1 cperl-hash-face) 5858 ;; (if (cperl-slash-is-regexp)
5892 (2 font-lock-variable-name-face)) 5859 ;; font-lock-function-name-face 'default) nil t))
5893 ;;("\\([smy]\\|tr\\)\\([^a-z_A-Z0-9]\\)\\(\\([^\n\\]*||\\)\\)\\2") 5860 ))
5894 ;;; Too much noise from \s* @s[ and friends
5895 ;;("\\(\\<\\([msy]\\|tr\\)[ \t]*\\([^ \t\na-zA-Z0-9_]\\)\\|\\(/\\)\\)"
5896 ;;(3 font-lock-function-name-face t t)
5897 ;;(4
5898 ;; (if (cperl-slash-is-regexp)
5899 ;; font-lock-function-name-face 'default) nil t))
5900 )))
5901 (if cperl-highlight-variables-indiscriminately 5861 (if cperl-highlight-variables-indiscriminately
5902 (setq t-font-lock-keywords-1 5862 (setq t-font-lock-keywords-1
5903 (append t-font-lock-keywords-1 5863 (append t-font-lock-keywords-1
@@ -5992,13 +5952,6 @@ indentation and initial hashes. Behaves usually outside of comment."
5992 ;; Do it the dull way, without choose-color 5952 ;; Do it the dull way, without choose-color
5993 (defvar cperl-guessed-background nil 5953 (defvar cperl-guessed-background nil
5994 "Display characteristics as guessed by cperl.") 5954 "Display characteristics as guessed by cperl.")
5995 ;; (or (fboundp 'x-color-defined-p)
5996 ;; (defalias 'x-color-defined-p
5997 ;; (cond ((fboundp 'color-defined-p) 'color-defined-p)
5998 ;; ;; XEmacs >= 19.12
5999 ;; ((fboundp 'valid-color-name-p) 'valid-color-name-p)
6000 ;; ;; XEmacs 19.11
6001 ;; (t 'x-valid-color-name-p))))
6002 (cperl-force-face font-lock-constant-face 5955 (cperl-force-face font-lock-constant-face
6003 "Face for constant and label names") 5956 "Face for constant and label names")
6004 (cperl-force-face font-lock-variable-name-face 5957 (cperl-force-face font-lock-variable-name-face
@@ -6064,16 +6017,7 @@ indentation and initial hashes. Behaves usually outside of comment."
6064 (let ((background 6017 (let ((background
6065 (if (boundp 'font-lock-background-mode) 6018 (if (boundp 'font-lock-background-mode)
6066 font-lock-background-mode 6019 font-lock-background-mode
6067 'light)) 6020 'light)))
6068 ;; (face-list (and (fboundp 'face-list) (face-list)))
6069 )
6070 ;; (fset 'cperl-is-face
6071 ;; (cond ((fboundp 'find-face)
6072 ;; (symbol-function 'find-face))
6073 ;; (face-list
6074 ;; (function (lambda (face) (member face face-list))))
6075 ;; (t
6076 ;; (function (lambda (face) (boundp face))))))
6077 (defvar cperl-guessed-background 6021 (defvar cperl-guessed-background
6078 (if (and (boundp 'font-lock-display-type) 6022 (if (and (boundp 'font-lock-display-type)
6079 (eq font-lock-display-type 'grayscale)) 6023 (eq font-lock-display-type 'grayscale))
@@ -6112,40 +6056,40 @@ indentation and initial hashes. Behaves usually outside of comment."
6112 (if (x-color-defined-p "orchid1") 6056 (if (x-color-defined-p "orchid1")
6113 "orchid1" 6057 "orchid1"
6114 "orange"))))) 6058 "orange")))))
6115;;; (if (cperl-is-face 'font-lock-other-emphasized-face) nil 6059 ;; (if (cperl-is-face 'font-lock-other-emphasized-face) nil
6116;;; (copy-face 'bold-italic 'font-lock-other-emphasized-face) 6060 ;; (copy-face 'bold-italic 'font-lock-other-emphasized-face)
6117;;; (cond 6061 ;; (cond
6118;;; ((eq background 'light) 6062 ;; ((eq background 'light)
6119;;; (set-face-background 'font-lock-other-emphasized-face 6063 ;; (set-face-background 'font-lock-other-emphasized-face
6120;;; (if (x-color-defined-p "lightyellow2") 6064 ;; (if (x-color-defined-p "lightyellow2")
6121;;; "lightyellow2" 6065 ;; "lightyellow2"
6122;;; (if (x-color-defined-p "lightyellow") 6066 ;; (if (x-color-defined-p "lightyellow")
6123;;; "lightyellow" 6067 ;; "lightyellow"
6124;;; "light yellow")))) 6068 ;; "light yellow"))))
6125;;; ((eq background 'dark) 6069 ;; ((eq background 'dark)
6126;;; (set-face-background 'font-lock-other-emphasized-face 6070 ;; (set-face-background 'font-lock-other-emphasized-face
6127;;; (if (x-color-defined-p "navy") 6071 ;; (if (x-color-defined-p "navy")
6128;;; "navy" 6072 ;; "navy"
6129;;; (if (x-color-defined-p "darkgreen") 6073 ;; (if (x-color-defined-p "darkgreen")
6130;;; "darkgreen" 6074 ;; "darkgreen"
6131;;; "dark green")))) 6075 ;; "dark green"))))
6132;;; (t (set-face-background 'font-lock-other-emphasized-face "gray90")))) 6076 ;; (t (set-face-background 'font-lock-other-emphasized-face "gray90"))))
6133;;; (if (cperl-is-face 'font-lock-emphasized-face) nil 6077 ;; (if (cperl-is-face 'font-lock-emphasized-face) nil
6134;;; (copy-face 'bold 'font-lock-emphasized-face) 6078 ;; (copy-face 'bold 'font-lock-emphasized-face)
6135;;; (cond 6079 ;; (cond
6136;;; ((eq background 'light) 6080 ;; ((eq background 'light)
6137;;; (set-face-background 'font-lock-emphasized-face 6081 ;; (set-face-background 'font-lock-emphasized-face
6138;;; (if (x-color-defined-p "lightyellow2") 6082 ;; (if (x-color-defined-p "lightyellow2")
6139;;; "lightyellow2" 6083 ;; "lightyellow2"
6140;;; "lightyellow"))) 6084 ;; "lightyellow")))
6141;;; ((eq background 'dark) 6085 ;; ((eq background 'dark)
6142;;; (set-face-background 'font-lock-emphasized-face 6086 ;; (set-face-background 'font-lock-emphasized-face
6143;;; (if (x-color-defined-p "navy") 6087 ;; (if (x-color-defined-p "navy")
6144;;; "navy" 6088 ;; "navy"
6145;;; (if (x-color-defined-p "darkgreen") 6089 ;; (if (x-color-defined-p "darkgreen")
6146;;; "darkgreen" 6090 ;; "darkgreen"
6147;;; "dark green")))) 6091 ;; "dark green"))))
6148;;; (t (set-face-background 'font-lock-emphasized-face "gray90")))) 6092 ;; (t (set-face-background 'font-lock-emphasized-face "gray90"))))
6149 (if (cperl-is-face 'font-lock-variable-name-face) nil 6093 (if (cperl-is-face 'font-lock-variable-name-face) nil
6150 (copy-face 'italic 'font-lock-variable-name-face)) 6094 (copy-face 'italic 'font-lock-variable-name-face))
6151 (if (cperl-is-face 'font-lock-constant-face) nil 6095 (if (cperl-is-face 'font-lock-constant-face) nil
@@ -6194,7 +6138,7 @@ Style of printout regulated by the variable `cperl-ps-print-face-properties'."
6194 (require 'ps-print) ; To get ps-print-face-extension-alist 6138 (require 'ps-print) ; To get ps-print-face-extension-alist
6195 (let ((ps-print-color-p t) 6139 (let ((ps-print-color-p t)
6196 (ps-print-face-extension-alist ps-print-face-extension-alist)) 6140 (ps-print-face-extension-alist ps-print-face-extension-alist))
6197 (cperl-ps-extend-face-list cperl-ps-print-face-properties) 6141 (ps-extend-face-list cperl-ps-print-face-properties)
6198 (ps-print-buffer-with-faces file))) 6142 (ps-print-buffer-with-faces file)))
6199 6143
6200;; (defun cperl-ps-print-init () 6144;; (defun cperl-ps-print-init ()
@@ -7171,8 +7115,7 @@ One may build such TAGS files from CPerl mode menu."
7171 (setq update 7115 (setq update
7172 ;; (imenu-choose-buffer-index "Packages: " (nth 2 cperl-hierarchy)) 7116 ;; (imenu-choose-buffer-index "Packages: " (nth 2 cperl-hierarchy))
7173 (if (if (fboundp 'display-popup-menus-p) 7117 (if (if (fboundp 'display-popup-menus-p)
7174 (let ((f 'display-popup-menus-p)) 7118 (display-popup-menus-p)
7175 (funcall f))
7176 window-system) 7119 window-system)
7177 (x-popup-menu t (nth 2 cperl-hierarchy)) 7120 (x-popup-menu t (nth 2 cperl-hierarchy))
7178 (require 'tmm) 7121 (require 'tmm)
@@ -8529,7 +8472,7 @@ the appropriate statement modifier."
8529 :type 'file 8472 :type 'file
8530 :group 'cperl) 8473 :group 'cperl)
8531 8474
8532;;; By Nick Roberts <Nick.Roberts@src.bae.co.uk> (with changes) 8475;; By Nick Roberts <Nick.Roberts@src.bae.co.uk> (with changes)
8533(defun cperl-pod-to-manpage () 8476(defun cperl-pod-to-manpage ()
8534 "Create a virtual manpage in Emacs from the Perl Online Documentation." 8477 "Create a virtual manpage in Emacs from the Perl Online Documentation."
8535 (interactive) 8478 (interactive)
@@ -8546,7 +8489,7 @@ the appropriate statement modifier."
8546 (format (cperl-pod2man-build-command) pod2man-args)) 8489 (format (cperl-pod2man-build-command) pod2man-args))
8547 'Man-bgproc-sentinel))))) 8490 'Man-bgproc-sentinel)))))
8548 8491
8549;;; Updated version by him too 8492;; Updated version by him too
8550(defun cperl-build-manpage () 8493(defun cperl-build-manpage ()
8551 "Create a virtual manpage in Emacs from the POD in the file." 8494 "Create a virtual manpage in Emacs from the POD in the file."
8552 (interactive) 8495 (interactive)
@@ -8619,7 +8562,7 @@ a result of qr//, this is not a performance hit), t for the rest."
8619 (if pp (goto-char pp) 8562 (if pp (goto-char pp)
8620 (message "No more interpolated REx")))) 8563 (message "No more interpolated REx"))))
8621 8564
8622;;; Initial version contributed by Trey Belew 8565;; Initial version contributed by Trey Belew
8623(defun cperl-here-doc-spell () 8566(defun cperl-here-doc-spell ()
8624 "Spell-check HERE-documents in the Perl buffer. 8567 "Spell-check HERE-documents in the Perl buffer.
8625If a region is highlighted, restricts to the region." 8568If a region is highlighted, restricts to the region."
@@ -8668,7 +8611,7 @@ function returns nil."
8668 (setq cont (funcall func pos posend prop))) 8611 (setq cont (funcall func pos posend prop)))
8669 (setq pos posend))))) 8612 (setq pos posend)))))
8670 8613
8671;;; Based on code by Masatake YAMATO: 8614;; Based on code by Masatake YAMATO:
8672(defun cperl-get-here-doc-region (&optional pos pod) 8615(defun cperl-get-here-doc-region (&optional pos pod)
8673 "Return HERE document region around the point. 8616 "Return HERE document region around the point.
8674Return nil if the point is not in a HERE document region. If POD is non-nil, 8617Return nil if the point is not in a HERE document region. If POD is non-nil,
@@ -8857,7 +8800,7 @@ do extra unwind via `cperl-unwind-to-safe'."
8857 (font-lock-default-fontify-region beg end loudly)) 8800 (font-lock-default-fontify-region beg end loudly))
8858 8801
8859(defvar cperl-d-l nil) 8802(defvar cperl-d-l nil)
8860(defvar edebug-backtrace-buffer) 8803(defvar edebug-backtrace-buffer) ;FIXME: Why?
8861(defun cperl-fontify-syntaxically (end) 8804(defun cperl-fontify-syntaxically (end)
8862 ;; Some vars for debugging only 8805 ;; Some vars for debugging only
8863 ;; (message "Syntaxifying...") 8806 ;; (message "Syntaxifying...")