GNU bug report logs - #348
perl mode color vs. /:/

Previous Next

Package: emacs;

Reported by: jidanni <at> jidanni.org

Date: Sun, 1 Jun 2008 23:15:04 UTC

Severity: normal

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (Emacs bug Tracking System)
To: jidanni <at> jidanni.org
Subject: bug#348 closed by Stefan Monnier <monnier <at> iro.umontreal.ca> (Re: 
 bug#348: perl mode color vs. /:/)
[Message part 1 (text/plain, inline)]
This is an automatic notification regarding your bug report
which was filed against the emacs package:

#348: perl mode color vs. /:/

It has been closed by Stefan Monnier <monnier <at> iro.umontreal.ca>.

Their explanation is attached below along with your original report.
If this explanation is unsatisfactory and you have not received a
better one in a separate message then please contact Stefan Monnier <monnier <at> iro.umontreal.ca> by
replying to this email.


-- 
348: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=348
Emacs Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: 348-close <at> debbugs.gnu.org
Subject: Re: bug#348: perl mode color vs. /:/
Date: Tue, 03 Jun 2008 03:19:53 -0400
>>>>> "jidanni" == jidanni  <jidanni <at> jidanni.org> writes:

> Perl mode needs an "m" here to get the colors right.
> Cperl mode has no problem. emacs-version "22.2.1".
> $ cat r.pl
> m/.*:dndli([^:]+)10:/; my $tmp=$1; #color OK
>  /.*:dndli([^:]+)10:/; my $tmp=$1; #color stuck.
> //;#to recover color, only to demonstrate that
> for(split /:/){print; print "\n";} #color stuck again.
> #By the way, add make the "OK" in the comment above become "OK." and
> #color gets unstuck!
> $ emacs -Q r.pl

Thanks.  I've installed the patch below which seems to fix
your examples.  Hopefully it doesn't make things worse in too many
other circumstances.


        Stefan


Index: lisp/progmodes/perl-mode.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/progmodes/perl-mode.el,v
retrieving revision 1.78
diff -u -r1.78 perl-mode.el
--- lisp/progmodes/perl-mode.el	6 May 2008 07:18:35 -0000	1.78
+++ lisp/progmodes/perl-mode.el	3 Jun 2008 07:18:03 -0000
@@ -252,7 +252,7 @@
 ;; <file*glob>
 (defvar perl-font-lock-syntactic-keywords
   ;; TODO: here-documents ("<<\\(\\sw\\|['\"]\\)")
-  '(;; Turn POD into b-style comments
+  `(;; Turn POD into b-style comments
     ("^\\(=\\)\\sw" (1 "< b"))
     ("^=cut[ \t]*\\(\n\\)" (1 "> b"))
     ;; Catch ${ so that ${var} doesn't screw up indentation.
@@ -267,12 +267,27 @@
     ;; Be careful not to match "sub { (...) ... }".
     ("\\<sub\\(?:[[:space:]]+[^{}[:punct:][:space:]]+\\)?[[:space:]]*(\\([^)]+\\))"
      1 '(1))
-    ;; Regexp and funny quotes.
-    ("\\(?:[?:.,;=!~({[]\\|\\(^\\)\\)[ \t\n]*\\(/\\)"
+    ;; Regexp and funny quotes.  Distinguishing a / that starts a regexp
+    ;; match from the division operator is ...interesting.
+    ;; Basically, / is a regexp match if it's preceded by an infix operator
+    ;; (or some similar separator), or by one of the special keywords
+    ;; corresponding to builtin functions that can take their first arg
+    ;; without parentheses.  Of course, that presume we're looking at the
+    ;; *opening* slash.  We can mis-match the closing ones, because they are
+    ;; treated separately later in
+    ;; perl-font-lock-special-syntactic-constructs.
+    (,(concat "\\(?:\\(?:\\(?:^\\|[^$@&%[:word:]]\\)"
+              (regexp-opt '("split" "if" "unless" "until" "while" "split"
+                            "grep" "map" "not" "or" "and"))
+              "\\)\\|[?:.,;=!~({[]\\|\\(^\\)\\)[ \t\n]*\\(/\\)")
      (2 (if (and (match-end 1)
                  (save-excursion
                    (goto-char (match-end 1))
-                   (skip-chars-backward " \t\n")
+                   ;; Not 100% correct since we haven't finished setting up
+                   ;; the syntax-table before point, but better than nothing.
+                   (forward-comment (- (point-max)))
+                   (put-text-property (point) (match-end 2)
+                                      'jit-lock-multiline t)
                    (not (memq (char-before)
                               '(?? ?: ?. ?, ?\; ?= ?! ?~ ?\( ?\[)))))
             nil ;; A division sign instead of a regexp-match.

[Message part 3 (message/rfc822, inline)]
From: jidanni <at> jidanni.org
To: bug-gnu-emacs <at> gnu.org
Subject: perl mode color vs. /:/
Date: Mon, 02 Jun 2008 04:47:28 +0800
Perl mode needs an "m" here to get the colors right.
Cperl mode has no problem. emacs-version "22.2.1".
$ cat r.pl
m/.*:dndli([^:]+)10:/; my $tmp=$1; #color OK
 /.*:dndli([^:]+)10:/; my $tmp=$1; #color stuck.
//;#to recover color, only to demonstrate that
for(split /:/){print; print "\n";} #color stuck again.
#By the way, add make the "OK" in the comment above become "OK." and
#color gets unstuck!
$ emacs -Q r.pl




This bug report was last modified 16 years and 352 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.