From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Pandora Newsgroups: gmane.emacs.devel Subject: Re: perl-mode "::" as word character [patch] Date: Thu, 05 May 2005 18:19:17 -0700 Message-ID: <427AC615.1000703@pacbell.net> References: <427329F6.5080508@pacbell.net> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1115343992 26670 80.91.229.2 (6 May 2005 01:46:32 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 6 May 2005 01:46:32 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri May 06 03:46:30 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DTrv6-0002j4-GJ for ged-emacs-devel@m.gmane.org; Fri, 06 May 2005 03:46:25 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DTs2i-0004uF-C0 for ged-emacs-devel@m.gmane.org; Thu, 05 May 2005 21:54:16 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DTru0-0000Lz-T9 for emacs-devel@gnu.org; Thu, 05 May 2005 21:45:17 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DTrtx-0000Ir-2R for emacs-devel@gnu.org; Thu, 05 May 2005 21:45:13 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DTrde-0007Rf-BK for emacs-devel@gnu.org; Thu, 05 May 2005 21:28:22 -0400 Original-Received: from [63.197.122.98] (helo=synx.dyndns.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DTra2-0001bx-Q7 for emacs-devel@gnu.org; Thu, 05 May 2005 21:24:39 -0400 Original-Received: from [127.0.0.1] (localhost [127.0.0.1]) by synx.dyndns.org (Postfix) with ESMTP id 3D2C020FA1E for ; Thu, 5 May 2005 18:19:18 -0700 (PDT) User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en Original-To: emacs-devel@gnu.org In-Reply-To: X-Enigmail-Version: 0.90.1.0 X-Enigmail-Supports: pgp-inline, pgp-mime X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:36740 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:36740 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. "\\(?:\\\\|\\\\)\\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. ;;'("[$@%*][#{]?\\(\\sw+\\)" 1 font-lock-variable-name-face) - '("[$*]{?\\(\\sw+\\(::\\sw+\\)*\\)" 1 font-lock-variable-name-face) - '("\\([@%]\\|\\$#\\)\\(\\sw+\\(::\\sw+\\)*\\)" + '("[$*]{?\\(\\sw+\\)" 1 font-lock-variable-name-face) + '("\\([@%]\\|\\$#\\)\\(\\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 ($$)'