jrockway / cperl-mode

cperl-mode with 5.10 fixes, mx-declare support, perl6 support, etc.
102 stars 33 forks source link

Syntax highlighting confused with division of postincrement #45

Closed choroba closed 4 years ago

choroba commented 7 years ago

/ is highlighted as a start of a regex instead of division after ++ or --. The rest of the code is highlighted wrongly.

screenshot from 2017-09-13 11-55-30

renormalist commented 6 years ago

Sigh, that magic slash.

I just know I once debugged a similar problem with variables named $y and slashes in a non-regex context but to cperl looking like y/// (the alternative syntax for tr///) -- and lost the battle.

Patches welcome. :-)

choroba commented 5 years ago

I was able to identify the place that changes the behaviour, but I can't find a way to fix it. For example, the following fixes division, but breaks matching:

screenshot from 2018-10-12 22-56-57

modified   cperl-mode.el
@@ -4126,8 +4126,8 @@ the sections using `cperl-pod-head-face', `cperl-pod-face',
                (or (memq (preceding-char)
                      (append (if (memq c '(?\? ?\<))
                              ;; $a++ ? 1 : 2
-                             "~{(=|&*!,;:["
-                           "~{(=|&+-*!,;:[") nil))
+                             "~{(=|&+-*!,;:["
+                           "~{(=|&*!,;:[") nil))
                    (and (eq (preceding-char) ?\})
                     (cperl-after-block-p (point-min)))
                    (and (eq (char-syntax (preceding-char)) ?w)
choroba commented 4 years ago

Fixed by #55