Subject: Re: 24.1; font-lock (highlighting) bug with dollar+quote sequence ('...$')

From: Vincent Lefevre <[email-masked]>
Date: Tue, 19 Jun 2012 15:15:23 +0200

On 2012-06-19 12:23:51 +0200, Vincent Lefevre wrote:
> Open the following file with "emacs -Q <filename>":
> 
> ------------------------------------------------------------
> #!/usr/bin/env perl
> # -*- mode: cperl -*-
> 
> $foo = 'blah $ '
>   and print "$foo\n";  # OK
> 
> $foo = 'blah $'
>   and print "$foo\n";  # Incorrectly highlighted
> ------------------------------------------------------------
> 
> The first "and print ..." line is correctly highlighted, but not the
> second one. It seems that CPerl is confused by a $ at the end of a
> single-quote string literal.

The problem is due to this change in cperl-mode.el:

@@ -1832,7 +1832,13 @@
   (make-local-variable 'cperl-syntax-state)
   (setq cperl-syntax-state nil)                ; reset syntaxification cache
   (if cperl-use-syntax-table-text-property
-      (progn
+      (if (boundp 'syntax-propertize-function)
+          (progn
+            ;; Reset syntaxification cache.
+            (set (make-local-variable 'cperl-syntax-done-to) nil)
+            (set (make-local-variable 'syntax-propertize-function)
+                 (lambda (start end)
+                   (goto-char start) (cperl-fontify-syntaxically end))))
        (make-local-variable 'parse-sexp-lookup-properties)
        ;; Do not introduce variable if not needed, we check it!
        (set 'parse-sexp-lookup-properties t)

-- 
Vincent Lefèvre <[email-masked]> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)