emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

perl-mode "::" as word character [patch]


From: Pandora
Subject: perl-mode "::" as word character [patch]
Date: Fri, 29 Apr 2005 23:47:18 -0700
User-agent: Mozilla Thunderbird 1.0 (X11/20041206)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Just dropping in for a teeny bit.  I was studying font-lock innards the
other day and noticed that the perl-mode font lock does a lot of
wrangling around the '::' sequence.  That's what's used in perl to
divide package names from package members.  But instead of sticking
\\(::\\sw\\)*s in after every \\sw, I noticed it'd be much simpler just
to consider the double colon (NOT the single colon) to be a \\sw
character.  Seems pretty cut and dried, since :: was only introduced to
perl as a namespace separator, and can be wholly considered as if it
were a word character.

Also since my experience has been that print/printf are used like
keywords, but act like functions; they could use some special
highlighting.  As for functions in general, both &\\(\\sw+\\) and
\\(\\sw+\\)( match a function name in perl, but perl-mode only
highlights the first expression as a function.

So... I went and made a patch against CVS, in case anyone else wants to
use these three quick little hacks.
Index: lisp/progmodes/perl-mode.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/perl-mode.el,v
retrieving revision 1.56
diff -r1.56 perl-mode.el
207a208
>     ;; Fontify print and printf as functions, typically w/o ()
208a210,211
>     '("\\<\\(print\\|printf\\)\\>" 1 font-lock-function-name-face)
>
210c213,214
<     '("&\\(\\sw+\\(::\\sw+\\)*\\)" 1 font-lock-function-name-face)
- ---
>     '("&\\(\\sw+\\)" 1 font-lock-function-name-face)
>     '("\\(\\sw+\\)\\s *(" 1 font-lock-function-name-face)
213,214c217,218
<     '("[$*]{?\\(\\sw+\\(::\\sw+\\)*\\)" 1 font-lock-variable-name-face)
<     '("\\(address@hidden|\\$#\\)\\(\\sw+\\(::\\sw+\\)*\\)"
- ---
>     '("[$*]{?\\(\\sw+\\)" 1 font-lock-variable-name-face)
<     '("\\(address@hidden|\\$#\\)\\(\\sw+\\(::\\sw+\\)*\\)"
- ---
>     '("[$*]{?\\(\\sw+\\)" 1 font-lock-variable-name-face)
>     '("\\(address@hidden|\\$#\\)\\(\\sw+\\)"
258a263,264
>     ;; Or $PKG::member  :: is a word character, really.  c.c
>     ("\\(::\\)" (1 "w"))
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCcyn2B/meY5RuPPQRAlJeAKCruu9fvqzETQhQQTE9TV70WSTLqgCdHsDL
R1rwSw/KRWeOvYaGIzb9+iM=
=dJBg
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]