aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/progmodes/cperl-mode.el86
1 files changed, 39 insertions, 47 deletions
diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el
index 1a2ad15f5b2..5b3395b77d2 100644
--- a/lisp/progmodes/cperl-mode.el
+++ b/lisp/progmodes/cperl-mode.el
@@ -2710,7 +2710,7 @@ PRESTART is the position basing on which START was found."
2710(defun cperl-beginning-of-property (p prop &optional lim) 2710(defun cperl-beginning-of-property (p prop &optional lim)
2711 "Given that P has a property PROP, find where the property starts. 2711 "Given that P has a property PROP, find where the property starts.
2712Will not look before LIM." 2712Will not look before LIM."
2713;;; XXXX What to do at point-max??? 2713;; XXXX What to do at point-max???
2714 (or (previous-single-property-change (cperl-1+ p) prop lim) 2714 (or (previous-single-property-change (cperl-1+ p) prop lim)
2715 (point-min)) 2715 (point-min))
2716 ;; (cond ((eq p (point-min)) 2716 ;; (cond ((eq p (point-min))
@@ -3061,7 +3061,7 @@ and closing parentheses and brackets."
3061 (error nil)) 3061 (error nil))
3062 (current-column)) 3062 (current-column))
3063 ((eq 'indentable (elt i 0)) ; Indenter for REGEXP qw() etc 3063 ((eq 'indentable (elt i 0)) ; Indenter for REGEXP qw() etc
3064 (cond ;;; [indentable terminator start-pos is-block] 3064 (cond ; [indentable terminator start-pos is-block]
3065 ((eq 'terminator (elt i 1)) ; Lone terminator of "indentable string" 3065 ((eq 'terminator (elt i 1)) ; Lone terminator of "indentable string"
3066 (goto-char (elt i 2)) ; After opening parens 3066 (goto-char (elt i 2)) ; After opening parens
3067 (1- (current-column))) 3067 (1- (current-column)))
@@ -3948,8 +3948,6 @@ recursive calls in starting lines of here-documents."
3948 "\\|" 3948 "\\|"
3949 ;; Second variant: Identifier or \ID (same as 'ID') 3949 ;; Second variant: Identifier or \ID (same as 'ID')
3950 "\\\\?\\(\\([a-zA-Z_][a-zA-Z_0-9]*\\)\\)" ; 5 + 1, 6 + 1 3950 "\\\\?\\(\\([a-zA-Z_][a-zA-Z_0-9]*\\)\\)" ; 5 + 1, 6 + 1
3951 ;; Do not have <<= or << 30 or <<30 or << $blah.
3952 ;; "\\([^= \t0-9$@%&]\\|[ \t]+[^ \t\n0-9$@%&]\\)" ; 6 + 1
3953 "\\)" 3951 "\\)"
3954 "\\|" 3952 "\\|"
3955 ;; -------- format capture groups 8-9 3953 ;; -------- format capture groups 8-9
@@ -4137,20 +4135,10 @@ recursive calls in starting lines of here-documents."
4137 ;; Here document 4135 ;; Here document
4138 ;; We can do many here-per-line; 4136 ;; We can do many here-per-line;
4139 ;; but multiline quote on the same line as <<HERE confuses us... 4137 ;; but multiline quote on the same line as <<HERE confuses us...
4140 ;; ;; One extra () before this: 4138 ;; One extra () before this:
4141 ;;"<<"
4142 ;; "<<\\(~?\\)" ; HERE-DOC, indented-p = capture 2 4139 ;; "<<\\(~?\\)" ; HERE-DOC, indented-p = capture 2
4143 ;; ;; First variant "BLAH" or just ``. 4140 ;; First variant "BLAH" or just ``: capture groups 4 and 5
4144 ;; "[ \t]*" ; Yes, whitespace is allowed! 4141 ;; Second variant: Identifier or \ID: capture group 6 and 7
4145 ;; "\\([\"'`]\\)" ; 3 + 1
4146 ;; "\\([^\"'`\n]*\\)" ; 4 + 1
4147 ;; "\\4"
4148 ;; "\\|"
4149 ;; ;; Second variant: Identifier or \ID or empty
4150 ;; "\\\\?\\(\\([a-zA-Z_][a-zA-Z_0-9]*\\)?\\)" ; 5 + 1, 6 + 1
4151 ;; ;; Do not have <<= or << 30 or <<30 or << $blah.
4152 ;; ;; "\\([^= \t0-9$@%&]\\|[ \t]+[^ \t\n0-9$@%&]\\)" ; 6 + 1
4153 ;; "\\)"
4154 ((match-beginning 3) ; 2 + 1: found "<<", detect its type 4142 ((match-beginning 3) ; 2 + 1: found "<<", detect its type
4155 (let* ((matched-pos (match-beginning 0)) 4143 (let* ((matched-pos (match-beginning 0))
4156 (quoted-delim-p (if (match-beginning 6) nil t)) 4144 (quoted-delim-p (if (match-beginning 6) nil t))
@@ -4169,10 +4157,8 @@ recursive calls in starting lines of here-documents."
4169 overshoot (nth 1 here-doc-results)) 4157 overshoot (nth 1 here-doc-results))
4170 (and (nth 2 here-doc-results) 4158 (and (nth 2 here-doc-results)
4171 (setq warning-message (nth 2 here-doc-results))))))) 4159 (setq warning-message (nth 2 here-doc-results)))))))
4172 ;; format 4160 ;; format capture groups 8-9
4173 ((match-beginning 8) 4161 ((match-beginning 8)
4174 ;; 1+6=7 extra () before this:
4175 ;;"^[ \t]*\\(format\\)[ \t]*\\([a-zA-Z0-9_]+\\)?[ \t]*=[ \t]*$"
4176 (setq b (point) 4162 (setq b (point)
4177 name (if (match-beginning 9) ; 7 + 2 4163 name (if (match-beginning 9) ; 7 + 2
4178 (match-string-no-properties 9) ; 7 + 2 4164 (match-string-no-properties 9) ; 7 + 2
@@ -4219,12 +4205,9 @@ recursive calls in starting lines of here-documents."
4219 (if (> (point) max) 4205 (if (> (point) max)
4220 (setq tmpend tb)) 4206 (setq tmpend tb))
4221 (put-text-property b (point) 'syntax-type 'format)) 4207 (put-text-property b (point) 'syntax-type 'format))
4222 ;; qq-like String or Regexp: 4208 ;; quotelike operator or regexp: capture groups 10 or 11
4209 ;; matches some false postives, to be eliminated here
4223 ((or (match-beginning 10) (match-beginning 11)) 4210 ((or (match-beginning 10) (match-beginning 11))
4224 ;; 1+6+2=9 extra () before this:
4225 ;; "\\<\\(q[wxqr]?\\|[msy]\\|tr\\)\\>"
4226 ;; "\\|"
4227 ;; "\\([/<]\\)" ; /blah/ or <file*glob>
4228 (setq b1 (if (match-beginning 10) 10 11) 4211 (setq b1 (if (match-beginning 10) 10 11)
4229 argument (buffer-substring 4212 argument (buffer-substring
4230 (match-beginning b1) (match-end b1)) 4213 (match-beginning b1) (match-end b1))
@@ -4281,13 +4264,23 @@ recursive calls in starting lines of here-documents."
4281 (and (eq (char-syntax (preceding-char)) ?w) 4264 (and (eq (char-syntax (preceding-char)) ?w)
4282 (progn 4265 (progn
4283 (forward-sexp -1) 4266 (forward-sexp -1)
4284;; After these keywords `/' starts a RE. One should add all the 4267 ;; After these keywords `/'
4285;; functions/builtins which expect an argument, but ... 4268 ;; starts a RE. One should
4269 ;; add all the
4270 ;; functions/builtins which
4271 ;; expect an argument, but
4272 ;; ...
4286 (and 4273 (and
4287 (not (memq (preceding-char) 4274 (not (memq (preceding-char)
4288 '(?$ ?@ ?& ?%))) 4275 '(?$ ?@ ?& ?%)))
4289 (looking-at 4276 (looking-at
4290 "\\(while\\|if\\|unless\\|until\\|for\\(each\\)?\\|and\\|or\\|not\\|xor\\|split\\|grep\\|map\\|print\\|say\\|return\\)\\>")))) 4277 (regexp-opt
4278 '("while" "if" "unless"
4279 "until" "for" "foreach"
4280 "and" "or" "not"
4281 "xor" "split" "grep" "map"
4282 "print" "say" "return")
4283 'symbols)))))
4291 (and (eq (preceding-char) ?.) 4284 (and (eq (preceding-char) ?.)
4292 (eq (char-after (- (point) 2)) ?.)) 4285 (eq (char-after (- (point) 2)) ?.))
4293 (bobp)) 4286 (bobp))
@@ -4487,12 +4480,13 @@ recursive calls in starting lines of here-documents."
4487 (1- e) e 'face my-cperl-delimiters-face))) 4480 (1- e) e 'face my-cperl-delimiters-face)))
4488 (if (and is-REx cperl-regexp-scan) 4481 (if (and is-REx cperl-regexp-scan)
4489 ;; Process RExen: embedded comments, charclasses and ] 4482 ;; Process RExen: embedded comments, charclasses and ]
4490;;;/\3333\xFg\x{FFF}a\ppp\PPP\qqq\C\99f(?{ foo })(??{ foo })/; 4483 ;; Examples:
4491;;;/a\.b[^a[:ff:]b]x$ab->$[|$,$ab->[cd]->[ef]|$ab[xy].|^${a,b}{c,d}/; 4484 ;;/\3333\xFg\x{FFF}a\ppp\PPP\qqq\C\99f(?{ foo })(??{ foo })/;
4492;;;/(?<=foo)(?<!bar)(x)(?:$ab|\$\/)$|\\\b\x888\776\[\:$/xxx; 4485 ;;/a\.b[^a[:ff:]b]x$ab->$[|$,$ab->[cd]->[ef]|$ab[xy].|^${a,b}{c,d}/;
4493;;;m?(\?\?{b,a})? + m/(??{aa})(?(?=xx)aa|bb)(?#aac)/; 4486 ;;/(?<=foo)(?<!bar)(x)(?:$ab|\$\/)$|\\\b\x888\776\[\:$/xxx;
4494;;;m$(^ab[c]\$)$ + m+(^ab[c]\$\+)+ + m](^ab[c\]$|.+)] + m)(^ab[c]$|.+\)); 4487 ;;m?(\?\?{b,a})? + m/(??{aa})(?(?=xx)aa|bb)(?#aac)/;
4495;;;m^a[\^b]c^ + m.a[^b]\.c.; 4488 ;;m$(^ab[c]\$)$ + m+(^ab[c]\$\+)+ + m](^ab[c\]$|.+)] + m)(^ab[c]$|.+\));
4489 ;;m^a[\^b]c^ + m.a[^b]\.c.;
4496 (save-excursion 4490 (save-excursion
4497 (goto-char (1+ b)) 4491 (goto-char (1+ b))
4498 ;; First 4492 ;; First
@@ -4556,8 +4550,6 @@ recursive calls in starting lines of here-documents."
4556 "\\?([0-9]+)" ; (?(1)foo|bar) 4550 "\\?([0-9]+)" ; (?(1)foo|bar)
4557 "\\|" 4551 "\\|"
4558 "\\?<[=!]" 4552 "\\?<[=!]"
4559 ;;;"\\|"
4560 ;;; "\\?"
4561 "\\)?" 4553 "\\)?"
4562 "\\)" 4554 "\\)"
4563 "\\|" 4555 "\\|"
@@ -4702,8 +4694,8 @@ recursive calls in starting lines of here-documents."
4702 (setq REx-subgr-end qtag) ;End smart-highlighted 4694 (setq REx-subgr-end qtag) ;End smart-highlighted
4703 ;; Apparently, I can't put \] into a charclass 4695 ;; Apparently, I can't put \] into a charclass
4704 ;; in m]]: m][\\\]\]] produces [\\]] 4696 ;; in m]]: m][\\\]\]] produces [\\]]
4705;;; POSIX? [:word:] [:^word:] only inside [] 4697 ;; POSIX? [:word:] [:^word:] only inside []
4706;;; "\\=\\(\\\\.\\|[^][\\]\\|\\[:\\^?\sw+:]\\|\\[[^:]\\)*]") 4698 ;; "\\=\\(\\\\.\\|[^][\\]\\|\\[:\\^?\sw+:]\\|\\[[^:]\\)*]")
4707 (while ; look for unescaped ] 4699 (while ; look for unescaped ]
4708 (and argument 4700 (and argument
4709 (re-search-forward 4701 (re-search-forward
@@ -4891,7 +4883,6 @@ recursive calls in starting lines of here-documents."
4891 ;; "\\(\\<sub[ \t\n\f]+\\|[&*$@%]\\)[a-zA-Z0-9_]*'") 4883 ;; "\\(\\<sub[ \t\n\f]+\\|[&*$@%]\\)[a-zA-Z0-9_]*'")
4892 ((match-beginning 19) ; old $abc'efg syntax 4884 ((match-beginning 19) ; old $abc'efg syntax
4893 (setq bb (match-end 0)) 4885 (setq bb (match-end 0))
4894 ;;;(if (nth 3 state) nil ; in string
4895 (put-text-property (1- bb) bb 'syntax-table cperl-st-word) 4886 (put-text-property (1- bb) bb 'syntax-table cperl-st-word)
4896 (goto-char bb)) 4887 (goto-char bb))
4897 ;; 1+6+2+1+1+6+1+1=19 extra () before this: 4888 ;; 1+6+2+1+1+6+1+1=19 extra () before this:
@@ -4908,7 +4899,7 @@ recursive calls in starting lines of here-documents."
4908 (setq bb (match-end 0)) 4899 (setq bb (match-end 0))
4909 (goto-char b) 4900 (goto-char b)
4910 (skip-chars-backward "\\\\") 4901 (skip-chars-backward "\\\\")
4911 ;;;(setq i2 (= (% (skip-chars-backward "\\\\") 2) -1)) 4902 ;; (setq i2 (= (% (skip-chars-backward "\\\\") 2) -1))
4912 (cperl-modify-syntax-type b cperl-st-punct) 4903 (cperl-modify-syntax-type b cperl-st-punct)
4913 (goto-char bb)) 4904 (goto-char bb))
4914 (t (error "Error in regexp of the sniffer"))) 4905 (t (error "Error in regexp of the sniffer")))
@@ -6053,9 +6044,9 @@ functions (which they are not). Inherits from `default'.")
6053 (group (eval cperl--basic-identifier-rx)))) 6044 (group (eval cperl--basic-identifier-rx))))
6054 1 font-lock-constant-face) 6045 1 font-lock-constant-face)
6055 ;; Uncomment to get perl-mode-like vars 6046 ;; Uncomment to get perl-mode-like vars
6056 ;;; '("[$*]{?\\(\\sw+\\)" 1 font-lock-variable-name-face) 6047 ;; '("[$*]{?\\(\\sw+\\)" 1 font-lock-variable-name-face)
6057 ;;; '("\\([@%]\\|\\$#\\)\\(\\sw+\\)" 6048 ;; '("\\([@%]\\|\\$#\\)\\(\\sw+\\)"
6058 ;;; (2 (cons font-lock-variable-name-face '(underline)))) 6049 ;; (2 (cons font-lock-variable-name-face '(underline))))
6059 ;; 1=my_etc, 2=white? 3=(+white? 4=white? 5=var 6050 ;; 1=my_etc, 2=white? 3=(+white? 4=white? 5=var
6060 ;; -------- variable declarations 6051 ;; -------- variable declarations
6061 ;; (matcher (subexp facespec) ... 6052 ;; (matcher (subexp facespec) ...
@@ -6196,13 +6187,13 @@ functions (which they are not). Inherits from `default'.")
6196 (,(rx (group-n 1 (group-n 2 (or (in "@%") "$#")) 6187 (,(rx (group-n 1 (group-n 2 (or (in "@%") "$#"))
6197 (eval cperl--normal-identifier-rx))) 6188 (eval cperl--normal-identifier-rx)))
6198 1 6189 1
6199;; ("\\(\\([@%]\\|\\$#\\)[a-zA-Z_:][a-zA-Z0-9_:]*\\)" 1 6190 ;; ("\\(\\([@%]\\|\\$#\\)[a-zA-Z_:][a-zA-Z0-9_:]*\\)" 1
6200 (if (eq (char-after (match-beginning 2)) ?%) 6191 (if (eq (char-after (match-beginning 2)) ?%)
6201 'cperl-hash-face 6192 'cperl-hash-face
6202 'cperl-array-face) 6193 'cperl-array-face)
6203 nil) 6194 nil)
6204;;("\\([smy]\\|tr\\)\\([^a-z_A-Z0-9]\\)\\(\\([^\n\\]*||\\)\\)\\2") 6195 ;;("\\([smy]\\|tr\\)\\([^a-z_A-Z0-9]\\)\\(\\([^\n\\]*||\\)\\)\\2")
6205;;; Too much noise from \s* @s[ and friends 6196 ;; Too much noise from \s* @s[ and friends
6206 ;;("\\(\\<\\([msy]\\|tr\\)[ \t]*\\([^ \t\na-zA-Z0-9_]\\)\\|\\(/\\)\\)" 6197 ;;("\\(\\<\\([msy]\\|tr\\)[ \t]*\\([^ \t\na-zA-Z0-9_]\\)\\|\\(/\\)\\)"
6207 ;;(3 font-lock-function-name-face t t) 6198 ;;(3 font-lock-function-name-face t t)
6208 ;;(4 6199 ;;(4
@@ -8929,7 +8920,8 @@ do extra unwind via `cperl-unwind-to-safe'."
8929 8920
8930(defun cperl-fontify-update-bad (end) 8921(defun cperl-fontify-update-bad (end)
8931 ;; Since fontification happens with different region than syntaxification, 8922 ;; Since fontification happens with different region than syntaxification,
8932 ;; do to the end of buffer, not to END;;; likewise, start earlier if needed 8923 ;; do to the end of buffer, not to END
8924 ;; likewise, start earlier if needed
8933 (let* ((pos (point)) (prop (get-text-property pos 'cperl-postpone)) posend) 8925 (let* ((pos (point)) (prop (get-text-property pos 'cperl-postpone)) posend)
8934 (if prop 8926 (if prop
8935 (setq pos (or (cperl-beginning-of-property 8927 (setq pos (or (cperl-beginning-of-property