[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: perl-mode "::" as word character [patch]
From: |
Pandora |
Subject: |
Re: perl-mode "::" as word character [patch] |
Date: |
Thu, 05 May 2005 18:19:17 -0700 |
User-agent: |
Mozilla Thunderbird 1.0 (X11/20041206) |
Stefan Monnier wrote:
> Word syntax is clearly wrong. Symbol syntax (i.e. "_") OTOH sounds right.
I would be happy to agree. But \\s_ doens't seem to match anything, and
\\sw doesn't match anything designated as ("\\(::\\)" (1 "_")). It only
matches "w". Word syntax may be "wrong" for English, but in perl ':' is
equivalent to A or q or whatever.
> I don't think function calls should be highlighted, only function definitions.
> But that's just me.
I'll go with the precedent, but if it's better without, you can remove
both the 'starting-with-&' and the 'followed-by-a-(' expressions.
They're both pretty equivocably defined as function calls, not function
definitions, in perl.
A more serious concern though, is the foreach construct:
foreach my $var (@list) {...}
That assigns the members of list to variable var one after the other.
My attempt to match 'followed-by-a-(' considers everything left of
(@list) to be a function call. I'm not good enough with emacs regexps
and font-lock to make this exception, so I'll leave my ...( function
highlighting commented out.
"\\(?:\\<foreach\\>\\|\\<for\\>\\)\\s *\\(\\sw+\\)\\s *(" and... then
how to make that /not/ highlighted, while every other
"\\(\\sw+\\)\\s *(" gets highlighted as a function call?
> Could you (re)send a context diff rather than plain diff?
Um, sure.
Index: lisp/progmodes/perl-mode.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/perl-mode.el,v
retrieving revision 1.56
diff -a -u -r1.56 perl-mode.el
--- lisp/progmodes/perl-mode.el 22 Mar 2005 19:43:13 -0000 1.56
+++ lisp/progmodes/perl-mode.el 6 May 2005 01:07:38 -0000
@@ -205,13 +205,18 @@
;;
;; Fontify local and my keywords as types.
'("\\<\\(local\\|my\\)\\>" . font-lock-type-face)
+ ;; Fontify print and printf as functions, typically w/o ()
;;
+ '("\\<\\(print\\|printf\\)\\>" 1 font-lock-function-name-face)
+
;; Fontify function, variable and file name references.
- '("&\\(\\sw+\\(::\\sw+\\)*\\)" 1 font-lock-function-name-face)
+ '("&\\(\\sw+\\)" 1 font-lock-function-name-face)
+;; How to handle foreach $var (...) {} ?
+;; '("\\(\\sw+\\)\\s *(" 1 font-lock-function-name-face)
;; Additionally underline non-scalar variables. Maybe this is a
bad idea.
;;'("address@hidden(\\sw+\\)" 1 font-lock-variable-name-face)
- '("[$*]{?\\(\\sw+\\(::\\sw+\\)*\\)" 1 font-lock-variable-name-face)
- '("\\(address@hidden|\\$#\\)\\(\\sw+\\(::\\sw+\\)*\\)"
+ '("[$*]{?\\(\\sw+\\)" 1 font-lock-variable-name-face)
+ '("\\(address@hidden|\\$#\\)\\(\\sw+\\)"
(2 (cons font-lock-variable-name-face '(underline))))
'("<\\(\\sw+\\)>" 1 font-lock-constant-face)
;;
@@ -256,6 +261,8 @@
("\\(\\$\\)[{']" (1 ". p"))
;; Handle funny names like $DB'stop.
("\\$ ?{?^?[_a-zA-Z][_a-zA-Z0-9]*\\('\\)[_a-zA-Z]" (1 "_"))
+ ;; Or $PKG::member :: is a word character, really. c.c
+ ("\\(::\\)" (1 "w"))
;; format statements
("^[ \t]*format.*=[ \t]*\\(\n\\)" (1 '(7)))
;; Funny things in sub arg specifications like `sub myfunc ($$)'