Skip to content

Commit a419e92

Browse files
committed
; cperl-mode.el: Fix fontification error with signatures
This fixes the second issue in Bug#79269. * lisp/progmodes/cperl-mode.el (cperl-init-faces): Move handling of signatures with initializers from the "anchor" to the "anchored" matcher * test/lisp/progmodes/cperl-mode-resources/proto-and-attrs.pl (sub_7): Test case for Bug#79269, wrong face report * test/lisp/progmodes/cperl-mode-tests.el (cperl-test-fontify-attrs-and-signatures): Make sure that the test catches sub_7 for Bug#79269
1 parent 680ef7b commit a419e92

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

lisp/progmodes/cperl-mode.el

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6374,9 +6374,7 @@ functions (which they are not). Inherits from `default'.")
63746374
(sequence (eval cperl--signature-rx)
63756375
(eval cperl--ws*-rx))
63766376
;; ... or the start of a "sloppy" signature
6377-
(sequence (eval cperl--sloppy-signature-rx)
6378-
;; arbitrarily continue "a few lines"
6379-
(repeat 0 200 (not (in "{"))))
6377+
(sequence (eval cperl--sloppy-signature-rx))
63806378
;; make sure we have a reasonably
63816379
;; short match for an incomplete sub
63826380
(not (in ";{("))
@@ -6392,7 +6390,13 @@ functions (which they are not). Inherits from `default'.")
63926390
(group (eval cperl--basic-variable-rx))))
63936391
(progn
63946392
(goto-char (match-beginning 2)) ; pre-match: Back to sig
6395-
(match-end 2))
6393+
;; While typing, forward-sexp might fail with a scan error.
6394+
;; If so, stop looking for declarations at (match-end 2)
6395+
(condition-case nil
6396+
(save-excursion
6397+
(forward-sexp)
6398+
(point))
6399+
(error (match-end 2))))
63966400
nil
63976401
(1 font-lock-variable-name-face)))
63986402
;; -------- flow control

test/lisp/progmodes/cperl-mode-resources/proto-and-attrs.pl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ sub sub_6
4141
{
4242
}
4343

44+
# Braces in initializers (Bug79269)
45+
sub sub_7
46+
($foo = { },
47+
$bar //= "baz")
48+
{
49+
}
50+
4451

4552
# Part 2: Same constructs for anonymous subs
4653
# A plain named subroutine without any optional stuff

test/lisp/progmodes/cperl-mode-tests.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ attributes, prototypes and signatures."
173173
(should (equal (get-text-property (match-beginning 0) 'face)
174174
'font-lock-function-name-face))
175175
(let ((start-of-sub (match-beginning 0))
176-
(end-of-sub (save-excursion (search-forward "}") (point))))
176+
(end-of-sub (save-excursion (search-forward "}\n") (point))))
177177

178178
;; Prototypes are shown as strings
179179
(when (search-forward-regexp " ([$%@*]*) " end-of-sub t)

0 commit comments

Comments
 (0)